Search in sources :

Example 1 with ActionModeController

use of org.chromium.chrome.browser.toolbar.ActionModeController in project AndroidChromium by JackyAndroid.

the class LocationBarLayout method initializeControls.

@Override
public void initializeControls(WindowDelegate windowDelegate, ActionBarDelegate actionBarDelegate, WindowAndroid windowAndroid) {
    mWindowDelegate = windowDelegate;
    mActionModeController = new ActionModeController(getContext(), actionBarDelegate);
    mActionModeController.setCustomSelectionActionModeCallback(new ToolbarActionModeCallback() {

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            boolean retVal = super.onCreateActionMode(mode, menu);
            mode.getMenuInflater().inflate(R.menu.textselectionmenu, menu);
            return retVal;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            if (item.getItemId() == R.id.copy_url) {
                ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("url", mOriginalUrl);
                clipboard.setPrimaryClip(clip);
                mode.finish();
                return true;
            } else {
                return super.onActionItemClicked(mode, item);
            }
        }
    });
    mWindowAndroid = windowAndroid;
    // If the user focused the omnibox prior to the native libraries being initialized,
    // autocomplete will not always be enabled, so we force it enabled in that case.
    mUrlBar.setIgnoreTextChangesForAutocomplete(false);
}
Also used : ClipboardManager(android.content.ClipboardManager) ToolbarActionModeCallback(org.chromium.chrome.browser.toolbar.ToolbarActionModeCallback) ActionMode(android.view.ActionMode) ActionModeController(org.chromium.chrome.browser.toolbar.ActionModeController) MenuItem(android.view.MenuItem) Menu(android.view.Menu) ClipData(android.content.ClipData)

Aggregations

ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 ActionMode (android.view.ActionMode)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 ActionModeController (org.chromium.chrome.browser.toolbar.ActionModeController)1 ToolbarActionModeCallback (org.chromium.chrome.browser.toolbar.ToolbarActionModeCallback)1