diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index a3dc4e6f..ad5d1623 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -124,6 +124,7 @@ import app.fedilab.android.client.entities.app.DomainsBlock; import app.fedilab.android.client.entities.app.Pinned; import app.fedilab.android.client.entities.app.PinnedTimeline; import app.fedilab.android.client.entities.app.StatusDraft; +import app.fedilab.android.client.entities.app.Timeline; import app.fedilab.android.databinding.ActivityMainBinding; import app.fedilab.android.databinding.NavHeaderMainBinding; import app.fedilab.android.exception.DBException; @@ -308,11 +309,26 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } else if (extras.getInt(Helper.INTENT_ACTION) == Helper.OPEN_NOTIFICATION) { final Handler handler = new Handler(); handler.postDelayed(() -> { - int position = BottomMenu.getPosition(bottomMenu, R.id.nav_notifications); - if (position > 0) { - binding.bottomNavView.getMenu().getItem(position).setChecked(true); - binding.viewPager.setCurrentItem(position); + SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(BaseMainActivity.this); + boolean singleBar = sharedpreferences.getBoolean(getString(R.string.SET_USE_SINGLE_TOPBAR), false); + if (!singleBar) { + int position = BottomMenu.getPosition(bottomMenu, R.id.nav_notifications); + if (position > 0) { + binding.bottomNavView.getMenu().getItem(position).setChecked(true); + binding.viewPager.setCurrentItem(position); + } + } else { + int position = 0; + for (PinnedTimeline pinnedTimeline : pinned.pinnedTimelines) { + if (pinnedTimeline.type == Timeline.TimeLineEnum.NOTIFICATION) { + binding.bottomNavView.getMenu().getItem(position).setChecked(true); + binding.viewPager.setCurrentItem(position); + break; + } + position++; + } } + }, 1000); intent.removeExtra(Helper.INTENT_ACTION); diff --git a/app/src/main/java/app/fedilab/android/client/entities/api/Status.java b/app/src/main/java/app/fedilab/android/client/entities/api/Status.java index 4ec31d27..451610b7 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/api/Status.java +++ b/app/src/main/java/app/fedilab/android/client/entities/api/Status.java @@ -35,7 +35,7 @@ public class Status implements Serializable, Cloneable { @SerializedName("id") public String id; @SerializedName("created_at") - public Date created_at; + public Date created_at = new Date(); @SerializedName("in_reply_to_id") public String in_reply_to_id; @SerializedName("in_reply_to_account_id") diff --git a/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java b/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java index 08d1cba1..01222a88 100644 --- a/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/PinnedTimelineHelper.java @@ -51,7 +51,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.regex.Pattern; import app.fedilab.android.BaseMainActivity; @@ -332,6 +331,7 @@ public class PinnedTimelineHelper { Pinned finalPinned = pinned; + int finalToRemove1 = toRemove; activityMainBinding.moreTimelines.setOnClickListener(v -> { PopupMenu popup = new PopupMenu(new ContextThemeWrapper(activity, Helper.popupStyle()), v); try { @@ -343,6 +343,7 @@ public class PinnedTimelineHelper { e.printStackTrace(); } int i = 0; + int j = 0; for (PinnedTimeline pinnedTimeline : finalPinned.pinnedTimelines) { MenuItem item = null; switch (pinnedTimeline.type) { @@ -380,13 +381,22 @@ public class PinnedTimelineHelper { break; } if (item != null) { - int finalI = i; + int finalI; + if (singleBar) { + finalI = i; + } else { + finalI = BOTTOM_TIMELINE_COUNT - finalToRemove1 + j; + } item.setOnMenuItemClickListener(item1 -> { if (finalI < activityMainBinding.tabLayout.getTabCount() && activityMainBinding.tabLayout.getTabAt(finalI) != null) { - Objects.requireNonNull(activityMainBinding.tabLayout.getTabAt(finalI)).select(); + TabLayout.Tab tab = activityMainBinding.tabLayout.getTabAt(finalI); + if (tab != null) { + tab.select(); + } } return false; }); + j++; } i++; }