Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab9effef authored by Michael W's avatar Michael W Committed by LuK1337
Browse files

Gallery2: 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: I120a1561aeceda2fc23721aa2ff4d68710fab76c
parent d766ecf7
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -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);

        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();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,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();
+4 −5
Original line number Diff line number Diff line
@@ -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");
    }