Support new signup notifications (#2357)
This commit is contained in:
parent
0c840a706d
commit
d21d045eda
11 changed files with 869 additions and 14 deletions
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package com.keylesspalace.tusky.components.notifications;
|
||||
|
||||
import static com.keylesspalace.tusky.viewdata.PollViewDataKt.buildDescription;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationChannelGroup;
|
||||
import android.app.NotificationManager;
|
||||
|
|
@ -73,8 +75,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import io.reactivex.rxjava3.core.Single;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
import static com.keylesspalace.tusky.viewdata.PollViewDataKt.buildDescription;
|
||||
|
||||
public class NotificationHelper {
|
||||
|
||||
private static int notificationId = 0;
|
||||
|
|
@ -116,6 +116,7 @@ public class NotificationHelper {
|
|||
public static final String CHANNEL_FAVOURITE = "CHANNEL_FAVOURITE";
|
||||
public static final String CHANNEL_POLL = "CHANNEL_POLL";
|
||||
public static final String CHANNEL_SUBSCRIPTIONS = "CHANNEL_SUBSCRIPTIONS";
|
||||
public static final String CHANNEL_SIGN_UP = "CHANNEL_SIGN_UP";
|
||||
|
||||
/**
|
||||
* WorkManager Tag
|
||||
|
|
@ -392,6 +393,7 @@ public class NotificationHelper {
|
|||
CHANNEL_FAVOURITE + account.getIdentifier(),
|
||||
CHANNEL_POLL + account.getIdentifier(),
|
||||
CHANNEL_SUBSCRIPTIONS + account.getIdentifier(),
|
||||
CHANNEL_SIGN_UP + account.getIdentifier(),
|
||||
};
|
||||
int[] channelNames = {
|
||||
R.string.notification_mention_name,
|
||||
|
|
@ -401,6 +403,7 @@ public class NotificationHelper {
|
|||
R.string.notification_favourite_name,
|
||||
R.string.notification_poll_name,
|
||||
R.string.notification_subscription_name,
|
||||
R.string.notification_sign_up_name,
|
||||
};
|
||||
int[] channelDescriptions = {
|
||||
R.string.notification_mention_descriptions,
|
||||
|
|
@ -410,6 +413,7 @@ public class NotificationHelper {
|
|||
R.string.notification_favourite_description,
|
||||
R.string.notification_poll_description,
|
||||
R.string.notification_subscription_description,
|
||||
R.string.notification_sign_up_description,
|
||||
};
|
||||
|
||||
List<NotificationChannel> channels = new ArrayList<>(6);
|
||||
|
|
@ -560,6 +564,8 @@ public class NotificationHelper {
|
|||
return account.getNotificationsFavorited();
|
||||
case POLL:
|
||||
return account.getNotificationsPolls();
|
||||
case SIGN_UP:
|
||||
return account.getNotificationsSignUps();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -582,6 +588,8 @@ public class NotificationHelper {
|
|||
return CHANNEL_FAVOURITE + account.getIdentifier();
|
||||
case POLL:
|
||||
return CHANNEL_POLL + account.getIdentifier();
|
||||
case SIGN_UP:
|
||||
return CHANNEL_SIGN_UP + account.getIdentifier();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
@ -663,6 +671,8 @@ public class NotificationHelper {
|
|||
} else {
|
||||
return context.getString(R.string.poll_ended_voted);
|
||||
}
|
||||
case SIGN_UP:
|
||||
return String.format(context.getString(R.string.notification_sign_up_format), accountName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
@ -671,6 +681,7 @@ public class NotificationHelper {
|
|||
switch (notification.getType()) {
|
||||
case FOLLOW:
|
||||
case FOLLOW_REQUEST:
|
||||
case SIGN_UP:
|
||||
return "@" + notification.getAccount().getUsername();
|
||||
case MENTION:
|
||||
case FAVOURITE:
|
||||
|
|
|
|||
|
|
@ -122,6 +122,17 @@ class NotificationPreferencesFragment : PreferenceFragmentCompat(), Injectable {
|
|||
true
|
||||
}
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
setTitle(R.string.pref_title_notification_filter_sign_ups)
|
||||
key = PrefKeys.NOTIFICATION_FILTER_SIGN_UPS
|
||||
isIconSpaceReserved = false
|
||||
isChecked = activeAccount.notificationsSignUps
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
updateAccount { it.notificationsSignUps = newValue as Boolean }
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory(R.string.pref_title_notification_alerts) { category ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue