summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2014-01-28 00:44:30 +0200
committerMichael Bestas <mikeioannina@gmail.com>2015-09-17 23:26:02 +0300
commitcea0604f347b07d51d48b14b6c6b7d43ba1b0377 (patch)
tree8e2ec7828858ab94caf542a42de558091fcf154b
parent4b6ade90186f024ce6986a5a13efa3be9e9c8d80 (diff)
downloadandroid_packages_apps_Snap-cea0604f347b07d51d48b14b6c6b7d43ba1b0377.zip
android_packages_apps_Snap-cea0604f347b07d51d48b14b6c6b7d43ba1b0377.tar.gz
android_packages_apps_Snap-cea0604f347b07d51d48b14b6c6b7d43ba1b0377.tar.bz2
Camera: Handle keys only while in app
Thanks to Lars Greiss (SlimRoms) Change-Id: I63f757d25260fba4683f494f8b4daf178a2b4e13
-rw-r--r--src/com/android/camera/CameraActivity.java11
-rw-r--r--src/com/android/camera/PhotoModule.java17
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java8
3 files changed, 25 insertions, 11 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 36505b1..2148158 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -199,6 +199,7 @@ public class CameraActivity extends Activity
private OnScreenHint mStorageHint;
private long mStorageSpaceBytes = Storage.LOW_STORAGE_THRESHOLD_BYTES;
private boolean mSecureCamera;
+ private boolean mInCameraApp = true;
// Keep track of powershutter state
public static boolean mPowerShutter = false;
// This is a hack to speed up the start of SecureCamera.
@@ -1782,7 +1783,7 @@ public class CameraActivity extends Activity
if (!CameraUtil.hasCameraKey()) {
mPowerShutter = val.equals(CameraSettings.VALUE_ON);
}
- if (mPowerShutter /*TODO: && mShowCameraAppView*/) {
+ if (mPowerShutter && mInCameraApp) {
getWindow().addPrivateFlags(
WindowManager.LayoutParams.PRIVATE_FLAG_PREVENT_POWER_KEY);
} else {
@@ -1814,6 +1815,10 @@ public class CameraActivity extends Activity
return mSecureCamera;
}
+ public boolean isInCameraApp() {
+ return mInCameraApp;
+ }
+
@Override
public void onModuleSelected(int moduleIndex) {
if (mCurrentModuleIndex == moduleIndex) {
@@ -2043,6 +2048,10 @@ public class CameraActivity extends Activity
*/
private void setPreviewControlsVisibility(boolean showControls) {
mCurrentModule.onPreviewFocusChanged(showControls);
+
+ // controls are only shown when the camera app is active
+ // so we can assume to fetch this information from here
+ mInCameraApp = showControls;
}
// Accessor methods for getting latency times used in performance testing
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 02f45b4..8865d54 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -2474,13 +2474,14 @@ public class PhotoModule
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- /*TODO: if (!mActivity.mShowCameraAppView) {
+ // Do not handle any key if the activity is
+ // not in active camera/video mode
+ if (!mActivity.isInCameraApp()) {
return false;
- }*/
+ }
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
- if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized
- && (mUI.mMenuInitialized)) {
+ if (mFirstTimeInitialized && (mUI.mMenuInitialized)) {
if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
onShutterButtonFocus(true);
} else {
@@ -2489,8 +2490,7 @@ public class PhotoModule
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
- if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized
- && (mUI.mMenuInitialized)) {
+ if (mFirstTimeInitialized && (mUI.mMenuInitialized)) {
if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
onShutterButtonFocus(true);
} else {
@@ -2499,7 +2499,7 @@ public class PhotoModule
}
return true;
case KeyEvent.KEYCODE_FOCUS:
- if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized) {
+ if (mFirstTimeInitialized) {
if (event.getRepeatCount() == 0) {
onShutterButtonFocus(true);
}
@@ -2534,9 +2534,6 @@ public class PhotoModule
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
- /*TODO: if (!mActivity.mShowCameraAppView) {
- return false;
- }*/
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 30fda16..e9090b7 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -1173,6 +1173,14 @@ public class WideAnglePanoramaModule
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
+ // Do not handle any key if the activity is paused
+ // or not in active camera/video mode
+ if (mPaused) {
+ return true;
+ } else if (!mActivity.isInCameraApp()) {
+ return false;
+ }
+
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN: