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

Commit 1a0406e1 authored by Cosmin Băieș's avatar Cosmin Băieș Committed by Android (Google) Code Review
Browse files

Merge "Add IME switch button long click support" into main

parents 72c4ebed 33f8bfba
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_BACK_BUTTON_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_HOME_BUTTON_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_HOME_BUTTON_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_OVERVIEW_BUTTON_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_OVERVIEW_BUTTON_TAP;
@@ -37,6 +38,7 @@ import android.os.Handler;
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.View;
import android.view.inputmethod.Flags;

import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
@@ -147,7 +149,7 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
                break;
            case BUTTON_IME_SWITCH:
                logEvent(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_TAP);
                showIMESwitcher();
                onImeSwitcherPress();
                break;
            case BUTTON_A11Y:
                logEvent(LAUNCHER_TASKBAR_A11Y_BUTTON_TAP);
@@ -190,6 +192,12 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
                backRecentsLongpress(buttonType);
                return true;
            case BUTTON_IME_SWITCH:
                if (Flags.imeSwitcherRevamp()) {
                    logEvent(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS);
                    onImeSwitcherLongPress();
                    return true;
                }
                return false;
            default:
                return false;
        }
@@ -305,10 +313,14 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa
        mSystemUiProxy.onBackPressed();
    }

    private void showIMESwitcher() {
    private void onImeSwitcherPress() {
        mSystemUiProxy.onImeSwitcherPressed();
    }

    private void onImeSwitcherLongPress() {
        mSystemUiProxy.onImeSwitcherLongPress();
    }

    private void notifyA11yClick(boolean longClick) {
        if (longClick) {
            mSystemUiProxy.notifyAccessibilityButtonLongClicked();
+11 −0
Original line number Diff line number Diff line
@@ -228,6 +228,17 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable {
        }
    }

    @Override
    public void onImeSwitcherLongPress() {
        if (mSystemUiProxy != null) {
            try {
                mSystemUiProxy.onImeSwitcherLongPress();
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call onImeSwitcherLongPress");
            }
        }
    }

    @Override
    public void setHomeRotationEnabled(boolean enabled) {
        if (mSystemUiProxy != null) {
+22 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_BACK_BUTTON_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_HOME_BUTTON_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_HOME_BUTTON_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_TAP;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_OVERVIEW_BUTTON_LONGPRESS;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_OVERVIEW_BUTTON_TAP;
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_A11Y;
@@ -26,6 +28,7 @@ import static org.mockito.Mockito.when;

import android.os.Handler;
import android.view.View;
import android.view.inputmethod.Flags;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
@@ -109,8 +112,27 @@ public class TaskbarNavButtonControllerTest {

    @Test
    public void testPressImeSwitcher() {
        mNavButtonController.init(mockTaskbarControllers);
        mNavButtonController.onButtonClick(BUTTON_IME_SWITCH, mockView);
        verify(mockStatsLogger, times(1)).log(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_TAP);
        verify(mockStatsLogger, never()).log(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS);
        verify(mockSystemUiProxy, times(1)).onImeSwitcherPressed();
        verify(mockSystemUiProxy, never()).onImeSwitcherLongPress();
    }

    @Test
    public void testLongPressImeSwitcher() {
        mNavButtonController.init(mockTaskbarControllers);
        mNavButtonController.onButtonLongClick(BUTTON_IME_SWITCH, mockView);
        verify(mockStatsLogger, never()).log(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_TAP);
        verify(mockSystemUiProxy, never()).onImeSwitcherPressed();
        if (Flags.imeSwitcherRevamp()) {
            verify(mockStatsLogger, times(1)).log(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS);
            verify(mockSystemUiProxy, times(1)).onImeSwitcherLongPress();
        } else {
            verify(mockStatsLogger, never()).log(LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS);
            verify(mockSystemUiProxy, never()).onImeSwitcherLongPress();
        }
    }

    @Test
+3 −0
Original line number Diff line number Diff line
@@ -795,6 +795,9 @@ public class StatsLogManager implements ResourceBasedOverride {
        @UiEvent(doc = "User launches Overview from meta+tab keyboard shortcut")
        LAUNCHER_OVERVIEW_SHOW_OVERVIEW_FROM_KEYBOARD_SHORTCUT(1765),

        @UiEvent(doc = "User long pressed on the taskbar IME switcher button")
        LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_LONGPRESS(1798),

        // ADD MORE
        ;