summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2016-05-23 11:17:28 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-05-23 11:26:31 (GMT)
commitd5e574a606fbccec88c32e43c4e0d216b597d1c1 (patch)
tree8a620ba4c0cda3eb6ffc49b67f09f0a2268c7820
parentf2d026d1b923e05c5d407f36fd23f75301635764 (diff)
downloadandroid_packages_apps_Gallery2-d5e574a606fbccec88c32e43c4e0d216b597d1c1.zip
android_packages_apps_Gallery2-d5e574a606fbccec88c32e43c4e0d216b597d1c1.tar.gz
android_packages_apps_Gallery2-d5e574a606fbccec88c32e43c4e0d216b597d1c1.tar.bz2
Gallery: Try to open existing camera
Do not just open Camera2, just open any existing cam Also get rid of context parameter as it's unused (Reference: BugReports 13-20160506-12 Line #5) Change-Id: I18514ee30411a639230840fc2f152b8331bbca3d
-rw-r--r--src/com/android/camera/CameraActivity.java18
-rw-r--r--src/com/android/gallery3d/app/Gallery.java2
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java2
-rw-r--r--src_pd/com/android/gallery3d/util/IntentHelper.java9
4 files changed, 17 insertions, 14 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index b74af47..9462aed 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -15,6 +15,7 @@
*/
package com.android.camera;
+import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.IntentHelper;
import android.app.Activity;
@@ -26,13 +27,16 @@ public class CameraActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- Intent intent = IntentHelper.getCameraIntent(CameraActivity.this);
- // Since this is being launched from a homescreen shorcut,
- // it's already in a new task. Start Camera activity and
- // reset the task to its initial state if needed.
- intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
+
+ if (GalleryUtils.isCameraAvailable(CameraActivity.this)) {
+ Intent intent = IntentHelper.getCameraIntent();
+ // Since this is being launched from a homescreen shorcut,
+ // it's already in a new task. Start Camera activity and
+ // reset the task to its initial state if needed.
+ intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ }
finish();
}
}
diff --git a/src/com/android/gallery3d/app/Gallery.java b/src/com/android/gallery3d/app/Gallery.java
index fd9097d..df3c0f9 100644
--- a/src/com/android/gallery3d/app/Gallery.java
+++ b/src/com/android/gallery3d/app/Gallery.java
@@ -26,7 +26,7 @@ public class Gallery extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- Intent intent = IntentHelper.getGalleryIntent(Gallery.this);
+ Intent intent = IntentHelper.getGalleryIntent();
// Since this is being launched from a homescreen shortcut,
// it's already in a new task. Start Gallery activity and
// reset the task to its initial state if needed.
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index 8e4ebb7..ed28705 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -238,7 +238,7 @@ public class GalleryUtils {
public static boolean isCameraAvailable(Context context) {
if (sCameraAvailableInitialized) return sCameraAvailable;
PackageManager pm = context.getPackageManager();
- Intent cameraIntent = IntentHelper.getCameraIntent(context);
+ Intent cameraIntent = IntentHelper.getCameraIntent();
List<ResolveInfo> apps = pm.queryIntentActivities(cameraIntent, 0);
sCameraAvailableInitialized = true;
sCameraAvailable = !apps.isEmpty();
diff --git a/src_pd/com/android/gallery3d/util/IntentHelper.java b/src_pd/com/android/gallery3d/util/IntentHelper.java
index 8aebfc1..d0fb59a 100644
--- a/src_pd/com/android/gallery3d/util/IntentHelper.java
+++ b/src_pd/com/android/gallery3d/util/IntentHelper.java
@@ -15,17 +15,16 @@
*/
package com.android.gallery3d.util;
-import android.content.Context;
import android.content.Intent;
+import android.provider.MediaStore;
public class IntentHelper {
- public static Intent getCameraIntent(Context context) {
- return new Intent(Intent.ACTION_MAIN)
- .setClassName("com.android.camera2", "com.android.camera.CameraLauncher");
+ public static Intent getCameraIntent() {
+ return new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
}
- public static Intent getGalleryIntent(Context context) {
+ public static Intent getGalleryIntent() {
return new Intent(Intent.ACTION_MAIN)
.setClassName("com.android.gallery3d", "com.android.gallery3d.app.GalleryActivity");
}