fixed #438
This commit is contained in:
parent
85591fb6a9
commit
508ea9a57e
|
@ -6,6 +6,8 @@ import android.graphics.PorterDuff.Mode;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
|
||||||
|
import org.mariotaku.twidere.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 14/11/5.
|
* Created by mariotaku on 14/11/5.
|
||||||
*/
|
*/
|
||||||
|
@ -23,13 +25,9 @@ public class ActionIconButton extends ImageButton {
|
||||||
|
|
||||||
public ActionIconButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
public ActionIconButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.color,
|
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconActionButton,
|
||||||
android.R.attr.colorForeground});
|
R.attr.cardActionButtonStyle, R.style.Widget_CardActionButton);
|
||||||
if (a.hasValue(0)) {
|
mDefaultColor = a.getColor(R.styleable.IconActionButton_iabColor, 0);
|
||||||
mDefaultColor = a.getColor(0, 0);
|
|
||||||
} else {
|
|
||||||
mDefaultColor = a.getColor(1, 0);
|
|
||||||
}
|
|
||||||
setColorFilter(mDefaultColor, Mode.SRC_ATOP);
|
setColorFilter(mDefaultColor, Mode.SRC_ATOP);
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ public class ActionIconThemedTextView extends AppCompatTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Context context, AttributeSet attrs) {
|
public void init(Context context, AttributeSet attrs) {
|
||||||
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconActionButton);
|
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconActionButton,
|
||||||
|
R.attr.cardActionButtonStyle, R.style.Widget_CardActionButton);
|
||||||
mColor = a.getColor(R.styleable.IconActionButton_iabColor, 0);
|
mColor = a.getColor(R.styleable.IconActionButton_iabColor, 0);
|
||||||
mDisabledColor = a.getColor(R.styleable.IconActionButton_iabDisabledColor, 0);
|
mDisabledColor = a.getColor(R.styleable.IconActionButton_iabDisabledColor, 0);
|
||||||
mActivatedColor = a.getColor(R.styleable.IconActionButton_iabActivatedColor, 0);
|
mActivatedColor = a.getColor(R.styleable.IconActionButton_iabActivatedColor, 0);
|
||||||
|
@ -94,6 +95,18 @@ public class ActionIconThemedTextView extends AppCompatTextView {
|
||||||
updateCompoundDrawables(start, top, end, bottom);
|
updateCompoundDrawables(start, top, end, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom) {
|
||||||
|
super.setCompoundDrawables(left, top, right, bottom);
|
||||||
|
updateCompoundDrawables(left, top, right, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCompoundDrawablesRelative(Drawable start, Drawable top, Drawable end, Drawable bottom) {
|
||||||
|
super.setCompoundDrawablesRelative(start, top, end, bottom);
|
||||||
|
updateCompoundDrawables(start, top, end, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
if (mColor != 0) return mColor;
|
if (mColor != 0) return mColor;
|
||||||
|
@ -126,7 +139,7 @@ public class ActionIconThemedTextView extends AppCompatTextView {
|
||||||
@Override
|
@Override
|
||||||
protected void drawableStateChanged() {
|
protected void drawableStateChanged() {
|
||||||
super.drawableStateChanged();
|
super.drawableStateChanged();
|
||||||
updateCompoundDrawables(TextViewSupport.getCompoundDrawablesRelative(this));
|
updateCompoundDrawables(getCompoundDrawables());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCompoundDrawables(Drawable... drawables) {
|
private void updateCompoundDrawables(Drawable... drawables) {
|
||||||
|
|
|
@ -291,8 +291,7 @@
|
||||||
android:paddingLeft="@dimen/element_spacing_normal"
|
android:paddingLeft="@dimen/element_spacing_normal"
|
||||||
android:paddingRight="@dimen/element_spacing_normal"
|
android:paddingRight="@dimen/element_spacing_normal"
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
app:iabActivatedColor="@color/highlight_reply"
|
app:iabActivatedColor="@color/highlight_reply"/>
|
||||||
app:iabColor="?android:textColorTertiary"/>
|
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
||||||
android:id="@+id/retweet_count"
|
android:id="@+id/retweet_count"
|
||||||
|
@ -306,8 +305,7 @@
|
||||||
android:paddingLeft="@dimen/element_spacing_normal"
|
android:paddingLeft="@dimen/element_spacing_normal"
|
||||||
android:paddingRight="@dimen/element_spacing_normal"
|
android:paddingRight="@dimen/element_spacing_normal"
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
app:iabActivatedColor="@color/highlight_retweet"
|
app:iabActivatedColor="@color/highlight_retweet"/>
|
||||||
app:iabColor="?android:textColorTertiary"/>
|
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
||||||
android:id="@+id/favorite_count"
|
android:id="@+id/favorite_count"
|
||||||
|
@ -320,7 +318,6 @@
|
||||||
android:paddingRight="@dimen/element_spacing_normal"
|
android:paddingRight="@dimen/element_spacing_normal"
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
app:iabActivatedColor="@color/highlight_like"
|
app:iabActivatedColor="@color/highlight_like"
|
||||||
app:iabColor="?android:textColorTertiary"
|
|
||||||
tools:drawableLeft="@drawable/ic_action_heart"
|
tools:drawableLeft="@drawable/ic_action_heart"
|
||||||
tools:drawableStart="@drawable/ic_action_heart"/>
|
tools:drawableStart="@drawable/ic_action_heart"/>
|
||||||
|
|
||||||
|
@ -337,7 +334,6 @@
|
||||||
android:layout_alignTop="@+id/action_buttons"
|
android:layout_alignTop="@+id/action_buttons"
|
||||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||||
android:layout_marginRight="@dimen/element_spacing_normal"
|
android:layout_marginRight="@dimen/element_spacing_normal"
|
||||||
android:color="?android:textColorTertiary"
|
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:src="@drawable/ic_action_more_vertical"/>
|
android:src="@drawable/ic_action_more_vertical"/>
|
||||||
|
|
||||||
|
|
|
@ -258,8 +258,7 @@
|
||||||
android:paddingLeft="@dimen/element_spacing_msmall"
|
android:paddingLeft="@dimen/element_spacing_msmall"
|
||||||
android:paddingRight="@dimen/element_spacing_msmall"
|
android:paddingRight="@dimen/element_spacing_msmall"
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
app:iabActivatedColor="@color/highlight_reply"
|
app:iabActivatedColor="@color/highlight_reply"/>
|
||||||
app:iabColor="?android:textColorTertiary"/>
|
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
||||||
android:id="@+id/retweet_count"
|
android:id="@+id/retweet_count"
|
||||||
|
@ -275,8 +274,7 @@
|
||||||
android:paddingLeft="@dimen/element_spacing_msmall"
|
android:paddingLeft="@dimen/element_spacing_msmall"
|
||||||
android:paddingRight="@dimen/element_spacing_msmall"
|
android:paddingRight="@dimen/element_spacing_msmall"
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
app:iabActivatedColor="@color/highlight_retweet"
|
app:iabActivatedColor="@color/highlight_retweet"/>
|
||||||
app:iabColor="?android:textColorTertiary"/>
|
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
||||||
android:id="@+id/favorite_count"
|
android:id="@+id/favorite_count"
|
||||||
|
@ -291,7 +289,6 @@
|
||||||
android:paddingRight="@dimen/element_spacing_msmall"
|
android:paddingRight="@dimen/element_spacing_msmall"
|
||||||
android:textAppearance="?android:textAppearanceSmall"
|
android:textAppearance="?android:textAppearanceSmall"
|
||||||
app:iabActivatedColor="@color/highlight_like"
|
app:iabActivatedColor="@color/highlight_like"
|
||||||
app:iabColor="?android:textColorTertiary"
|
|
||||||
tools:drawableLeft="@drawable/ic_action_heart"
|
tools:drawableLeft="@drawable/ic_action_heart"
|
||||||
tools:drawableStart="@drawable/ic_action_heart"/>
|
tools:drawableStart="@drawable/ic_action_heart"/>
|
||||||
|
|
||||||
|
@ -306,7 +303,6 @@
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignTop="@+id/action_buttons"
|
android:layout_alignTop="@+id/action_buttons"
|
||||||
android:color="?android:textColorTertiary"
|
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:src="@drawable/ic_action_more_horizontal"
|
android:src="@drawable/ic_action_more_horizontal"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible"/>
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="Widget.CardActionButton" parent="Widget.Base.ImageButton">
|
|
||||||
<item name="android:background">?selectableItemBackgroundBorderless</item>
|
|
||||||
<item name="android:color">?android:textColorSecondary</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Widget.Light.CardActionButton" parent="Widget.Base.ImageButton">
|
|
||||||
<item name="android:background">?selectableItemBackgroundBorderless</item>
|
|
||||||
<item name="android:color">?android:textColorSecondary</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="Widget.ProfileImage.Large">
|
<style name="Widget.ProfileImage.Large">
|
||||||
<item name="android:background">@drawable/bg_oval_white</item>
|
<item name="android:background">@drawable/bg_oval_white</item>
|
||||||
<item name="sivElevation">@dimen/elevation_card</item>
|
<item name="sivElevation">@dimen/elevation_card</item>
|
||||||
|
|
|
@ -22,10 +22,11 @@
|
||||||
|
|
||||||
<style name="Widget.Base" parent="android:Widget.Material"/>
|
<style name="Widget.Base" parent="android:Widget.Material"/>
|
||||||
|
|
||||||
<style name="Widget.Base.Light" parent="android:Widget.Material.Light"/>
|
|
||||||
|
|
||||||
<style name="Widget.Base.Light.ImageButton" parent="android:Widget.Holo.Light.ImageButton"/>
|
|
||||||
|
|
||||||
<style name="Widget.Base.ImageButton" parent="android:Widget.Material.ImageButton"/>
|
<style name="Widget.Base.ImageButton" parent="android:Widget.Material.ImageButton"/>
|
||||||
|
|
||||||
|
<style name="Widget.Base.Light" parent="android:Widget.Material.Light"/>
|
||||||
|
|
||||||
|
<style name="Widget.Base.Light.ImageButton" parent="android:Widget.Material.Light.ImageButton"/>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -16,16 +16,16 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.CardActionButton" parent="Widget.Base.ImageButton">
|
<style name="Widget.CardActionButton" parent="Widget.Base.ImageButton">
|
||||||
<item name="android:background">?selectableItemBackground</item>
|
<item name="android:background">?selectableItemBackgroundBorderless</item>
|
||||||
<item name="android:color">?android:textColorSecondary</item>
|
<item name="android:color">?android:textColorSecondary</item>
|
||||||
|
<item name="iabColor">?android:textColorTertiary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Widget.Light.CardActionButton" parent="Widget.Base.Light.ImageButton">
|
<style name="Widget.Light.CardActionButton" parent="Widget.Base.Light.ImageButton">
|
||||||
<item name="android:background">?selectableItemBackground</item>
|
<item name="android:background">?selectableItemBackgroundBorderless</item>
|
||||||
<item name="android:color">?android:textColorSecondary</item>
|
<item name="iabColor">?android:textColorTertiary</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<style name="Widget.ProfileImage" parent="Widget.Base">
|
<style name="Widget.ProfileImage" parent="Widget.Base">
|
||||||
<item name="android:scaleType">centerCrop</item>
|
<item name="android:scaleType">centerCrop</item>
|
||||||
<item name="android:adjustViewBounds">false</item>
|
<item name="android:adjustViewBounds">false</item>
|
||||||
|
|
|
@ -22,12 +22,10 @@
|
||||||
|
|
||||||
<style name="Widget.Base" parent="android:Widget.Holo"/>
|
<style name="Widget.Base" parent="android:Widget.Holo"/>
|
||||||
|
|
||||||
|
<style name="Widget.Base.ImageButton" parent="android:Widget.Holo.ImageButton"/>
|
||||||
|
|
||||||
<style name="Widget.Base.Light" parent="android:Widget.Holo.Light"/>
|
<style name="Widget.Base.Light" parent="android:Widget.Holo.Light"/>
|
||||||
|
|
||||||
<style name="Widget.Base.Light.ImageButton" parent="android:Widget.Holo.Light.ImageButton"/>
|
<style name="Widget.Base.Light.ImageButton" parent="android:Widget.Holo.Light.ImageButton"/>
|
||||||
|
|
||||||
<style name="Widget.Base.ImageButton" parent="android:Widget.Holo.ImageButton"/>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue