From bf7d50692c05d653732f5f002309c7c5718f9656 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 8 Apr 2019 16:32:10 +0200 Subject: [PATCH] use styled warning for message error. fixes #3428 --- .../ui/ConversationsOverviewFragment.java | 4 ++-- .../ui/PublishProfilePictureActivity.java | 6 +++--- .../eu/siacs/conversations/ui/XmppActivity.java | 14 -------------- .../conversations/ui/adapter/MessageAdapter.java | 6 +++++- src/main/res/values/styles.xml | 10 +++++++++- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java index 5312f8212..829785073 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java @@ -196,7 +196,7 @@ public class ConversationsOverviewFragment extends XmppFragment { public static Conversation getSuggestion(Activity activity) { final Conversation exception; Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment); - if (fragment != null && fragment instanceof ConversationsOverviewFragment) { + if (fragment instanceof ConversationsOverviewFragment) { exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek(); } else { exception = null; @@ -206,7 +206,7 @@ public class ConversationsOverviewFragment extends XmppFragment { public static Conversation getSuggestion(Activity activity, Conversation exception) { Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment); - if (fragment != null && fragment instanceof ConversationsOverviewFragment) { + if (fragment instanceof ConversationsOverviewFragment) { List conversations = ((ConversationsOverviewFragment) fragment).conversations; if (conversations.size() > 0) { Conversation suggestion = conversations.get(0); diff --git a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java index d818cdf7e..e46c4c40d 100644 --- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java @@ -68,7 +68,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC public void onAvatarPublicationFailed(int res) { runOnUiThread(() -> { hintOrWarning.setText(res); - hintOrWarning.setTextColor(getWarningTextColor()); + hintOrWarning.setTextAppearance(this,R.style.TextAppearance_Conversations_Body1_Warning); hintOrWarning.setVisibility(View.VISIBLE); publishing = false; togglePublishButton(true, R.string.publish); @@ -208,7 +208,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC if (bm == null) { togglePublishButton(false, R.string.publish); this.hintOrWarning.setVisibility(View.VISIBLE); - this.hintOrWarning.setTextColor(getWarningTextColor()); + this.hintOrWarning.setTextAppearance(this,R.style.TextAppearance_Conversations_Body1_Warning); this.hintOrWarning.setText(R.string.error_publish_avatar_converting); return; } @@ -219,7 +219,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC } else { togglePublishButton(false, R.string.publish); this.hintOrWarning.setVisibility(View.VISIBLE); - this.hintOrWarning.setTextColor(getWarningTextColor()); + this.hintOrWarning.setTextAppearance(this,R.style.TextAppearance_Conversations_Body1_Warning); if (account.getStatus() == Account.State.ONLINE) { this.hintOrWarning.setText(R.string.error_publish_avatar_no_server_support); } else { diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 50adb41d8..87c417697 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -92,8 +92,6 @@ public abstract class XmppActivity extends ActionBarActivity { public XmppConnectionService xmppConnectionService; public boolean xmppConnectionServiceBound = false; - protected int mColorRed; - protected static final String FRAGMENT_TAG_DIALOG = "dialog"; private boolean isCameraFeatureAvailable = false; @@ -400,9 +398,6 @@ public abstract class XmppActivity extends ActionBarActivity { ExceptionHelper.init(getApplicationContext()); new EmojiService(this).init(); this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); - - mColorRed = ContextCompat.getColor(this, R.color.red800); - this.mTheme = findTheme(); setTheme(this.mTheme); @@ -767,15 +762,6 @@ public abstract class XmppActivity extends ActionBarActivity { } } - public int getWarningTextColor() { - return this.mColorRed; - } - - public int getPixel(int dp) { - DisplayMetrics metrics = getResources().getDisplayMetrics(); - return ((int) (dp * metrics.density)); - } - public boolean copyTextToClipboard(String text, int labelResId) { ClipboardManager mClipBoardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); String label = getResources().getString(labelResId); 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 54f376650..077e1b8bc 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -242,7 +242,11 @@ public class MessageAdapter extends ArrayAdapter implements CopyTextVie break; } if (error && type == SENT) { - viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_Warning); + if (darkBackground) { + viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_Warning_OnDark); + } else { + viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_Warning); + } } else { if (darkBackground) { viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_OnDark); diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml index 8ae7d8aae..432f256c0 100644 --- a/src/main/res/values/styles.xml +++ b/src/main/res/values/styles.xml @@ -31,6 +31,10 @@ ?android:textColorPrimary + + @@ -112,7 +116,11 @@ + +