Add Android FAB option menu with Gooey Effect » Tell Me How - A Place for Technology Geekier

How to Add Android FAB option menu with Gooey Effect
How to Add Android FAB option menu with Gooey Effect
After google confirmation of Android Orbit will be next version of Android after Nought. Here we come with A cool Android FAB option menu with Gooey effect. You think what is Gooey effect just let see above image you will clear.
Every Android app have option menu and if it is also a major factor to make that app user friendly. And if you use some great effect in this area then your app success rate will be increase.

What this Android FAB option menu Lib cab do :

  1. Tab on each menu you get call with menu number.
  2. You can customize the number of the menu.
  3. Distance between super menu and sub men can be customize.
  4. Customize menu icon.
Source: Add Android FAB option menu with Gooey Effect » Tell Me How - A Place for Technology Geekier:

Add Chrome like Tab Switcher Android Library » Tell Me How - A Place for Technology Geekier

How to Add Chrome like Tab Switcher Android Library
How to Add Chrome like Tab Switcher Android Library
We’re all fascinated to see Tab Switcher in Android browser like Google Chrome, Opera or UC Browser and want to add that Chrome like Tab Switcher in Android. Then ChromeLikeTabSwitcher Android library is for you.
It is an Android-library, which provides a tab switcher similar to the one, which is used in the Android version of Google’s Chrome browser. It provides layouts optimized for smartphone and tablet devices.
Source:
Add Chrome like Tab Switcher Android Library » Tell Me How - A Place for Technology Geekier:

[Confirmed] : Google Android Orbit will be after Nougat » Tell Me How - A Place for Technology Geekier



Google Android Orbit
Google Android Orbit
Google has a history of giving its operating system versions fun names. And recently Google launched Android O developer preview with their features. But this time they confirmed the name of Upcoming version of Android and that is Orbit.
Google actually named its operating system after a Kit Kat bar. They follows that model and tie-up with US based sugarless chewing gum company Orbit.
Many of rumor for Android O is that it will be Oreo but Android Orbit is confirmed after meeting between Sundar Pichai and CEO of Wrigley company (Orbit gum). They introduce some other features comes in Android Orbit.
[Confirmed] : Google Android Orbit will be after Nougat » Tell Me How - A Place for Technology Geekier:

MathView Android Layout Library » Tell Me How - A Place for Technology Geekier

When i was beginner then i want to make an Android app on Math tutorial but i faced a problem to show advance Math formulas. But now if you also want to do same thing then i have a great library named Katext MathView Android Layout Library.
How to add MathView Android Layout Library
It is a KhanAcademy Katex based Library for Rendering math faster in various Android Devices. This a View which is created from extending webview. This view allows you to render latex in your android devices. It can load normal text, text with latex and latex alone. The only thing you have to make sure is your latex should be enclosed inside either $your latex formula$ or $$your latex formula$$. This will also allow you to beautify your formula text by setting color and text size.

json2view : Some important properties and types

In our all previous article we see implementation and their some example of json2view android library.

But here we see some important properties and types of json2view library which you can use in your applications.

Any View

