Search in sources :

Example 6 with NavigationBarView

use of com.google.android.material.navigation.NavigationBarView in project LSPosed by naicfeng.

the class MainActivity method handleIntent.

private void handleIntent(Intent intent) {
    if (intent == null) {
        return;
    }
    NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
    if (navHostFragment == null) {
        return;
    }
    NavController navController = navHostFragment.getNavController();
    var nav = (NavigationBarView) binding.nav;
    if (intent.getAction() != null && intent.getAction().equals("android.intent.action.APPLICATION_PREFERENCES")) {
        nav.setSelectedItemId(R.id.settings_fragment);
    } else if (ConfigManager.isBinderAlive()) {
        if (!TextUtils.isEmpty(intent.getDataString())) {
            switch(intent.getDataString()) {
                case "modules":
                    nav.setSelectedItemId(R.id.modules_nav);
                    break;
                // break;
                case "repo":
                    if (ConfigManager.isMagiskInstalled()) {
                        nav.setSelectedItemId(R.id.repo_nav);
                    }
                    break;
                case "settings":
                    nav.setSelectedItemId(R.id.settings_fragment);
                    break;
                default:
                    var data = intent.getData();
                    if (data != null && data.getScheme().equals("module")) {
                        navController.navigate(new Uri.Builder().scheme("lsposed").authority("module").appendQueryParameter("modulePackageName", data.getHost()).appendQueryParameter("moduleUserId", String.valueOf(data.getPort())).build(), new NavOptions.Builder().setEnterAnim(R.anim.fragment_enter).setExitAnim(R.anim.fragment_exit).setPopEnterAnim(R.anim.fragment_enter_pop).setPopExitAnim(R.anim.fragment_exit_pop).setLaunchSingleTop(true).setPopUpTo(navController.getGraph().getStartDestinationId(), false, true).build());
                    }
            }
        }
    }
}
Also used : NavigationBarView(com.google.android.material.navigation.NavigationBarView) NavOptions(androidx.navigation.NavOptions) NavController(androidx.navigation.NavController) NavHostFragment(androidx.navigation.fragment.NavHostFragment) Uri(android.net.Uri)

Aggregations

NavigationBarView (com.google.android.material.navigation.NavigationBarView)6 NavController (androidx.navigation.NavController)4 NavHostFragment (androidx.navigation.fragment.NavHostFragment)4 Uri (android.net.Uri)2 NavOptions (androidx.navigation.NavOptions)2 SuppressLint (android.annotation.SuppressLint)1 StrictMode (android.os.StrictMode)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 HomeFragment (com.netbyte.vtunnel.fragment.HomeFragment)1