mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix icon bug colors
This commit is contained in:
parent
f5b0eacfab
commit
3a8f037be5
2 changed files with 47 additions and 46 deletions
|
@ -646,6 +646,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
holder.binding.actionButtonBookmark.setInactiveImage(R.drawable.ic_round_bookmark_border_24);
|
holder.binding.actionButtonBookmark.setInactiveImage(R.drawable.ic_round_bookmark_border_24);
|
||||||
holder.binding.actionButtonBoost.setActiveImage(R.drawable.ic_round_repeat_active_24);
|
holder.binding.actionButtonBoost.setActiveImage(R.drawable.ic_round_repeat_active_24);
|
||||||
holder.binding.actionButtonBoost.setInactiveImage(R.drawable.ic_round_repeat_24);
|
holder.binding.actionButtonBoost.setInactiveImage(R.drawable.ic_round_repeat_24);
|
||||||
|
holder.binding.actionButtonFavorite.setActiveImageTint(R.color.marked_icon);
|
||||||
|
holder.binding.actionButtonBoost.setActiveImageTint(R.color.boost_icon);
|
||||||
|
holder.binding.actionButtonBookmark.setActiveImageTint(R.color.marked_icon);
|
||||||
applyColor(context, holder);
|
applyColor(context, holder);
|
||||||
|
|
||||||
if (status.pinned) {
|
if (status.pinned) {
|
||||||
|
@ -2324,6 +2327,9 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||||
Helper.changeDrawableColor(context, R.drawable.ic_bot, theme_icons_color);
|
Helper.changeDrawableColor(context, R.drawable.ic_bot, theme_icons_color);
|
||||||
Helper.changeDrawableColor(context, R.drawable.ic_round_reply_24, theme_icons_color);
|
Helper.changeDrawableColor(context, R.drawable.ic_round_reply_24, theme_icons_color);
|
||||||
Helper.changeDrawableColor(context, holder.binding.actionButtonTranslate, theme_icons_color);
|
Helper.changeDrawableColor(context, holder.binding.actionButtonTranslate, theme_icons_color);
|
||||||
|
holder.binding.actionButtonBoost.setInActiveImageTintColor(theme_icons_color);
|
||||||
|
holder.binding.actionButtonFavorite.setInActiveImageTintColor(theme_icons_color);
|
||||||
|
holder.binding.actionButtonBookmark.setInActiveImageTintColor(theme_icons_color);
|
||||||
holder.binding.replyCount.setTextColor(theme_icons_color);
|
holder.binding.replyCount.setTextColor(theme_icons_color);
|
||||||
}
|
}
|
||||||
if (theme_statuses_color != -1) {
|
if (theme_statuses_color != -1) {
|
||||||
|
|
|
@ -7,10 +7,10 @@ import android.animation.ObjectAnimator;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
|
@ -55,21 +55,24 @@ public class SparkButton extends FrameLayout implements View.OnClickListener {
|
||||||
private float animationSpeed = 1;
|
private float animationSpeed = 1;
|
||||||
private boolean isChecked = false;
|
private boolean isChecked = false;
|
||||||
private AnimatorSet animatorSet;
|
private AnimatorSet animatorSet;
|
||||||
private SparkEventListener listener;
|
private final Context context;
|
||||||
|
|
||||||
SparkButton(Context context) {
|
SparkButton(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SparkButton(Context context, AttributeSet attrs) {
|
public SparkButton(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
initFromXML(attrs);
|
initFromXML(attrs);
|
||||||
|
this.context = context;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SparkButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
public SparkButton(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
initFromXML(attrs);
|
initFromXML(attrs);
|
||||||
|
this.context = context;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +80,7 @@ public class SparkButton extends FrameLayout implements View.OnClickListener {
|
||||||
public SparkButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public SparkButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
initFromXML(attrs);
|
initFromXML(attrs);
|
||||||
|
this.context = context;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +225,24 @@ public class SparkButton extends FrameLayout implements View.OnClickListener {
|
||||||
return isChecked;
|
return isChecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setInActiveImageTint(int inActiveImageTint) {
|
||||||
|
this.inActiveImageTint = getColor(inActiveImageTint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInActiveImageTintColor(int inActiveImageTint) {
|
||||||
|
this.inActiveImageTint = inActiveImageTint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveImageTint(int activeImageTint) {
|
||||||
|
this.activeImageTint = getColor(activeImageTint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveImageTintColor(int activeImageTint) {
|
||||||
|
this.activeImageTint = activeImageTint;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change Button State (Works only if both active and disabled image resource is defined)
|
* Change Button State (Works only if both active and disabled image resource is defined)
|
||||||
*
|
*
|
||||||
|
@ -229,6 +251,7 @@ public class SparkButton extends FrameLayout implements View.OnClickListener {
|
||||||
public void setChecked(boolean flag) {
|
public void setChecked(boolean flag) {
|
||||||
isChecked = flag;
|
isChecked = flag;
|
||||||
imageView.setImageResource(isChecked ? imageResourceIdActive : imageResourceIdInactive);
|
imageView.setImageResource(isChecked ? imageResourceIdActive : imageResourceIdInactive);
|
||||||
|
imageView.setColorFilter(isChecked ? activeImageTint : inActiveImageTint, PorterDuff.Mode.SRC_ATOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInactiveImage(int inactiveResource) {
|
public void setInactiveImage(int inactiveResource) {
|
||||||
|
@ -241,11 +264,9 @@ public class SparkButton extends FrameLayout implements View.OnClickListener {
|
||||||
imageView.setImageResource(isChecked ? imageResourceIdActive : imageResourceIdInactive);
|
imageView.setImageResource(isChecked ? imageResourceIdActive : imageResourceIdInactive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean shouldPlayAnimation = listener == null || listener.onEvent(this, isChecked);
|
|
||||||
|
|
||||||
if (shouldPlayAnimation) {
|
|
||||||
if (imageResourceIdInactive != INVALID_RESOURCE_ID) {
|
if (imageResourceIdInactive != INVALID_RESOURCE_ID) {
|
||||||
isChecked = !isChecked;
|
isChecked = !isChecked;
|
||||||
|
|
||||||
|
@ -264,36 +285,8 @@ public class SparkButton extends FrameLayout implements View.OnClickListener {
|
||||||
playAnimation();
|
playAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void setOnTouchListener() {
|
|
||||||
setOnTouchListener((v, event) -> {
|
|
||||||
switch (event.getAction()) {
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
imageView.animate().scaleX(0.8f).scaleY(0.8f).setDuration(150).setInterpolator(DECELERATE_INTERPOLATOR);
|
|
||||||
setPressed(true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_UP:
|
|
||||||
imageView.animate().scaleX(1).scaleY(1).setInterpolator(DECELERATE_INTERPOLATOR);
|
|
||||||
if (isPressed()) {
|
|
||||||
performClick();
|
|
||||||
setPressed(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MotionEvent.ACTION_CANCEL:
|
|
||||||
imageView.animate().scaleX(1).scaleY(1).setInterpolator(DECELERATE_INTERPOLATOR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getColor(int id) {
|
private int getColor(int id) {
|
||||||
return ContextCompat.getColor(getContext(), id);
|
return ContextCompat.getColor(getContext(), id);
|
||||||
}
|
}
|
||||||
|
@ -310,4 +303,6 @@ public class SparkButton extends FrameLayout implements View.OnClickListener {
|
||||||
// recycle typedArray
|
// recycle typedArray
|
||||||
a.recycle();
|
a.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue