From 8d45d91aff52bd8dce24c7d64654da47f718f357 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sat, 21 Jan 2017 14:03:17 +0200 Subject: [PATCH] Fixed link handling and navBar buttons crashing the ap, added ripple effect to all clickable items. --- .../activities/topic/TopicActivity.java | 16 ++- .../mthmmy/activities/topic/TopicAdapter.java | 5 +- .../gr/thmmy/mthmmy/base/BaseActivity.java | 2 +- .../res/layout/activity_board_sub_board.xml | 124 ++++++++++-------- .../main/res/layout/activity_board_topic.xml | 124 ++++++++++-------- .../res/layout/activity_downloads_row.xml | 93 +++++++------ app/src/main/res/layout/activity_topic.xml | 4 + .../res/layout/fragment_latest_posts_row.xml | 90 +++++++------ app/src/main/res/values/styles.xml | 2 - 9 files changed, 249 insertions(+), 211 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 24ccb3b7..6c670797 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 @@ -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: diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 9919719e..ceb363f5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -556,7 +556,7 @@ class TopicAdapter extends RecyclerView.Adapter { 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 { return true; } } - } + }*/ + topicTask.execute(uri.toString()); return true; } else if (target.is(ThmmyPage.PageCategory.BOARD)) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index 5086e812..1d323135 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/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 array) { - if (!array.isEmpty()) { + if (array != null && !array.isEmpty()) { for (Bookmark b : array) { if (b != null) { return Objects.equals(b.getId(), bookmark.getId()) diff --git a/app/src/main/res/layout/activity_board_sub_board.xml b/app/src/main/res/layout/activity_board_sub_board.xml index b78a9c07..3dcd5d6e 100644 --- a/app/src/main/res/layout/activity_board_sub_board.xml +++ b/app/src/main/res/layout/activity_board_sub_board.xml @@ -1,79 +1,87 @@ + android:orientation="vertical"> + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:orientation="vertical" + android:paddingLeft="16dp" + android:paddingRight="16dp"> - + android:layout_marginBottom="5dp" + android:layout_marginTop="5dp" + android:orientation="horizontal"> - - + - + + - + android:layout_marginBottom="5dp" + android:orientation="vertical" + android:visibility="gone"> - + - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_board_topic.xml b/app/src/main/res/layout/activity_board_topic.xml index a036f151..7ce361e5 100644 --- a/app/src/main/res/layout/activity_board_topic.xml +++ b/app/src/main/res/layout/activity_board_topic.xml @@ -1,77 +1,85 @@ + android:orientation="vertical"> + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:orientation="vertical" + android:paddingLeft="16dp" + android:paddingRight="16dp"> - + android:layout_marginBottom="5dp" + android:layout_marginTop="5dp" + android:orientation="horizontal"> - - + - + + - + android:layout_marginBottom="5dp" + android:orientation="vertical" + android:visibility="gone"> - + - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_downloads_row.xml b/app/src/main/res/layout/activity_downloads_row.xml index f4fd93b5..3206e64f 100644 --- a/app/src/main/res/layout/activity_downloads_row.xml +++ b/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"> + android:background="?attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:orientation="vertical" + android:paddingEnd="16dp" + android:paddingStart="16dp"> - + android:layout_marginBottom="5dp" + android:layout_marginTop="5dp" + android:orientation="horizontal"> - - + - + + - + android:layout_marginBottom="5dp" + android:orientation="vertical" + android:visibility="gone"> - + - + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index d7de516f..23b12737 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/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"/> diff --git a/app/src/main/res/layout/fragment_latest_posts_row.xml b/app/src/main/res/layout/fragment_latest_posts_row.xml index 82d5b60d..cad4d1cb 100644 --- a/app/src/main/res/layout/fragment_latest_posts_row.xml +++ b/app/src/main/res/layout/fragment_latest_posts_row.xml @@ -1,55 +1,61 @@ - + android:background="@color/card_background"> - + android:background="?android:attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:paddingBottom="6dp" + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:paddingTop="6dp"> - + + - - + - - - \ No newline at end of file + android:layout_height="match_parent" + android:layout_alignParentStart="true" + android:layout_below="@+id/spacer_divider"> + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 98df4222..3f32d79c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -42,6 +42,4 @@ @color/primary_text @color/dialog_bg_semi_transparent - -