Browse Source

UI fixes for topics activity

pull/54/head
Apostolos Fanakis 6 years ago
parent
commit
b31ad5db06
  1. 24
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. 16
      app/src/main/res/layout/activity_topic.xml

24
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;
@ -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;

16
app/src/main/res/layout/activity_topic.xml

@ -5,8 +5,8 @@
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">
<RelativeLayout
@ -32,6 +32,7 @@
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:textColor="@color/white" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
@ -39,10 +40,11 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/topic_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|start"
android:layout_below="@id/appbar"
android:layout_height="match_parent"
android:layout_above="@id/emoji_keyboard"
android:layout_below="@id/appbar"
android:layout_gravity="top|start"
android:background="@color/background"
android:clipToPadding="false"
android:paddingBottom="4dp"
android:paddingTop="4dp"
@ -56,17 +58,19 @@
android:layout_height="240dp"
android:layout_alignParentBottom="true"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:id="@+id/error_textview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/appbar"
android:layout_gravity="top|start"
android:gravity="center"
android:text="@string/network_error_retry_prompt"
android:textColor="@color/white"
android:textSize="32sp"
android:textSize="18sp"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:id="@+id/bottom_navigation_bar"

Loading…
Cancel
Save