Merge "Alternative workaround for using private attribute" into sc-dev
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<resources xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
|
<resources>
|
||||||
<!-- Keyguard PIN pad styles -->
|
<!-- Keyguard PIN pad styles -->
|
||||||
<style name="Keyguard.TextView" parent="@android:style/Widget.DeviceDefault.TextView">
|
<style name="Keyguard.TextView" parent="@android:style/Widget.DeviceDefault.TextView">
|
||||||
<item name="android:textSize">@dimen/kg_status_line_font_size</item>
|
<item name="android:textSize">@dimen/kg_status_line_font_size</item>
|
||||||
@@ -32,7 +32,9 @@
|
|||||||
<item name="android:stateListAnimator">@null</item>
|
<item name="android:stateListAnimator">@null</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="NumPadKey" parent="Theme.SystemUI">
|
<style name="NumPadKey" parent="Theme.SystemUI">
|
||||||
<item name="android:colorControlNormal">?androidprv:attr/colorSurface</item>
|
<!-- Studio can't directly reference ?androidprv:attr/colorSurface here, so this value
|
||||||
|
is resolved in {@link NumPadAnimator}. -->
|
||||||
|
<item name="android:colorControlNormal">@null</item>
|
||||||
<item name="android:colorControlHighlight">?android:attr/colorAccent</item>
|
<item name="android:colorControlHighlight">?android:attr/colorAccent</item>
|
||||||
<item name="android:background">@drawable/num_pad_key_background</item>
|
<item name="android:background">@drawable/num_pad_key_background</item>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import androidx.annotation.StyleRes;
|
|||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.animation.Interpolators;
|
import com.android.systemui.animation.Interpolators;
|
||||||
|
import com.android.systemui.util.Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides background color and radius animations for key pad buttons.
|
* Provides background color and radius animations for key pad buttons.
|
||||||
@@ -100,7 +101,8 @@ class NumPadAnimator {
|
|||||||
|
|
||||||
ContextThemeWrapper ctw = new ContextThemeWrapper(context, mStyle);
|
ContextThemeWrapper ctw = new ContextThemeWrapper(context, mStyle);
|
||||||
TypedArray a = ctw.obtainStyledAttributes(customAttrs);
|
TypedArray a = ctw.obtainStyledAttributes(customAttrs);
|
||||||
mNormalColor = a.getColor(0, 0);
|
mNormalColor = Utils.getPrivateAttrColorIfUnset(ctw, a, 0, 0,
|
||||||
|
com.android.internal.R.attr.colorSurface);
|
||||||
mHighlightColor = a.getColor(1, 0);
|
mHighlightColor = a.getColor(1, 0);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
@@ -177,4 +179,23 @@ public class Utils {
|
|||||||
&& resources.getBoolean(R.bool.config_use_split_notification_shade);
|
&& resources.getBoolean(R.bool.config_use_split_notification_shade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the color provided at the specified {@param attrIndex} in {@param a} if it exists,
|
||||||
|
* otherwise, returns the color from the private attribute {@param privAttrId}.
|
||||||
|
*/
|
||||||
|
public static int getPrivateAttrColorIfUnset(ContextThemeWrapper ctw, TypedArray a,
|
||||||
|
int attrIndex, int defColor, int privAttrId) {
|
||||||
|
// If the index is specified, use that value
|
||||||
|
if (a.hasValue(attrIndex)) {
|
||||||
|
return a.getColor(attrIndex, defColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise fallback to the value of the private attribute
|
||||||
|
int[] customAttrs = { privAttrId };
|
||||||
|
a = ctw.obtainStyledAttributes(customAttrs);
|
||||||
|
int color = a.getColor(0, defColor);
|
||||||
|
a.recycle();
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user