Browse Source

feat: bookmarks ui improvements

develop
Ezerous 2 years ago
parent
commit
793f630096
  1. 2
      app/build.gradle
  2. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java
  3. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java
  4. 12
      app/src/main/res/drawable/ic_notification_off.xml
  5. 8
      app/src/main/res/layout/fragment_bookmarks.xml
  6. 23
      app/src/main/res/layout/fragment_bookmarks_row.xml

2
app/build.gradle

@ -15,7 +15,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 30
versionCode 31 versionCode 31
versionName "2.0.1" versionName "2.1.0"
archivesBaseName = "mTHMMY-v$versionName" archivesBaseName = "mTHMMY-v$versionName"
buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\"" buildConfigField "String", "CURRENT_BRANCH", "\"" + getCurrentBranch() + "\""
buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\"" buildConfigField "String", "COMMIT_HASH", "\"" + getCommitHash() + "\""

13
app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java

@ -89,7 +89,9 @@ public class BookmarksActivity extends BaseActivity {
startActivity(intent); startActivity(intent);
break; break;
case BookmarksFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION: case BookmarksFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION:
return toggleNotification(bookmarkedTopic); boolean notificationsEnabled = toggleNotification(bookmarkedTopic);
displayNotificationsToggleToast(notificationsEnabled);
return notificationsEnabled;
case BookmarksFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK: case BookmarksFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK:
removeBookmark(bookmarkedTopic); removeBookmark(bookmarkedTopic);
Toast.makeText(BaseApplication.getInstance().getApplicationContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); Toast.makeText(BaseApplication.getInstance().getApplicationContext(), "Bookmark removed", Toast.LENGTH_SHORT).show();
@ -112,7 +114,9 @@ public class BookmarksActivity extends BaseActivity {
startActivity(intent); startActivity(intent);
break; break;
case BookmarksFragment.INTERACTION_TOGGLE_BOARD_NOTIFICATION: case BookmarksFragment.INTERACTION_TOGGLE_BOARD_NOTIFICATION:
return toggleNotification(bookmarkedBoard); boolean notificationsEnabled = toggleNotification(bookmarkedBoard);
displayNotificationsToggleToast(notificationsEnabled);
return notificationsEnabled;
case BookmarksFragment.INTERACTION_REMOVE_BOARD_BOOKMARK: case BookmarksFragment.INTERACTION_REMOVE_BOARD_BOOKMARK:
removeBookmark(bookmarkedBoard); removeBookmark(bookmarkedBoard);
Toast.makeText(getApplicationContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); Toast.makeText(getApplicationContext(), "Bookmark removed", Toast.LENGTH_SHORT).show();
@ -123,6 +127,11 @@ public class BookmarksActivity extends BaseActivity {
return true; 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 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages. If it becomes too memory intensive, * one of the sections/tabs/pages. If it becomes too memory intensive,

2
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) { if (bookmark != null && bookmark.getTitle() != null) {
final LinearLayout row = (LinearLayout) layoutInflater.inflate( final LinearLayout row = (LinearLayout) layoutInflater.inflate(
R.layout.fragment_bookmarks_row, bookmarksLinearView, false); R.layout.fragment_bookmarks_row, bookmarksLinearView, false);
row.setOnClickListener(view -> { row.findViewById(R.id.bookmark_card).setOnClickListener(view -> {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity instanceof BookmarksActivity) if (activity instanceof BookmarksActivity)
((BookmarksActivity) activity).onFragmentRowInteractionListener(type, interactionClick, bookmark); ((BookmarksActivity) activity).onFragmentRowInteractionListener(type, interactionClick, bookmark);

12
app/src/main/res/drawable/ic_notification_off.xml

@ -1,5 +1,9 @@
<vector android:height="24dp" android:tint="#26A69A" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:height="24dp"
<path android:fillColor="@android:color/white" android:pathData="M20,18.69L7.84,6.14 5.27,3.49 4,4.76l2.8,2.8v0.01c-0.52,0.99 -0.8,2.16 -0.8,3.42v5l-2,2v1h13.73l2,2L21,19.72l-1,-1.03zM12,22c1.11,0 2,-0.89 2,-2h-4c0,1.11 0.89,2 2,2zM18,14.68L18,11c0,-3.08 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68c-0.15,0.03 -0.29,0.08 -0.42,0.12 -0.1,0.03 -0.2,0.07 -0.3,0.11h-0.01c-0.01,0 -0.01,0 -0.02,0.01 -0.23,0.09 -0.46,0.2 -0.68,0.31 0,0 -0.01,0 -0.01,0.01L18,14.68z"/> android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#26A69A"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.9,2 2,2zM18,16v-5c0,-3.07 -1.63,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.64,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2zM16,17L8,17v-6c0,-2.48 1.51,-4.5 4,-4.5s4,2.02 4,4.5v6z" />
</vector> </vector>

8
app/src/main/res/layout/fragment_bookmarks.xml

@ -9,7 +9,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="top|start" android:layout_gravity="top|start"
android:background="@color/primary_lighter" android:background="@color/primary_lighter_2"
android:scrollbars="none" android:scrollbars="none"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
@ -17,10 +17,8 @@
android:id="@+id/bookmarks_container" android:id="@+id/bookmarks_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:layout_margin="2dp"
android:showDividers="middle" android:orientation="vertical" />
android:divider="?android:listDivider"
android:dividerPadding="16dp" />
</androidx.core.widget.NestedScrollView> </androidx.core.widget.NestedScrollView>
<TextView <TextView

23
app/src/main/res/layout/fragment_bookmarks_row.xml

@ -1,12 +1,24 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/bookmark_row" android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/bookmark_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" 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:clickable="true"
android:focusable="true" android:focusable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
@ -41,9 +53,10 @@
android:paddingBottom="3dp" android:paddingBottom="3dp"
android:paddingTop="3dp" android:paddingTop="3dp"
android:paddingStart="6dp" android:paddingStart="6dp"
android:paddingEnd="6dp" android:paddingEnd="12dp"
android:layout_marginEnd="12dp"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:contentDescription="@string/remove_bookmark" android:contentDescription="@string/remove_bookmark"
app:srcCompat="@drawable/ic_delete_accent_24dp" /> app:srcCompat="@drawable/ic_delete_accent_24dp" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
Loading…
Cancel
Save