Java Code Examples for android.view.KeyEvent#KEYCODE_FOCUS
The following examples show how to use
android.view.KeyEvent#KEYCODE_FOCUS .
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: ContentViewCore.java From 365browser with Apache License 2.0 | 7 votes |
/** * Check whether a key should be propagated to the embedder or not. * We need to send almost every key to Blink. However: * 1. We don't want to block the device on the renderer for * some keys like menu, home, call. * 2. There are no WebKit equivalents for some of these keys * (see app/keyboard_codes_win.h) * Note that these are not the same set as KeyEvent.isSystemKey: * for instance, AKEYCODE_MEDIA_* will be dispatched to webkit*. */ private static boolean shouldPropagateKeyEvent(KeyEvent event) { int keyCode = event.getKeyCode(); if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_CALL || keyCode == KeyEvent.KEYCODE_ENDCALL || keyCode == KeyEvent.KEYCODE_POWER || keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_CAMERA || keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { return false; } return true; }
Example 2
Source File: CompoundBarcodeView.java From Viewer with Apache License 2.0 | 6 votes |
/** * Handles focus, camera, volume up and volume down keys. * * Note that this view is not usually focused, so the Activity should call this directly. */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app return true; // Use volume up/down to turn on light case KeyEvent.KEYCODE_VOLUME_DOWN: setTorchOff(); return true; case KeyEvent.KEYCODE_VOLUME_UP: setTorchOn(); return true; } return super.onKeyDown(keyCode, event); }
Example 3
Source File: MainActivity.java From retroboy with MIT License | 6 votes |
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_FOCUS: // Reset auto focus when dedicated photo button is completely released _focusManager.resetFocus(); return true; case KeyEvent.KEYCODE_CAMERA: if (event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_UP) { // Take photo when the dedicated photo button is pressed MotionEvent motevent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0); _captureListener.onTouch(null, motevent); motevent.recycle(); } return true; } return super.onKeyUp(keyCode, event); }
Example 4
Source File: ScanActivity.java From bither-android with Apache License 2.0 | 6 votes |
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // don't launch camera app return true; case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: cameraHandler.post(new Runnable() { @Override public void run() { cameraManager .setTorch(keyCode == KeyEvent.KEYCODE_VOLUME_UP); } }); return true; } return super.onKeyDown(keyCode, event); }
Example 5
Source File: CaptureActivity.java From android-apps with MIT License | 6 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED); finish(); return true; } else if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); return true; } } else if (keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_CAMERA) { // Handle these events so they don't launch the Camera app return true; } return super.onKeyDown(keyCode, event); }
Example 6
Source File: BarCodeScannerFragment.java From zxingfragmentlib with Apache License 2.0 | 6 votes |
public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app return true; // Use volume up/down to turn on light case KeyEvent.KEYCODE_VOLUME_DOWN: setTorchOff(); return true; case KeyEvent.KEYCODE_VOLUME_UP: setTorchOn(); return true; } return false; }
Example 7
Source File: CaptureActivity.java From CodeScaner with MIT License | 6 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: setResult(RESULT_CANCELED); finish(); return true; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app return true; // Use volume up/down to turn on light case KeyEvent.KEYCODE_VOLUME_DOWN: cameraManager.setTorch(false); return true; case KeyEvent.KEYCODE_VOLUME_UP: cameraManager.setTorch(true); return true; } return super.onKeyDown(keyCode, event); }
Example 8
Source File: UEntropyActivity.java From bither-android with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // don't launch camera app return true; case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: return true; } return super.onKeyDown(keyCode, event); }
Example 9
Source File: AppInvCaptureActivity.java From appinventor-extensions with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED); finish(); return true; } if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); return true; } break; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app return true; // Use volume up/down to turn on light case KeyEvent.KEYCODE_VOLUME_DOWN: cameraManager.setTorch(false); return true; case KeyEvent.KEYCODE_VOLUME_UP: cameraManager.setTorch(true); return true; } return super.onKeyDown(keyCode, event); }
Example 10
Source File: CaptureActivity.java From ZXing-Standalone-library with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED); finish(); return true; } if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); return true; } break; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app return true; // Use volume up/down to turn on light case KeyEvent.KEYCODE_VOLUME_DOWN: cameraManager.setTorch(false); return true; case KeyEvent.KEYCODE_VOLUME_UP: cameraManager.setTorch(true); return true; } return super.onKeyDown(keyCode, event); }
Example 11
Source File: PhotoModule.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_FOCUS: if (/* TODO: mActivity.isInCameraApp() && */mFirstTimeInitialized && !mActivity.getCameraAppUI() .isInIntentReview()) { if (event.getRepeatCount() == 0) { onShutterButtonFocus(true); } return true; } return false; case KeyEvent.KEYCODE_CAMERA: if (mFirstTimeInitialized && event.getRepeatCount() == 0) { onShutterButtonClick(); } return true; case KeyEvent.KEYCODE_DPAD_CENTER: // If we get a dpad center event without any focused view, move // the focus to the shutter button and press it. if (mFirstTimeInitialized && event.getRepeatCount() == 0) { // Start auto-focus immediately to reduce shutter lag. After // the shutter button gets the focus, onShutterButtonFocus() // will be called again but it is fine. onShutterButtonFocus(true); } return true; } return false; }
Example 12
Source File: QrViewActivity.java From LLApp with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { setResult(RESULT_CANCELED); finish(); return true; } else if (keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_CAMERA) { return true; } return super.onKeyDown(keyCode, event); }
Example 13
Source File: CaptureActivity.java From reacteu-app with MIT License | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: if (source == IntentSource.NATIVE_APP_INTENT) { setResult(RESULT_CANCELED); finish(); return true; } if ((source == IntentSource.NONE || source == IntentSource.ZXING_LINK) && lastResult != null) { restartPreviewAfterDelay(0L); return true; } break; case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // Handle these events so they don't launch the Camera app return true; // Use volume up/down to turn on light case KeyEvent.KEYCODE_VOLUME_DOWN: cameraManager.setTorch(false); return true; case KeyEvent.KEYCODE_VOLUME_UP: cameraManager.setTorch(true); return true; } return super.onKeyDown(keyCode, event); }
Example 14
Source File: ScanIsbnActivity.java From barterli_android with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_FOCUS) || (keyCode == KeyEvent.KEYCODE_CAMERA)) { // Handle these events so they don't launch the Camera app return true; } return super.onKeyDown(keyCode, event); }
Example 15
Source File: ContentViewClient.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
public boolean shouldOverrideKeyEvent(KeyEvent event) { int keyCode = event.getKeyCode(); // We need to send almost every key to WebKit. However: // 1. We don't want to block the device on the renderer for // some keys like menu, home, call. // 2. There are no WebKit equivalents for some of these keys // (see app/keyboard_codes_win.h) // Note that these are not the same set as KeyEvent.isSystemKey: // for instance, AKEYCODE_MEDIA_* will be dispatched to webkit. if (keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_CALL || keyCode == KeyEvent.KEYCODE_ENDCALL || keyCode == KeyEvent.KEYCODE_POWER || keyCode == KeyEvent.KEYCODE_HEADSETHOOK || keyCode == KeyEvent.KEYCODE_CAMERA || keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE || keyCode == KeyEvent.KEYCODE_VOLUME_UP) { return true; } // We also have to intercept some shortcuts before we send them to the ContentView. if (event.isCtrlPressed() && ( keyCode == KeyEvent.KEYCODE_TAB || keyCode == KeyEvent.KEYCODE_W || keyCode == KeyEvent.KEYCODE_F4)) { return true; } return false; }
Example 16
Source File: DecoderActivity.java From barterli_android with Apache License 2.0 | 5 votes |
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_CAMERA) { // Handle these events so they don't launch the Camera app return true; } return super.onKeyDown(keyCode, event); }
Example 17
Source File: AlarmAlertFullScreenToTest.java From X-Alarm with GNU Affero General Public License v3.0 | 5 votes |
@Override public boolean dispatchKeyEvent(KeyEvent event) { // Avoid closing alarm by the following keys switch (event.getKeyCode()) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_CAMERA: case KeyEvent.KEYCODE_FOCUS: return true; default: break; } return super.dispatchKeyEvent(event); }
Example 18
Source File: ScanActivity.java From green_android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_FOCUS: case KeyEvent.KEYCODE_CAMERA: // don't launch camera app return true; case KeyEvent.KEYCODE_VOLUME_DOWN: case KeyEvent.KEYCODE_VOLUME_UP: cameraHandler.post(() -> cameraManager.setTorch(keyCode == KeyEvent.KEYCODE_VOLUME_UP)); return true; } return super.onKeyDown(keyCode, event); }
Example 19
Source File: ImageCapture.java From Camera2 with Apache License 2.0 | 5 votes |
public void captureImages(String reportTag, Instrumentation inst) { int total_num_of_images = CameraStressTestRunner.mImageIterations; Log.v(TAG, "no of images = " + total_num_of_images); //TODO(yslau): Need to integrate the outoput with the central dashboard, //write to a txt file as a temp solution boolean memoryResult = false; KeyEvent focusEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_FOCUS); try { testUtil.writeReportHeader(reportTag, total_num_of_images); for (int i = 0; i < total_num_of_images; i++) { Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN); inst.sendKeySync(focusEvent); inst.sendCharacterSync(KeyEvent.KEYCODE_CAMERA); Thread.sleep(WAIT_FOR_IMAGE_CAPTURE_TO_BE_TAKEN); testUtil.writeResult(i); } } catch (Exception e) { Log.v(TAG, "Got exception: " + e.toString()); assertTrue("testImageCapture", false); } }
Example 20
Source File: PhotoModule.java From Camera2 with Apache License 2.0 | 5 votes |
@Override public boolean onKeyUp(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: if (/* mActivity.isInCameraApp() && */mFirstTimeInitialized && !mActivity.getCameraAppUI() .isInIntentReview()) { if (mUI.isCountingDown()) { cancelCountDown(); } else { mVolumeButtonClickedFlag = true; onShutterButtonClick(); } return true; } return false; case KeyEvent.KEYCODE_FOCUS: if (mFirstTimeInitialized) { onShutterButtonFocus(false); } return true; } return false; }