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

Commit bff4842c authored by vadimt's avatar vadimt
Browse files

Removing unnecessarily requiring activity to be a launcher

It can be fallback recents, which breaks fallback recents tests.

See: https://sponge.corp.google.com/target?id=f2aee870-f682-40b7-978a-d3b6ee12f2db&target=com.google.android.apps.nexuslauncher.tests&showTestCases=ALL

Change-Id: Ib1ff1ca3db451104e6a8de58e27255bf5fb41544
Tests: FallbackRecentsTest.goToOverviewFromHome
parent b3ca6aee
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -26,12 +26,12 @@ import android.view.View;
import android.widget.Toast;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.userevent.nano.LauncherLogProto;

public class RemoteActionShortcut extends SystemShortcut<Launcher> {
public class RemoteActionShortcut extends SystemShortcut<BaseDraggingActivity> {
    private static final String TAG = "RemoteActionShortcut";

    private final RemoteAction mAction;
@@ -44,13 +44,13 @@ public class RemoteActionShortcut extends SystemShortcut<Launcher> {

    @Override
    public View.OnClickListener getOnClickListener(
            final Launcher launcher, final ItemInfo itemInfo) {
            final BaseDraggingActivity activity, final ItemInfo itemInfo) {
        return view -> {
            AbstractFloatingView.closeAllOpenViews(launcher);
            AbstractFloatingView.closeAllOpenViews(activity);

            try {
                mAction.getActionIntent().send(
                        launcher,
                        activity,
                        0,
                        new Intent().putExtra(
                                Intent.EXTRA_PACKAGE_NAME,
@@ -59,20 +59,20 @@ public class RemoteActionShortcut extends SystemShortcut<Launcher> {
                            if (resultData != null && !resultData.isEmpty()) {
                                Log.e(TAG, "Remote action returned result: " + mAction.getTitle()
                                        + " : " + resultData);
                                Toast.makeText(launcher, resultData, Toast.LENGTH_SHORT).show();
                                Toast.makeText(activity, resultData, Toast.LENGTH_SHORT).show();
                            }
                        },
                        new Handler(Looper.getMainLooper()));
            } catch (PendingIntent.CanceledException e) {
                Log.e(TAG, "Remote action canceled: " + mAction.getTitle(), e);
                Toast.makeText(launcher, launcher.getString(
                Toast.makeText(activity, activity.getString(
                        R.string.remote_action_failed,
                        mAction.getTitle()),
                        Toast.LENGTH_SHORT)
                        .show();
            }

            launcher.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP,
            activity.getUserEventDispatcher().logActionOnControl(LauncherLogProto.Action.Touch.TAP,
                    LauncherLogProto.ControlType.REMOTE_ACTION_SHORTCUT, view);
        };
    }