use styled warning for message error. fixes #3428

This commit is contained in:
Daniel Gultsch 2019-04-08 16:32:10 +02:00
parent 7ada794e6e
commit bf7d50692c
5 changed files with 19 additions and 21 deletions

View File

@ -196,7 +196,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
public static Conversation getSuggestion(Activity activity) { public static Conversation getSuggestion(Activity activity) {
final Conversation exception; final Conversation exception;
Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment); Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment != null && fragment instanceof ConversationsOverviewFragment) { if (fragment instanceof ConversationsOverviewFragment) {
exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek(); exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek();
} else { } else {
exception = null; exception = null;
@ -206,7 +206,7 @@ public class ConversationsOverviewFragment extends XmppFragment {
public static Conversation getSuggestion(Activity activity, Conversation exception) { public static Conversation getSuggestion(Activity activity, Conversation exception) {
Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment); Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment != null && fragment instanceof ConversationsOverviewFragment) { if (fragment instanceof ConversationsOverviewFragment) {
List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations; List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations;
if (conversations.size() > 0) { if (conversations.size() > 0) {
Conversation suggestion = conversations.get(0); Conversation suggestion = conversations.get(0);

View File

@ -68,7 +68,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
public void onAvatarPublicationFailed(int res) { public void onAvatarPublicationFailed(int res) {
runOnUiThread(() -> { runOnUiThread(() -> {
hintOrWarning.setText(res); hintOrWarning.setText(res);
hintOrWarning.setTextColor(getWarningTextColor()); hintOrWarning.setTextAppearance(this,R.style.TextAppearance_Conversations_Body1_Warning);
hintOrWarning.setVisibility(View.VISIBLE); hintOrWarning.setVisibility(View.VISIBLE);
publishing = false; publishing = false;
togglePublishButton(true, R.string.publish); togglePublishButton(true, R.string.publish);
@ -208,7 +208,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
if (bm == null) { if (bm == null) {
togglePublishButton(false, R.string.publish); togglePublishButton(false, R.string.publish);
this.hintOrWarning.setVisibility(View.VISIBLE); 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); this.hintOrWarning.setText(R.string.error_publish_avatar_converting);
return; return;
} }
@ -219,7 +219,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
} else { } else {
togglePublishButton(false, R.string.publish); togglePublishButton(false, R.string.publish);
this.hintOrWarning.setVisibility(View.VISIBLE); 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) { if (account.getStatus() == Account.State.ONLINE) {
this.hintOrWarning.setText(R.string.error_publish_avatar_no_server_support); this.hintOrWarning.setText(R.string.error_publish_avatar_no_server_support);
} else { } else {

View File

@ -92,8 +92,6 @@ public abstract class XmppActivity extends ActionBarActivity {
public XmppConnectionService xmppConnectionService; public XmppConnectionService xmppConnectionService;
public boolean xmppConnectionServiceBound = false; public boolean xmppConnectionServiceBound = false;
protected int mColorRed;
protected static final String FRAGMENT_TAG_DIALOG = "dialog"; protected static final String FRAGMENT_TAG_DIALOG = "dialog";
private boolean isCameraFeatureAvailable = false; private boolean isCameraFeatureAvailable = false;
@ -400,9 +398,6 @@ public abstract class XmppActivity extends ActionBarActivity {
ExceptionHelper.init(getApplicationContext()); ExceptionHelper.init(getApplicationContext());
new EmojiService(this).init(); new EmojiService(this).init();
this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); this.isCameraFeatureAvailable = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
mColorRed = ContextCompat.getColor(this, R.color.red800);
this.mTheme = findTheme(); this.mTheme = findTheme();
setTheme(this.mTheme); 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) { public boolean copyTextToClipboard(String text, int labelResId) {
ClipboardManager mClipBoardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); ClipboardManager mClipBoardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
String label = getResources().getString(labelResId); String label = getResources().getString(labelResId);

View File

@ -242,7 +242,11 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie
break; break;
} }
if (error && type == SENT) { 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 { } else {
if (darkBackground) { if (darkBackground) {
viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_OnDark); viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_OnDark);

View File

@ -31,6 +31,10 @@
<item name="android:textColorLink">?android:textColorPrimary</item> <item name="android:textColorLink">?android:textColorPrimary</item>
</style> </style>
<style name="TextAppearance.Conversations.Body1.Warning" parent="TextAppearance.AppCompat.Body1">
<item name="android:textColor">?color_warning</item>
</style>
<style name="TextAppearance.Conversations.Body1.Linkified" parent="TextAppearance.AppCompat.Body1"> <style name="TextAppearance.Conversations.Body1.Linkified" parent="TextAppearance.AppCompat.Body1">
<item name="android:textSize">?TextSizeBody1</item> <item name="android:textSize">?TextSizeBody1</item>
</style> </style>
@ -112,7 +116,11 @@
</style> </style>
<style name="TextAppearance.Conversations.Caption.Warning" parent="TextAppearance.Conversations.Caption"> <style name="TextAppearance.Conversations.Caption.Warning" parent="TextAppearance.Conversations.Caption">
<item name="android:textColor">@color/red800</item> <item name="android:textColor">@color/red_a700</item>
</style>
<style name="TextAppearance.Conversations.Caption.Warning.OnDark" parent="TextAppearance.Conversations.Caption">
<item name="android:textColor">@color/red_a100</item>
</style> </style>
<style name="TextAppearance.Conversations.Caption.Highlight" parent="TextAppearance.Conversations.Caption"> <style name="TextAppearance.Conversations.Caption.Highlight" parent="TextAppearance.Conversations.Caption">