Browse Source

navigation fixes related to more tab

renovate/androidx.fragment-fragment-ktx-1.x
Austin Huang 3 years ago
parent
commit
114a0b090e
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 5
      app/src/main/java/awais/instagrabber/activities/MainActivity.kt
  2. 7
      app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java
  3. 6
      app/src/main/res/navigation/more_nav_graph.xml
  4. 4
      app/src/main/res/navigation/settings_nav_graph.xml

5
app/src/main/java/awais/instagrabber/activities/MainActivity.kt

@ -340,7 +340,8 @@ class MainActivity : BaseLanguageActivity() {
it.startDestinationFragmentId it.startDestinationFragmentId
}.toMutableList().apply { }.toMutableList().apply {
add(R.id.postViewFragment) add(R.id.postViewFragment)
add(R.id.favoritesFragment)
add(R.id.favorites_non_top)
add(R.id.notifications_viewer_non_top)
add(R.id.profile_non_top) add(R.id.profile_non_top)
} }
if (setDefaultTabFromSettings) { if (setDefaultTabFromSettings) {
@ -356,7 +357,7 @@ class MainActivity : BaseLanguageActivity() {
rootNavGraph.id = R.id.root_nav_graph rootNavGraph.id = R.id.root_nav_graph
rootNavGraph.label = "root_nav_graph" rootNavGraph.label = "root_nav_graph"
rootNavGraph.addDestinations(topLevelDestinations) rootNavGraph.addDestinations(topLevelDestinations)
rootNavGraph.setStartDestination(if (startNavRootId != 0) startNavRootId else R.id.profile_nav_graph)
rootNavGraph.startDestination = if (startNavRootId != 0) startNavRootId else R.id.profile_nav_graph
navController.graph = rootNavGraph navController.graph = rootNavGraph
binding.bottomNavView.setupWithNavController(navController) binding.bottomNavView.setupWithNavController(navController)
appBarConfiguration = AppBarConfiguration(currentTabs.map { it.startDestinationFragmentId }.toSet()) appBarConfiguration = AppBarConfiguration(currentTabs.map { it.startDestinationFragmentId }.toSet())

7
app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java

@ -194,7 +194,12 @@ public class MorePreferencesFragment extends BasePreferencesFragment {
if (showExplore) { if (showExplore) {
screen.addPreference(getPreference(R.string.title_discover, R.drawable.ic_explore_24, preference -> { screen.addPreference(getPreference(R.string.title_discover, R.drawable.ic_explore_24, preference -> {
if (isSafeToNavigate(navController)) { if (isSafeToNavigate(navController)) {
navController.navigate(R.id.discover_nav_graph);
try {
final NavDirections navDirections = MorePreferencesFragmentDirections.actionToDiscover();
navController.navigate(navDirections);
} catch (Exception e) {
Log.e(TAG, "setupPreferenceScreen: ", e);
}
} }
return true; return true;
})); }));

6
app/src/main/res/navigation/more_nav_graph.xml

@ -14,6 +14,10 @@
android:id="@+id/action_to_settings" android:id="@+id/action_to_settings"
app:destination="@id/settings_nav_graph" /> app:destination="@id/settings_nav_graph" />
<action
android:id="@+id/action_to_discover"
app:destination="@id/discover_nav_graph" />
<action <action
android:id="@+id/action_to_about" android:id="@+id/action_to_about"
app:destination="@id/aboutFragment" /> app:destination="@id/aboutFragment" />
@ -517,6 +521,8 @@
<include app:graph="@navigation/settings_nav_graph" /> <include app:graph="@navigation/settings_nav_graph" />
<include app:graph="@navigation/discover_nav_graph" />
<fragment <fragment
android:id="@+id/storyListViewerFragment" android:id="@+id/storyListViewerFragment"
android:name="awais.instagrabber.fragments.StoryListViewerFragment" android:name="awais.instagrabber.fragments.StoryListViewerFragment"

4
app/src/main/res/navigation/settings_nav_graph.xml

@ -41,10 +41,6 @@
android:id="@+id/themePreferencesFragment" android:id="@+id/themePreferencesFragment"
android:name="awais.instagrabber.fragments.settings.ThemePreferencesFragment" android:name="awais.instagrabber.fragments.settings.ThemePreferencesFragment"
android:label="@string/theme_settings" /> android:label="@string/theme_settings" />
<fragment
android:id="@+id/favoritesFragment"
android:name="awais.instagrabber.fragments.FavoritesFragment"
android:label="@string/title_favorites" />
<fragment <fragment
android:id="@+id/backupPreferencesFragment" android:id="@+id/backupPreferencesFragment"
android:name="awais.instagrabber.fragments.settings.BackupPreferencesFragment" android:name="awais.instagrabber.fragments.settings.BackupPreferencesFragment"

Loading…
Cancel
Save