summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorSascha Haeberling <haeberling@google.com>2013-08-28 15:28:57 -0700
committerSascha Haeberling <haeberling@google.com>2013-08-28 15:59:49 -0700
commit2654dd9bb6a7d917dab1a48e2182c4f49fe71f11 (patch)
tree3fc037b0280ded324cceb56a8b51e38769b3537e /src/com
parent2d1c49c2959d8b5adecd8bb5668fd50c1bf0190c (diff)
downloadandroid_packages_apps_Snap-2654dd9bb6a7d917dab1a48e2182c4f49fe71f11.tar.gz
android_packages_apps_Snap-2654dd9bb6a7d917dab1a48e2182c4f49fe71f11.tar.bz2
android_packages_apps_Snap-2654dd9bb6a7d917dab1a48e2182c4f49fe71f11.zip
Let the Camera app remember which mode it was started in last.
Bug: 7320368 Change-Id: Ia2ae47693f453c9bcff315af87fe1e5a44b6e5c7
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/camera/CameraActivity.java62
1 files changed, 47 insertions, 15 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 3a3dd0cc1..8efeba2e6 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
+import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
@@ -33,6 +34,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
+import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.provider.Settings;
import android.util.Log;
@@ -82,6 +84,8 @@ public class CameraActivity extends Activity
"com.android.camera.action.TRIM";
public static final String MEDIA_ITEM_PATH = "media-item-path";
+ private static final String PREF_STARTUP_MODULE_INDEX = "camera.startup_module";
+
// The intent extra for camera from secure lock screen. True if the gallery
// should only show newly captured pictures. sSecureAlbumId does not
// increment. This is used when switching between camera, camcorder, and
@@ -637,13 +641,28 @@ public class CameraActivity extends Activity
mFilmStripView.setPanoramaViewHelper(mPanoramaViewHelper);
// Set up the camera preview first so the preview shows up ASAP.
mFilmStripView.setListener(mFilmStripListener);
+
+ int moduleIndex = -1;
if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction())
|| MediaStore.ACTION_VIDEO_CAPTURE.equals(getIntent().getAction())) {
- mCurrentModule = new VideoModule();
- mCurrentModuleIndex = CameraSwitcher.VIDEO_MODULE_INDEX;
+ moduleIndex = CameraSwitcher.VIDEO_MODULE_INDEX;
+ } else if (MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA.equals(getIntent().getAction())
+ || MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(getIntent()
+ .getAction())
+ || MediaStore.ACTION_IMAGE_CAPTURE.equals(getIntent().getAction())
+ || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(getIntent().getAction())) {
+ moduleIndex = CameraSwitcher.PHOTO_MODULE_INDEX;
} else {
- mCurrentModule = new PhotoModule();
+ // If the activity has not been started using an explicit intent,
+ // read the module index from the last time the user changed modes
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ moduleIndex = prefs.getInt(PREF_STARTUP_MODULE_INDEX, -1);
+ if (moduleIndex < 0) {
+ moduleIndex = CameraSwitcher.PHOTO_MODULE_INDEX;
+ }
}
+ setModuleFromIndex(moduleIndex);
+
mCurrentModule.init(this, mCameraModuleRootView);
mOrientationListener = new MyOrientationEventListener(this);
mMainHandler = new Handler(getMainLooper());
@@ -834,13 +853,32 @@ public class CameraActivity extends Activity
}
@Override
- public void onCameraSelected(int i) {
- if (mCurrentModuleIndex == i) return;
+ public void onCameraSelected(int moduleIndex) {
+ if (mCurrentModuleIndex == moduleIndex) return;
CameraHolder.instance().keep();
closeModule(mCurrentModule);
- mCurrentModuleIndex = i;
- switch (i) {
+ setModuleFromIndex(moduleIndex);
+
+ openModule(mCurrentModule);
+ mCurrentModule.onOrientationChanged(mLastRawOrientation);
+ if (mMediaSaveService != null) {
+ mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService);
+ }
+
+ // Store the module index so we can use it the next time the Camera
+ // starts up.
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ prefs.edit().putInt(PREF_STARTUP_MODULE_INDEX, moduleIndex).apply();
+ }
+
+ /**
+ * Sets the mCurrentModuleIndex, creates a new module instance for the
+ * given index an sets it as mCurrentModule.
+ */
+ private void setModuleFromIndex(int moduleIndex) {
+ mCurrentModuleIndex = moduleIndex;
+ switch (moduleIndex) {
case CameraSwitcher.VIDEO_MODULE_INDEX:
mCurrentModule = new VideoModule();
break;
@@ -850,14 +888,8 @@ public class CameraActivity extends Activity
case CameraSwitcher.LIGHTCYCLE_MODULE_INDEX:
mCurrentModule = PhotoSphereHelper.createPanoramaModule();
break;
- default:
- break;
- }
-
- openModule(mCurrentModule);
- mCurrentModule.onOrientationChanged(mLastRawOrientation);
- if (mMediaSaveService != null) {
- mCurrentModule.onMediaSaveServiceConnected(mMediaSaveService);
+ default:
+ break;
}
}