From 793f630096357ad83b5dc9e95d8f0fc6c2123b12 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Tue, 23 Aug 2022 08:59:48 +0300 Subject: [PATCH] feat: bookmarks ui improvements --- app/build.gradle | 2 +- .../bookmarks/BookmarksActivity.java | 13 ++- .../bookmarks/BookmarksFragment.java | 2 +- .../main/res/drawable/ic_notification_off.xml | 14 ++- .../main/res/layout/fragment_bookmarks.xml | 8 +- .../res/layout/fragment_bookmarks_row.xml | 93 +++++++++++-------- 6 files changed, 78 insertions(+), 54 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6171590a..777af2d6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,7 @@ android { minSdkVersion 21 targetSdkVersion 30 versionCode 31 - versionName "2.0.1" + versionName "2.1.0" archivesBaseName = "mTHMMY-v$versionName" buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\"" buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\"" diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java index 7fbdf746..6ce16ec0 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java @@ -89,7 +89,9 @@ public class BookmarksActivity extends BaseActivity { startActivity(intent); break; case BookmarksFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION: - return toggleNotification(bookmarkedTopic); + boolean notificationsEnabled = toggleNotification(bookmarkedTopic); + displayNotificationsToggleToast(notificationsEnabled); + return notificationsEnabled; case BookmarksFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK: removeBookmark(bookmarkedTopic); Toast.makeText(BaseApplication.getInstance().getApplicationContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); @@ -112,7 +114,9 @@ public class BookmarksActivity extends BaseActivity { startActivity(intent); break; case BookmarksFragment.INTERACTION_TOGGLE_BOARD_NOTIFICATION: - return toggleNotification(bookmarkedBoard); + boolean notificationsEnabled = toggleNotification(bookmarkedBoard); + displayNotificationsToggleToast(notificationsEnabled); + return notificationsEnabled; case BookmarksFragment.INTERACTION_REMOVE_BOARD_BOOKMARK: removeBookmark(bookmarkedBoard); Toast.makeText(getApplicationContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); @@ -123,6 +127,11 @@ public class BookmarksActivity extends BaseActivity { return true; } + private void displayNotificationsToggleToast (boolean notificationsEnabled){ + String toastText = notificationsEnabled ? "Notifications enabled" : "Notifications disabled"; + Toast.makeText(BaseApplication.getInstance().getApplicationContext(), toastText, Toast.LENGTH_SHORT).show(); + } + /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. If it becomes too memory intensive, diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java index 3b634550..3c2713d1 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java @@ -106,7 +106,7 @@ public class BookmarksFragment extends Fragment { if (bookmark != null && bookmark.getTitle() != null) { final LinearLayout row = (LinearLayout) layoutInflater.inflate( R.layout.fragment_bookmarks_row, bookmarksLinearView, false); - row.setOnClickListener(view -> { + row.findViewById(R.id.bookmark_card).setOnClickListener(view -> { Activity activity = getActivity(); if (activity instanceof BookmarksActivity) ((BookmarksActivity) activity).onFragmentRowInteractionListener(type, interactionClick, bookmark); diff --git a/app/src/main/res/drawable/ic_notification_off.xml b/app/src/main/res/drawable/ic_notification_off.xml index 1efd1289..f91fda60 100644 --- a/app/src/main/res/drawable/ic_notification_off.xml +++ b/app/src/main/res/drawable/ic_notification_off.xml @@ -1,5 +1,9 @@ - - - + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_bookmarks.xml b/app/src/main/res/layout/fragment_bookmarks.xml index e672fab8..280a9cc4 100644 --- a/app/src/main/res/layout/fragment_bookmarks.xml +++ b/app/src/main/res/layout/fragment_bookmarks.xml @@ -9,7 +9,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="top|start" - android:background="@color/primary_lighter" + android:background="@color/primary_lighter_2" android:scrollbars="none" app:layout_behavior="@string/appbar_scrolling_view_behavior"> @@ -17,10 +17,8 @@ android:id="@+id/bookmarks_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:showDividers="middle" - android:divider="?android:listDivider" - android:dividerPadding="16dp" /> + android:layout_margin="2dp" + android:orientation="vertical" /> + android:layout_height="wrap_content"> - + android:foreground="?android:attr/selectableItemBackground" + card_view:cardBackgroundColor="@color/background" + card_view:cardCornerRadius="5dp" + card_view:cardElevation="2dp" + card_view:cardPreventCornerOverlap="false" + card_view:cardUseCompatPadding="true" + android:clickable="true" + android:focusable="true"> + - + - + + + + + \ No newline at end of file