From c1b5094dc72946250d136e5e355f49e151947cbf Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Wed, 11 Nov 2020 20:04:38 +0900 Subject: [PATCH] Move activity notification viewer to its own nav graph. Fixes https://github.com/austinhuang0131/barinsta/issues/247 --- .../instagrabber/activities/MainActivity.java | 14 ++++---------- .../settings/MorePreferencesFragment.java | 3 +-- .../navigation/direct_messages_nav_graph.xml | 6 ++++++ .../main/res/navigation/discover_nav_graph.xml | 6 ++++++ app/src/main/res/navigation/feed_nav_graph.xml | 6 ++++++ app/src/main/res/navigation/more_nav_graph.xml | 14 +++++--------- .../notification_viewer_nav_graph.xml | 17 +++++++++++++++++ .../main/res/navigation/profile_nav_graph.xml | 6 ++++++ 8 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 app/src/main/res/navigation/notification_viewer_nav_graph.xml diff --git a/app/src/main/java/awais/instagrabber/activities/MainActivity.java b/app/src/main/java/awais/instagrabber/activities/MainActivity.java index af1c9bcf..c556eaf3 100644 --- a/app/src/main/java/awais/instagrabber/activities/MainActivity.java +++ b/app/src/main/java/awais/instagrabber/activities/MainActivity.java @@ -35,7 +35,6 @@ import androidx.lifecycle.LiveData; import androidx.navigation.NavBackStackEntry; import androidx.navigation.NavController; import androidx.navigation.NavDestination; -import androidx.navigation.NavDirections; import androidx.navigation.ui.NavigationUI; import com.google.android.material.appbar.AppBarLayout; @@ -58,7 +57,6 @@ import awais.instagrabber.customviews.helpers.CustomHideBottomViewOnScrollBehavi import awais.instagrabber.databinding.ActivityMainBinding; import awais.instagrabber.fragments.PostViewV2Fragment; import awais.instagrabber.fragments.main.FeedFragment; -import awais.instagrabber.fragments.settings.MorePreferencesFragmentDirections; import awais.instagrabber.interfaces.FetchListener; import awais.instagrabber.models.IntentModel; import awais.instagrabber.models.SuggestionModel; @@ -634,14 +632,10 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage } private void showActivityView() { - binding.bottomNavView.setSelectedItemId(R.id.more_nav_graph); - binding.bottomNavView.post(() -> { - if (currentNavControllerLiveData == null) return; - final NavController navController = currentNavControllerLiveData.getValue(); - if (navController == null) return; - final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToNotificationsViewer(); - navController.navigate(navDirections); - }); + if (currentNavControllerLiveData == null) return; + final NavController navController = currentNavControllerLiveData.getValue(); + if (navController == null) return; + navController.navigate(R.id.action_global_notificationsViewerFragment); } private void bindActivityCheckerService() { diff --git a/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java b/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java index 8b12bb38..74cb4edd 100644 --- a/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java @@ -103,8 +103,7 @@ public class MorePreferencesFragment extends BasePreferencesFragment { screen.addPreference(getDivider(context)); if (isLoggedIn) { screen.addPreference(getPreference(R.string.action_notif, R.drawable.ic_not_liked, preference -> { - final NavDirections navDirections = MorePreferencesFragmentDirections.actionMorePreferencesFragmentToNotificationsViewer(); - NavHostFragment.findNavController(this).navigate(navDirections); + NavHostFragment.findNavController(this).navigate(R.id.action_global_notificationsViewerFragment); return true; })); } diff --git a/app/src/main/res/navigation/direct_messages_nav_graph.xml b/app/src/main/res/navigation/direct_messages_nav_graph.xml index 532d5dcc..9839d56e 100644 --- a/app/src/main/res/navigation/direct_messages_nav_graph.xml +++ b/app/src/main/res/navigation/direct_messages_nav_graph.xml @@ -38,6 +38,12 @@ app:nullable="false" /> + + + + + + + + + + + + @@ -9,6 +8,7 @@ + + + - @@ -69,11 +70,6 @@ android:id="@+id/aboutFragment" android:name="awais.instagrabber.fragments.settings.AboutFragment" android:label="@string/action_about" /> - + + + + + + \ No newline at end of file diff --git a/app/src/main/res/navigation/profile_nav_graph.xml b/app/src/main/res/navigation/profile_nav_graph.xml index aad54aee..58b2d1d4 100644 --- a/app/src/main/res/navigation/profile_nav_graph.xml +++ b/app/src/main/res/navigation/profile_nav_graph.xml @@ -58,6 +58,12 @@ app:nullable="false" /> + + + +