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

Commit d7af7bb6 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Initial implementation of Overview keyboard interactions

Lots of things are not yet implemented or don't work: animations,
fallback mode, taking params into account, dozing etc.

Bug: 73090995
Test: Press, Alt-tab, tab with and without shift, press Alt-Tab on
already open Overview.

Change-Id: Ifd140e27bead4fa52532a04000c0b60923b485be
parent 9da6c526
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.states.InternalStateHandler;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.ActivityManagerWrapper;

/**
@@ -65,6 +66,12 @@ public class OverviewCommandHelper extends InternalStateHandler {
        homeIntent.setComponent(launcher).setPackage(null);
    }

    private void openRecents() {
        Intent intent = addToIntent(new Intent(homeIntent));
        mContext.startActivity(intent);
        initWhenReady();
    }

    public void onOverviewToggle() {
        if (DEBUG_START_FALLBACK_ACTIVITY) {
            mContext.startActivity(new Intent(mContext, RecentsActivity.class)
@@ -79,17 +86,30 @@ public class OverviewCommandHelper extends InternalStateHandler {
            boolean isQuickTap = elapsedTime < ViewConfiguration.getDoubleTapTimeout();
            startNonLauncherTask(isQuickTap ? 2 : 1);
        } else {
            Intent intent = addToIntent(new Intent(homeIntent));
            mContext.startActivity(intent);
            initWhenReady();
            openRecents();
        }
    }

    public void onOverviewShown() {
        if (isOverviewAlmostVisible()) {
            final RecentsView rv = getLauncher().getOverviewPanel();
            rv.selectNextTask();
        } else {
            openRecents();
        }
    }

    public void onOverviewHidden() {
        final RecentsView rv = getLauncher().getOverviewPanel();
        rv.launchCurrentTask();
    }

    private void startNonLauncherTask(int backStackCount) {
        for (RecentTaskInfo rti : mAM.getRecentTasks(backStackCount, UserHandle.myUserId())) {
            backStackCount--;
            if (backStackCount == 0) {
                mAM.startActivityFromRecents(rti.id, null);
                break;
            }
        }
    }
+11 −2
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.systemui.shared.system.NavigationBarCompat.HitTarget;
public class TouchInteractionService extends Service {

    public static final boolean DEBUG_SHOW_OVERVIEW_BUTTON = false;
    public static final boolean DEBUG_OPEN_OVERVIEW_VIA_ALT_TAB = false;

    private static final SparseArray<String> sMotionEventNames;

@@ -140,10 +141,18 @@ public class TouchInteractionService extends Service {
        }

        @Override
        public void onOverviewShown(boolean triggeredFromAltTab) { }
        public void onOverviewShown(boolean triggeredFromAltTab) {
            if (DEBUG_OPEN_OVERVIEW_VIA_ALT_TAB) {
                mOverviewCommandHelper.onOverviewShown();
            }
        }

        @Override
        public void onOverviewHidden(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { }
        public void onOverviewHidden(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
            if (DEBUG_OPEN_OVERVIEW_VIA_ALT_TAB) {
                mOverviewCommandHelper.onOverviewHidden();
            }
        }
    };

    private final TouchConsumer mNoOpTouchConsumer = (ev) -> {};
+23 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
import android.util.SparseBooleanArray;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;

@@ -585,4 +586,26 @@ public abstract class RecentsView<T extends BaseActivity>
        anim.setDuration(duration).setInterpolator(interpolator);
        set.play(anim);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_TAB
                && event.getAction() == KeyEvent.ACTION_DOWN) {
            setCurrentPage((getCurrentPage()
                    + (event.isShiftPressed() ? getPageCount() - 1 : 1)) % getPageCount());
            loadVisibleTaskData();
            return true;
        }
        return super.dispatchKeyEvent(event);
    }

    public void selectNextTask() {
        setCurrentPage((getCurrentPage() + 1) % getPageCount());
        loadVisibleTaskData();
    }

    public void launchCurrentTask() {
        final TaskView currentTask = (TaskView) getChildAt(getCurrentPage());
        currentTask.launchTask(true);
    }
}