2528: Do not remove notifications on general resume (#3312)

* 2528: Do not remove notifications on general resume

* 2528: Have notification removal in the right onResume
This commit is contained in:
UlrichKu 2023-02-25 21:18:03 +01:00 committed by GitHub
parent f2b07196e6
commit 4ab305f3dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -354,7 +354,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
NotificationHelper.clearNotificationsForActiveAccount(this, accountManager)
val currentEmojiPack = preferences.getString(EMOJI_PREFERENCE, "") val currentEmojiPack = preferences.getString(EMOJI_PREFERENCE, "")
if (currentEmojiPack != selectedEmojiPack) { if (currentEmojiPack != selectedEmojiPack) {
Log.d( Log.d(
@ -726,10 +725,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje
onTabSelectedListener = object : OnTabSelectedListener { onTabSelectedListener = object : OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab) { override fun onTabSelected(tab: TabLayout.Tab) {
if (tab.position == notificationTabPosition) {
NotificationHelper.clearNotificationsForActiveAccount(this@MainActivity, accountManager)
}
binding.mainToolbar.title = tabs[tab.position].title(this@MainActivity) binding.mainToolbar.title = tabs[tab.position].title(this@MainActivity)
refreshComposeButtonState(tabAdapter, tab.position) refreshComposeButtonState(tabAdapter, tab.position)

View file

@ -63,6 +63,7 @@ import com.keylesspalace.tusky.appstore.FavoriteEvent;
import com.keylesspalace.tusky.appstore.PinEvent; import com.keylesspalace.tusky.appstore.PinEvent;
import com.keylesspalace.tusky.appstore.PreferenceChangedEvent; import com.keylesspalace.tusky.appstore.PreferenceChangedEvent;
import com.keylesspalace.tusky.appstore.ReblogEvent; import com.keylesspalace.tusky.appstore.ReblogEvent;
import com.keylesspalace.tusky.components.notifications.NotificationHelper;
import com.keylesspalace.tusky.databinding.FragmentTimelineNotificationsBinding; import com.keylesspalace.tusky.databinding.FragmentTimelineNotificationsBinding;
import com.keylesspalace.tusky.db.AccountEntity; import com.keylesspalace.tusky.db.AccountEntity;
import com.keylesspalace.tusky.db.AccountManager; import com.keylesspalace.tusky.db.AccountManager;
@ -1210,6 +1211,9 @@ public class NotificationsFragment extends SFragment implements
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
NotificationHelper.clearNotificationsForActiveAccount(requireContext(), accountManager);
String rawAccountNotificationFilter = accountManager.getActiveAccount().getNotificationsFilter(); String rawAccountNotificationFilter = accountManager.getActiveAccount().getNotificationsFilter();
Set<Notification.Type> accountNotificationFilter = NotificationTypeConverterKt.deserialize(rawAccountNotificationFilter); Set<Notification.Type> accountNotificationFilter = NotificationTypeConverterKt.deserialize(rawAccountNotificationFilter);
if (!notificationFilter.equals(accountNotificationFilter)) { if (!notificationFilter.equals(accountNotificationFilter)) {

View file

@ -117,7 +117,8 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
builder.setCategory(NotificationCompat.CATEGORY_SOCIAL) builder.setCategory(NotificationCompat.CATEGORY_SOCIAL)
builder.setOnlyAlertOnce(true) builder.setOnlyAlertOnce(true)
notificationManager.notify(notificationId, builder.build()) // There is a separate "I am sending" notification, so simply remove the handled one.
notificationManager.cancel(notificationId)
} }
} }
} }