[Galaxy Note GT-N7000 Android Development] majdinj:
Continue moddings!!

Ink effect enabling

This is handy one :crying:

To do this you will need to play with 2 files (android.policy.jar and SecSettings.apk) and lib folder.

Please download ink effect resources with ALL default colors enabled from here.

A. android.policy.jar file:

1.	Copy the contents of “to android.policy.jar” folder.

2.	Decompile android.policy.jar by backsmali/smali program.

3.	Go to classout\com\android\internal\policy\impl\sec\ folder and paste the content of “to android.policy.jar” folder there and accept overwriting.

4.	Now compile (smali), the result will be class.dex file. Open the original android.policy.jar by WinRAR and drag drop class.dex file inside android.policy.jar file

Now push the new modified android.policy.jar to system\framework in your phone

B. SecSettings.apk file:

Decompile SecSettings.apk by APK-Multi tool

I. Image resource

Copy all images in “to res.drawable-xhdpi” folder to res\drawable-xhdpi

II. Adding lines to strings.xml resources

1.	Go to res\values and open strings.xml by notepad++

2.	You should make sure that the following strings are all there; if some missing, please add before </resources> line at the bottom:

<string name="ink_effect">Ink effect</string>
<string name="inkeffect_help_body">Show ink effect on the lock screen. If a live wallpaper is set on the lock screen, the ink effect will be disabled automatically</string>
<string name="ink_effect_color_none">None</string>
<string name="ink_effect_color_pink">Pink</string>
<string name="ink_effect_color_orange">Orange</string>
<string name="ink_effect_color_green">Green</string>
<string name="ink_effect_color_blue">Blue</string>
<string name="ink_effect_color_navy">Navy</string>
<string name="ink_effect_color_purple">Purple</string>
<string name="ink_effect_color_brown">Brown</string>
<string name="ink_effect_color_lightblue">Light Blue</string>
<string name="ink_effect_color_red">Red</string>
<string name="ink_effect_color_black">Black</string>

3.	Now save your file.

III. Adding command line to Lockscreen_settings.xml

<!-- if it is not there already

1. Go to \res\xml folder and open lockscreen_settings.xml

2. Add these lines bellow ripple effect line (the blue color lines):

<CheckBoxPreference android:title="@string/ripple_effect" android:key="ripple_effect" android:summary="@string/ripple_effect_summary" />
[b][color=blue] <PreferenceScreen android:title="@string/ink_effect" android:key="ink_effect">
<intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.InkeffectPreview" />
</PreferenceScreen>[/b][/color]

3. Save changes.

IV. InkeffectPreview.smali

1.	Copy the files InkeffectPreview.smali

2.	Go to smali\com\android\settings and paste it there and accept changes.

Now this is the tricky part..!!

3.	Open it and go to the following section:

:array_14
.array-data 0x4
0xb7t 0x3t 0x2t 0x7ft
0xb9t 0x3t 0x2t 0x7ft
0xcet 0x1t 0x2t 0x7ft
0xcat 0x1t 0x2t 0x7ft
0xc6t 0x1t 0x2t 0x7ft
0xcct 0x1t 0x2t 0x7ft
0xd0t 0x1t 0x2t 0x7ft
0xc8t 0x1t 0x2t 0x7ft
0xb5t 0x3t 0x2t 0x7ft
.end array-data

:array_2a
.array-data 0x4
0xb8t 0x3t 0x2t 0x7ft
0xbat 0x3t 0x2t 0x7ft
0xcft 0x1t 0x2t 0x7ft
0xcbt 0x1t 0x2t 0x7ft
0xc7t 0x1t 0x2t 0x7ft
0xcdt 0x1t 0x2t 0x7ft
0xd1t 0x1t 0x2t 0x7ft
0xc9t 0x1t 0x2t 0x7ft
0xb6t 0x3t 0x2t 0x7ft
.end array-data

4.	You can see here several numbers... these are [ink_ nameofcolor] ids for array_14 and [ink_ nameofcolor _h] ids for array_2a in public.xml.

5.	So you have to open public.xml file from res\values folder

6.	Search for colors ids you added… for start search for “ink_none” for array_14 section and “ink_none_h” for array_2a section.

We will start with “ink_none”

The line will be something like this:

<public type="drawable" name="ink_none" id="0x7f0203b7" />

And if you noticed the array_14 section in InkeffectPreview.smali the first line will represent the ink_none in public.xml file. So we have to convert public.xml ids to array_14, SO PLEASE match to colors here:

<public type="drawable" name="ink_none" id="[B][COLOR="DarkOrchid"]0x7f[/COLOR][COLOR="DeepSkyBlue"]02[/COLOR][COLOR="Lime"]03[/COLOR][COLOR="Red"]b7[/COLOR][/B]" />

to in array_14 section:

[B]0x[COLOR="Red"]b7[/COLOR]t 0x[COLOR="Lime"]03[/COLOR]t 0x[COLOR="DeepSkyBlue"]02[/COLOR]t [COLOR="DarkOrchid"]0x7f[/COLOR]t[/B]

Yes that’s it!! Do the same for “ink_none_h” id in array_2a section.

<public type="drawable" name="ink_none_h" id="[B][COLOR="DarkOrchid"]0x7f[/COLOR][COLOR="DeepSkyBlue"]02[/COLOR][COLOR="Lime"]03[/COLOR][COLOR="Red"]b8[/COLOR][/B]" />

to in array_2a section:

[B]0x[COLOR="Red"]b8[/COLOR]t 0x[COLOR="Lime"]03[/COLOR]t 0x[COLOR="DeepSkyBlue"]02[/COLOR]t [COLOR="DarkOrchid"]0x7f[/COLOR]t[/B]

7.	Now we have finished editing InkeffectPreview.smali for the two none color ids (ink_none & ink_none_h)

8.	Do the same for the rest of colors (the orders of array_14 & array_2a will represent the order of ink colors in your settings menu later on, so it must be in exact order). Also if went down you will see these colors orders as following (None, Pink, Orange, Green, Blue, Navy, Purple, Brown, Light blue, Red, Black) so again you need to keep same order while you are entering ids in array_14 and array_2a... so your arrays should be represented like this (imaginary for learning purpose only):

:array_14
.array-data 0x4
[B] ink_none
ink_pink
ink_orange
ink_green
ink_blue
ink_navy
ink_purple
ink_brown
ink_lightblue
ink_red
ink_black[/B]
.end array-data

:array_2a
.array-data 0x4
[B] ink_none_h
ink_pink_h
ink_orange_h
ink_green_h
ink_blue_h
ink_navy_h
ink_purple_h
ink_brown_h
ink_lightblue_h
ink_red_h
ink_black_h[/B]
.end array-data

9.	We didn't finish yet, you have to link all ids inside InkeffectPreview.smali to correct ids in public.xml file (very annoying!!). Search for all ids inside InkeffectPreview.smali and change them to their corresponding ones inside public.xml. Here is the correct order of ids inside public.xml:

-	inkeffect_preview

-	ink_effect_color_none

-	ink_effect_color_pink

-	ink_effect_color_orange

-	ink_effect_color_green

-	ink_effect_color_blue

-	ink_effect_color_navy

-	ink_effect_color_purple

-	ink_effect_color_brown

-	ink_effect_color_lightblue

-	ink_effect_color_red

-	ink_effect_color_black

-	preview_image

-	ink_help

-	mode_list

-	inkeffect_preview_list_item

-	button_layout

-	inkeffect_menu

-	menu_cancel --> (type="string")

-	menu_save

-	menu_cancel --> (type="id")

Here is example:

You searched for first id in InkeffectPreview.smali (all ids begin with 0x7f) and it was for example (0x7f090514) and you know this should represent "inkeffect_preview" inside public.xml (according to the order above). So now open public.xml and search for "inkeffect_preview", if you find it, it will have an id like (0x7f040072) copy this id and put it instead of that one inside InkeffectPreview.smali and that is it. Do the same for the rest of ids as well.

Pay attention to "menu_cancel" id, it has two variables inside public.xml, type="string" and type="id". So make sure you use the correct one in public.xml for the correct one in InkeffectPreview.smali !!!

10.	Now save changes.

V. LockScreenSettings.smali

1.	Copy the files LockScreenSettings.smali

2.	Go to smali\com\android\settings and paste it there and accept changes.

3.	Open it and go to the following section:

:array_10
.array-data 0x4
0x09t 0xft 0x9t 0x7ft
0x0at 0xft 0x9t 0x7ft
0x4ft 0xdt 0x9t 0x7ft
0x50t 0xdt 0x9t 0x7ft
0x52t 0xdt 0x9t 0x7ft
0x53t 0xdt 0x9t 0x7ft
0x54t 0xdt 0x9t 0x7ft
0x51t 0xdt 0x9t 0x7ft
0x0bt 0xft 0x9t 0x7ft
.end array-data

