Browse Source

Fixed link handling and navBar buttons crashing the ap, added ripple effect to all clickable items.

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
8d45d91aff
  1. 16
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. 5
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  3. 2
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  4. 124
      app/src/main/res/layout/activity_board_sub_board.xml
  5. 124
      app/src/main/res/layout/activity_board_topic.xml
  6. 93
      app/src/main/res/layout/activity_downloads_row.xml
  7. 4
      app/src/main/res/layout/activity_topic.xml
  8. 90
      app/src/main/res/layout/fragment_latest_posts_row.xml
  9. 2
      app/src/main/res/values/styles.xml

16
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -326,11 +326,11 @@ public class TopicActivity extends BaseActivity {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
} else if (event.getAction() == MotionEvent.ACTION_UP && autoIncrement) {
} else if (rect != null && event.getAction() == MotionEvent.ACTION_UP && autoIncrement) {
autoIncrement = false;
paginationEnabled(true);
changePage(pageRequestValue - 1);
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
} else if (rect != null && event.getAction() == MotionEvent.ACTION_MOVE) {
if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) {
autoIncrement = false;
decrementPageRequestValue(pageRequestValue - thisPage);
@ -446,7 +446,7 @@ public class TopicActivity extends BaseActivity {
protected Integer doInBackground(String... strings) {
Document document;
base_url = strings[0].substring(0, strings[0].lastIndexOf(".")); //This topic's base url
base_url = strings[0].substring(0, strings[0].lastIndexOf(".")); //New topic's base url
String newPageUrl = strings[0];
//Finds the index of message focus if present
@ -456,7 +456,7 @@ public class TopicActivity extends BaseActivity {
String tmp = newPageUrl.substring(newPageUrl.indexOf("msg") + 3);
if (tmp.contains(";"))
postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf(";")));
else
else if (tmp.contains("#"))
postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf("#")));
}
}
@ -477,8 +477,7 @@ public class TopicActivity extends BaseActivity {
}
}
}
if (Objects.equals(loadedPageUrl.substring(base_url.length())
, newPageUrl.substring(base_url.length())))
if (Integer.parseInt(newPageUrl.substring(base_url.length() + 1)) / 15 + 1 == thisPage)
return SAME_PAGE;
} else topicTitle = null;
@ -531,6 +530,11 @@ public class TopicActivity extends BaseActivity {
Toast.makeText(getBaseContext(), "Network Error", Toast.LENGTH_SHORT).show();
break;
case SAME_PAGE:
progressBar.setVisibility(ProgressBar.INVISIBLE);
topicAdapter.customNotifyDataSetChanged(new TopicTask());
if (replyFAB.getVisibility() != View.GONE) replyFAB.setEnabled(true);
paginationEnabled(true);
Toast.makeText(TopicActivity.this, "That's the same page.", Toast.LENGTH_SHORT).show();
//TODO change focus
break;
default:

5
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -556,7 +556,7 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
if (target.is(ThmmyPage.PageCategory.TOPIC)) {
//This url points to a topic
//Checks if this is the current topic
if (Objects.equals(uriString.substring(0, uriString.lastIndexOf(".")), base_url)) {
/*if (Objects.equals(uriString.substring(0, uriString.lastIndexOf(".")), base_url)) {
//Gets uri's targeted message's index number
String msgIndexReq = uriString.substring(uriString.indexOf("msg") + 3);
if (msgIndexReq.contains("#"))
@ -571,7 +571,8 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
return true;
}
}
}
}*/
topicTask.execute(uri.toString());
return true;
} else if (target.is(ThmmyPage.PageCategory.BOARD)) {

2
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -515,7 +515,7 @@ public abstract class BaseActivity extends AppCompatActivity {
}
private boolean matchExists(Bookmark bookmark, ArrayList<Bookmark> array) {
if (!array.isEmpty()) {
if (array != null && !array.isEmpty()) {
for (Bookmark b : array) {
if (b != null) {
return Objects.equals(b.getId(), bookmark.getId())

124
app/src/main/res/layout/activity_board_sub_board.xml

@ -1,79 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/child_board_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/card_background"
android:clickable="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
android:orientation="vertical">
<LinearLayout
android:id="@+id/child_board_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView
android:id="@+id/child_board_title"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/child_board_title"
android:textColor="@color/accent"
android:textSize="22sp"/>
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageButton
android:id="@+id/child_board_expand_collapse_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/card_background"
android:contentDescription="@string/child_board_button"
android:src="@drawable/ic_arrow_drop_down"/>
</LinearLayout>
<TextView
android:id="@+id/child_board_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/child_board_title"
android:textColor="@color/accent"
android:textSize="22sp"/>
<LinearLayout
android:id="@+id/child_board_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:orientation="vertical"
android:visibility="gone">
<ImageButton
android:id="@+id/child_board_expand_collapse_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/child_board_button"
android:src="@drawable/ic_arrow_drop_down"/>
</LinearLayout>
<TextView
android:id="@+id/child_board_mods"
<LinearLayout
android:id="@+id/child_board_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/child_board_mods"
android:textColor="@color/secondary_text"
android:textSize="12sp"
android:textStyle="italic"/>
android:layout_marginBottom="5dp"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/child_board_stats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/child_board_stats"
android:textColor="@color/secondary_text"
android:textSize="12sp"/>
<TextView
android:id="@+id/child_board_mods"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/child_board_mods"
android:textColor="@color/secondary_text"
android:textSize="12sp"
android:textStyle="italic"/>
<TextView
android:id="@+id/child_board_last_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:text="@string/child_board_last_post"
android:textColor="@color/primary_text"
android:textSize="12sp"/>
<TextView
android:id="@+id/child_board_stats"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/child_board_stats"
android:textColor="@color/secondary_text"
android:textSize="12sp"/>
<TextView
android:id="@+id/child_board_last_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:text="@string/child_board_last_post"
android:textColor="@color/primary_text"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

124
app/src/main/res/layout/activity_board_topic.xml

@ -1,77 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topic_row_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
android:orientation="vertical">
<LinearLayout
android:id="@+id/topic_row_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView
android:id="@+id/topic_subject"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/topic_subject"
android:textColor="@color/primary_text"
android:textSize="18sp"/>
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageButton
android:id="@+id/topic_expand_collapse_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/background"
android:contentDescription="@string/child_board_button"
android:src="@drawable/ic_arrow_drop_down"/>
</LinearLayout>
<TextView
android:id="@+id/topic_subject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/topic_subject"
android:textColor="@color/primary_text"
android:textSize="18sp"/>
<LinearLayout
android:id="@+id/topic_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:orientation="vertical"
android:visibility="gone">
<ImageButton
android:id="@+id/topic_expand_collapse_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/child_board_button"
android:src="@drawable/ic_arrow_drop_down"/>
</LinearLayout>
<TextView
android:id="@+id/topic_started_by"
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/topic_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/topic_started_by"
android:textColor="@color/secondary_text"
android:textSize="12sp"/>
android:layout_marginBottom="5dp"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/topic_stats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/topic_stats"
android:textColor="@color/secondary_text"
android:textSize="12sp"/>
<TextView
android:id="@+id/topic_started_by"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/topic_started_by"
android:textColor="@color/secondary_text"
android:textSize="12sp"/>
<TextView
android:id="@+id/topic_last_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:text="@string/topic_last_post"
android:textColor="@color/primary_text"
android:textSize="12sp"/>
<TextView
android:id="@+id/topic_stats"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:text="@string/topic_stats"
android:textColor="@color/secondary_text"
android:textSize="12sp"/>
<TextView
android:id="@+id/topic_last_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
android:clickable="true"
android:text="@string/topic_last_post"
android:textColor="@color/primary_text"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

93
app/src/main/res/layout/activity_downloads_row.xml

@ -5,61 +5,70 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/card_background"
android:orientation="vertical"
android:paddingEnd="16dp"
android:paddingStart="16dp">
android:orientation="vertical">
<LinearLayout
android:id="@+id/download_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:paddingEnd="16dp"
android:paddingStart="16dp">
<TextView
android:id="@+id/download_title"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:textColor="@color/accent"
android:textSize="18sp"/>
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageButton
android:id="@+id/download_information_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/card_background"
android:contentDescription="@string/child_board_button"
android:src="@drawable/ic_arrow_drop_down"/>
</LinearLayout>
<TextView
android:id="@+id/download_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginTop="2dp"
android:layout_weight="1"
android:textColor="@color/accent"
android:textSize="18sp"/>
<LinearLayout
android:id="@+id/child_board_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:orientation="vertical"
android:visibility="gone">
<ImageButton
android:id="@+id/download_information_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/child_board_button"
android:src="@drawable/ic_arrow_drop_down"/>
</LinearLayout>
<TextView
android:id="@+id/download_sub_title"
<LinearLayout
android:id="@+id/child_board_expandable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text"/>
android:layout_marginBottom="5dp"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/download_extra_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text"/>
<TextView
android:id="@+id/download_sub_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text"/>
<TextView
android:id="@+id/download_uploader_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text"/>
<TextView
android:id="@+id/download_extra_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text"/>
<TextView
android:id="@+id/download_uploader_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/secondary_text"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

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

@ -60,6 +60,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/button_first"
app:srcCompat="@drawable/page_first"/>
@ -68,6 +69,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/button_previous"
app:srcCompat="@drawable/page_previous"/>
@ -88,6 +90,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/button_next"
app:srcCompat="@drawable/page_next"/>
@ -96,6 +99,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/button_last"
app:srcCompat="@drawable/page_last"/>
</LinearLayout>

90
app/src/main/res/layout/fragment_latest_posts_row.xml

@ -1,55 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/latest_posts_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/card_background"
android:clickable="true"
android:foreground="?android:attr/selectableItemBackground"
android:paddingBottom="6dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="6dp">
android:background="@color/card_background">
<TextView
android:id="@+id/title"
<RelativeLayout
android:id="@+id/latest_posts_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/primary_text"/>
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingBottom="6dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="6dp">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/title"
android:textColor="@color/secondary_text"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:textAppearance="?attr/textAppearanceListItem"
android:textColor="@color/primary_text"/>
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/title"
android:textColor="@color/secondary_text"/>
<View
android:id="@+id/spacer_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/date"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:background="@color/divider"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/spacer_divider">
<View
android:id="@+id/spacer_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/date"
android:layout_marginBottom="3dp"
android:layout_marginTop="3dp"
android:background="@color/divider"/>
<WebView
android:id="@+id/post"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/card_background"
android:text="@string/post"/>
</FrameLayout>
</RelativeLayout>
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/spacer_divider">
<WebView
android:id="@+id/post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/card_background"
android:text="@string/post"/>
</FrameLayout>
</RelativeLayout>
</FrameLayout>

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

@ -42,6 +42,4 @@
<item name="android:textColorPrimary">@color/primary_text</item>
<item name="android:colorBackground">@color/dialog_bg_semi_transparent</item>
</style>
</resources>

Loading…
Cancel
Save