Revert "refactor(notifications-tab/badge): use improved implementation"
This reverts commit ac561549
This commit is contained in:
@@ -47,7 +47,6 @@ public class GlobalUserPreferences{
|
||||
public static boolean collapseLongPosts;
|
||||
public static boolean spectatorMode;
|
||||
public static boolean autoHideFab;
|
||||
public static boolean unreadNotifications;
|
||||
public static boolean defaultToUnlistedReplies;
|
||||
public static boolean disableDoubleTapToSwipe;
|
||||
public static String publishButtonText;
|
||||
@@ -104,7 +103,6 @@ public class GlobalUserPreferences{
|
||||
collapseLongPosts=prefs.getBoolean("collapseLongPosts", true);
|
||||
spectatorMode=prefs.getBoolean("spectatorMode", false);
|
||||
autoHideFab=prefs.getBoolean("autoHideFab", true);
|
||||
unreadNotifications=prefs.getBoolean("unreadNotifications", false);
|
||||
defaultToUnlistedReplies=prefs.getBoolean("defaultToUnlistedReplies", false);
|
||||
disableDoubleTapToSwipe=prefs.getBoolean("disableDoubleTapToSwipe", false);
|
||||
publishButtonText=prefs.getString("publishButtonText", "");
|
||||
@@ -156,7 +154,6 @@ public class GlobalUserPreferences{
|
||||
.putBoolean("collapseLongPosts", collapseLongPosts)
|
||||
.putBoolean("spectatorMode", spectatorMode)
|
||||
.putBoolean("autoHideFab", autoHideFab)
|
||||
.putBoolean("unreadNotifications", unreadNotifications)
|
||||
.putString("publishButtonText", publishButtonText)
|
||||
.putBoolean("bottomEncoding", bottomEncoding)
|
||||
.putBoolean("defaultToUnlistedReplies", defaultToUnlistedReplies)
|
||||
|
||||
@@ -89,8 +89,6 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
||||
@Override
|
||||
public void onSuccess(org.joinmastodon.android.model.Notification result){
|
||||
MastodonAPIController.runInBackground(()->PushNotificationReceiver.this.notify(context, pn, accountID, result));
|
||||
GlobalUserPreferences.unreadNotifications = true;
|
||||
GlobalUserPreferences.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,6 +58,7 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
||||
private View tabBarWrap;
|
||||
private ImageView tabBarAvatar;
|
||||
private ImageView notificationTabIcon;
|
||||
private boolean notificationBadged = false;
|
||||
@IdRes
|
||||
private int currentTab=R.id.tab_home;
|
||||
|
||||
@@ -124,7 +125,21 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
||||
ViewImageLoader.load(tabBarAvatar, null, new UrlImageLoaderRequest(self.avatar, V.dp(28), V.dp(28)));
|
||||
|
||||
notificationTabIcon=content.findViewById(R.id.tab_notifications);
|
||||
|
||||
AccountSessionManager.getInstance()
|
||||
.getAccount(accountID).getCacheController()
|
||||
.getNotifications(null, 1, false, false, true, new Callback<>() {
|
||||
@Override
|
||||
public void onSuccess(PaginatedResponse<List<Notification>> result) {
|
||||
notificationBadged = result.items.get(0).createdAt.isAfter(Instant.ofEpochMilli(GlobalUserPreferences.lastNotificationOpenedTime));
|
||||
setNotificationBadge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error) {
|
||||
error.showToast(getContext());
|
||||
}
|
||||
});
|
||||
|
||||
if(savedInstanceState==null){
|
||||
getChildFragmentManager().beginTransaction()
|
||||
@@ -268,7 +283,8 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
||||
}
|
||||
|
||||
if(tab == R.id.tab_notifications){
|
||||
GlobalUserPreferences.unreadNotifications = false;
|
||||
notificationBadged=false;
|
||||
GlobalUserPreferences.lastNotificationOpenedTime = System.currentTimeMillis();
|
||||
GlobalUserPreferences.save();
|
||||
setNotificationBadge();
|
||||
}
|
||||
@@ -354,6 +370,6 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene
|
||||
}
|
||||
|
||||
private void setNotificationBadge() {
|
||||
notificationTabIcon.setImageDrawable(getContext().getDrawable(GlobalUserPreferences.unreadNotifications ? R.drawable.ic_notifications_tab_badged : R.drawable.ic_fluent_alert_28_selector));
|
||||
notificationTabIcon.setImageDrawable(getContext().getDrawable(notificationBadged ? R.drawable.ic_notifications_tab_badged : R.drawable.ic_fluent_alert_28_selector));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user