Quantcast
Channel: xda-developers - Android Themes
Viewing all articles
Browse latest Browse all 4090

How to add Screenshot toggle to Notification panel for AOSP / CM / MTK JB 4.2 ++

$
0
0
HOW TO ADD SCREENSHOT TOGGLE TO NOTIFICATION PANEL
AOSP / CM / MTK JB 4.2 ++




Hi guys :):victory::laugh::silly:
This mod is actually already in most of Open Source Rom Quicksettings Tiles view, but I change the code little bit to put the toggle on notification panel

Credit & thanks ;
- Carbon Rom, AOKP, cRdroid AOSP , CyanogenMod, BeanStalk
- [Unofficial Community] Galaxy Wonder CyanogenMod Indonesia
- Mediatek Android Art and Dev Indonesia

Feature :
- On click will take screenshot anywhere
- On long click will delay screenshot in 5 seconds

REQUIREMENT:
- BRAIN
- Patient
- experience
- Know how to decompile/recompiling Apk file
- Know how to decompile/recompiling jar Apk file
- notepad++
- Tool for decompiling, : apkmanager/apktool/Virtous/apkmultitools/ or else

STEP - 1
 

- Decompile your SystemUI.apk
- Download attached SCREENSHOT-SystemUI.zip exstract it and merge it to your decompiled SystemUI.apk
- SystemUI.apk/res/layout/status_bar_expanded_header.xml
add the red code
Code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:id="@id/header" android:background="@drawable/notification_header_bg" android:layout_width="fill_parent" android:layout_height="@dimen/notification_panel_header_height" android:baselineAligned="false"
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui">
    <RelativeLayout android:enabled="false" android:id="@id/datetime" android:background="@drawable/ic_notify_button_bg" android:paddingLeft="8.0dip" android:paddingRight="8.0dip" android:layout_width="wrap_content" android:layout_height="fill_parent">
        <com.android.systemui.statusbar.policy.Clock android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Clock" android:id="@id/clock" android:clickable="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8.0dip" android:singleLine="true" android:layout_centerVertical="true" />
        <com.android.systemui.statusbar.policy.DateView android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date" android:id="@id/date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/clock" android:layout_centerVertical="true" />
    </RelativeLayout>
    <ImageButton android:id="@id/asteroid_screenshot_button" android:background="@drawable/asteroid_screenshot_button_bg" android:paddingTop="3.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_asteroid_screenshot" android:layout_toRightOf="@id/date" android:paddingStart="7.0dip" />
    <Space android:layout_width="0.0dip" android:layout_height="0.0dip" android:layout_weight="1.0" />
    <TextView android:textSize="11.0dip" android:textStyle="bold" android:textColor="#ff00a040" android:layout_gravity="center_vertical" android:id="@id/header_debug_info" android:padding="2.0dip" android:visibility="invisible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:fontFamily="sans-serif-condensed" />
    <ImageView android:id="@id/clear_all_button" android:layout_width="50.0dip" android:layout_height="50.0dip" android:src="@drawable/ic_notify_clear" android:scaleType="center" android:contentDescription="@string/accessibility_clear_all" />
    <FrameLayout android:id="@id/settings_button_holder" android:layout_width="50.0dip" android:layout_height="50.0dip" android:layout_marginLeft="12.0dip">
        <ImageView android:id="@id/settings_button" android:layout_width="50.0dip" android:layout_height="50.0dip" android:src="@drawable/ic_notify_settings" android:scaleType="center" android:contentDescription="@string/accessibility_desc_quick_settings" />
        <ImageView android:id="@id/notification_button" android:visibility="gone" android:layout_width="50.0dip" android:layout_height="50.0dip" android:src="@drawable/ic_notifications" android:scaleType="center" android:contentDescription="@string/accessibility_notifications_button" />
    </FrameLayout>
</LinearLayout>

- SystemUI.apk/res/values/strings.xml
add the red line to end of it before </resources>
Code:

    <string name="status_bar_help_title">Notifications appear here</string>
    <string name="status_bar_help_text">"Access them anytime by swiping down.
Swipe down again for system controls."</string>
    <string name="permdesc_screenshot">Capture screenshot</string>
    <string name="permlab_screenshot">Allows the app to cature a screenshot. This is protected by SystemUI.</string>
    <string name="screenshot_toast">Screenshot in %1$d seconds</string>

</resources>

- SystemUI.apk/res/values/ids.xml
add the red line to end of it before </resources>
Code:

    <item type="id" name="notification_inspect_item">false</item>
    <item type="id" name="recent_remove_item">false</item>
    <item type="id" name="recent_inspect_item">false</item>
    <item type="id" name="asteroid_screenshot_button">false</item>
</resources>

- Recompile your SystemUI.apk



STEP - 2
 

- Decompile the newly Recompiled APK again

