From b31ad5db0644f08454f7ad1f1cc992a948796d9e Mon Sep 17 00:00:00 2001 From: Apostolof Date: Mon, 10 Sep 2018 20:36:21 +0300 Subject: [PATCH] UI fixes for topics activity --- .../activities/topic/TopicActivity.java | 26 ++++++++++++-- app/src/main/res/layout/activity_topic.xml | 36 ++++++++++--------- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 84f35817..953f7ad8 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -12,12 +12,17 @@ import android.os.Bundle; import android.os.Handler; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; +import android.support.v4.content.ContextCompat; +import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatDelegate; import android.support.v7.widget.RecyclerView; +import android.text.Spannable; +import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.method.LinkMovementMethod; +import android.text.style.ForegroundColorSpan; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -62,7 +67,7 @@ import static gr.thmmy.mthmmy.services.NotificationService.NEW_POST_TAG; */ @SuppressWarnings("unchecked") public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFocusChangeListener, - EmojiKeyboard.EmojiKeyboardOwner{ + EmojiKeyboard.EmojiKeyboardOwner { //Activity's variables /** * The key to use when putting topic's url String to {@link TopicActivity}'s Bundle. @@ -651,7 +656,15 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo // no page has been loaded yet. Give user the ability to refresh recyclerView.setVisibility(View.GONE); TextView errorTextview = findViewById(R.id.error_textview); - errorTextview.setText(getString(R.string.network_error_retry_prompt)); + + Spannable errorText = new SpannableString(getString(R.string.network_error_retry_prompt)); + errorText.setSpan( + new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.accent, null)), + errorText.toString().indexOf("Tap to retry"), + errorText.length(), + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + + errorTextview.setText(errorText); errorTextview.setVisibility(View.VISIBLE); errorTextview.setOnClickListener(view -> { viewModel.reloadPage(); @@ -671,6 +684,15 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo Timber.w("Requested topic was unauthorized"); recyclerView.setVisibility(View.GONE); TextView errorTextview = findViewById(R.id.error_textview); + + Spannable errorText = new SpannableString(getString(R.string.unauthorized_topic_error)); + errorText.setSpan( + //TODO: maybe change the color to a red in order to indicate the error nature of the message + new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.accent, null)), + 0, + errorText.length(), + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + errorTextview.setText(getString(R.string.unauthorized_topic_error)); errorTextview.setVisibility(View.VISIBLE); break; diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index 242fb44e..1ef0d0e7 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -5,13 +5,13 @@ android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" android:background="@color/background" + android:fitsSystemWindows="true" tools:context=".activities.topic.TopicActivity"> + android:layout_height="match_parent"> @@ -39,10 +40,11 @@ - + android:visibility="gone" /> - + + Subject… Submit Message… - Could not connect to thmmy.gr \n\n Tap to retry + Could not connect to thmmy.gr\n\nTap to retry Network error retry This topic is either missing or off limits to you