Name Type Example
layout_width dimen {"name":"layout_width", "type":"dimen", "value":"match_parent"}
{"name":"layout_width", "type":"dimen", "value":"250dp"}
{"name":"layout_width", "type":"dimen", "value":"90%"}
layout_height dimen {"name":"layout_width", "type":"dimen", "value":"50dp"}
id ref {"name":"id", "type":"ref", "value":"closeBtn"}
padding_left
padding_right
padding_top
padding_bottom
padding
dimen {"name":"padding", "type":"dimen", "value":"8dp"}
layout_marginLeft
layout_marginRight
layout_marginTop
layout_marginBottom
layout_margin
dimen {"name":"layout_margin", "type":"dimen", "value":"16dp"}
background color {"name":"background", "type":"color", "value":"#00FF00"}
ref {"name":"background", "type":"ref", "value":"drawable_name_in_res_folder"}
base64 {"name":"background", "type":"base64", "value":"BASE64_ENCODE_OF_PNG_IMAGE"}
drawable “`{“name”:”background”, “type”:”drawable”, “value”: {“CORNER”: “10dp
enabled boolean {"name":"enabled", "type":"boolean", "value":"true"}
selected boolean {"name":"selected", "type":"boolean", "value":"t"}
clickable boolean {"name":"clickable", "type":"boolean", "value":"0"}

Text View

Name Type Example
text string {"name":"id", "type":"string", "value":"Hello World!"}
text ref {"name":"id", "type":"ref", "value":"string_id_from_res_string.xml"}
textColor color {"name":"textColor", "type":"color", "value":"0xFF00FF00"}
textSize dimen {"name":"textSize", "type":"textSize", "value":"13sp"}
textStyle integer {"name":"textStyle", "type":"integer", "value":"1"}
Value are Constants in Typeface
  • 0: normal
  • 1: bold
  • 2: italics
  • 3: bold+italics
ellipsize string {"name":"ellipsize", "type":"string", "value":"MIDDLE"}
Enum Value from TextUtils.TruncateAt
maxLines integer {"name":"maxLines", "type":"integer", "value":"3"}
gravity integer {"name":"gravity", "type":"integer", "value":"16"}
Values from Gravity eg 16 for CENTER_VERTICAL
string {"name":"gravity", "type":"string", "value":"CENTER_VERTICAL"}
Constants name from Gravity
drawableTop
drawableBottom
drawableLeft
drawableRight
dimen {"name":"drawableTop", "type":"base64", "value":"Base64EncodedImage"}

Image View

Name Type Example
src ref {"name":"src", "type":"ref", "value":"drawadle_name_from_res"}
base64 {"name":"src", "type":"base64", "value":"Base64EncodedImage"}
scaletype string {"name":"scaletype", "type":"string", "value":"CENTER_CROP"}
Enum Value from ImageView.ScaleType
adjustviewbounds boolean {"name":"adjustviewbounds", "type":"boolean", "value":"f"}

ViewGroup (LinearLayout / RelativeLayout)

Name Type Example
layout_above
layout_alignBaseline
layout_alignBottom
layout_alignEnd
layout_alignLeft
layout_alignRight
layout_alignStart
layout_alignTop
layout_below
layout_toEndof
layout_toLeftof
layout_toRightof
layout_toStartof
ref {"name":"layout_below", "type":"ref", "value":"idOfOtherViewInSameReativeLayout"}
layout_alignParentBottom
layout_alignParentEnd
layout_alignParentLeft
layout_alignParentRight
layout_alignParentStart
layout_alignParentTop
layout_alignWithParentIfMissing
layout_centeHorizontal
layout_centerInParent
layout_centerVertical
boolean {"name":"layout_alignParentBottom", "type":"boolean", "value":"true"}
layout_gravity integer {"name":"layout_gravity", "type":"integer", "value":"16"}
Values from Gravity eg 16 for CENTER_VERTICAL
string {"name":"layout_gravity", "type":"string", "value":"CENTER_VERTICAL"}
Constants name from Gravity
orientation integer {"name":"orientation", "type":"integer", "value":"0"}
  • 0 : horizontal
  • 1 : vertical
string {"name":"orientation", "type":"string", "value":"HORIZONTAL"}
value : "HORIZONTAL" | "VERTICAL"

Generic (experimental)

Name Type Example
Function json { "name": "function", "type": "json", "value": { "function":"setMax", "args":[ {"primitive":"Integer" , "value":"10"} ] } }
to call setMax function with argument 10 of the new created View (eg seekBar.setMax(10) if the property belongs to widget “SeekBar”)

 

Types

Name used in
string eg. the text Value of TextView
integer most used in predefined values
(eg Horizontal == 0 for LinearLayout Orientation)
dimen 12sp, 13dp, 120 (if only number implies pixels),
90% (0.9 * dimension of device screen width)
base64 encoded with base64 image
json custom functionality

 

Hope you like this tutorial and if you’ve any problem then comment box is for you.

The post json2view : Some important properties and types appeared first on Tell Me How - A Place for Technology Geekier.

json2view : Create dynamic Android layouts

In previous article we discuss about changes Android layout dynamically and here we discuss some more examples about How we can make dynamic Android layouts using json2view library.

You can check installation and implementation of json2view Android library.

  • Create and attach view in the specific Parent (created from xml)
/* load xml layout */
setContentView(R.layout.main);
ViewParent viewParent = (ViewParent) findViewById(R.id.parent_view_id)
JSONObject jsonObject = ... // load from network, sdcard etc
View sampleView = DynamicView.createView(this, jsonObject, viewParent);
  • Create and attach view in the activity
JSONObject jsonObject = ... // load from network, sdcard etc
View sampleView = DynamicView.createView(this, jsonObject);
sampleView.setLayoutParams(
   new WindowManager.LayoutParams(
      WindowManager.LayoutParams.MATCH_PARENT,
      WindowManager.LayoutParams.MATCH_PARENT));
setContentView(sampleView);
  • Create a view and get reference to specific children in the view tree
static public class SampleViewHolder {
   /* we need the View with id testClick */
   @DynamicViewId(id = "testClick")
   public View clickableView;

   /* Constructor must be public */
   public SampleViewHolder() {}
}

...

@Override
protected void onCreate(Bundle savedInstanceState) {
   /* load xml layout */
   setContentView(R.layout.main);
   ViewParent viewParent = (ViewParent) findViewById(R.id.parent_view_id)
   JSONObject jsonObject = ... // load from network, sdcard etc
   /* attach the view from the json in parent and add a tag in sampleView. */
   View sampleView = 
      DynamicView.createView(this, jsonObject, viewParent, SampleViewHolder.class);
/*
   The tag's class is SampleViewHolder. 
   The variables that Annotated @DynamicViewId will be the reference,
   to the actual view created, with id (that is the argument of the annotation).
   In this example the json contains a view with id "testClick"
   and the View return in clickableView
*/
   ((SampleViewHolder) sampleView.getTag())
      .clickableView.setOnClickListener( /* attach to click listener */ );

}

Hope you like this tutorial and if you’ve any problem then comment box is for you.

The post json2view : Create dynamic Android layouts appeared first on Tell Me How - A Place for Technology Geekier.

json2view : How to change Android layout dynamically

In previous article we discuss about installation of json2view library and how to change properties of Android ui dynamically but today we discuss about how to change Android layout dynamically with help of json2view library.

You can check installation and implementation of json2view Android library.

Let come with example of json2view Android library and in this tutorial we studying how to dynamically change Android layout using json2view library.

Xml 2 JSON Examples

output

Using json2view to reorganize the layout of a screen

before

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:minWidth="250dp"
        android:text="menu 01" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:minWidth="250dp"
        android:text="menu 02" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:minWidth="250dp"
        android:text="menu 03" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        android:minWidth="250dp"
        android:text="menu 04" />

</LinearLayout>
{
  "views": [{
    "views": [],
    "properties": [{
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "center",
      "type": "string",
      "name": "layout_gravity"
    },
    {
      "value": "10dp",
      "type": "dimen",
      "name": "layout_margin"
    },
    {
      "value": "250dp",
      "type": "dimen",
      "name": "minWidth"
    },
    {
      "value": "menu 01",
      "type": "string",
      "name": "text"
    }],
    "widget": "Button"
  },
  {
    "views": [],
    "properties": [{
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "center",
      "type": "string",
      "name": "layout_gravity"
    },
    {
      "value": "10dp",
      "type": "dimen",
      "name": "layout_margin"
    },
    {
      "value": "250dp",
      "type": "dimen",
      "name": "minWidth"
    },
    {
      "value": "menu 02",
      "type": "string",
      "name": "text"
    }],
    "widget": "Button"
  },
  {
    "views": [],
    "properties": [{
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "center",
      "type": "string",
      "name": "layout_gravity"
    },
    {
      "value": "10dp",
      "type": "dimen",
      "name": "layout_margin"
    },
    {
      "value": "250dp",
      "type": "dimen",
      "name": "minWidth"
    },
    {
      "value": "menu 03",
      "type": "string",
      "name": "text"
    }],
    "widget": "Button"
  },
  {
    "views": [],
    "properties": [{
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "wrap_content",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "center",
      "type": "string",
      "name": "layout_gravity"
    },
    {
      "value": "10dp",
      "type": "dimen",
      "name": "layout_margin"
    },
    {
      "value": "250dp",
      "type": "dimen",
      "name": "minWidth"
    },
    {
      "value": "menu 04",
      "type": "string",
      "name": "text"
    }],
    "widget": "Button"
  }],
  "properties": [{
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_width"
  },
  {
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_height"
  },
  {
    "value": "vertical",
    "type": "string",
    "name": "orientation"
  }],
  "widget": "LinearLayout"
}

after

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:orientation="horizontal">

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:text="menu 01" />

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:text="menu 02" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:orientation="horizontal">

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:text="menu 03" />

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="0.5"
            android:text="menu 04" />
    </LinearLayout>

</LinearLayout>
{
  "views": [{
    "views": [{
      "views": [],
      "properties": [{
        "value": "0dp",
        "type": "dimen",
        "name": "layout_width"
      },
      {
        "value": "match_parent",
        "type": "dimen",
        "name": "layout_height"
      },
      {
        "value": "10dp",
        "type": "dimen",
        "name": "layout_margin"
      },
      {
        "value": "0.5",
        "type": "float",
        "name": "layout_weight"
      },
      {
        "value": "menu 01",
        "type": "string",
        "name": "text"
      }],
      "widget": "Button"
    },
    {
      "views": [],
      "properties": [{
        "value": "0dp",
        "type": "dimen",
        "name": "layout_width"
      },
      {
        "value": "match_parent",
        "type": "dimen",
        "name": "layout_height"
      },
      {
        "value": "10dp",
        "type": "dimen",
        "name": "layout_margin"
      },
      {
        "value": "0.5",
        "type": "float",
        "name": "layout_weight"
      },
      {
        "value": "menu 02",
        "type": "string",
        "name": "text"
      }],
      "widget": "Button"
    }],
    "properties": [{
      "value": "match_parent",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "0dp",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "0.5",
      "type": "float",
      "name": "layout_weight"
    },
    {
      "value": "horizontal",
      "type": "string",
      "name": "orientation"
    }],
    "widget": "LinearLayout"
  },
  {
    "views": [{
      "views": [],
      "properties": [{
        "value": "0dp",
        "type": "dimen",
        "name": "layout_width"
      },
      {
        "value": "match_parent",
        "type": "dimen",
        "name": "layout_height"
      },
      {
        "value": "10dp",
        "type": "dimen",
        "name": "layout_margin"
      },
      {
        "value": "0.5",
        "type": "float",
        "name": "layout_weight"
      },
      {
        "value": "menu 03",
        "type": "string",
        "name": "text"
      }],
      "widget": "Button"
    },
    {
      "views": [],
      "properties": [{
        "value": "0dp",
        "type": "dimen",
        "name": "layout_width"
      },
      {
        "value": "match_parent",
        "type": "dimen",
        "name": "layout_height"
      },
      {
        "value": "10dp",
        "type": "dimen",
        "name": "layout_margin"
      },
      {
        "value": "0.5",
        "type": "float",
        "name": "layout_weight"
      },
      {
        "value": "menu 04",
        "type": "string",
        "name": "text"
      }],
      "widget": "Button"
    }],
    "properties": [{
      "value": "match_parent",
      "type": "dimen",
      "name": "layout_width"
    },
    {
      "value": "0dp",
      "type": "dimen",
      "name": "layout_height"
    },
    {
      "value": "0.5",
      "type": "float",
      "name": "layout_weight"
    },
    {
      "value": "horizontal",
      "type": "string",
      "name": "orientation"
    }],
    "widget": "LinearLayout"
  }],
  "properties": [{
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_width"
  },
  {
    "value": "match_parent",
    "type": "dimen",
    "name": "layout_height"
  },
  {
    "value": "vertical",
    "type": "string",
    "name": "orientation"
  }],
  "widget": "LinearLayout"
}

Hope you like this tutorial and if you’ve any problem then comment box is for you.

The post json2view : How to change Android layout dynamically appeared first on Tell Me How - A Place for Technology Geekier.

Make dynamic Android View using json2view library

In most of Android application we need to make dynamic Android view as per requirement that’s why i come with json2view library which is a simple library that can convert a compatible JSON file to an Android view so you can load dynamically the view in your Android app without the need to update the APK.

This removes the hassle of updating, re-compiling and uploading the APK to Google Play every-time you want to make small or big changes in the UI.

How it works

You can parse any xml through the json2view library to create a JSON that will be used at runtime to dynamically generate the Android UI using native code. This JSON can be hosted anywhere on the internet (your own server, Dropbox, Github Pages etc.) and can be fetched in your app at any point you decide.

how it works schematic

Note: Runtime creation of a view without the precompiled version of xml in apk (res/layout), especially for highly complex layouts, can be a potential latency issue.

Installation

  • Download project
  • add json2view in your project by adding in your settings.gradle
include ':json2view'
project(':json2view'*).projectDir = new File(settingsDir, '$(json2viewPath)/json2view/json2view')
  • add in build.gradle of application module (not project build.gradle) in dependencies section
compile project(':json2view')

Getting started

Basic JSON format

The input JSON has 3 fields for every view we want to create :

  • widget : canonicalName of View (for views in package android.widget you can ommit android.widget)
  • properties : list of properties for the view. (Available Properties) By default we add layout_width & layout_height with value `wrap_content’
  • views : children views for ViewGroup (optional)

