diff options
Diffstat (limited to '')
17 files changed, 239 insertions, 102 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusColors.java b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusColors.java new file mode 100644 index 00000000..352e86e3 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusColors.java @@ -0,0 +1,157 @@ +package de.thedevstack.conversationsplus; + +/** + * Helper class for accessing colors. + */ +public final class ConversationsPlusColors { + /** + * Returns the primary background color. + * @return the primary background color + */ + public static int primaryBackground() { + return byId(R.color.primaryBackground); + } + + /** + * Returns the secondary background color. + * @return the secondary background color + */ + public static int secondaryBackground() { + return byId(R.color.secondaryBackground); + } + + /** + * Returns the primary text color. + * @return the primary text color + */ + public static int primaryText() { + return byId(R.color.primaryText); + } + + /** + * Returns the secondary text color. + * @return the secondary text color + */ + public static int secondaryText() { + return byId(R.color.secondaryText); + } + + /** + * Returns the tertiary text color. + * @return the tertiary text color + */ + public static int tertiaryText() { + return byId(R.color.tertiaryText); + } + + /** + * Returns the primary text color on dark background. + * @return the primary text color on dark background + */ + public static int primaryTextOnDark() { + return byId(R.color.primaryTextOnDark); + } + + /** + * Returns the secondary text color on dark background. + * @return the secondary text color on dark background + */ + public static int secondaryTextOnDark() { + return byId(R.color.secondaryTextOnDark); + } + + /** + * Returns the online color. + * @return the online color + */ + public static int online() { + return byId(R.color.online); + } + + /** + * Returns the color for the presence status 'chat'. + * @return the color for the presence status 'chat' + */ + public static int chat() { + return byId(R.color.chat); + } + + /** + * Returns the color for the presence status 'away'. + * @return the color for the presence status 'away' + */ + public static int away() { + return byId(R.color.away); + } + + /** + * Returns the color for the presence status 'dnd'. + * @return the color for the presence status 'dnd' + */ + public static int dnd() { + return byId(R.color.dnd); + } + + /** + * Returns the color for the presence status 'xa'. + * @return the color for the presence status 'xa' + */ + public static int xa() { + return byId(R.color.xa); + } + + /** + * Returns the color for the presence status 'offline'. + * @return the color for the presence status 'offline' + */ + public static int offline() { + return byId(R.color.offline); + } + + /** + * Returns the error color. + * @return the error color + */ + public static int error() { + return byId(R.color.error); + } + + /** + * Returns the warning color. + * @return the warning color + */ + public static int warning() { + return byId(R.color.warning); + } + + /** + * Returns the notification color. + * @return the notification color + */ + public static int notification() { + return byId(R.color.notification); + } + + /** + * Returns the accent color. + * @return the accent color + */ + public static int accent() { + return byId(R.color.accent); + } + + /** + * Returns the color identified by id. + * Delegates to android.content.res.Resources.getColor(int) + * @param id the id of the color + * @see {@link android.content.res.Resources#getColor(int)} + * @return the color identified by id + */ + private static int byId(int id) { + return ConversationsPlusApplication.getAppContext().getResources().getColor(id); + } + + private ConversationsPlusColors() { + // avoid instantiation - helper class + } +} diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java b/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java index 74d76f13..8f73be1d 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Contact.java @@ -170,7 +170,7 @@ public class Contact implements ListItem, Blockable { @Override public int getStatusColor() { - return Color.parseColor(UIHelper.getStatusColor(getMostAvailableStatus())); + return UIHelper.getStatusColor(getMostAvailableStatus()); } public boolean match(String needle) { diff --git a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java index 92b7cfa1..1baec3a5 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java @@ -27,6 +27,7 @@ import java.util.LinkedHashMap; import java.util.List; import de.thedevstack.conversationsplus.ConversationsPlusApplication; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.utils.ImageUtil; import de.thedevstack.conversationsplus.utils.MessageUtil; @@ -167,7 +168,7 @@ public class NotificationService { } private void setNotificationColor(final Builder mBuilder) { - mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary)); + mBuilder.setColor(ConversationsPlusColors.notification()); } public void updateNotification(final boolean notify) { diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ChangePasswordActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ChangePasswordActivity.java index 1eb9fa05..65b3c49b 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ChangePasswordActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ChangePasswordActivity.java @@ -6,6 +6,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.Toast; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.services.XmppConnectionService; @@ -38,7 +39,7 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti mNewPasswordConfirm.setError(null); xmppConnectionService.updateAccountPasswordOnServer(mAccount, newPassword, ChangePasswordActivity.this); mChangePasswordButton.setEnabled(false); - mChangePasswordButton.setTextColor(getSecondaryTextColor()); + mChangePasswordButton.setTextColor(ConversationsPlusColors.secondaryText()); mChangePasswordButton.setText(R.string.updating); } } @@ -91,7 +92,7 @@ public class ChangePasswordActivity extends XmppActivity implements XmppConnecti public void run() { mNewPassword.setError(getString(R.string.could_not_change_password)); mChangePasswordButton.setEnabled(true); - mChangePasswordButton.setTextColor(getPrimaryTextColor()); + mChangePasswordButton.setTextColor(ConversationsPlusColors.primaryText()); mChangePasswordButton.setText(R.string.change_password); } }); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java index ac06544a..9a616414 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/EditAccountActivity.java @@ -38,6 +38,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.ui.listeners.ShowResourcesListDialogListener; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.R; @@ -336,24 +337,24 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate if (accountInfoEdited() && !mInitMode) { this.mSaveButton.setText(R.string.save); this.mSaveButton.setEnabled(true); - this.mSaveButton.setTextColor(getPrimaryTextColor()); + this.mSaveButton.setTextColor(ConversationsPlusColors.primaryText()); } else if (mAccount != null && (mAccount.getStatus() == Account.State.CONNECTING || mFetchingAvatar)) { this.mSaveButton.setEnabled(false); - this.mSaveButton.setTextColor(getSecondaryTextColor()); + this.mSaveButton.setTextColor(ConversationsPlusColors.secondaryText()); this.mSaveButton.setText(R.string.account_status_connecting); } else if (mAccount != null && mAccount.getStatus() == Account.State.DISABLED && !mInitMode) { this.mSaveButton.setEnabled(true); - this.mSaveButton.setTextColor(getPrimaryTextColor()); + this.mSaveButton.setTextColor(ConversationsPlusColors.primaryText()); this.mSaveButton.setText(R.string.enable); } else { this.mSaveButton.setEnabled(true); - this.mSaveButton.setTextColor(getPrimaryTextColor()); + this.mSaveButton.setTextColor(ConversationsPlusColors.primaryText()); if (!mInitMode) { if (mAccount != null && mAccount.isOnlineAndConnected()) { this.mSaveButton.setText(R.string.save); if (!accountInfoEdited()) { this.mSaveButton.setEnabled(false); - this.mSaveButton.setTextColor(getSecondaryTextColor()); + this.mSaveButton.setTextColor(ConversationsPlusColors.secondaryText()); } } else { this.mSaveButton.setText(R.string.connect); @@ -552,7 +553,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate getActionBar().setHomeButtonEnabled(false); } this.mCancelButton.setEnabled(false); - this.mCancelButton.setTextColor(getSecondaryTextColor()); + this.mCancelButton.setTextColor(ConversationsPlusColors.secondaryText()); } if (Config.DOMAIN_LOCK == null) { final KnownHostsAdapter mKnownHostsAdapter = new KnownHostsAdapter(this, diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java index 23601f44..1501c78a 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/PublishProfilePictureActivity.java @@ -22,6 +22,7 @@ import com.soundcloud.android.crop.Crop; import java.io.File; import java.io.FileNotFoundException; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.utils.ImageUtil; import de.thedevstack.conversationsplus.Config; import de.thedevstack.conversationsplus.R; @@ -85,7 +86,7 @@ public class PublishProfilePictureActivity extends XmppActivity { @Override public void run() { hintOrWarning.setText(errorCode); - hintOrWarning.setTextColor(getWarningTextColor()); + hintOrWarning.setTextColor(ConversationsPlusColors.warning()); publishButton.setText(R.string.publish); enablePublishButton(); } @@ -245,7 +246,7 @@ public class PublishProfilePictureActivity extends XmppActivity { } if (!support) { this.hintOrWarning - .setTextColor(getWarningTextColor()); + .setTextColor(ConversationsPlusColors.warning()); this.hintOrWarning .setText(R.string.error_publish_avatar_no_server_support); } @@ -288,7 +289,7 @@ public class PublishProfilePictureActivity extends XmppActivity { if (bm == null) { disablePublishButton(); - this.hintOrWarning.setTextColor(getWarningTextColor()); + this.hintOrWarning.setTextColor(ConversationsPlusColors.warning()); this.hintOrWarning .setText(R.string.error_publish_avatar_converting); return; @@ -298,10 +299,10 @@ public class PublishProfilePictureActivity extends XmppActivity { enablePublishButton(); this.publishButton.setText(R.string.publish); this.hintOrWarning.setText(R.string.publish_avatar_explanation); - this.hintOrWarning.setTextColor(getPrimaryTextColor()); + this.hintOrWarning.setTextColor(ConversationsPlusColors.primaryText()); } else { disablePublishButton(); - this.hintOrWarning.setTextColor(getWarningTextColor()); + this.hintOrWarning.setTextColor(ConversationsPlusColors.warning()); this.hintOrWarning .setText(R.string.error_publish_avatar_no_server_support); } @@ -316,12 +317,12 @@ public class PublishProfilePictureActivity extends XmppActivity { protected void enablePublishButton() { this.publishButton.setEnabled(true); - this.publishButton.setTextColor(getPrimaryTextColor()); + this.publishButton.setTextColor(ConversationsPlusColors.primaryText()); } protected void disablePublishButton() { this.publishButton.setEnabled(false); - this.publishButton.setTextColor(getSecondaryTextColor()); + this.publishButton.setTextColor(ConversationsPlusColors.secondaryText()); } public void refreshUiReal() { diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/TrustKeysActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/TrustKeysActivity.java index a3f674be..7772adc4 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/TrustKeysActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/TrustKeysActivity.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.crypto.axolotl.AxolotlService; import de.thedevstack.conversationsplus.crypto.axolotl.XmppAxolotlSession; @@ -306,12 +307,12 @@ public class TrustKeysActivity extends XmppActivity implements OnKeyStatusUpdate private void unlock() { mSaveButton.setEnabled(true); - mSaveButton.setTextColor(getPrimaryTextColor()); + mSaveButton.setTextColor(ConversationsPlusColors.primaryText()); } private void lock() { mSaveButton.setEnabled(false); - mSaveButton.setTextColor(getSecondaryTextColor()); + mSaveButton.setTextColor(ConversationsPlusColors.secondaryText()); } private void lockOrUnlockAsNeeded() { diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/VerifyOTRActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/VerifyOTRActivity.java index 494d4bea..3ecdc179 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/VerifyOTRActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/VerifyOTRActivity.java @@ -19,6 +19,7 @@ import com.google.zxing.integration.android.IntentResult; import net.java.otr4j.OtrException; import net.java.otr4j.session.Session; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.entities.Contact; @@ -380,14 +381,14 @@ public class VerifyOTRActivity extends XmppActivity implements XmppConnectionSer protected void activateButton(Button button, int text, View.OnClickListener listener) { button.setEnabled(true); - button.setTextColor(getPrimaryTextColor()); + button.setTextColor(ConversationsPlusColors.primaryText()); button.setText(text); button.setOnClickListener(listener); } protected void deactivateButton(Button button, int text) { button.setEnabled(false); - button.setTextColor(getSecondaryTextColor()); + button.setTextColor(ConversationsPlusColors.secondaryText()); button.setText(text); button.setOnClickListener(null); } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java index fed3049b..f7856a9c 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/XmppActivity.java @@ -70,6 +70,7 @@ import java.util.List; import java.util.concurrent.RejectedExecutionException; import de.thedevstack.android.logcat.Logging; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.utils.ImageUtil; import de.thedevstack.conversationsplus.Config; @@ -103,16 +104,6 @@ public abstract class XmppActivity extends Activity { public boolean xmppConnectionServiceBound = false; protected boolean registeredListeners = false; - protected int mPrimaryTextColor; - protected int mSecondaryTextColor; - protected int mTertiaryTextColor; - protected int mPrimaryBackgroundColor; - protected int mSecondaryBackgroundColor; - protected int mColorRed; - protected int mColorOrange; - protected int mColorGreen; - protected int mPrimaryColor; - protected boolean mUseSubject = true; private DisplayMetrics metrics; @@ -360,15 +351,6 @@ public abstract class XmppActivity extends Activity { super.onCreate(savedInstanceState); metrics = getResources().getDisplayMetrics(); ExceptionHelper.init(getApplicationContext()); - mPrimaryTextColor = getResources().getColor(R.color.primaryText); - mSecondaryTextColor = getResources().getColor(R.color.secondaryText); - mTertiaryTextColor = getResources().getColor(R.color.black12); - mColorRed = getResources().getColor(R.color.error); - mColorOrange = getResources().getColor(R.color.orange500); - mColorGreen = getResources().getColor(R.color.online); - mPrimaryColor = getResources().getColor(R.color.primary); - mPrimaryBackgroundColor = getResources().getColor(R.color.primaryBackground); - mSecondaryBackgroundColor = getResources().getColor(R.color.secondaryBackground); this.mTheme = findTheme(); setTheme(this.mTheme); this.mUsingEnterKey = ConversationsPlusPreferences.displayEnterKey(); @@ -749,30 +731,30 @@ public abstract class XmppActivity extends Activity { if (Config.X509_VERIFICATION && trust == XmppAxolotlSession.Trust.TRUSTED_X509) { trustToggle.setOnClickListener(null); } - key.setTextColor(getPrimaryTextColor()); - keyType.setTextColor(getSecondaryTextColor()); + key.setTextColor(ConversationsPlusColors.primaryText()); + keyType.setTextColor(ConversationsPlusColors.secondaryText()); break; case UNDECIDED: trustToggle.setChecked(false); trustToggle.setEnabled(false); - key.setTextColor(getPrimaryTextColor()); - keyType.setTextColor(getSecondaryTextColor()); + key.setTextColor(ConversationsPlusColors.primaryText()); + keyType.setTextColor(ConversationsPlusColors.secondaryText()); break; case INACTIVE_UNTRUSTED: case INACTIVE_UNDECIDED: trustToggle.setOnClickListener(null); trustToggle.setChecked(false); trustToggle.setEnabled(false); - key.setTextColor(getTertiaryTextColor()); - keyType.setTextColor(getTertiaryTextColor()); + key.setTextColor(ConversationsPlusColors.tertiaryText()); + keyType.setTextColor(ConversationsPlusColors.tertiaryText()); break; case INACTIVE_TRUSTED: case INACTIVE_TRUSTED_X509: trustToggle.setOnClickListener(null); trustToggle.setChecked(true); trustToggle.setEnabled(false); - key.setTextColor(getTertiaryTextColor()); - keyType.setTextColor(getTertiaryTextColor()); + key.setTextColor(ConversationsPlusColors.tertiaryText()); + keyType.setTextColor(ConversationsPlusColors.tertiaryText()); break; } @@ -782,7 +764,7 @@ public abstract class XmppActivity extends Activity { keyType.setVisibility(View.GONE); } if (highlight) { - keyType.setTextColor(getResources().getColor(R.color.accent)); + keyType.setTextColor(ConversationsPlusColors.accent()); keyType.setText(getString(x509 ? R.string.omemo_fingerprint_x509_selected_message : R.string.omemo_fingerprint_selected_message)); } else { keyType.setText(getString(x509 ? R.string.omemo_fingerprint_x509 : R.string.omemo_fingerprint)); @@ -944,34 +926,6 @@ public abstract class XmppActivity extends Activity { } }; - public int getTertiaryTextColor() { - return this.mTertiaryTextColor; - } - - public int getSecondaryTextColor() { - return this.mSecondaryTextColor; - } - - public int getPrimaryTextColor() { - return this.mPrimaryTextColor; - } - - public int getWarningTextColor() { - return this.mColorRed; - } - - public int getOnlineColor() { - return this.mColorGreen; - } - - public int getPrimaryBackgroundColor() { - return this.mPrimaryBackgroundColor; - } - - public int getSecondaryBackgroundColor() { - return this.mSecondaryBackgroundColor; - } - public int getPixel(int dp) { DisplayMetrics metrics = getResources().getDisplayMetrics(); return ((int) (dp * metrics.density)); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java index b6caa019..ee209576 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java @@ -13,6 +13,7 @@ import android.widget.TextView; import java.util.List; import de.thedevstack.conversationsplus.Config; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.services.AvatarService; @@ -48,14 +49,14 @@ public class AccountAdapter extends ArrayAdapter<Account> { statusView.setText(getContext().getString(account.getStatus().getReadableId())); switch (account.getStatus()) { case ONLINE: - statusView.setTextColor(activity.getOnlineColor()); + statusView.setTextColor(ConversationsPlusColors.online()); break; case DISABLED: case CONNECTING: - statusView.setTextColor(activity.getSecondaryTextColor()); + statusView.setTextColor(ConversationsPlusColors.secondaryText()); break; default: - statusView.setTextColor(activity.getWarningTextColor()); + statusView.setTextColor(ConversationsPlusColors.warning()); break; } final Switch tglAccountState = (Switch) view.findViewById(R.id.tgl_account_status); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java index ab131cd0..37b8aa18 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java @@ -20,6 +20,7 @@ import java.lang.ref.WeakReference; import java.util.List; import java.util.concurrent.RejectedExecutionException; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.ui.listeners.ShowResourcesListDialogListener; import de.tzur.conversations.Settings; import de.thedevstack.conversationsplus.R; @@ -52,7 +53,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> { // Highlight the currently selected conversation if (this.activity instanceof ConversationActivity) { ConversationActivity a = (ConversationActivity) this.activity; - int c = conversation == a.getSelectedConversation() ? a.getSecondaryBackgroundColor() : a.getPrimaryBackgroundColor(); + int c = conversation == a.getSelectedConversation() ? ConversationsPlusColors.secondaryBackground() : ConversationsPlusColors.primaryBackground(); view.findViewById(R.id.conversationListRowContent).setBackgroundColor(c); view.findViewById(R.id.conversationListRowFrame).setBackgroundColor(c); } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java index bcfc1dc6..9311674b 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java @@ -39,6 +39,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import de.thedevstack.conversationsplus.ConversationsPlusApplication; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.ConversationsPlusPreferences; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.crypto.axolotl.XmppAxolotlSession; @@ -121,9 +122,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { private int getMessageTextColor(boolean onDark, boolean primary) { if (onDark) { - return activity.getResources().getColor(primary ? R.color.white : R.color.white70); + return primary ? ConversationsPlusColors.primaryTextOnDark() : ConversationsPlusColors.secondaryTextOnDark(); } else { - return activity.getResources().getColor(primary ? R.color.black87 : R.color.black54); + return primary ? ConversationsPlusColors.primaryText() : ConversationsPlusColors.secondaryText(); } } @@ -184,7 +185,7 @@ public class MessageAdapter extends ArrayAdapter<Message> { break; } if (error && type == SENT) { - viewHolder.time.setTextColor(activity.getWarningTextColor()); + viewHolder.time.setTextColor(ConversationsPlusColors.warning()); } else { viewHolder.time.setTextColor(this.getMessageTextColor(darkBackground,false)); } @@ -199,7 +200,7 @@ public class MessageAdapter extends ArrayAdapter<Message> { message.getAxolotlFingerprint()); if(trust == null || (!trust.trusted() && !trust.trustedInactive())) { - viewHolder.indicator.setColorFilter(activity.getWarningTextColor()); + viewHolder.indicator.setColorFilter(ConversationsPlusColors.warning()); viewHolder.indicator.setAlpha(1.0f); } else { viewHolder.indicator.clearColorFilter(); diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/PresencesArrayAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/PresencesArrayAdapter.java index 2f8d12f2..2d777897 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/adapter/PresencesArrayAdapter.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/PresencesArrayAdapter.java @@ -36,7 +36,7 @@ public class PresencesArrayAdapter extends ArrayAdapter<Presence> { View rowView = inflater.inflate(R.layout.dialog_resources_status, parent, false); TextView textView = (TextView) rowView.findViewById(R.id.dlg_res_stat_resource_name); textView.setText(this.values[position].resource); - textView.setTextColor(Color.parseColor(UIHelper.getStatusColor(this.values[position].status))); + textView.setTextColor(UIHelper.getStatusColor(this.values[position].status)); return rowView; } diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java index 9ef51dd4..dfa3147d 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java @@ -8,6 +8,7 @@ import android.widget.TextView; import java.util.Date; import de.thedevstack.android.logcat.Logging; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Conversation; import de.thedevstack.conversationsplus.entities.Message; @@ -86,7 +87,7 @@ public class MessageDetailsDialog extends AbstractAlertDialog { break; case Message.STATUS_SEND_FAILED: msgStatusResId = R.string.dlg_msg_details_msg_status_failed; - msgStatusTextView.setTextColor(getContext().getResources().getColor(R.color.error)); + msgStatusTextView.setTextColor(ConversationsPlusColors.error()); break; case Message.STATUS_RECEIVED: msgStatusResId = R.string.dlg_msg_details_msg_status_received; diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/forms/FormFieldWrapper.java b/src/main/java/de/thedevstack/conversationsplus/ui/forms/FormFieldWrapper.java index c82421a2..662d5bb5 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/forms/FormFieldWrapper.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/forms/FormFieldWrapper.java @@ -9,6 +9,7 @@ import android.view.View; import java.util.List; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.xmpp.forms.Field; @@ -57,7 +58,7 @@ public abstract class FormFieldWrapper { int start = label.length(); int end = label.length() + 2; spannableString.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), start, end, 0); - spannableString.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.accent)), start, end, 0); + spannableString.setSpan(new ForegroundColorSpan(ConversationsPlusColors.accent()), start, end, 0); } return spannableString; } diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java index 1c142dad..f27aabb6 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java @@ -12,6 +12,7 @@ import java.util.Calendar; import java.util.Date; import java.util.Locale; +import de.thedevstack.conversationsplus.ConversationsPlusColors; import de.thedevstack.conversationsplus.R; import de.thedevstack.conversationsplus.entities.Contact; import de.thedevstack.conversationsplus.entities.Conversation; @@ -242,19 +243,21 @@ public class UIHelper { } } - public static String getStatusColor(Presence.Status status) { - switch (status) { - case ONLINE: - case CHAT: - return "#259B23"; - case AWAY: - case XA: - return "#FF9800"; - case DND: - return "#E51C23"; - } - return "#CCCCCC"; - } + public static int getStatusColor(Presence.Status status) { + switch (status) { + case ONLINE: + return ConversationsPlusColors.online(); + case CHAT: + return ConversationsPlusColors.chat(); + case AWAY: + return ConversationsPlusColors.away(); + case XA: + return ConversationsPlusColors.xa(); + case DND: + return ConversationsPlusColors.dnd(); + } + return ConversationsPlusColors.offline(); + } private static String getDisplayedMucCounterpart(final Jid counterpart) { if (counterpart==null) { diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml index 2d744395..2a0ad592 100644 --- a/src/main/res/values/colors.xml +++ b/src/main/res/values/colors.xml @@ -4,11 +4,23 @@ <color name="secondaryBackground">@color/grey200</color> <color name="primaryText">@color/black87</color> <color name="secondaryText">@color/black54</color> + <color name="tertiaryText">@color/black12</color> + + <color name="primaryTextOnDark">@color/white</color> + <color name="secondaryTextOnDark">@color/white70</color> + <color name="warning">@color/red500</color> <color name="error">@color/red500</color> - <color name="online">@color/green500</color> <color name="notification">@color/green500</color> + <!-- Colors for presence status --> + <color name="online">@color/green500</color> + <color name="chat">@color/green500</color> + <color name="away">@color/orange500</color> + <color name="xa">@color/orange500</color> + <color name="dnd">#ffe51c23</color> + <color name="offline">#ffcccccc</color> + <color name="primary">@color/green500</color> <color name="primary_dark">@color/green700</color> <color name="accent">#ff0091ea</color> |