Skip to content

Commit

Permalink
[Base 1/2] QS Tile Icon Accent Toggle
Browse files Browse the repository at this point in the history
Idea taken from -: DotOS/android_frameworks_base@8976f61

aex edits:- disabled by default, remove useless overlay

Change-Id: I834053e6b118024e1b0609150df641b999fd48f9
  • Loading branch information
SuperDroidBond authored and aoleary committed Oct 4, 2018
1 parent 9be443d commit d555ba5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
8 changes: 8 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4840,6 +4840,14 @@ public boolean validate(String value) {
*/
public static final String CHOOSER_ACTIVITY_BLACKLIST = "chooser_activity_blacklist";

/**
** Whether to show Device Accent on QS on the screen.
** 0 = OFF
** 1 = ON
** @hide
**/
public static final String QS_TILE_TINTING_ENABLE = "qs_tile_tinting_enable";

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down
5 changes: 5 additions & 0 deletions packages/SystemUI/res/values/aos_colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<!-- Zen QS panel -->
<color name="zen_qs_panel_close_button_color">@android:color/white</color>

<!-- QS tiles Active and Inactive tint (Requires config_enable_qs_tile_tinting bool set to true) -->
<color name="qs_tiles_active_tint">@*android:color/accent_device_default_light</color>
<color name="qs_tiles_inactive_tint">@*android:color/hint_foreground_material_light</color>
<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. -->

<!-- Theme tile DO NOT OVERLAY!!! We need the true colors here! -->
<color name="quick_settings_theme_tile_default">#4285F4</color>
<color name="quick_settings_theme_tile_red">#FF5252</color>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.provider.Settings;
import android.os.Handler;

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

setTint(iv, Color.argb(alpha, channel, channel, channel));
setTint(iv, toColor);
});

anim.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import android.util.ArraySet;
import android.util.Log;
import android.util.SparseArray;

import android.provider.Settings;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.settingslib.RestrictedLockUtils;
Expand All @@ -50,6 +50,8 @@
import com.android.systemui.qs.PagedTileLayout.TilePage;
import com.android.systemui.qs.QSHost;

import com.android.systemui.R;

import java.util.ArrayList;

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

public static int getColorForState(Context context, int state) {

boolean enableQsTileTinting = Settings.System.getInt(context.getContentResolver(),
Settings.System.QS_TILE_TINTING_ENABLE, 0) == 1;

switch (state) {
case Tile.STATE_UNAVAILABLE:
return Utils.getDisabled(context,
Utils.getColorAttr(context, android.R.attr.colorForeground));
if (enableQsTileTinting) {
return Utils.getDisabled(context,
context.getResources().getColor(R.color.qs_tiles_unavailable_tint));
} else {
return Utils.getDisabled(context,
Utils.getColorAttr(context, android.R.attr.colorForeground));
}
case Tile.STATE_INACTIVE:
return Utils.getColorAttr(context, android.R.attr.textColorHint);
if (enableQsTileTinting) {
return Utils.getColorAttr(context, android.R.attr.textColorHint);
} else {
return Utils.getColorAttr(context, android.R.attr.textColorHint);
}
case Tile.STATE_ACTIVE:
return Utils.getColorAttr(context, android.R.attr.textColorPrimary);
if (enableQsTileTinting) {
return context.getResources().getColor(R.color.qs_tiles_active_tint);
} else {
return Utils.getColorAttr(context, android.R.attr.textColorPrimary);
}
default:
Log.e("QSTile", "Invalid state " + state);
return 0;
Expand Down

0 comments on commit d555ba5

Please sign in to comment.