Update disabled states to be less opaque
Also adds Resources method for retrieving floating-point values. BUG: 16374059 Change-Id: I68c6a40cbe5badfad624548b9abf2d657dbc2019
This commit is contained in:
@@ -233,7 +233,7 @@ public class ColorStateList implements Parcelable {
|
||||
}
|
||||
|
||||
if (alphaRes != 0) {
|
||||
alpha = r.getFraction(alphaRes, 1, 1);
|
||||
alpha = r.getFloat(alphaRes);
|
||||
}
|
||||
|
||||
// Apply alpha modulation.
|
||||
|
||||
@@ -985,6 +985,34 @@ public class Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a floating-point value for a particular resource ID.
|
||||
*
|
||||
* @param id The desired resource identifier, as generated by the aapt
|
||||
* tool. This integer encodes the package, type, and resource
|
||||
* entry. The value 0 is an invalid identifier.
|
||||
*
|
||||
* @return Returns the floating-point value contained in the resource.
|
||||
*
|
||||
* @throws NotFoundException Throws NotFoundException if the given ID does
|
||||
* not exist or is not a floating-point value.
|
||||
* @hide Pending API council approval.
|
||||
*/
|
||||
public float getFloat(int id) {
|
||||
synchronized (mAccessLock) {
|
||||
TypedValue value = mTmpValue;
|
||||
if (value == null) {
|
||||
mTmpValue = value = new TypedValue();
|
||||
}
|
||||
getValue(id, value, true);
|
||||
if (value.type == TypedValue.TYPE_FLOAT) {
|
||||
return value.getFloat();
|
||||
}
|
||||
throw new NotFoundException("Resource ID #0x" + Integer.toHexString(id) + " type #0x"
|
||||
+ Integer.toHexString(value.type) + " is not valid");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an XmlResourceParser through which you can read a view layout
|
||||
* description for the given resource ID. This parser has limited
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:alpha="0.5" android:color="@color/button_material_dark"/>
|
||||
<item android:state_enabled="false"
|
||||
android:alpha="@dimen/disabled_alpha_material"
|
||||
android:color="@color/button_material_dark"/>
|
||||
<item android:color="@color/button_material_dark"/>
|
||||
</selector>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:alpha="0.5" android:color="@color/button_material_light"/>
|
||||
<item android:state_enabled="false"
|
||||
android:alpha="@dimen/disabled_alpha_material"
|
||||
android:color="@color/button_material_light"/>
|
||||
<item android:color="@color/button_material_light"/>
|
||||
</selector>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:alpha="0.5" android:color="@android:color/bright_foreground_material_dark"/>
|
||||
<item android:color="@android:color/bright_foreground_material_dark"/>
|
||||
<item android:state_enabled="false"
|
||||
android:alpha="@dimen/disabled_alpha_material"
|
||||
android:color="@color/bright_foreground_material_dark"/>
|
||||
<item android:color="@color/bright_foreground_material_dark"/>
|
||||
</selector>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:alpha="0.5" android:color="@android:color/bright_foreground_material_light"/>
|
||||
<item android:color="@android:color/bright_foreground_material_light"/>
|
||||
<item android:state_enabled="false"
|
||||
android:alpha="@dimen/disabled_alpha_material"
|
||||
android:color="@color/bright_foreground_material_light"/>
|
||||
<item android:color="@color/bright_foreground_material_light"/>
|
||||
</selector>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:alpha="0.5" android:color="@color/primary_text_default_material_dark"/>
|
||||
<item android:state_enabled="false"
|
||||
android:alpha="@dimen/disabled_alpha_material"
|
||||
android:color="@color/primary_text_default_material_dark"/>
|
||||
<item android:color="@color/primary_text_default_material_dark"/>
|
||||
</selector>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:alpha="0.5" android:color="@color/primary_text_default_material_light"/>
|
||||
<item android:state_enabled="false"
|
||||
android:alpha="@dimen/disabled_alpha_material"
|
||||
android:color="@color/primary_text_default_material_light"/>
|
||||
<item android:color="@color/primary_text_default_material_light"/>
|
||||
</selector>
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
android:src="@drawable/btn_switch_to_on_mtrl_00001"
|
||||
android:gravity="center"
|
||||
android:tintMode="multiply"
|
||||
android:tint="?attr/colorButtonNormal"
|
||||
android:alpha="?attr/disabledAlpha" />
|
||||
android:tint="?attr/colorButtonNormal" />
|
||||
</item>
|
||||
<item
|
||||
android:state_checked="true"
|
||||
|
||||
@@ -18,12 +18,7 @@
|
||||
<item android:state_enabled="false" android:state_checked="true">
|
||||
<nine-patch android:src="@drawable/switch_track_mtrl_alpha"
|
||||
android:tint="?attr/colorControlActivated"
|
||||
android:alpha="0.15" />
|
||||
</item>
|
||||
<item android:state_enabled="false">
|
||||
<nine-patch android:src="@drawable/switch_track_mtrl_alpha"
|
||||
android:tint="?attr/colorButtonNormal"
|
||||
android:alpha="0.15" />
|
||||
android:alpha="0.2" />
|
||||
</item>
|
||||
<item android:state_checked="true">
|
||||
<nine-patch android:src="@drawable/switch_track_mtrl_alpha"
|
||||
|
||||
@@ -68,4 +68,7 @@
|
||||
<dimen name="control_padding_material">4dp</dimen>
|
||||
<!-- Default rounded corner for controls -->
|
||||
<dimen name="control_corner_material">2dp</dimen>
|
||||
|
||||
<!-- Default alpha value for disabled elements. -->
|
||||
<item name="disabled_alpha_material" format="float" type="dimen">0.26</item>
|
||||
</resources>
|
||||
|
||||
@@ -46,7 +46,7 @@ please see themes_device_defaults.xml.
|
||||
<item name="colorForegroundInverse">@color/bright_foreground_material_light</item>
|
||||
<item name="colorBackground">@color/background_material_dark</item>
|
||||
<item name="colorBackgroundCacheHint">@color/background_cache_hint_selector_material_dark</item>
|
||||
<item name="disabledAlpha">0.5</item>
|
||||
<item name="disabledAlpha">@dimen/disabled_alpha_material</item>
|
||||
<item name="backgroundDimAmount">0.6</item>
|
||||
|
||||
<!-- Text styles -->
|
||||
@@ -387,7 +387,7 @@ please see themes_device_defaults.xml.
|
||||
<item name="colorForegroundInverse">@color/bright_foreground_material_dark</item>
|
||||
<item name="colorBackground">@color/background_material_light</item>
|
||||
<item name="colorBackgroundCacheHint">@color/background_cache_hint_selector_material_light</item>
|
||||
<item name="disabledAlpha">0.5</item>
|
||||
<item name="disabledAlpha">@dimen/disabled_alpha_material</item>
|
||||
<item name="backgroundDimAmount">0.6</item>
|
||||
|
||||
<!-- Text styles -->
|
||||
|
||||
Reference in New Issue
Block a user