diff options
author | Michael Bestas <mikeioannina@gmail.com> | 2014-01-20 20:40:32 +0200 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-11-02 12:22:26 -0700 |
commit | 85c301a49187a33e766766591a1a1de97377608a (patch) | |
tree | 1c41846bd79618b34f9851c59dc176714ad8be51 /src/com/android/camera | |
parent | 032c6038f5206de8ea28ecaebe4c62b04367f91e (diff) | |
download | android_packages_apps_Snap-85c301a49187a33e766766591a1a1de97377608a.tar.gz android_packages_apps_Snap-85c301a49187a33e766766591a1a1de97377608a.tar.bz2 android_packages_apps_Snap-85c301a49187a33e766766591a1a1de97377608a.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/android/camera')
-rwxr-xr-x | src/com/android/camera/CameraActivity.java | 16 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/ComboPreferences.java | 4 | ||||
-rwxr-xr-x | src/com/android/camera/PhotoMenu.java | 3 | ||||
-rwxr-xr-x | src/com/android/camera/PhotoModule.java | 26 | ||||
-rw-r--r-- | src/com/android/camera/VideoMenu.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/VideoModule.java | 10 |
7 files changed, 66 insertions, 2 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 8ed4fb812..f34bf7386 100755 --- 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. @@ -211,6 +212,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; @@ -1924,6 +1927,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 f1a858613..19de894c7 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"; @@ -254,6 +256,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 24a5612c7..8031ab149 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. @@ -157,7 +158,8 @@ public class ComboPreferences implements || key.equals(SettingsManager.KEY_CAMERA_ID) || key.equals(SettingsManager.KEY_MONO_ONLY) || key.equals(SettingsManager.KEY_MONO_PREVIEW) - || 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 dca66d1cb..1b57253cc 100755 --- 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. @@ -194,6 +195,7 @@ public class PhotoMenu extends MenuController CameraSettings.KEY_REDEYE_REDUCTION, CameraSettings.KEY_SELFIE_MIRROR, CameraSettings.KEY_SHUTTER_SOUND + CameraSettings.KEY_POWER_SHUTTER }; mOtherKeys2 = new String[] { @@ -212,6 +214,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 1279d9cbf..9305392cc 100755 --- 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. @@ -572,6 +573,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(); @@ -2590,6 +2595,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); @@ -2743,6 +2751,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: case KeyEvent.KEYCODE_VOLUME_DOWN: @@ -2770,12 +2781,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: @@ -2789,6 +2809,11 @@ public class PhotoModule onShutterButtonFocus(false); } return true; + case KeyEvent.KEYCODE_POWER: + if (CameraActivity.mPowerShutter && mFirstTimeInitialized) { + onShutterButtonClick(); + } + return true; } return false; } @@ -4649,6 +4674,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 f04989d0b..7af839bb7 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 76aa8a623..1a7b8b0b6 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. @@ -500,6 +501,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. @@ -1398,6 +1402,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; } @@ -2828,6 +2837,7 @@ public class VideoModule implements CameraModule, Storage.setSaveSDCard( mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH, "0").equals("1")); mActivity.updateStorageSpaceAndHint(); + mActivity.initPowerShutter(mPreferences); } } |