Browse Source

UI fixes for topics activity

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

26
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.os.Handler;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar; 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.AlertDialog;
import android.support.v7.app.AppCompatDelegate; import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -62,7 +67,7 @@ import static gr.thmmy.mthmmy.services.NotificationService.NEW_POST_TAG;
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFocusChangeListener, public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFocusChangeListener,
EmojiKeyboard.EmojiKeyboardOwner{ EmojiKeyboard.EmojiKeyboardOwner {
//Activity's variables //Activity's variables
/** /**
* The key to use when putting topic's url String to {@link TopicActivity}'s Bundle. * 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 // no page has been loaded yet. Give user the ability to refresh
recyclerView.setVisibility(View.GONE); recyclerView.setVisibility(View.GONE);
TextView errorTextview = findViewById(R.id.error_textview); 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.setVisibility(View.VISIBLE);
errorTextview.setOnClickListener(view -> { errorTextview.setOnClickListener(view -> {
viewModel.reloadPage(); viewModel.reloadPage();
@ -671,6 +684,15 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
Timber.w("Requested topic was unauthorized"); Timber.w("Requested topic was unauthorized");
recyclerView.setVisibility(View.GONE); recyclerView.setVisibility(View.GONE);
TextView errorTextview = findViewById(R.id.error_textview); 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.setText(getString(R.string.unauthorized_topic_error));
errorTextview.setVisibility(View.VISIBLE); errorTextview.setVisibility(View.VISIBLE);
break; break;

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

@ -5,13 +5,13 @@
android:id="@+id/main_content" android:id="@+id/main_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="@color/background" android:background="@color/background"
android:fitsSystemWindows="true"
tools:context=".activities.topic.TopicActivity"> tools:context=".activities.topic.TopicActivity">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" > android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:id="@+id/appbar" android:id="@+id/appbar"
@ -32,6 +32,7 @@
android:id="@+id/toolbar_title" android:id="@+id/toolbar_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:textColor="@color/white" /> android:textColor="@color/white" />
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
@ -39,10 +40,11 @@
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/topic_recycler_view" android:id="@+id/topic_recycler_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="top|start"
android:layout_below="@id/appbar"
android:layout_above="@id/emoji_keyboard" android:layout_above="@id/emoji_keyboard"
android:layout_below="@id/appbar"
android:layout_gravity="top|start"
android:background="@color/background"
android:clipToPadding="false" android:clipToPadding="false"
android:paddingBottom="4dp" android:paddingBottom="4dp"
android:paddingTop="4dp" android:paddingTop="4dp"
@ -55,18 +57,20 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="240dp" android:layout_height="240dp"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:visibility="gone"/> android:visibility="gone" />
</RelativeLayout>
<TextView <TextView
android:id="@+id/error_textview" android:id="@+id/error_textview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@id/appbar"
android:layout_gravity="top|start"
android:gravity="center" android:gravity="center"
android:text="@string/network_error_retry_prompt" android:text="@string/network_error_retry_prompt"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="32sp" android:textSize="18sp"
android:visibility="gone" /> android:visibility="gone" />
</RelativeLayout>
<LinearLayout <LinearLayout
android:id="@+id/bottom_navigation_bar" android:id="@+id/bottom_navigation_bar"

2
app/src/main/res/values/strings.xml

@ -55,7 +55,7 @@
<string name="subject">Subject&#8230;</string> <string name="subject">Subject&#8230;</string>
<string name="submit">Submit</string> <string name="submit">Submit</string>
<string name="post_message">Message&#8230;</string> <string name="post_message">Message&#8230;</string>
<string name="network_error_retry_prompt">Could not connect to thmmy.gr \n\n Tap to retry</string> <string name="network_error_retry_prompt">Could not connect to thmmy.gr\n\nTap to retry</string>
<string name="generic_network_error">Network error</string> <string name="generic_network_error">Network error</string>
<string name="retry">retry</string> <string name="retry">retry</string>
<string name="unauthorized_topic_error">This topic is either missing or off limits to you</string> <string name="unauthorized_topic_error">This topic is either missing or off limits to you</string>

Loading…
Cancel
Save