From c37c1dffd4de787a94056b9b6359381a4dcfffed Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 21 Sep 2018 18:35:06 -0700 Subject: [PATCH] Allow setting the color for a group. --- .../securesms/RecipientPreferenceActivity.java | 14 +++++++++----- .../securesms/recipients/Recipient.java | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java index f5b50ce0f9..1e74347833 100644 --- a/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java +++ b/src/org/thoughtcrime/securesms/RecipientPreferenceActivity.java @@ -54,6 +54,7 @@ import org.thoughtcrime.securesms.database.RecipientDatabase.VibrateState; import org.thoughtcrime.securesms.database.loaders.ThreadMediaLoader; import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob; import org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob; +import org.thoughtcrime.securesms.jobs.MultiDeviceGroupUpdateJob; import org.thoughtcrime.securesms.mms.GlideApp; import org.thoughtcrime.securesms.mms.GlideRequests; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; @@ -380,15 +381,14 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi vibrateCallPreference.setSummary(vibrateCallSummary.first); vibrateCallPreference.setValueIndex(vibrateCallSummary.second); + colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity())); + colorPreference.setColor(recipient.getColor().toActionBarColor(getActivity())); + if (recipient.isGroupRecipient()) { - if (colorPreference != null) colorPreference.setVisible(false); if (identityPreference != null) identityPreference.setVisible(false); if (aboutCategory != null) getPreferenceScreen().removePreference(aboutCategory); if (aboutDivider != null) getPreferenceScreen().removePreference(aboutDivider); } else { - colorPreference.setColors(MaterialColors.CONVERSATION_PALETTE.asConversationColorArray(getActivity())); - colorPreference.setColor(recipient.getColor().toActionBarColor(getActivity())); - aboutPreference.setTitle(formatAddress(recipient.getAddress())); aboutPreference.setSummary(recipient.getCustomLabel()); aboutPreference.setSecure(recipient.getRegistered() == RecipientDatabase.RegisteredState.REGISTERED); @@ -583,7 +583,11 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi protected Void doInBackground(Void... params) { DatabaseFactory.getRecipientDatabase(context).setColor(recipient, selectedColor); - if (recipient.resolve().getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) { + if (recipient.resolve().isGroupRecipient()) { + ApplicationContext.getInstance(context) + .getJobManager() + .add(new MultiDeviceGroupUpdateJob(context)); + } else if (recipient.resolve().getRegistered() == RecipientDatabase.RegisteredState.REGISTERED) { ApplicationContext.getInstance(context) .getJobManager() .add(new MultiDeviceContactUpdateJob(context, recipient.getAddress())); diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index 41b8638e35..79e0d9605b 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -292,8 +292,7 @@ public class Recipient implements RecipientModifiedListener { } public synchronized @NonNull MaterialColor getColor() { - if (isGroupRecipient()) return MaterialColor.BLUE; - else if (color != null) return color; + if (color != null) return color; else if (name != null) return ContactColors.generateFor(name); else return ContactColors.UNKNOWN_COLOR; }