Java Code Examples for android.app.ActionBar#setHomeButtonEnabled()

The following examples show how to use android.app.ActionBar#setHomeButtonEnabled() . 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: SomeActivity.java    From something.apk with MIT License 6 votes vote down vote up
private void configureActionbar(){
    ActionBar bar = getActionBar();
    bar.setHomeButtonEnabled(true);
    bar.setDisplayShowHomeEnabled(false);

    tint = new SystemBarTintManager(this);
    TypedValue tintColor = new TypedValue();
    if(getTheme().resolveAttribute(R.attr.statusBarBackground, tintColor, true)){
        tint.setStatusBarTintEnabled(true);
        tint.setTintColor(tintColor.data);
        defaultActionbarColor = tintColor.data;
        currentActionbarColor = tintColor.data;
    }else{
        tint.setStatusBarTintEnabled(false);
    }

    TypedValue actionbarBackground = new TypedValue();
    if(getTheme().resolveAttribute(R.attr.actionbarBackgroundLayerList, actionbarBackground, false)){
        actionbarBackgroundList = (LayerDrawable) getResources().getDrawable(actionbarBackground.data);
        actionbarBackgroundList.mutate();
        actionbarColor = (ColorDrawable) actionbarBackgroundList.findDrawableByLayerId(R.id.actionbar_background_color);
        actionbarColor.mutate();
        bar.setBackgroundDrawable(actionbarBackgroundList);
    }

}
 
Example 2
Source File: RootActivity.java    From Mortar-Flow-Dagger2-demo with MIT License 6 votes vote down vote up
@Override
public void dispatch(Flow.Traversal traversal, final Flow.TraversalCallback callback) {
    Path path = traversal.destination.top();
    setTitle(path.getClass().getSimpleName());
    ActionBar actionBar = getActionBar();
    boolean canGoBack = traversal.destination.size() > 1;
    actionBar.setDisplayHomeAsUpEnabled(canGoBack);
    actionBar.setHomeButtonEnabled(canGoBack);

    pathContainerView.dispatch(traversal, new Flow.TraversalCallback() {
        @Override
        public void onTraversalCompleted() {
            invalidateOptionsMenu();
            callback.onTraversalCompleted();
        }
    });
}
 
Example 3
Source File: FileChooserActivity.java    From qiniu-lab-android with MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (HAS_ACTIONBAR) {
        boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0;

        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(hasBackStack);
        actionBar.setHomeButtonEnabled(hasBackStack);
    }

    return true;
}
 
Example 4
Source File: ThirdActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	// enable the home button
	ActionBar actionBar = getActionBar();
	actionBar.setHomeButtonEnabled(true);
}
 
Example 5
Source File: Preferences.java    From XInstaller with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onStop() {
    getActivity().setTitle(oldTitle);
    ActionBar ab = getActivity().getActionBar();
    if (ab != null && oldTitle.equals(getString(R.string.app_name))) {
        ab.setDisplayHomeAsUpEnabled(false);
        ab.setHomeButtonEnabled(false);
    }
    getActivity().invalidateOptionsMenu();
    super.onStop();
}
 
Example 6
Source File: MainActivity.java    From Qshp with MIT License 5 votes vote down vote up
private void initActionBar() {
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
    }
}
 
Example 7
Source File: FileChooserActivity.java    From Readily with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (HAS_ACTIONBAR) {
        boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0;

        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(hasBackStack);
        actionBar.setHomeButtonEnabled(hasBackStack);
    }

    return true;
}
 
Example 8
Source File: SettingsActivity.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    final Intent intent = getIntent();
    if (actionBar != null) {
        mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
        actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
        actionBar.setHomeButtonEnabled(mShowHomeAsUp);
    }
    StatsUtils.onSettingsActivity(
            intent.hasExtra(EXTRA_ENTRY_KEY) ? intent.getStringExtra(EXTRA_ENTRY_KEY)
                    : EXTRA_ENTRY_VALUE_SYSTEM_SETTINGS);
}
 
Example 9
Source File: PreferencesActivity.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setTitle(R.string.preferences);
		
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayShowTitleEnabled(true);
		actionBar.setDisplayShowHomeEnabled(true);
		actionBar.setDisplayHomeAsUpEnabled(false);
		actionBar.setHomeButtonEnabled(true);
		actionBar.setLogo(this.getResources().getDrawable(R.drawable.ic_action_up));
		actionBar.setDisplayUseLogoEnabled(true);
		
		addPreferencesFromResource(R.xml.preferences);
		