4.	You can see here several numbers... these are [ink_effect_color_nameofcolor] ids in public.xml

5.	The first line will represent the “ink_effect_color_none” text in public.xml file. So we have to convert public.xml ids to array_10, SO PLEASE match to colors here:

<public type="string" name="ink_effect_color_none" id="[B][COLOR="DarkOrchid"]0x7f[/COLOR][COLOR="DeepSkyBlue"]09[/COLOR][COLOR="Lime"]0f[/COLOR][COLOR="Red"]09[/COLOR][/B]" />

to in array_10:

[B]0x[COLOR="Red"]09[/COLOR]t 0x[COLOR="Lime"]0f[/COLOR]t 0x[COLOR="DeepSkyBlue"]09[/COLOR]t [COLOR="DarkOrchid"]0x7f[/COLOR]t[/B]

6.	Now we finish editing LockScreenSettings.smali for the none color ids (ink_effect_color_none) this will represent the text color name in settings menu later on, so make color orders as same as order in InkeffectPreview.smali or you will have wrong color to wrong text color name in settings menu!!

7.	Do the same for the rest of colors.

8.	Again we haven't finished yet, you have to link all ids inside LockScreenSettings.smali to correct ids in public.xml file (very annoying!!). Search for all ids inside LockScreenSettings.smali and change them to their corresponding ones inside public.xml. Here is the correct order of ids inside public.xml:

-	lockscreen_settings

-	information_ticker_only_weibo_summary

-	ripple_effect_summary

-	ripple_effect_second_summary

-	wakeup_in_lockscreen_summary_nomotion

-	information_ticker_weibo_summary

-	information_ticker_facebook_summary

-	message_network_unavailable

-	motion_camera_short_cut_turn_on_motion

-	motion_activation

-	dlg_ok

-	cancel --> (type="string")

Here is example:

You searched for first id in LockScreenSettings.smali (all ids begin with 0x7f) and it was for example (0x7f09071b) and you know this should represent "lockscreen_settings" inside public.xml (according to the order above). So now open public.xml and search for "lockscreen_settings", if you find it, it will have an id like (0x7f07003a) copy this id and put it instead of that one inside LockScreenSettings.smali and that is it. Do the same for the rest of ids as well.

Pay attention to "cancel" id inside public.xml, the one that we want is with type="string" variable. So make sure you use the correct one in public.xml for the one in LockScreenSettings.smali !!!

9.	Now save changes.

NOW we finally finish editing SecSettings.apk. Recompile the finished project and push it to your phone.

C. lib folder

Just copy the content of “to lib folder” to lib folder in system\lib in your phone.

Adding new ink colors

You are not satisfied with ink colors you have, so why you don't create your own!!

Let's start:

I. Image resource

Create new images of two forms [ink_nameofnewcolor.png] and [ink_nameofnewcolor_h.png] for the new color that you want to add and put them inside res\drawable-xhdpi folder.

II. Adding lines to strings.xml resources

1. Open strings.xml file and add new line just before </resources>

<string name="ink_effect_color_nameofnewcolor">Name of the new color</string>

2. And again you need to recompile your SecSettings.apk to generate new ids in public.xml files automatically!!

THEN decompile the new SecSettings.apk (we will work on this one now, so delete the previous SecSettings.apk project to not cause confusion!!)

III. LockScreenSettings.smali

1. Find the following line:

const/16 v0, 0x[B]b[/B]

This will represent how many ink colors you have in your ink colors list; here it is b (i.e 11 colors) so we will increase it to c (i.e 12 colors) and the line will be like this:

const/16 v0, 0x[B]c[/B]

2. Now go to array_10 list and add new array for your new color:

:array_10
.array-data 0x4
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
0xact 0x0t 0x9t 0x7ft
[B][COLOR="Red"]0xact 0x0t 0x9t 0x7ft[/COLOR][/B] [COLOR="Green"]<!-- New array line[/COLOR]
.end array-data
.end method

3. And as usual link it to "ink_effect_color_nameofnewcolor" id in public.xml

4. Save changes.

IV. InkeffectPreview.smali

1. Find the following line:

const/16 v1, 0x[B]b[/B]

This will represent how many ink colors you have in your ink colors list; here it is b (i.e 11 colors) so we will increase it to c (i.e 12 colors) and the line will be like this:

const/16 v1, 0x[B]c[/B]

