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

Commit 829b9ea7 authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Merge "Update sysui for screen pinning with gestural nav" into qt-dev

am: 975eea7e

Change-Id: I9ba11d859769970a5bd2186465d829f284856776
parents 7d0226e0 975eea7e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1345,6 +1345,7 @@
    <!-- Screen pinning dialog description. -->
    <string name="screen_pinning_description">This keeps it in view until you unpin. Touch &amp; hold Back and Overview to unpin.</string>
    <string name="screen_pinning_description_recents_invisible">This keeps it in view until you unpin. Touch &amp; hold Back and Home to unpin.</string>
    <string name="screen_pinning_description_gestural">This keeps it in view until you unpin. Swipe up &amp; hold to unpin.</string>
    <!-- Screen pinning dialog description. -->
    <string name="screen_pinning_description_accessible">This keeps it in view until you unpin. Touch &amp; hold Overview to unpin.</string>
    <string name="screen_pinning_description_recents_invisible_accessible">This keeps it in view until you unpin. Touch &amp; hold Home to unpin.</string>
+5 −0
Original line number Diff line number Diff line
@@ -96,4 +96,9 @@ interface ISystemUiProxy {
     * Notifies that the accessibility button in the system's navigation area has been long clicked
     */
    void notifyAccessibilityButtonLongClicked() = 16;

    /**
     * Ends the system screen pinning.
     */
    void stopScreenPinning() = 17;
}
+20 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;

import android.annotation.FloatRange;
import android.app.ActivityTaskManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -150,6 +151,25 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
            }
        }

        @Override
        public void stopScreenPinning() {
            if (!verifyCaller("stopScreenPinning")) {
                return;
            }
            long token = Binder.clearCallingIdentity();
            try {
                mHandler.post(() -> {
                    try {
                        ActivityTaskManager.getService().stopSystemLockTaskMode();
                    } catch (RemoteException e) {
                        Log.e(TAG_OPS, "Failed to stop screen pinning");
                    }
                });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        @Override
        public void onStatusBarMotionEvent(MotionEvent event) {
            if (!verifyCaller("onStatusBarMotionEvent")) {
+17 −3
Original line number Diff line number Diff line
@@ -48,14 +48,17 @@ import android.widget.TextView;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.WindowManagerWrapper;
import com.android.systemui.statusbar.phone.NavigationBarView;
import com.android.systemui.statusbar.phone.NavigationModeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.util.leak.RotationUtils;

import java.util.ArrayList;

public class ScreenPinningRequest implements View.OnClickListener {
public class ScreenPinningRequest implements View.OnClickListener,
        NavigationModeController.ModeChangedListener {

    private final Context mContext;

@@ -64,6 +67,7 @@ public class ScreenPinningRequest implements View.OnClickListener {
    private final OverviewProxyService mOverviewProxyService;

    private RequestWindowView mRequestWindow;
    private int mNavBarMode;

    // Id of task to be pinned or locked.
    private int taskId;
@@ -75,6 +79,7 @@ public class ScreenPinningRequest implements View.OnClickListener {
        mWindowManager = (WindowManager)
                mContext.getSystemService(Context.WINDOW_SERVICE);
        mOverviewProxyService = Dependency.get(OverviewProxyService.class);
        mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this);
    }

    public void clearPrompt() {
@@ -103,6 +108,11 @@ public class ScreenPinningRequest implements View.OnClickListener {
        mWindowManager.addView(mRequestWindow, lp);
    }

    @Override
    public void onNavigationModeChanged(int mode) {
        mNavBarMode = mode;
    }

    public void onConfigurationChanged() {
        if (mRequestWindow != null) {
            mRequestWindow.onConfigurationChanged();
@@ -224,7 +234,9 @@ public class ScreenPinningRequest implements View.OnClickListener {
            mLayout.findViewById(R.id.screen_pinning_text_area)
                    .setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
            View buttons = mLayout.findViewById(R.id.screen_pinning_buttons);
            if (WindowManagerWrapper.getInstance().hasSoftNavigationBar(mContext.getDisplayId())) {
            WindowManagerWrapper wm = WindowManagerWrapper.getInstance();
            if (!QuickStepContract.isGesturalMode(mNavBarMode) 
            	    && wm.hasSoftNavigationBar(mContext.getDisplayId())) {
                buttons.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
                swapChildrenIfRtlAndVertical(buttons);
            } else {
@@ -248,7 +260,9 @@ public class ScreenPinningRequest implements View.OnClickListener {
                    && navigationBarView.isRecentsButtonVisible();
            boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled();
            int descriptionStringResId;
            if (recentsVisible) {
            if (QuickStepContract.isGesturalMode(mNavBarMode)) {
                descriptionStringResId = R.string.screen_pinning_description_gestural;
            } else if (recentsVisible) {
                mLayout.findViewById(R.id.screen_pinning_recents_group).setVisibility(VISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg_light).setVisibility(INVISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg).setVisibility(INVISIBLE);