[GUIDE]Add “Delete” button to the screenshot preview

Hey, guys, we know that some ROMs don’t have the “Delete” button on the screenshot preview like the Sony Xperia series. Hence, here is the guide that can help you add “Delete” button to your screenshot preview.
1.    Copy the “system/priv-app/SystemUI.apk” to you computer;
2.    Decompile it (if you are using an odexed ROM, you need to combine the “SystemUI.apk” and “SystemUI.odex” first);
3.    Open “SystemUI/res/values/strings.xml” and add these two line below;

Screenshot deleted.

4. Unzip the “add_delete_button.zip” provided here below and copy it to “SystemUI/”;
5. Open “SystemUI/smali/com/android/systemui/screenshot/ SaveImageInBackgroundTask.smali” and you will find this line:

    invoke-virtual/range {v18 .. v21}, Landroid/app/Notification$Builder;->addAction(ILjava/lang/CharSequence;Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;

6. Add these lines below:

    new-instance v8, Landroid/content/Intent;
    invoke-direct {v8}, Landroid/content/Intent;-><init>()V
    .local v8, "deleteIntent":Landroid/content/Intent;
    const-class v19, Lcom/android/systemui/screenshot/DeleteScreenshot;
    move-object/from16 v0, v19
    invoke-virtual {v8, v5, v0}, Landroid/content/Intent;->setClass(Landroid/content/Context;Ljava/lang/Class;)Landroid/content/Intent;
    const-string v19, "com.android.systemui.SCREENSHOT_URI"
    invoke-virtual/range {v17 .. v17}, Landroid/net/Uri;->toString()Ljava/lang/String;
    move-result-object v20
    move-object/from16 v0, v19
    move-object/from16 v1, v20
    invoke-virtual {v8, v0, v1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;
    .line 241
    move-object/from16 v0, p0
    iget-object v0, v0, Lcom/android/systemui/screenshot/SaveImageInBackgroundTask;->mNotificationBuilder:Landroid/app/Notification$Builder;
    move-object/from16 v19, v0
    const v20, 0x7f020021
    const v21, 0x7f090049
    move/from16 v0, v21
    invoke-virtual {v12, v0}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;
    move-result-object v21
    const/16 v22, 0x0
    const/high16 v23, 0x10000000
    move/from16 v0, v22
    move/from16 v1, v23
    invoke-static {v5, v0, v8, v1}, Landroid/app/PendingIntent;->getBroadcast(Landroid/content/Context;ILandroid/content/Intent;I)Landroid/app/PendingIntent;
    move-result-object v22
    invoke-virtual/range {v19 .. v22}, Landroid/app/Notification$Builder;->addAction(ILjava/lang/CharSequence;Landroid/app/PendingIntent;)Landroid/app/Notification$Builder;

7. Change the addresses “v8, v5, v12, v17, v23, v22, v21, v20, v19” to the correct addresses.
[code language=”plain” title=”For example(For C6833_HK_108):”]
Before – After
v8 – v15
v5 – v3
v12 – v11
v17 – v16
v23 – v22
v22 – v21
v21 – v20
v20 – v19
v19 – v18[/code]
8. Compile the package and then decompile it;
9. Open “SystemUI/smali/com/android/systemui/screenshot/DeleteScreenshot.smali” and you will find this line and then replace it with yours’:

    const v3, 0x7f09004a    # systemui/res/values/public.xml -screenshot_delete_confirmation

10. Open “SystemUI/smali/com/android/systemui/screenshot/ SaveImageInBackgroundTask.smali” and you will find these two lines and then replace the values with yours’:

    const v20, 0x7f020021    # systemui/res/values/public.xml - ic_menu_delete
    const v21, 0x7f090049    # systemui/res/values/public.xml - screenshot_delete_action

11. Open “SystemUI/ AndroidManifest.xml” and you will find this line below (if can’t, please search the keyword “screenshot”, and you will find a similar sentence):

        <service android:exported="false" android:name=".screenshot.TakeScreenshotService" android:process=":screenshot" />

12. Change it to:

        <service android:exported="false" android:name=".screenshot.TakeScreenshotService" android:process=":screenshot" />
        <receiver android:exported="true" android:name=".screenshot.DeleteScreenshot"/>

13. Compile it and then copy it to your phone, enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »