Android Customize Quick Setting Tiles (New Feature in NOUGAT 7.0)

Android Customize Quick Setting Tiles (7.0 NOUGAT) In-Build Feature In Android 7.0 Nougat

Android Customize Quick Setting Tiles If you swipe down from Android’s menu bar twice, you’ll get a nice panel of quick settings you can toggle with one tap. Want to hide some of these settings, move them around, or add new ones? You have a few choices.

Android 7.0 Nougat finally added the ability to customize this menu, though it was available in 6.0 Marshmallow from within a hidden menu called “System UI Tuner”. If you’re rooted, however, you can get even more options on any version of Android, Marshmallow or otherwise.

Nougat Users: Use the Built-In Customization

Customizing the Quick Settings area on Android phones has long been a tweak that custom ROMs and other root mods offer, but with Android 7.0 Nougat, it’s a baked-in feature. Google even released an API that allows developers to build third-party Quick Settings buttons.

First things first: go ahead and give the notification area a tug to pull show the top of the Quick Settings panel and notifications. Then, pull it down one more time to show the entire Quick Settings menu.

On the bottom-right corner, you should see an “Edit” button. Go ahead and tap that.

This will, unsurprisingly, open the Quick Settings Edit menu. Modifying this menu is super simple and intuitive: just long-press and drag icons to where you want them. The Quick Settings menu can be two pages long—you navigate through them by swiping—with nine icons on each. That’s a lot of buttons!

And that’s really where the power of the new customizable Quick Settings menu shows: you can add custom apps to the menu now. There are already a handful of options in the Play Store, including simple things like “Facts tile” and a much more robust, fully-customizable app called Custom Quick Settings.

To add one of these custom apps, go ahead and install it on your phone—we’ll be using Fact Quick Settings Tile for this tutorial.

With the app installed, go ahead and jump back into the Quick Settings Edit menu. A new option called “Fact Quick Tile” should be available. Just add that. Yeah, it’s really that simple.

In This Tutorial When you Click On the Fact Quick Button then the dialog box appear on screen with interesting Fact messages.

Step by Step Tutorial

Step 1: Open Android Studio.

Step 2: Create a new project as follows:

If you see the Welcome to Android Studio dialog, choose Start a new Android Studio project, available under ‘Quick Start’ on the right of the dialog.
Otherwise, click File in the Android Studio menu bar, then New, New Project.
Step 3: Enter your app name, company domain, and project location, as prompted. Then click Next.

Step 4: Select the form factors you need for your app. If you’re not sure what you need, just select Phone and Tablet. Then click Next.

Step 5: Select Blank Activity in the ‘Add an activity to Mobile’ dialog. Then click Next.

Step 6: Enter the activity name, layout name and title as prompted. The default values are fine. Then click Finish.

After that wait for few seconds. Android Studio starts Gradle and builds of your project.

Step 7: Now Create 4 class file as Follows.

  1. MainActivity.java
  2. TileDialog.java
  3. MyTileService.java
  4. Constants.java
Step 8: Add Button in activity_main.xml file as follows:

 <Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal='true'
 android:layout_centerVertical='true'
 android:id="@+id/btn_facts"
 android:text="show Facts"
 style="@style/Widget.AppCompat.Button.Colored"/>

Coding:

MainActivity.java

package com.platform.android.tilesdemo;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

private Button mButton;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
 setSupportActionBar(toolbar);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
 fab.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View view) {
 Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
 .setAction("Action", null).show();
 }
 });
 setupButton();
 }

private void setupButton()
 {
 mButton = (Button)findViewById(R.id.btn_facts);
 mButton.setOnClickListener(new View.OnClickListener()
 {
 @Override
 public void onClick(View view)
 {
 showDialog();

}
 });

}
 private void showDialog(){
 TileDialog.getDialog(this).show();
 }

@Override
 public boolean onCreateOptionsMenu(Menu menu) {
 // Inflate the menu; this adds items to the action bar if it is present.
 getMenuInflater().inflate(R.menu.menu_main, menu);
 return true;
 }

@Override
 public boolean onOptionsItemSelected(MenuItem item) {
 // Handle action bar item clicks here. The action bar will
 // automatically handle clicks on the Home/Up button, so long
 // as you specify a parent activity in AndroidManifest.xml.
 int id = item.getItemId();

//noinspection SimplifiableIfStatement
 if (id == R.id.action_settings) {
 return true;
 }

return super.onOptionsItemSelected(item);
 }
}

TileDialog.java

package com.platform.android.tilesdemo;

/**
 * Created by Nexus on 5/31/2017.
 */

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

import java.util.Random;

public class TileDialog {

 public static AlertDialog getDialog(Context context) {

 AlertDialog.Builder builder = new AlertDialog.Builder(context);
 builder.setTitle("Fact");
 Random random = new Random();
 builder.setMessage(Constants.facts[random.nextInt(6)]);
 builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
 @Override
 public void onClick(DialogInterface dialogInterface, int i) {

 dialogInterface.dismiss();
 }
 });

 return builder.create();
 }
}

MyTileService.java

package com.platform.android.tilesdemo;

import android.os.Build;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.support.annotation.RequiresApi;
import android.util.Log;

/**
 * Created by Nexus on 5/31/2017.
 */

@RequiresApi(api = Build.VERSION_CODES.N)

public class MyTileService extends TileService {
 //Here The code is writen for on click event of quick setting icon.

//This can only work on the android N version smartphone. for that i used android simulation bcs that has android 7 installed.

//lets start.

public static final String TAG = MyTileService.class.getSimpleName();

@Override
 public void onTileAdded(){
 Log.d(TAG,"onTileAdded");

}

@Override
 public void onStartListening()

{
 Tile tile = getQsTile();
 Log.d(TAG,"onStartListening:" +tile.getLabel());

}

@Override

public void onClick(){
 Log.d(TAG, "onClick: ");

if(!isSecure()) {
 showDialog();
 }else{
 unlockAndRun(new Runnable() {
 @Override
 public void run() {

showDialog();
 }
 });
 }
 }
private void showDialog()
{
 showDialog(TileDialog.getDialog(this));
}
}

Constants.java

package com.platform.android.tilesdemo;

/**
 * Created by Nexus on 5/31/2017.
 */

public class Constants {
 // Here we Wrote all the facts that are shown in the box. and It will be in alphanumaric form as follows.

public static final String facts [] = {
//here add the data that you want to display... like this...

"The domain name www.youtube.com was registered on February 14, 2005.",
 "The average 21 year old has spent 5,000 hours playing video games, has exchanged 250,000 e-mails, instant and text messages and has spent 10,000 hours on the mobile phone",
 "The first computer mouse was invented by Doug Engelbart in around 1964 and was made of wood.",
 "On an average work day, a typist’s fingers travel 12.6 miles.",
 "Bill Gates, the founder of Microsoft was a college drop out.",
 "While it took the radio 38 years, and the television a short 13 years, it took the World Wide Web only 4 years to reach 50 million users."


 };
}

OUTPUT:

 

    

Post a comment

Your email address will not be published. Required fields are marked *