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

Commit 5dea887b authored by Utkarsh Gupta's avatar Utkarsh Gupta Committed by Bruno Martins
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 9b3ebc6b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -129,4 +129,10 @@
    <string name="screenrecord_skip_time_summary">Remove the 3 second wait</string>
    <string name="screenrecord_hevc_switch_label">HEVC encoding</string>
    <string name="screenrecord_hevc_switch_summary">Use the more efficient HEVC encoder</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>
+15 −1
Original line number Diff line number Diff line
@@ -17,8 +17,10 @@
package com.android.systemui.navigationbar;

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

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

    private boolean hasSoftNavigationBar() {
        try {
            return WindowManagerGlobal.getWindowManagerService()
                    .hasNavigationBar(mContext.getDisplayId());
        } catch (RemoteException e) {
            Slog.e(TAG, "Failed to check soft navigation bar", e);
            return false;
        }
    }
}
+10 −6
Original line number Diff line number Diff line
@@ -302,14 +302,18 @@ public class ScreenPinningRequest implements
                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 = !hasSoftNavigationBar(displayId)
                        ? 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 = !hasSoftNavigationBar(displayId)
                        ? R.string.screen_pinning_description_no_navbar
                        : touchExplorationEnabled
                                ? R.string.screen_pinning_description_recents_invisible_accessible
                                : R.string.screen_pinning_description_recents_invisible;
            }
+18 −1
Original line number Diff line number Diff line
@@ -1703,7 +1703,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    }

    private void backLongPress() {
        if (hasLongPressOnBackBehavior()) {
        if (unpinActivity()) {
            mBackKeyHandled = true;
            performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, "Back - Long Press");
        } else if (hasLongPressOnBackBehavior()) {
            mBackKeyHandled = true;

            long now = SystemClock.uptimeMillis();
@@ -4285,6 +4288,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        return false;
    }

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

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