From 918c32dade6e0df8860294b5a6b925bf8283a1a2 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 18 May 2022 16:26:34 +0200 Subject: [PATCH] Fix issue #62 --- .../activities/ReorderTimelinesActivity.java | 2 +- .../android/client/entities/BottomMenu.java | 7 ++++- .../ui/drawer/ReorderBottomMenuAdapter.java | 1 - .../android/viewmodel/mastodon/ReorderVM.java | 3 +++ .../android/viewmodel/mastodon/TopBarVM.java | 2 +- .../main/res/layout/activity_reorder_tabs.xml | 27 ++++++++++++++++--- app/src/main/res/values/strings.xml | 2 ++ 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java b/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java index be55801a..53924c51 100644 --- a/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java @@ -129,7 +129,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra }); reorderVM.getBottomMenu().observe(ReorderTimelinesActivity.this, _bottomMenu -> { this.bottomMenu = _bottomMenu; - if (this.bottomMenu == null) { + if (_bottomMenu == null) { this.bottomMenu = new BottomMenu(getApplicationContext()).defaultBottomMenu(); this.bottomMenu.bottom_menu = new ArrayList<>(); } diff --git a/app/src/main/java/app/fedilab/android/client/entities/BottomMenu.java b/app/src/main/java/app/fedilab/android/client/entities/BottomMenu.java index ff121e30..1d849073 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/BottomMenu.java +++ b/app/src/main/java/app/fedilab/android/client/entities/BottomMenu.java @@ -118,10 +118,13 @@ public class BottomMenu implements Serializable { public BottomMenu hydrate(Account account, BottomNavigationView bottomNavigationView) { bottomNavigationView.getMenu().clear(); - BottomMenu bottomMenu; + BottomMenu bottomMenu = null; try { bottomMenu = getAllBottomMenu(account); } catch (DBException e) { + e.printStackTrace(); + } + if (bottomMenu == null) { bottomMenu = defaultBottomMenu(); } for (BottomMenu.MenuItem menuItem : bottomMenu.bottom_menu) { @@ -294,6 +297,8 @@ public class BottomMenu implements Serializable { public BottomMenu defaultBottomMenu() { BottomMenu bottomMenu = new BottomMenu(); + bottomMenu.user_id = MainActivity.currentUserID; + bottomMenu.instance = MainActivity.currentInstance; bottomMenu.bottom_menu = new ArrayList<>(); MenuItem menuItemHome = new MenuItem(); menuItemHome.position = 0; diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ReorderBottomMenuAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ReorderBottomMenuAdapter.java index 8278e269..499f062b 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ReorderBottomMenuAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ReorderBottomMenuAdapter.java @@ -131,7 +131,6 @@ public class ReorderBottomMenuAdapter extends RecyclerView.Adapter bottomMenuMutableLiveData.setValue(finalBottomMenu); diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TopBarVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TopBarVM.java index 87ed69fa..b4361ecf 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TopBarVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/TopBarVM.java @@ -42,7 +42,7 @@ public class TopBarVM extends AndroidViewModel { Handler mainHandler = new Handler(Looper.getMainLooper()); Pinned pinnedTimeline = null; try { - pinnedTimeline = pinned.getPinned(BaseMainActivity.accountWeakReference.get()); + pinnedTimeline = pinned.getAllPinned(BaseMainActivity.accountWeakReference.get()); } catch (DBException e) { e.printStackTrace(); } diff --git a/app/src/main/res/layout/activity_reorder_tabs.xml b/app/src/main/res/layout/activity_reorder_tabs.xml index 72127e90..7d99742a 100644 --- a/app/src/main/res/layout/activity_reorder_tabs.xml +++ b/app/src/main/res/layout/activity_reorder_tabs.xml @@ -18,18 +18,30 @@ + + + android:layout_marginTop="10dp" + app:layout_constraintTop_toBottomOf="@+id/title_bottom"> + + app:layout_constraintTop_toBottomOf="@+id/title_top"> Poll duration: Always display bookmark button Display + Bottom menu + Top bar menu