diff options
author | Danesh Mondegarian <daneshm90@gmail.com> | 2013-10-19 04:38:16 +0300 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2013-10-25 02:28:07 -0700 |
commit | d66e59ddeb9d45ca31ad71c662a4c4e62b196468 (patch) | |
tree | f791494159521dc075edff24bb5517357fe6475b /src/com/android | |
parent | 148fd03e0aded0c5e5188c64a35d554a052eba7d (diff) | |
download | android_packages_apps_Gallery2-d66e59ddeb9d45ca31ad71c662a4c4e62b196468.tar.gz android_packages_apps_Gallery2-d66e59ddeb9d45ca31ad71c662a4c4e62b196468.tar.bz2 android_packages_apps_Gallery2-d66e59ddeb9d45ca31ad71c662a4c4e62b196468.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.
Signed-off-by: Michael Bestas <mikeioannina@gmail.com>
Change-Id: I0992baa558eefd306d00fbece59cb5c512d9448b
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/camera/ActivityBase.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 6 | ||||
-rw-r--r-- | src/com/android/camera/ComboPreferences.java | 2 | ||||
-rw-r--r-- | src/com/android/camera/PhotoMenu.java | 3 | ||||
-rw-r--r-- | src/com/android/camera/PhotoModule.java | 28 | ||||
-rw-r--r-- | src/com/android/camera/RecordLocationPreference.java | 7 | ||||
-rw-r--r-- | src/com/android/camera/VideoMenu.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/VideoModule.java | 13 |
8 files changed, 69 insertions, 9 deletions
diff --git a/src/com/android/camera/ActivityBase.java b/src/com/android/camera/ActivityBase.java index 31710494a..4b74acd84 100644 --- a/src/com/android/camera/ActivityBase.java +++ b/src/com/android/camera/ActivityBase.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 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. @@ -82,6 +83,9 @@ public abstract class ActivityBase extends AbstractGalleryActivity protected boolean mPaused; protected GalleryActionBar mActionBar; + // Keep track of powershutter state + public static boolean mPowerShutter = false; + // multiple cameras support protected int mNumberOfCameras; protected int mCameraId; @@ -226,6 +230,17 @@ public abstract class ActivityBase extends AbstractGalleryActivity return true; } + 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 && mShowCameraAppView) { + getWindow().addFlags(WindowManager.LayoutParams.PREVENT_POWER_KEY); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.PREVENT_POWER_KEY); + } + } + @Override protected void onResume() { super.onResume(); diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index cbdfb3f91..43d8cdcd8 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 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. @@ -70,8 +71,11 @@ public class CameraSettings { public static final String KEY_PHOTOSPHERE_PICTURESIZE = "pref_photosphere_picturesize_key"; public static final String KEY_STORAGE = "pref_camera_storage_key"; public static final String KEY_VIDEO_HDR = "pref_camera_video_hdr_key"; + public static final String KEY_POWER_SHUTTER = "pref_power_shutter"; 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; @@ -452,7 +456,7 @@ public class CameraSettings { if (version == 2) { editor.putString(KEY_RECORD_LOCATION, pref.getBoolean(KEY_RECORD_LOCATION, false) - ? RecordLocationPreference.VALUE_ON + ? CameraSettings.VALUE_ON : RecordLocationPreference.VALUE_NONE); version = 3; } diff --git a/src/com/android/camera/ComboPreferences.java b/src/com/android/camera/ComboPreferences.java index aa39fcceb..183392ad7 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 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,6 +153,7 @@ 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_POWER_SHUTTER) || key.equals(CameraSettings.KEY_STORAGE); } diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java index 68f65a0c1..88f5a0347 100644 --- a/src/com/android/camera/PhotoMenu.java +++ b/src/com/android/camera/PhotoMenu.java @@ -211,7 +211,8 @@ public class PhotoMenu extends PieController } // extra settings popup mOtherKeys = new String[] { - CameraSettings.KEY_FOCUS_MODE + CameraSettings.KEY_FOCUS_MODE, + CameraSettings.KEY_POWER_SHUTTER }; item = makeItem(R.drawable.ic_settings_holo_light); item.setLabel(res.getString(R.string.camera_menu_more_label).toUpperCase(locale)); diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index d9c810396..35d759a75 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 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. @@ -502,7 +503,7 @@ public class PhotoModule .setPositiveButton(R.string.remember_location_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { - setLocationPreference(RecordLocationPreference.VALUE_ON); + setLocationPreference(CameraSettings.VALUE_ON); } }) .setNegativeButton(R.string.remember_location_no, new DialogInterface.OnClickListener() { @@ -514,7 +515,7 @@ public class PhotoModule .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { - setLocationPreference(RecordLocationPreference.VALUE_OFF); + setLocationPreference(CameraSettings.VALUE_OFF); } }) .show(); @@ -1399,6 +1400,8 @@ public class PhotoModule @Override public void updateCameraAppView() { + // Setup Power shutter + mActivity.initPowerShutter(mPreferences); } @Override @@ -1497,6 +1500,9 @@ public class PhotoModule resetScreenOn(); + // Load the power shutter + mActivity.initPowerShutter(mPreferences); + mNamedImages = null; if (mLocationManager != null) mLocationManager.recordLocation(false); @@ -1629,6 +1635,9 @@ public class PhotoModule @Override public boolean onKeyDown(int keyCode, KeyEvent event) { + if (!mActivity.mShowCameraAppView) { + return false; + } switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (mActivity.isInCameraApp() && mFirstTimeInitialized @@ -1670,12 +1679,21 @@ public class PhotoModule mUI.pressShutterButton(); } return true; + case KeyEvent.KEYCODE_POWER: + if (mFirstTimeInitialized && event.getRepeatCount() == 0 + && ActivityBase.mPowerShutter) { + onShutterButtonFocus(true); + } + return true; } return false; } @Override public boolean onKeyUp(int keyCode, KeyEvent event) { + if (!mActivity.mShowCameraAppView) { + return false; + } switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: case KeyEvent.KEYCODE_VOLUME_DOWN: @@ -1685,6 +1703,11 @@ public class PhotoModule onShutterButtonFocus(false); } return true; + case KeyEvent.KEYCODE_POWER: + if (ActivityBase.mPowerShutter) { + onShutterButtonClick(); + } + return true; } return false; } @@ -2116,6 +2139,7 @@ public class PhotoModule resizeForPreviewAspectRatio(); mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup, mPreferences); + mActivity.initPowerShutter(mPreferences); } else { mHandler.sendEmptyMessage(SET_PHOTO_UI_PARAMS); } diff --git a/src/com/android/camera/RecordLocationPreference.java b/src/com/android/camera/RecordLocationPreference.java index 9992afabb..c74e77824 100644 --- a/src/com/android/camera/RecordLocationPreference.java +++ b/src/com/android/camera/RecordLocationPreference.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 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. @@ -28,8 +29,6 @@ import android.util.AttributeSet; public class RecordLocationPreference extends IconListPreference { public static final String VALUE_NONE = "none"; - public static final String VALUE_ON = "on"; - public static final String VALUE_OFF = "off"; private final ContentResolver mResolver; @@ -40,14 +39,14 @@ public class RecordLocationPreference extends IconListPreference { @Override public String getValue() { - return get(getSharedPreferences(), mResolver) ? VALUE_ON : VALUE_OFF; + return get(getSharedPreferences(), mResolver) ? CameraSettings.VALUE_ON : CameraSettings.VALUE_OFF; } public static boolean get( SharedPreferences pref, ContentResolver resolver) { String value = pref.getString( CameraSettings.KEY_RECORD_LOCATION, VALUE_NONE); - return VALUE_ON.equals(value); + return CameraSettings.VALUE_ON.equals(value); } public static boolean isSet(SharedPreferences pref) { diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java index 83819002d..ac5d3ab94 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 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. @@ -72,7 +73,8 @@ public class VideoMenu extends PieController CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL, CameraSettings.KEY_VIDEO_QUALITY, CameraSettings.KEY_RECORD_LOCATION, - CameraSettings.KEY_STORAGE + CameraSettings.KEY_STORAGE, + CameraSettings.KEY_POWER_SHUTTER }; item = makeItem(R.drawable.ic_settings_holo_light); item.setLabel(mActivity.getResources().getString(R.string.camera_menu_settings_label)); diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index 97e5d90bf..2ee1cfc95 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 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. @@ -415,6 +416,9 @@ public class VideoModule implements CameraModule, mPrefVideoEffectDefault = mActivity.getString(R.string.pref_video_effect_default); resetEffect(); + // 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. @@ -1248,6 +1252,11 @@ public class VideoModule implements CameraModule, case KeyEvent.KEYCODE_CAMERA: mUI.pressShutter(false); return true; + case KeyEvent.KEYCODE_POWER: + if (ActivityBase.mPowerShutter) { + onShutterButtonClick(); + } + return true; } return false; } @@ -2304,6 +2313,7 @@ public class VideoModule implements CameraModule, setCameraParameters(); } mUI.updateOnScreenIndicators(mParameters, mPreferences); + mActivity.initPowerShutter(mPreferences); } } @@ -2456,6 +2466,9 @@ public class VideoModule implements CameraModule, public void updateCameraAppView() { if (!mPreviewing || mParameters.getFlashMode() == null) return; + // Setup Power shutter + mActivity.initPowerShutter(mPreferences); + // When going to and back from gallery, we need to turn off/on the flash. if (!mActivity.mShowCameraAppView) { if (mParameters.getFlashMode().equals(Parameters.FLASH_MODE_OFF)) { |