From 157ca65b0a247f9be342fb1b06cbf123c4dfb0c9 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 1 Mar 2018 19:44:08 +0100 Subject: [PATCH] use text styles in more places --- .../conversations/ui/EditAccountActivity.java | 6 +-- .../siacs/conversations/ui/OmemoActivity.java | 10 ++--- .../siacs/conversations/ui/XmppActivity.java | 4 -- .../ui/adapter/MessageAdapter.java | 31 +++++++++++----- .../conversations/ui/service/AudioPlayer.java | 6 ++- src/main/res/layout/activity_edit_account.xml | 17 ++------- .../activity_publish_profile_picture.xml | 2 +- src/main/res/layout/activity_set_presence.xml | 10 ++--- src/main/res/layout/contact_key.xml | 1 - .../res/layout/dialog_verify_fingerprints.xml | 4 +- src/main/res/layout/fragment_conversation.xml | 6 +-- src/main/res/layout/list_item_tag.xml | 23 ++++++------ src/main/res/layout/message_content.xml | 8 +--- src/main/res/layout/message_date_bubble.xml | 4 +- src/main/res/layout/message_received.xml | 8 ++-- src/main/res/layout/message_sent.xml | 3 +- src/main/res/layout/message_status.xml | 4 +- src/main/res/layout/presence_template.xml | 8 ++-- src/main/res/values/attrs.xml | 1 - src/main/res/values/styles.xml | 37 ++++++++++++++++++- src/main/res/values/themes.xml | 4 -- 21 files changed, 102 insertions(+), 95 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 20eb3201a..0d40e4d47 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -965,7 +965,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat this.mPgpFingerprint.setText(OpenPgpUtils.convertKeyIdToHex(pgpKeyId)); this.mPgpFingerprint.setOnClickListener(openPgp); if ("pgp".equals(messageFingerprint)) { - this.getmPgpFingerprintDesc.setTextColor(ContextCompat.getColor(this, R.color.accent)); + this.getmPgpFingerprintDesc.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption_Highlight); } this.getmPgpFingerprintDesc.setOnClickListener(openPgp); this.mPgpDeleteFingerprintButton.setOnClickListener(delete); @@ -976,10 +976,10 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (ownAxolotlFingerprint != null && Config.supportOmemo()) { this.mAxolotlFingerprintBox.setVisibility(View.VISIBLE); if (ownAxolotlFingerprint.equals(messageFingerprint)) { - this.mOwnFingerprintDesc.setTextColor(ContextCompat.getColor(this, R.color.accent)); + this.mOwnFingerprintDesc.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption_Highlight); this.mOwnFingerprintDesc.setText(R.string.omemo_fingerprint_selected_message); } else { - this.mOwnFingerprintDesc.setTextColor(getSecondaryTextColor()); + this.mOwnFingerprintDesc.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption); this.mOwnFingerprintDesc.setText(R.string.omemo_fingerprint); } this.mAxolotlFingerprint.setText(CryptoHelper.prettifyFingerprint(ownAxolotlFingerprint.substring(2))); diff --git a/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java b/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java index dd4829784..b69f189a1 100644 --- a/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/OmemoActivity.java @@ -137,8 +137,8 @@ public abstract class OmemoActivity extends XmppActivity { binding.tglTrust.setChecked(status.isTrusted()); if (status.isActive()) { - binding.key.setTextColor(getPrimaryTextColor()); - binding.keyType.setTextColor(getSecondaryTextColor()); + binding.key.setTextAppearance(this,R.style.TextAppearance_Conversations_Fingerprint); + binding.keyType.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption); if (status.isVerified()) { binding.verifiedFingerprint.setVisibility(View.VISIBLE); binding.verifiedFingerprint.setAlpha(1.0f); @@ -164,8 +164,8 @@ public abstract class OmemoActivity extends XmppActivity { toast = v -> hideToast(); } } else { - binding.key.setTextColor(getTertiaryTextColor()); - binding.keyType.setTextColor(getTertiaryTextColor()); + binding.key.setTextAppearance(this,R.style.TextAppearance_Conversations_Fingerprint_Disabled); + binding.keyType.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption_Disabled); toast = v -> replaceToast(getString(R.string.this_device_is_no_longer_in_use), false); if (status.isVerified()) { binding.tglTrust.setVisibility(View.GONE); @@ -188,7 +188,7 @@ public abstract class OmemoActivity extends XmppActivity { binding.keyType.setVisibility(View.GONE); } if (highlight) { - binding.keyType.setTextColor(ContextCompat.getColor(this, R.color.accent)); + binding.keyType.setTextAppearance(this,R.style.TextAppearance_Conversations_Caption_Highlight); binding.keyType.setText(getString(x509 ? R.string.omemo_fingerprint_x509_selected_message : R.string.omemo_fingerprint_selected_message)); } else { binding.keyType.setText(getString(x509 ? R.string.omemo_fingerprint_x509 : R.string.omemo_fingerprint)); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index cf3db9380..32febdc00 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -778,10 +778,6 @@ public abstract class XmppActivity extends AppCompatActivity { } } - public int getTertiaryTextColor() { - return this.mTertiaryTextColor; - } - public int getSecondaryTextColor() { return this.mSecondaryTextColor; } 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 adc0703df..d2741da4b 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -288,8 +288,13 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie break; } if (error && type == SENT) { - viewHolder.time.setTextColor(activity.getWarningTextColor()); + viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_Waring); } else { + if (darkBackground) { + viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_OnDark); + } else { + viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption); + } viewHolder.time.setTextColor(this.getMessageTextColor(darkBackground, false)); } if (message.getEncryption() == Message.ENCRYPTION_NONE) { @@ -351,8 +356,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setText(text); - viewHolder.messageBody.setTextColor(getMessageTextColor(darkBackground, false)); - viewHolder.messageBody.setTypeface(null, Typeface.ITALIC); + if (darkBackground) { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Secondary_OnDark); + } else { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Secondary); + } viewHolder.messageBody.setTextIsSelectable(false); } @@ -361,10 +369,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.image.setVisibility(View.GONE); viewHolder.audioPlayer.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.VISIBLE); - viewHolder.messageBody.setText(getContext().getString( - R.string.decryption_failed)); - viewHolder.messageBody.setTextColor(getMessageTextColor(darkBackground, false)); - viewHolder.messageBody.setTypeface(null, Typeface.NORMAL); + if (darkBackground) { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Secondary_OnDark); + } else { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_Secondary); + } viewHolder.messageBody.setTextIsSelectable(false); } @@ -454,8 +463,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.audioPlayer.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.VISIBLE); - viewHolder.messageBody.setTextColor(this.getMessageTextColor(darkBackground, true)); - viewHolder.messageBody.setLinkTextColor(this.getMessageTextColor(darkBackground, true)); + if (darkBackground) { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_OnDark); + } else { + viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1); + } viewHolder.messageBody.setHighlightColor(ContextCompat.getColor(activity, darkBackground ? (type == SENT || !mUseGreenBackground ? R.color.black26 : R.color.grey800) : R.color.grey500)); viewHolder.messageBody.setTypeface(null, Typeface.NORMAL); @@ -704,7 +716,6 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.status_message.setText(DateUtils.formatDateTime(activity, message.getTimeSent(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR)); } viewHolder.message_box.setBackgroundResource(activity.isDarkTheme() ? R.drawable.date_bubble_grey : R.drawable.date_bubble_white); - viewHolder.status_message.setTextColor(activity.getSecondaryTextColor()); return view; } else if (type == STATUS) { if ("LOAD_MORE".equals(message.getBody())) { diff --git a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java index ebb904ea6..8e9d5a8d6 100644 --- a/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java +++ b/src/main/java/eu/siacs/conversations/ui/service/AudioPlayer.java @@ -56,7 +56,11 @@ public class AudioPlayer implements View.OnClickListener, MediaPlayer.OnCompleti } private boolean init(ViewHolder viewHolder, Message message) { - viewHolder.runtime.setTextColor(this.messageAdapter.getMessageTextColor(viewHolder.darkBackground, false)); + if (viewHolder.darkBackground) { + viewHolder.runtime.setTextAppearance(this.messageAdapter.getContext(), R.style.TextAppearance_Conversations_Caption_OnDark); + } else { + viewHolder.runtime.setTextAppearance(this.messageAdapter.getContext(), R.style.TextAppearance_Conversations_Caption); + } viewHolder.progress.setOnSeekBarChangeListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ColorStateList color = ContextCompat.getColorStateList(messageAdapter.getContext(), viewHolder.darkBackground ? R.color.white70 : R.color.bubble); diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml index 3f6e6a45e..9efa1cc17 100644 --- a/src/main/res/layout/activity_edit_account.xml +++ b/src/main/res/layout/activity_edit_account.xml @@ -481,18 +481,14 @@ android:id="@+id/pgp_fingerprint" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:fontFamily="monospace" - android:textColor="?attr/color_text_primary" - android:textSize="?attr/TextSizeBody" - android:typeface="monospace"/> + android:textAppearance="@style/TextAppearance.Conversations.Fingerprint"/> + android:textAppearance="@style/TextAppearance.AppCompat.Caption"/> + android:textAppearance="@style/TextAppearance.Conversations.Fingerprint"/> + android:textAppearance="@style/TextAppearance.AppCompat.Caption"/> + android:background="?attr/color_background_secondary"> + android:inputType="textMultiLine"/> + android:text="@string/all_accounts_on_this_device"/>