Add Custom Toggles to Android 4.2 QuickSettings

December 4, 2012

Android 4.2 JellyBean brought lots of goodies to the plate. One of them was the most awaited QuickToggles / QuickSettings that let you quickly change power toggles, settings right from the Notifications bar.

If you’re a programmer/developerROM maker/developer,  you can learn how you can add your custom Toggles to QuickSettings on Android 4.2 Jellybean.

The guide explains step-by-step how to mod your favorite ROMs and add your own Toggles to QuickSettings.

How to Add your Own Custom Toggles to Android 4.2 QuickSettings

All you need is access to Android 4.2 Jellybean Open source codebase, and start some hacking. You can also start by decompiling the SystemUI as follows:

time make -j8 SystemUI

SystemUI source code for AOKP, CM 10.1

Step 1.

Navigate to src/com/android/systemui/statusbar/phone/QuickSettings.java, and you will see two options to create a Toggle:

1. addSystemTiles:380 – Static tiles with useful information.
2. addTemporaryTiles:571 – This type of tile will get removed without activity, for example, the alarm quick setting is a temp tile.

Lets talk about the first option in a bit of detail.

Method definition for addSystemTiles:
        // CpuInfo tile
        QuickSettingsTileView cpuInfoTile = (QuickSettingsTileView)
                inflater.inflate(R.layout.quick_settings_tile, parent, false);
        cpuInfoTile.setContent(R.layout.quick_settings_tile_cpuinfo, inflater);
        cpuInfoTile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startSettingsActivity(Intent.ACTION_POWER_USAGE_SUMMARY);
            }
        });
        mModel.addCpuInfoTile(cpuInfoTile, new QuickSettingsModel.RefreshCallback() {
            @Override
            public void refreshView(QuickSettingsTileView view, State state) {
                ImageView iv = (ImageView) view.findViewById(R.id.cpuinfo_image);
                TextView tva = (TextView) view.findViewById(R.id.cpuinfoa_textview);
                TextView tvb = (TextView) view.findViewById(R.id.cpuinfob_textview);
                Drawable d = mContext.getResources().getDrawable(R.drawable.ic_settings_performance);
		String GOV = fileReadOneLine(GOV_FILE);
		String FREQ = fileReadOneLine(SCALE_CUR_FILE);
                iv.setImageDrawable(d);
                tva.setText(GOV);
                tvb.setText(FREQ);
                view.setContentDescription(
                        mContext.getString(R.string.accessibility_quick_settings_cpuinfo, GOV));
            }
        });
        parent.addView(cpuInfoTile);

Step 2.

The second part is updating the Toggle with a Widget view. You can view other definitions in here to update various states.

src/com/android/systemui/statusbar/phone/QuickSettingsModel.java:174

    private QuickSettingsTileView mCpuInfoTile;
    private RefreshCallback mCpuInfoCallback;
    private State mCpuInfoState = new State();

The layout definition resides in res/layout/quick_settings_tile_cpuinfo.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright ... -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical">
    <ImageView
        android:id="@+id/cpuinfo_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:paddingBottom="10dp"/>
    <TextView
        style="@style/TextAppearance.QuickSettings.TileView"
        android:id="@+id/cpuinfoa_textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="#287AA9"
        android:gravity="center"/>
    <TextView
        style="@style/TextAppearance.QuickSettings.TileView"
        android:id="@+id/cpuinfob_textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textColor="#287AA9"
        android:gravity="center"/>
</LinearLayout>

Set contentDescription in res/values/strings.xml

    <string name="accessibility_quick_settings_cpuinfo">CpuInfo <xliff:g id="meminfo" example="CpuInfo">%s</xliff:g>.</string>

That would create a basic Widget in your Toggles. You can always shape it to your needs, but this guide should give you a basic idea for getting started.

Related: How to Compile ROMs

Follow us on Google+TwitterFacebook for latest in Android.

CyanogenMod 10 CM10 Jellybean Development Progress

July 13, 2012

Jellybean has been Open Sourced, and CyanogenMod team had started working on it almost immediately.
The Project butter surely makes Jellybean tasty and attractive and Cyanogenmod 10 would be the first ROM to bring it to variety of devices.