Next go to
res/values/public.xml
open it with Notepad++
leave it, but keep it open

- smali/com/android/systemui/statusbar/phone/PhoneStatusBar.smali
add the red lines :

Code:

.field mAnimY:F

.field mAnimating:Z

.field mAnimatingReveal:Z

.field mAsteroidScreenshotButton:Landroid/widget/ImageButton;

.field mBatteryController:Lcom/android/systemui/statusbar/policy/BatteryController;

.field mBluetoothController:Lcom/android/systemui/statusbar/policy/BluetoothController;


Code:

.field mFlipSettingsViewAnim:Landroid/animation/Animator;

.field mFocusChangeListener:Landroid/view/View$OnFocusChangeListener;

.field private final mGestureRec:Lcom/android/systemui/statusbar/GestureRecorder;

.field public mHandler:Landroid/os/Handler;

.field private mHasDockBattery:Z

.field mHasFlipSettings:Z


Code:

.field mQS:Lcom/android/systemui/statusbar/phone/QuickSettingsController;

.field mQueueLock:Ljava/lang/Object;

.field private final mRecentsClickListener:Landroid/view/View$OnClickListener;

.field private mRecreating:Z

.field private mRunnable:Ljava/lang/Runnable;

.field private mScreenWidth:F

.field mScrollView:Landroid/widget/ScrollView;

.field mScrollViewAnim:Landroid/animation/Animator;

- NEXT, Search this method
Code:

.method public constructor <init>()V
and add the red code
Code:

    iput v2, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mDisabled:I

 
    iput v2, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mSystemUiVisibility:I

    new-instance v0, Landroid/os/Handler;

    invoke-direct {v0}, Landroid/os/Handler;-><init>()V

    iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mHandler:Landroid/os/Handler;


   
    new-instance v0, Landroid/util/DisplayMetrics;

    invoke-direct {v0}, Landroid/util/DisplayMetrics;-><init>()V

    iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mDisplayMetrics:Landroid/util/DisplayMetrics;

   
    iput-object v3, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mGestureRec:Lcom/android/systemui/statusbar/GestureRecorder;

   
    iput v2, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mNavigationIconHints:I


- NEXT, still in the same method,
add the red code above return-void
Code:

new-instance v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$32;

    invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$32;-><init>(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V

    iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStartTracing:Ljava/lang/Runnable;

   
    new-instance v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$33;

    invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$33;-><init>(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V

    iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStopTracing:Ljava/lang/Runnable;

    new-instance v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$AsteroidSrcreenshot5;

    invoke-direct {v0, p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$AsteroidSrcreenshot5;-><init>(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V

    iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mRunnable:Ljava/lang/Runnable;


   
    return-void
.end method

.method static synthetic access$000(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;I)V
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 116
    invoke-direct {p0, p1}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->adjustBrightness(I)V

    return-void
.end method

- NEXT, add new access
Code:

    return-void
.end method

.method static synthetic access$130000000(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)Ljava/lang/Runnable;
    .locals 1
    .parameter "x0"

    .prologue
    .line 34
    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mRunnable:Ljava/lang/Runnable;

    return-object v0
.end method


.method static synthetic access$000(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;I)V

NEXT
Code:

    iget-object v1, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mLightsOnAnimation:Landroid/animation/Animator;

    goto :goto_0
.end method

.method private setupAsteroidScreenshotButton()V
    .locals 3

    .prologue
    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarWindow:Lcom/android/systemui/statusbar/phone/StatusBarWindowView;

    const v1, 0x7f0900e5

    invoke-virtual {v0, v1}, Lcom/android/systemui/statusbar/phone/StatusBarWindowView;->findViewById(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Landroid/widget/ImageButton;

    iput-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mAsteroidScreenshotButton:Landroid/widget/ImageButton;

    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mAsteroidScreenshotButton:Landroid/widget/ImageButton;

    new-instance v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$AsteroidSrcreenshot3;

    invoke-direct {v1, p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$AsteroidSrcreenshot3;-><init>(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V

    invoke-virtual {v0, v1}, Landroid/widget/ImageButton;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mAsteroidScreenshotButton:Landroid/widget/ImageButton;

    new-instance v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$AsteroidSrcreenshot4;

    invoke-direct {v1, p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar$AsteroidSrcreenshot4;-><init>(Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V

    invoke-virtual {v0, v1}, Landroid/widget/ImageButton;->setOnLongClickListener(Landroid/view/View$OnLongClickListener;)V

    return-void
.end method


.method private updateShowSearchHoldoff()V
    .locals 2

    .prologue
    .line 1133
    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    const v1, 0x7f0d0001

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getInteger(I)I

    move-result v0

    iput v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mShowSearchHoldoff:I

    .line 1135
    return-void
.end method

Quote:

Change this 0x7f0900e5, according to the value you got in your own public.xml
Code:

<public type="id" name="asteroid_screenshot_button" id="0x7f??????" />


NEXT, find this method
Code:

.method protected makeStatusBarView()Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;
and add the red code
Code:

const-string v1, "android.intent.action.SCREEN_ON"

    invoke-virtual {v0, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 775
    iget-object v1, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v4, v1, v0}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 778
    invoke-direct {p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->resetUserSetupObserver()V

  invoke-direct {p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->setupAsteroidScreenshotButton()V

    .line 780
    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mPowerWidget:Lcom/android/systemui/statusbar/powerwidget/PowerWidget;

    invoke-virtual {v0}, Lcom/android/systemui/statusbar/powerwidget/PowerWidget;->setupWidget()V

    .line 781
    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mPowerWidget:Lcom/android/systemui/statusbar/powerwidget/PowerWidget;

    invoke-virtual {v0}, Lcom/android/systemui/statusbar/powerwidget/PowerWidget;->updateVisibility()V


.method public static viewInfo(Landroid/view/View;)Ljava/lang/String;
    .locals 2
    .parameter

OR MEDIATEK DEVICES

Code:

    const-string v1, "android.intent.action.ACTION_BOOT_IPO"

    invoke-virtual {v12, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 768
    const-string v1, "android.provider.Telephony.SPN_STRINGS_UPDATED"

    invoke-virtual {v12, v1}, Landroid/content/IntentFilter;->addAction(Ljava/lang/String;)V

    .line 769
    move-object/from16 v0, p0

    iget-object v1, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBroadcastReceiver:Landroid/content/BroadcastReceiver;

    invoke-virtual {v11, v1, v12}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 772
    invoke-direct/range {p0 .. p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->resetUserSetupObserver()V

    invoke-direct/range {p0 .. p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->setupAsteroidScreenshotButton()V

    .line 774
    new-instance v20, Landroid/content/IntentFilter;

    invoke-direct/range {v20 .. v20}, Landroid/content/IntentFilter;-><init>()V

    .line 775
    .local v20, simInfoIntentFilter:Landroid/content/IntentFilter;
    const-string v1, "android.intent.action.SIM_SETTING_INFO_CHANGED"

NEXT,
go to,.
- smali/com/android/systemui/statusbar/phone/PhoneStatusBar$AsteroidSrcreenshot4.smali
search for this
Code:

const v4, 0x7f0a00f8
Change this 0x7f0a00f8, according to the value you got in your own public.xml
Code:

<public type="string" name="screenshot_toast" id="0x7f??????" />
- NEXT

- Disable signature check
here : http://forum.xda-developers.com/show....php?t=1698352
or in here : http://forum.xda-developers.com/show...01&postcount=3

- AndroidManifest.xml
Add The RED CODE , and
REMOVE the BLUE CODE
Code:

<uses-permission android:name="android.permission.READ_DREAM_STATE" />
    <uses-permission android:name="android.permission.WRITE_DREAM_STATE" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
    <protected-broadcast android:name="android.permission.SCREENSHOT" />
    <protected-broadcast android:name="android.intent.action.SCREENSHOT" />
    <permission android:label="@string/permlab_screenshot" android:name="android.permission.SCREENSHOT" android:protectionLevel="signatureOrSystem" android:description="@string/permdesc_screenshot" />

    <application android:label="@string/app_label" android:icon="@*android:drawable/platlogo" android:allowClearUserData="false" android:persistent="true" android:allowBackup="false" android:hardwareAccelerated="true">
        <service android:name="SystemUIService" android:exported="true" />
        <service android:name=".screenshot.TakeScreenshotService" android:permission="android.permission.SCREENSHOT" android:exported="false" android:process=":screenshot">
            <intent-filter>
                <android name="android.intent.action.SCREENSHOT" />
            </intent-filter>
        </service>

        <service android:name=".screenshot.TakeScreenshotService" android:exported="false" android:process=":screenshot" />
        <service android:name=".LoadAverageService" android:exported="true" />
        <service android:name=".ImageWallpaper" android:permission="android.permission.BIND_WALLPAPER" android:exported="true" />
        <receiver android:name=".BootReceiver" androidprv:primaryUserOnly="true">

- RECOMPILE YOUR SYSTEMUI.APK and SIGN it

- I ussually use ApkMultitools to decompile/recompile/sign APK
so if you use ApkMultitools, you can use my signer keys
download attached file, exstract it and merge to your ApkMultitools / other / here

Attached Thumbnails
Click image for larger version

Name:	Screenshot_.png
Views:	N/A
Size:	8.0 KB
ID:	2801648  
Attached Files
File Type: zip SCREENSHOT-SystemUI.apk.zip - [Click for QR Code] (8.1 KB)
File Type: zip Signer_CM11-KK.zip - [Click for QR Code] (5.4 KB)

Viewing all articles
Browse latest Browse all 4090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>