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

Commit 3e431136 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Move code/interfaces out of ScreenshotController

Bug: 328603973
Flag: EXEMPT moving code only
Test: manual, atest
Change-Id: Ieeb2ed91436b289ea1a280204583bc23bcd6854a
parent c12fe875
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
                    ScreenshotNotificationSmartActionsProvider.ACTION_TYPE,
                    ScreenshotNotificationSmartActionsProvider.DEFAULT_ACTION_TYPE);
            Intent intent = new Intent(context, SmartActionsReceiver.class)
                    .putExtra(ScreenshotController.EXTRA_ACTION_INTENT, action.actionIntent)
                    .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT, action.actionIntent)
                    .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
            addIntentExtras(mScreenshotId, intent, actionType, true /* smartActionsEnabled */);
            PendingIntent broadcastIntent = PendingIntent.getBroadcast(context,
@@ -302,9 +302,9 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
    private static void addIntentExtras(String screenshotId, Intent intent, String actionType,
            boolean smartActionsEnabled) {
        intent
                .putExtra(ScreenshotController.EXTRA_ACTION_TYPE, actionType)
                .putExtra(ScreenshotController.EXTRA_ID, screenshotId)
                .putExtra(ScreenshotController.EXTRA_SMART_ACTIONS_ENABLED, smartActionsEnabled);
                .putExtra(SmartActionsReceiver.EXTRA_ACTION_TYPE, actionType)
                .putExtra(SmartActionsReceiver.EXTRA_ID, screenshotId)
                .putExtra(SmartActionsReceiver.EXTRA_SMART_ACTIONS_ENABLED, smartActionsEnabled);
    }

    /**
@@ -327,8 +327,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
        }

        Intent wrappedIntent = new Intent(mContext, SmartActionsReceiver.class)
                .putExtra(ScreenshotController.EXTRA_ACTION_INTENT, quickShare.actionIntent)
                .putExtra(ScreenshotController.EXTRA_ACTION_INTENT_FILLIN,
                .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT, quickShare.actionIntent)
                .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT_FILLIN,
                        createFillInIntent(uri, imageTime))
                .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        Bundle extras = quickShare.getExtras();
+1 −22
Original line number Diff line number Diff line
@@ -98,25 +98,6 @@ import javax.inject.Provider;
public class ScreenshotController implements ScreenshotHandler {
    private static final String TAG = logTag(ScreenshotController.class);

    public interface TransitionDestination {
        /**
         * Allows the long screenshot activity to call back with a destination location (the bounds
         * on screen of the destination for the transitioning view) and a Runnable to be run once
         * the transition animation is complete.
         */
        void setTransitionDestination(Rect transitionDestination, Runnable onTransitionEnd);
    }

    // These strings are used for communicating the action invoked to
    // ScreenshotNotificationSmartActionsProvider.
    public static final String EXTRA_ACTION_TYPE = "android:screenshot_action_type";
    public static final String EXTRA_ID = "android:screenshot_id";
    public static final String EXTRA_SMART_ACTIONS_ENABLED = "android:smart_actions_enabled";
    public static final String EXTRA_ACTION_INTENT = "android:screenshot_action_intent";
    public static final String EXTRA_ACTION_INTENT_FILLIN =
            "android:screenshot_action_intent_fillin";


    // From WizardManagerHelper.java
    private static final String SETTINGS_SECURE_USER_SETUP_COMPLETE = "user_setup_complete";

