List of usage examples for android.app ActionBar DISPLAY_HOME_AS_UP
int DISPLAY_HOME_AS_UP
To view the source code for android.app ActionBar DISPLAY_HOME_AS_UP.
Click Source Link
From source file:com.android.contacts.activities.ActionBarAdapter.java
private void updateDisplayOptionsInner() { // All the flags we may change in this method. final int MASK = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP; // The current flags set to the action bar. (only the ones that we may change here) final int current = mActionBar.getDisplayOptions() & MASK; final boolean isSearchOrSelectionMode = mSearchMode || mSelectionMode; // Build the new flags... int newFlags = 0; if (mShowHomeIcon && !isSearchOrSelectionMode) { newFlags |= ActionBar.DISPLAY_SHOW_HOME; }/* www . ja v a 2 s .co m*/ if (mSearchMode && !mSelectionMode) { // The search container is placed inside the toolbar. So we need to disable the // Toolbar's content inset in order to allow the search container to be the width of // the window. mToolbar.setContentInsetsRelative(0, mToolbar.getContentInsetEnd()); } if (!isSearchOrSelectionMode) { newFlags |= ActionBar.DISPLAY_SHOW_TITLE; mToolbar.setContentInsetsRelative(mMaxToolbarContentInsetStart, mToolbar.getContentInsetEnd()); } if (mSelectionMode) { // Minimize the horizontal width of the Toolbar since the selection container is placed // behind the toolbar and its left hand side needs to be clickable. FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mToolbar.getLayoutParams(); params.width = LayoutParams.WRAP_CONTENT; params.gravity = Gravity.END; mToolbar.setLayoutParams(params); } else { FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mToolbar.getLayoutParams(); params.width = LayoutParams.MATCH_PARENT; params.gravity = Gravity.END; mToolbar.setLayoutParams(params); } if (current != newFlags) { // Pass the mask here to preserve other flags that we're not interested here. mActionBar.setDisplayOptions(newFlags, MASK); } }
From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java
@Override public void setDisplayOptions(int newOpts) { final int oldOpts = mDisplayOpts; final int changed = oldOpts ^ newOpts; mDisplayOpts = newOpts;//from ww w .j a v a2s . c o m if (changed != 0) { if ((changed & ActionBar.DISPLAY_HOME_AS_UP) != 0) { if ((newOpts & ActionBar.DISPLAY_HOME_AS_UP) != 0) { updateNavigationIcon(); updateHomeAccessibility(); } else { mToolbar.setNavigationIcon(null); } } if ((changed & AFFECTS_LOGO_MASK) != 0) { updateToolbarLogo(); } if ((changed & ActionBar.DISPLAY_SHOW_TITLE) != 0) { if ((newOpts & ActionBar.DISPLAY_SHOW_TITLE) != 0) { mToolbar.setTitle(mTitle); mToolbar.setSubtitle(mSubtitle); } else { mToolbar.setTitle(null); mToolbar.setSubtitle(null); } } if ((changed & ActionBar.DISPLAY_SHOW_CUSTOM) != 0 && mCustomView != null) { if ((newOpts & ActionBar.DISPLAY_SHOW_CUSTOM) != 0) { mToolbar.addView(mCustomView); } else { mToolbar.removeView(mCustomView); } } } }
From source file:com.mediatek.galleryfeature.stereo.segment.background.StereoBackgroundActivity.java
private void setActionBarDisplayOptions(ActionBar actionBar, boolean displayHomeAsUp, boolean showTitle) { if (actionBar == null) { return;// w w w . j av a 2s. c om } int options = 0; if (displayHomeAsUp) { options |= ActionBar.DISPLAY_HOME_AS_UP; } if (showTitle) { options |= ActionBar.DISPLAY_SHOW_TITLE; } actionBar.setDisplayOptions(options, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setHomeButtonEnabled(displayHomeAsUp); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setTitle(R.string.m_save); }
From source file:android.support.v7.widget.ToolbarWidgetWrapper.java
private void updateNavigationIcon() { if ((mDisplayOpts & ActionBar.DISPLAY_HOME_AS_UP) != 0) { mToolbar.setNavigationIcon(mNavIcon != null ? mNavIcon : mDefaultNavigationIcon); } else {//from w ww . j av a 2s . co m mToolbar.setNavigationIcon(null); } }
From source file:com.android.settings.HWSettings.java
protected void setActionBarStyle() { ActionBar actionBar = getActionBar(); if (actionBar == null) { return;//www . ja v a2 s .co m } if (this.toString().contains("SubSettings")) { actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); actionBar.setDisplayHomeAsUpEnabled(true); } else { actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP ^ ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); actionBar.setDisplayHomeAsUpEnabled(false); } }
From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java
private void updateHomeAccessibility() { if ((mDisplayOpts & ActionBar.DISPLAY_HOME_AS_UP) != 0) { if (TextUtils.isEmpty(mHomeDescription)) { mToolbar.setNavigationContentDescription(mDefaultNavigationContentDescription); } else {//from w ww . ja v a 2 s . c o m mToolbar.setNavigationContentDescription(mHomeDescription); } } }
From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java
private void updateNavigationIcon() { if ((mDisplayOpts & ActionBar.DISPLAY_HOME_AS_UP) != 0) { mToolbar.setNavigationIcon(mNavIcon != null ? mNavIcon : mDefaultNavigationIcon); }/* ww w . j a v a 2 s.c om*/ }
From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java
private void handleHome(MenuItem item) { FragmentManager fm = getSupportFragmentManager(); if (fm.getBackStackEntryCount() > 0) { fm.popBackStack();//from w w w . jav a 2s . com } else if ((bar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0) { finish(); } }
From source file:com.brandroidtools.filemanager.activities.NavigationActivity.java
/** * {@inheritDoc}//from www . j a v a 2 s . c o m */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { //###################### // Home/Up button //###################### case android.R.id.home: if ((getActionBar().getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) == ActionBar.DISPLAY_HOME_AS_UP) { checkBackAction(); } return true; //###################### // Action Buttons //###################### case R.id.mnu_bookmarks: openBookmarks(); break; case R.id.mnu_history: openHistory(); break; case R.id.mnu_search: openSearch(); break; //- Create new object case R.id.mnu_actions_new_directory: case R.id.mnu_actions_new_file: showInputNameDialog(item); break; // Paste selection case R.id.mnu_actions_paste_selection: if (true) { CopyMoveActionPolicy.triggerCopyMoveFileSystemObjects(NavigationActivity.this, this.onRequestFilesMarkedForPaste(), this.onRequestPasteOperationType(), getCurrentNavigationFragment(), getCurrentNavigationFragment(), NavigationActivity.this); } break; case R.id.mnu_actions_properties_current_folder: openPropertiesDialog(getCurrentNavigationFragment().getCurrentDir()); break; case R.id.mnu_settings: //Settings Intent settings = new Intent(NavigationActivity.this, SettingsPreferences.class); startActivity(settings); break; default: return super.onOptionsItemSelected(item); } return super.onOptionsItemSelected(item); }
From source file:android.app.Activity.java
/** * Default implementation of//from w w w .ja va2s.c om * {@link android.view.Window.Callback#onMenuItemSelected} * for activities. This calls through to the new * {@link #onOptionsItemSelected} method for the * {@link android.view.Window#FEATURE_OPTIONS_PANEL} * panel, so that subclasses of * Activity don't need to deal with feature codes. */ public boolean onMenuItemSelected(int featureId, MenuItem item) { CharSequence titleCondensed = item.getTitleCondensed(); switch (featureId) { case Window.FEATURE_OPTIONS_PANEL: // Put event logging here so it gets called even if subclass // doesn't call through to superclass's implmeentation of each // of these methods below if (titleCondensed != null) { EventLog.writeEvent(50000, 0, titleCondensed.toString()); } if (onOptionsItemSelected(item)) { return true; } if (mFragments.dispatchOptionsItemSelected(item)) { return true; } if (item.getItemId() == android.R.id.home && mActionBar != null && (mActionBar.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != 0) { if (mParent == null) { return onNavigateUp(); } else { return mParent.onNavigateUpFromChild(this); } } return false; case Window.FEATURE_CONTEXT_MENU: if (titleCondensed != null) { EventLog.writeEvent(50000, 1, titleCondensed.toString()); } if (onContextItemSelected(item)) { return true; } return mFragments.dispatchContextItemSelected(item); default: return false; } }