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

Commit c230fe4a authored by Utkarsh Gupta's avatar Utkarsh Gupta Committed by LuK1337
Browse files

Allow screen unpinning on devices without navbar

Change-Id: Iedfc08f4d95bbee3c8578c0d2450b90739e63603

Screen Pinning: Show correct text for on screen nav.

  Similar to I09c2ef661bff272cb4f7ca43bac0e45f4b20a4d4,
  we're not getting an instance of PhoneWindowManager which
  we can rely on to update dynamically.

  TICKET: OPO-393

Change-Id: Iacf8221066461fb6940dd88432e665812545c3ff
parent e3bb0af5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -125,4 +125,10 @@

    <!-- Name of the additional status bar icons also exposed with SystemUI Tuner -->
    <string name="status_bar_location">Location</string>

    <!-- Screen pinning dialog description. (for devices without navbar) -->
    <string name="screen_pinning_description_no_navbar">This keeps it in view until you unpin. Touch &amp; hold Back to unpin.</string>

    <!-- Notify use that they are in Lock-to-app (for devices without navbar)-->
    <string name="screen_pinning_toast_no_navbar">To unpin this screen, touch &amp; hold Back button</string>
</resources>
+22 −7
Original line number Diff line number Diff line
@@ -35,9 +35,11 @@ import android.text.SpannableStringBuilder;
import android.text.style.BulletSpan;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.IWindowManager;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;
import android.view.animation.DecelerateInterpolator;
import android.widget.Button;
@@ -270,20 +272,24 @@ public class ScreenPinningRequest implements View.OnClickListener,
                    && navigationBarView.isRecentsButtonVisible();
            boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled();
            int descriptionStringResId;
            if (QuickStepContract.isGesturalMode(mNavBarMode)) {
            if (hasNavigationBar() && 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);
                descriptionStringResId = touchExplorationEnabled
                descriptionStringResId = !hasNavigationBar()
                        ? R.string.screen_pinning_description_no_navbar
                        : touchExplorationEnabled
                                ? R.string.screen_pinning_description_accessible
                                : R.string.screen_pinning_description;
            } else {
                mLayout.findViewById(R.id.screen_pinning_recents_group).setVisibility(INVISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg_light).setVisibility(VISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg).setVisibility(VISIBLE);
                descriptionStringResId = touchExplorationEnabled
                descriptionStringResId = !hasNavigationBar()
                        ? R.string.screen_pinning_description_no_navbar
                        : touchExplorationEnabled
                                ? R.string.screen_pinning_description_recents_invisible_accessible
                                : R.string.screen_pinning_description_recents_invisible;
            }
@@ -335,6 +341,15 @@ public class ScreenPinningRequest implements View.OnClickListener,
            }
        }

        private boolean hasNavigationBar() {
            IWindowManager windowManagerService = WindowManagerGlobal.getWindowManagerService();
            try {
                return windowManagerService.hasNavigationBar(mContext.getDisplayId());
            } catch (RemoteException e) {
                return false;
            }
        }

        @Override
        public void onDetachedFromWindow() {
            mBroadcastDispatcher.unregisterReceiver(mReceiver);
+19 −5
Original line number Diff line number Diff line
@@ -17,8 +17,11 @@
package com.android.systemui.statusbar.phone;

import android.content.Context;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Slog;
import android.view.IWindowManager;
import android.view.WindowManagerGlobal;
import android.widget.Toast;

import com.android.systemui.R;
@@ -60,7 +63,9 @@ public class ScreenPinningNotify {
        if (mLastToast != null) {
            mLastToast.cancel();
        }
        mLastToast = makeAllUserToastAndShow(isGestureNavEnabled
        mLastToast = makeAllUserToastAndShow(!hasNavigationBar()
                ? R.string.screen_pinning_toast_no_navbar
                : isGestureNavEnabled
                        ? R.string.screen_pinning_toast_gesture_nav
                        : isRecentsButtonVisible
                                ? R.string.screen_pinning_toast
@@ -73,4 +78,13 @@ public class ScreenPinningNotify {
        toast.show();
        return toast;
    }

    private boolean hasNavigationBar() {
        IWindowManager windowManagerService = WindowManagerGlobal.getWindowManagerService();
        try {
            return windowManagerService.hasNavigationBar(mContext.getDisplayId());
        } catch (RemoteException e) {
            return false;
        }
     }
}
+20 −2
Original line number Diff line number Diff line
@@ -1467,8 +1467,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, false,
                "Back - Long Press");
        if (!unpinActivity(false)) {
            performKeyAction(mBackLongPressAction, event);
        }
    }

    private void accessibilityShortcutActivated() {
        mAccessibilityShortcutController.performAccessibilityShortcut();
@@ -1523,7 +1525,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private boolean hasLongPressOnBackBehavior() {
        return mBackLongPressAction != Action.NOTHING;
        return mBackLongPressAction != Action.NOTHING || unpinActivity(true);
    }

    private void interceptScreenshotChord() {
@@ -3581,6 +3583,22 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return false;
    }

    private boolean unpinActivity(boolean checkOnly) {
        if (!hasNavigationBar()) {
            try {
                if (ActivityTaskManager.getService().isInLockTaskMode()) {
                    if (!checkOnly) {
                        ActivityTaskManager.getService().stopSystemLockTaskMode();
                    }
                    return true;
                }
            } catch (RemoteException e) {
                // ignore
            }
        }
        return false;
    }

    // TODO(b/117479243): handle it in InputPolicy
    /** {@inheritDoc} */
    @Override