Java Code Examples for android.view.ActionMode#setTitle()

The following examples show how to use android.view.ActionMode#setTitle() . 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: ListViewMultiChoiceModeListener.java    From android-kernel-tweaker with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	MenuInflater inflater=host.getMenuInflater();
	inflater.inflate(R.menu.main, menu);
	mDelete = (MenuItem) menu.findItem(R.id.action_delete);
	mAdd = (MenuItem) menu.findItem(R.id.action_add);

	if(delete) {
		mode.setTitle("Delete items");
		mAdd.setVisible(false);
	}else {
		mDelete.setVisible(false);
		mode.setTitle("Add on boot");
	}
	mode.setSubtitle("1 Item Selected");
	activeMode=mode;

	return(true);
}
 
Example 2
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
	if (checked) {
		// Directories and footer items cannot be checked
		boolean valid = false;

		final Cursor cursor = mAdapter.getItem(position);
		if (cursor != null) {
			final String docMimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
			final int docFlags = getCursorInt(cursor, Document.COLUMN_FLAGS);
			// if (!Document.MIME_TYPE_DIR.equals(docMimeType)) {
			valid = isDocumentEnabled(docMimeType, docFlags);
			// }
		}

		if (!valid) {
			mCurrentView.setItemChecked(position, false);
		}
	}

	int count = mCurrentView.getCheckedItemCount();
	mode.setTitle(getResources().getString(R.string.mode_selected_count, count));
	if (count == 1 || count == 2) {
		mode.invalidate();
	}
}
 
Example 3
Source File: FloatingPastePopupMenu.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void createPasteMenu(ActionMode mode, Menu menu) {
    mode.setTitle(DeviceFormFactor.isTablet()
                    ? mContext.getString(R.string.actionbar_textselection_title)
                    : null);
    mode.setSubtitle(null);
    SelectionPopupController.initializeMenu(mContext, mode, menu);
    if (!mDelegate.canPaste()) menu.removeItem(R.id.select_action_menu_paste);
    if (!mDelegate.canSelectAll()) menu.removeItem(R.id.select_action_menu_select_all);
    if (!mDelegate.canPasteAsPlainText()) {
        menu.removeItem(R.id.select_action_menu_paste_as_plain_text);
    }
    // TODO(ctzsm): Remove runtime title set after O SDK rolls.
    MenuItem item = menu.findItem(R.id.select_action_menu_paste_as_plain_text);
    if (item != null) {
        item.setTitle(mContext.getResources().getIdentifier(
                "paste_as_plain_text", "string", "android"));
    }
    menu.removeItem(R.id.select_action_menu_cut);
    menu.removeItem(R.id.select_action_menu_copy);
    menu.removeItem(R.id.select_action_menu_share);
    menu.removeItem(R.id.select_action_menu_web_search);
}
 
Example 4
Source File: ReadingActivity.java    From IslamicLibraryAndroid with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActionModeStarted(@NonNull ActionMode mode) {
    if (mActionMode == null) {
        mActionMode = mode;
        Menu menu = mode.getMenu();

        menu.clear();

        if (!shouldDisplayFloatingSelectionMenu()) {
            MenuInflater inflater = new MenuInflater(this);

            inflater.inflate(R.menu.text_selection_context_menu, menu);
            mode.setTitle(null);

            menu.findItem(R.id.action_copy_text).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_select_all_text).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_add_comment).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_share_text).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            menu.findItem(R.id.action_add_highlight).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

            if (mHighlightClickedFlag) {
                menu.findItem(R.id.action_add_comment).setVisible(true);
                menu.findItem(R.id.highlight_remove).setVisible(true);
            }
        }
    }

    super.onActionModeStarted(mode);
    for (ActionModeChangeListener actionModeChangeListener : mActionModeChangeListener) {
        actionModeChangeListener.actionModeStarted();
    }
}
 
Example 5
Source File: ContentFragment.java    From androidtestdebug with MIT License 5 votes vote down vote up
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
    actionMode.setTitle(R.string.photo_selection_cab_title);

    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.photo_context_menu, menu);
    return true;
}
 
Example 6
Source File: GalleryFragment.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
	int nSelected = (batch == null) ? 0 : batch.size();
	mode.setTitle(GalleryFragment.this.getString(
			R.string.home_gallery_selected, nSelected));
	
	 
	 MenuItem miDropbox2 = menu.findItem(R.id.menu_remote_access_dropbox);
		DropboxSyncManager dsm = DropboxSyncManager.getInstance(a);
		if (dsm != null && dsm.isSyncing())
			miDropbox2.setChecked(true);
		
	return false; // Return false if nothing is done
}
 