2. Now go to array_14 list and array_2a and add new array for your new color:

.line 50
:array_14
.array-data 0x4
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
0xact 0x1t 0x2t 0x7ft
[B][COLOR="Red"]0xact 0x1t 0x2t 0x7ft[/COLOR][/B] [COLOR="Green"]<!-- New array line[/COLOR]
.end array-data

.line 62
:array_2a
.array-data 0x4
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
0xadt 0x1t 0x2t 0x7ft
[B][COLOR="Red"]0xadt 0x1t 0x2t 0x7ft[/COLOR][/B] [COLOR="Green"]<!-- New array line[/COLOR]
.end array-data
.end method

And as usual link the one in array_14 to "ink_nameofnewcolor" id in public.xml and the one in array_2a to "ink_nameofnewcolor_h" id in public.xml

3. Search down for this line:

const/16 v2, 0x[B]b[/B]

And yes change b to c to be like this:

const/16 v2, 0x[B]c[/B]

4. Now we need to add the new color to the list, so search for these lines:

sget-object v2, Lcom/android/settings/InkeffectPreview;->mInkcolorItem:[Ljava/lang/String;

const/16 v3, 0x[B][COLOR="Red"]a[/COLOR][/B]

invoke-virtual {p0}, Lcom/android/settings/InkeffectPreview;->getResources()Landroid/content/res/Resources;

move-result-object v4

const v5, [B][COLOR="Red"]0x7f090d55[/COLOR][/B]

invoke-virtual {v4, v5}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

const-string v4, "[B][COLOR="Red"]Black[/COLOR][/B]"

aput-object v4, v2, v3

Copy these lines and paste them again bellow them, and change the red color values above to blue ones:

sget-object v2, Lcom/android/settings/InkeffectPreview;->mInkcolorItem:[Ljava/lang/String;

const/16 v3, 0x[B][COLOR="Blue"]b[/COLOR][/B] [COLOR="Green"]<!-- Next number in the list[/COLOR]

invoke-virtual {p0}, Lcom/android/settings/InkeffectPreview;->getResources()Landroid/content/res/Resources;

move-result-object v4

const v5, [B][COLOR="Blue"]0x7f??????[/COLOR][/B] [COLOR="Green"]<!-- id of "ink_effect_color_nameofnewcolor" in public.xml[/COLOR]

invoke-virtual {v4, v5}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

const-string v4, "[B][COLOR="Blue"]Name of the new color[/COLOR][/B]" [COLOR="Green"]<!-- Name of the new color[/COLOR]

aput-object v4, v2, v3

5. Save changes.

V. CircleUnlockRippleRenderer.smali

This file is found in android.policy.jar and it determines the RGB value of the color when rendering.

1. Find the following line:

const/16 v3, 0x[B]b[/B]

And yes change b to c to be like this:

const/16 v3, 0x[B]c[/B]

2. Find these lines:

const/16 v4, 0x[B][COLOR="Red"]a[/COLOR][/B]

new-array v5, v7, [F

fill-array-data v5, :array_[B][COLOR="Red"]26a[/COLOR][/B]

aput-object v5, v3, v4

Copy these lines and paste them again bellow them, and change the red color values above to blue ones:

const/16 v4, 0x[B][COLOR="Blue"]b[/COLOR][/B] [COLOR="Green"]<!-- Next number in the list
[/COLOR]
new-array v5, v7, [F

fill-array-data v5, :array_[B][COLOR="Blue"]26b[/COLOR][/B] [COLOR="Green"]<!-- Next number in the list[/COLOR]

aput-object v5, v3, v4

3. As we have new array_26b, so we have to make RGB hex code for it. Find ".end method" and add array data above it like this:

:array_26b [COLOR="Green"]<!-- Our new array[/COLOR]
.array-data 0x4
0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t [COLOR="Green"]<!-- Red value in hex[/COLOR]
0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t [COLOR="Green"]<!-- Green value in hex[/COLOR]
0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t [COLOR="Green"]<!-- Blue value in hex[/COLOR]
.end array-data
.end method

You need to change these values to their RGB Hex, Hex, Hex coding; but how!!

You need first to have RGB in decimal value (0-255) by using photoshop for example; then convert it to float value by dividing your decimal value on 255, then use IEEE floating point calculator (for Windows) to convert the result to hex.

Example:

You open your photoshop and choose this color values (light blue):

Here R=0, G=159, B=180

For R=0, we need to divide it on 255, the result will be 0

For G=159, we need to divide it on 255, the result will be about 0.62353

For B=180, we need to divide it on 255, the result will be about 0.70588

Now open IEEE floating point calculator and enter these numbers to convert them to hex

So..

For R:

For G:

For B:

So if we return back to our array_26b the result will be like this:

:array_26b
.array-data 0x4
0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t 0x[B][COLOR="Purple"]00[/COLOR][/B]t [COLOR="Green"]<!-- Red value in hex[/COLOR]
0x[B][COLOR="Purple"]a9[/COLOR][/B]t 0x[B][COLOR="Purple"]9f[/COLOR][/B]t 0x[B][COLOR="Purple"]1f[/COLOR][/B]t 0x[B][COLOR="Purple"]3f[/COLOR][/B]t [COLOR="Green"]<!-- Green value in hex[/COLOR]
0x[B][COLOR="Purple"]8d[/COLOR][/B]t 0x[B][COLOR="Purple"]b4[/COLOR][/B]t 0x[B][COLOR="Purple"]34[/COLOR][/B]t 0x[B][COLOR="Purple"]3f[/COLOR][/B]t [COLOR="Green"]<!-- Blue value in hex[/COLOR]
.end array-data
.end method

And viola we finished!!

4. Save changes.

Now recompile both SecSettings.apk and android.policy.jar and push them to your device

Integrating application in settings menu

This really handy one.. so take care!!:confused:

In this tutorial, we will add USB-Mode program to Settings menu as an example

On your PC

1)	Decompile SecSettings.apk.

2)	Decompile the program that you want to add to settings menu (USB-Mode)

3)	Go to \res\drawable-xhdpi folder and add icon for your program that you want to add (you can take it from decompiled wanted program (USBMode folder).

4)	Go to \res\values folder and open strings.xml by NotePad++ and add these lines just before </resources> for your program

<string name="gloryromaddons">GloryROM Addons</string>
<string name="usbswitcher_text">USB mode switcher</string>

Here change “gloryromaddons” with any thing you want to show as a header in the Settings menu. “usbswitcher_text” is your wanted program

5)	Go to \res\xml folder and open settings_headers.xml by NotePad++ and add these lines (the place you put these lines will be the place where added program will be displayed in Settings menu)

<header android:title="@string/gloryromaddons" />
<header android:icon="@drawable/usbswitcher" android:title="@string/usbswitcher_text">
<intent android:targetPackage="in.zatta.USB_switch" android:action="android.intent.action.MAIN" android:targetClass="in.zatta.USB_switch.USB_switcherActivity" />
</header>

The first line

reflect the header title in settings menu (So gloryromaddons will be seen as “GloryROM Addons” in the phone, see strings.xml that we edited and you will figure it out!!)

The 2nd line is for added program:

android:icon=@drawable/name of icon you put in drawable-xhdpi folder (here we put usbswitcher as the icon name inside drawable-xhdpi)

android:title=@string/name of string put for added program in strings.xml (here we put usbswitcher_text as in strings.xml)

The 3rd line

is the functionality and is the most difficult one:

android:targetPackage=package of wanted program inside its own AndroidManifest.xml (here it is “in.zatta.USB_switch”)

android:action=first action of wanted program inside its own AndroidManifest.xml (here it is “android.intent.action.MAIN”)

androidtargetClass= android:targetPackage.Activity (we have android:targetPackage from previous step but we need also .Activity how to get it??) This is the tricky one so do the following:

On your phone:

install the program you want to add (USB mode switcher) and ADW launcher from Google play and make ADW launcher as your phone launcher. Find a blank area on your homescreen(s), long press, then select custom shortcut --> pick your activity --> activities --> browse down until you find USB switcher app and expand with the arrow on the left of USB switcher, you will see several activities (some may have only one). The first one in the list is usually its opening class; it is in between the ( )'s. In this example it is .USB_switcherActivity

Go back to your PC:

So now androidtargetClass= android:targetPackage.Activity

will be:

androidtargetClass= in.zatta.USB_switch.USB_switcherActivity

6)	Now compile SecSettings and push it to your phone.

Additional step:

If you want to hide this app from applications drawer do the followings:

1)	Decompile your desired app (here USB-Mode.apk)

2)	Go to AndroidManifest.xml file and open it by NotePad++

3)	Delete this line :

<category android:name="android.intent.category.LAUNCHER" />

4)	Compile your app as non system apk and sign it then push it to your phone

Results example: