Java Code Examples for android.view.MenuItem#setTitleCondensed()

The following examples show how to use android.view.MenuItem#setTitleCondensed() . 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: AppMenuPropertiesDelegate.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the bookmark item's visibility.
 *
 * @param bookmarkMenuItem {@link MenuItem} for adding/editing the bookmark.
 * @param currentTab        Current tab being displayed.
 */
protected void updateBookmarkMenuItem(MenuItem bookmarkMenuItem, Tab currentTab) {
    bookmarkMenuItem.setEnabled(mBookmarkBridge.isEditBookmarksEnabled());
    if (currentTab.getBookmarkId() != Tab.INVALID_BOOKMARK_ID) {
        bookmarkMenuItem.setIcon(R.drawable.btn_star_filled);
        bookmarkMenuItem.setChecked(true);
        bookmarkMenuItem.setTitleCondensed(mActivity.getString(R.string.edit_bookmark));
    } else {
        bookmarkMenuItem.setIcon(R.drawable.btn_star);
        bookmarkMenuItem.setChecked(false);
        bookmarkMenuItem.setTitleCondensed(null);
    }
}
 
Example 2
Source File: AppMenuPropertiesDelegate.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the bookmark item's visibility.
 *
 * @param bookmarkMenuItem {@link MenuItem} for adding/editing the bookmark.
 * @param currentTab        Current tab being displayed.
 */
protected void updateBookmarkMenuItem(MenuItem bookmarkMenuItem, Tab currentTab) {
    bookmarkMenuItem.setEnabled(mBookmarkBridge.isEditBookmarksEnabled());
    if (currentTab.getBookmarkId() != Tab.INVALID_BOOKMARK_ID) {
        bookmarkMenuItem.setIcon(R.drawable.btn_star_filled);
        bookmarkMenuItem.setChecked(true);
        bookmarkMenuItem.setTitleCondensed(mActivity.getString(R.string.edit_bookmark));
    } else {
        bookmarkMenuItem.setIcon(R.drawable.btn_star);
        bookmarkMenuItem.setChecked(false);
        bookmarkMenuItem.setTitleCondensed(null);
    }
}
 
Example 3
Source File: AppMenuPropertiesDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the bookmark item's visibility.
 *
 * @param bookmarkMenuItem {@link MenuItem} for adding/editing the bookmark.
 * @param currentTab        Current tab being displayed.
 */
protected void updateBookmarkMenuItem(MenuItem bookmarkMenuItem, Tab currentTab) {
    bookmarkMenuItem.setEnabled(mBookmarkBridge.isEditBookmarksEnabled());
    if (currentTab.getBookmarkId() != Tab.INVALID_BOOKMARK_ID) {
        bookmarkMenuItem.setIcon(R.drawable.btn_star_filled);
        bookmarkMenuItem.setChecked(true);
        bookmarkMenuItem.setTitleCondensed(mActivity.getString(R.string.edit_bookmark));
    } else {
        bookmarkMenuItem.setIcon(R.drawable.btn_star);
        bookmarkMenuItem.setChecked(false);
        bookmarkMenuItem.setTitleCondensed(null);
    }
}
 
Example 4
Source File: AppMenuPropertiesDelegate.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Updates the request desktop site item's visibility
 *
 * @param requstMenuItem {@link MenuItem} for request desktop site.
 * @param currentTab      Current tab being displayed.
 */
protected void updateRequestDesktopSiteMenuItem(
        MenuItem requstMenuItem, Tab currentTab) {
    String url = currentTab.getUrl();
    boolean isChromeScheme = url.startsWith(UrlConstants.CHROME_URL_PREFIX)
            || url.startsWith(UrlConstants.CHROME_NATIVE_URL_PREFIX);
    requstMenuItem.setVisible(!isChromeScheme || currentTab.isNativePage());
    requstMenuItem.setChecked(currentTab.getUseDesktopUserAgent());
    requstMenuItem.setTitleCondensed(requstMenuItem.isChecked()
            ? mActivity.getString(R.string.menu_request_desktop_site_on)
            : mActivity.getString(R.string.menu_request_desktop_site_off));
}
 
Example 5
Source File: FormEntryActivity.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    /*
     * EventLog accepts only proper Strings as input, but prior to this version,
     * Android would try to send SpannedStrings to it, thus crashing the app.
     * This makes sure the title is actually a String.
     * This fixes bug 174626.
     */
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2
            && item.getTitleCondensed() != null) {
        item.setTitleCondensed(item.getTitleCondensed().toString());
    }

    return super.onMenuItemSelected(featureId, item);
}
 
Example 6
Source File: SwapWorkflowActivity.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
private void setUpNextButton(Menu menu, @StringRes int titleResId) {
    MenuItem next = menu.findItem(R.id.action_next);
    CharSequence title = getString(titleResId);
    next.setTitle(title);
    next.setTitleCondensed(title);
    MenuItemCompat.setShowAsAction(next,
            MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
    next.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            sendNext();
            return true;
        }
    });
}