summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2013-11-05 16:43:50 +0200
committerMichael Bestas <mikeioannina@gmail.com>2015-09-17 23:26:02 +0300
commit4b6ade90186f024ce6986a5a13efa3be9e9c8d80 (patch)
tree1bd5eebc88ce444e13f4fe28e0f99d7ee70473f5
parent69fe66517f086a01b6f9fb80e669256ec11c6625 (diff)
downloadandroid_packages_apps_Snap-4b6ade90186f024ce6986a5a13efa3be9e9c8d80.zip
android_packages_apps_Snap-4b6ade90186f024ce6986a5a13efa3be9e9c8d80.tar.gz
android_packages_apps_Snap-4b6ade90186f024ce6986a5a13efa3be9e9c8d80.tar.bz2
Camera: Cleanup hardware key handling
* Fix power shutter behaviour in camcorder mode * Disable volume change while in panorama mode, volume buttons should only handle camera operations while in the camera * Add camera/power/volume key shutter handling in panorama mode On devices with a hardware camera key: * Disable power & volume shutter features * Volume buttons control the zoom On devices without a hardware camera key: * When power shutter is disabled, volume buttons control the shutter (like AOSP) * When power shutter is enabled, volume buttons control the zoom Change-Id: I141946d5b6f5aec8b1e9a9f99270d30295596079
-rw-r--r--src/com/android/camera/CameraActivity.java4
-rw-r--r--src/com/android/camera/CameraSettings.java4
-rw-r--r--src/com/android/camera/PhotoModule.java21
-rw-r--r--src/com/android/camera/VideoModule.java41
-rw-r--r--src/com/android/camera/WideAnglePanoramaModule.java33
-rw-r--r--src/com/android/camera/util/CameraUtil.java12
6 files changed, 100 insertions, 15 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 7743888..36505b1 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1779,7 +1779,9 @@ public class CameraActivity extends Activity
protected void initPowerShutter(ComboPreferences prefs) {
String val = prefs.getString(CameraSettings.KEY_POWER_SHUTTER,
getResources().getString(R.string.pref_camera_power_shutter_default));
- mPowerShutter = val.equals(CameraSettings.VALUE_ON);
+ if (!CameraUtil.hasCameraKey()) {
+ mPowerShutter = val.equals(CameraSettings.VALUE_ON);
+ }
if (mPowerShutter /*TODO: && mShowCameraAppView*/) {
getWindow().addPrivateFlags(
WindowManager.LayoutParams.PRIVATE_FLAG_PREVENT_POWER_KEY);
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index b986f5b..1dde274 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -759,6 +759,7 @@ public class CameraSettings {
ListPreference cameraHdr = group.findPreference(KEY_CAMERA_HDR);
ListPreference disMode = group.findPreference(KEY_DIS);
ListPreference cameraHdrPlus = group.findPreference(KEY_CAMERA_HDR_PLUS);
+ ListPreference powerShutter = group.findPreference(KEY_POWER_SHUTTER);
ListPreference videoHfrMode =
group.findPreference(KEY_VIDEO_HIGH_FRAME_RATE);
ListPreference seeMoreMode = group.findPreference(KEY_SEE_MORE);
@@ -843,6 +844,9 @@ public class CameraSettings {
!GcamHelper.hasGcamCapture() || isFrontCamera)) {
removePreference(group, cameraHdrPlus.getKey());
}
+ if (powerShutter != null && CameraUtil.hasCameraKey()) {
+ removePreference(group, powerShutter.getKey());
+ }
if (SystemProperties.getBoolean("persist.env.camera.saveinsd", false)) {
final String CAMERA_SAVEPATH_SDCARD = "1";
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 9a798d5..02f45b4 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -2481,13 +2481,21 @@ public class PhotoModule
case KeyEvent.KEYCODE_VOLUME_UP:
if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized
&& (mUI.mMenuInitialized)) {
- mUI.onScaleStepResize(true);
+ if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
+ onShutterButtonFocus(true);
+ } else {
+ mUI.onScaleStepResize(true);
+ }
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized
&& (mUI.mMenuInitialized)) {
- mUI.onScaleStepResize(false);
+ if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
+ onShutterButtonFocus(true);
+ } else {
+ mUI.onScaleStepResize(false);
+ }
}
return true;
case KeyEvent.KEYCODE_FOCUS:
@@ -2516,7 +2524,7 @@ public class PhotoModule
return true;
case KeyEvent.KEYCODE_POWER:
if (mFirstTimeInitialized && event.getRepeatCount() == 0
- && CameraActivity.mPowerShutter) {
+ && CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
onShutterButtonFocus(true);
}
return true;
@@ -2532,6 +2540,10 @@ public class PhotoModule
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
case KeyEvent.KEYCODE_VOLUME_DOWN:
+ if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()
+ && mFirstTimeInitialized) {
+ onShutterButtonClick();
+ }
return true;
case KeyEvent.KEYCODE_FOCUS:
if (mFirstTimeInitialized) {
@@ -2539,7 +2551,8 @@ public class PhotoModule
}
return true;
case KeyEvent.KEYCODE_POWER:
- if (CameraActivity.mPowerShutter && mFirstTimeInitialized) {
+ if (CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()
+ && mFirstTimeInitialized) {
onShutterButtonClick();
}
return true;
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index bdf656d..e6bf16d 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1207,25 +1207,41 @@ public class VideoModule implements CameraModule,
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
- mUI.onScaleStepResize(true);
+ if (event.getRepeatCount() == 0 && !CameraActivity.mPowerShutter &&
+ !CameraUtil.hasCameraKey()) {
+ mUI.clickShutter();
+ } else {
+ mUI.onScaleStepResize(true);
+ }
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
- mUI.onScaleStepResize(false);
+ if (event.getRepeatCount() == 0 && !CameraActivity.mPowerShutter &&
+ !CameraUtil.hasCameraKey()) {
+ mUI.clickShutter();
+ } else {
+ mUI.onScaleStepResize(false);
+ }
return true;
case KeyEvent.KEYCODE_CAMERA:
if (event.getRepeatCount() == 0) {
mUI.clickShutter();
- return true;
}
- break;
+ return true;
case KeyEvent.KEYCODE_DPAD_CENTER:
if (event.getRepeatCount() == 0) {
mUI.clickShutter();
- return true;
}
- break;
+ return true;
+ case KeyEvent.KEYCODE_POWER:
+ if (event.getRepeatCount() == 0 && CameraActivity.mPowerShutter &&
+ !CameraUtil.hasCameraKey()) {
+ mUI.clickShutter();
+ }
+ return true;
case KeyEvent.KEYCODE_MENU:
- if (mMediaRecorderRecording) return true;
+ if (mMediaRecorderRecording) {
+ return true;
+ }
break;
}
return false;
@@ -1235,14 +1251,21 @@ public class VideoModule implements CameraModule,
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
+ if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
+ mUI.pressShutter(false);
+ }
+ return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
+ if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
+ mUI.pressShutter(false);
+ }
return true;
case KeyEvent.KEYCODE_CAMERA:
mUI.pressShutter(false);
return true;
case KeyEvent.KEYCODE_POWER:
- if (CameraActivity.mPowerShutter) {
- onShutterButtonClick();
+ if (CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
+ mUI.pressShutter(false);
}
return true;
}
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 62b478d..30fda16 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -294,6 +294,9 @@ public class WideAnglePanoramaModule
CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(), activity);
mLocationManager = new LocationManager(mActivity, null);
+ // Power shutter
+ mActivity.initPowerShutter(mPreferences);
+
mMainHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -887,6 +890,10 @@ public class WideAnglePanoramaModule
}
mUI.showPreviewCover();
releaseCamera();
+
+ // Load the power shutter
+ mActivity.initPowerShutter(mPreferences);
+
synchronized (mRendererLock) {
mCameraTexture = null;
@@ -1164,14 +1171,38 @@ public class WideAnglePanoramaModule
public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
-
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ return true;
+ case KeyEvent.KEYCODE_CAMERA:
+ if (event.getRepeatCount() == 0) {
+ onShutterButtonClick();
+ }
+ return true;
+ case KeyEvent.KEYCODE_POWER:
+ return true;
+ }
return false;
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ if (!CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
+ onShutterButtonClick();
+ }
+ return true;
+ case KeyEvent.KEYCODE_POWER:
+ if (CameraActivity.mPowerShutter && !CameraUtil.hasCameraKey()) {
+ onShutterButtonClick();
+ }
+ return true;
+ }
return false;
}
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 966caa6..316d341 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -118,6 +118,9 @@ public class CameraUtil {
public static final String TRUE = "true";
public static final String FALSE = "false";
+ // Hardware camera key mask
+ private static final int KEY_MASK_CAMERA = 0x20;
+
// Fields for the show-on-maps-functionality
private static final String MAPS_PACKAGE_NAME = "com.google.android.apps.maps";
private static final String MAPS_CLASS_NAME = "com.google.android.maps.MapsActivity";
@@ -154,6 +157,10 @@ public class CameraUtil {
return (supported != null) && supported.contains(SCENE_MODE_HDR);
}
+ public static boolean hasCameraKey() {
+ return (sDeviceKeysPresent & KEY_MASK_CAMERA) != 0;
+ }
+
public static boolean isMeteringAreaSupported(Parameters params) {
return params.getMaxNumMeteringAreas() > 0;
}
@@ -179,6 +186,9 @@ public class CameraUtil {
private static float sPixelDensity = 1;
private static ImageFileNamer sImageFileNamer;
+ // Get available hardware keys
+ private static int sDeviceKeysPresent;
+
private CameraUtil() {
}
@@ -190,6 +200,8 @@ public class CameraUtil {
sPixelDensity = metrics.density;
sImageFileNamer = new ImageFileNamer(
context.getString(R.string.image_file_name_format));
+ sDeviceKeysPresent = context.getResources().getInteger(
+ com.android.internal.R.integer.config_deviceHardwareKeys);
}
public static int dpToPixel(int dp) {