Browse Source

Move activity notification viewer to its own nav graph. Fixes https://github.com/austinhuang0131/barinsta/issues/247

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
c1b5094dc7
  1. 14
      app/src/main/java/awais/instagrabber/activities/MainActivity.java
  2. 3
      app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java
  3. 6
      app/src/main/res/navigation/direct_messages_nav_graph.xml
  4. 6
      app/src/main/res/navigation/discover_nav_graph.xml
  5. 6
      app/src/main/res/navigation/feed_nav_graph.xml
  6. 14
      app/src/main/res/navigation/more_nav_graph.xml
  7. 17
      app/src/main/res/navigation/notification_viewer_nav_graph.xml
  8. 6
      app/src/main/res/navigation/profile_nav_graph.xml

14
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() {

3
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;
}));
}

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

@ -38,6 +38,12 @@
app:nullable="false" />
</action>
<include app:graph="@navigation/notification_viewer_nav_graph" />
<action
android:id="@+id/action_global_notificationsViewerFragment"
app:destination="@id/notification_viewer_nav_graph" />
<fragment
android:id="@+id/directMessagesInboxFragment"
android:name="awais.instagrabber.fragments.directmessages.DirectMessageInboxFragment"

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

@ -57,6 +57,12 @@
app:nullable="false" />
</action>
<include app:graph="@navigation/notification_viewer_nav_graph" />
<action
android:id="@+id/action_global_notificationsViewerFragment"
app:destination="@id/notification_viewer_nav_graph" />
<fragment
android:id="@+id/discoverFragment"
android:name="awais.instagrabber.fragments.main.DiscoverFragment"

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

@ -57,6 +57,12 @@
app:nullable="false" />
</action>
<include app:graph="@navigation/notification_viewer_nav_graph" />
<action
android:id="@+id/action_global_notificationsViewerFragment"
app:destination="@id/notification_viewer_nav_graph" />
<fragment
android:id="@+id/feedFragment"
android:name="awais.instagrabber.fragments.main.FeedFragment"

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

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/more_nav_graph"
app:startDestination="@id/morePreferencesFragment">
@ -9,6 +8,7 @@
<include app:graph="@navigation/hashtag_nav_graph" />
<include app:graph="@navigation/location_nav_graph" />
<include app:graph="@navigation/comments_nav_graph" />
<include app:graph="@navigation/notification_viewer_nav_graph" />
<action
android:id="@+id/action_global_profileFragment"
@ -37,6 +37,10 @@
app:nullable="false" />
</action>
<action
android:id="@+id/action_global_notificationsViewerFragment"
app:destination="@id/notification_viewer_nav_graph" />
<fragment
android:id="@+id/morePreferencesFragment"
android:name="awais.instagrabber.fragments.settings.MorePreferencesFragment"
@ -47,9 +51,6 @@
<action
android:id="@+id/action_morePreferencesFragment_to_aboutFragment"
app:destination="@id/aboutFragment" />
<action
android:id="@+id/action_morePreferencesFragment_to_notificationsViewer"
app:destination="@id/notificationsViewer" />
<action
android:id="@+id/action_morePreferencesFragment_to_favoritesFragment"
app:destination="@id/favoritesFragment" />
@ -69,11 +70,6 @@
android:id="@+id/aboutFragment"
android:name="awais.instagrabber.fragments.settings.AboutFragment"
android:label="@string/action_about" />
<fragment
android:id="@+id/notificationsViewer"
android:name="awais.instagrabber.fragments.NotificationsViewerFragment"
android:label="@string/title_notifications"
tools:layout="@layout/fragment_notifications_viewer" />
<fragment
android:id="@+id/themePreferencesFragment"
android:name="awais.instagrabber.fragments.settings.ThemePreferencesFragment"

17
app/src/main/res/navigation/notification_viewer_nav_graph.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/notification_viewer_nav_graph"
app:startDestination="@id/notificationsViewer">
<fragment
android:id="@+id/notificationsViewer"
android:name="awais.instagrabber.fragments.NotificationsViewerFragment"
android:label="@string/title_notifications"
tools:layout="@layout/fragment_notifications_viewer" />
<action
android:id="@+id/action_global_notificationsViewerFragment"
app:destination="@id/notificationsViewer" />
</navigation>

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

@ -58,6 +58,12 @@
app:nullable="false" />
</action>
<include app:graph="@navigation/notification_viewer_nav_graph" />
<action
android:id="@+id/action_global_notificationsViewerFragment"
app:destination="@id/notification_viewer_nav_graph" />
<fragment
android:id="@+id/profileFragment"
android:name="awais.instagrabber.fragments.main.ProfileFragment"

Loading…
Cancel
Save