[Galaxy S II Themes and Apps] jarari2:
*Please consider that I'm not using English as first language, so my instructions can look like non-sense, hard to understand. Sorry for that.

**Is this right place to post? I saw some down there so I posted here, but if it's not the right place, please move this thread.

On Galaxy Note II, ink effect appears when sweeping the lockscreen with S-Pen.

This guide tells you how to enable ink effect on other Galaxy devices which uses JB Samsung Firmware.

Please download source files here : http://db.tt/21yMeRfj

Source file zip contains smali files of ripple/ink renderer, lockscreen setting, images for ink color option, *.so library files for rippple/ink rendering, and public.xml which came from SecSettings.apk.

I will walk through each files and tell you what I did.

First, CircleUnlockRippleRenderer*.smali files contain ripple/ink rendering command. I took it from N7100 leaked JB firmware.

On this part, I removed the part which checks whether the device has "com.sec.feature.spen_usp" as system feature or not.

Also, I hard-coded Landroid/view/MotionEvent;->getSource()I to 0x4002(SOURCE_STYLUS), to make the device recognize hand as S-pen.

You can just overwrite the files in android.policy.

I forgot to edit one part!

In, CircleUnlockRippleRenderer.smali

Find 0x1080618 and replace it to id value of "reflectionmap" in public.xml of framework-res.apk.

Because I didn't edit that, water ripple was somewhat different from original Note 2 ripple.

Thanks to shoman94!

InkeffectPreview.smali is from SecSetting of N7100 leaked JB firmware as well. This file determines which image file, string to show when the user pressed Ink Effect option.

On this file, I changed array-datas to

:array_14
.array-data 0x4
0x28t 0x2t 0x2t 0x7ft
0x2at 0x2t 0x2t 0x7ft
0x2bt 0x2t 0x2t 0x7ft
0x2ct 0x2t 0x2t 0x7ft
0x2dt 0x2t 0x2t 0x7ft
0x2et 0x2t 0x2t 0x7ft
0x2ft 0x2t 0x2t 0x7ft
0x30t 0x2t 0x2t 0x7ft
0x31t 0x2t 0x2t 0x7ft
.end array-data
.line 62
:array_2a
.array-data 0x4
0x32t 0x2t 0x2t 0x7ft
0x33t 0x2t 0x2t 0x7ft
0x34t 0x2t 0x2t 0x7ft
0x35t 0x2t 0x2t 0x7ft
0x36t 0x2t 0x2t 0x7ft
0x37t 0x2t 0x2t 0x7ft
0x38t 0x2t 0x2t 0x7ft
0x39t 0x2t 0x2t 0x7ft
0x3bt 0x2t 0x2t 0x7ft
.end array-data

and made method constructor ()V get 9 array-datas(0x9), instead of 8(0x8)

These array values are id of ink_ image files in public.xml, and you should read it from back.

Ex)First array-data of array_14 is 0x7f020228, which is ink_none.png.

Also, I'm not sure about other devices, but SGS2 XXLSJ had fewer strings related to color option, so I hard-coded using const-string.

Ex)

