Fix issue #475 - Support notifications when edited

This commit is contained in:
Thomas 2022-11-17 11:42:06 +01:00
parent 2593d08d20
commit 4b106ffba4
6 changed files with 34 additions and 2 deletions

View File

@ -64,6 +64,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private final int TYPE_POLL = 5;
private final int TYPE_STATUS = 6;
private final int TYPE_REACTION = 8;
private final int TYPE_UPDATE = 9;
public FetchMoreCallBack fetchMoreCallBack;
private Context context;
@ -92,6 +93,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
return TYPE_MENTION;
case "reblog":
return TYPE_REBLOG;
case "update":
return TYPE_UPDATE;
case "favourite":
return TYPE_FAVOURITE;
case "poll":
@ -227,6 +230,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_star_24);
} else if (getItemViewType(position) == TYPE_REBLOG) {
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_repeat_24);
} else if (getItemViewType(position) == TYPE_UPDATE) {
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_edit_24);
} else if (getItemViewType(position) == TYPE_REACTION) {
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_insert_emoticon_24);
} else if (getItemViewType(position) == TYPE_POLL) {
@ -292,6 +297,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_favourite));
} else if (getItemViewType(position) == TYPE_REBLOG) {
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_reblog));
} else if (getItemViewType(position) == TYPE_UPDATE) {
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_update));
} else if (getItemViewType(position) == TYPE_POLL) {
title = context.getString(R.string.notif_poll);
}

View File

@ -230,6 +230,8 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
excludeType.remove("reblog");
} else if (notificationType == NotificationTypeEnum.POLLS) {
excludeType.remove("poll");
} else if (notificationType == NotificationTypeEnum.UPDATES) {
excludeType.remove("update");
} else if (notificationType == NotificationTypeEnum.TOOTS) {
excludeType.remove("status");
} else if (notificationType == NotificationTypeEnum.FOLLOWS) {
@ -477,7 +479,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
if (i != refPosition) {
//Loop through notifications, only fav and boost will be aggregated if they are just bellow
if (notifications.get(i).type != null && notifications.get(refPosition).type != null && notifications.get(i).type.equals(notifications.get(refPosition).type)
&& (notifications.get(i).type.equals("favourite") || notifications.get(i).type.equals("reblog"))
&& (notifications.get(i).type.equals("favourite") || notifications.get(i).type.equals("reblog") || notifications.get(i).type.equals("update"))
&& notifications.get(i).status != null && notifications.get(refPosition).status != null && notifications.get(i).status.id.equals(notifications.get(refPosition).status.id)
) {
if (notificationList.size() > 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"),

View File

@ -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<String> 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);

View File

@ -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;
}
}

View File

@ -102,6 +102,13 @@
android:text="@string/notif_display_follows"
app:icon="@drawable/ic_baseline_person_add_alt_1_24" />
<com.google.android.material.button.MaterialButton
android:id="@+id/display_updates"
style="@style/Widget.App.Button.IconOnly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/notif_display_updates"
app:icon="@drawable/ic_baseline_edit_24" />
</com.google.android.material.button.MaterialButtonToggleGroup>

View File

@ -1987,4 +1987,6 @@
<string name="profiles">Profiles</string>
<string name="toast_feature_not_supported">Your instance does not seem to support that feature!</string>
<string name="watch_trends_for_instance">Watch trends for this instance</string>
<string name="notif_update">Edited a message</string>
<string name="notif_display_updates">Updates</string>
</resources>