List of usage examples for android.view Menu setQwertyMode
public void setQwertyMode(boolean isQwerty);
From source file:org.openremote.android.console.Main.java
public static void populateMenu(Menu menu) { menu.setQwertyMode(true); MenuItem configItem = menu.add(0, Constants.MENU_ITEM_SETTING, 0, R.string.configure); configItem.setIcon(R.drawable.ic_menu_manage); MenuItem quit = menu.add(0, Constants.MENU_ITEM_QUIT, 0, R.string.quit); quit.setIcon(R.drawable.ic_menu_close_clear_cancel); }
From source file:org.webinos.app.wrt.ui.WidgetListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.setQwertyMode(true); menu.add(0, SCAN_MENUITEM_ID, 0, getString(R.string.scan_sd_card)); menu.add(0, PZP_MENUITEM_ID, 0, getString(R.string.pzp_settings)); /* add any configured stores to the menu */ if (stores != null) { for (int i = 0; i < stores.length; i++) { Store store = stores[i];/*from w ww. j a v a 2 s . c o m*/ menu.add(1, STORES_MENUITEM_BASE + i, 0, store.name).setIcon(store.icon); } } return true; }
From source file:org.openremote.android.console.GroupActivity.java
/** * If there is no global and local tabbar, create default menu. * Contains "setting" and "logout".//from w w w . j a v a 2s . com * * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu) */ @Override public boolean onCreateOptionsMenu(Menu menu) { menu.setQwertyMode(true); MenuItem setting = menu.add(-1, Constants.MENU_ITEM_SETTING, 0, R.string.setting); setting.setIcon(R.drawable.ic_menu_manage); if (AppSettingsModel.isSSLEnabled(getApplicationContext())) { MenuItem ssl = menu.add(-1, Constants.MENU_ITEM_SSL, 0, R.string.ssl_clientcert); ssl.setIcon(R.drawable.ic_menu_lock); } MenuItem logout = menu.add(-1, Constants.MENU_ITEM_LOGOUT, 1, R.string.logout); logout.setIcon(R.drawable.ic_menu_revert); return true; }
From source file:android.support.v7.app.ToolbarActionBar.java
@Override public boolean onKeyShortcut(int keyCode, KeyEvent ev) { Menu menu = getMenu(); if (menu != null) { final KeyCharacterMap kmap = KeyCharacterMap .load(ev != null ? ev.getDeviceId() : KeyCharacterMap.VIRTUAL_KEYBOARD); menu.setQwertyMode(kmap.getKeyboardType() != KeyCharacterMap.NUMERIC); menu.performShortcut(keyCode, ev, 0); }//from ww w.j a v a2 s . c o m // This action bar always returns true for handling keyboard shortcuts. // This will block the window from preparing a temporary panel to handle // keyboard shortcuts. return true; }
From source file:org.connectbot.ConsoleFragment.java
/** * *//* ww w. ja v a 2 s. c o m*/ // TODO: Move to activity /*private void configureOrientation() { String rotateDefault; if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) rotateDefault = PreferenceConstants.ROTATION_PORTRAIT; else rotateDefault = PreferenceConstants.ROTATION_LANDSCAPE; String rotate = prefs.getString(PreferenceConstants.ROTATION, rotateDefault); if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate)) rotate = rotateDefault; // request a forced orientation if requested by user if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); forcedOrientation = true; } else if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); forcedOrientation = true; } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); forcedOrientation = false; } }*/ @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { super.onCreateOptionsMenu(menu, menuInflater); menuInflater.inflate(R.menu.host_menu, menu); menu.setQwertyMode(true); mMenuDisconnect = menu.findItem(R.id.disconnect); mMenuCopy = menu.findItem(R.id.copy); mMenuPaste = menu.findItem(R.id.paste); mMenuPortForwards = menu.findItem(R.id.port_forwards); mMenuUrlScan = menu.findItem(R.id.url_scan); mMenuResize = menu.findItem(R.id.resize); }
From source file:org.connectbot.ConsoleActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); TerminalView view = adapter.getCurrentTerminalView(); final boolean activeTerminal = view != null; boolean sessionOpen = false; boolean disconnected = false; boolean canForwardPorts = false; if (activeTerminal) { TerminalBridge bridge = view.bridge; sessionOpen = bridge.isSessionOpen(); disconnected = bridge.isDisconnected(); canForwardPorts = bridge.canFowardPorts(); }/* w w w.j ava 2 s. c om*/ menu.setQwertyMode(true); disconnect = menu.add(R.string.list_host_disconnect); if (hardKeyboard) disconnect.setAlphabeticShortcut('w'); if (!sessionOpen && disconnected) disconnect.setTitle(R.string.console_menu_close); disconnect.setEnabled(activeTerminal); disconnect.setIcon(android.R.drawable.ic_menu_close_clear_cancel); disconnect.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // disconnect or close the currently visible session TerminalView terminalView = adapter.getCurrentTerminalView(); TerminalBridge bridge = terminalView.bridge; bridge.dispatchDisconnect(true); return true; } }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { copy = menu.add(R.string.console_menu_copy); if (hardKeyboard) copy.setAlphabeticShortcut('c'); MenuItemCompat.setShowAsAction(copy, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); copy.setIcon(R.drawable.ic_action_copy); copy.setEnabled(activeTerminal); copy.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { adapter.getCurrentTerminalView().startPreHoneycombCopyMode(); Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG) .show(); return true; } }); } paste = menu.add(R.string.console_menu_paste); if (hardKeyboard) paste.setAlphabeticShortcut('v'); MenuItemCompat.setShowAsAction(paste, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); paste.setIcon(R.drawable.ic_action_paste); paste.setEnabled(activeTerminal); paste.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { pasteIntoTerminal(); return true; } }); portForward = menu.add(R.string.console_menu_portforwards); if (hardKeyboard) portForward.setAlphabeticShortcut('f'); portForward.setIcon(android.R.drawable.ic_menu_manage); portForward.setEnabled(sessionOpen && canForwardPorts); portForward.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { TerminalView terminalView = adapter.getCurrentTerminalView(); TerminalBridge bridge = terminalView.bridge; Intent intent = new Intent(ConsoleActivity.this, PortForwardListActivity.class); intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId()); ConsoleActivity.this.startActivityForResult(intent, REQUEST_EDIT); return true; } }); urlscan = menu.add(R.string.console_menu_urlscan); if (hardKeyboard) urlscan.setAlphabeticShortcut('u'); urlscan.setIcon(android.R.drawable.ic_menu_search); urlscan.setEnabled(activeTerminal); urlscan.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminalView = adapter.getCurrentTerminalView(); List<String> urls = terminalView.bridge.scanForURLs(); Dialog urlDialog = new Dialog(ConsoleActivity.this); urlDialog.setTitle(R.string.console_menu_urlscan); ListView urlListView = new ListView(ConsoleActivity.this); URLItemListener urlListener = new URLItemListener(ConsoleActivity.this); urlListView.setOnItemClickListener(urlListener); urlListView.setAdapter( new ArrayAdapter<String>(ConsoleActivity.this, android.R.layout.simple_list_item_1, urls)); urlDialog.setContentView(urlListView); urlDialog.show(); return true; } }); resize = menu.add(R.string.console_menu_resize); if (hardKeyboard) resize.setAlphabeticShortcut('s'); resize.setIcon(android.R.drawable.ic_menu_crop); resize.setEnabled(sessionOpen); resize.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminalView = adapter.getCurrentTerminalView(); @SuppressLint("InflateParams") // Dialogs do not have a parent view. final View resizeView = inflater.inflate(R.layout.dia_resize, null, false); new android.support.v7.app.AlertDialog.Builder(ConsoleActivity.this, R.style.AlertDialogTheme) .setView(resizeView) .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int width, height; try { width = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.width)).getText().toString()); height = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.height)).getText().toString()); } catch (NumberFormatException nfe) { // TODO change this to a real dialog where we can // make the input boxes turn red to indicate an error. return; } terminalView.forceSize(width, height); } }).setNegativeButton(android.R.string.cancel, null).create().show(); return true; } }); return true; }
From source file:org.woltage.irssiconnectbot.ConsoleActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); View view = findCurrentView(R.id.console_flip); final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final boolean activeTerminal = (view instanceof TerminalView); boolean sessionOpen = false; boolean disconnected = false; boolean canForwardPorts = false; if (activeTerminal) { TerminalBridge bridge = ((TerminalView) view).bridge; sessionOpen = bridge.isSessionOpen(); disconnected = bridge.isDisconnected(); canForwardPorts = bridge.canFowardPorts(); }//from ww w . j av a2 s. c om menu.setQwertyMode(true); disconnect = menu.add(R.string.list_host_disconnect); if (hardKeyboard) disconnect.setAlphabeticShortcut('w'); if (!sessionOpen && disconnected) disconnect.setTitle(R.string.console_menu_close); disconnect.setEnabled(activeTerminal); disconnect.setIcon(android.R.drawable.ic_menu_close_clear_cancel); disconnect.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // disconnect or close the currently visible session TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; bridge.dispatchDisconnect(true); if (bound != null && prefs.getBoolean("unloadKeysOnDisconnect", true)) { bound.lockUnusedKeys(); } return true; } }); copy = menu.add(R.string.console_menu_copy); if (hardKeyboard) copy.setAlphabeticShortcut('c'); copy.setIcon(android.R.drawable.ic_menu_set_as); copy.setEnabled(activeTerminal); copy.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // mark as copying and reset any previous bounds TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); copySource = terminalView.bridge; SelectionArea area = copySource.getSelectionArea(); area.reset(); area.setBounds(copySource.buffer.getColumns(), copySource.buffer.getRows()); area.setRow(copySource.buffer.getCursorRow()); area.setColumn(copySource.buffer.getCursorColumn()); copySource.setSelectingForCopy(true); // Make sure we show the initial selection copySource.redraw(); Toast.makeText(ConsoleActivity.this, getString(R.string.console_copy_start), Toast.LENGTH_LONG) .show(); return true; } }); paste = menu.add(R.string.console_menu_paste); if (hardKeyboard) paste.setAlphabeticShortcut('v'); paste.setIcon(android.R.drawable.ic_menu_edit); paste.setEnabled(clipboard.hasText() && sessionOpen); paste.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // force insert of clipboard text into current console TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; // pull string from clipboard and generate all events to force // down String clip = clipboard.getText().toString(); bridge.injectString(clip); return true; } }); portForward = menu.add(R.string.console_menu_portforwards); if (hardKeyboard) portForward.setAlphabeticShortcut('f'); portForward.setIcon(android.R.drawable.ic_menu_manage); portForward.setEnabled(sessionOpen && canForwardPorts); portForward.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); TerminalBridge bridge = terminalView.bridge; Intent intent = new Intent(ConsoleActivity.this, PortForwardListActivity.class); intent.putExtra(Intent.EXTRA_TITLE, bridge.host.getId()); ConsoleActivity.this.startActivityForResult(intent, REQUEST_EDIT); return true; } }); urlscan = menu.add(R.string.console_menu_urlscan); if (hardKeyboard) urlscan.setAlphabeticShortcut('u'); urlscan.setIcon(android.R.drawable.ic_menu_search); urlscan.setEnabled(activeTerminal); urlscan.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminal = (TerminalView) findCurrentView(R.id.console_flip); TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.urlScan(terminal); return true; } }); resize = menu.add(R.string.console_menu_resize); if (hardKeyboard) resize.setAlphabeticShortcut('s'); resize.setIcon(android.R.drawable.ic_menu_crop); resize.setEnabled(sessionOpen); resize.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { final TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); final View resizeView = inflater.inflate(R.layout.dia_resize, null, false); ((EditText) resizeView.findViewById(R.id.width)) .setText(prefs.getString("default_fsize_width", "80")); ((EditText) resizeView.findViewById(R.id.height)) .setText(prefs.getString("default_fsize_height", "25")); new AlertDialog.Builder(ConsoleActivity.this).setView(resizeView) .setPositiveButton(R.string.button_resize, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int width, height; try { width = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.width)).getText().toString()); height = Integer.parseInt( ((EditText) resizeView.findViewById(R.id.height)).getText().toString()); } catch (NumberFormatException nfe) { // TODO change this to a real dialog where we can // make the input boxes turn red to indicate an error. return; } if (width > 0 && height > 0) { terminalView.forceSize(width, height); terminalView.bridge.parentChanged(terminalView); } else { new AlertDialog.Builder(ConsoleActivity.this) .setMessage("Width and height must be higher than zero.") .setTitle("Error").show(); } } }).setNegativeButton(android.R.string.cancel, null).create().show(); return true; } }); MenuItem ctrlKey = menu.add("Ctrl"); ctrlKey.setEnabled(activeTerminal); ctrlKey.setIcon(R.drawable.button_ctrl); MenuItemCompat.setShowAsAction(ctrlKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); ctrlKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.metaPress(TerminalKeyListener.META_CTRL_ON); terminal.bridge.tryKeyVibrate(); return true; } }); MenuItem escKey = menu.add("Esc"); escKey.setEnabled(activeTerminal); escKey.setIcon(R.drawable.button_esc); MenuItemCompat.setShowAsAction(escKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); escKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.sendEscape(); terminal.bridge.tryKeyVibrate(); return true; } }); MenuItem symKey = menu.add("SYM"); symKey.setEnabled(activeTerminal); symKey.setIcon(R.drawable.button_sym); MenuItemCompat.setShowAsAction(symKey, MenuItem.SHOW_AS_ACTION_IF_ROOM); symKey.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; TerminalView terminal = (TerminalView) flip; TerminalKeyListener handler = terminal.bridge.getKeyHandler(); handler.showCharPickerDialog(terminal); return true; } }); MenuItem inputButton = menu.add("Input"); inputButton.setEnabled(activeTerminal); inputButton.setIcon(R.drawable.button_input); MenuItemCompat.setShowAsAction(inputButton, MenuItem.SHOW_AS_ACTION_IF_ROOM); inputButton.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; final TerminalView terminal = (TerminalView) flip; Thread promptThread = new Thread(new Runnable() { public void run() { String inj = getCurrentPromptHelper().requestStringPrompt(null, ""); terminal.bridge.injectString(inj); } }); promptThread.setName("Prompt"); promptThread.setDaemon(true); promptThread.start(); return true; } }); MenuItem keyboard = menu.add("Show Keyboard"); keyboard.setEnabled(activeTerminal); keyboard.setIcon(R.drawable.button_keyboard); MenuItemCompat.setShowAsAction(keyboard, MenuItem.SHOW_AS_ACTION_IF_ROOM); keyboard.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; inputManager.showSoftInput(flip, InputMethodManager.SHOW_FORCED); return true; } }); MenuItem keys = menu.add(R.string.console_menu_pubkeys); keys.setIcon(android.R.drawable.ic_lock_lock); keys.setIntent(new Intent(this, PubkeyListActivity.class)); keys.setEnabled(activeTerminal); keys.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Intent intent = new Intent(ConsoleActivity.this, PubkeyListActivity.class); intent.putExtra(PubkeyListActivity.PICK_MODE, true); ConsoleActivity.this.startActivityForResult(intent, REQUEST_SELECT); return true; } }); return true; }