eg. JSON to create a empty TextView

{
    "widget": "android.widgetTextView",
  "properties": []
}

eg. JSON to create a TextView with textSize : 12sp and text : “Hello TellMeHow!”

{
    "widget": "TextView",
  "properties": [
      {"name":"textSize", "type": "dimen", "value":"13sp"},
      {"name":"text", "type": "string", "value":"Hello TellMeHow!"}
  ]
}

You can use ConvertXML2JSON.groovy (from ./utils) to convert any android xml to json2view valid JSON file (the script needs further development to create a valid JSON for every case)
try :

./gradlew runScript -Pxml=./pathToInputXmlFile.xml

from the root folder of the project

Loading dynamic layout

create and attach view in the specific Parent (created from xml)

ViewParent viewParent = (ViewParent) findViewById(R.id.parent_view_id)
JSONObject jsonObject = ... // load from network, sdcard etc
View sampleView = DynamicView.createView(this, jsonObject, viewParent);

 

The post Make dynamic Android View using json2view library appeared first on Tell Me How - A Place for Technology Geekier.

Create Custom Android Toast Using TastyToast Library

We all use Android Toast in our application and definitely bored with native Android Toast. You can see many way to create custom Toast for your Android application. But today i am showing you a great Android Library which helps an user to get rid of their native Android Toast.

