Loading packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,14 @@ import com.android.systemui.shared.recents.ISystemUiProxy; oneway interface IOverviewProxy { void onBind(in ISystemUiProxy sysUiProxy); /** * Called once immediately prior to the first onMotionEvent() call, providing a hint to the * target the initial source of the subsequent motion events. * * @param downHitTarget is one of the {@link NavigationBarCompat.HitTarget}s */ void onPreMotionEvent(int downHitTarget); /** * Proxies motion events from the nav bar in SystemUI to the OverviewProxyService. The sender * guarantees the following order of events: Loading packages/SystemUI/shared/src/com/android/systemui/shared/system/NavigationBarCompat.java 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.shared.system; import android.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; public class NavigationBarCompat { @Retention(RetentionPolicy.SOURCE) @IntDef({HIT_TARGET_NONE, HIT_TARGET_BACK, HIT_TARGET_HOME}) public @interface HitTarget{} public static final int HIT_TARGET_NONE = 0; public static final int HIT_TARGET_BACK = 1; public static final int HIT_TARGET_HOME = 2; } packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java +5 −2 Original line number Diff line number Diff line Loading @@ -131,6 +131,9 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture mNavigationBarView.requestUnbufferedDispatch(event); event.transform(mTransformGlobalMatrix); try { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { overviewProxy.onPreMotionEvent(mNavigationBarView.getDownHitTarget()); } overviewProxy.onMotionEvent(event); if (DEBUG_OVERVIEW_PROXY) { Log.d(TAG_OPS, "Send MotionEvent: " + event.toString()); Loading @@ -146,8 +149,8 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture } public boolean onInterceptTouchEvent(MotionEvent event) { int action = event.getAction(); switch (action & MotionEvent.ACTION_MASK) { int action = event.getActionMasked(); switch (action) { case MotionEvent.ACTION_DOWN: { mTouchDownX = (int) event.getX(); mTouchDownY = (int) event.getY(); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +41 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package com.android.systemui.statusbar.phone; import static android.view.MotionEvent.ACTION_DOWN; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_BACK; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_HOME; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_NONE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.LayoutTransition; Loading Loading @@ -61,6 +66,7 @@ import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.statusbar.phone.NavGesture; import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper; import com.android.systemui.recents.RecentsOnboarding; import com.android.systemui.shared.system.NavigationBarCompat; import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.policy.DeadZone; import com.android.systemui.statusbar.policy.KeyButtonDrawable; Loading Loading @@ -95,6 +101,11 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav int mDisabledFlags = 0; int mNavigationIconHints = 0; private @NavigationBarCompat.HitTarget int mDownHitTarget = HIT_TARGET_NONE; private Rect mHomeButtonBounds = new Rect(); private Rect mBackButtonBounds = new Rect(); private int[] mTmpPosition = new int[2]; private KeyButtonDrawable mBackIcon, mBackLandIcon, mBackAltIcon, mBackAltLandIcon; private KeyButtonDrawable mBackCarModeIcon, mBackLandCarModeIcon; private KeyButtonDrawable mBackAltCarModeIcon, mBackAltLandCarModeIcon; Loading Loading @@ -284,6 +295,18 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav @Override public boolean onInterceptTouchEvent(MotionEvent event) { switch (event.getActionMasked()) { case ACTION_DOWN: int x = (int) event.getX(); int y = (int) event.getY(); mDownHitTarget = HIT_TARGET_NONE; if (mBackButtonBounds.contains(x, y)) { mDownHitTarget = HIT_TARGET_BACK; } else if (mHomeButtonBounds.contains(x, y)) { mDownHitTarget = HIT_TARGET_HOME; } break; } return mGestureHelper.onInterceptTouchEvent(event); } Loading @@ -295,6 +318,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav return super.onTouchEvent(event); } public @NavigationBarCompat.HitTarget int getDownHitTarget() { return mDownHitTarget; } public void abortCurrentGesture() { getHomeButton().abortCurrentGesture(); } Loading Loading @@ -783,9 +810,23 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); updateButtonLocationOnScreen(getBackButton(), mBackButtonBounds); updateButtonLocationOnScreen(getHomeButton(), mHomeButtonBounds); mGestureHelper.onLayout(changed, left, top, right, bottom); } private void updateButtonLocationOnScreen(ButtonDispatcher button, Rect buttonBounds) { View view = button.getCurrentView(); if (view == null) { buttonBounds.setEmpty(); return; } view.getLocationInWindow(mTmpPosition); buttonBounds.set(mTmpPosition[0], mTmpPosition[1], mTmpPosition[0] + view.getMeasuredWidth(), mTmpPosition[1] + view.getMeasuredHeight()); } private void updateRotatedViews() { mRotatedViews[Surface.ROTATION_0] = mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickScrubController.java +5 −15 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT; import static android.view.WindowManagerPolicyConstants.NAV_BAR_BOTTOM; import static com.android.systemui.OverviewProxyService.DEBUG_OVERVIEW_PROXY; import static com.android.systemui.OverviewProxyService.TAG_OPS; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_HOME; /** * Class to detect gestures on the navigation bar and implement quick scrub and switch. Loading Loading @@ -92,7 +93,6 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene private final Handler mHandler = new Handler(); private final Interpolator mQuickScrubEndInterpolator = new DecelerateInterpolator(); private final Rect mTrackRect = new Rect(); private final Rect mHomeButtonRect = new Rect(); private final Paint mTrackPaint = new Paint(); private final int mScrollTouchSlop; private final OverviewProxyService mOverviewEventSender; Loading Loading @@ -138,7 +138,7 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velX, float velY) { if (!isQuickScrubEnabled() || mQuickScrubActive || !mAllowQuickSwitch || !mHomeButtonRect.contains(mTouchDownX, mTouchDownY)) { mNavigationBarView.getDownHitTarget() != HIT_TARGET_HOME) { return false; } float velocityX = mIsRTL ? -velX : velX; Loading Loading @@ -226,7 +226,8 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene case MotionEvent.ACTION_DOWN: { int x = (int) event.getX(); int y = (int) event.getY(); if (isQuickScrubEnabled() && mHomeButtonRect.contains(x, y)) { if (isQuickScrubEnabled() && mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME) { mTouchDownX = x; mTouchDownY = y; homeButton.setDelayTouchFeedback(true); Loading Loading @@ -346,17 +347,6 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene x2 = x1 + width / 2 - mTrackPadding; } mTrackRect.set(x1, y1, x2, y2); // Get the touch rect of the home button location View homeView = mNavigationBarView.getHomeButton().getCurrentView(); if (homeView != null) { int[] globalHomePos = homeView.getLocationOnScreen(); int[] globalNavBarPos = mNavigationBarView.getLocationOnScreen(); int homeX = globalHomePos[0] - globalNavBarPos[0]; int homeY = globalHomePos[1] - globalNavBarPos[1]; mHomeButtonRect.set(homeX, homeY, homeX + homeView.getMeasuredWidth(), homeY + homeView.getMeasuredHeight()); } } @Override Loading @@ -381,7 +371,7 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene } boolean isQuickScrubEnabled() { return SystemProperties.getBoolean("persist.quickstep.scrub.enabled", false); return SystemProperties.getBoolean("persist.quickstep.scrub.enabled", true); } private void startQuickScrub() { Loading Loading
packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,14 @@ import com.android.systemui.shared.recents.ISystemUiProxy; oneway interface IOverviewProxy { void onBind(in ISystemUiProxy sysUiProxy); /** * Called once immediately prior to the first onMotionEvent() call, providing a hint to the * target the initial source of the subsequent motion events. * * @param downHitTarget is one of the {@link NavigationBarCompat.HitTarget}s */ void onPreMotionEvent(int downHitTarget); /** * Proxies motion events from the nav bar in SystemUI to the OverviewProxyService. The sender * guarantees the following order of events: Loading
packages/SystemUI/shared/src/com/android/systemui/shared/system/NavigationBarCompat.java 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ package com.android.systemui.shared.system; import android.annotation.IntDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; public class NavigationBarCompat { @Retention(RetentionPolicy.SOURCE) @IntDef({HIT_TARGET_NONE, HIT_TARGET_BACK, HIT_TARGET_HOME}) public @interface HitTarget{} public static final int HIT_TARGET_NONE = 0; public static final int HIT_TARGET_BACK = 1; public static final int HIT_TARGET_HOME = 2; }
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java +5 −2 Original line number Diff line number Diff line Loading @@ -131,6 +131,9 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture mNavigationBarView.requestUnbufferedDispatch(event); event.transform(mTransformGlobalMatrix); try { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { overviewProxy.onPreMotionEvent(mNavigationBarView.getDownHitTarget()); } overviewProxy.onMotionEvent(event); if (DEBUG_OVERVIEW_PROXY) { Log.d(TAG_OPS, "Send MotionEvent: " + event.toString()); Loading @@ -146,8 +149,8 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture } public boolean onInterceptTouchEvent(MotionEvent event) { int action = event.getAction(); switch (action & MotionEvent.ACTION_MASK) { int action = event.getActionMasked(); switch (action) { case MotionEvent.ACTION_DOWN: { mTouchDownX = (int) event.getX(); mTouchDownY = (int) event.getY(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +41 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package com.android.systemui.statusbar.phone; import static android.view.MotionEvent.ACTION_DOWN; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_BACK; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_HOME; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_NONE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.LayoutTransition; Loading Loading @@ -61,6 +66,7 @@ import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.statusbar.phone.NavGesture; import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper; import com.android.systemui.recents.RecentsOnboarding; import com.android.systemui.shared.system.NavigationBarCompat; import com.android.systemui.stackdivider.Divider; import com.android.systemui.statusbar.policy.DeadZone; import com.android.systemui.statusbar.policy.KeyButtonDrawable; Loading Loading @@ -95,6 +101,11 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav int mDisabledFlags = 0; int mNavigationIconHints = 0; private @NavigationBarCompat.HitTarget int mDownHitTarget = HIT_TARGET_NONE; private Rect mHomeButtonBounds = new Rect(); private Rect mBackButtonBounds = new Rect(); private int[] mTmpPosition = new int[2]; private KeyButtonDrawable mBackIcon, mBackLandIcon, mBackAltIcon, mBackAltLandIcon; private KeyButtonDrawable mBackCarModeIcon, mBackLandCarModeIcon; private KeyButtonDrawable mBackAltCarModeIcon, mBackAltLandCarModeIcon; Loading Loading @@ -284,6 +295,18 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav @Override public boolean onInterceptTouchEvent(MotionEvent event) { switch (event.getActionMasked()) { case ACTION_DOWN: int x = (int) event.getX(); int y = (int) event.getY(); mDownHitTarget = HIT_TARGET_NONE; if (mBackButtonBounds.contains(x, y)) { mDownHitTarget = HIT_TARGET_BACK; } else if (mHomeButtonBounds.contains(x, y)) { mDownHitTarget = HIT_TARGET_HOME; } break; } return mGestureHelper.onInterceptTouchEvent(event); } Loading @@ -295,6 +318,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav return super.onTouchEvent(event); } public @NavigationBarCompat.HitTarget int getDownHitTarget() { return mDownHitTarget; } public void abortCurrentGesture() { getHomeButton().abortCurrentGesture(); } Loading Loading @@ -783,9 +810,23 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); updateButtonLocationOnScreen(getBackButton(), mBackButtonBounds); updateButtonLocationOnScreen(getHomeButton(), mHomeButtonBounds); mGestureHelper.onLayout(changed, left, top, right, bottom); } private void updateButtonLocationOnScreen(ButtonDispatcher button, Rect buttonBounds) { View view = button.getCurrentView(); if (view == null) { buttonBounds.setEmpty(); return; } view.getLocationInWindow(mTmpPosition); buttonBounds.set(mTmpPosition[0], mTmpPosition[1], mTmpPosition[0] + view.getMeasuredWidth(), mTmpPosition[1] + view.getMeasuredHeight()); } private void updateRotatedViews() { mRotatedViews[Surface.ROTATION_0] = mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickScrubController.java +5 −15 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT; import static android.view.WindowManagerPolicyConstants.NAV_BAR_BOTTOM; import static com.android.systemui.OverviewProxyService.DEBUG_OVERVIEW_PROXY; import static com.android.systemui.OverviewProxyService.TAG_OPS; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_HOME; /** * Class to detect gestures on the navigation bar and implement quick scrub and switch. Loading Loading @@ -92,7 +93,6 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene private final Handler mHandler = new Handler(); private final Interpolator mQuickScrubEndInterpolator = new DecelerateInterpolator(); private final Rect mTrackRect = new Rect(); private final Rect mHomeButtonRect = new Rect(); private final Paint mTrackPaint = new Paint(); private final int mScrollTouchSlop; private final OverviewProxyService mOverviewEventSender; Loading Loading @@ -138,7 +138,7 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velX, float velY) { if (!isQuickScrubEnabled() || mQuickScrubActive || !mAllowQuickSwitch || !mHomeButtonRect.contains(mTouchDownX, mTouchDownY)) { mNavigationBarView.getDownHitTarget() != HIT_TARGET_HOME) { return false; } float velocityX = mIsRTL ? -velX : velX; Loading Loading @@ -226,7 +226,8 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene case MotionEvent.ACTION_DOWN: { int x = (int) event.getX(); int y = (int) event.getY(); if (isQuickScrubEnabled() && mHomeButtonRect.contains(x, y)) { if (isQuickScrubEnabled() && mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME) { mTouchDownX = x; mTouchDownY = y; homeButton.setDelayTouchFeedback(true); Loading Loading @@ -346,17 +347,6 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene x2 = x1 + width / 2 - mTrackPadding; } mTrackRect.set(x1, y1, x2, y2); // Get the touch rect of the home button location View homeView = mNavigationBarView.getHomeButton().getCurrentView(); if (homeView != null) { int[] globalHomePos = homeView.getLocationOnScreen(); int[] globalNavBarPos = mNavigationBarView.getLocationOnScreen(); int homeX = globalHomePos[0] - globalNavBarPos[0]; int homeY = globalHomePos[1] - globalNavBarPos[1]; mHomeButtonRect.set(homeX, homeY, homeX + homeView.getMeasuredWidth(), homeY + homeView.getMeasuredHeight()); } } @Override Loading @@ -381,7 +371,7 @@ public class QuickScrubController extends GestureDetector.SimpleOnGestureListene } boolean isQuickScrubEnabled() { return SystemProperties.getBoolean("persist.quickstep.scrub.enabled", false); return SystemProperties.getBoolean("persist.quickstep.scrub.enabled", true); } private void startQuickScrub() { Loading