Example usage for android.app ActionBar DISPLAY_HOME_AS_UP

List of usage examples for android.app ActionBar DISPLAY_HOME_AS_UP

Introduction

In this page you can find the example usage for android.app ActionBar DISPLAY_HOME_AS_UP.

Prototype

int DISPLAY_HOME_AS_UP

To view the source code for android.app ActionBar DISPLAY_HOME_AS_UP.

Click Source Link

Document

Display the 'home' element such that it appears as an 'up' affordance.

Usage

From source file:se.toxbee.sleepfighter.activity.EditGPSFilterAreaActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
    String name = this.printName();

    if (Build.VERSION.SDK_INT >= 11) {
        // add the custom view to the action bar.
        ActionBar actionBar = getActionBar();
        actionBar.setCustomView(R.layout.gpsfilter_area_actionbar);
        actionBar.setDisplayOptions(// w ww .java2  s . c  o  m
                ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);

        View customView = actionBar.getCustomView();

        // Setup edit name component.
        EditText editNameView = (EditText) customView.findViewById(R.id.edit_gpsfilter_area_title_edit);
        editNameView.setText(name);
        editNameView.setOnEditorActionListener(new OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                area.setName(GPSFilterTextUtils.printName(getResources(), v.getText().toString()));
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                return false;
            }
        });
        editNameView.clearFocus();

        // Setup enabled switch.
        CompoundButton activatedSwitch = (CompoundButton) customView
                .findViewById(R.id.edit_gpsfilter_area_toggle);
        activatedSwitch.setChecked(this.area.isEnabled());
        activatedSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                area.setEnabled(isChecked);
            }
        });
    } else {
        this.setTitle(name);
    }
}

From source file:com.tct.email.activity.setup.EmailPreferenceActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Intent i = getIntent();
    if (savedInstanceState == null) {
        // If we are not restarting from a previous instance, we need to
        // figure out the initial prefs to show.  (Otherwise, we want to
        // continue showing whatever the user last selected.)
        if (INTENT_ACCOUNT_MANAGER_ENTRY == null) {
            INTENT_ACCOUNT_MANAGER_ENTRY = getString(R.string.intent_account_manager_entry);
        }// ww  w .j  a  v a  2  s  . com
        if (INTENT_ACCOUNT_MANAGER_ENTRY.equals(i.getAction())) {
            // This case occurs if we're changing account settings from Settings -> Accounts.
            // We get an account object in the intent, but it's not actually useful to us since
            // it's always just the first account of that type. The user can't specify which
            // account they wish to view from within the settings UI, so just dump them at the
            // main screen.
            // android.accounts.Account acct = i.getParcelableExtra("account");
        } else if (i.hasExtra(EditSettingsExtras.EXTRA_FOLDER)) {
            throw new IllegalArgumentException("EXTRA_FOLDER is no longer supported");
        } else {
            // Otherwise, we're called from within the Email app and look for our extras
            final long accountId = IntentUtilities.getAccountIdFromIntent(i);
            if (accountId != -1) {
                final Bundle args = AccountSettingsFragment.buildArguments(accountId);
                startPreferencePanel(AccountSettingsFragment.class.getName(), args, 0, null, null, 0);
                // TS: jin.dong 2015-08-07 EMAIL BUGFIX_989528 ADD_S
                finish();
                return;
                // TS: jin.dong 2015-08-07 EMAIL BUGFIX_989528 ADD_E
            }
        }
    }
    mShowDebugMenu = i.getBooleanExtra(EXTRA_ENABLE_DEBUG, false);

    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
    }
    ListView listView = getListView();
    if (listView != null) {
        listView.setDivider(new ColorDrawable(Color.GRAY));
        listView.setDividerHeight(1);
    }
    mFeedbackUri = Utils.getValidUri(getString(R.string.email_feedback_uri));
}

From source file:com.android.contacts.activities.ContactDetailActivity.java

/** @} */

@Override/*w  w w. j av a 2  s .  co  m*/
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    LogUtils.i(TAG, "[onCreate][launch]start");
    ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet
    registerPHBReceiver();
    mIsActivitFinished = false;
    /** M: Bug Fix for ALPS00393950 @{ */
    boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this);
    if (!isUsingTwoPanes) {
        SetIndicatorUtils.getInstance().registerReceiver(this);
    }
    /** @} */
    if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        // This activity must not be shown. We have to select the contact in the
        // PeopleActivity instead ==> Create a forward intent and finish
        final Intent originalIntent = getIntent();
        Intent intent = new Intent();
        intent.setAction(originalIntent.getAction());
        intent.setDataAndType(originalIntent.getData(), originalIntent.getType());

        // If we are launched from the outside, we should create a new task, because the user
        // can freely navigate the app (this is different from phones, where only the UP button
        // kicks the user into the full app)
        if (shouldUpRecreateTask(intent)) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        } else {
            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }
        intent.setClass(this, PeopleActivity.class);
        startActivity(intent);
        LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity..");
        finish();
        return;
    }

    setContentView(R.layout.contact_detail_activity);

    mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(),
            null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener);

    // We want the UP affordance but no app icon.
    // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick.
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        ///@Modify for add Customer view{
        actionBar.setDisplayOptions(
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM,
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
                        | ActionBar.DISPLAY_SHOW_CUSTOM);
        ///@}
        actionBar.setTitle("");
    }

    Log.i(TAG, getIntent().getData().toString());
    /** M: New Feature xxx @{ */
    //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE
    if (getIntent() != null && getIntent().getData() != null) {
        mSimOrPhoneUri = getIntent().getData();
        Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri);
    } else {
        Log.e(TAG, "Get intent data error getIntent() = " + getIntent());
    }
    /// M: @ CT contacts detail history set listener{
    ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(),
            ContactPluginDefault.COMMD_FOR_OP09);
    /// @}
    LogUtils.i(TAG, "[onCreate][launch]end");
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    fabSkin = PreferenceUtils.getAccentString(Sp);

    int th = Integer.parseInt(Sp.getString("theme", "0"));

    theme = th == 2 ? PreferenceUtils.hourOfDay() : th;

    // setting accent theme
    if (Build.VERSION.SDK_INT >= 21) {

        switch (fabSkin) {
        case "#F44336":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_red);
            else//w  w w  .j  a  v  a  2 s.  com
                setTheme(R.style.pref_accent_dark_red);
            break;

        case "#e91e63":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_pink);
            else
                setTheme(R.style.pref_accent_dark_pink);
            break;

        case "#9c27b0":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_purple);
            else
                setTheme(R.style.pref_accent_dark_purple);
            break;

        case "#673ab7":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_purple);
            else
                setTheme(R.style.pref_accent_dark_deep_purple);
            break;

        case "#3f51b5":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_indigo);
            else
                setTheme(R.style.pref_accent_dark_indigo);
            break;

        case "#2196F3":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue);
            else
                setTheme(R.style.pref_accent_dark_blue);
            break;

        case "#03A9F4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_blue);
            else
                setTheme(R.style.pref_accent_dark_light_blue);
            break;

        case "#00BCD4":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_cyan);
            else
                setTheme(R.style.pref_accent_dark_cyan);
            break;

        case "#009688":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_teal);
            else
                setTheme(R.style.pref_accent_dark_teal);
            break;

        case "#4CAF50":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_green);
            else
                setTheme(R.style.pref_accent_dark_green);
            break;

        case "#8bc34a":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_light_green);
            else
                setTheme(R.style.pref_accent_dark_light_green);
            break;

        case "#FFC107":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_amber);
            else
                setTheme(R.style.pref_accent_dark_amber);
            break;

        case "#FF9800":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_orange);
            else
                setTheme(R.style.pref_accent_dark_orange);
            break;

        case "#FF5722":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_deep_orange);
            else
                setTheme(R.style.pref_accent_dark_deep_orange);
            break;

        case "#795548":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_brown);
            else
                setTheme(R.style.pref_accent_dark_brown);
            break;

        case "#212121":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_black);
            else
                setTheme(R.style.pref_accent_dark_black);
            break;

        case "#607d8b":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_blue_grey);
            else
                setTheme(R.style.pref_accent_dark_blue_grey);
            break;

        case "#004d40":
            if (theme == 0)
                setTheme(R.style.pref_accent_light_super_su);
            else
                setTheme(R.style.pref_accent_dark_super_su);
            break;
        }
    } else {
        if (theme == 1) {
            setTheme(R.style.appCompatDark);
        } else {
            setTheme(R.style.appCompatLight);
        }
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    skin = PreferenceUtils.getPrimaryColorString(Sp);
    if (Build.VERSION.SDK_INT >= 21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze",
                ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(),
                Color.parseColor(skin));
        ((Activity) this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_HOME_AS_UP
            | android.support.v7.app.ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    int sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        boolean colourednavigation = Sp.getBoolean("colorednavigation", true);
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor((PreferenceUtils.getStatusColor(skin)));
        if (colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }
    selectItem(0);
}

From source file:com.dnielfe.manager.Browser.java

private void initActionBar() {
    mActionBar = this.getActionBar();
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM
            | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP);

    // set custom ActionBar layout
    final View mActionView = getLayoutInflater().inflate(R.layout.activity_browser_actionbar, null);
    mActionBar.setCustomView(mActionView);
    mActionBar.show();/*from   w  ww .jav a 2  s  . co m*/
}

