Example usage for android.app ActionBar setDisplayHomeAsUpEnabled

List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled

Introduction

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

Prototype

public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);

Source Link

Document

Set whether home should be displayed as an "up" affordance.

Usage

From source file:com.antew.redditinpictures.library.ui.ImageViewerActivity.java

/**
 * Enable some additional newer visibility and ActionBar features to create a more
 * immersive photo viewing experience./*ww  w . j a v a  2 s .  com*/
 * <p/>
 * Initialize the mActionBarHeight variable.
 */
private void initializeActionBar() {
    final ActionBar actionBar = getActionBar();

    // Hide title text and set home as up
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(R.string.reddit_in_pictures);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Calculate ActionBar height
    TypedValue tv = new TypedValue();
    if (getTheme() != null && getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
    }
}

From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java

/**
 * Initialize the activity action bar/*from   w ww  .j a  v  a2  s.c  o m*/
 */
private void createActionBar() {
    final ActionBar actionBar = getActionBar();

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
}

From source file:org.jitsi.service.osgi.OSGiActivity.java

/**
 * Called when the activity is starting. Initializes the corresponding
 * call interface./*from  w  w  w .  jav a2 s .  c o m*/
 *
 * @param savedInstanceState If the activity is being re-initialized after
 * previously being shut down then this Bundle contains the data it most
 * recently supplied in onSaveInstanceState(Bundle).
 * Note: Otherwise it is null.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void onCreate(Bundle savedInstanceState) {
    // Hooks the exception handler to the UI thread
    ExceptionHandler.checkAndAttachExceptionHandler();

    if (AndroidUtils.hasAPI(11)) {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {

            // Disable up arrow on home activity
            Class<?> homeActivity = JitsiApplication.getHomeScreenActivityClass();
            if (this.getClass().equals(homeActivity)) {
                actionBar.setDisplayHomeAsUpEnabled(false);

                if (AndroidUtils.hasAPI(14)) {
                    actionBar.setHomeButtonEnabled(false);
                }
            }

            ActionBarUtil.setTitle(this, getTitle());
        }
    }

    super.onCreate(savedInstanceState);

    ServiceConnection serviceConnection = new ServiceConnection() {
        public void onServiceConnected(ComponentName name, IBinder service) {
            if (this == OSGiActivity.this.serviceConnection)
                setService((BundleContextHolder) service);
        }

        public void onServiceDisconnected(ComponentName name) {
            if (this == OSGiActivity.this.serviceConnection)
                setService(null);
        }
    };

    this.serviceConnection = serviceConnection;

    boolean bindService = false;

    try {
        bindService = bindService(new Intent(this, OSGiService.class), serviceConnection, BIND_AUTO_CREATE);
    } finally {
        if (!bindService)
            this.serviceConnection = null;
    }

    // Registers exit action listener
    this.registerReceiver(exitListener, new IntentFilter(JitsiApplication.ACTION_EXIT));
}

From source file:com.android.mms.ui.SelectRecipientsList.java

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

    setContentView(R.layout.select_recipients_list_screen);

    if (savedInstanceState != null) {
        mMode = savedInstanceState.getInt(MODE);
    } else {/* w w  w. j av  a 2  s.  com*/
        mMode = getIntent().getIntExtra(MODE, MODE_INFO);
    }

    mContactsPreferences = new ContactsPreferences(this);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);

    mTabPager = (ViewPager) findViewById(R.id.tab_pager);
    mTabPager.setAdapter(new ListTabAdapter());
    mTabPager.setOnPageChangeListener(new TabPagerListener());
    mViewPagerTabs = (ViewPagerTabs) findViewById(R.id.lists_pager_header);
    mViewPagerTabs.setViewPager(mTabPager);
    mViewPagerTabs.setVisibility(mMode == MODE_DEFAULT ? View.VISIBLE : View.GONE);

    mContactListAdapter = new SelectRecipientsListAdapter(this);
    mGroupListAdapter = new SelectRecipientsGroupListAdapter(this);

    switch (mMode) {
    case MODE_INFO:
        setTitle(R.string.attach_add_contact_as_text);
        break;
    case MODE_VCARD:
        setTitle(R.string.attach_add_contact_as_vcard);
        break;
    default:
        // leave it be
    }

    // Get things ready
    mCheckedPhoneNumbers = new HashSet<PhoneNumber>();
    mLocalGroups = new HashSet<Group>();
    getLoaderManager().initLoader(0, null, this);

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
}

From source file:com.networksaremadeofstring.anonionooid.RelayDetailsSwipe.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_relay_details_swipe);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mContext = this;
    if (null == lc)
        lc = new LocalCache(mContext);

    lc.open();//from   w  ww  .j  ava 2s.c o m
    isFavourite = lc.isAFavourite(getIntent().getStringExtra(Ooo.ARG_ITEM_ID));
    lc.close();

    // Show the Up button in the action bar.
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setIcon(R.drawable.ab_icon);

    try {
        //fingerprint =
        actionBar.setSubtitle(getIntent().getStringExtra(Ooo.ARG_ITEM_ID));

    } catch (Exception e) {
        e.printStackTrace();
    }

    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        arguments = new Bundle();
        arguments.putString(Ooo.ARG_ITEM_ID, getIntent().getStringExtra(Ooo.ARG_ITEM_ID));

        /*RelayDetailFragment fragment = new RelayDetailFragment();
        fragment.setArguments(arguments);
        getFragmentManager().beginTransaction()
            .add(R.id.relay_detail_container, fragment)
            .commit();*/
    }

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.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 callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.ls.sip.CameraFragment.java

@Override
public void onHiddenChanged(boolean isHidden) {
    super.onHiddenChanged(isHidden);

    if (!isHidden) {
        ActionBar ab = getActivity().getActionBar();

        if (ab != null) {
            ab.setBackgroundDrawable(//from  w  ww  .  j  av a 2s  . c  o m
                    ContextCompat.getDrawable(getActivity(), R.drawable.cwac_cam2_action_bar_bg_transparent));
            ab.setTitle("");

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ab.setDisplayHomeAsUpEnabled(false);
            } else {
                ab.setDisplayShowHomeEnabled(false);
                ab.setHomeButtonEnabled(false);
            }
        }

        if (btnTakePicture != null) {
            btnTakePicture.setEnabled(true);
            btnSwitch.setEnabled(true);
        }
    }
}

From source file:org.billthefarmer.shorty.LookupActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lookup);/*from ww w  .  jav  a  2  s. co m*/

    // Get text views
    nameView = (TextView) findViewById(R.id.lu_name);
    urlView = (TextView) findViewById(R.id.lu_url);

    // Get buttons, set listener
    Button add = (Button) findViewById(R.id.add);
    if (add != null)
        add.setOnClickListener(this);

    Button remove = (Button) findViewById(R.id.remove);
    if (remove != null)
        remove.setOnClickListener(this);

    Button select = (Button) findViewById(R.id.select);
    if (select != null)
        select.setOnClickListener(this);

    // get list view
    listView = (ListView) findViewById(R.id.list);

    if (listView != null)
        listView.setOnItemClickListener(this);

    // Enable back navigation on action bar
    ActionBar actionBar = getActionBar();
    if (actionBar != null)
        actionBar.setDisplayHomeAsUpEnabled(true);

    // Get preferences
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    String name = preferences.getString(MainActivity.PREF_NAME, null);
    String url = preferences.getString(MainActivity.PREF_URL, null);

    // Set fields from preferences
    if (name != null)
        nameView.setText(name);
    if (url != null)
        urlView.setText(url);

    String entryJSON = preferences.getString(PREF_ENTRIES, null);
    String valueJSON = preferences.getString(PREF_VALUES, null);

    // Get resources
    Resources resources = getResources();

    // Add entries
    if (entryJSON != null) {
        try {
            JSONArray entryArray = new JSONArray(entryJSON);
            entryList = new ArrayList<String>();
            for (int i = 0; !entryArray.isNull(i); i++)
                entryList.add(entryArray.getString(i));
        }

        catch (Exception e) {
            String entries[] = resources.getStringArray(R.array.entries);
            entryList = new ArrayList<String>(Arrays.asList(entries));
        }
    }

    else {
        String entries[] = resources.getStringArray(R.array.entries);
        entryList = new ArrayList<String>(Arrays.asList(entries));
    }

    if (valueJSON != null) {
        try {
            JSONArray valueArray = new JSONArray(valueJSON);
            valueList = new ArrayList<String>();
            for (int i = 0; !valueArray.isNull(i); i++)
                valueList.add(valueArray.getString(i));
        }

        catch (Exception e) {
            String values[] = resources.getStringArray(R.array.values);
            valueList = new ArrayList<String>(Arrays.asList(values));
        }
    }

    else {
        String values[] = resources.getStringArray(R.array.values);
        valueList = new ArrayList<String>(Arrays.asList(values));
    }

    // Set array adapter
    arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, entryList);

    listView.setAdapter(arrayAdapter);
}

