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