From source file:android.support.v7.widget.ToolbarWidgetWrapper.java

private int detectDisplayOptions() {
    int opts = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO;
    if (mToolbar.getNavigationIcon() != null) {
        opts |= ActionBar.DISPLAY_HOME_AS_UP;
        mDefaultNavigationIcon = mToolbar.getNavigationIcon();
    }/*from   w  w  w .  j ava  2  s . c  o  m*/
    return opts;
}

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

private int detectDisplayOptions() {
    int opts = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO;
    if (mToolbar.getNavigationIcon() != null) {
        opts |= ActionBar.DISPLAY_HOME_AS_UP;
    }/*  w  w w. j a  v a  2s.c  o  m*/
    return opts;
}

From source file:com.dnielfe.manager.Browser.java

private void setupDrawer() {
    final TypedArray array = obtainStyledAttributes(new int[] { R.attr.themeId });
    final int themeId = array.getInteger(0, SimpleExplorer.THEME_ID_LIGHT);
    array.recycle();//from ww  w  . j  a v  a 2s.  co  m

    mDrawer = (LinearLayout) findViewById(R.id.left_drawer);

    // Set shadow of navigation drawer
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    int icon = themeId == SimpleExplorer.THEME_ID_LIGHT ? R.drawable.holo_light_ic_drawer
            : R.drawable.holo_dark_ic_drawer;

    // Add Navigation Drawer to ActionBar
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, icon, R.string.drawer_open,
            R.string.drawer_close) {

        @Override
        public void onDrawerOpened(View view) {
            super.onDrawerOpened(view);
            mActionBar.setDisplayOptions(
                    ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
            mActionBar.setTitle(R.string.app_name);
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            mActionBar.setDisplayOptions(
                    ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);
            invalidateOptionsMenu();
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

From source file:com.geotrackin.gpslogger.GpsMainActivity.java

public void SetUpActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(actionBar.getThemedContext(),
            R.array.gps_main_views, android.R.layout.simple_spinner_dropdown_item);

    actionBar.setListNavigationCallbacks(spinnerAdapter, this);

    //Reload the user's previously selected view f73
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    actionBar.setSelectedNavigationItem(prefs.getInt("dropdownview", 0));

    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("");
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
            | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.actionbar);

    ImageButton helpButton = (ImageButton) actionBar.getCustomView().findViewById(R.id.imgHelp);
    helpButton.setOnClickListener(new View.OnClickListener() {
        @Override//from   w  w w . j a v  a2  s .  co  m
        public void onClick(View view) {
            Intent faqtivity = new Intent(getApplicationContext(), Faqtivity.class);
            startActivity(faqtivity);
        }
    });

}

From source file:android.support.v7.widget.ToolbarWidgetWrapper.java

@Override
public void setDisplayOptions(int newOpts) {
    final int oldOpts = mDisplayOpts;
    final int changed = oldOpts ^ newOpts;
    mDisplayOpts = newOpts;/*from   w w w .  j  a v a 2s.c  o  m*/
    if (changed != 0) {
        if ((changed & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
            if ((newOpts & ActionBar.DISPLAY_HOME_AS_UP) != 0) {
                updateHomeAccessibility();
            }
            updateNavigationIcon();
        }

        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);
            }
        }
    }
}