From ac94879c98d4789d09562bc36350ff564518e70f Mon Sep 17 00:00:00 2001 From: cketti Date: Mon, 13 Jan 2020 01:21:41 +0100 Subject: [PATCH] Add NavController to MessageList --- .../java/com/fsck/k9/activity/MessageList.java | 14 ++++++++++++-- .../src/main/res/navigation/navigation_main.xml | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 app/ui/src/main/res/navigation/navigation_main.xml diff --git a/app/ui/src/main/java/com/fsck/k9/activity/MessageList.java b/app/ui/src/main/java/com/fsck/k9/activity/MessageList.java index 8db7d8794..08ae1f868 100644 --- a/app/ui/src/main/java/com/fsck/k9/activity/MessageList.java +++ b/app/ui/src/main/java/com/fsck/k9/activity/MessageList.java @@ -20,6 +20,8 @@ import androidx.fragment.app.FragmentTransaction; import androidx.drawerlayout.widget.DrawerLayout; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.navigation.NavController; + import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.Menu; @@ -60,7 +62,6 @@ import com.fsck.k9.ui.managefolders.ManageFoldersActivity; import com.fsck.k9.ui.messagelist.DefaultFolderProvider; import com.fsck.k9.ui.messageview.MessageViewFragment; import com.fsck.k9.ui.messageview.MessageViewFragment.MessageViewFragmentListener; -import com.fsck.k9.ui.onboarding.OnboardingActivity; import com.fsck.k9.view.ViewSwitcher; import com.fsck.k9.view.ViewSwitcher.OnSwitchCompleteListener; import com.mikepenz.materialdrawer.Drawer.OnDrawerListener; @@ -215,15 +216,18 @@ public class MessageList extends K9Activity implements MessageListFragmentListen */ private boolean messageListWasDisplayed = false; private ViewSwitcher viewSwitcher; + private NavController navController; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + navController = createNavController(); + List accounts = preferences.getAccounts(); if (accounts.isEmpty()) { - OnboardingActivity.launch(this); + navController.navigate(R.id.action_global_onboardingScreen); finish(); return; } @@ -1638,4 +1642,10 @@ public class MessageList extends K9Activity implements MessageListFragmentListen drawer.deselect(); } } + + private NavController createNavController() { + NavController navController = new NavController(this); + navController.setGraph(R.navigation.navigation_main); + return navController; + } } diff --git a/app/ui/src/main/res/navigation/navigation_main.xml b/app/ui/src/main/res/navigation/navigation_main.xml new file mode 100644 index 000000000..e4514b908 --- /dev/null +++ b/app/ui/src/main/res/navigation/navigation_main.xml @@ -0,0 +1,17 @@ + + + + + + + +