From 4b106ffba45ef33f3fead8afa4d07a805dbc7b03 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 17 Nov 2022 11:42:06 +0100 Subject: [PATCH] Fix issue #475 - Support notifications when edited --- .../fedilab/android/ui/drawer/NotificationAdapter.java | 7 +++++++ .../fragment/timeline/FragmentMastodonNotification.java | 6 +++++- .../fragment/timeline/FragmentNotificationContainer.java | 9 +++++++++ .../ui/pageadapter/FedilabNotificationPageAdapter.java | 5 ++++- app/src/main/res/layout/popup_notification_settings.xml | 7 +++++++ app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/NotificationAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/NotificationAdapter.java index f10286973..cff693854 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/NotificationAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/NotificationAdapter.java @@ -64,6 +64,7 @@ public class NotificationAdapter extends RecyclerView.Adapter 0) { @@ -676,6 +678,8 @@ public class FragmentMastodonNotification extends Fragment implements Notificati @SerializedName("FAVOURITES") FAVOURITES("FAVOURITES"), @SerializedName("REBLOGS") + UPDATES("UPDATES"), + @SerializedName("UPDATES") REBLOGS("REBLOGS"), @SerializedName("POLLS") POLLS("POLLS"), diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java index 6079fcb37..b5cc921c8 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java @@ -76,6 +76,7 @@ public class FragmentNotificationContainer extends Fragment { binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_poll_24)); binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_home_24)); binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_person_add_alt_1_24)); + binding.tabLayout.addTab(binding.tabLayout.newTab().setIcon(R.drawable.ic_baseline_edit_24)); binding.viewpagerNotificationContainer.setAdapter(new FedilabNotificationPageAdapter(getChildFragmentManager(), true)); } AtomicBoolean changes = new AtomicBoolean(false); @@ -90,6 +91,7 @@ public class FragmentNotificationContainer extends Fragment { ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayPollResults); ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayUpdatesFromPeople); ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayFollows); + ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayUpdates); DrawableCompat.setTintList(DrawableCompat.wrap(dialogView.displayAllCategories.getThumbDrawable()), ThemeHelper.getSwitchCompatThumbDrawable(requireActivity())); DrawableCompat.setTintList(DrawableCompat.wrap(dialogView.displayAllCategories.getTrackDrawable()), ThemeHelper.getSwitchCompatTrackDrawable(requireActivity())); @@ -125,6 +127,7 @@ public class FragmentNotificationContainer extends Fragment { dialogView.displayPollResults.setChecked(true); dialogView.displayUpdatesFromPeople.setChecked(true); dialogView.displayFollows.setChecked(true); + dialogView.displayUpdates.setChecked(true); String excludedCategories = sharedpreferences.getString(getString(R.string.SET_EXCLUDED_NOTIFICATIONS_TYPE) + BaseMainActivity.currentUserID + BaseMainActivity.currentInstance, null); List excludedCategoriesList = new ArrayList<>(); if (excludedCategories != null) { @@ -155,6 +158,10 @@ public class FragmentNotificationContainer extends Fragment { excludedCategoriesList.add("follow"); dialogView.displayFollows.setChecked(false); break; + case "update": + excludedCategoriesList.add("update"); + dialogView.displayUpdates.setChecked(false); + break; } } } @@ -173,6 +180,8 @@ public class FragmentNotificationContainer extends Fragment { notificationType = "status"; } else if (checkedId == R.id.display_follows) { notificationType = "follow"; + } else if (checkedId == R.id.display_updates) { + notificationType = "update"; } if (isChecked) { excludedCategoriesList.remove(notificationType); diff --git a/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabNotificationPageAdapter.java b/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabNotificationPageAdapter.java index eaff1b3b8..edd50f9c1 100644 --- a/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabNotificationPageAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/pageadapter/FedilabNotificationPageAdapter.java @@ -83,6 +83,9 @@ public class FedilabNotificationPageAdapter extends FragmentStatePagerAdapter { case 6: bundle.putSerializable(Helper.ARG_NOTIFICATION_TYPE, FragmentMastodonNotification.NotificationTypeEnum.FOLLOWS); break; + case 7: + bundle.putSerializable(Helper.ARG_NOTIFICATION_TYPE, FragmentMastodonNotification.NotificationTypeEnum.UPDATES); + break; } } fragmentMastodonNotification.setArguments(bundle); @@ -91,6 +94,6 @@ public class FedilabNotificationPageAdapter extends FragmentStatePagerAdapter { @Override public int getCount() { - return extended ? 7 : 2; + return extended ? 8 : 2; } } \ No newline at end of file diff --git a/app/src/main/res/layout/popup_notification_settings.xml b/app/src/main/res/layout/popup_notification_settings.xml index aee425626..330dcdfa5 100644 --- a/app/src/main/res/layout/popup_notification_settings.xml +++ b/app/src/main/res/layout/popup_notification_settings.xml @@ -102,6 +102,13 @@ android:text="@string/notif_display_follows" app:icon="@drawable/ic_baseline_person_add_alt_1_24" /> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7c2bb9ff2..87dbfe94b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1987,4 +1987,6 @@ Profiles Your instance does not seem to support that feature! Watch trends for this instance + Edited a message + Updates