Skip to content

Commit

Permalink
2528: Do not remove notifications on general resume (#3312)
Browse files Browse the repository at this point in the history
* 2528: Do not remove notifications on general resume

* 2528: Have notification removal in the right onResume
  • Loading branch information
Lakoja authored Feb 25, 2023
1 parent f2b0719 commit 4ab305f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 0 additions & 5 deletions app/src/main/java/com/keylesspalace/tusky/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje

override fun onResume() {
super.onResume()
NotificationHelper.clearNotificationsForActiveAccount(this, accountManager)
val currentEmojiPack = preferences.getString(EMOJI_PREFERENCE, "")
if (currentEmojiPack != selectedEmojiPack) {
Log.d(
Expand Down Expand Up @@ -726,10 +725,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, HasAndroidInje

onTabSelectedListener = object : OnTabSelectedListener {
override fun onTabSelected(tab: TabLayout.Tab) {
if (tab.position == notificationTabPosition) {
NotificationHelper.clearNotificationsForActiveAccount(this@MainActivity, accountManager)
}

binding.mainToolbar.title = tabs[tab.position].title(this@MainActivity)

refreshComposeButtonState(tabAdapter, tab.position)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import com.keylesspalace.tusky.appstore.PinEvent;
import com.keylesspalace.tusky.appstore.PreferenceChangedEvent;
import com.keylesspalace.tusky.appstore.ReblogEvent;
import com.keylesspalace.tusky.components.notifications.NotificationHelper;
import com.keylesspalace.tusky.databinding.FragmentTimelineNotificationsBinding;
import com.keylesspalace.tusky.db.AccountEntity;
import com.keylesspalace.tusky.db.AccountManager;
Expand Down Expand Up @@ -1210,6 +1211,9 @@ public Object getChangePayload(@NonNull NotificationViewData oldItem, @NonNull N
@Override
public void onResume() {
super.onResume();

NotificationHelper.clearNotificationsForActiveAccount(requireContext(), accountManager);

String rawAccountNotificationFilter = accountManager.getActiveAccount().getNotificationsFilter();
Set<Notification.Type> accountNotificationFilter = NotificationTypeConverterKt.deserialize(rawAccountNotificationFilter);
if (!notificationFilter.equals(accountNotificationFilter)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class SendStatusBroadcastReceiver : BroadcastReceiver() {
builder.setCategory(NotificationCompat.CATEGORY_SOCIAL)
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)
}
}
}
Expand Down

0 comments on commit 4ab305f

Please sign in to comment.