OSDN Git Service

Starting share/edit/play activities in its own task.
authorSenpo Hu <senpo@google.com>
Fri, 29 Aug 2014 23:27:03 +0000 (16:27 -0700)
committerSenpo Hu <senpo@google.com>
Tue, 2 Sep 2014 18:51:15 +0000 (11:51 -0700)
Bug: 17091348
Change-Id: Ib90173e164fab2a1aba753ab4d4f05d305d3d522

src/com/android/camera/CameraActivity.java
src/com/android/camera/VideoModule.java
src/com/android/camera/util/CameraUtil.java

index 43cddd2..55f1d40 100644 (file)
@@ -175,14 +175,6 @@ public class CameraActivity extends Activity
     public static final String MODULE_SCOPE_PREFIX = "_preferences_module_";
     public static final String CAMERA_SCOPE_PREFIX = "_preferences_camera_";
 
-    /**
-     * Request code from an activity we started that indicated that we do not
-     * want to reset the view to the preview in onResume.
-     */
-    public static final int REQ_CODE_DONT_SWITCH_TO_PREVIEW = 142;
-
-    public static final int REQ_CODE_GCAM_DEBUG_POSTCAPTURE = 999;
-
     private static final int MSG_CLEAR_SCREEN_ON_FLAG = 2;
     private static final long SCREEN_DELAY_MS = 2 * 60 * 1000; // 2 mins.
     private static final int MAX_PEEK_BITMAP_PIXELS = 1600000; // 1.6 * 4 MBs.
@@ -976,7 +968,11 @@ public class CameraActivity extends Activity
 
     @Override
     public void launchActivityByIntent(Intent intent) {
-        startActivityForResult(intent, REQ_CODE_DONT_SWITCH_TO_PREVIEW);
+        // Starting from L, we prefer not to start edit activity within camera's task.
+        mResetToPreviewOnResume = false;
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+        startActivity(intent);
     }
 
     @Override
@@ -1640,15 +1636,6 @@ public class CameraActivity extends Activity
     }
 
     @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        if (requestCode == REQ_CODE_DONT_SWITCH_TO_PREVIEW) {
-            mResetToPreviewOnResume = false;
-        } else {
-            super.onActivityResult(requestCode, resultCode, data);
-        }
-    }
-
-    @Override
     public void onResume() {
         CameraPerformanceTracker.onEvent(CameraPerformanceTracker.ACTIVITY_RESUME);
         Log.v(TAG, "Build info: " + Build.DISPLAY);
index 4e92385..0bdb9a3 100644 (file)
@@ -609,9 +609,9 @@ public class VideoModule extends CameraModule
     private void startPlayVideoActivity() {
         Intent intent = new Intent(Intent.ACTION_VIEW);
         intent.setDataAndType(mCurrentVideoUri, convertOutputFormatToMimeType(mProfile.fileFormat));
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         try {
-            mActivity
-                    .startActivityForResult(intent, CameraActivity.REQ_CODE_DONT_SWITCH_TO_PREVIEW);
+            mActivity.startActivity(intent);
         } catch (ActivityNotFoundException ex) {
             Log.e(TAG, "Couldn't view video " + mCurrentVideoUri, ex);
         }
index ff19a4d..2e18536 100644 (file)
@@ -976,7 +976,8 @@ public class CameraUtil {
                 Intent intent = IntentHelper.getVideoPlayerIntent(uri)
                         .putExtra(Intent.EXTRA_TITLE, title)
                         .putExtra(KEY_TREAT_UP_AS_BACK, true);
-                activity.startActivityForResult(intent, CameraActivity.REQ_CODE_DONT_SWITCH_TO_PREVIEW);
+                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                activity.startActivity(intent);
             } else {
                 // In order not to send out any intent to be intercepted and
                 // show the lock screen immediately, we just let the secure
@@ -1008,8 +1009,8 @@ public class CameraUtil {
                     MAPS_CLASS_NAME);
             Intent mapsIntent = new Intent(Intent.ACTION_VIEW,
                     Uri.parse(uri)).setComponent(compName);
-            activity.startActivityForResult(mapsIntent,
-                    CameraActivity.REQ_CODE_DONT_SWITCH_TO_PREVIEW);
+            mapsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            activity.startActivity(mapsIntent);
         } catch (ActivityNotFoundException e) {
             // Use the "geo intent" if no GMM is installed
             Log.e(TAG, "GMM activity not found!", e);