aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ConversationsPlusColors.java157
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/adapter/PresencesArrayAdapter.java2
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java4
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Contact.java2
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java3
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java13
-rw-r--r--src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java15
-rw-r--r--src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java66
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java8
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java3
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/forms/FormFieldWrapper.java4
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java30
-rw-r--r--src/main/res/values/colors.xml14
17 files changed, 246 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/ui/adapter/PresencesArrayAdapter.java b/src/main/java/de/thedevstack/conversationsplus/ui/adapter/PresencesArrayAdapter.java
index e14d7f6b..d1f1e835 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 9ada85f3..e5a478e8 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,8 @@ import android.widget.TextView;
import java.util.Date;
import de.thedevstack.android.logcat.Logging;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
@@ -86,7 +88,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/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java
index bdde12e3..9b4be366 100644
--- a/src/main/java/eu/siacs/conversations/entities/Contact.java
+++ b/src/main/java/eu/siacs/conversations/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/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index 0f40e8d7..c54e2f31 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/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/eu/siacs/conversations/ui/ChangePasswordActivity.java b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java
index 1cc8fd29..5c3f9bb3 100644
--- a/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ChangePasswordActivity.java
@@ -6,6 +6,8 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService;
@@ -38,7 +40,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 +93,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/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index 720a7454..9e01837a 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/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 eu.siacs.conversations.Config;
import eu.siacs.conversations.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/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
index 57fcf4e3..301baff5 100644
--- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java
+++ b/src/main/java/eu/siacs/conversations/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 eu.siacs.conversations.Config;
import eu.siacs.conversations.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/eu/siacs/conversations/ui/TrustKeysActivity.java b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java
index cc4ba7b2..96a365ef 100644
--- a/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/TrustKeysActivity.java
@@ -18,6 +18,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
@@ -305,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/eu/siacs/conversations/ui/VerifyOTRActivity.java b/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java
index 2e415d5b..d94c9a1e 100644
--- a/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/VerifyOTRActivity.java
@@ -19,6 +19,8 @@ import com.google.zxing.integration.android.IntentResult;
import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
@@ -380,14 +382,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/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 2568e4b9..880641b9 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/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;
@@ -104,16 +105,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;
@@ -361,15 +352,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();
@@ -750,30 +732,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;
}
@@ -783,7 +765,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));
@@ -945,34 +927,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/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
index b8f15e0e..55d3f5a7 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java
@@ -12,6 +12,8 @@ import android.widget.TextView;
import java.util.List;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
@@ -48,14 +50,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/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index 2e40717a..31e54a0d 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/eu/siacs/conversations/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 eu.siacs.conversations.R;
@@ -53,7 +54,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/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 1c0813a5..478c0604 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/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.providers.ConversationsPlusFileProvider;
import eu.siacs.conversations.R;
@@ -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/eu/siacs/conversations/ui/forms/FormFieldWrapper.java b/src/main/java/eu/siacs/conversations/ui/forms/FormFieldWrapper.java
index 3b051191..cb504576 100644
--- a/src/main/java/eu/siacs/conversations/ui/forms/FormFieldWrapper.java
+++ b/src/main/java/eu/siacs/conversations/ui/forms/FormFieldWrapper.java
@@ -9,6 +9,8 @@ import android.view.View;
import java.util.List;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.xmpp.forms.Field;
@@ -57,7 +59,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/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index 5e4b4acd..a97b16a4 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -12,6 +12,8 @@ import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
+import de.thedevstack.conversationsplus.ConversationsPlusColors;
+
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
@@ -242,19 +244,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>