Skip to content

Commit d555ba5

Browse files
SuperDroidBondaoleary
authored andcommitted
[Base 1/2] QS Tile Icon Accent Toggle
Idea taken from -: DotOS/android_frameworks_base@8976f61 aex edits:- disabled by default, remove useless overlay Change-Id: I834053e6b118024e1b0609150df641b999fd48f9
1 parent 9be443d commit d555ba5

4 files changed

Lines changed: 40 additions & 6 deletions

File tree

core/java/android/provider/Settings.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4840,6 +4840,14 @@ public boolean validate(String value) {
48404840
*/
48414841
public static final String CHOOSER_ACTIVITY_BLACKLIST = "chooser_activity_blacklist";
48424842

4843+
/**
4844+
** Whether to show Device Accent on QS on the screen.
4845+
** 0 = OFF
4846+
** 1 = ON
4847+
** @hide
4848+
**/
4849+
public static final String QS_TILE_TINTING_ENABLE = "qs_tile_tinting_enable";
4850+
48434851
/**
48444852
* Settings to backup. This is here so that it's in the same place as the settings
48454853
* keys and easy to update.

packages/SystemUI/res/values/aos_colors.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
<!-- Zen QS panel -->
4545
<color name="zen_qs_panel_close_button_color">@android:color/white</color>
4646

47+
<!-- QS tiles Active and Inactive tint (Requires config_enable_qs_tile_tinting bool set to true) -->
48+
<color name="qs_tiles_active_tint">@*android:color/accent_device_default_light</color>
49+
<color name="qs_tiles_inactive_tint">@*android:color/hint_foreground_material_light</color>
50+
<color name="qs_tiles_unavailable_tint">@*android:color/foreground_material_light</color> <!-- keep in mind that the code adds 0.26 (light) or 0.30 (dark) alpha to this color. -->
51+
4752
<!-- Theme tile DO NOT OVERLAY!!! We need the true colors here! -->
4853
<color name="quick_settings_theme_tile_default">#4285F4</color>
4954
<color name="quick_settings_theme_tile_red">#FF5252</color>

packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import android.view.View;
2828
import android.widget.ImageView;
2929
import android.widget.ImageView.ScaleType;
30+
import android.provider.Settings;
31+
import android.os.Handler;
3032

3133
import com.android.systemui.R;
3234
import com.android.systemui.plugins.qs.QSIconView;
@@ -173,7 +175,7 @@ public static void animateGrayScale(int fromColor, int toColor, ImageView iv) {
173175
int alpha = (int) (fromAlpha + (toAlpha - fromAlpha) * fraction);
174176
int channel = (int) (fromChannel + (toChannel - fromChannel) * fraction);
175177

176-
setTint(iv, Color.argb(alpha, channel, channel, channel));
178+
setTint(iv, toColor);
177179
});
178180

179181
anim.start();

packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import android.util.ArraySet;
3737
import android.util.Log;
3838
import android.util.SparseArray;
39-
39+
import android.provider.Settings;
4040
import com.android.internal.annotations.VisibleForTesting;
4141
import com.android.internal.logging.MetricsLogger;
4242
import com.android.settingslib.RestrictedLockUtils;
@@ -50,6 +50,8 @@
5050
import com.android.systemui.qs.PagedTileLayout.TilePage;
5151
import com.android.systemui.qs.QSHost;
5252

53+
import com.android.systemui.R;
54+
5355
import java.util.ArrayList;
5456

5557
/**
@@ -370,14 +372,31 @@ protected void checkIfRestrictionEnforcedByAdminOnly(State state, String userRes
370372
public abstract CharSequence getTileLabel();
371373

372374
public static int getColorForState(Context context, int state) {
375+
376+
boolean enableQsTileTinting = Settings.System.getInt(context.getContentResolver(),
377+
Settings.System.QS_TILE_TINTING_ENABLE, 0) == 1;
378+
373379
switch (state) {
374380
case Tile.STATE_UNAVAILABLE:
375-
return Utils.getDisabled(context,
376-
Utils.getColorAttr(context, android.R.attr.colorForeground));
381+
if (enableQsTileTinting) {
382+
return Utils.getDisabled(context,
383+
context.getResources().getColor(R.color.qs_tiles_unavailable_tint));
384+
} else {
385+
return Utils.getDisabled(context,
386+
Utils.getColorAttr(context, android.R.attr.colorForeground));
387+
}
377388
case Tile.STATE_INACTIVE:
378-
return Utils.getColorAttr(context, android.R.attr.textColorHint);
389+
if (enableQsTileTinting) {
390+
return Utils.getColorAttr(context, android.R.attr.textColorHint);
391+
} else {
392+
return Utils.getColorAttr(context, android.R.attr.textColorHint);
393+
}
379394
case Tile.STATE_ACTIVE:
380-
return Utils.getColorAttr(context, android.R.attr.textColorPrimary);
395+
if (enableQsTileTinting) {
396+
return context.getResources().getColor(R.color.qs_tiles_active_tint);
397+
} else {
398+
return Utils.getColorAttr(context, android.R.attr.textColorPrimary);
399+
}
381400
default:
382401
Log.e("QSTile", "Invalid state " + state);
383402
return 0;

0 commit comments

Comments
 (0)