Java Code Examples for androidx.appcompat.app.actionbar#setHomeActionContentDescription()

The following examples show how to use androidx.appcompat.app.actionbar#setHomeActionContentDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateExperimentFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.menu_update_experiment, menu);

  ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
  actionBar.setHomeActionContentDescription(android.R.string.cancel);

  super.onCreateOptionsMenu(menu, inflater);
}
 
Example 2
Source File: ClaimExperimentsActivity.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_claim_experiments);
  boolean isTablet = getResources().getBoolean(R.bool.is_tablet);
  if (!isTablet) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }

  AppAccount claimingAccount =
      WhistlePunkApplication.getAccount(this, getIntent(), ARG_ACCOUNT_KEY);

  ActionBar actionBar = getSupportActionBar();
  actionBar.setHomeAsUpIndicator(
      ColorUtils.colorDrawable(
          this,
          ContextCompat.getDrawable(this, R.drawable.ic_close_white_24dp),
          R.color.claim_experiments_action_bar_text));
  actionBar.setHomeActionContentDescription(android.R.string.cancel);
  actionBar.setTitle(getString(R.string.title_activity_claim_experiments));
  actionBar.setSubtitle(claimingAccount.getAccountName());

  if (getSupportFragmentManager().findFragmentByTag(FRAGMENT_TAG) == null) {
    Fragment fragment =
        ExperimentListFragment.newInstanceForClaimExperimentsMode(
            this, claimingAccount, getIntent().getBooleanExtra(ARG_USE_PANES, true));
    getSupportFragmentManager()
        .beginTransaction()
        .add(R.id.container, fragment, FRAGMENT_TAG)
        .commit();
  }
}
 
Example 3
Source File: UpdateRunFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.menu_update_run, menu);

  ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  actionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
  actionBar.setHomeActionContentDescription(android.R.string.cancel);

  super.onCreateOptionsMenu(menu, inflater);
}
 
Example 4
Source File: LabelDetailsFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();

  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24dp);
  actionBar.setHomeActionContentDescription(R.string.action_save);

  super.onCreateOptionsMenu(menu, inflater);
}
 
Example 5
Source File: EditTriggerFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.menu_edit_trigger, menu);

  ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  if (isNewTrigger()) {
    actionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
    actionBar.setHomeActionContentDescription(android.R.string.cancel);
  }

  menu.findItem(R.id.action_save).setVisible(isNewTrigger());
  menu.findItem(R.id.action_save).setEnabled(!isSavingNewTrigger);

  SensorAppearance appearance =
      AppSingleton.getInstance(getActivity())
          .getSensorAppearanceProvider(appAccount)
          .getAppearance(sensorId);
  String triggerTitle =
      getString(
          isNewTrigger()
              ? R.string.title_fragment_add_trigger
              : R.string.title_fragment_edit_trigger);
  actionBar.setTitle(String.format(triggerTitle, appearance.getName(getActivity())));

  super.onCreateOptionsMenu(menu, inflater);
}
 
Example 6
Source File: MainActivity.java    From science-journal with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  savedItemId =
      (savedInstanceState == null)
          ? NO_SELECTED_ITEM
          : savedInstanceState.getInt(ARG_SELECTED_NAV_ITEM_ID, NO_SELECTED_ITEM);

  WhistlePunkApplication.getPerfTrackerProvider(this).onActivityInit();

  accountsProvider = WhistlePunkApplication.getAppServices(this).getAccountsProvider();

  setContentView(R.layout.activity_main);
  accountsProvider.installAccountSwitcher(this);

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  boolean isTablet = getResources().getBoolean(R.bool.is_tablet);
  if (!isTablet) {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  }

  final ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
    actionBar.setHomeActionContentDescription(R.string.navigation_drawer_content_description);
    actionBar.setDisplayShowTitleEnabled(true);
  }

  drawerLayout = (MultiTouchDrawerLayout) findViewById(R.id.drawer_layout);
  drawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.color_primary_dark));
  navigationView = (NavigationView) findViewById(R.id.navigation);
  navigationView.setNavigationItemSelectedListener(this);

  // Only show dev testing options when requested.
  if (!Flags.showTestingOptions()) {
    navigationView.getMenu().removeItem(R.id.dev_testing_options);
  }

  feedbackProvider = WhistlePunkApplication.getAppServices(this).getFeedbackProvider();

  setVolumeControlStream(AudioManager.STREAM_MUSIC);
}