Importance slider updates.

Icon & tint.

Bug: 28911161
Change-Id: Ic56270c8803557863f914ee0eaf6801f1341387d
This commit is contained in:
Julia Reynolds
2016-05-26 11:08:16 -04:00
parent 72167fe650
commit 9782079130
2 changed files with 12 additions and 5 deletions

View File

@@ -58,8 +58,8 @@
android:focusable="true" android:focusable="true"
android:background="#00ffffff" android:background="#00ffffff"
android:progressBackgroundTint="@color/importance_secondary_slider_color" android:progressBackgroundTint="@color/importance_secondary_slider_color"
android:thumbTint="@color/importance_disabled_slider_color" android:thumbTint="?android:attr/colorAccent"
android:progressTint="@color/importance_disabled_slider_color" android:progressTint="?android:attr/colorAccent"
style="@android:style/Widget.Material.SeekBar.Discrete" style="@android:style/Widget.Material.SeekBar.Discrete"
android:tickMarkTint="@android:color/black" /> android:tickMarkTint="@android:color/black" />

View File

@@ -23,6 +23,7 @@ import com.android.settings.SeekBarPreference;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Handler; import android.os.Handler;
import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService;
@@ -47,6 +48,8 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
private SeekBar mSeekBar; private SeekBar mSeekBar;
private ColorStateList mActiveSliderTint; private ColorStateList mActiveSliderTint;
private ColorStateList mInactiveSliderTint; private ColorStateList mInactiveSliderTint;
private float mActiveSliderAlpha = 1.0f;
private float mInactiveSliderAlpha;
private boolean mAutoOn; private boolean mAutoOn;
private Handler mHandler; private Handler mHandler;
@@ -61,6 +64,11 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
mInactiveSliderTint = ColorStateList.valueOf( mInactiveSliderTint = ColorStateList.valueOf(
context.getColor(R.color.importance_disabled_slider_color)); context.getColor(R.color.importance_disabled_slider_color));
mHandler = new Handler(); mHandler = new Handler();
final TypedArray ta =
context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.Theme, 0, 0);
mInactiveSliderAlpha =
ta.getFloat(com.android.internal.R.styleable.Theme_disabledAlpha, 0.5f);
ta.recycle();
} }
public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) { public ImportanceSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -128,13 +136,12 @@ public class ImportanceSeekBarPreference extends SeekBarPreference implements
private void applyAutoUi(ImageView autoButton) { private void applyAutoUi(ImageView autoButton) {
mSeekBar.setEnabled(!mAutoOn); mSeekBar.setEnabled(!mAutoOn);
final ColorStateList sliderTint = mAutoOn ? mInactiveSliderTint : mActiveSliderTint; final float alpha = mAutoOn ? mInactiveSliderAlpha : mActiveSliderAlpha;
final ColorStateList starTint = mAutoOn ? mActiveSliderTint : mInactiveSliderTint; final ColorStateList starTint = mAutoOn ? mActiveSliderTint : mInactiveSliderTint;
Drawable icon = autoButton.getDrawable().mutate(); Drawable icon = autoButton.getDrawable().mutate();
icon.setTintList(starTint); icon.setTintList(starTint);
autoButton.setImageDrawable(icon); autoButton.setImageDrawable(icon);
mSeekBar.setProgressTintList(sliderTint); mSeekBar.setAlpha(alpha);
mSeekBar.setThumbTintList(sliderTint);
if (mAutoOn) { if (mAutoOn) {
setProgress(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT); setProgress(NotificationListenerService.Ranking.IMPORTANCE_DEFAULT);