[Nexus S Themes and Apps] mikko3024:
How to apply the Mms.apk next line mod.

Note: This guide assumes that you have knowledge of decompiling-recompiling apks, baksmali-ing and smali-ing.

The mod is a two part modification.

- First is to remove the smiley button when typing an sms/mms with the enter button by modifying layout xml res files. After changing the xml res files, the enter button would appear. But the enter button would function as in the enter-to-send behavior.

- Second is to modify a smali ui file to change the enter-to-send behavior and allow inserting next lines in the text editor.

Part I - Showing the enter button.

1. Decompile the Mms.apk. (apktool or any tool of your preference)

2. Open res/layout/compose_message_activity.xml

3. find |textShortMessage and delete it. (From my experience there is usually a single instance of that text in the file.)

4. Recompile the apk.

Note: You may need to perform apktool if framework-res.apk first to successfully decompile and recompile without errors.

Part II - Smali edit.

1. From the decompiled files under Part I, open smali/com/android/mms/ui/ComposeMessageActivity.smali.

2. Modify the method onEditorAction with the snippet below. (The line with .method public onEditorAction(Landroid/widget/TextView;ILandroid/view/KeyEvent;)Z)

Modified .method snippet:

.method public onEditorAction(Landroid/widget/TextView;ILandroid/view/KeyEvent;)Z
.locals 4
.parameter "v"
.parameter "actionId"
.parameter "event"

.prologue
const/4 v3, 0x1

const/4 v2, 0x0

.line 3217
if-eqz p3, :cond_4

.line 3218
invoke-virtual {p3}, Landroid/view/KeyEvent;->getKeyCode()I

move-result v0

const/16 v1, 0x17

if-eq v0, v1, :cond_0

invoke-virtual {p3}, Landroid/view/KeyEvent;->getKeyCode()I

move-result v0

const/16 v1, 0x42

if-ne v0, v1, :cond_1

:cond_0
move v0, v2

.line 3232
:goto_0
return v0

.line 3221
:cond_1
invoke-virtual {p3}, Landroid/view/KeyEvent;->isShiftPressed()Z

move-result v0

if-nez v0, :cond_3

.line 3222
invoke-direct {p0}, Lcom/android/mms/ui/ComposeMessageActivity;->isPreparedForSending()Z

move-result v0

if-eqz v0, :cond_2

.line 3223
invoke-direct {p0}, Lcom/android/mms/ui/ComposeMessageActivity;->confirmSendMessageIfNeeded()V

:cond_2
move v0, v3

.line 3225
goto :goto_0

:cond_3
move v0, v2

.line 3227
goto :goto_0

.line 3229
:cond_4
invoke-direct {p0}, Lcom/android/mms/ui/ComposeMessageActivity;->isPreparedForSending()Z

move-result v0

if-eqz v0, :cond_5

.line 3230
invoke-direct {p0}, Lcom/android/mms/ui/ComposeMessageActivity;->confirmSendMessageIfNeeded()V

:cond_5
move v0, v3

.line 3232
goto :goto_0
.end method

3. Adjust the .line numbering to the numbering used by the previous method before patching. Not adjusting the .line numbering would/may cause errors.

Note that your .line numbering may be different from my .line numbering. For example your previous .method may occupy 3040 to 3055. Adjust the above code's .line numbering to fit that range.

4. After modifying the smali file, create a duplicate of the smali folder.

5. Smali the smali folder to obtain a new classes.dex file.

java -jar ./smali.jar -o ./classes.dex ./smali

6. Open the patched Mms.apk file earlier using WinZip or WinRAR and overwrite its classes.dex file with the new modified one.

If you're on Ubuntu you can type this command in terminal:

zip -m Mms.apk classes.dex

7. Copy the patched Mms.apk file to your phone's /system/app folder. Apply proper ownership and permissions.