From source file:com.concentricsky.android.khanacademy.app.ManageDownloadsActivity.java

@Override
protected void onStart() {
    super.onStart();

    gridView = (GridView) findViewById(R.id.grid);
    gridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    gridView.setMultiChoiceModeListener(multiChoiceModeListener);
    gridView.setOnItemClickListener(itemClickListener);

    View emptyView = getLayoutInflater().inflate(R.layout.listview_empty, null, false);
    ((TextView) emptyView.findViewById(R.id.text_list_empty)).setText(R.string.msg_no_downloaded_videos);
    ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    addContentView(emptyView, p);/*from   www.j a v  a  2s .  c o m*/

    gridView.setEmptyView(emptyView);

    requestDataService(new ObjectCallback<KADataService>() {
        @Override
        public void call(final KADataService dataService) {
            ManageDownloadsActivity.this.dataService = dataService;

            CursorAdapter adapter = new Adapter(ManageDownloadsActivity.this, null, 0,
                    dataService.getThumbnailManager());
            gridView.setAdapter(adapter);

            new AsyncTask<Void, Void, Cursor>() {
                @Override
                protected Cursor doInBackground(Void... arg) {
                    return getCursor();
                }

                @Override
                protected void onPostExecute(Cursor cursor) {
                    ((CursorAdapter) gridView.getAdapter()).changeCursor(cursor);
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

            final ActionBar ab = getActionBar();
            ab.setDisplayHomeAsUpEnabled(true);

            ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            ab.setTitle("");

            setupListNavigation();

            // The receiver performs actions that require a dataService, so register it here.
            IntentFilter filter = new IntentFilter();
            filter.addAction(ACTION_LIBRARY_UPDATE);
            filter.addAction(ACTION_BADGE_EARNED);
            filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED);
            filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE);
            filter.addAction(ACTION_TOAST);
            broadcastManager.registerReceiver(receiver, filter);
        }
    });
}

From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuActivity.java

private void setGUI() {
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    mDeviceNameView = (TextView) findViewById(R.id.device_name);
    mFileNameView = (TextView) findViewById(R.id.file_name);
    mFileSizeView = (TextView) findViewById(R.id.file_size);
    mFileStatusView = (TextView) findViewById(R.id.file_status);

    firmwareButtons = new Button[3];
    firmwareButtons[0] = (Button) findViewById(R.id.action_select_file);
    firmwareButtons[1] = (Button) findViewById(R.id.action_choose_version);
    firmwareButtons[2] = (Button) findViewById(R.id.action_update_latest);

    mUploadButton = (Button) findViewById(R.id.action_upload);
    mTextPercentage = (TextView) findViewById(R.id.textviewProgress);
    mTextUploading = (TextView) findViewById(R.id.textviewUploading);
    mProgressBar = (ProgressBar) findViewById(R.id.progressbar_file);

    final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    final boolean uploadInProgress = preferences.getBoolean(DfuService.PREFS_DFU_IN_PROGRESS, false);
    if (uploadInProgress) {
        // Restore image file information
        mDeviceNameView.setText(preferences.getString(PREFS_DEVICE_NAME, ""));
        mFileNameView.setText(preferences.getString(PREFS_FILE_NAME, ""));
        mFileSizeView.setText(preferences.getString(PREFS_FILE_SIZE, ""));
        mFileStatusView.setText(R.string.dfu_file_status_ok);
        showProgressBar();//from w  w w .  j ava2s . c o m
    }
}

From source file:ru.mtuci.musicanalyzer.apollo.ui.activities.ProfileActivity.java

/**
 * {@inheritDoc}/*  ww w  .j a v a 2s  .  com*/
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Temporay until I can work out a nice landscape layout
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Get the preferences
    mPreferences = PreferenceUtils.getInstace(this);

    // Initialze the image fetcher
    mImageFetcher = ApolloUtils.getImageFetcher(this);

    // Initialize the Bundle
    mArguments = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
    // Get the MIME type
    mType = mArguments.getString(Config.MIME_TYPE);
    // Get the profile title
    mProfileName = mArguments.getString(Config.NAME);
    // Get the artist name
    if (isArtist() || isAlbum()) {
        mArtistName = mArguments.getString(Config.ARTIST_NAME);
    }

    // Initialize the pager adapter
    mPagerAdapter = new PagerAdapter(this);

    // Initialze the carousel
    mTabCarousel = (ProfileTabCarousel) findViewById(R.id.acivity_profile_base_tab_carousel);
    mTabCarousel.reset();
    mTabCarousel.getPhoto().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            ProfileType profileType;
            if (isArtist()) {
                profileType = ProfileType.ARTIST;
            } else if (isAlbum()) {
                profileType = ProfileType.ALBUM;
            } else {
                profileType = ProfileType.OTHER;
            }
            PhotoSelectionDialog.newInstance(isArtist() ? mArtistName : mProfileName, profileType)
                    .show(getSupportFragmentManager(), "PhotoSelectionDialog");
        }
    });
    // Set up the action bar
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    /* Set up the artist profile */
    if (isArtist()) {
        // Add the carousel images
        mTabCarousel.setArtistProfileHeader(this, mArtistName);

        // Artist profile fragments
        mPagerAdapter.add(ArtistSongFragment.class, mArguments);
        mPagerAdapter.add(ArtistAlbumFragment.class, mArguments);

        // Action bar title
        mResources.setTitle(mArtistName);

    } else
    // Set up the album profile
    if (isAlbum()) {
        // Add the carousel images
        mTabCarousel.setAlbumProfileHeader(this, mProfileName, mArtistName);

        // Album profile fragments
        mPagerAdapter.add(AlbumSongFragment.class, mArguments);

        // Action bar title = album name
        mResources.setTitle(mProfileName);
        // Action bar subtitle = year released
        mResources.setSubtitle(mArguments.getString(Config.ALBUM_YEAR));
    } else
    // Set up the favorites profile
    if (isFavorites()) {
        // Add the carousel images
        mTabCarousel.setPlaylistOrGenreProfileHeader(this, mProfileName);

        // Favorite fragment
        mPagerAdapter.add(FavoriteFragment.class, null);

        // Action bar title = Favorites
        mResources.setTitle(mProfileName);
    } else
    // Set up the last added profile
    if (isLastAdded()) {
        // Add the carousel images
        mTabCarousel.setPlaylistOrGenreProfileHeader(this, mProfileName);

        // Last added fragment
        mPagerAdapter.add(LastAddedFragment.class, null);

        // Action bar title = Last added
        mResources.setTitle(mProfileName);
    } else
    // Set up the user playlist profile
    if (isPlaylist()) {
        // Add the carousel images
        mTabCarousel.setPlaylistOrGenreProfileHeader(this, mProfileName);

        // Playlist profile fragments
        mPagerAdapter.add(PlaylistSongFragment.class, mArguments);

        // Action bar title = playlist name
        mResources.setTitle(mProfileName);
    } else
    // Set up the genre profile
    if (isGenre()) {
        // Add the carousel images
        mTabCarousel.setPlaylistOrGenreProfileHeader(this, mProfileName);

        // Genre profile fragments
        mPagerAdapter.add(GenreSongFragment.class, mArguments);

        // Action bar title = playlist name
        mResources.setTitle(mProfileName);
    }

    // Initialize the ViewPager
    mViewPager = (ViewPager) findViewById(R.id.acivity_profile_base_pager);
    // Attch the adapter
    mViewPager.setAdapter(mPagerAdapter);
    // Offscreen limit
    mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1);
    // Attach the page change listener
    mViewPager.setOnPageChangeListener(this);
    // Attach the carousel listener
    mTabCarousel.setListener(this);
}