From 34706a5e024df16027a292953606114db7e12dbe Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 1 Apr 2018 17:52:14 +0200 Subject: use text styles in more places --- .../de/pixart/messenger/services/AudioPlayer.java | 6 +- .../pixart/messenger/ui/EditAccountActivity.java | 6 +- .../java/de/pixart/messenger/ui/OmemoActivity.java | 12 +-- .../java/de/pixart/messenger/ui/XmppActivity.java | 4 - .../messenger/ui/adapter/MessageAdapter.java | 31 ++++-- src/main/res/layout/activity_edit_account.xml | 25 ++--- .../layout/activity_publish_profile_picture.xml | 4 +- src/main/res/layout/activity_set_presence.xml | 15 ++- src/main/res/layout/activity_share_locaction.xml | 29 +++-- src/main/res/layout/contact_key.xml | 1 - src/main/res/layout/dialog_show_password.xml | 2 +- src/main/res/layout/dialog_verify_fingerprints.xml | 9 +- src/main/res/layout/fragment_conversation.xml | 6 +- src/main/res/layout/list_item_tag.xml | 11 +- src/main/res/layout/message_content.xml | 119 ++++++++++----------- src/main/res/layout/message_date_bubble.xml | 3 +- src/main/res/layout/message_received.xml | 22 ++-- src/main/res/layout/message_sent.xml | 27 +++-- src/main/res/layout/message_status.xml | 24 ++--- src/main/res/layout/presence_template.xml | 28 +++-- src/main/res/values/styles.xml | 48 ++++++++- 21 files changed, 224 insertions(+), 208 deletions(-) diff --git a/src/main/java/de/pixart/messenger/services/AudioPlayer.java b/src/main/java/de/pixart/messenger/services/AudioPlayer.java index e2600c100..e6d1e7c08 100644 --- a/src/main/java/de/pixart/messenger/services/AudioPlayer.java +++ b/src/main/java/de/pixart/messenger/services/AudioPlayer.java @@ -57,7 +57,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/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 3bba088ad..b69cf637e 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -1008,7 +1008,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); @@ -1038,10 +1038,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/de/pixart/messenger/ui/OmemoActivity.java b/src/main/java/de/pixart/messenger/ui/OmemoActivity.java index b278e146c..850188a2c 100644 --- a/src/main/java/de/pixart/messenger/ui/OmemoActivity.java +++ b/src/main/java/de/pixart/messenger/ui/OmemoActivity.java @@ -3,7 +3,6 @@ package de.pixart.messenger.ui; import android.content.Intent; import android.databinding.DataBindingUtil; -import android.os.Bundle; import android.support.v4.content.ContextCompat; import android.support.v7.app.AlertDialog; import android.view.ContextMenu; @@ -11,7 +10,6 @@ import android.view.MenuItem; import android.view.View; import android.widget.CompoundButton; import android.widget.LinearLayout; -import android.widget.TextView; import android.widget.Toast; import de.pixart.messenger.Config; @@ -133,8 +131,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); @@ -160,8 +158,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); @@ -184,7 +182,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/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java index 4ae530d37..38d7086f4 100644 --- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java +++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java @@ -906,10 +906,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/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index defaffa99..436f0f219 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -304,7 +304,7 @@ 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); DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); if (file.exists()) { if (activity.xmppConnectionService.mHttpConnectionManager.getAutoAcceptFileSize() >= message.getFileParams().size) { @@ -329,6 +329,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie viewHolder.resend_button.setVisibility(View.GONE); viewHolder.time.setTextColor(this.getMessageTextColor(darkBackground, false)); } 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) { @@ -386,8 +391,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); } @@ -396,10 +404,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); } @@ -507,8 +516,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.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 ? R.color.grey800 : R.color.grey500)); viewHolder.messageBody.setTypeface(null, Typeface.NORMAL); if (message.getBody() != null) { @@ -853,7 +865,6 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie } else { viewHolder.status_message.setText(DateUtils.formatDateTime(activity, message.getTimeSent(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR)); } - viewHolder.status_message.setTextColor(activity.getSecondaryTextColor()); return view; } else if (type == STATUS) { if ("LOAD_MORE".equals(message.getBody())) { diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml index e0ef55c6e..3df1ec353 100644 --- a/src/main/res/layout/activity_edit_account.xml +++ b/src/main/res/layout/activity_edit_account.xml @@ -495,18 +495,14 @@ android:id="@+id/pgp_fingerprint" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:fontFamily="monospace" - android:textColor="@color/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" /> @@ -586,18 +578,13 @@ android:id="@+id/axolotl_fingerprint" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:fontFamily="monospace" - android:textColor="@color/black87" - android:textSize="?attr/TextSizeBody" - android:typeface="monospace" /> + android:textAppearance="@style/TextAppearance.Conversations.Fingerprint" /> + android:textAppearance="@style/TextAppearance.AppCompat.Caption" /> + android:textAppearance="@style/TextAppearance.AppCompat.Body1" + android:textColor="?attr/color_text_primary" /> diff --git a/src/main/res/layout/activity_set_presence.xml b/src/main/res/layout/activity_set_presence.xml index 1996e6fdf..8ecf792a8 100644 --- a/src/main/res/layout/activity_set_presence.xml +++ b/src/main/res/layout/activity_set_presence.xml @@ -1,5 +1,6 @@ + + android:inputType="textMultiLine" /> + android:layout_gravity="center_horizontal" /> + android:text="@string/all_accounts_on_this_device" />