summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2014-01-20 20:40:32 +0200
committerMichael Bestas <mikeioannina@gmail.com>2015-09-17 23:26:02 +0300
commit69fe66517f086a01b6f9fb80e669256ec11c6625 (patch)
treef2645455775f1fe11616071ae9771ab418832247
parent090a890049355881cba3ed6d503aebafae056384 (diff)
downloadandroid_packages_apps_Snap-69fe66517f086a01b6f9fb80e669256ec11c6625.tar.gz
android_packages_apps_Snap-69fe66517f086a01b6f9fb80e669256ec11c6625.tar.bz2
android_packages_apps_Snap-69fe66517f086a01b6f9fb80e669256ec11c6625.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
-rw-r--r--AndroidManifest.xml1
-rw-r--r--res/values/cm_arrays.xml27
-rw-r--r--res/values/cm_strings.xml4
-rw-r--r--res/xml/camera_preferences.xml6
-rw-r--r--res/xml/video_preferences.xml6
-rw-r--r--src/com/android/camera/CameraActivity.java16
-rw-r--r--src/com/android/camera/CameraSettings.java4
-rw-r--r--src/com/android/camera/ComboPreferences.java4
-rw-r--r--src/com/android/camera/PhotoMenu.java5
-rw-r--r--src/com/android/camera/PhotoModule.java25
-rw-r--r--src/com/android/camera/VideoMenu.java5
-rw-r--r--src/com/android/camera/VideoModule.java10
12 files changed, 110 insertions, 3 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 01211061f..c2e35c5c2 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -34,6 +34,7 @@
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
+ <uses-permission android:name="android.permission.PREVENT_POWER_KEY" />
<supports-screens
android:anyDensity="true"
diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml
new file mode 100644
index 000000000..b308c083e
--- /dev/null
+++ b/res/values/cm_arrays.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="pref_switch_entryvalues" translatable="false">
+ <item>off</item>
+ <item>on</item>
+ </string-array>
+
+ <array name="pref_switch_entries" translatable="false">
+ <item>@string/setting_off</item>
+ <item>@string/setting_on</item>
+ </array>
+</resources>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 126e2043d..e803ae6f5 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -142,4 +142,8 @@
<!-- Red eye flash mode title -->
<string name="pref_camera_flashmode_entry_redeye">Red eye</string>
<string name="pref_camera_flashmode_label_redeye">RED EYE</string>
+
+ <!-- Power shutter -->
+ <string name="pref_camera_power_shutter_title">Power shutter</string>
+ <string name="pref_camera_power_shutter_default" translatable="false">off</string>
</resources>
diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml
index 6fc88a35f..2f48c20e3 100644
--- a/res/xml/camera_preferences.xml
+++ b/res/xml/camera_preferences.xml
@@ -341,4 +341,10 @@
camera:title="@string/pref_camera_manual_focus_title"
camera:entries="@array/pref_camera_manual_focus_entries"
camera:entryValues="@array/pref_camera_manual_focus_entry_values" />
+ <ListPreference
+ camera:key="pref_power_shutter"
+ camera:defaultValue="@string/pref_camera_power_shutter_default"
+ camera:title="@string/pref_camera_power_shutter_title"
+ camera:entries="@array/pref_switch_entries"
+ camera:entryValues="@array/pref_switch_entryvalues" />
</PreferenceGroup>
diff --git a/res/xml/video_preferences.xml b/res/xml/video_preferences.xml
index 2c67a4782..91452ce94 100644
--- a/res/xml/video_preferences.xml
+++ b/res/xml/video_preferences.xml
@@ -161,4 +161,10 @@
camera:title="@string/pref_camera_video_rotation_title"
camera:entries="@array/pref_camera_video_rotation_entries"
camera:entryValues="@array/pref_camera_video_rotation_entryvalues" />
+ <ListPreference
+ camera:key="pref_power_shutter"
+ camera:defaultValue="@string/pref_camera_power_shutter_default"
+ camera:title="@string/pref_camera_power_shutter_title"
+ camera:entries="@array/pref_switch_entries"
+ camera:entryValues="@array/pref_switch_entryvalues" />
</PreferenceGroup>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index c900d1bf4..77438881c 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.
@@ -198,6 +199,8 @@ public class CameraActivity extends Activity
private OnScreenHint mStorageHint;
private long mStorageSpaceBytes = Storage.LOW_STORAGE_THRESHOLD_BYTES;
private boolean mSecureCamera;
+ // Keep track of powershutter state
+ public static boolean mPowerShutter = false;
// This is a hack to speed up the start of SecureCamera.
private static boolean sFirstStartAfterScreenOn = true;
private int mLastRawOrientation;
@@ -1773,6 +1776,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 b60c65914..b986f5b1e 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.
@@ -77,6 +78,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";
@@ -236,6 +238,8 @@ public class CameraSettings {
public static final String KEY_TS_MAKEUP_LEVEL_CLEAN = "pref_camera_tsmakeup_clean";
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 d0039ab9e..2d2bc85ca 100644
--- 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.
@@ -152,7 +153,8 @@ public class ComboPreferences implements
|| key.equals(CameraSettings.KEY_TIMER)
|| key.equals(CameraSettings.KEY_TIMER_SOUND_EFFECTS)
|| key.equals(CameraSettings.KEY_PHOTOSPHERE_PICTURESIZE)
- || key.equals(CameraSettings.KEY_CAMERA_SAVEPATH);
+ || key.equals(CameraSettings.KEY_CAMERA_SAVEPATH)
+ || key.equals(CameraSettings.KEY_POWER_SHUTTER);
}
@Override
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index 534924281..0d16c7d36 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.
@@ -180,7 +181,8 @@ public class PhotoMenu extends MenuController
CameraSettings.KEY_EXPOSURE,
CameraSettings.KEY_WHITE_BALANCE,
CameraSettings.KEY_FOCUS_MODE,
- CameraSettings.KEY_REDEYE_REDUCTION
+ CameraSettings.KEY_REDEYE_REDUCTION,
+ CameraSettings.KEY_POWER_SHUTTER
};
mOtherKeys2 = new String[] {
@@ -197,6 +199,7 @@ public class PhotoMenu extends MenuController
CameraSettings.KEY_WHITE_BALANCE,
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 c23c41f9c..9a798d50b 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.
@@ -493,6 +494,9 @@ public class PhotoModule
mPreferences.setLocalId(mActivity, mCameraId);
CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
+ // Power shutter
+ mActivity.initPowerShutter(mPreferences);
+
if (mOpenCameraThread == null) {
mOpenCameraThread = new OpenCameraThread();
mOpenCameraThread.start();
@@ -2315,6 +2319,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);
@@ -2467,6 +2474,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
@@ -2504,12 +2514,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:
@@ -2519,6 +2538,11 @@ public class PhotoModule
onShutterButtonFocus(false);
}
return true;
+ case KeyEvent.KEYCODE_POWER:
+ if (CameraActivity.mPowerShutter && mFirstTimeInitialized) {
+ onShutterButtonClick();
+ }
+ return true;
}
return false;
}
@@ -4184,6 +4208,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 ead8645f0..bfce0db69 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.
@@ -113,7 +114,8 @@ public class VideoMenu extends MenuController
CameraSettings.KEY_CAMERA_SAVEPATH,
CameraSettings.KEY_EXPOSURE,
CameraSettings.KEY_WHITE_BALANCE,
- CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE
+ CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
+ CameraSettings.KEY_POWER_SHUTTER
};
mOtherKeys2 = new String[] {
CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
@@ -123,6 +125,7 @@ public class VideoMenu extends MenuController
CameraSettings.KEY_EXPOSURE,
CameraSettings.KEY_WHITE_BALANCE,
CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
+ CameraSettings.KEY_POWER_SHUTTER,
CameraSettings.KEY_SEE_MORE,
CameraSettings.KEY_DIS,
CameraSettings.KEY_VIDEO_EFFECT,
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index ee06289f2..bdf656da6 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.
@@ -439,6 +440,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.
@@ -1236,6 +1240,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;
}
@@ -2503,6 +2512,7 @@ public class VideoModule implements CameraModule,
Storage.setSaveSDCard(
mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1"));
mActivity.updateStorageSpaceAndHint();
+ mActivity.initPowerShutter(mPreferences);
}
}