[Android General] wlryss:
Show/Hide the Text under Toggles. The Color of the Text under Toggles. Android 9 PIE. On the Fly.​

I. SystemUI.apk

Add to SystemUI.apk - GearUtils

Copy files from the downloaded SystemUI.rar archive and put in the decompiled SystemUI.apk

In SystemUI/smali/com/android/systemui/qs/tileimpl/QSTileView.smali add lines:

.class public Lcom/android/systemui/qs/tileimpl/QSTileView;
.super Lcom/android/systemui/qs/tileimpl/QSTileBaseView;
.source "QSTileView.java"

# interfaces
.implements Lcom/android/systemui/coloring/QSColoringServiceObject;
+++.implements Lcom/android/wubydax/GearContentObserver$OnContentChangedListener;

# instance fields
.field private mDefaultTextSize:F

.field private mDensityDpi:I

+++.field private mGearContentObserver:Lcom/android/wubydax/GearContentObserver;

.field protected mLabel:Landroid/widget/TextView;

.field private mLabelContainer:Landroid/view/ViewGroup;

.field protected mSecondLine:Landroid/widget/TextView;

+++.field private mTextColor:I

# direct methods

In .method public constructor <init>(Landroid/content/Context;Lcom/android/systemui/plugins/qs/QSIconView;Z)V add line before return-void:

.method public constructor <init>(Landroid/content/Context;Lcom/android/systemui/plugins/qs/QSIconView;Z)V
.locals 5

invoke-direct {p0, p1, p2, p3}, Lcom/android/systemui/qs/tileimpl/QSTileBaseView;-><init>(Landroid/content/Context;Lcom/android/systemui/plugins/qs/QSIconView;Z)V

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

invoke-virtual {p0, v1, v2, v1, v1}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setPadding(IIII)V