sget-object v2, Lcom/android/settings/InkeffectPreview;->mInkcolorItem:[Ljava/lang/String;
invoke-virtual {p0}, Lcom/android/settings/InkeffectPreview;->getResources()Landroid/content/res/Resources;
move-result-object v3
const v4, 0x7f090cdc
invoke-virtual {v3, v4}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;
const-string v3, "None"** <--v3 is not the string I want, so intercept it.
aput-object v3, v2, v7

You can overwrite this file to SecSettings as well, after changing array-data according to your public.xml.

LockScreenSettings.smali is smali file related to Lockscreen Settings.

On this file, as I wrote above, color strings were fewer then 9, so I just changed array-data to show blank. If you wish, you can add some strings and change id to show color values on Lockscreen Setting, instead of just blank.

Then I removed removePreference(Landroid/preference/Preference;)Z around mInkEffect:Landroid/preference/PreferenceScreen to show Ink Effect option.

Last file I edited is public.xml. I added id of ink_ images which will be used in InkeffectPreview.smali.

After modifying all codes, pushlibWaterRipple.so libWaterRipple2.so into*/system/lib of your device,

inkeffect folder and JniWaterRippleRender.smali to andorid.policy(blah~/impl/sec)

Now, compile and check if it's working or not!

-----------------End of the main modification.

---------OPTIONAL : Add new colors!

So, do you want to add new colors to your ink list?

Then you should edit 4 files : public.xml, InkeffectPreview.smali, CircleUnlockRippleRenderer.smali, LockScreenSettings.smali.

public.xml and LockScreenSettings.smali is the easiest one, so let's modify them first.

Open public.xml and add ink_*.png and ink_*_h.png files, which will be shown when the color is selected.

For example, I'll add ink_red.png and ink_red_h.png like this:

<public type="drawable" name="ink_red" id="0x7f02023c" />
<public type="drawable" name="ink_red_h" id="0x7f02023d" />

That's all for public.xml. Save it and exit.

Now, open LockScreenSettings.smali and find these

const/16 v0, 0x9

new-array v0, v0, [I

fill-array-data v0, :array_10

change 0x9 to the number of colors you want to have.

I'm going to add just 1 color, so I change to this:

const/16 v0, 0xa

new-array v0, v0, [I

fill-array-data v0, :array_10

Now, if you see below, you'll see array-datas.

: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
.end array-data

*Values can be different on your system.

Add more lines. It determines which string to show on Lockscreen Setting when the color is selected.

: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
.end array-data

*I added just one line, for red color.

Save the file and exit.

Now, open InkeffectPreview.smali and you'll find 2 sets of arrays and this line

const/16 v1, 0x9

Change it to the number of colors.

Also, add more lines to all array datas.

For example, I'm going to add red color,so I added ink_red.png and ink_red_h.png like this

:array_14
.array-data 0x4
0x28t 0x2t 0x2t 0x7ft
0x2at 0x2t 0x2t 0x7ft
0x2bt 0x2t 0x2t 0x7ft
0x2ct 0x2t 0x2t 0x7ft
0x2dt 0x2t 0x2t 0x7ft
0x2et 0x2t 0x2t 0x7ft
0x2ft 0x2t 0x2t 0x7ft
0x30t 0x2t 0x2t 0x7ft
0x31t 0x2t 0x2t 0x7ft
0x3ct 0x2t 0x2t 0x7ft
.end array-data

.line 62
:array_2a
.array-data 0x4
0x32t 0x2t 0x2t 0x7ft
0x33t 0x2t 0x2t 0x7ft
0x34t 0x2t 0x2t 0x7ft
0x35t 0x2t 0x2t 0x7ft
0x36t 0x2t 0x2t 0x7ft
0x37t 0x2t 0x2t 0x7ft
0x38t 0x2t 0x2t 0x7ft
0x39t 0x2t 0x2t 0x7ft
0x3bt 0x2t 0x2t 0x7ft
0x3dt 0x2t 0x2t 0x7ft
.end array-data

You'll find another 0x9 below, so edit it too.

const/16 v2, 0x9

new-array v2, v2, [Ljava/lang/String;

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

to

const/16 v2, 0xa

new-array v2, v2, [Ljava/lang/String;

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

in this case.

Last thing to do on InkeffectPreview.smali is adding color to the list.

Find this and paste it, modify Bolded values.

You can remove the red lines.

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

[B]const/16 v3, 0x8[/B] <----List No. This means it's 9th item of mInkcolorItem.

[COLOR="Red"]invoke-virtual {p0}, Lcom/android/settings/InkeffectPreview;->getResources()Landroid/content/res/Resources;

move-result-object v4

const v5, 0x7f090ce6

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

const-string v4, "Light Blue" <----Name of the color.

aput-object v4, v2, v3

Save the file.

Now, last file to edit is CircleUnlockRippleRenderer.smali

This file determines the RGB value of the color when rendering.

Find 0x9 again and modify it like this:

const/16 v3, 0xa

Find these lines

*Values can be different on your system.

[B]const/16 v4, 0x8[/B]

new-array v5, v7, [F

fill-array-data v5, :[B]array_268[/B]

aput-object v5, v3, v4

Paste this value and modify value of bolded lines. Like this:

const/16 v4, 0x9

new-array v5, v7, [F

fill-array-data v5, :array_269

aput-object v5, v3, v4

As I changed array name to array_269, so I have to make one for it.

Find .end method and add array data above like this:

:array_269
.array-data 0x4
0x0t 0x0t 0x80t 0x3ft <--Red value. 1.0F
0x0t 0x0t 0x0t 0x0t <--Green value. 0.0F
0x0t 0x0t 0x0t 0x0t <--Blue value. 0.0F
.end array-data

That's all. Compile and enjoy :D

Thanks to ICS_XD for telling me that line 242 of lockscreensettings.smali is important :)