@@ -378,9 +359,7 @@ public class ScreenshotController implements ScreenshotHandler {
            if (screenshotPrivateProfileAccessibilityAnnouncementFix()) {
                mAnnouncementResolver.getScreenshotAnnouncement(
                        screenshot.getUserHandle().getIdentifier(),
                        announcement -> {
                            mViewProxy.announceForAccessibility(announcement);
                        });
                        mViewProxy::announceForAccessibility);
            } else {
                if (mUserManager.isManagedProfile(screenshot.getUserHandle().getIdentifier())) {
                    mViewProxy.announceForAccessibility(mContext.getResources().getString(
+9 −4
Original line number Diff line number Diff line
@@ -17,10 +17,6 @@
package com.android.systemui.screenshot;

import static com.android.systemui.screenshot.LogConfig.DEBUG_ACTIONS;
import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ACTION_INTENT;
import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ACTION_INTENT_FILLIN;
import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ACTION_TYPE;
import static com.android.systemui.screenshot.ScreenshotController.EXTRA_ID;

import android.app.ActivityOptions;
import android.app.PendingIntent;
@@ -36,6 +32,15 @@ import javax.inject.Inject;
 */
public class SmartActionsReceiver extends BroadcastReceiver {
    private static final String TAG = "SmartActionsReceiver";
    // These strings are used for communicating the action invoked to
    // ScreenshotNotificationSmartActionsProvider.
    public static final String EXTRA_ACTION_TYPE = "android:screenshot_action_type";
    public static final String EXTRA_ID = "android:screenshot_id";
    public static final String EXTRA_SMART_ACTIONS_ENABLED = "android:smart_actions_enabled";
    public static final String EXTRA_ACTION_INTENT = "android:screenshot_action_intent";
    public static final String EXTRA_ACTION_INTENT_FILLIN =
            "android:screenshot_action_intent_fillin";


    private final ScreenshotSmartActions mScreenshotSmartActions;

+14 −5
Original line number Diff line number Diff line
@@ -16,8 +16,9 @@

package com.android.systemui.screenshot.scroll;

import android.graphics.Rect;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.screenshot.ScreenshotController;

import java.util.concurrent.atomic.AtomicReference;

@@ -30,9 +31,18 @@ import javax.inject.Inject;
@SysUISingleton
public class LongScreenshotData {
    private final AtomicReference<ScrollCaptureController.LongScreenshot> mLongScreenshot;
    private final AtomicReference<ScreenshotController.TransitionDestination>
    private final AtomicReference<TransitionDestination>
            mTransitionDestinationCallback;

    public interface TransitionDestination {
        /**
         * Allows the long screenshot activity to call back with a destination location (the bounds
         * on screen of the destination for the transitioning view) and a Runnable to be run once
         * the transition animation is complete.
         */
        void setTransitionDestination(Rect transitionDestination, Runnable onTransitionEnd);
    }

    @Inject
    public LongScreenshotData() {
        mLongScreenshot = new AtomicReference<>();
@@ -63,15 +73,14 @@ public class LongScreenshotData {
    /**
     * Set the holder's TransitionDestination callback.
     */
    public void setTransitionDestinationCallback(
            ScreenshotController.TransitionDestination destination) {
    public void setTransitionDestinationCallback(TransitionDestination destination) {
        mTransitionDestinationCallback.set(destination);
    }

    /**
     * Return the current TransitionDestination callback and clear.
     */
    public ScreenshotController.TransitionDestination takeTransitionDestinationCallback() {
    public TransitionDestination takeTransitionDestinationCallback() {
        return mTransitionDestinationCallback.getAndSet(null);
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ class SaveImageInBackgroundTaskTest : SysuiTestCase() {
            )
        val quickSharePendingIntent =
            quickShareAction.actionIntent.intent.extras!!.getParcelable(
                ScreenshotController.EXTRA_ACTION_INTENT,
                SmartActionsReceiver.EXTRA_ACTION_INTENT,
                PendingIntent::class.java
            )

@@ -266,7 +266,7 @@ class SaveImageInBackgroundTaskTest : SysuiTestCase() {
        assertEquals(
            immutablePendingIntent,
            quickShareAction.actionIntent.intent.extras!!.getParcelable(
                ScreenshotController.EXTRA_ACTION_INTENT,
                SmartActionsReceiver.EXTRA_ACTION_INTENT,
                PendingIntent::class.java
            )
        )
Loading