+++	invoke-direct {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->registerGearObserver()V

return-void
.end method

Add a method below:

.method private registerGearObserver()V
.locals 7

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->getContext()Landroid/content/Context;

move-result-object v3

invoke-virtual {v3}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v1

new-instance v3, Lcom/android/wubydax/GearContentObserver;

new-instance v4, Landroid/os/Handler;

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

invoke-direct {v3, v4, p0}, Lcom/android/wubydax/GearContentObserver;-><init>(Landroid/os/Handler;Lcom/android/wubydax/GearContentObserver$OnContentChangedListener;)V

iput-object v3, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mGearContentObserver:Lcom/android/wubydax/GearContentObserver;

new-instance v0, Ljava/util/ArrayList;

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

const-string v3, "wrp_text_viewed"

invoke-virtual {v0, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

const-string v3, "wrp_togg_use_colors"

invoke-virtual {v0, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

const-string v3, "wrp_togg_color_texto"

invoke-virtual {v0, v3}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

invoke-virtual {v0}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;

move-result-object v3

:goto_0
invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

move-result v4

if-eqz v4, :cond_0

invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

move-result-object v2

check-cast v2, Ljava/lang/String;

invoke-static {v2}, Landroid/provider/Settings$System;->getUriFor(Ljava/lang/String;)Landroid/net/Uri;

move-result-object v4

const/4 v5, 0x0

iget-object v6, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mGearContentObserver:Lcom/android/wubydax/GearContentObserver;

invoke-virtual {v1, v4, v5, v6}, Landroid/content/ContentResolver;->registerContentObserver(Landroid/net/Uri;ZLandroid/database/ContentObserver;)V

goto :goto_0

:cond_0
return-void
.end method

In .method protected createLabel()V it is necessary to increase quantity of locales (from 6 to 8) and to add the code:

.method protected createLabel()V
.locals 8

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->getContext()Landroid/content/Context;

move-result-object v0

invoke-static {v0}, Landroid/view/LayoutInflater;->from(Landroid/content/Context;)Landroid/view/LayoutInflater;

move-result-object v0
-----------------------------------------------------
iget-object v1, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mLabelContainer:Landroid/view/ViewGroup;

invoke-virtual {p0, v1}, Lcom/android/systemui/qs/tileimpl/QSTileView;->addView(Landroid/view/View;)V

+++	invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setQsTileText()V

const/4 v6, 0x0

const-string v7, "wrp_togg_use_colors"

invoke-static {v7, v6}, Lcom/android/wubydax/GearUtils;->getDbIntForKey(Ljava/lang/String;I)I

move-result v7

if-eqz v7, :cond_next

iget-object v3, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mLabel:Landroid/widget/TextView;

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setTextColor()V

iget v2, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mTextColor:I

invoke-virtual {v3, v2}, Landroid/widget/TextView;->setTextColor(I)V

:cond_next+++
return-void
.end method

In .method protected handleColorChanged(Lcom/android/systemui/plugins/qs/QSTile$State;)V it is necessary to increase quantity of locales (from 3 to 5) and to add the code:

.method protected handleColorChanged(Lcom/android/systemui/plugins/qs/QSTile$State;)V
.locals 5

invoke-super {p0, p1}, Lcom/android/systemui/qs/tileimpl/QSTileBaseView;->handleColorChanged(Lcom/android/systemui/plugins/qs/QSTile$State;)V

const-class v0, Lcom/android/systemui/coloring/QSColoringServiceManager;

invoke-static {v0}, Lcom/android/systemui/Dependency;->get(Ljava/lang/Class;)Ljava/lang/Object;
..........................................................................................................................................................
iget-object v0, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mLabel:Landroid/widget/TextView;

iget-object v2, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mContext:Landroid/content/Context;

invoke-virtual {v2, v1}, Landroid/content/Context;->getColor(I)I

move-result v2

+++	const/4 v3, 0x0

const-string v4, "wrp_togg_use_colors"

invoke-static {v4, v3}, Lcom/android/wubydax/GearUtils;->getDbIntForKey(Ljava/lang/String;I)I

move-result v4

if-eqz v4, :cond_next

iget v2, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mTextColor:I ### v2 in this line shall correspond v2 in invoke-virtual {v0, v2}, Landroid/widget/TextView;->setTextColor(I)V below

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setTextColor()V

:cond_next+++
invoke-virtual {v0, v2}, Landroid/widget/TextView;->setTextColor(I)V

:cond_1
iget-object v0, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mSecondLine:Landroid/widget/TextView;
...............................................................................................................................................................
invoke-virtual {v2, v1}, Landroid/content/Context;->getColor(I)I

move-result v1

+++	const/4 v3, 0x0

const-string v4, "wrp_togg_use_colors"

invoke-static {v4, v3}, Lcom/android/wubydax/GearUtils;->getDbIntForKey(Ljava/lang/String;I)I

move-result v4

if-eqz v4, :cond_next1

iget v1, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mTextColor:I ### v1 in this line shall correspond v1 in invoke-virtual {v0, v1}, Landroid/widget/TextView;->setTextColor(I)V below

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setTextColor()V

:cond_next1+++
invoke-virtual {v0, v1}, Landroid/widget/TextView;->setTextColor(I)V

:cond_2
invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->updateShowButtonBackground()V

return-void
.end method

In .method public updateShowButtonBackground()V it is necessary to increase quantity of locales (from 7 to 9) and to add the code:

.method public updateShowButtonBackground()V
.locals 9

const-class v0, Lcom/android/systemui/coloring/QSColoringServiceManager;

invoke-static {v0}, Lcom/android/systemui/Dependency;->get(Ljava/lang/Class;)Ljava/lang/Object;

move-result-object v0

check-cast v0, Lcom/android/systemui/coloring/QSColoringServiceManager;
..................................................................................................................
:cond_4
iget-object v6, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mContext:Landroid/content/Context;

invoke-virtual {v6, v5}, Landroid/content/Context;->getColor(I)I

move-result v5

:goto_2
+++	const/4 v7, 0x0

const-string v8, "wrp_togg_use_colors"

invoke-static {v8, v7}, Lcom/android/wubydax/GearUtils;->getDbIntForKey(Ljava/lang/String;I)I

move-result v8

if-eqz v8, :cond_next

iget-object v4, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mLabel:Landroid/widget/TextView; ### v4 in this line shall correspond v4 in invoke-virtual {v4, v5}, Landroid/widget/TextView;->setTextColor(I)V below

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setTextColor()V

iget v5, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mTextColor:I ### v5 in this line shall correspond v5 in invoke-virtual {v4, v5}, Landroid/widget/TextView;->setTextColor(I)V below

:cond_next+++
invoke-virtual {v4, v5}, Landroid/widget/TextView;->setTextColor(I)V

:cond_5
return-void
.end method

At the end of smali add methods:

.method setQsTileText()V
.locals 4

iget-object v0, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mLabel:Landroid/widget/TextView;

invoke-virtual {v0}, Landroid/widget/LinearLayout;->getContext()Landroid/content/Context;

move-result-object v0

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "wrp_text_viewed"

const v2, 0x1

invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v0

const/4 v3, 0x0

if-ne v0, v3, :cond_0

const v3, 0x8

iget-object v0, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mLabel:Landroid/widget/TextView;

invoke-virtual {v0, v3}, Landroid/widget/TextView;->setVisibility(I)V

goto :goto_0

:cond_0
const v3, 0x1

iget-object v0, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mLabel:Landroid/widget/TextView;

invoke-virtual {v0, v3}, Landroid/widget/TextView;->setVisibility(I)V

:goto_0
return-void
.end method

.method setTextColor()V
.locals 5

const/4 v3, 0x0

const-string v4, "wrp_togg_use_colors"

invoke-static {v4, v3}, Lcom/android/wubydax/GearUtils;->getDbIntForKey(Ljava/lang/String;I)I

move-result v4

if-eqz v4, :cond_0

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->getContext()Landroid/content/Context;

move-result-object v0

invoke-virtual {v0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

move-result-object v0

const-string v1, "wrp_togg_color_texto"

const v2, -0xfc45

invoke-static {v0, v1, v2}, Landroid/provider/Settings$System;->getInt(Landroid/content/ContentResolver;Ljava/lang/String;I)I

move-result v0

iput v0, p0, Lcom/android/systemui/qs/tileimpl/QSTileView;->mTextColor:I

:cond_0
return-void
.end method

.method public onContentChanged(Ljava/lang/String;)V
.locals 1

const-string v0, "wrp_text_viewed"

invoke-virtual {v0, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v0

if-eqz v0, :cond_0

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setQsTileText()V

goto :goto_0

:cond_0
const-string v0, "wrp_togg_use_colors"

invoke-virtual {v0, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v0

if-eqz v0, :cond_1

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setTextColor()V

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->updateShowButtonBackground()V

goto :goto_0

:cond_1
const-string v0, "wrp_togg_color_texto"

invoke-virtual {v0, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

move-result v0

if-eqz v0, :cond_2

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->setTextColor()V

invoke-virtual {p0}, Lcom/android/systemui/qs/tileimpl/QSTileView;->updateShowButtonBackground()V

:cond_2
:goto_0
return-void

.end method

II. Rom Control

Add in the right place:

<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Text under Toggles" android:key="wrp_text_viewed" android:defaultValue="true" android:summaryOn="Show" android:summaryOff="Hide" />
<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Change Color" android:key="wrp_togg_use_colors" android:defaultValue="false" android:summaryOn="Allowed" android:summaryOff="Forbidden" />
<com.wubydax.romcontrol.v2.prefs.ColorPickerPreference android:title="Text Color under toggles" android:key="wrp_togg_color_texto" android:dependency="wrp_togg_use_colors" android:defaultValue="\#ff212122" />