TastyToast helps the user by characterising the type of Toast into five main category which are success, danger, warning, info and default.

  • For each default category, it not only changes background and text colour but also adds tasty Custom View on the left side of Toast.

The library provides flexibility to customize text color, background of Toast and has specific toast icon for each category.

Recommended article:

How to create custom Android Toast using TastyToast

It very easy to use lets show first demo then we dive with code:

Preview

Demo success - TastyToast Android Custom Toast LibraryDemo warning - TastyToast Android Custom Toast Library



Demo error - TastyToast Android Custom Toast LibraryDemo info - TastyToast Android Custom Toast Library Demo default - TastyToast Android Custom Toast Library Demo confusion - TastyToast Android Custom Toast Library

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Dependency

Add dependency in your app module

dependencies { compile 'com.sdsmdg.tastytoast:tastytoast:0.1.1' }

Usage

Java

TastyToast.makeText(getApplicationContext(), "Hello World !", TastyToast.LENGTH_LONG, TastyToast.WARNING);

Last parameter here is the type of toast you want to show.

Thats it how easy it is. Isn’t it ? Please tell us in comment with your thoughts.

The post Create Custom Android Toast Using TastyToast Library appeared first on Tell Me How - A Place for Technology Geekier.

Make Videocon Television Your All Time Friend For Utmost Entertainment

