diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 4e92cd0d9ec32ee9686a9bb9860c174c516740d7..f16669b467c6a49bf109a2e5d84e4892036494c2 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -3658,8 +3658,8 @@ public class ConversationFragment extends XmppFragment this.binding.textSendButton.setTag(action); final Activity activity = getActivity(); if (activity != null) { - this.binding.textSendButton.setImageResource( - SendButtonTool.getSendButtonImageResource(activity, action, status)); + this.binding.textSendButton.setImageDrawable( + SendButtonTool.getSendButtonImageResource(activity, action, status, text.length() > 0 || hasAttachments)); } ViewGroup.LayoutParams params = binding.threadIdenticonLayout.getLayoutParams(); diff --git a/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java b/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java index ccbfb96eb412a8956f8d60c3e37161dd04f2859d..a9aa947a097d076faad41a6c4c9bdd97e636a43a 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java +++ b/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java @@ -32,6 +32,8 @@ package eu.siacs.conversations.ui.util; import android.app.Activity; import android.content.SharedPreferences; import android.content.res.TypedArray; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.preference.PreferenceManager; import eu.siacs.conversations.R; @@ -80,111 +82,51 @@ public class SendButtonTool { } } - public static int getSendButtonImageResource(Activity activity, SendButtonAction action, Presence.Status status) { + public static int colorForStatus(Activity activity, Presence.Status status) { + switch (status) { + case CHAT: + case ONLINE: + return 0xff4ab04a; + case AWAY: + return 0xfff8b990; + case XA: + case DND: + return 0xffe97975; + default: + return StyledAttributes.getColor(activity, R.attr.icon_tint); + } + } + + public static Drawable getSendButtonImageResource(Activity activity, SendButtonAction action, Presence.Status status, boolean canSend) { + final Drawable d; switch (action) { case TEXT: - switch (status) { - case CHAT: - case ONLINE: - return R.drawable.ic_send_text_online; - case AWAY: - return R.drawable.ic_send_text_away; - case XA: - case DND: - return R.drawable.ic_send_text_dnd; - default: - return getThemeResource(activity, R.attr.ic_send_text_offline, R.drawable.ic_send_text_offline); - } + d = canSend ? + activity.getResources().getDrawable(R.drawable.ic_send_text_online) : + activity.getResources().getDrawable(R.drawable.ic_attach_file_white_24dp); + break; case RECORD_VIDEO: - switch (status) { - case CHAT: - case ONLINE: - return R.drawable.ic_send_videocam_online; - case AWAY: - return R.drawable.ic_send_videocam_away; - case XA: - case DND: - return R.drawable.ic_send_videocam_dnd; - default: - return getThemeResource(activity, R.attr.ic_send_videocam_offline, R.drawable.ic_send_videocam_offline); - } + d = activity.getResources().getDrawable(R.drawable.ic_send_videocam_online); + break; case TAKE_PHOTO: - switch (status) { - case CHAT: - case ONLINE: - return R.drawable.ic_send_photo_online; - case AWAY: - return R.drawable.ic_send_photo_away; - case XA: - case DND: - return R.drawable.ic_send_photo_dnd; - default: - return getThemeResource(activity, R.attr.ic_send_photo_offline, R.drawable.ic_send_photo_offline); - } + d = activity.getResources().getDrawable(R.drawable.ic_send_photo_online); + break; case RECORD_VOICE: - switch (status) { - case CHAT: - case ONLINE: - return R.drawable.ic_send_voice_online; - case AWAY: - return R.drawable.ic_send_voice_away; - case XA: - case DND: - return R.drawable.ic_send_voice_dnd; - default: - return getThemeResource(activity, R.attr.ic_send_voice_offline, R.drawable.ic_send_voice_offline); - } + d = activity.getResources().getDrawable(R.drawable.ic_send_voice_online); + break; case SEND_LOCATION: - switch (status) { - case CHAT: - case ONLINE: - return R.drawable.ic_send_location_online; - case AWAY: - return R.drawable.ic_send_location_away; - case XA: - case DND: - return R.drawable.ic_send_location_dnd; - default: - return getThemeResource(activity, R.attr.ic_send_location_offline, R.drawable.ic_send_location_offline); - } + d = activity.getResources().getDrawable(R.drawable.ic_send_location_online); + break; case CANCEL: - switch (status) { - case CHAT: - case ONLINE: - return R.drawable.ic_send_cancel_online; - case AWAY: - return R.drawable.ic_send_cancel_away; - case XA: - case DND: - return R.drawable.ic_send_cancel_dnd; - default: - return getThemeResource(activity, R.attr.ic_send_cancel_offline, R.drawable.ic_send_cancel_offline); - } + d = activity.getResources().getDrawable(R.drawable.ic_send_cancel_online); + break; case CHOOSE_PICTURE: - switch (status) { - case CHAT: - case ONLINE: - return R.drawable.ic_send_picture_online; - case AWAY: - return R.drawable.ic_send_picture_away; - case XA: - case DND: - return R.drawable.ic_send_picture_dnd; - default: - return getThemeResource(activity, R.attr.ic_send_picture_offline, R.drawable.ic_send_picture_offline); - } + d = activity.getResources().getDrawable(R.drawable.ic_send_picture_online); + break; + default: + return null; } - return getThemeResource(activity, R.attr.ic_send_text_offline, R.drawable.ic_send_text_offline); + d.mutate().setColorFilter(colorForStatus(activity, status), PorterDuff.Mode.SRC_IN); + return d; } - - private static int getThemeResource(Activity activity, int r_attr_name, int r_drawable_def) { - int[] attrs = {r_attr_name}; - TypedArray ta = activity.getTheme().obtainStyledAttributes(attrs); - - int res = ta.getResourceId(0, r_drawable_def); - ta.recycle(); - - return res; - } - } diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index 24c18e8d3ee06eb161539a909e72a6872e0dfc57..e000199228744581aee3f177c50614d9b7be728b 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -622,7 +622,7 @@ public class UIHelper { case AWAY: return new ListItem.Tag(context.getString(R.string.presence_away), 0xfff8b990); case XA: - return new ListItem.Tag(context.getString(R.string.presence_xa), 0xff397975); + return new ListItem.Tag(context.getString(R.string.presence_xa), 0xffe97975); case DND: return new ListItem.Tag(context.getString(R.string.presence_dnd), 0xffe97975); default: diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 2579c7b51c82c180d109a489a7e08b42acb94eaf..26898962c92e45dd786e6402268c89059f26dcb0 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -413,4 +413,4 @@ 56sp - \ No newline at end of file +