From 4fd036f79877d1a5e35f1af6d9680bacea652704 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 26 Sep 2023 00:46:32 +0200 Subject: [PATCH] make the button look more like a button --- .../securesms/ProfileSettingsAdapter.java | 18 ++++++++++-------- .../securesms/ProfileSettingsItem.java | 13 ++++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java b/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java index 7574447b4..629a88ec1 100644 --- a/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java +++ b/src/org/thoughtcrime/securesms/ProfileSettingsAdapter.java @@ -62,22 +62,24 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter int chatlistIndex; int settingsId; String label; + int labelColor; int iconLeft; - ItemData(int type, int settingsId, String label, int iconLeft) { - this(type, 0, 0, settingsId, label, iconLeft); + ItemData(int type, int settingsId, String label, int labelColor, int iconLeft) { + this(type, 0, 0, settingsId, label, labelColor, iconLeft); } ItemData(int type, int contactId, int chatlistIndex) { - this(type, contactId, chatlistIndex, 0, null, 0); + this(type, contactId, chatlistIndex, 0, null, 0, 0); } - ItemData(int type, int contactId, int chatlistIndex, int settingsId, @Nullable String label, int iconLeft) { + ItemData(int type, int contactId, int chatlistIndex, int settingsId, @Nullable String label, int labelColor, int iconLeft) { this.type = type; this.contactId = contactId; this.chatlistIndex = chatlistIndex; this.settingsId = settingsId; this.label = label; + this.labelColor = labelColor; this.iconLeft = iconLeft; } }; @@ -194,7 +196,7 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter int settingsId = itemData.get(i).settingsId; ProfileSettingsItem profileSettingsItem = (ProfileSettingsItem) holder.itemView; profileSettingsItem.setOnClickListener(view -> clickListener.onSettingsClicked(settingsId)); - profileSettingsItem.set(itemData.get(i).label, itemData.get(i).iconLeft); + profileSettingsItem.set(itemData.get(i).label, itemData.get(i).labelColor, itemData.get(i).iconLeft); } } @@ -320,14 +322,14 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter if (!dcContact.getVerifierAddr().isEmpty()) { verifiedInfo = context.getString(R.string.verified_by, dcContact.getVerifierAddr()); } - itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_VERIFIED, verifiedInfo, R.drawable.ic_verified)); + itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_VERIFIED, verifiedInfo, 0, R.drawable.ic_verified)); } - itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_SEND_MESSAGE, context.getString(R.string.send_message), 0)); + itemData.add(new ItemData(ItemData.TYPE_PRIMARY_SETTING, SETTING_SEND_MESSAGE, context.getString(R.string.send_message), R.color.delta_accent, 0)); } itemDataStatusText = dcContact.getStatus(); if (!itemDataStatusText.isEmpty()) { - itemData.add(new ItemData(ItemData.TYPE_STATUS, 0, itemDataStatusText, 0)); + itemData.add(new ItemData(ItemData.TYPE_STATUS, 0, itemDataStatusText, 0, 0)); } itemDataSharedChats = sharedChats; diff --git a/src/org/thoughtcrime/securesms/ProfileSettingsItem.java b/src/org/thoughtcrime/securesms/ProfileSettingsItem.java index c97800cd5..8d285d173 100644 --- a/src/org/thoughtcrime/securesms/ProfileSettingsItem.java +++ b/src/org/thoughtcrime/securesms/ProfileSettingsItem.java @@ -5,6 +5,10 @@ import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.TextView; +import androidx.core.content.ContextCompat; + +import org.thoughtcrime.securesms.util.ResUtil; + public class ProfileSettingsItem extends LinearLayout { private TextView labelView; @@ -23,8 +27,15 @@ public class ProfileSettingsItem extends LinearLayout { labelView = findViewById(R.id.label); } - public void set(String label, int iconLeft) { + public void set(String label, int labelColor, int iconLeft) { labelView.setText(label==null? "" : label); labelView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, 0,0,0); + + // we need different color getters as `labelColor` is `R.color.name` while default is `R.attr.name` + if (labelColor != 0) { + labelView.setTextColor(ContextCompat.getColor(getContext(), labelColor)); + } else { + labelView.setTextColor(ResUtil.getColor(getContext(), R.attr.emoji_text_color)); // + } } }