//		lockScreenMode = (ListPreference) findPreference(Preferences.Keys.LOCK_SCREEN_MODE);
//		updateSummaryWithChoice(lockScreenMode, lockScreenMode.getValue(), getResources().getStringArray(R.array.lockScreenOptions_));

		language = (ListPreference) findPreference(Preferences.Keys.LANGUAGE);
		updateSummaryWithChoice(language, language.getValue(), getResources().getStringArray(R.array.languages_));
		
		//originalImage = (ListPreference) findPreference(Models.IUser.ASSET_ENCRYPTION);
		//updateSummaryWithChoice(originalImage, originalImage.getValue(), getResources().getStringArray(R.array.originalImageOptions_));

		panicAction = (ListPreference) findPreference(Preferences.Keys.PANIC_ACTION);
		updateSummaryWithChoice(panicAction, panicAction.getValue(), getResources().getStringArray(R.array.panicActionOptions_));
	}
 
Example 10
Source File: PreviewActivity.java    From something.apk with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reply_preview_activity);
    ActionBar ab = getActionBar();
    if(ab != null){
        ab.setHomeButtonEnabled(true);
        ab.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 11
Source File: MaterialMenuIcon.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override @TargetApi(14)
protected void setActionBarSettings(Activity activity) {
    ActionBar actionBar = activity.getActionBar();
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setIcon(getDrawable());
}
 
Example 12
Source File: SettingsActivity.java    From bluetooth-spp-terminal with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings_activity);

    final ActionBar bar = getActionBar();
    bar.setHomeButtonEnabled(true);
    bar.setDisplayHomeAsUpEnabled(true);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.registerOnSharedPreferenceChangeListener(this);
    setPrefenceTitle(getString(R.string.pref_commands_mode));
    setPrefenceTitle(getString(R.string.pref_checksum_mode));
    setPrefenceTitle(getString(R.string.pref_commands_ending));
}
 
Example 13
Source File: FileChooserActivity.java    From filechooser with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (HAS_ACTIONBAR) {
        boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0;

        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(hasBackStack);
        actionBar.setHomeButtonEnabled(hasBackStack);
    }

    return true;
}
 
Example 14
Source File: HomeActivity.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
private void resetActionBar()
{
	ActionBar actionBar = getActionBar();
	actionBar.setDisplayShowTitleEnabled(true);
	actionBar.setTitle(R.string.app_name);
	actionBar.setDisplayShowHomeEnabled(true);
	actionBar.setDisplayHomeAsUpEnabled(false);
	actionBar.setHomeButtonEnabled(true);
	actionBar.setIcon(R.mipmap.ic_launcher);
	actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
 
Example 15
Source File: Preferences.java    From XInstaller with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, parent, savedInstanceState);

    WebView v = new WebView(getActivity());

    ActionBar ab = getActivity().getActionBar();
    if (ab != null) {
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setHomeButtonEnabled(true);
    }
    return v;
}
 
Example 16
Source File: MainActivity.java    From mOrgAnd with GNU General Public License v2.0 5 votes vote down vote up
private ActionBar initActionbar() {
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setHomeButtonEnabled(true);
    //actionBar.setDisplayHomeAsUpEnabled(false);
    return actionBar;
}
 
Example 17
Source File: SettingsActivity.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedState) {
    super.onCreate(savedState);
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }
}
 
Example 18
Source File: EditNoteActivity.java    From droitatedDB with Apache License 2.0 4 votes vote down vote up
private void initHome() {
	ActionBar actionBar = getActionBar();
	actionBar.setDisplayHomeAsUpEnabled(true);
	actionBar.setHomeButtonEnabled(true);
}
 
Example 19
Source File: CompatibilityImpl.java    From Overchan-Android with GNU General Public License v3.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static void setHomeButtonEnabledTrue(ActionBar actionBar) {
    actionBar.setHomeButtonEnabled(true);
}
 
Example 20
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab()
                        .setText(mAppSectionsPagerAdapter.getPageTitle(i))
                        .setTabListener(this));
    }
}