diff options
Diffstat (limited to 'src/main/java/de/pixart')
7 files changed, 27 insertions, 20 deletions
diff --git a/src/main/java/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java index 781603784..adc106ee5 100644 --- a/src/main/java/de/pixart/messenger/services/NotificationService.java +++ b/src/main/java/de/pixart/messenger/services/NotificationService.java @@ -14,6 +14,7 @@ import android.support.v4.app.NotificationCompat.BigPictureStyle; import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.RemoteInput; +import android.support.v4.content.ContextCompat; import android.text.SpannableString; import android.text.style.StyleSpan; import android.util.DisplayMetrics; @@ -233,7 +234,7 @@ public class NotificationService { } private void setNotificationColor(final Builder mBuilder) { - mBuilder.setColor(mXmppConnectionService.getResources().getColor(R.color.primary)); + mBuilder.setColor(ContextCompat.getColor(mXmppConnectionService, R.color.primary)); } public void updateNotification(final boolean notify) { diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index b0fd4cd79..8a2e72145 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -14,6 +14,7 @@ import android.preference.PreferenceManager; import android.provider.ContactsContract.CommonDataKinds; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents; +import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -558,7 +559,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp key.setText(CryptoHelper.prettifyFingerprint(otrFingerprint)); if (otrFingerprint != null && otrFingerprint.equals(messageFingerprint)) { keyType.setText(R.string.otr_fingerprint_selected_message); - keyType.setTextColor(getResources().getColor(R.color.accent)); + keyType.setTextColor(ContextCompat.getColor(this, R.color.accent)); } else { keyType.setText(R.string.otr_fingerprint); } @@ -607,7 +608,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp TextView keyType = (TextView) view.findViewById(R.id.key_type); keyType.setText(R.string.openpgp_key_id); if ("pgp".equals(messageFingerprint)) { - keyType.setTextColor(getResources().getColor(R.color.accent)); + keyType.setTextColor(ContextCompat.getColor(this, R.color.accent)); } key.setText(OpenPgpUtils.convertKeyIdToHex(contact.getPgpKeyId())); view.setOnClickListener(new OnClickListener() { diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 359d24e31..957b0e0c9 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -14,6 +14,7 @@ import android.os.Bundle; import android.provider.Settings; import android.security.KeyChain; import android.security.KeyChainAliasCallback; +import android.support.v4.content.ContextCompat; import android.text.Editable; import android.text.TextWatcher; import android.view.Menu; @@ -941,7 +942,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (ownAxolotlFingerprint != null && Config.supportOmemo()) { this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE); if (ownAxolotlFingerprint.equals(messageFingerprint)) { - this.mOwnFingerprintDesc.setTextColor(getResources().getColor(R.color.accent)); + this.mOwnFingerprintDesc.setTextColor(ContextCompat.getColor(this, R.color.accent)); } else { this.mOwnFingerprintDesc.setTextColor(getSecondaryTextColor()); } diff --git a/src/main/java/de/pixart/messenger/ui/OmemoActivity.java b/src/main/java/de/pixart/messenger/ui/OmemoActivity.java index dfef4e200..499654cba 100644 --- a/src/main/java/de/pixart/messenger/ui/OmemoActivity.java +++ b/src/main/java/de/pixart/messenger/ui/OmemoActivity.java @@ -5,6 +5,7 @@ import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.support.v4.content.ContextCompat; import android.view.ContextMenu; import android.view.MenuItem; import android.view.View; @@ -228,7 +229,7 @@ public abstract class OmemoActivity extends XmppActivity { keyType.setVisibility(View.GONE); } if (highlight) { - keyType.setTextColor(getResources().getColor(R.color.accent)); + keyType.setTextColor(ContextCompat.getColor(this, R.color.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)); diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index b46ec8296..95a896cde 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -42,6 +42,7 @@ import android.os.IBinder; import android.os.PowerManager; import android.os.SystemClock; import android.preference.PreferenceManager; +import android.support.v4.content.ContextCompat; import android.text.InputType; import android.util.DisplayMetrics; import android.util.Pair; @@ -400,16 +401,16 @@ public abstract class XmppActivity extends Activity { EmojiManager.install(new IosEmojiProvider()); // This line needs to be executed before any usage of EmojiTextView or EmojiEditText. metrics = getResources().getDisplayMetrics(); ExceptionHelper.init(getApplicationContext()); - mPrimaryTextColor = getResources().getColor(R.color.black87); - mSecondaryTextColor = getResources().getColor(R.color.black54); - mTertiaryTextColor = getResources().getColor(R.color.black12); - mColorRed = getResources().getColor(R.color.red800); - mColorWhite = getResources().getColor(R.color.white70); - mColorOrange = getResources().getColor(R.color.orange500); - mColorGreen = getResources().getColor(R.color.realgreen); - mPrimaryColor = getResources().getColor(R.color.primary); - mPrimaryBackgroundColor = getResources().getColor(R.color.grey50); - mSecondaryBackgroundColor = getResources().getColor(R.color.grey200); + mPrimaryTextColor = ContextCompat.getColor(this, R.color.black87); + mSecondaryTextColor = ContextCompat.getColor(this, R.color.black54); + mTertiaryTextColor = ContextCompat.getColor(this, R.color.black12); + mColorRed = ContextCompat.getColor(this, R.color.red800); + mColorWhite = ContextCompat.getColor(this, R.color.white70); + mColorOrange = ContextCompat.getColor(this, R.color.orange500); + mColorGreen = ContextCompat.getColor(this, R.color.realgreen); + mPrimaryColor = ContextCompat.getColor(this, R.color.primary); + mPrimaryBackgroundColor = ContextCompat.getColor(this, R.color.grey50); + mSecondaryBackgroundColor = ContextCompat.getColor(this, R.color.grey200); this.mTheme = findTheme(); setTheme(this.mTheme); this.mUsingEnterKey = usingEnterKey(); diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index bb36f41e0..4c62bb1e6 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -13,6 +13,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; +import android.support.v4.content.ContextCompat; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableStringBuilder; @@ -168,9 +169,9 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie private int getMessageTextColor(boolean onDark, boolean primary) { if (onDark) { - return activity.getResources().getColor(primary ? R.color.dark : R.color.primary); + return ContextCompat.getColor(activity, primary ? R.color.dark : R.color.primary); } else { - return activity.getResources().getColor(primary ? R.color.dark : R.color.primary); + return ContextCompat.getColor(activity, primary ? R.color.dark : R.color.primary); } } @@ -386,7 +387,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie body.setSpan(new DividerSpan(false), end, end + 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } int color = darkBackground ? this.getMessageTextColor(darkBackground, false) - : getContext().getResources().getColor(R.color.bubble); + : ContextCompat.getColor(activity, R.color.bubble); DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); body.setSpan(new QuoteSpan(color, metrics), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return 0; @@ -524,7 +525,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie } viewHolder.messageBody.setTextColor(this.getMessageTextColor(darkBackground, true)); viewHolder.messageBody.setLinkTextColor(this.getMessageTextColor(darkBackground, true)); - viewHolder.messageBody.setHighlightColor(activity.getResources().getColor(darkBackground ? R.color.grey800 : R.color.grey500)); + viewHolder.messageBody.setHighlightColor(ContextCompat.getColor(activity, darkBackground ? R.color.grey800 : R.color.grey500)); viewHolder.messageBody.setTypeface(null, Typeface.NORMAL); } diff --git a/src/main/java/de/pixart/messenger/ui/forms/FormFieldWrapper.java b/src/main/java/de/pixart/messenger/ui/forms/FormFieldWrapper.java index 01b9ea0f9..adcc11809 100644 --- a/src/main/java/de/pixart/messenger/ui/forms/FormFieldWrapper.java +++ b/src/main/java/de/pixart/messenger/ui/forms/FormFieldWrapper.java @@ -1,6 +1,7 @@ package de.pixart.messenger.ui.forms; import android.content.Context; +import android.support.v4.content.ContextCompat; import android.text.SpannableString; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; @@ -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(ContextCompat.getColor(context, R.color.accent)), start, end, 0); } return spannableString; } |