GUIDE - HOW TO ADD NETWORK TRAFFIC TINT ON LIGHT STATUS BAR
CREDITS TO @daxgirl for original mod!
First you will need to add
<item type="id" name="network_traffic">false</item> to your ids.xml, you can call the id whatever you want just remember it
Second add the newly created id to res/layout/status_bar.xml, I have highlighted it here in blue, note it matches the id created <com.android.wubydax.NetworkTraffic android:id="
@id/network_traffic" android:layout_width="wrap_content" android:layout_height="fill_parent" />
Third we will add this id in StatusbarIconController in the method noted below - addition noted in blue, I have included some code here as an example from my file - I also increased my locals to use the new way of adding ids without decompiling and recompiling systemUI.
Please also add field mNetworkTraffic:Lcom/android/wubydax/NetworkTraffic;:
Code:
.method public constructor <init>(Landroid/content/Context;Landroid/view/View;Landroid/view/View;Lcom/android/systemui/statusbar/phone/PhoneStatusBar;)V
.locals 9
.param p1, "context" # Landroid/content/Context;
.param p2, "statusBar" # Landroid/view/View;
.param p3, "keyguardStatusBar" # Landroid/view/View;
.param p4, "phoneStatusBar" # Lcom/android/systemui/statusbar/phone/PhoneStatusBar;
.prologue
.
.
.
.
.line 183
iget-object v1, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mNotificationIcons:Lcom/android/systemui/statusbar/phone/IconMerger;
iget-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mMoreIcon:Landroid/widget/ImageView;
invoke-virtual {v1, v2}, Lcom/android/systemui/statusbar/phone/IconMerger;->setOverflowIndicator(Landroid/view/View;)V
.line 184
invoke-virtual {p3, v3}, Landroid/view/View;->findViewById(I)Landroid/view/View;
move-result-object v1
check-cast v1, Landroid/widget/LinearLayout;
iput-object v1, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mStatusIconsKeyguard:Landroid/widget/LinearLayout;
.line 185
invoke-virtual {p2, v6}, Landroid/view/View;->findViewById(I)Landroid/view/View;
move-result-object v1
check-cast v1, Lcom/android/systemui/BatteryMeterView;
iput-object v1, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mBatteryMeterView:Lcom/android/systemui/BatteryMeterView;
[COLOR="Blue"] const-string v7, "network_traffic"
const-string v8, "id"
invoke-static {v7, v8}, Lcom/android/wubydax/GearUtils;->getIdentifier(Ljava/lang/String;Ljava/lang/String;)I
move-result v1
invoke-virtual {p2, v1}, Landroid/view/View;->findViewById(I)Landroid/view/View;
move-result-object v1
check-cast v1, Lcom/android/wubydax/NetworkTraffic;
iput-object v1, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mNetworkTraffic:Lcom/android/wubydax/NetworkTraffic;[/COLOR]
.
.
.
Fourth in the same smali in .method private applyIconTint()V add the following (I added it just under he battery meter view section - but i have tried adding it other places and it works.
Code:
iget-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mBatteryMeterView:Lcom/android/systemui/BatteryMeterView;
iget v3, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mDarkIntensity:F
invoke-virtual {v2, v3}, Lcom/android/systemui/BatteryMeterView;->setDarkIntensity(F)V
#####
[COLOR="Blue"]iget-object v2, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mNetworkTraffic:Lcom/android/wubydax/NetworkTraffic;
iget v3, p0, Lcom/android/systemui/statusbar/phone/StatusBarIconController;->mDarkIntensity:F
invoke-virtual {v2, v3}, Lcom/android/wubydax/NetworkTraffic;->setDarkIntensity(F)V[/COLOR]
Fifth The rest of he work will be in the NetworkTraffic smali that was added from
@daxgirl mod:
Add the following fields:
.field private mLightModeIconColorSingleTone:I
.field private mDarkModeIconColorSingleTone:I
.field private mDownloadTint:I
.field private mUploadTint:I
.field private mNetworkTrafficTint:I
.field private mNetworkTrafficArrowTint:I
sixth Same smali in .method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet
V add the following, I included additional code to show where added:
Code:
.
.
const-string v3, "dimen"
invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
move-result-object v4
invoke-virtual {v1, v2, v3, v4}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
move-result v2
invoke-virtual {v1, v2}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I
move-result v2
iput v2, p0, Lcom/android/wubydax/NetworkTraffic;->txtSizeMulti:I
.line 231
[COLOR="Blue"] const v2, 0x7f0a00ad ##make sure this agrees to your id for "dark_mode_icon_color_single_tone"
invoke-virtual {p1, v2}, Landroid/content/Context;->getColor(I)I
move-result v2
iput v2, p0, Lcom/android/wubydax/NetworkTraffic;->mDarkModeIconColorSingleTone:I
const v2, 0x7f0a00b1 ##make sure this agrees to your id for "light_mode_icon_color_single_tone"
invoke-virtual {p1, v2}, Landroid/content/Context;->getColor(I)I
move-result v2
iput v2, p0, Lcom/android/wubydax/NetworkTraffic;->mLightModeIconColorSingleTone:I[/COLOR]
seventh Add the following private method which is really a copy past from StatusbarIconController smali - however
PLEASE ENSURE to change the float in the bracket to
(FII) since the evaluation method in the NetworkTraffic.smali is written slighly different, also make sure path is updated in appropriate spot to
Lcom/android/wubydax/NetworkTraffic
Code:
[COLOR="blue"].method private getTintInternal(FII)I
.locals 3
invoke-static {}, Landroid/animation/ArgbEvaluator;->getInstance()Landroid/animation/ArgbEvaluator;
move-result-object v0
invoke-static {p2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v1
iget v2, p0, Lcom/android/wubydax/NetworkTraffic;->mDarkModeIconColorSingleTone:I
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2
invoke-virtual {v0, p1, v1, v2}, Landroid/animation/ArgbEvaluator;->evaluate(FLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/lang/Integer;
invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I
move-result v0
return v0
.end method[/COLOR]
eight in .method private updateSettings()V do the following, again I have included some code to show what I did. Since you are using the same NetworkTraffic smali it will be easy to find:
Code:
if-eqz v9, :cond_95
.line 289
[COLOR="Red"]#iget v9, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficColor:I #I have found that it works without this change[/COLOR]
[COLOR="Blue"]iget v9, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficTint:I[/COLOR]
.
.
.local v8, "uploadColored":Landroid/text/SpannableString;
[COLOR="Red"]# iget v9, p0, Lcom/android/wubydax/NetworkTraffic;->mUploadColor:I[/COLOR]
[COLOR="Blue"] iget v9, p0, Lcom/android/wubydax/NetworkTraffic;->mUploadTint:I[/COLOR]
.
.
.local v2, "downloadColored":Landroid/text/SpannableString;
[COLOR="Red"]# iget v9, p0, Lcom/android/wubydax/NetworkTraffic;->mDownloadColor:I[/COLOR]
[COLOR="Blue"] iget v9, p0, Lcom/android/wubydax/NetworkTraffic;->mDownloadTint:I[/COLOR]
.
.
ninth in .method private updateTrafficDrawable()V do the following:
Code:
.
.
[COLOR="Red"]# iget v2, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficColor:I[/COLOR]
[COLOR="Blue"] iget v2, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficTint:I[/COLOR]
.
.
.
.
[COLOR="Red"]# iget v2, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficArrowColor:I[/COLOR]
[COLOR="Blue"]iget v2, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficArrowTint:I[/COLOR]
tenth add the following method at the bottom of smali:
Code:
[COLOR="Blue"].method public setDarkIntensity(F)V
.locals 2
.param p1, "darkIntensity" # F
.prologue
.line 371
iget v1, p0, Lcom/android/wubydax/NetworkTraffic;->mLightModeIconColorSingleTone:I
iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficColor:I
invoke-direct {p0, p1, v0, v1}, Lcom/android/wubydax/NetworkTraffic;->getTintInternal(FII)I
move-result v0
iput v0, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficTint:I
iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficArrowColor:I
invoke-direct {p0, p1, v0, v1}, Lcom/android/wubydax/NetworkTraffic;->getTintInternal(FII)I
move-result v0
iput v0, p0, Lcom/android/wubydax/NetworkTraffic;->mNetworkTrafficArrowTint:I
iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mUploadColor:I
invoke-direct {p0, p1, v0, v1}, Lcom/android/wubydax/NetworkTraffic;->getTintInternal(FII)I
move-result v0
iput v0, p0, Lcom/android/wubydax/NetworkTraffic;->mUploadTint:I
iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mDownloadColor:I
invoke-direct {p0, p1, v0, v1}, Lcom/android/wubydax/NetworkTraffic;->getTintInternal(FII)I
move-result v0
iput v0, p0, Lcom/android/wubydax/NetworkTraffic;->mDownloadTint:I
.line 373
invoke-direct {p0}, Lcom/android/wubydax/NetworkTraffic;->updateSettings()V
.line 374
return-void
.end method[/COLOR]
Note there is a bug on updating colors which will either require a systemUI restart of go from regular statusbar to light statusbar then after the tint animation the color updates - I am not an expert so not sure about this yet. Maybe an expert can help - @daxgirl I certainly hope you don't mind me messing up you mod! thanks in advance - please help with kinks?? Thanks. This was a lot of trial and error - of course with some understanding (a little...hahaha) of what i was doing
oh - also i had to make these access changes it would not work properly until i did, they are called in NetworkTraffic$1 smali:
Code:
.method static synthetic access$1200(Lcom/android/wubydax/NetworkTraffic;)I
.registers 2
.param p0, "x0" # Lcom/android/wubydax/NetworkTraffic;
.prologue
.line 42
[COLOR="Red"]# iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mDownloadColor:I[/COLOR]
[COLOR="Blue"]iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mDownloadTint:I[/COLOR]
return v0
.end method
Code:
.method static synthetic access$900(Lcom/android/wubydax/NetworkTraffic;)I
.registers 2
.param p0, "x0" # Lcom/android/wubydax/NetworkTraffic;
.prologue
.line 42
[COLOR="Red"]# iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mUploadColor:I[/COLOR]
[COLOR="Blue"] iget v0, p0, Lcom/android/wubydax/NetworkTraffic;->mUploadTint:I[/COLOR]
return v0
.end method