Today the total concept of television has been changed due to the development of technology. Television is jeeringly termed as the bulky box, but that outlook is changed today.To enhance the beauty of the living room, Television companies have introduced and brought slim and smart television in the market. Technology has made it easy to get fine video quality and fine image in the smart televisions. While sitting cosily in the drawing-room, and witness the events of the world or the favourite serials or movies, the customers would like to witness the best quality picture rather lively pictures in their television set. Customers can experience a new type of television viewing which is uninterrupted and unparalleled and alive.



Make Videocon Television Your All Time Friend For Utmost Entertainment

What facilities you can get on Videocon Smart Television? 

Videocon Smart Television Price In India can complete the customers’ all demands as you can get all the latest features in it. Videocon has brought smart television with different facilities in it like surfing different web pages, watching anything on a big screen, 3D pictures, streaming content from online gaming, can download any apps and can get the access into it directly from the television. Videocon has offered the innovative choice of ‘Smart Share’ and ‘Smart Browser’ that can help you to sort-out any type of files easily. The customers can sync in all their gadgets with their smart television so that they can work efficiently. The most promising matter is it has less consumption of energy with high quality pictures.

Some tips you should keep in mind when you are purchasing a Television

As such there are different companies that have brought almost same type of smart television in the market but when you are buying the smart television, you should keep in mind certain factors and these are the technical requirement, connectivity of the television, and definitely the price of the high-end models. Videocon Television Price In India can fulfill your requirements.