Development of CM10 as already begun and making significant progress every night. First nascent version of Jellybean falvored CM10 is already showcased on LG Optimus phone.

CyanogenMod’s Ricardo Cercuiera tossed a video of an early CM10 build on his YouTube page, declaring “it lives!” The early build is running on an LG Optimus 4X HD, and runs through unlocking the screen and recording and playing back a video. The build is still having some trouble with Google’s revamped search integration, but considering Android 4.1′s source code was released only days ago, the quick development is promising.

He also quotes:

Note: The point of the preview isn’t as much the specific device, I’m just trying to point out that we can actually get CM10 to do things now on devices that aren’t named “Nexus” :-P

So we know that CM10 beta and stable builds aren’t that far. Although it involves a lot of work to port AOSP Jellybean to a lot of devices, as per Steve Kondik, but the team is working day and night to make it possible. Hats off to the brilliance of Open Source.

Follow us on Google+, Twitter, Facebook for latest in Android mods, news.

MIUI style Progress-Bar Battery Indicator on Android

April 5, 2012

It all started with low battery performance of smartphones, but now its more of a thing we love to showoff. Google Play is loaded with number of apps that either show the battery status or display advanced stats.

One of the best implementations of Battery indicators is done by MIUI ROM. ChargeBar brings the MIUI Style Circular Battery Indicator to all Android ROMs. It brings the same splendid circular progress of battery along with the charge animation.

Developed by Thomas Barrasso, ChargeBar displays the exact amount of charge left in your battery. It does this in the form of a completely customizable thin line.

App is full of settings that let you customize your ChargeBar. You can customize settings like starting on boot, hide in lock screen / full-screen apps to cosmetic ones like the ChargeBar’s color, height and position.

The default color for the Progress-Bar is Holo blue, the native color of Android 4.0 ICS, but you can choose your own color. Also, you can set the height of the battery bar indicator, default being 3 pixels. The best part is that you can place this bar above or below the Notification bar.

Works on Both Android Phones, Tablets Android 2.1 & above.

We love chargeBar and highly recommend it. Get it from Google Play. Best part, its free!

Follow us on Google+, Twitter, Facebook for latest in Android mods, news.

Reset Flash Counter Tool on Galaxy S2, Note

February 15, 2012

Installing, Flashing custom ROM to your modern Android smartphones increments the Flash counter each time. Manufacturers use this counter to void your warranty when they detect a counter >zero.

This Flash counter increments each time you flash a Custom ROM. However, Chainfire brings a superb Tool to Reset Flash counter on Android phones like Samsung Galaxy SII, Galaxy Note.

TriangleAway will let you reset your flash counter and remove the yellow triangle by coding the bootloader. Of course, it works only on rooted android with Android Ice Cream Sandwich.

As per Chainfire & Team Hacksung claim that the flash counter and triangle state had to be stored somewhere. You can dump and compare the entire /dev/block/mmcblk0 and you won’t find a difference. The solution comes with the new kernel uses by ICS builds. The flash disk actually has two hidden boot partitions, /dev/block/mmcblk0boot0 and /dev/block/mmcblk0boot1 . The MMC driver in the kernels used for Gingerbread did not present these partitions in the past, the MMC driver in the ICS kernel does.

This isn’t easily doable on Gingerbread. That is also why this currently does not work on the SGNote. When ICS is released for the SGNote it’ll probably be compatible out of the box, or trivial to make it compatible.

Soon as more official ICS firmwares become available, much more devices will be able to use this interesting tool which should be used for experts only.

Download TriangleAway apk more at xda forum.

Follow us on Google+, Twitter for latest in Android mods, news.

 

Enable Virtual buttons on Android ICS

February 4, 2012

You can Enable Virtual buttons on Any Android Ice Cream Sandwich ROM (Android 4.0.x), with a simple trick.

You must follow the instructions below very carefully in order to get Virtual buttons on ICS.

Step 1: Use any: ES File explorer or Root explorer to copy system > framework > framework-res.apk to PC.

Step 2: Keep a backup of the original APK  & Decompile the copied APK using APK Tool. APK Tool 1.4.3 would work fine.

Step 3: Open /res/values/bools.xml using a text editor, find config_showNavigationBar and set its value to true.