Example 7
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	editMode = root != null && root.isEditSupported();
	int menuId = R.menu.mode_simple_directory;
	if (null != root && root.isApp()) {
		menuId = R.menu.mode_apps;
	} else {
		menuId = R.menu.mode_directory;
	}

	mode.getMenuInflater().inflate(menuId, menu);
	int count = mCurrentView.getCheckedItemCount();
	mode.setTitle(count+"");
	return true;
}
 
Example 8
Source File: ListUnit.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	gridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE);
	gridView.clearChoices();
	mode.setTitle(instance.context.getString(R.string.text_selected_format, 0));
	int selectAllResId = ResourceUtils.getSystemSelectionIcon(instance.context, "actionModeSelectAllDrawable",
			"ic_menu_selectall_holo_dark");
	int flags = MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT;
	ActionIconSet set = new ActionIconSet(instance.context);
	menu.add(0, ACTION_MENU_SELECT_ALL, 0, R.string.action_select_all)
			.setIcon(selectAllResId).setShowAsAction(flags);
	menu.add(0, ACTION_MENU_DOWNLOAD_FILES, 0, R.string.action_download_files)
			.setIcon(set.getId(R.attr.actionDownload)).setShowAsAction(flags);
	return true;
}
 
Example 9
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
	editMode = root != null && root.isEditSupported();
	int menuId = R.menu.mode_simple_directory;
	if (null != root && root.isApp()) {
		menuId = R.menu.mode_apps;
	} else {
		menuId = R.menu.mode_directory;
	}

	mode.getMenuInflater().inflate(menuId, menu);
	int count = mCurrentView.getCheckedItemCount();
	mode.setTitle(count+"");
	return true;
}
 
Example 10
Source File: SelectActionModeCallback.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    mode.setTitle(null);
    mode.setSubtitle(null);
    mEditable = mActionHandler.isSelectionEditable();
    createActionMenu(mode, menu);
    return true;
}
 
Example 11
Source File: PlaylistFragment.java    From BeyondUPnP with Apache License 2.0 5 votes vote down vote up
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.menu_list_multi_select, menu);
    mode.setTitle("Select Items");
    setSubtitle(mode);
    return true;
}
 
Example 12
Source File: EditFragment.java    From android-sholi with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.list_select, menu);
    mode.setTitle(R.string.fragment_edit_selection_mode_title);
    _newItemEdit.setVisibility(View.INVISIBLE);
    return true;
}
 
Example 13
Source File: NotesFragment.java    From writeily-pro with MIT License 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.notes_context_menu, menu);
    mode.setTitle(getResources().getString(R.string.select_elements));
    return true;
}
 
Example 14
Source File: InstagramGalleryActivity.java    From InstagramPhotoPicker-Android with MIT License 5 votes vote down vote up
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.photo_selection_menu, menu);

    int selectCount = gridView.getCheckedItemCount();
    mode.setTitle("" + selectCount);

    return true;
}
 
Example 15
Source File: ActionModeController.java    From SimpleExplorer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onItemCheckedStateChanged(ActionMode mode, int position,
                                      long id, boolean checked) {
    mode.setTitle(mListView.getCheckedItemCount() + mSelected);
}
 
Example 16
Source File: List16.java    From codeexamples-android with Eclipse Public License 1.0 4 votes vote down vote up
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.list_select_menu, menu);
    mode.setTitle("Select Items");
    return true;
}
 
Example 17
Source File: ManageDownloadsActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 4 votes vote down vote up
private void updateTitle(ActionMode mode) {
	int childCount = gridView.getCount();
	int checkedCount = gridView.getCheckedItemCount();
	mode.setTitle(String.format("%d of %d selected.", checkedCount, childCount));
}
 
Example 18
Source File: DeleteAdapter.java    From budget-envelopes with GNU General Public License v3.0 4 votes vote down vote up
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    mode.setTitle(R.string.deleted_name);
    mode.getMenuInflater().inflate(R.menu.undo, menu);
    return mDeletedId != -1;
}
 
Example 19
Source File: AccountActivity.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    mode.getMenuInflater().inflate(R.menu.contextual_menu_accountactivity, menu);
    mode.setTitle(getString(R.string.account_management));
    return true;
}
 
Example 20
Source File: MultiModeListener.java    From rss with GNU General Public License v3.0 4 votes vote down vote up
private
void updateTitle(ActionMode mode)
{
    String count = NUMBER_FORMAT.format(m_itemCount);
    mode.setTitle(m_resources.getQuantityString(R.plurals.items_selected, m_itemCount, count));
}