Loading packages/SystemUI/res/layout/screen_pinning_request_buttons.xml +19 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,25 @@ android:layout_height="@dimen/screen_pinning_request_button_height" android:layout_weight="0" android:paddingStart="@dimen/screen_pinning_request_frame_padding" android:paddingEnd="@dimen/screen_pinning_request_frame_padding" > android:paddingEnd="@dimen/screen_pinning_request_frame_padding" android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent"> <ImageView android:id="@+id/screen_pinning_recents_bg_light" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="matrix" android:src="@drawable/screen_pinning_light_bg_circ" /> <ImageView android:id="@+id/screen_pinning_recents_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingEnd="@dimen/screen_pinning_request_inner_padding" android:paddingStart="@dimen/screen_pinning_request_inner_padding" android:paddingTop="@dimen/screen_pinning_request_inner_padding" android:scaleType="matrix" android:src="@drawable/screen_pinning_bg_circ" /> <ImageView android:layout_width="match_parent" Loading packages/SystemUI/res/layout/screen_pinning_request_buttons_land.xml +19 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,25 @@ android:id="@+id/screen_pinning_recents_group" android:layout_height="@dimen/screen_pinning_request_button_width" android:layout_width="@dimen/screen_pinning_request_button_height" android:layout_weight="0" > android:layout_weight="0" android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent"> <ImageView android:id="@+id/screen_pinning_recents_bg_light" android:layout_height="match_parent" android:layout_width="match_parent" android:scaleType="matrix" android:src="@drawable/screen_pinning_light_bg_circ" /> <ImageView android:id="@+id/screen_pinning_recents_bg" android:layout_height="match_parent" android:layout_width="match_parent" android:scaleType="matrix" android:paddingLeft="@dimen/screen_pinning_request_inner_padding" android:paddingTop="@dimen/screen_pinning_request_inner_padding" android:paddingBottom="@dimen/screen_pinning_request_inner_padding" android:src="@drawable/screen_pinning_bg_circ" /> <ImageView android:layout_height="match_parent" Loading packages/SystemUI/res/values/strings.xml +3 −1 Original line number Diff line number Diff line Loading @@ -1102,7 +1102,9 @@ <!-- Screen pinning dialog title. --> <string name="screen_pinning_title">Screen is pinned</string> <!-- Screen pinning dialog description. --> <string name="screen_pinning_description">This keeps it in view until you unpin. Touch & hold Back to unpin.</string> <string name="screen_pinning_description">This keeps it in view until you unpin. Touch & hold Back and Overview to unpin.</string> <!-- Screen pinning dialog description. --> <string name="screen_pinning_description_accessible">This keeps it in view until you unpin. Touch & hold Overview to unpin.</string> <!-- Screen pinning positive response. --> <string name="screen_pinning_positive">Got it</string> <!-- Screen pinning negative response. --> Loading packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java +5 −3 Original line number Diff line number Diff line Loading @@ -230,10 +230,12 @@ public class ScreenPinningRequest implements View.OnClickListener { .setVisibility(View.INVISIBLE); } boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled(); ((TextView) mLayout.findViewById(R.id.screen_pinning_description)) .setText(R.string.screen_pinning_description); final int backBgVisibility = mAccessibilityService.isEnabled() ? View.INVISIBLE : View.VISIBLE; .setText(touchExplorationEnabled ? R.string.screen_pinning_description_accessible : R.string.screen_pinning_description); final int backBgVisibility = touchExplorationEnabled ? View.INVISIBLE : View.VISIBLE; mLayout.findViewById(R.id.screen_pinning_back_bg).setVisibility(backBgVisibility); mLayout.findViewById(R.id.screen_pinning_back_bg_light).setVisibility(backBgVisibility); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +67 −32 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ import android.view.ViewStub; import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; import android.view.animation.AccelerateInterpolator; import android.view.animation.Interpolator; import android.widget.ImageView; Loading Loading @@ -179,6 +180,7 @@ import com.android.systemui.statusbar.policy.EncryptionHelper; import com.android.systemui.statusbar.policy.FlashlightController; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.HotspotControllerImpl; import com.android.systemui.statusbar.policy.KeyButtonView; import com.android.systemui.statusbar.policy.KeyguardMonitor; import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; import com.android.systemui.statusbar.policy.LocationControllerImpl; Loading Loading @@ -666,6 +668,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private RankingMap mLatestRankingMap; private boolean mNoAnimationOnNextBarModeChange; private FalsingManager mFalsingManager; private long mLastLockToAppLongPress; private KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { @Override Loading Loading @@ -1325,29 +1328,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } }; private View.OnLongClickListener mLongPressBackListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return handleLongPressBack(); } }; private View.OnLongClickListener mRecentsLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (mRecents == null || !ActivityManager.supportsMultiWindow() || !getComponent(Divider.class).getView().getSnapAlgorithm() .isSplitScreenFeasible()) { return false; } toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); return true; } }; @Override protected void toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction) { if (mRecents == null) { Loading Loading @@ -1432,11 +1412,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, recentsButton.setOnClickListener(mRecentsClickListener); recentsButton.setOnTouchListener(mRecentsPreloadOnTouchListener); recentsButton.setLongClickable(true); recentsButton.setOnLongClickListener(mRecentsLongClickListener); recentsButton.setOnLongClickListener(this::handleLongPressBackRecents); ButtonDispatcher backButton = mNavigationBarView.getBackButton(); backButton.setLongClickable(true); backButton.setOnLongClickListener(mLongPressBackListener); backButton.setOnLongClickListener(this::handleLongPressBackRecents); ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); homeButton.setOnTouchListener(mHomeActionListener); Loading Loading @@ -4849,17 +4829,60 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } /** * Handles long press for back button. This exits screen pinning. * This handles long-press of both back and recents. They are * handled together to capture them both being long-pressed * at the same time to exit screen pinning (lock task). * * When accessibility mode is on, only a long-press from recents * is required to exit. * * In all other circumstances we try to pass through long-press events * for Back, so that apps can still use it. Which can be from two things. * 1) Not currently in screen pinning (lock task). * 2) Back is long-pressed without recents. */ private boolean handleLongPressBack() { private boolean handleLongPressBackRecents(View v) { try { boolean sendBackLongPress = false; IActivityManager activityManager = ActivityManagerNative.getDefault(); if (activityManager.isInLockTaskMode()) { activityManager.stopSystemLockTaskMode(); boolean touchExplorationEnabled = mAccessibilityManager.isTouchExplorationEnabled(); boolean inLockTaskMode = activityManager.isInLockTaskMode(); if (inLockTaskMode && !touchExplorationEnabled) { long time = System.currentTimeMillis(); // If we recently long-pressed the other button then they were // long-pressed 'together' if ((time - mLastLockToAppLongPress) < LOCK_TO_APP_GESTURE_TOLERENCE) { activityManager.stopLockTaskMode(); // When exiting refresh disabled flags. mNavigationBarView.setDisabledFlags(mDisabled1, true); return true; } else if ((v.getId() == R.id.back) && !mNavigationBarView.getRecentsButton().getCurrentView().isPressed()) { // If we aren't pressing recents right now then they presses // won't be together, so send the standard long-press action. sendBackLongPress = true; } mLastLockToAppLongPress = time; } else { // If this is back still need to handle sending the long-press event. if (v.getId() == R.id.back) { sendBackLongPress = true; } else if (touchExplorationEnabled && inLockTaskMode) { // When in accessibility mode a long press that is recents (not back) // should stop lock task. activityManager.stopLockTaskMode(); // When exiting refresh disabled flags. mNavigationBarView.setDisabledFlags(mDisabled1, true); return true; } else if (v.getId() == R.id.recent_apps) { return handleLongPressRecents(); } } if (sendBackLongPress) { KeyButtonView keyButtonView = (KeyButtonView) v; keyButtonView.sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); keyButtonView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); return true; } } catch (RemoteException e) { Log.d(TAG, "Unable to reach activity manager", e); Loading @@ -4867,6 +4890,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, return false; } private boolean handleLongPressRecents() { if (mRecents == null || !ActivityManager.supportsMultiWindow() || !getComponent(Divider.class).getView().getSnapAlgorithm() .isSplitScreenFeasible()) { return false; } toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); return true; } @Override public void showScreenPinningRequest(int taskId) { if (mKeyguardMonitor.isShowing()) { Loading Loading
packages/SystemUI/res/layout/screen_pinning_request_buttons.xml +19 −1 Original line number Diff line number Diff line Loading @@ -108,7 +108,25 @@ android:layout_height="@dimen/screen_pinning_request_button_height" android:layout_weight="0" android:paddingStart="@dimen/screen_pinning_request_frame_padding" android:paddingEnd="@dimen/screen_pinning_request_frame_padding" > android:paddingEnd="@dimen/screen_pinning_request_frame_padding" android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent"> <ImageView android:id="@+id/screen_pinning_recents_bg_light" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="matrix" android:src="@drawable/screen_pinning_light_bg_circ" /> <ImageView android:id="@+id/screen_pinning_recents_bg" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingEnd="@dimen/screen_pinning_request_inner_padding" android:paddingStart="@dimen/screen_pinning_request_inner_padding" android:paddingTop="@dimen/screen_pinning_request_inner_padding" android:scaleType="matrix" android:src="@drawable/screen_pinning_bg_circ" /> <ImageView android:layout_width="match_parent" Loading
packages/SystemUI/res/layout/screen_pinning_request_buttons_land.xml +19 −1 Original line number Diff line number Diff line Loading @@ -38,7 +38,25 @@ android:id="@+id/screen_pinning_recents_group" android:layout_height="@dimen/screen_pinning_request_button_width" android:layout_width="@dimen/screen_pinning_request_button_height" android:layout_weight="0" > android:layout_weight="0" android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent"> <ImageView android:id="@+id/screen_pinning_recents_bg_light" android:layout_height="match_parent" android:layout_width="match_parent" android:scaleType="matrix" android:src="@drawable/screen_pinning_light_bg_circ" /> <ImageView android:id="@+id/screen_pinning_recents_bg" android:layout_height="match_parent" android:layout_width="match_parent" android:scaleType="matrix" android:paddingLeft="@dimen/screen_pinning_request_inner_padding" android:paddingTop="@dimen/screen_pinning_request_inner_padding" android:paddingBottom="@dimen/screen_pinning_request_inner_padding" android:src="@drawable/screen_pinning_bg_circ" /> <ImageView android:layout_height="match_parent" Loading
packages/SystemUI/res/values/strings.xml +3 −1 Original line number Diff line number Diff line Loading @@ -1102,7 +1102,9 @@ <!-- Screen pinning dialog title. --> <string name="screen_pinning_title">Screen is pinned</string> <!-- Screen pinning dialog description. --> <string name="screen_pinning_description">This keeps it in view until you unpin. Touch & hold Back to unpin.</string> <string name="screen_pinning_description">This keeps it in view until you unpin. Touch & hold Back and Overview to unpin.</string> <!-- Screen pinning dialog description. --> <string name="screen_pinning_description_accessible">This keeps it in view until you unpin. Touch & hold Overview to unpin.</string> <!-- Screen pinning positive response. --> <string name="screen_pinning_positive">Got it</string> <!-- Screen pinning negative response. --> Loading
packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java +5 −3 Original line number Diff line number Diff line Loading @@ -230,10 +230,12 @@ public class ScreenPinningRequest implements View.OnClickListener { .setVisibility(View.INVISIBLE); } boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled(); ((TextView) mLayout.findViewById(R.id.screen_pinning_description)) .setText(R.string.screen_pinning_description); final int backBgVisibility = mAccessibilityService.isEnabled() ? View.INVISIBLE : View.VISIBLE; .setText(touchExplorationEnabled ? R.string.screen_pinning_description_accessible : R.string.screen_pinning_description); final int backBgVisibility = touchExplorationEnabled ? View.INVISIBLE : View.VISIBLE; mLayout.findViewById(R.id.screen_pinning_back_bg).setVisibility(backBgVisibility); mLayout.findViewById(R.id.screen_pinning_back_bg_light).setVisibility(backBgVisibility); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +67 −32 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ import android.view.ViewStub; import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.view.accessibility.AccessibilityEvent; import android.view.animation.AccelerateInterpolator; import android.view.animation.Interpolator; import android.widget.ImageView; Loading Loading @@ -179,6 +180,7 @@ import com.android.systemui.statusbar.policy.EncryptionHelper; import com.android.systemui.statusbar.policy.FlashlightController; import com.android.systemui.statusbar.policy.HeadsUpManager; import com.android.systemui.statusbar.policy.HotspotControllerImpl; import com.android.systemui.statusbar.policy.KeyButtonView; import com.android.systemui.statusbar.policy.KeyguardMonitor; import com.android.systemui.statusbar.policy.KeyguardUserSwitcher; import com.android.systemui.statusbar.policy.LocationControllerImpl; Loading Loading @@ -666,6 +668,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private RankingMap mLatestRankingMap; private boolean mNoAnimationOnNextBarModeChange; private FalsingManager mFalsingManager; private long mLastLockToAppLongPress; private KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { @Override Loading Loading @@ -1325,29 +1328,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } }; private View.OnLongClickListener mLongPressBackListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return handleLongPressBack(); } }; private View.OnLongClickListener mRecentsLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (mRecents == null || !ActivityManager.supportsMultiWindow() || !getComponent(Divider.class).getView().getSnapAlgorithm() .isSplitScreenFeasible()) { return false; } toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); return true; } }; @Override protected void toggleSplitScreenMode(int metricsDockAction, int metricsUndockAction) { if (mRecents == null) { Loading Loading @@ -1432,11 +1412,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, recentsButton.setOnClickListener(mRecentsClickListener); recentsButton.setOnTouchListener(mRecentsPreloadOnTouchListener); recentsButton.setLongClickable(true); recentsButton.setOnLongClickListener(mRecentsLongClickListener); recentsButton.setOnLongClickListener(this::handleLongPressBackRecents); ButtonDispatcher backButton = mNavigationBarView.getBackButton(); backButton.setLongClickable(true); backButton.setOnLongClickListener(mLongPressBackListener); backButton.setOnLongClickListener(this::handleLongPressBackRecents); ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); homeButton.setOnTouchListener(mHomeActionListener); Loading Loading @@ -4849,17 +4829,60 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } /** * Handles long press for back button. This exits screen pinning. * This handles long-press of both back and recents. They are * handled together to capture them both being long-pressed * at the same time to exit screen pinning (lock task). * * When accessibility mode is on, only a long-press from recents * is required to exit. * * In all other circumstances we try to pass through long-press events * for Back, so that apps can still use it. Which can be from two things. * 1) Not currently in screen pinning (lock task). * 2) Back is long-pressed without recents. */ private boolean handleLongPressBack() { private boolean handleLongPressBackRecents(View v) { try { boolean sendBackLongPress = false; IActivityManager activityManager = ActivityManagerNative.getDefault(); if (activityManager.isInLockTaskMode()) { activityManager.stopSystemLockTaskMode(); boolean touchExplorationEnabled = mAccessibilityManager.isTouchExplorationEnabled(); boolean inLockTaskMode = activityManager.isInLockTaskMode(); if (inLockTaskMode && !touchExplorationEnabled) { long time = System.currentTimeMillis(); // If we recently long-pressed the other button then they were // long-pressed 'together' if ((time - mLastLockToAppLongPress) < LOCK_TO_APP_GESTURE_TOLERENCE) { activityManager.stopLockTaskMode(); // When exiting refresh disabled flags. mNavigationBarView.setDisabledFlags(mDisabled1, true); return true; } else if ((v.getId() == R.id.back) && !mNavigationBarView.getRecentsButton().getCurrentView().isPressed()) { // If we aren't pressing recents right now then they presses // won't be together, so send the standard long-press action. sendBackLongPress = true; } mLastLockToAppLongPress = time; } else { // If this is back still need to handle sending the long-press event. if (v.getId() == R.id.back) { sendBackLongPress = true; } else if (touchExplorationEnabled && inLockTaskMode) { // When in accessibility mode a long press that is recents (not back) // should stop lock task. activityManager.stopLockTaskMode(); // When exiting refresh disabled flags. mNavigationBarView.setDisabledFlags(mDisabled1, true); return true; } else if (v.getId() == R.id.recent_apps) { return handleLongPressRecents(); } } if (sendBackLongPress) { KeyButtonView keyButtonView = (KeyButtonView) v; keyButtonView.sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); keyButtonView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); return true; } } catch (RemoteException e) { Log.d(TAG, "Unable to reach activity manager", e); Loading @@ -4867,6 +4890,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, return false; } private boolean handleLongPressRecents() { if (mRecents == null || !ActivityManager.supportsMultiWindow() || !getComponent(Divider.class).getView().getSnapAlgorithm() .isSplitScreenFeasible()) { return false; } toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS, MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS); return true; } @Override public void showScreenPinningRequest(int taskId) { if (mKeyguardMonitor.isShowing()) { Loading