Step 4: (Optional) Optionally you can turn off backlight for your hardware capacitive buttons. To do this, edit arrays.xml. Search for config_autoBrightnessButtonBacklightValues and set all item values to ’0′ (i.e.zero).

Step 5: To avoid keyboard overlapping problem, you need to adjust the dimensions for the virtual buttons.Open dimens.xml, find navigation_bar_height and edit its value to something which suits you best. 37.0dip should be good.

Step 6: Compile the APK using aapt. Copy the modified APK back to system > framework.

You should now have enabled onscreen Virtual soft button for back, home and multitasking. Capacitive buttons will be disabled for some users, for others, they would continue to work.

Follow us on Google+Twitter for latest in Android mods, news.

 

HowTo Create Android Bootscreen / Boot Animations

January 31, 2012

Creating a Android Bootscreen / Boot Animations like a Pro can be a tricky thing.

To start with, you would need:

  • A photo Editing program (GIMP and Photoshop are the best.)
  • A text editor besides notepad or wordpad. (Notepad++)
  • An archive manager (7-Zip or WinRAR)

Here’s a summary of what you need to do, full description can be found at XDA forum:

Step 1: Folders
So in this step, we need to make folders. The number of folders depends on what type of animation you want. You can name the folders anything you want as long as they are reflected in your desc.txt

Step 2: Images
So this section will be a generalization of the images. Each image in the video is called a frame. They usually vary slightly from image to image which sped through makes the illusion of a video.

-Each frame must be 480*800 px (thats 480 pixels wide by 800 pixels tall) in png format.

Step 3: Placing images in folders
This step will vary from user to user. based on what type of animation you are making.

Intro to loop (2 folders):
With this one, you are going to place all of the images that is to be the intro to folder 1.
All looping images will go into folder 2.

Step 4: desc.txt
This is the ‘script’ that tells android how to animate the screen.

Step 5: Packaging

1. Highlight all of your folders and desc.txt and right click > “Add to archive…”
2. On the left side, change the radio buttons from rar to zip
3. Change compression method to “store”
4. Name the file. For now, you can name it anything. Eventually, it will need to be named “bootanimation.zip”

The final zip would have to be placed on your android in the right directory: copy bootanimation.zip to /system/customize/resource.

Follow us on Google+Twitter for latest in Android mods, news.

Enable Native SIP Calling on 3G in Android Gingerbread ROMs

January 30, 2012

We know Gingerbread Android 2.3.x is out of fashion but majority of the android users are still on Android 2.3, so it makes sense to still talk about it.

Gingerbread brought Native SIP support to Android for Calling over Wifi, 3G, without a voice plan. However, there are no straightforward guides around the web that talk about it.

Compatibility: Method works for: All Gingerbread 2.3.x Stock roms, AOSP roms, MIUI roms and Sense roms, worked for me on all.

Downloads: APKTool

1. Apktools bz2

2. Brut tar
Note: This guide is for windows, however, it works as-is on Linux, Mac OSX.

Step 1. Pull Framework-res.apk from your ROM’s zip file. Ideal path is  /system/framework directory.

Step 2. Extract both files that you downloaded to c:\apktools. You should see 3 extracted files. Copy the framework-res.apk to the same directory: c:\apktools

Step 3. Run CMD on windows, Terminal on OSX, Windows and run the following commands:

cd \apktools
apktools d framework-res.apk temp

Step 4. A folder named temp will appear. Inside temp, edit the file: C:\apktools\temp\res\values\bools.xml
Search the following line:

<bool name=”config_sip_wifi_only”>true</bool>

change  ”true” to “false” and save the file.

Step 5. On Terminal/ CMD run apktools again.

c:
cd \apktools
apktools b temp temp.apk

Step 6. Now rename your original framework-res.apk to framework-res.apk.zip. Open it with winrar/winzip/7zip it will open like regular archive. take the file that was created by the build process:
C:\apktools\temp\build\apk\resources.arsc

Step 7. Use this file to replace the file inside the archive of framerwork-res.apk.zip (overwriting the original, inside the zip)
rename the file back to framework-res.apk.

Congratulations, now you have a sip over 3g enabled framework-res.apk.

Step 8. Just replace it in your ROM zip and flush the ROM, you need to wipe cache and dalvik cache.

Follow us on Google+Twitter for latest in Android mods, news.