This commit is contained in:
Mariotaku Lee 2016-03-02 23:23:12 +08:00
parent 85591fb6a9
commit 508ea9a57e
8 changed files with 35 additions and 43 deletions

View File

@ -6,6 +6,8 @@ import android.graphics.PorterDuff.Mode;
import android.util.AttributeSet;
import android.widget.ImageButton;
import org.mariotaku.twidere.R;
/**
* Created by mariotaku on 14/11/5.
*/
@ -23,13 +25,9 @@ public class ActionIconButton extends ImageButton {
public ActionIconButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.color,
android.R.attr.colorForeground});
if (a.hasValue(0)) {
mDefaultColor = a.getColor(0, 0);
} else {
mDefaultColor = a.getColor(1, 0);
}
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IconActionButton,
R.attr.cardActionButtonStyle, R.style.Widget_CardActionButton);
mDefaultColor = a.getColor(R.styleable.IconActionButton_iabColor, 0);
setColorFilter(mDefaultColor, Mode.SRC_ATOP);
a.recycle();
}

View File

@ -60,7 +60,8 @@ public class ActionIconThemedTextView extends AppCompatTextView {
}
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);
mDisabledColor = a.getColor(R.styleable.IconActionButton_iabDisabledColor, 0);
mActivatedColor = a.getColor(R.styleable.IconActionButton_iabActivatedColor, 0);
@ -94,6 +95,18 @@ public class ActionIconThemedTextView extends AppCompatTextView {
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
public int getColor() {
if (mColor != 0) return mColor;
@ -126,7 +139,7 @@ public class ActionIconThemedTextView extends AppCompatTextView {
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
updateCompoundDrawables(TextViewSupport.getCompoundDrawablesRelative(this));
updateCompoundDrawables(getCompoundDrawables());
}
private void updateCompoundDrawables(Drawable... drawables) {

View File

@ -291,8 +291,7 @@
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_normal"
android:textAppearance="?android:textAppearanceSmall"
app:iabActivatedColor="@color/highlight_reply"
app:iabColor="?android:textColorTertiary"/>
app:iabActivatedColor="@color/highlight_reply"/>
<org.mariotaku.twidere.view.ActionIconThemedTextView
android:id="@+id/retweet_count"
@ -306,8 +305,7 @@
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_normal"
android:textAppearance="?android:textAppearanceSmall"
app:iabActivatedColor="@color/highlight_retweet"
app:iabColor="?android:textColorTertiary"/>
app:iabActivatedColor="@color/highlight_retweet"/>
<org.mariotaku.twidere.view.ActionIconThemedTextView
android:id="@+id/favorite_count"
@ -320,7 +318,6 @@
android:paddingRight="@dimen/element_spacing_normal"
android:textAppearance="?android:textAppearanceSmall"
app:iabActivatedColor="@color/highlight_like"
app:iabColor="?android:textColorTertiary"
tools:drawableLeft="@drawable/ic_action_heart"
tools:drawableStart="@drawable/ic_action_heart"/>
@ -337,7 +334,6 @@
android:layout_alignTop="@+id/action_buttons"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_normal"
android:color="?android:textColorTertiary"
android:focusable="false"
android:src="@drawable/ic_action_more_vertical"/>

View File

@ -258,8 +258,7 @@
android:paddingLeft="@dimen/element_spacing_msmall"
android:paddingRight="@dimen/element_spacing_msmall"
android:textAppearance="?android:textAppearanceSmall"
app:iabActivatedColor="@color/highlight_reply"
app:iabColor="?android:textColorTertiary"/>
app:iabActivatedColor="@color/highlight_reply"/>
<org.mariotaku.twidere.view.ActionIconThemedTextView
android:id="@+id/retweet_count"
@ -275,8 +274,7 @@
android:paddingLeft="@dimen/element_spacing_msmall"
android:paddingRight="@dimen/element_spacing_msmall"
android:textAppearance="?android:textAppearanceSmall"
app:iabActivatedColor="@color/highlight_retweet"
app:iabColor="?android:textColorTertiary"/>
app:iabActivatedColor="@color/highlight_retweet"/>
<org.mariotaku.twidere.view.ActionIconThemedTextView
android:id="@+id/favorite_count"
@ -291,7 +289,6 @@
android:paddingRight="@dimen/element_spacing_msmall"
android:textAppearance="?android:textAppearanceSmall"
app:iabActivatedColor="@color/highlight_like"
app:iabColor="?android:textColorTertiary"
tools:drawableLeft="@drawable/ic_action_heart"
tools:drawableStart="@drawable/ic_action_heart"/>
@ -306,7 +303,6 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/action_buttons"
android:color="?android:textColorTertiary"
android:focusable="false"
android:src="@drawable/ic_action_more_horizontal"
tools:visibility="visible"/>

View File

@ -1,16 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<item name="android:background">@drawable/bg_oval_white</item>
<item name="sivElevation">@dimen/elevation_card</item>

View File

@ -22,10 +22,11 @@
<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.Light" parent="android:Widget.Material.Light"/>
<style name="Widget.Base.Light.ImageButton" parent="android:Widget.Material.Light.ImageButton"/>
</resources>

View File

@ -16,16 +16,16 @@
</style>
<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="iabColor">?android:textColorTertiary</item>
</style>
<style name="Widget.Light.CardActionButton" parent="Widget.Base.Light.ImageButton">
<item name="android:background">?selectableItemBackground</item>
<item name="android:color">?android:textColorSecondary</item>
<item name="android:background">?selectableItemBackgroundBorderless</item>
<item name="iabColor">?android:textColorTertiary</item>
</style>
<style name="Widget.ProfileImage" parent="Widget.Base">
<item name="android:scaleType">centerCrop</item>
<item name="android:adjustViewBounds">false</item>

View File

@ -22,12 +22,10 @@
<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.ImageButton" parent="android:Widget.Holo.Light.ImageButton"/>
<style name="Widget.Base.ImageButton" parent="android:Widget.Holo.ImageButton"/>
</resources>