Fix issue #534 - Allow to filter notifications for admin/moderators
This commit is contained in:
parent
0b690838bb
commit
f9b87f762b
|
@ -1528,6 +1528,18 @@ public class Helper {
|
|||
channelId = "channel_status";
|
||||
channelTitle = context.getString(R.string.channel_notif_status);
|
||||
break;
|
||||
case UPDATE:
|
||||
channelId = "channel_update";
|
||||
channelTitle = context.getString(R.string.channel_notif_update);
|
||||
break;
|
||||
case SIGN_UP:
|
||||
channelId = "channel_signup";
|
||||
channelTitle = context.getString(R.string.channel_notif_signup);
|
||||
break;
|
||||
case REPORT:
|
||||
channelId = "channel_report";
|
||||
channelTitle = context.getString(R.string.channel_notif_report);
|
||||
break;
|
||||
default:
|
||||
channelId = "channel_boost";
|
||||
channelTitle = context.getString(R.string.channel_notif_boost);
|
||||
|
@ -1989,6 +2001,9 @@ public class Helper {
|
|||
BOOST,
|
||||
FAV,
|
||||
POLL,
|
||||
UPDATE,
|
||||
SIGN_UP,
|
||||
REPORT,
|
||||
STATUS,
|
||||
BACKUP,
|
||||
STORE,
|
||||
|
|
|
@ -158,6 +158,9 @@ public class NotificationsHelper {
|
|||
boolean notif_poll = prefs.getBoolean(context.getString(R.string.SET_NOTIF_POLL), true);
|
||||
boolean notif_fav = prefs.getBoolean(context.getString(R.string.SET_NOTIF_FAVOURITE), true);
|
||||
boolean notif_status = prefs.getBoolean(context.getString(R.string.SET_NOTIF_STATUS), true);
|
||||
boolean notif_update = prefs.getBoolean(context.getString(R.string.SET_NOTIF_UPDATE), true);
|
||||
boolean notif_signup = prefs.getBoolean(context.getString(R.string.SET_NOTIF_ADMIN_SIGNUP), true);
|
||||
boolean notif_report = prefs.getBoolean(context.getString(R.string.SET_NOTIF_ADMIN_REPORT), true);
|
||||
|
||||
final String max_id = prefs.getString(context.getString(R.string.LAST_NOTIFICATION_ID) + key, null);
|
||||
|
||||
|
@ -232,18 +235,18 @@ public class NotificationsHelper {
|
|||
title = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_reblog));
|
||||
else
|
||||
title = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_reblog));
|
||||
}
|
||||
if (notification.status != null) {
|
||||
if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
|
||||
if (notification.status != null) {
|
||||
if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -254,18 +257,18 @@ public class NotificationsHelper {
|
|||
title = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_favourite));
|
||||
else
|
||||
title = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_favourite));
|
||||
}
|
||||
if (notification.status != null) {
|
||||
if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
|
||||
if (notification.status != null) {
|
||||
if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -298,21 +301,62 @@ public class NotificationsHelper {
|
|||
title = context.getString(R.string.notif_poll_self);
|
||||
else
|
||||
title = context.getString(R.string.notif_poll);
|
||||
}
|
||||
if (notification.status != null) {
|
||||
if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
|
||||
if (notification.status != null) {
|
||||
if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "update":
|
||||
notifType = Helper.NotifType.UPDATE;
|
||||
if (notif_update) {
|
||||
title = context.getString(R.string.notif_update_push);
|
||||
if (notification.status != null) {
|
||||
if (notification.status.spoiler_text != null && notification.status.spoiler_text.length() > 0) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.spoiler_text)).toString();
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content, FROM_HTML_MODE_LEGACY)).toString();
|
||||
else
|
||||
message = new SpannableString(Html.fromHtml(notification.status.content)).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "admin.sign_up":
|
||||
notifType = Helper.NotifType.SIGN_UP;
|
||||
if (notif_signup) {
|
||||
title = context.getString(R.string.notif_sign_up);
|
||||
if (notification.account.display_name != null && notification.account.display_name.length() > 0)
|
||||
message = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_signed_up));
|
||||
else
|
||||
message = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_signed_up));
|
||||
targeted_account = notification.account.id;
|
||||
}
|
||||
break;
|
||||
case "admin.report":
|
||||
notifType = Helper.NotifType.REPORT;
|
||||
if (notif_report) {
|
||||
title = context.getString(R.string.notif_report);
|
||||
if (notification.account.display_name != null && notification.account.display_name.length() > 0)
|
||||
message = String.format("%s %s", notification.account.display_name, context.getString(R.string.notif_reported));
|
||||
else
|
||||
message = String.format("@%s %s", notification.account.acct, context.getString(R.string.notif_reported));
|
||||
targeted_account = notification.account.id;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
if (message != null) {
|
||||
|
@ -321,7 +365,7 @@ public class NotificationsHelper {
|
|||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Helper.INTENT_ACTION, Helper.NOTIFICATION_INTENT);
|
||||
intent.putExtra(Helper.PREF_KEY_ID, account.user_id);
|
||||
if (targeted_account != null && notifType == Helper.NotifType.FOLLLOW)
|
||||
if (targeted_account != null)
|
||||
intent.putExtra(Helper.INTENT_TARGETED_ACCOUNT, targeted_account);
|
||||
intent.putExtra(Helper.PREF_INSTANCE, account.instance);
|
||||
notificationUrl = notification.account.avatar;
|
||||
|
|
|
@ -83,6 +83,8 @@ public class FragmentNotificationContainer extends Fragment {
|
|||
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.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_report_24));
|
||||
binding.viewpagerNotificationContainer.setAdapter(new FedilabNotificationPageAdapter(getChildFragmentManager(), true));
|
||||
}
|
||||
AtomicBoolean changes = new AtomicBoolean(false);
|
||||
|
@ -98,6 +100,8 @@ public class FragmentNotificationContainer extends Fragment {
|
|||
ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayUpdatesFromPeople);
|
||||
ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayFollows);
|
||||
ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayUpdates);
|
||||
ThemeHelper.changeButtonColor(requireActivity(), dialogView.displaySignups);
|
||||
ThemeHelper.changeButtonColor(requireActivity(), dialogView.displayReports);
|
||||
|
||||
DrawableCompat.setTintList(DrawableCompat.wrap(dialogView.displayAllCategories.getThumbDrawable()), ThemeHelper.getSwitchCompatThumbDrawable(requireActivity()));
|
||||
DrawableCompat.setTintList(DrawableCompat.wrap(dialogView.displayAllCategories.getTrackDrawable()), ThemeHelper.getSwitchCompatTrackDrawable(requireActivity()));
|
||||
|
@ -134,6 +138,8 @@ public class FragmentNotificationContainer extends Fragment {
|
|||
dialogView.displayUpdatesFromPeople.setChecked(true);
|
||||
dialogView.displayFollows.setChecked(true);
|
||||
dialogView.displayUpdates.setChecked(true);
|
||||
dialogView.displaySignups.setChecked(true);
|
||||
dialogView.displayReports.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) {
|
||||
|
@ -168,6 +174,14 @@ public class FragmentNotificationContainer extends Fragment {
|
|||
excludedCategoriesList.add("update");
|
||||
dialogView.displayUpdates.setChecked(false);
|
||||
break;
|
||||
case "admin.sign_up":
|
||||
excludedCategoriesList.add("admin.sign_up");
|
||||
dialogView.displaySignups.setChecked(false);
|
||||
break;
|
||||
case "admin.report":
|
||||
excludedCategoriesList.add("admin.report");
|
||||
dialogView.displayReports.setChecked(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,6 +202,10 @@ public class FragmentNotificationContainer extends Fragment {
|
|||
notificationType = "follow";
|
||||
} else if (checkedId == R.id.display_updates) {
|
||||
notificationType = "update";
|
||||
} else if (checkedId == R.id.display_signups) {
|
||||
notificationType = "admin.sign_up";
|
||||
} else if (checkedId == R.id.display_reports) {
|
||||
notificationType = "admin.report";
|
||||
}
|
||||
if (isChecked) {
|
||||
excludedCategoriesList.remove(notificationType);
|
||||
|
|
|
@ -86,6 +86,12 @@ public class FedilabNotificationPageAdapter extends FragmentStatePagerAdapter {
|
|||
case 7:
|
||||
bundle.putSerializable(Helper.ARG_NOTIFICATION_TYPE, FragmentMastodonNotification.NotificationTypeEnum.UPDATES);
|
||||
break;
|
||||
case 8:
|
||||
bundle.putSerializable(Helper.ARG_NOTIFICATION_TYPE, FragmentMastodonNotification.NotificationTypeEnum.ADMIN_SIGNUP);
|
||||
break;
|
||||
case 9:
|
||||
bundle.putSerializable(Helper.ARG_NOTIFICATION_TYPE, FragmentMastodonNotification.NotificationTypeEnum.ADMIN_REPORT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fragmentMastodonNotification.setArguments(bundle);
|
||||
|
@ -94,6 +100,6 @@ public class FedilabNotificationPageAdapter extends FragmentStatePagerAdapter {
|
|||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return extended ? 8 : 2;
|
||||
return extended ? 10 : 2;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M15.73,3L8.27,3L3,8.27v7.46L8.27,21h7.46L21,15.73L21,8.27L15.73,3zM12,17.3c-0.72,0 -1.3,-0.58 -1.3,-1.3 0,-0.72 0.58,-1.3 1.3,-1.3 0.72,0 1.3,0.58 1.3,1.3 0,0.72 -0.58,1.3 -1.3,1.3zM13,13h-2L11,7h2v6z" />
|
||||
</vector>
|
|
@ -109,6 +109,22 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/notif_display_updates"
|
||||
app:icon="@drawable/ic_baseline_edit_24" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/display_signups"
|
||||
style="@style/Widget.App.Button.IconOnly"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/sign_ups"
|
||||
app:icon="@drawable/ic_baseline_person_add_alt_1_24" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/display_reports"
|
||||
style="@style/Widget.App.Button.IconOnly"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reports"
|
||||
app:icon="@drawable/ic_baseline_report_24" />
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
|
||||
|
|
|
@ -320,6 +320,9 @@
|
|||
<string name="channel_notif_poll">Poll Ended</string>
|
||||
<string name="channel_notif_backup">Messages Backup</string>
|
||||
<string name="channel_notif_status">New posts</string>
|
||||
<string name="channel_notif_update">New update</string>
|
||||
<string name="channel_notif_signup">New sign-up</string>
|
||||
<string name="channel_notif_report">New report</string>
|
||||
<string name="channel_notif_media">Media Download</string>
|
||||
<string name="select_sound">Select Tone</string>
|
||||
<string name="set_enable_time_slot">Enable time slot</string>
|
||||
|
@ -404,6 +407,9 @@
|
|||
<string name="vote">Vote</string>
|
||||
<string name="notif_poll">A poll you have voted in has ended</string>
|
||||
<string name="notif_poll_self">A poll you published has ended</string>
|
||||
<string name="notif_update_push">A message you shared has been edited</string>
|
||||
<string name="notif_sign_up">A user signed-up</string>
|
||||
<string name="notif_report">A user sent a report</string>
|
||||
<string name="settings_category_notif_categories">Categories</string>
|
||||
<string name="move_timeline">Move timeline</string>
|
||||
<string name="hide_timeline">Hide timeline</string>
|
||||
|
@ -449,7 +455,8 @@
|
|||
<string name="agreement_check">I agree to %1$s and %2$s</string>
|
||||
<string name="server_rules">server rules</string>
|
||||
<string name="tos">terms of service</string>
|
||||
<string name="sign_up">Sign up</string>
|
||||
<string name="sign_up">Sign-up</string>
|
||||
<string name="sign_ups">Sign-ups</string>
|
||||
<string name="validation_needed">This instance works with invitations. Your account will need to be manually approved by an administrator before being usable.</string>
|
||||
<string name="cannot_be_empty">This field cannot be empty!</string>
|
||||
<string name="password_error">Passwords don\'t match!</string>
|
||||
|
@ -1254,6 +1261,9 @@
|
|||
<string name="SET_NOTIF_FAVOURITE" translatable="false">SET_NOTIF_FAVOURITE</string>
|
||||
<string name="SET_NOTIF_POLL" translatable="false">SET_NOTIF_POLL</string>
|
||||
<string name="SET_NOTIF_STATUS" translatable="false">SET_NOTIF_STATUS</string>
|
||||
<string name="SET_NOTIF_UPDATE" translatable="false">SET_NOTIF_UPDATE</string>
|
||||
<string name="SET_NOTIF_ADMIN_SIGNUP" translatable="false">SET_NOTIF_ADMIN_SIGNUP</string>
|
||||
<string name="SET_NOTIF_ADMIN_REPORT" translatable="false">SET_NOTIF_ADMIN_REPORT</string>
|
||||
<string name="SET_FONT_SCALE" translatable="false">SET_FONT_SCALE</string>
|
||||
<string name="SET_MAX_INDENTATION" translatable="false">SET_MAX_INDENTATION</string>
|
||||
<string name="SET_FONT_SCALE_INT" translatable="false">SET_FONT_SCALE_INT</string>
|
||||
|
@ -1904,6 +1914,7 @@
|
|||
<string name="delete_timeline">Delete timeline</string>
|
||||
<string name="notif_submitted_report">Submitted a report</string>
|
||||
<string name="notif_signed_up">Signed up</string>
|
||||
<string name="notif_reported">sent a report</string>
|
||||
<string name="Suggestions">Suggestions</string>
|
||||
<string name="not_interested">Not interested</string>
|
||||
<string name="blocked_domains">Blocked domains</string>
|
||||
|
@ -1916,4 +1927,7 @@
|
|||
<string name="action_pinned_delete">Delete the pinned timelines?</string>
|
||||
<string name="domains">Domains</string>
|
||||
<string name="keep_notifications">Keep notifications</string>
|
||||
<string name="set_notif_update">Notify for updates</string>
|
||||
<string name="set_notif_user_sign_up">New sign-up (moderators)</string>
|
||||
<string name="set_notif_admin_report">New report (moderators)</string>
|
||||
</resources>
|
|
@ -77,6 +77,24 @@
|
|||
app:key="@string/SET_NOTIF_STATUS"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_notif_status" />
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_NOTIF_UPDATE"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_notif_update" />
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_NOTIF_ADMIN_SIGNUP"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_notif_user_sign_up" />
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_NOTIF_ADMIN_REPORT"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_notif_admin_report" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
|
Loading…
Reference in New Issue