Change value of themedIconTint to be a color resource, instead of a ColorStateList resource which is not supported for the XML tint attribute of an ImageView below v21.
This commit is contained in:
parent
d7b3fc6ee1
commit
c8ea8cf43a
@ -3,7 +3,6 @@ package com.philliphsu.clock2.alarms;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
@ -162,14 +161,11 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
|
||||
}
|
||||
|
||||
private void bindRingtone(String ringtone) {
|
||||
// TODO: Write a Utils method for this.
|
||||
TypedArray a = getContext().getTheme().obtainStyledAttributes(new int[] {R.attr.themedIconTint});
|
||||
ColorStateList iconTint = a.getColorStateList(0);
|
||||
a.recycle();
|
||||
int iconTint = Utils.getTextColorFromThemeAttr(getContext(), R.attr.themedIconTint);
|
||||
|
||||
Drawable ringtoneIcon = mRingtone.getCompoundDrawablesRelative()[0/*start*/];
|
||||
ringtoneIcon = DrawableCompat.wrap(ringtoneIcon.mutate());
|
||||
DrawableCompat.setTintList(ringtoneIcon, iconTint);
|
||||
DrawableCompat.setTint(ringtoneIcon, iconTint);
|
||||
mRingtone.setCompoundDrawablesRelativeWithIntrinsicBounds(ringtoneIcon, null, null, null);
|
||||
|
||||
// Initializing to Settings.System.DEFAULT_ALARM_ALERT_URI will show
|
||||
|
||||
@ -9,7 +9,11 @@
|
||||
<!--<item name="dialogTheme">@style/AppCompatDialogTheme</item>-->
|
||||
<item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
|
||||
<item name="bottomSheetDialogTheme">@style/BottomSheetDialogTheme</item>
|
||||
<item name="themedIconTint">@color/icon_color</item>
|
||||
<!--The icons that need to be tinted with this attribute will only ever be in
|
||||
the active state, so we don't need to use @color/icon_color ColorStateList resource.
|
||||
Secondly, using a ColorStateList resource via XML for the tint attribute of an ImageView
|
||||
is not supported below 21. -->
|
||||
<item name="themedIconTint">@color/icon_color_active_light</item>
|
||||
<item name="android:textColorHint">@color/text_color_disabled_light</item>
|
||||
</style>
|
||||
|
||||
@ -22,7 +26,11 @@
|
||||
<item name="alertDialogTheme">@style/AppCompatAlertDialogStyle.Dark</item>
|
||||
<!--TODO: Dark theme-->
|
||||
<item name="bottomSheetDialogTheme">@style/BottomSheetDialogTheme</item>
|
||||
<item name="themedIconTint">@color/icon_color_dark</item>
|
||||
<!--The icons that need to be tinted with this attribute will only ever be in
|
||||
the active state, so we don't need to use @color/icon_color_dark ColorStateList resource
|
||||
Secondly, using a ColorStateList resource via XML for the tint attribute of an ImageView
|
||||
is not supported below 21.-->
|
||||
<item name="themedIconTint">@color/icon_color_active_dark</item>
|
||||
<item name="android:textColorHint">@color/text_color_disabled_dark</item>
|
||||
</style>
|
||||
|
||||
|
||||
@ -18,10 +18,13 @@
|
||||
<item name="android:layout_width">@dimen/cardview_action_icon_size</item>
|
||||
<item name="android:layout_height">@dimen/cardview_action_icon_size</item>
|
||||
<item name="android:background">?selectableItemBackground</item>
|
||||
<item name="android:tint">?attr/themedIconTint</item>
|
||||
<item name="android:layout_marginStart">@dimen/cardview_action_icon_margin</item>
|
||||
<item name="android:layout_marginEnd">@dimen/cardview_action_icon_margin</item>
|
||||
<item name="android:layout_marginBottom">@dimen/cardview_action_icon_margin</item>
|
||||
<!--https://code.google.com/p/android/issues/detail?id=18220-->
|
||||
<!--"... there is no support for color state list in the ImageView tint attribute
|
||||
prior to API 21." ImageButton is a subclass of ImageView.-->
|
||||
<item name="android:tint">?attr/themedIconTint</item>
|
||||
</style>
|
||||
<style name="TimerAction.AddOneMinute">
|
||||
<item name="android:gravity">center</item>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user