@Test public void pressingConfigureQRCode_launchesQRCodeTabsActivity() { ActivityScenario<MainMenuActivity> firstActivity = ActivityScenario.launch(MainMenuActivity.class); firstActivity.onActivity(activity -> { MenuItem item = new RoboMenuItem(R.id.menu_configure_qr_code); activity.onOptionsItemSelected(item); Intent expectedIntent = new Intent(activity, QRCodeTabsActivity.class); Intent actual = shadowOf(RuntimeEnvironment.application).getNextStartedActivity(); assertThat(expectedIntent.getComponent(), equalTo(actual.getComponent())); }); }
@Override public boolean onOptionsItemSelected(MenuItem item) { if (!MultiClickGuard.allowClick(getClass().getName())) { return true; } switch (item.getItemId()) { case R.id.menu_configure_qr_code: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.SCAN_QR_CODE); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, QRCodeTabsActivity.class)); } return true; case R.id.menu_about: startActivity(new Intent(this, AboutActivity.class)); return true; case R.id.menu_general_preferences: startActivity(new Intent(this, PreferencesActivity.class)); return true; case R.id.menu_admin_preferences: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.ADMIN_SETTINGS); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, AdminPreferencesActivity.class)); } return true; } return super.onOptionsItemSelected(item); }
MainMenuActivity extends CollectAbstractActivity implements AdminPasswordDialogFragment.AdminPasswordDialogCallback { @Override public boolean onOptionsItemSelected(MenuItem item) { if (!MultiClickGuard.allowClick(getClass().getName())) { return true; } switch (item.getItemId()) { case R.id.menu_configure_qr_code: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.SCAN_QR_CODE); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, QRCodeTabsActivity.class)); } return true; case R.id.menu_about: startActivity(new Intent(this, AboutActivity.class)); return true; case R.id.menu_general_preferences: startActivity(new Intent(this, PreferencesActivity.class)); return true; case R.id.menu_admin_preferences: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.ADMIN_SETTINGS); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, AdminPreferencesActivity.class)); } return true; } return super.onOptionsItemSelected(item); } }
MainMenuActivity extends CollectAbstractActivity implements AdminPasswordDialogFragment.AdminPasswordDialogCallback { @Override public boolean onOptionsItemSelected(MenuItem item) { if (!MultiClickGuard.allowClick(getClass().getName())) { return true; } switch (item.getItemId()) { case R.id.menu_configure_qr_code: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.SCAN_QR_CODE); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, QRCodeTabsActivity.class)); } return true; case R.id.menu_about: startActivity(new Intent(this, AboutActivity.class)); return true; case R.id.menu_general_preferences: startActivity(new Intent(this, PreferencesActivity.class)); return true; case R.id.menu_admin_preferences: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.ADMIN_SETTINGS); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, AdminPreferencesActivity.class)); } return true; } return super.onOptionsItemSelected(item); }  }
MainMenuActivity extends CollectAbstractActivity implements AdminPasswordDialogFragment.AdminPasswordDialogCallback { @Override public boolean onOptionsItemSelected(MenuItem item) { if (!MultiClickGuard.allowClick(getClass().getName())) { return true; } switch (item.getItemId()) { case R.id.menu_configure_qr_code: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.SCAN_QR_CODE); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, QRCodeTabsActivity.class)); } return true; case R.id.menu_about: startActivity(new Intent(this, AboutActivity.class)); return true; case R.id.menu_general_preferences: startActivity(new Intent(this, PreferencesActivity.class)); return true; case R.id.menu_admin_preferences: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.ADMIN_SETTINGS); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, AdminPreferencesActivity.class)); } return true; } return super.onOptionsItemSelected(item); }  @Override void onDestroy(); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); @Override void onCorrectAdminPassword(Action action); @Override void onIncorrectAdminPassword(); }
MainMenuActivity extends CollectAbstractActivity implements AdminPasswordDialogFragment.AdminPasswordDialogCallback { @Override public boolean onOptionsItemSelected(MenuItem item) { if (!MultiClickGuard.allowClick(getClass().getName())) { return true; } switch (item.getItemId()) { case R.id.menu_configure_qr_code: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.SCAN_QR_CODE); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, QRCodeTabsActivity.class)); } return true; case R.id.menu_about: startActivity(new Intent(this, AboutActivity.class)); return true; case R.id.menu_general_preferences: startActivity(new Intent(this, PreferencesActivity.class)); return true; case R.id.menu_admin_preferences: if (adminPasswordProvider.isAdminPasswordSet()) { Bundle args = new Bundle(); args.putSerializable(AdminPasswordDialogFragment.ARG_ACTION, Action.ADMIN_SETTINGS); showIfNotShowing(AdminPasswordDialogFragment.class, args, getSupportFragmentManager()); } else { startActivity(new Intent(this, AdminPreferencesActivity.class)); } return true; } return super.onOptionsItemSelected(item); }  @Override void onDestroy(); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); @Override void onCorrectAdminPassword(Action action); @Override void onIncorrectAdminPassword(); @Inject
    public Analytics analytics; }