Quantcast
Channel: xda-developers - Verizon Galaxy S III Android Development
Viewing all articles
Browse latest Browse all 352

[MOD] GUIDE] Add working brightness slider and WiFi toggle to the expanded status bar

$
0
0
This MOD/GUIDE will add a working brightness slider bar and Wifi quick button to your drop down status bar.

I know there are some other mods out there that do this by adding lidroid-res and a quick panel APK but this will do it with just some smali edits so no new APKs to install. This is just the brightness slider and WiFi quick button, not the 15 quickbutton mod

This has been tested on a STOCK DEODEXed LG7 ROM. If you want to add this to a custom ROM you will likely lose some other MODs/Themes.

Always Nandroid First!

Dev's, if you want to use this in your ROMs feel free but please throw me a thanks and some credit.

Here is the guide.....

 


We will be de/recompiling SystemUI.apk.

Navigate to res/values/arrays

find the following code
 
Code:

        <item>Bluetooth</item>
        <item>Location</item>
        <item>SilentMode</item>
        <item>MobileData</item>
        <item>AutoRotate</item>
        <item>PowerSaving</item>
        <item>AirplaneMode</item>
        <item>DrivingMode</item>
        <item>Sync</item>



Change it to the following:
 
Code:

        <item>Wifi</item>
        <item>Location</item>
        <item>Bluetooth</item>
        <item>SilentMode</item>
        <item>MobileData</item>
        <item>AutoRotate</item>
        <item>PowerSaving</item>
        <item>AirplaneMode</item>
        <item>DrivingMode</item>



Feel free to change the order of the code above to suit your needs. They will layout in your quickpanel in the same order you put them in above.

Navigate to res/layout/tw_status_bar_expanded.xml

Find the following code and delete the part in RED only:
 
Code:

<LinearLayout android:orientation="horizontal" android:focusable="true" android:visibility="gone" android:clickable="true" android:layout_width="fill_parent" android:layout_height="56.0dip">


That will make the brightness slider visible but not yet functional.

Navigate to smali/com/android/systemui/statusbar/phone/PhoneStatusBar.smali

Add the following lines below in GREEN
 
Code:

.field private mBatteryTextObserver:Lcom/android/systemui/statusbar/phone/PhoneStatusBar$BatteryTextObserver;

.field mBrightness:Lcom/android/systemui/statusbar/policy/BrightnessController;

.field private mBroadcastReceiver:Landroid/content/BroadcastReceiver;



For the next step there are a lot of changes that need to be made in the Method. For the sake of time and this guide, we will simply C&P the entire method with the revised one. If you are anal like me and would like to see exactly what is being changed, simly use your editor compare tool to see the differences.

Find the following line:
 
Code:

.method interceptTouchEvent(Landroid/view/MotionEvent;)Z


Starting at (and including) the very next line delete all code all the way up to (and including) the first "end Method" you come to and paste in the following in its place. You may want to copy half the code and paste and copy the other half and paste. One C&P may not capture all the code at one time.

 
Code:

.locals 16

    move-object/from16 v0, p0

    iget v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mDisabled:I

    const/high16 v13, 0x1

    and-int/2addr v12, v13

    if-eqz v12, :cond_0

    const/4 v12, 0x0

    :goto_0
    return v12

    :cond_0
    const-string v12, "STATUSBAR-PhoneStatusBar"

    new-instance v13, Ljava/lang/StringBuilder;

    invoke-direct {v13}, Ljava/lang/StringBuilder;-><init>()V

    const-string v14, "interceptTouchEvent() : "

    invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v13

    move-object/from16 v0, p1

    invoke-virtual {v13, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v13

    invoke-virtual {v13}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v13

    invoke-static {v12, v13}, Landroid/util/Slog;->d(Ljava/lang/String;Ljava/lang/String;)I

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBrightness:Lcom/android/systemui/statusbar/policy/BrightnessController;

    invoke-virtual {v12}, Lcom/android/systemui/statusbar/policy/BrightnessController;->syncBrightness()V

    invoke-virtual/range {p1 .. p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v1

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mStatusBarView:Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;

    invoke-virtual {v12}, Lcom/android/systemui/statusbar/phone/PhoneStatusBarView;->getHeight()I

    move-result v6

    mul-int/lit8 v3, v6, 0x2

    invoke-virtual/range {p1 .. p1}, Landroid/view/MotionEvent;->getRawY()F

    move-result v12

    float-to-int v10, v12

    if-nez v1, :cond_7

    invoke-virtual/range {p0 .. p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->isUnsecureKeyguardLocked()Z

    move-result v12

    if-eqz v12, :cond_1

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

    :cond_1

    move-object/from16 v0, p0

    iget-boolean v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mExpanded:Z

    if-nez v12, :cond_5

    sub-int v12, v6, v10

    move-object/from16 v0, p0

    iput v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mViewDelta:I

    :goto_1

    move-object/from16 v0, p0

    iget-boolean v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mExpanded:Z

    if-nez v12, :cond_2

    if-lt v10, v3, :cond_3

    :cond_2

    move-object/from16 v0, p0

    iget-boolean v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mExpanded:Z

    if-eqz v12, :cond_4

    move-object/from16 v0, p0

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

    iget v12, v12, Landroid/util/DisplayMetrics;->heightPixels:I

    sub-int/2addr v12, v3

    if-le v10, v12, :cond_4

    :cond_3
    invoke-virtual/range {p1 .. p1}, Landroid/view/MotionEvent;->getRawX()F

    move-result v12

    float-to-int v8, v12

    move-object/from16 v0, p0

    iget v2, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mEdgeBorder:I

    if-lt v8, v2, :cond_4

    move-object/from16 v0, p0

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

    iget v12, v12, Landroid/util/DisplayMetrics;->widthPixels:I

    sub-int/2addr v12, v2

    if-ge v8, v12, :cond_4

    move-object/from16 v0, p0

    iget-boolean v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mExpanded:Z

    if-nez v12, :cond_6

    const/4 v12, 0x1

    :goto_2

    move-object/from16 v0, p0

    invoke-virtual {v0, v10, v12}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->prepareTracking(IZ)V

    invoke-direct/range {p0 .. p1}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->trackMovement(Landroid/view/MotionEvent;)V

    :cond_4
    :goto_3
    const/4 v12, 0x0

    goto/16 :goto_0

    :cond_5

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mTrackingView:Lcom/android/systemui/statusbar/phone/TrackingView;

    move-object/from16 v0, p0

    iget-object v13, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mAbsPos:[I
       
    invoke-virtual {v12, v13}, Lcom/android/systemui/statusbar/phone/TrackingView;->getLocationOnScreen([I)V

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mAbsPos:[I

    const/4 v13, 0x1

    aget v12, v12, v13

    move-object/from16 v0, p0

    iget-object v13, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mTrackingView:Lcom/android/systemui/statusbar/phone/TrackingView;

    invoke-virtual {v13}, Lcom/android/systemui/statusbar/phone/TrackingView;->getHeight()I

    move-result v13

    add-int/2addr v12, v13

    sub-int/2addr v12, v10

    move-object/from16 v0, p0

    iput v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mViewDelta:I

    goto :goto_1

    :cond_6
    const/4 v12, 0x0

    goto :goto_2

    :cond_7

    move-object/from16 v0, p0

    iget-boolean v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mTracking:Z

    if-eqz v12, :cond_4

    invoke-direct/range {p0 .. p1}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->trackMovement(Landroid/view/MotionEvent;)V

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mCloseView:Lcom/android/systemui/statusbar/phone/CloseDragHandle;

    invoke-virtual {v12}, Lcom/android/systemui/statusbar/phone/CloseDragHandle;->getHeight()I

    move-result v12

    add-int v4, v6, v12

    const/4 v12, 0x2

    if-ne v1, v12, :cond_a

    invoke-virtual/range {p0 .. p0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->isUnsecureKeyguardLocked()Z

    move-result v12

    if-eqz v12, :cond_8

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

    :cond_8

    move-object/from16 v0, p0

    iget-boolean v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mAnimatingReveal:Z

    if-eqz v12, :cond_9

    if-lt v10, v4, :cond_4

    :cond_9
    const/4 v12, 0x0

    move-object/from16 v0, p0

    iput-boolean v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mAnimatingReveal:Z

    move-object/from16 v0, p0

    iget v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mViewDelta:I

    add-int/2addr v12, v10

    move-object/from16 v0, p0

    invoke-virtual {v0, v12}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->updateExpandedViewPos(I)V

    goto :goto_3

    :cond_a
    const/4 v12, 0x1

    if-eq v1, v12, :cond_b

    const/4 v12, 0x3

    if-ne v1, v12, :cond_4

    :cond_b

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mVelocityTracker:Landroid/view/VelocityTracker;
       
    const/16 v13, 0x3e8

    invoke-virtual {v12, v13}, Landroid/view/VelocityTracker;->computeCurrentVelocity(I)V

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mVelocityTracker:Landroid/view/VelocityTracker;

    invoke-virtual {v12}, Landroid/view/VelocityTracker;->getYVelocity()F

    move-result v11

    const/4 v12, 0x0

    cmpg-float v12, v11, v12

    if-gez v12, :cond_f

    const/4 v5, 0x1

    :goto_4

    move-object/from16 v0, p0

    iget-object v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mVelocityTracker:Landroid/view/VelocityTracker;

    invoke-virtual {v12}, Landroid/view/VelocityTracker;->getXVelocity()F

    move-result v9

    const/4 v12, 0x0

    cmpg-float v12, v9, v12

    if-gez v12, :cond_c

    neg-float v9, v9

    :cond_c

    move-object/from16 v0, p0

    iget v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mFlingGestureMaxXVelocityPx:F

    cmpl-float v12, v9, v12

    if-lez v12, :cond_d

    move-object/from16 v0, p0

    iget v9, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mFlingGestureMaxXVelocityPx:F

    :cond_d
    float-to-double v12, v11

    float-to-double v14, v9

    invoke-static {v12, v13, v14, v15}, Ljava/lang/Math;->hypot(DD)D

    move-result-wide v12

    double-to-float v7, v12

    if-eqz v5, :cond_e

    neg-float v7, v7

    :cond_e

    move-object/from16 v0, p0

    iget v12, v0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mViewDelta:I

    add-int/2addr v12, v10

    const/4 v13, 0x0

    move-object/from16 v0, p0

    invoke-virtual {v0, v12, v7, v13}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->performFling(IFZ)V

    goto/16 :goto_3

    :cond_f
    const/4 v5, 0x0

    goto :goto_4
.end method



Find the following code and add the lines in GREEN:
 
Code:

iput-boolean v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mUseStatusBarMarquee:Z


    new-instance v19, Lcom/android/systemui/statusbar/policy/BrightnessController;

    const v18, 0x7f0f0097

    move/from16 v0, v18

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

    move-result-object v18

    check-cast v18, Lcom/android/systemui/statusbar/policy/ToggleSlider;

    move-object/from16 v0, v19

    move-object/from16 v1, v18

    invoke-direct {v0, v4, v1}, Lcom/android/systemui/statusbar/policy/BrightnessController;-><init>(Landroid/content/Context;Lcom/android/systemui/statusbar/policy/ToggleSlider;)V

    move-object/from16 v0, v19

    move-object/from16 v1, p0

    iput-object v0, v1, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBrightness:Lcom/android/systemui/statusbar/policy/BrightnessController;


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


    return-object v13



Find the following code and add the parts in GREEN
 
Code:

invoke-virtual {p0, v0}, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->setSystemUiVisibility(I)V

    goto :goto_0
.end method

.method public setMaxBrightness(I)V
    .locals 1

    iget-object v0, p0, Lcom/android/systemui/statusbar/phone/PhoneStatusBar;->mBrightness:Lcom/android/systemui/statusbar/policy/BrightnessController;

    invoke-virtual {v0, p1}, Lcom/android/systemui/statusbar/policy/BrightnessController;->setMaxBrightness(I)V

    return-void
.end method

.method setNotificationIconVisibility(ZI)V



Thats it!


Recompile
Chmod 644
Push to /system/app

Let me know how it goes.


Viewing all articles
Browse latest Browse all 352

Trending Articles



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