diff options
author | 2025-02-26 14:57:04 +0000 | |
---|---|---|
committer | 2025-02-26 14:57:04 +0000 | |
commit | a51d95a4328f8f6f64ce476a8594138b71881c9d (patch) | |
tree | f3e0fe880c7e9c5a19d913e89391b237dc30c06c | |
parent | c2a33420922209a61a007d1ca5ae77976b59aceb (diff) |
Make editor invocation from long screenshots honor preferred editor.
It was doing its own intent creation because it needs to special-case
some of the params for the shared element transition. This change makes
it use ActionIntentCreator and modify the Intent after that as needed.
Test: Manual verification of editor shared transition with flag on.
Bug: 391401141
Flag: com.android.systemui.shared.use_preferred_image_editor
Change-Id: I371395f82cc50e6d0c003ecb1892f09a3fbbea5a
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/screenshot/scroll/LongScreenshotActivity.java | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/scroll/LongScreenshotActivity.java b/packages/SystemUI/src/com/android/systemui/screenshot/scroll/LongScreenshotActivity.java index 48e08a0496c1..ecea30f1b1c3 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/scroll/LongScreenshotActivity.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/scroll/LongScreenshotActivity.java @@ -16,6 +16,8 @@ package com.android.systemui.screenshot.scroll; +import static com.android.systemui.shared.Flags.usePreferredImageEditor; + import android.app.Activity; import android.app.ActivityOptions; import android.content.ComponentName; @@ -355,26 +357,47 @@ public class LongScreenshotActivity extends Activity { mScreenshotUserHandle, false, /* activityOptions */ null, /* transitionCoordinator */ null); } else { - String editorPackage = getString(R.string.config_screenshotEditor); - Intent intent = new Intent(Intent.ACTION_EDIT); - intent.setDataAndType(uri, "image/png"); - intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION - | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); - Bundle options = null; - - // Skip shared element transition for implicit edit intents - if (!TextUtils.isEmpty(editorPackage)) { - intent.setComponent(ComponentName.unflattenFromString(editorPackage)); - mTransitionView.setImageBitmap(mOutputBitmap); - mTransitionView.setVisibility(View.VISIBLE); - mTransitionView.setTransitionName( - ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME); - options = ActivityOptions.makeSceneTransitionAnimation(this, mTransitionView, - ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME).toBundle(); - // TODO: listen for transition completing instead of finishing onStop - mTransitionStarted = true; + if (usePreferredImageEditor()) { + Intent intent = mActionIntentCreator.createEdit(uri); + Bundle options = null; + + if (intent.getComponent() != null) { + // Modify intent for shared transition if we're opening a specific editor. + intent.removeFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.removeFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); + mTransitionView.setImageBitmap(mOutputBitmap); + mTransitionView.setVisibility(View.VISIBLE); + mTransitionView.setTransitionName( + ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME); + options = ActivityOptions.makeSceneTransitionAnimation(this, mTransitionView, + ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME).toBundle(); + // TODO: listen for transition completing instead of finishing onStop + mTransitionStarted = true; + } + + startActivity(intent, options); + } else { + String editorPackage = getString(R.string.config_screenshotEditor); + Intent intent = new Intent(Intent.ACTION_EDIT); + intent.setDataAndType(uri, "image/png"); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION + | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + Bundle options = null; + + // Skip shared element transition for implicit edit intents + if (!TextUtils.isEmpty(editorPackage)) { + intent.setComponent(ComponentName.unflattenFromString(editorPackage)); + mTransitionView.setImageBitmap(mOutputBitmap); + mTransitionView.setVisibility(View.VISIBLE); + mTransitionView.setTransitionName( + ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME); + options = ActivityOptions.makeSceneTransitionAnimation(this, mTransitionView, + ChooserActivity.FIRST_IMAGE_PREVIEW_TRANSITION_NAME).toBundle(); + // TODO: listen for transition completing instead of finishing onStop + mTransitionStarted = true; + } + startActivity(intent, options); } - startActivity(intent, options); } } |