Merge pull request #4446 from k9mail/navigation_main

Add NavController to MessageList
This commit is contained in:
cketti 2020-01-14 16:34:54 +01:00 committed by GitHub
commit f98d6c95b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View file

@ -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<Account> 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;
}
}

View file

@ -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/navigation_main"
app:startDestination="@id/onboardingScreen">
<activity
android:id="@+id/onboardingScreen"
android:name="com.fsck.k9.ui.onboarding.OnboardingActivity"
tools:layout="@layout/activity_onboarding"/>
<action
android:id="@+id/action_global_onboardingScreen"
app:destination="@id/onboardingScreen" />
</navigation>