Loading app/src/main/java/app/fedilab/android/BaseMainActivity.java +39 −20 Original line number Diff line number Diff line Loading @@ -1096,10 +1096,11 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt binding.bottomNavView.removeBadge(R.id.nav_privates); } } selectTab(Timeline.TimeLineEnum.CONVERSATION.getValue(), count); } @Override public void onUpdateNotification(int count, String slug) { public void onUpdateNotification(int count) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); if (!singleBar) { Loading @@ -1111,6 +1112,42 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt binding.bottomNavView.removeBadge(R.id.nav_notifications); } } selectTab(Timeline.TimeLineEnum.NOTIFICATION.getValue(), count); } private int getTabPosition(String slug) { int position = 0; for (int i = 0; i < binding.tabLayout.getTabCount(); i++) { TabLayout.Tab tab = binding.tabLayout.getTabAt(i); if (tab != null && tab.getTag() != null && tab.getTag().equals(slug)) { return position; } position++; } return -1; } private void selectTab(String slug, int count) { int position = getTabPosition(slug); if (position >= 0 && position < binding.tabLayout.getTabCount()) { TabLayout.Tab tab = binding.tabLayout.getTabAt(position); View view = null; if (tab != null) { view = tab.getCustomView(); } if (view != null) { TextView counter = view.findViewById(R.id.tab_counter); if (counter != null) { if (count > 0) { counter.setVisibility(View.VISIBLE); counter.setText(String.valueOf(count)); } else { counter.setVisibility(View.GONE); counter.setText("0"); } } } } } @Override Loading Loading @@ -1166,25 +1203,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt break; } } int selectedTab = binding.tabLayout.getSelectedTabPosition(); TabLayout.Tab tab = binding.tabLayout.getTabAt(selectedTab); View view = null; if (tab != null) { view = tab.getCustomView(); } if (view != null) { TextView counter = view.findViewById(R.id.tab_counter); if (counter != null) { if (count > 0) { counter.setVisibility(View.VISIBLE); counter.setText(String.valueOf(count)); } else { counter.setVisibility(View.GONE); counter.setText("0"); } } } selectTab(slug, count); } @Override Loading app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java +13 −0 Original line number Diff line number Diff line Loading @@ -245,6 +245,7 @@ public class PinnedTimelineHelper { List<PinnedTimeline> pinnedToRemove = new ArrayList<>(); for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) { //Default timelines are not added if we are not in the single bar mode String ident = null; if (!singleBar) { switch (pinnedTimeline.type) { case HOME: Loading @@ -262,14 +263,23 @@ public class PinnedTimelineHelper { switch (pinnedTimeline.type) { case LIST: name = pinnedTimeline.mastodonList.title; ident = "@l@" + pinnedTimeline.mastodonList.id; break; case TAG: name = pinnedTimeline.tagTimeline.displayName != null && !pinnedTimeline.tagTimeline.displayName.isEmpty() ? pinnedTimeline.tagTimeline.displayName : pinnedTimeline.tagTimeline.name.replaceAll("#", ""); ident = "@T@" + name; break; case REMOTE: name = pinnedTimeline.remoteInstance.host; if (pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) { String remoteInstance = sharedpreferences.getString(activity.getString(R.string.SET_NITTER_HOST), activity.getString(R.string.DEFAULT_NITTER_HOST)).toLowerCase(); ident = "@R@" + remoteInstance; } else { ident = "@R@" + pinnedTimeline.remoteInstance.host; } break; } if (pinnedTimeline.type == Timeline.TimeLineEnum.LIST || pinnedTimeline.type == Timeline.TimeLineEnum.TAG || pinnedTimeline.type == Timeline.TimeLineEnum.REMOTE) { TabCustomViewBinding tabCustomViewBinding = TabCustomViewBinding.inflate(activity.getLayoutInflater()); tabCustomViewBinding.title.setText(name); Loading Loading @@ -326,6 +336,9 @@ public class PinnedTimelineHelper { } tab.setCustomView(tabCustomDefaultViewBinding.getRoot()); } //We be used to fetch position of tabs String slug = pinnedTimeline.type.getValue() + (ident != null ? "|" + ident : ""); tab.setTag(slug); activityMainBinding.tabLayout.addTab(tab); pinnedTimelineVisibleList.add(pinnedTimeline); } Loading app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java +1 −1 Original line number Diff line number Diff line Loading @@ -468,7 +468,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati //Update the timeline with new statuses int insertedStatus = updateNotificationListWith(fetched_notifications.notifications); if (insertedStatus >= 0 && FragmentNotificationContainer.update != null && notificationType == NotificationTypeEnum.ALL && (direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || direction == FragmentMastodonTimeline.DIRECTION.REFRESH)) { FragmentNotificationContainer.update.onUpdateNotification(insertedStatus, notificationType.getValue()); FragmentNotificationContainer.update.onUpdateNotification(insertedStatus); } if (direction == FragmentMastodonTimeline.DIRECTION.TOP && fetchingMissing) { binding.recyclerView.scrollToPosition(getPosition(fetched_notifications.notifications.get(fetched_notifications.notifications.size() - 1)) + 1); Loading app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java +1 −1 Original line number Diff line number Diff line Loading @@ -270,6 +270,6 @@ public class FragmentNotificationContainer extends Fragment { public interface UpdateCounters { void onUpdateNotification(int count, String slug); void onUpdateNotification(int count); } } Loading
app/src/main/java/app/fedilab/android/BaseMainActivity.java +39 −20 Original line number Diff line number Diff line Loading @@ -1096,10 +1096,11 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt binding.bottomNavView.removeBadge(R.id.nav_privates); } } selectTab(Timeline.TimeLineEnum.CONVERSATION.getValue(), count); } @Override public void onUpdateNotification(int count, String slug) { public void onUpdateNotification(int count) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); if (!singleBar) { Loading @@ -1111,6 +1112,42 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt binding.bottomNavView.removeBadge(R.id.nav_notifications); } } selectTab(Timeline.TimeLineEnum.NOTIFICATION.getValue(), count); } private int getTabPosition(String slug) { int position = 0; for (int i = 0; i < binding.tabLayout.getTabCount(); i++) { TabLayout.Tab tab = binding.tabLayout.getTabAt(i); if (tab != null && tab.getTag() != null && tab.getTag().equals(slug)) { return position; } position++; } return -1; } private void selectTab(String slug, int count) { int position = getTabPosition(slug); if (position >= 0 && position < binding.tabLayout.getTabCount()) { TabLayout.Tab tab = binding.tabLayout.getTabAt(position); View view = null; if (tab != null) { view = tab.getCustomView(); } if (view != null) { TextView counter = view.findViewById(R.id.tab_counter); if (counter != null) { if (count > 0) { counter.setVisibility(View.VISIBLE); counter.setText(String.valueOf(count)); } else { counter.setVisibility(View.GONE); counter.setText("0"); } } } } } @Override Loading Loading @@ -1166,25 +1203,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt break; } } int selectedTab = binding.tabLayout.getSelectedTabPosition(); TabLayout.Tab tab = binding.tabLayout.getTabAt(selectedTab); View view = null; if (tab != null) { view = tab.getCustomView(); } if (view != null) { TextView counter = view.findViewById(R.id.tab_counter); if (counter != null) { if (count > 0) { counter.setVisibility(View.VISIBLE); counter.setText(String.valueOf(count)); } else { counter.setVisibility(View.GONE); counter.setText("0"); } } } selectTab(slug, count); } @Override Loading
app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java +13 −0 Original line number Diff line number Diff line Loading @@ -245,6 +245,7 @@ public class PinnedTimelineHelper { List<PinnedTimeline> pinnedToRemove = new ArrayList<>(); for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) { //Default timelines are not added if we are not in the single bar mode String ident = null; if (!singleBar) { switch (pinnedTimeline.type) { case HOME: Loading @@ -262,14 +263,23 @@ public class PinnedTimelineHelper { switch (pinnedTimeline.type) { case LIST: name = pinnedTimeline.mastodonList.title; ident = "@l@" + pinnedTimeline.mastodonList.id; break; case TAG: name = pinnedTimeline.tagTimeline.displayName != null && !pinnedTimeline.tagTimeline.displayName.isEmpty() ? pinnedTimeline.tagTimeline.displayName : pinnedTimeline.tagTimeline.name.replaceAll("#", ""); ident = "@T@" + name; break; case REMOTE: name = pinnedTimeline.remoteInstance.host; if (pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) { String remoteInstance = sharedpreferences.getString(activity.getString(R.string.SET_NITTER_HOST), activity.getString(R.string.DEFAULT_NITTER_HOST)).toLowerCase(); ident = "@R@" + remoteInstance; } else { ident = "@R@" + pinnedTimeline.remoteInstance.host; } break; } if (pinnedTimeline.type == Timeline.TimeLineEnum.LIST || pinnedTimeline.type == Timeline.TimeLineEnum.TAG || pinnedTimeline.type == Timeline.TimeLineEnum.REMOTE) { TabCustomViewBinding tabCustomViewBinding = TabCustomViewBinding.inflate(activity.getLayoutInflater()); tabCustomViewBinding.title.setText(name); Loading Loading @@ -326,6 +336,9 @@ public class PinnedTimelineHelper { } tab.setCustomView(tabCustomDefaultViewBinding.getRoot()); } //We be used to fetch position of tabs String slug = pinnedTimeline.type.getValue() + (ident != null ? "|" + ident : ""); tab.setTag(slug); activityMainBinding.tabLayout.addTab(tab); pinnedTimelineVisibleList.add(pinnedTimeline); } Loading
app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonNotification.java +1 −1 Original line number Diff line number Diff line Loading @@ -468,7 +468,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati //Update the timeline with new statuses int insertedStatus = updateNotificationListWith(fetched_notifications.notifications); if (insertedStatus >= 0 && FragmentNotificationContainer.update != null && notificationType == NotificationTypeEnum.ALL && (direction == FragmentMastodonTimeline.DIRECTION.FETCH_NEW || direction == FragmentMastodonTimeline.DIRECTION.SCROLL_TOP || direction == FragmentMastodonTimeline.DIRECTION.REFRESH)) { FragmentNotificationContainer.update.onUpdateNotification(insertedStatus, notificationType.getValue()); FragmentNotificationContainer.update.onUpdateNotification(insertedStatus); } if (direction == FragmentMastodonTimeline.DIRECTION.TOP && fetchingMissing) { binding.recyclerView.scrollToPosition(getPosition(fetched_notifications.notifications.get(fetched_notifications.notifications.size() - 1)) + 1); Loading
app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentNotificationContainer.java +1 −1 Original line number Diff line number Diff line Loading @@ -270,6 +270,6 @@ public class FragmentNotificationContainer extends Fragment { public interface UpdateCounters { void onUpdateNotification(int count, String slug); void onUpdateNotification(int count); } }