summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2014-01-20 20:40:32 +0200
committerArne Coucheron <arco68@gmail.com>2018-01-26 00:53:20 +0100
commit7132454a49c67c1d8e27de20169249bd14790bea (patch)
tree507116a28a780a340b83f7421ad97779eecc27be /src/com
parentdce40170eca239b2232c2aa2d5a4489771fdac2b (diff)
downloadandroid_packages_apps_Snap-7132454a49c67c1d8e27de20169249bd14790bea.tar.gz
android_packages_apps_Snap-7132454a49c67c1d8e27de20169249bd14790bea.tar.bz2
android_packages_apps_Snap-7132454a49c67c1d8e27de20169249bd14790bea.zip
Camera: Powerkey shutter (2/2)
Ported from cm-10.1 Including cm-10.1 camera commit: aa4ae80a41fbab763891c5ef6d67a9e5b4bb981b Don't mess around with pref local ID for power shutter initialization. Includes http://review.cyanogenmod.org/56986 [mikeioannina]: Updates for L Signed-off-by: Michael Bestas <mikeioannina@gmail.com> Change-Id: I0992baa558eefd306d00fbece59cb5c512d9448b
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/CameraActivity.java16
-rw-r--r--src/com/android/camera/CameraSettings.java4
-rwxr-xr-xsrc/com/android/camera/ComboPreferences.java4
-rw-r--r--src/com/android/camera/PhotoMenu.java5
-rw-r--r--src/com/android/camera/PhotoModule.java26
-rw-r--r--src/com/android/camera/VideoMenu.java5
-rw-r--r--src/com/android/camera/VideoModule.java10
7 files changed, 67 insertions, 3 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index f679e26c3..d36f2294d 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013-2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -220,6 +221,8 @@ public class CameraActivity extends Activity
private final Object mStorageSpaceLock = new Object();
private long mStorageSpaceBytes = Storage.LOW_STORAGE_THRESHOLD_BYTES;
private boolean mSecureCamera;
+ // Keep track of powershutter state
+ public static boolean mPowerShutter = false;
private int mLastRawOrientation;
private MyOrientationEventListener mOrientationListener;
private Handler mMainHandler;
@@ -2000,6 +2003,19 @@ 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 (mPowerShutter /*TODO: && mShowCameraAppView*/) {
+ getWindow().addPrivateFlags(
+ WindowManager.LayoutParams.PRIVATE_FLAG_PREVENT_POWER_KEY);
+ } else {
+ getWindow().clearPrivateFlags(
+ WindowManager.LayoutParams.PRIVATE_FLAG_PREVENT_POWER_KEY);
+ }
+ }
+
protected void setResultEx(int resultCode) {
mResultCodeForTesting = resultCode;
setResult(resultCode);
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index 3c388c912..aa96612ff 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013-2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -81,6 +82,7 @@ public class CameraSettings {
public static final String KEY_PHOTOSPHERE_PICTURESIZE = "pref_photosphere_picturesize_key";
public static final String KEY_STARTUP_MODULE_INDEX = "camera.startup_module";
+ public static final String KEY_POWER_SHUTTER = "pref_power_shutter";
public static final String KEY_VIDEO_ENCODER = "pref_camera_videoencoder_key";
public static final String KEY_AUDIO_ENCODER = "pref_camera_audioencoder_key";
public static final String KEY_POWER_MODE = "pref_camera_powermode_key";
@@ -271,6 +273,8 @@ public class CameraSettings {
public static final String KEY_SELFIE_FLASH = "pref_selfie_flash_key";
public static final String EXPOSURE_DEFAULT_VALUE = "0";
+ public static final String VALUE_ON = "on";
+ public static final String VALUE_OFF = "off";
public static final int CURRENT_VERSION = 5;
public static final int CURRENT_LOCAL_VERSION = 2;
diff --git a/src/com/android/camera/ComboPreferences.java b/src/com/android/camera/ComboPreferences.java
index de6db8e9d..107360a55 100755
--- a/src/com/android/camera/ComboPreferences.java
+++ b/src/com/android/camera/ComboPreferences.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2013-2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -157,7 +158,8 @@ public class ComboPreferences implements
|| key.equals(SettingsManager.KEY_MONO_ONLY)
|| key.equals(SettingsManager.KEY_MONO_PREVIEW)
|| key.equals(SettingsManager.KEY_SWITCH_CAMERA)
- || key.equals(SettingsManager.KEY_CLEARSIGHT);
+ || key.equals(SettingsManager.KEY_CLEARSIGHT)
+ || key.equals(CameraSettings.KEY_POWER_SHUTTER);
}
@Override
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index 5b3ea1eb2..e23faa42f 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013-2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -199,7 +200,8 @@ public class PhotoMenu extends MenuController
CameraSettings.KEY_QC_CHROMA_FLASH,
CameraSettings.KEY_REDEYE_REDUCTION,
CameraSettings.KEY_SELFIE_MIRROR,
- CameraSettings.KEY_SHUTTER_SOUND
+ CameraSettings.KEY_SHUTTER_SOUND,
+ CameraSettings.KEY_POWER_SHUTTER
};
mOtherKeys2 = new String[] {
@@ -218,6 +220,7 @@ public class PhotoMenu extends MenuController
CameraSettings.KEY_QC_CHROMA_FLASH,
CameraSettings.KEY_FOCUS_MODE,
CameraSettings.KEY_REDEYE_REDUCTION,
+ CameraSettings.KEY_POWER_SHUTTER,
CameraSettings.KEY_AUTO_HDR,
CameraSettings.KEY_HDR_MODE,
CameraSettings.KEY_HDR_NEED_1X,
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 95ef283c0..7f18144f0 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013-2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -598,6 +599,10 @@ public class PhotoModule
CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
mUI = new PhotoUI(activity, this, parent);
+
+ // Power shutter
+ mActivity.initPowerShutter(mPreferences);
+
if (mOpenCameraThread == null) {
mOpenCameraThread = new OpenCameraThread();
mOpenCameraThread.start();
@@ -2792,6 +2797,9 @@ public class PhotoModule
// (e.g. onResume -> onPause -> onResume).
stopPreview();
+ // Load the power shutter
+ mActivity.initPowerShutter(mPreferences);
+
mNamedImages = null;
if (mLocationManager != null) mLocationManager.recordLocation(false);
@@ -2941,6 +2949,9 @@ public class PhotoModule
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
+ /*TODO: if (!mActivity.mShowCameraAppView) {
+ return false;
+ }*/
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (/*TODO: mActivity.isInCameraApp() &&*/ mFirstTimeInitialized
@@ -2978,12 +2989,21 @@ public class PhotoModule
mUI.pressShutterButton();
}
return true;
+ case KeyEvent.KEYCODE_POWER:
+ if (mFirstTimeInitialized && event.getRepeatCount() == 0
+ && CameraActivity.mPowerShutter) {
+ onShutterButtonFocus(true);
+ }
+ return true;
}
return false;
}
@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:
@@ -2993,6 +3013,11 @@ public class PhotoModule
onShutterButtonFocus(false);
}
return true;
+ case KeyEvent.KEYCODE_POWER:
+ if (CameraActivity.mPowerShutter && mFirstTimeInitialized) {
+ onShutterButtonClick();
+ }
+ return true;
}
return false;
}
@@ -4954,6 +4979,7 @@ public class PhotoModule
setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE);
mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup,
mPreferences);
+ mActivity.initPowerShutter(mPreferences);
} else {
mHandler.sendEmptyMessage(SET_PHOTO_UI_PARAMS);
}
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
index e891ce7af..29d22ac85 100644
--- a/src/com/android/camera/VideoMenu.java
+++ b/src/com/android/camera/VideoMenu.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013-2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -117,7 +118,8 @@ public class VideoMenu extends MenuController
CameraSettings.KEY_EXPOSURE,
CameraSettings.KEY_WHITE_BALANCE,
CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
- CameraSettings.KEY_DIS
+ CameraSettings.KEY_DIS,
+ CameraSettings.KEY_POWER_SHUTTER
};
mOtherKeys2 = new String[] {
CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
@@ -128,6 +130,7 @@ public class VideoMenu extends MenuController
CameraSettings.KEY_WHITE_BALANCE,
CameraSettings.KEY_FACE_DETECTION,
CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
+ CameraSettings.KEY_POWER_SHUTTER,
CameraSettings.KEY_SEE_MORE,
CameraSettings.KEY_NOISE_REDUCTION,
CameraSettings.KEY_DIS,
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 7c5a88e6f..a509b8f32 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 The Android Open Source Project
+ * Copyright (C) 2013-2015 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -506,6 +507,9 @@ public class VideoModule implements CameraModule,
mOrientationManager = new OrientationManager(mActivity);
+ // Power shutter
+ mActivity.initPowerShutter(mPreferences);
+
/*
* To reduce startup time, we start the preview in another thread.
* We make sure the preview is started at the end of onCreate.
@@ -1415,6 +1419,11 @@ public class VideoModule implements CameraModule,
case KeyEvent.KEYCODE_CAMERA:
mUI.pressShutter(false);
return true;
+ case KeyEvent.KEYCODE_POWER:
+ if (CameraActivity.mPowerShutter) {
+ onShutterButtonClick();
+ }
+ return true;
}
return false;
}
@@ -2916,6 +2925,7 @@ public class VideoModule implements CameraModule,
Storage.setSaveSDCard(
mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1"));
mActivity.updateStorageSpaceAndHint();
+ mActivity.initPowerShutter(mPreferences);
}
}