List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled
public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
public void updateActionBar() { final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(true); final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE); actionBar.setDisplayHomeAsUpEnabled(showIndicator); if (mDrawerToggle != null) { mDrawerToggle.setDrawerIndicatorEnabled(showIndicator); }//from w ww. j a va 2 s . c om if (isRootsDrawerOpen()) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setIcon(new ColorDrawable()); if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { actionBar.setTitle(R.string.title_open); } else if (mState.action == ACTION_CREATE) { actionBar.setTitle(R.string.title_save); } } else { final RootInfo root = getCurrentRoot(); actionBar.setIcon(root != null ? root.loadIcon(this) : null); if (mState.stack.size() <= 1) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(root.title); } else { mIgnoreNextNavigation = true; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setTitle(null); actionBar.setListNavigationCallbacks(mStackAdapter, mStackListener); actionBar.setSelectedNavigationItem(mStackAdapter.getCount() - 1); } } }
From source file:fr.paug.droidcon.ui.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AnalyticsManager.initializeAnalyticsTracker(getApplicationContext()); PrefUtils.init(this); // // Check if the EULA has been accepted; if not, show it. // if (!PrefUtils.isTosAccepted(this)) { // Intent intent = new Intent(this, WelcomeActivity.class); // startActivity(intent); // finish(); // }//from w ww . j a v a 2 s . c o m mImageLoader = new ImageLoader(this); mHandler = new Handler(); // Enable or disable each Activity depending on the form factor. This is necessary // because this app uses many implicit intents where we don't name the exact Activity // in the Intent, so there should only be one enabled Activity that handles each // Intent in the app. UIUtils.enableDisableActivitiesByFormFactor(this); if (savedInstanceState == null) { registerGCMClient(); } SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); sp.registerOnSharedPreferenceChangeListener(this); ActionBar ab = getActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } mLPreviewUtils = LPreviewUtils.getInstance(this); mThemedStatusBarColor = getResources().getColor(R.color.theme_primary_dark); }
From source file:com.tweetlanes.android.core.view.HomeActivity.java
private boolean configureListNavigation() { if (mSpinnerAdapter == null) { return false; }/*from w w w . j a v a2s. co m*/ ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); int accountIndex = 0; AccountDescriptor currentAccount = getApp().getCurrentAccount(); if (currentAccount != null) { for (int i = 0; i < getApp().getAccounts().size(); i++) { if (currentAccount.getAccountKey().equals(getApp().getAccounts().get(i).getAccountKey())) { accountIndex = i; break; } } } actionBar.setSelectedNavigationItem(accountIndex); actionBar.setDisplayHomeAsUpEnabled(false); return true; }
From source file:com.tweetlanes.android.view.HomeActivity.java
private boolean configureListNavigation() { if (mSpinnerAdapter == null) { return false; }//from w w w.j a v a 2s.c o m ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); int accountIndex = 0; AccountDescriptor currentAccount = getApp().getCurrentAccount(); if (currentAccount != null) { String testScreenName = "@" + currentAccount.getScreenName().toLowerCase(); for (int i = 0; i < mAdapterStrings.length; i++) { if (testScreenName.equals(mAdapterStrings[i].toLowerCase())) { accountIndex = i; break; } } } actionBar.setSelectedNavigationItem(accountIndex); actionBar.setDisplayHomeAsUpEnabled(false); return true; }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
@Override @TargetApi(11)//from w w w.j av a 2s . c om public void onCreate(Bundle icicle) { super.onCreate(icicle); if (!InstallMosh.isInstallStarted()) { new InstallMosh(this); } configureStrictMode(); hardKeyboard = getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY; hardKeyboard = hardKeyboard && !Build.MODEL.contains("Transformer"); this.setContentView(R.layout.act_console); BugSenseHandler.setup(this, "d27a12dc"); clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); prefs = PreferenceManager.getDefaultSharedPreferences(this); // hide action bar if requested by user try { ActionBar actionBar = getActionBar(); if (!prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) { actionBar.hide(); } actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); } catch (NoSuchMethodError error) { Log.w(TAG, "Android sdk version pre 11. Not touching ActionBar."); } // hide status bar if requested by user if (prefs.getBoolean(PreferenceConstants.FULLSCREEN, false)) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } // TODO find proper way to disable volume key beep if it exists. setVolumeControlStream(AudioManager.STREAM_MUSIC); // handle requested console from incoming intent requested = getIntent().getData(); inflater = LayoutInflater.from(this); flip = (ViewFlipper) findViewById(R.id.console_flip); empty = (TextView) findViewById(android.R.id.empty); stringPromptGroup = (RelativeLayout) findViewById(R.id.console_password_group); stringPromptInstructions = (TextView) findViewById(R.id.console_password_instructions); stringPrompt = (EditText) findViewById(R.id.console_password); stringPrompt.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_UP) return false; if (keyCode != KeyEvent.KEYCODE_ENTER) return false; // pass collected password down to current terminal String value = stringPrompt.getText().toString(); PromptHelper helper = getCurrentPromptHelper(); if (helper == null) return false; helper.setResponse(value); // finally clear password for next user stringPrompt.setText(""); updatePromptVisible(); return true; } }); booleanPromptGroup = (RelativeLayout) findViewById(R.id.console_boolean_group); booleanPrompt = (TextView) findViewById(R.id.console_prompt); booleanYes = (Button) findViewById(R.id.console_prompt_yes); booleanYes.setOnClickListener(new OnClickListener() { public void onClick(View v) { PromptHelper helper = getCurrentPromptHelper(); if (helper == null) return; helper.setResponse(Boolean.TRUE); updatePromptVisible(); } }); booleanNo = (Button) findViewById(R.id.console_prompt_no); booleanNo.setOnClickListener(new OnClickListener() { public void onClick(View v) { PromptHelper helper = getCurrentPromptHelper(); if (helper == null) return; helper.setResponse(Boolean.FALSE); updatePromptVisible(); } }); // preload animations for terminal switching slide_left_in = AnimationUtils.loadAnimation(this, R.anim.slide_left_in); slide_left_out = AnimationUtils.loadAnimation(this, R.anim.slide_left_out); slide_right_in = AnimationUtils.loadAnimation(this, R.anim.slide_right_in); slide_right_out = AnimationUtils.loadAnimation(this, R.anim.slide_right_out); fade_out_delayed = AnimationUtils.loadAnimation(this, R.anim.fade_out_delayed); fade_stay_hidden = AnimationUtils.loadAnimation(this, R.anim.fade_stay_hidden); // Preload animation for keyboard button keyboard_fade_in = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_in); keyboard_fade_out = AnimationUtils.loadAnimation(this, R.anim.keyboard_fade_out); inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); final RelativeLayout keyboardGroup = (RelativeLayout) findViewById(R.id.keyboard_group); if (Build.MODEL.contains("Transformer") && getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY && prefs.getBoolean(PreferenceConstants.ACTIONBAR, true)) { keyboardGroup.setEnabled(false); keyboardGroup.setVisibility(View.INVISIBLE); } mKeyboardButton = (ImageView) findViewById(R.id.button_keyboard); mKeyboardButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED); keyboardGroup.setVisibility(View.GONE); } }); final ImageView symButton = (ImageView) findViewById(R.id.button_sym); symButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.showCharPickerDialog(terminal); keyboardGroup.setVisibility(View.GONE); } }); mInputButton = (ImageView) findViewById(R.id.button_input); mInputButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; final TerminalView terminal = (TerminalView) flip; Thread promptThread = new Thread(new Runnable() { public void run() { String inj = getCurrentPromptHelper().requestStringPrompt(null, ""); terminal.bridge.injectString(inj); } }); promptThread.setName("Prompt"); promptThread.setDaemon(true); promptThread.start(); keyboardGroup.setVisibility(View.GONE); } }); final ImageView ctrlButton = (ImageView) findViewById(R.id.button_ctrl); ctrlButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.metaPress(TerminalKeyListener.META_CTRL_ON); terminal.bridge.tryKeyVibrate(); keyboardGroup.setVisibility(View.GONE); } }); final ImageView escButton = (ImageView) findViewById(R.id.button_esc); escButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.sendEscape(); terminal.bridge.tryKeyVibrate(); keyboardGroup.setVisibility(View.GONE); } }); // detect fling gestures to switch between terminals final GestureDetector detect = new GestureDetector(new ICBSimpleOnGestureListener(this)); flip.setLongClickable(true); flip.setOnTouchListener(new ICBOnTouchListener(this, keyboardGroup, detect)); }
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.subredditselect); // load personal list from saved prefereces, if null use default and save mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(SubredditSelectActivity.this); global = ((GlobalObjects) SubredditSelectActivity.this.getApplicationContext()); // get subreddit list and set adapter subredditList = global.getSubredditManager().getSubredditNames(); subsAdapter = new MySubredditsAdapter(this, subredditList); ListView subListView = (ListView) findViewById(R.id.sublist); subListView.setAdapter(subsAdapter); subListView.setTextFilterEnabled(true); subListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String subreddit = ((TextView) view.findViewById(R.id.subreddit_name)).getText().toString(); global.getSubredditManager().setFeedSubreddit(mAppWidgetId, subreddit); updateFeedAndFinish();// w w w. ja v a 2s . co m //System.out.println(sreddit+" selected"); } }); subsAdapter.sort(new Comparator<String>() { @Override public int compare(String s, String t1) { return s.compareToIgnoreCase(t1); } }); // get multi list and set adapter mMultiAdapter = new MyMultisAdapter(this); ListView multiListView = (ListView) findViewById(R.id.multilist); multiListView.setAdapter(mMultiAdapter); multiListView.setTextFilterEnabled(true); multiListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == mMultiAdapter.getCount() - 1) { LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_multi_add, parent, false); final EditText name = (EditText) layout.findViewById(R.id.new_multi_name); AlertDialog.Builder builder = new AlertDialog.Builder(SubredditSelectActivity.this); builder.setTitle("Create A Multi").setView(layout) .setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (name.getText().toString().equals("")) { Toast.makeText(SubredditSelectActivity.this, "Please enter a name for the multi", Toast.LENGTH_LONG).show(); return; } new SubscriptionEditTask(SubscriptionEditTask.ACTION_MULTI_CREATE) .execute(name.getText().toString()); dialogInterface.dismiss(); } }).show(); } else { JSONObject multiObj = mMultiAdapter.getItem(position); try { String name = multiObj.getString("display_name"); String path = multiObj.getString("path"); global.getSubredditManager().setFeed(mAppWidgetId, name, path, true); updateFeedAndFinish(); } catch (JSONException e) { e.printStackTrace(); Toast.makeText(SubredditSelectActivity.this, "Error setting multi.", Toast.LENGTH_LONG) .show(); } } } }); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { mAppWidgetId = 0; // Id of 4 zeros indicates its the app view, not a widget, that is being updated } else { String action = getIntent().getAction(); widgetFirstTimeSetup = action != null && action.equals("android.appwidget.action.APPWIDGET_CONFIGURE"); } } else { mAppWidgetId = 0; } final ViewPager pager = (ViewPager) findViewById(R.id.pager); pager.setAdapter(new SimpleTabsAdapter(new String[] { "My Subreddits", "My Multis" }, new int[] { R.id.sublist, R.id.multilist }, SubredditSelectActivity.this, null)); LinearLayout tabsLayout = (LinearLayout) findViewById(R.id.tab_widget); tabs = new SimpleTabsWidget(SubredditSelectActivity.this, tabsLayout); tabs.setViewPager(pager); addButton = (Button) findViewById(R.id.addsrbutton); addButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(SubredditSelectActivity.this, ViewAllSubredditsActivity.class); startActivityForResult(intent, 1); } }); refreshButton = (Button) findViewById(R.id.refreshloginbutton); refreshButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (global.mRedditData.isLoggedIn()) { if (pager.getCurrentItem() == 1) { refreshMultireddits(); } else { refreshSubreddits(); } } else { global.mRedditData.initiateLogin(SubredditSelectActivity.this); } } }); // sort button sortBtn = (Button) findViewById(R.id.sortselect); String sortTxt = "Sort: " + mSharedPreferences.getString("sort-" + (mAppWidgetId == 0 ? "app" : mAppWidgetId), "hot"); sortBtn.setText(sortTxt); sortBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { showSortDialog(); } }); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } // set theme colors setThemeColors(); GlobalObjects.doShowWelcomeDialog(SubredditSelectActivity.this); }
From source file:me.albertonicoletti.latex.activities.EditorActivity.java
/** * Initializes the navigation drawer.//from w w w . j av a 2s . co m */ private void initDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); /* Recycler View containing the open documents */ RecyclerView mDrawerList = (RecyclerView) findViewById(R.id.left_drawer); mDrawerList.setHasFixedSize(true); // Sets the layout manager /* Recycler View layout manager */ RecyclerView.LayoutManager documentsLayoutManager = new LinearLayoutManager(this); mDrawerList.setLayoutManager(documentsLayoutManager); documentsAdapter = new DocumentsAdapter(documentsToFiles(), new DocumentClickListener(this), DocumentsAdapter.DRAWER); mDrawerList.setAdapter(documentsAdapter); mDrawerLayout.openDrawer(GravityCompat.START); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setTitle(document.getName()); } } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setTitle("Choose File"); } } }; // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); } }
From source file:dev.dworks.apps.anexplorer.DocumentsActivity.java
public void updateActionBar() { final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(true); final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE); actionBar.setDisplayHomeAsUpEnabled(showIndicator); if (mDrawerToggle != null) { mDrawerToggle.setDrawerIndicatorEnabled(showIndicator); }//from w w w . ja va 2 s . co m if (isRootsDrawerOpen()) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setIcon(new ColorDrawable()); if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT || mState.action == ACTION_BROWSE) { actionBar.setTitle(R.string.app_name); actionBar.setIcon(R.drawable.ic_launcher); } else if (mState.action == ACTION_CREATE) { actionBar.setTitle(R.string.title_save); } } else { final RootInfo root = getCurrentRoot(); //actionBar.setIcon(root != null ? root.loadIcon(this) : null); if (mState.stack.size() <= 1) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(root.title); } else { mIgnoreNextNavigation = true; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setTitle(null); actionBar.setListNavigationCallbacks(mStackAdapter, mStackListener); actionBar.setSelectedNavigationItem(mStackAdapter.getCount() - 1); } } }
From source file:com.shafiq.mytwittle.view.HomeActivity.java
private boolean configureListNavigation() { if (mSpinnerAdapter == null) { return false; }//from ww w . j a v a 2 s . co m ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); int accountIndex = 0; AccountDescriptor currentAccount = getApp().getCurrentAccount(); if (currentAccount != null) { String testScreenName = "@" + currentAccount.getScreenName() + (currentAccount.getSocialNetType() == SocialNetConstant.Type.Appdotnet ? " (App.net)" : " (Twitter)"); for (int i = 0; i < mAdapterStrings.length; i++) { if (testScreenName.toLowerCase().equals(mAdapterStrings[i].toLowerCase())) { accountIndex = i; break; } } } actionBar.setSelectedNavigationItem(accountIndex); actionBar.setDisplayHomeAsUpEnabled(false); return true; }
From source file:com.android.contacts.activities.DialtactsActivity.java
/** * Hides every tab and shows search UI for phone lookup. *//*w ww. ja v a2s. com*/ private void enterSearchUi() { if (mSearchFragment == null) { // We add the search fragment dynamically in the first onLayoutChange() and // mSearchFragment is set sometime later when the fragment transaction is actually // executed, which means there's a window when users are able to hit the (physical) // search key but mSearchFragment is still null. // It's quite hard to handle this case right, so let's just ignore the search key // in this case. Users can just hit it again and it will work this time. return; } if (mSearchView == null) { prepareSearchView(); } final ActionBar actionBar = getActionBar(); final Tab tab = actionBar.getSelectedTab(); // User can search during the call, but we don't want to remember the status. if (tab != null && !DialpadFragment.phoneIsInUse()) { mLastManuallySelectedFragment = tab.getPosition(); } mSearchView.setQuery(null, true); actionBar.setDisplayShowCustomEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); updateFakeMenuButtonsVisibility(false); for (int i = 0; i < TAB_INDEX_COUNT; i++) { sendFragmentVisibilityChange(i, false /* not visible */ ); } // Show the search fragment and hide everything else. mSearchFragment.setUserVisibleHint(true); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.show(mSearchFragment); transaction.commitAllowingStateLoss(); mViewPager.setVisibility(View.GONE); // We need to call this and onActionViewCollapsed() manually, since we are using a custom // layout instead of asking the search menu item to take care of SearchView. mSearchView.onActionViewExpanded(); mInSearchUi = true; }