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

Unverified Commit 2c62ec1d authored by Timi Rautamäki's avatar Timi Rautamäki Committed by Michael Bestas
Browse files

SystemUI: screenshot: open the screenshot instead of edit



Open the taken screenshot in gallery application when clicking on the
preview. There is a seperate edit button, so the preview imageview
should open gallery instead.

Co-authored-by: default avatarMichael Bestas <mkbestas@lineageos.org>
Co-authored-by: default avatarTommy Webb <tommy@calyxinstitute.org>
Test: atest com.android.systemui.screenshot.ScreenshotNotificationSmartActionsTest
Change-Id: I8f882ddd0da47ca50acc37d25ee0866ce5698e4f
parent 86d3fe49
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -74,15 +74,26 @@ object ActionIntentCreator {
     *   available.
     */
    fun createEdit(rawUri: Uri, context: Context): Intent {
        return createEditOrView(rawUri, context, Intent(Intent.ACTION_EDIT))
    }

    /**
     * @return an ACTION_VIEW intent for the given URI, directed to config_screenshotEditor if
     *   available.
     */
    fun createView(rawUri: Uri, context: Context): Intent {
        return createEditOrView(rawUri, context, Intent(Intent.ACTION_VIEW))
    }

    private fun createEditOrView(rawUri: Uri, context: Context, intent: Intent): Intent {
        val uri = uriWithoutUserId(rawUri)
        val editIntent = Intent(Intent.ACTION_EDIT)

        val editor = context.getString(R.string.config_screenshotEditor)
        if (editor.isNotEmpty()) {
            editIntent.component = ComponentName.unflattenFromString(editor)
            intent.component = ComponentName.unflattenFromString(editor)
        }

        return editIntent
        return intent
            .setDataAndType(uri, "image/png")
            .putExtra(EXTRA_EDIT_SOURCE, EDIT_SOURCE_SCREENSHOT)
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.log.DebugLogger.debugLog
import com.android.systemui.res.R
import com.android.systemui.screenshot.ActionIntentCreator.createEdit
import com.android.systemui.screenshot.ActionIntentCreator.createShareWithSubject
import com.android.systemui.screenshot.ActionIntentCreator.createView
import com.android.systemui.screenshot.ScreenshotEvent.SCREENSHOT_EDIT_TAPPED
import com.android.systemui.screenshot.ScreenshotEvent.SCREENSHOT_PREVIEW_TAPPED
import com.android.systemui.screenshot.ScreenshotEvent.SCREENSHOT_SHARE_TAPPED
@@ -84,7 +85,7 @@ constructor(
                uiEventLogger.log(SCREENSHOT_PREVIEW_TAPPED, 0, request.packageNameString)
                onDeferrableActionTapped { result ->
                    actionExecutor.startSharedTransition(
                        createEdit(result.uri, context),
                        createView(result.uri, context),
                        result.user,
                        true
                    )
+1 −1
Original line number Diff line number Diff line
@@ -796,7 +796,7 @@ public class ScreenshotView extends FrameLayout implements
            mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_PREVIEW_TAPPED, 0, mPackageName);
            prepareSharedTransition();
            mCallbacks.onAction(
                    ActionIntentCreator.INSTANCE.createEdit(imageData.uri, mContext),
                    ActionIntentCreator.INSTANCE.createView(imageData.uri, mContext),
                    imageData.owner, true);
        });
        if (mQuickShareChip != null) {