@Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.about_menu_option:
        Navigation.findNavController(requireView())
            .navigate(MainFragmentDirections.actionMainFragmentToAboutAnySoftKeyboardFragment());
        return true;
      case R.id.tweaks_menu_option:
        Navigation.findNavController(requireView())
            .navigate(MainFragmentDirections.actionMainFragmentToMainTweaksFragment());
        return true;
      case R.id.backup_prefs:
        mDialogController.showDialog(R.id.backup_prefs);
        return true;
      case R.id.restore_prefs:
        mDialogController.showDialog(R.id.restore_prefs);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
@Test
  public void testRestoreMenuItem() throws Exception {
    Shadows.shadowOf((Application) getApplicationContext());
    final MainFragment fragment = startFragment();
    final FragmentActivity activity = fragment.getActivity();

    Menu menu = Shadows.shadowOf(activity).getOptionsMenu();
    Assert.assertNotNull(menu);
    final MenuItem item = menu.findItem(R.id.restore_prefs);
    Assert.assertNotNull(item);

    fragment.onOptionsItemSelected(item);
    TestRxSchedulers.foregroundFlushAllJobs();

    final AlertDialog dialog = GeneralDialogTestUtil.getLatestShownDialog();
    Assert.assertNotNull(dialog);
    Assert.assertEquals(
        getApplicationContext().getText(R.string.pick_prefs_providers_to_restore),
        GeneralDialogTestUtil.getTitleFromDialog(dialog));
    Assert.assertNotNull(dialog.getListView());
    Assert.assertEquals(
        GlobalPrefsBackup.getAllPrefsProviders(getApplicationContext()).size(),
        dialog.getListView().getCount());
  }