[Galaxy S II Android Development] jeboo:
Well, it seems Sammy has yet again added another great feature but forgot the option to turn it off! So as usual, we grab our shovels and fix that which is piled before us.

First, we thank Mirko ddd for his patch that allows us the option:http://xdaforums.com/showthread.php?t=2095845

So as you can see, it's a nice, clean patch and will follow the format of previous toggles I've written about. This tutorial is based upon XXLSJ.

Step 1. Implement Mirko's patch as a configurable option

In ZoomManager.smali within framework.jar, we will need to patch at 3 points:

a) Add the following variable to the top of the smali after '.field private registerTiltListener:Z':

.field private final mContext:Landroid/content/Context;

b) Then we will add 3 lines to the end (ABOVE return-void) of the following method: '.method public constructor <init>(Landroid/webkit/WebViewClassic;Landroid/webkit/CallbackProxy;)V'

invoke-virtual {p1}, Landroid/webkit/WebViewClassic;->getContext()Landroid/content/Context;

move-result-object v0

iput-object v0, p0, Landroid/webkit/ZoomManager;->mContext:Landroid/content/Context;

c) Now we will implement the actual patch based on our newly created setting. Find '.method setEdgeZoom(Z)V' and replace the code between '.prologue' and '.line 1602' with the following:

#const/4 v5, 0x1

const/4 v4, 0x0

iget-object v2, p0, Landroid/webkit/ZoomManager;->mContext:Landroid/content/Context;

invoke-virtual {v2}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v2

const-string v3, "edgezoom_toggle"

invoke-static {v2, v3, v4}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v5

if-nez v5, :disable_ez

const/4 v5, 0x1

goto :toggle_resume

:disable_ez

const/4 v5, 0x0

:toggle_resume

That's it for framework.jar, recompile, upload and ensure it's stable before proceeding.

Step 2. Modifying Display settings, the most involved portion of this tutorial

Decompile SecSettings.apk and find DisplaySettings.smali. We will have 5 patch points:

a) Add a new variable to top of smali after '.field private mTouchKeyLight:Landroid/preference/ListPreference;':

.field private mEdgeZoomPreference:Landroid/preference/CheckBoxPreference;

b) Search for '.method public onCreate(Landroid/os/Bundle;)V' and add the following code after

'iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mMultiWindowPref:Landroid/preference/CheckBoxPreference;':

const-string v12, "edgezoom_toggle"

invoke-virtual {p0, v12}, Lcom/android/settings/DisplaySettings;->findPreference(Ljava/lang/CharSequence;)Landroid/preference/Preference;

move-result-object v12

check-cast v12, Landroid/preference/CheckBoxPreference;

iput-object v12, p0, Lcom/android/settings/DisplaySettings;->mEdgeZoomPreference:Landroid/preference/CheckBoxPreference;

c) In '.method public onPreferenceTreeClick(Landroid/preference/PreferenceScreen;Landroid/preference/Preference;)Z' find '.line 985' and just

ABOVE

it replace 'if-eqz v0, :cond_0' with:

if-eqz v0, :cond_new

d) About 20 lines below the last patch, you will see 'goto :goto_a' just before the end of the method. Paste the following code after 'goto :goto_a' but before '.end method':

:cond_new
iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mEdgeZoomPreference:Landroid/preference/CheckBoxPreference;

invoke-virtual {p2, v0}, Ljava/lang/Object;->equals(Ljava/lang/Object;)Z

move-result v0

if-eqz v0, :cond_0

iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mEdgeZoomPreference:Landroid/preference/CheckBoxPreference;

invoke-virtual {v0}, Landroid/preference/CheckBoxPreference;->isChecked()Z

move-result v0

invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v3

const-string v4, "edgezoom_toggle"

if-nez v0, :cond_newA

const/4 v0, 0x0

goto :cond_newB

:cond_newA

const/4 v0, 0x1

:cond_newB
invoke-static {v3, v4, v0}, Landroid/provider/Settings$System;->putInt(Landroid/content/ContentResolver;Ljava/lang/String;I)Z

goto/16 :goto_1

e) Within '.method public onResume()V' find 'return-void' and add this code ABOVE that line:

iget-object v0, p0, Lcom/android/settings/DisplaySettings;->mEdgeZoomPreference:Landroid/preference/CheckBoxPreference;

invoke-virtual {p0}, Lcom/android/settings/DisplaySettings;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v3

const-string v4, "edgezoom_toggle"

const/4 v1, 0x0

invoke-static {v3, v4, v1}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v3

if-eqz v3, :goto_2b

const/4 v1, 0x1

goto :goto_2c

:goto_2b
const/4 v1, 0x0

:goto_2c
invoke-virtual {v0, v1}, Landroid/preference/CheckBoxPreference;->setChecked(Z)V

That's it for DisplaySettings.smali, but we have just a few xml edits left before recompiling.

Step 3. Adding the actual setting, the easy part

In res/xml/display_settings.xml, add this line wherever you want the setting to appear:

<CheckBoxPreference android:title="@string/edgezoom_title" android:key="edgezoom_toggle" android:summary="@string/edgezoom_summary" />

In strings.xml, add:

<string name="edgezoom_title">Disable Edge Zoom</string>
<string name="edgezoom_summary">Disable edge zoom feature used in email and browsers</string>

In public.xml, add the IDs (NOTE: these numbers may differ depending on previous mods):

<public type="string" name="edgezoom_title" id="0x7f090ef4" />
<public type="string" name="edgezoom_summary" id="0x7f090ef5" />

Compile SecSettings.apk, upload and reboot. If all goes well, you should have a setting to control this new feature!