j2HTML – Java HTML5 generation Library

If you’re a Java lover and want to make UI interface in java instead of using HTML5. Then j2HTML is a java library of Java to HTML generator. You can enjoy typesafe HTML generation.

How to add j2html in project

Add the maven dependency

<dependency>
    <groupId>com.j2html</groupId>
    <artifactId>j2html</artifactId>
    <version>0.88</version>
</dependency>

Import TagCreator and start building HTML

import static j2html.TagCreator.*;

public class Main {
    public static void main(String[] args) {
        body().with(
                h1("Heading!").withClass("example"),
                img().withSrc("img/hello.png")
        ).render();
    }
}

The above Java will result in the following HTML:

<body>
    <h1 class="example">Heading!</h1>
    <img src="img/hello.png">
</body>

Basic example

Creating a basic webpage in j2html is pretty similar to HTML. This Java code:

html().with(
    head().with(
        title("Title"),
        link().withRel("stylesheet").withHref("/css/main.css")
    ),
    body().with(
        main().with(
            h1("Heading!")
        )
    )
)

Becomes this HTML:

<html>
    <head>
        <title>Title</title>
        <link rel="stylesheet" href="/css/main.css">
    </head>
    <body>
        <main>
            <h1>Heading!</h1>
        </main>
    </body>
<html>

It’s literally impossible to forget to close a div, mistype an attribute name, or forget an attribute quote! Remember to include the Java wrapping code though, j2html is not a template language, all files are .java.

Partials

You can create partials for elements you use a lot:

public static Tag enterPasswordInput(String placeholder) {
    return passwordInput("enterPassword", placeholder);
}

public static Tag choosePasswordInput(String placeholder) {
    return passwordInput("choosePassword", placeholder);
}

public static Tag repeatPasswordInput(String placeholder) {
    return passwordInput("repeatPassword", placeholder);
}

public static Tag passwordInput(String identifier, String placeholder) {
    return input()
        .withType("password")
        .withId(identifier)
        .withName(identifier)
        .withPlaceholder(placeholder)
        .isRequired();
}

public static Tag emailInput(String placeholder) {
    return input()
        .withType("email")
        .withId("email")
        .withName("email")
        .withPlaceholder(placeholder)
        .isRequired();
}

public static Tag submitButton(String text) {
    return button().withType("submit").withText(text);
}

The equivalent HTML would be:

<input
    type="password"
    id="enterPassword"
    name="enterPassword"
    placeholder="Enter password"
    required
    >

<input
    type="password"
    id="choosePassword"
    name="choosePassword"
    placeholder="Choose password"
    required
    >

<input
    type="password"
    id="repeatPassword"
    name="repeatPassword"
    placeholder="Repeat password"
    required
    >

<input
    type="email"
    id="email"
    name="email"
    placeholder="Email"
    required
    >

<button type="submit">Text</button>

For more example you can see above given button.

Hope you like this tutorial please comment below your thoughts.

The post j2HTML – Java HTML5 generation Library appeared first on Tell Me How - A Place for Technology Geekier.

SlidingRootNav – DrawerLayout-like ViewGroup Android Library

Sometime we need to show ViewGroup content with DrawerLayout and very complicated to implement but this library is a DrawerLayout-like ViewGroup, where a “drawer” is hidden under the content view, which can be shifted to make the drawer visible. It doesn’t provide you with a drawer builder.

Gradle

Add this into your dependencies block.

compile 'com.yarolegovich:sliding-root-nav:1.0.2'

Usage:

  1. Create your content_view.xml (example) or construct a View programatically.
  2. Set the content view (for example, using setContentView in your activity).
  3. Create your menu.xml (example) or construct a View programatically.
  4. Now you need to inject the menu in your onCreate. You can specify transformations of a content view or use the default ones.
new SlidingRootNavBuilder(this)
  .withMenuLayout(R.layout.menu_left_drawer)
  .inject();

API

Transformations

You can specify root transformations using SlidingRootNavBuilder.

new SlidingRootNavBuilder(this)
  .withDragDistance(140) //Horizontal translation of a view. Default == 180dp
  .withRootViewScale(0.7f) //Content view's scale will be interpolated between 1f and 0.7f. Default == 0.65f;
  .withRootViewElevation(10) //Content view's elevation will be interpolated between 0 and 10dp. Default == 8.
  .withRootViewYTranslation(4) //Content view's translationY will be interpolated between 0 and 4. Default == 0
  .addRootTransformation(customTransformation)
  .inject();

customTransformation in the above example is a user-created class that implements RootTransformation interface.

Menu behavior

new SlidingRootNavBuilder(this)
  .withMenuOpened(true) //Initial menu opened/closed state. Default == false
  .withMenuLocked(false) //If true, a user can't open or close the menu. Default == false.
  .withGravity(SlideGravity.LEFT) //If LEFT you can swipe a menu from left to right, if RIGHT - the direction is opposite. 
  .withSavedState(savedInstanceState) //If you call the method, layout will restore its opened/closed state
  .inject();

Controling the layout

A call to inject() returns you an interface for controlling the layout.

public interface SlidingRootNav {
    boolean isMenuHidden();
    boolean isMenuLocked();
    void closeMenu();
    void closeMenu(boolean animated);
    void openMenu();
    void openMenu(boolean animated);
    void setMenuLocked(boolean locked);
    SlidingRootNavLayout getLayout(); //If for some reason you need to work directly with layout - you can
}

Callbacks

  • Drag progress:
builder.addDragListener(listener);

public interface DragListener {
  void onDrag(float progress); //Float between 0 and 1, where 1 is a fully visible menu
}
  • Drag state changes:
builder.addDragStateListener(listener);

public interface DragStateListener {
  void onDragStart();
  void onDragEnd(boolean isMenuOpened);
}
  • Compatibility with DrawerLayout.DrawerListener:
DrawerListenerAdapter adapter = new DrawerListenerAdapter(yourDrawerListener, viewToPassAsDrawer);
builder.addDragListener(listenerAdapter).addDragStateListener(listenerAdapter);

Hope you like this tutorial please comment below.

The post SlidingRootNav – DrawerLayout-like ViewGroup Android Library appeared first on Tell Me How - A Place for Technology Geekier.

FingerprintManager – Handle Android fingerprint API

After Fingerprint security comes in Android many developers want to use that feature in their app but handle android fingerprint API is a hard task but this library offers an easy way to handle authorisation and encryption tasks using Android Fingerprint APIs.

Handle Android fingerprint API

This library can be used to provide basic authentication through fingerprint API, using manual password as backup option. It also allows you to encrypt messages using fingerprint APIs. This library provides a sample to show how it can be used.

Basic use:

You import via gradle from https://jitpack.io add in it to your repositories

allprojects {
   repositories {
     ...
     maven { url 'https://jitpack.io' }
   }
 }

and then adding the library as dependency:

dependencies {
  compile 'com.github.JesusM:FingerprintManager:v1.0'
}

Create the fingerprint manager.

fingerPrintManager = new JFingerprintManager(context, key);

key is the name for the symmetric key that is created in the Android Key Store. JFingerprintManager.InitialisationCallback contains a set of method that are called whether the fingerprint is ready to be used or when there is any error (like no fingerprint has been enrolled yet, or if there has been a problem initialising it).

Once the library is ready to be used, it provides two features: authentication and encryption.

Authentication

Authentication provides the simplest way to authenticate a user. Once it uses its fingerprint scanner, you’ll obtain enough information to allow any operation that requires a user authentication. The library API is pretty simple, just call startAuthentication method passing to it a callback that will let you know the result of the operation. If the authentication went ok, you’ll obtain a CryptoObject object that will let you use for authentication operations (see encryption below to see what you can do with that data)

Logic to authenticate using fingerprint:

fingerPrintManager.startAuthentication(new JFingerprintManager.AuthenticationCallback() {
   @Override
   public void onAuthenticationSuccess(@NonNull FingerprintManagerCompat.CryptoObject cryptoObject) {
       // Logic when authentication has been successful
   }
          
   @Override
   public void onSuccessWithManualPassword(@NonNull String password) {
       // Logic when authentication has been successful writting password manually
   }
          
   @Override
   public void onFingerprintNotRecognized() {
       // Logic when fingerprint is not recognised
   }
          
   @Override
   public void onAuthenticationFailedWithHelp(String help) {
       // Logic when authentication has failed
   }
          
   @Override
   public void onFingerprintNotAvailable() {
       // Logic when fingerprint is not available
   }
}, getSupportFragmentManager());

Encryption

Authentication will be don only using fingerprint APIs, so if fingerprint is not present or suitable, it will fail.

Logic to encrypt an String message using the library:

fingerPrintManager.encrypt(messageToBeEncrypted, new JFingerprintManager.EncryptCallback() {
    @Override
    public void onFingerprintNotRecognized() {
      // Logic when fingerprint was not recognized not available
    }

    @Override
    public void onAuthenticationFailedWithHelp(String help) {
      // Logic when encryption failed with a message
    }

    @Override
    public void onFingerprintNotAvailable() {
      // Logic when fingerprint is not available
    }

    @Override
    public void onEncryptionSuccess(String messageEncrypted) {
        // Logic to handle the encrypted message
    }

    @Override
    public void onEncryptionFailed() {
        // Logic to handle encryption failed
    }
}, getSupportFragmentManager());

Customisation:

The library allows you to customise how the visual component is displayed. In order to do that, you can follow these steps:

1.- Declare a xml them like this:

<style name ="DialogThemeLight" parent="Theme.AppCompat.Light.Dialog.MinWidth">
      <item name="colorAccent">@color/dialog_light_theme_accent</item>
      <item name="android:colorAccent">@color/dialog_light_theme_accent</item>
      <item name="android:background">@color/dialog_light_theme_background</item>
      <item name="android:textColorPrimary">@color/dialog_light_theme_text_color_primary</item>
      <item name="android:textColorSecondary">@color/dialog_light_theme_text_color_secondary</item>
  </style>

2.- Once you have the theme, the library provides a method to set it:

fingerPrintManager.setAuthenticationDialogStyle(theme);

In the screenshots section you can see some samples of the customisations.

Authentication using fingerprint and manual password using a light theme.

handle Android fingerprint API

handle Android fingerprint API

Same screens but this time using a dark theme.

handle Android fingerprint API

handle Android fingerprint API

Resources

Hope your like this post please comment your valuable thoughts.

The post FingerprintManager – Handle Android fingerprint API appeared first on Tell Me How - A Place for Technology Geekier.

Android 7.0 Nougat Update got in Moto G4 Plus

Just six months past, Lenovo has unleash an announcement that they’d be bringing the android 7.0 nougat update for the Moto G4 series, along with some other devices. A few of weeks past, the team started the process that brings the update to the us devices. They began with a reportedly “soak test” created on Republic Wireless, so they created the update offered just for a particular range of devices. during this method, they’ll be able to see the real-world performance.

Moto G4 plus to receive the Android 7.0 Nougat update

The full rollout is on its thanks to reach the Moto G4 plus devices within the us. According to a report created by android Central, whoever owns such a model (with the number XT1644) began to receive the OTA (over-the-air) update. However, the update is offered just for people who own an unbarred G4 plus.

The file is around 741 MB massive, and possibly it comes together with performance enhancements and bug fixes, besides transfer the android 7.0 nougat OS in itself. it’s unclear for currently whether the update can bring the latest android security patch discharged in March or not.

Features comes with this update for

Back in october, the Indian branch of Lenovo had created public an especially detailed changelog that showed what’s going to be included in the Moto G4 and G4 plus devices update. According to the report, the update brings a fast switch feature between the apps, so as to help with multitasking. Moreover, the developers bring a multi-window view, thus you’ll be able to see two apps at identical time, side by side. Android nougat additionally brings a new work mode, that enables you to turn the work apps and notifications on and off. This can be significantly helpful in separating your work from your personal life on the device and not only.

The post Android 7.0 Nougat Update got in Moto G4 Plus appeared first on Tell Me How - A Place for Technology Geekier.