Loading src/com/android/launcher3/Launcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -258,7 +258,7 @@ import com.android.launcher3.widget.picker.WidgetsFullSheet; import com.android.systemui.plugins.LauncherOverlayPlugin; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.shared.LauncherOverlayManager; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy; import com.android.wm.shell.Flags; import java.io.FileDescriptor; Loading Loading @@ -2810,7 +2810,7 @@ public class Launcher extends StatefulActivity<LauncherState> /** * Call this after onCreate to set or clear overlay. */ public void setLauncherOverlay(LauncherOverlay overlay) { public void setLauncherOverlay(LauncherOverlayTouchProxy overlay) { mWorkspace.setLauncherOverlay(overlay); } Loading src/com/android/launcher3/PagedView.java +13 −13 Original line number Diff line number Diff line Loading @@ -1140,7 +1140,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou mEdgeGlowLeft.onPullDistance(0f, 1f - displacement); } if (!mEdgeGlowRight.isFinished()) { mEdgeGlowRight.onPullDistance(0f, displacement); mEdgeGlowRight.onPullDistance(0f, displacement, ev); } } Loading Loading @@ -1320,10 +1320,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou int consumed = 0; if (delta < 0 && mEdgeGlowRight.getDistance() != 0f) { consumed = Math.round(size * mEdgeGlowRight.onPullDistance(delta / size, displacement)); mEdgeGlowRight.onPullDistance(delta / size, displacement, ev)); } else if (delta > 0 && mEdgeGlowLeft.getDistance() != 0f) { consumed = Math.round(-size * mEdgeGlowLeft.onPullDistance(-delta / size, 1 - displacement)); mEdgeGlowLeft.onPullDistance(-delta / size, 1 - displacement, ev)); } delta -= consumed; } Loading @@ -1341,14 +1341,14 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou final float pulledToX = oldScroll + delta; if (pulledToX < mMinScroll) { mEdgeGlowLeft.onPullDistance(-delta / size, 1.f - displacement); mEdgeGlowLeft.onPullDistance(-delta / size, 1.f - displacement, ev); if (!mEdgeGlowRight.isFinished()) { mEdgeGlowRight.onRelease(); mEdgeGlowRight.onRelease(ev); } } else if (pulledToX > mMaxScroll) { mEdgeGlowRight.onPullDistance(delta / size, displacement); mEdgeGlowRight.onPullDistance(delta / size, displacement, ev); if (!mEdgeGlowLeft.isFinished()) { mEdgeGlowLeft.onRelease(); mEdgeGlowLeft.onRelease(ev); } } Loading @@ -1356,7 +1356,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou postInvalidateOnAnimation(); } } } else { awakenScrollBars(); } Loading Loading @@ -1456,10 +1455,11 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou } invalidate(); } mEdgeGlowLeft.onFlingVelocity(velocity); mEdgeGlowRight.onFlingVelocity(velocity); } mEdgeGlowLeft.onRelease(); mEdgeGlowRight.onRelease(); mEdgeGlowLeft.onRelease(ev); mEdgeGlowRight.onRelease(ev); // End any intermediate reordering states resetTouchState(); break; Loading @@ -1468,8 +1468,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou if (mIsBeingDragged) { runOnPageScrollsInitialized(this::snapToDestination); } mEdgeGlowLeft.onRelease(); mEdgeGlowRight.onRelease(); mEdgeGlowLeft.onRelease(ev); mEdgeGlowRight.onRelease(ev); resetTouchState(); break; Loading src/com/android/launcher3/Workspace.java +2 −2 Original line number Diff line number Diff line Loading @@ -125,8 +125,8 @@ import com.android.launcher3.widget.PendingAppWidgetHostView; import com.android.launcher3.widget.WidgetManagerHelper; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import com.android.launcher3.widget.util.WidgetSizes; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayCallbacks; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy; import java.util.ArrayList; import java.util.Iterator; Loading Loading @@ -1237,7 +1237,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T> mLauncher.onPageEndTransition(); } public void setLauncherOverlay(LauncherOverlay overlay) { public void setLauncherOverlay(LauncherOverlayTouchProxy overlay) { final EdgeEffectCompat newEffect; if (overlay == null) { newEffect = new EdgeEffectCompat(getContext()); Loading src/com/android/launcher3/util/EdgeEffectCompat.java +11 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.util; import android.content.Context; import android.view.MotionEvent; import android.widget.EdgeEffect; import com.android.launcher3.Utilities; Loading Loading @@ -43,4 +44,14 @@ public class EdgeEffectCompat extends EdgeEffect { return deltaDistance; } } public float onPullDistance(float deltaDistance, float displacement, MotionEvent ev) { return onPullDistance(deltaDistance, displacement); } public void onFlingVelocity(int velocity) { } public void onRelease(MotionEvent ev) { onRelease(); } } src/com/android/launcher3/util/OverlayEdgeEffect.java +48 −6 Original line number Diff line number Diff line Loading @@ -17,10 +17,13 @@ package com.android.launcher3.util; import android.content.Context; import android.graphics.Canvas; import android.os.SystemClock; import android.view.MotionEvent; import android.widget.EdgeEffect; import com.android.launcher3.BuildConfig; import com.android.launcher3.Utilities; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy; /** * Extension of {@link EdgeEffect} which shows the Launcher overlay Loading @@ -28,11 +31,11 @@ import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverla public class OverlayEdgeEffect extends EdgeEffectCompat { protected float mDistance; protected final LauncherOverlay mOverlay; protected final LauncherOverlayTouchProxy mOverlay; protected boolean mIsScrolling; protected final boolean mIsRtl; public OverlayEdgeEffect(Context context, LauncherOverlay overlay) { public OverlayEdgeEffect(Context context, LauncherOverlayTouchProxy overlay) { super(context); mOverlay = overlay; mIsRtl = Utilities.isRtl(context.getResources()); Loading @@ -44,12 +47,30 @@ public class OverlayEdgeEffect extends EdgeEffectCompat { } public float onPullDistance(float deltaDistance, float displacement) { // Fallback implementation, will never actually get called if (BuildConfig.IS_DEBUG_DEVICE) { throw new RuntimeException("Wrong method called"); } MotionEvent mv = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, displacement, 0, 0); try { return onPullDistance(deltaDistance, displacement, mv); } finally { mv.recycle(); } } @Override public float onPullDistance(float deltaDistance, float displacement, MotionEvent ev) { mDistance = Math.max(0f, deltaDistance + mDistance); if (!mIsScrolling) { mOverlay.onScrollInteractionBegin(); int originalAction = ev.getAction(); ev.setAction(MotionEvent.ACTION_DOWN); mOverlay.onOverlayMotionEvent(ev, 0); ev.setAction(originalAction); mIsScrolling = true; } mOverlay.onScrollChange(mDistance, mIsRtl); mOverlay.onOverlayMotionEvent(ev, mDistance); return mDistance > 0 ? deltaDistance : 0; } Loading @@ -63,9 +84,30 @@ public class OverlayEdgeEffect extends EdgeEffectCompat { @Override public void onRelease() { // Fallback implementation, will never actually get called if (BuildConfig.IS_DEBUG_DEVICE) { throw new RuntimeException("Wrong method called"); } MotionEvent mv = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, mDistance, 0, 0); onRelease(mv); mv.recycle(); } @Override public void onFlingVelocity(int velocity) { mOverlay.onFlingVelocity(velocity); } @Override public void onRelease(MotionEvent ev) { if (mIsScrolling) { int originalAction = ev.getAction(); ev.setAction(MotionEvent.ACTION_UP); mOverlay.onOverlayMotionEvent(ev, mDistance); ev.setAction(originalAction); mDistance = 0; mOverlay.onScrollInteractionEnd(); mIsScrolling = false; } } Loading Loading
src/com/android/launcher3/Launcher.java +2 −2 Original line number Diff line number Diff line Loading @@ -258,7 +258,7 @@ import com.android.launcher3.widget.picker.WidgetsFullSheet; import com.android.systemui.plugins.LauncherOverlayPlugin; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.shared.LauncherOverlayManager; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy; import com.android.wm.shell.Flags; import java.io.FileDescriptor; Loading Loading @@ -2810,7 +2810,7 @@ public class Launcher extends StatefulActivity<LauncherState> /** * Call this after onCreate to set or clear overlay. */ public void setLauncherOverlay(LauncherOverlay overlay) { public void setLauncherOverlay(LauncherOverlayTouchProxy overlay) { mWorkspace.setLauncherOverlay(overlay); } Loading
src/com/android/launcher3/PagedView.java +13 −13 Original line number Diff line number Diff line Loading @@ -1140,7 +1140,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou mEdgeGlowLeft.onPullDistance(0f, 1f - displacement); } if (!mEdgeGlowRight.isFinished()) { mEdgeGlowRight.onPullDistance(0f, displacement); mEdgeGlowRight.onPullDistance(0f, displacement, ev); } } Loading Loading @@ -1320,10 +1320,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou int consumed = 0; if (delta < 0 && mEdgeGlowRight.getDistance() != 0f) { consumed = Math.round(size * mEdgeGlowRight.onPullDistance(delta / size, displacement)); mEdgeGlowRight.onPullDistance(delta / size, displacement, ev)); } else if (delta > 0 && mEdgeGlowLeft.getDistance() != 0f) { consumed = Math.round(-size * mEdgeGlowLeft.onPullDistance(-delta / size, 1 - displacement)); mEdgeGlowLeft.onPullDistance(-delta / size, 1 - displacement, ev)); } delta -= consumed; } Loading @@ -1341,14 +1341,14 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou final float pulledToX = oldScroll + delta; if (pulledToX < mMinScroll) { mEdgeGlowLeft.onPullDistance(-delta / size, 1.f - displacement); mEdgeGlowLeft.onPullDistance(-delta / size, 1.f - displacement, ev); if (!mEdgeGlowRight.isFinished()) { mEdgeGlowRight.onRelease(); mEdgeGlowRight.onRelease(ev); } } else if (pulledToX > mMaxScroll) { mEdgeGlowRight.onPullDistance(delta / size, displacement); mEdgeGlowRight.onPullDistance(delta / size, displacement, ev); if (!mEdgeGlowLeft.isFinished()) { mEdgeGlowLeft.onRelease(); mEdgeGlowLeft.onRelease(ev); } } Loading @@ -1356,7 +1356,6 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou postInvalidateOnAnimation(); } } } else { awakenScrollBars(); } Loading Loading @@ -1456,10 +1455,11 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou } invalidate(); } mEdgeGlowLeft.onFlingVelocity(velocity); mEdgeGlowRight.onFlingVelocity(velocity); } mEdgeGlowLeft.onRelease(); mEdgeGlowRight.onRelease(); mEdgeGlowLeft.onRelease(ev); mEdgeGlowRight.onRelease(ev); // End any intermediate reordering states resetTouchState(); break; Loading @@ -1468,8 +1468,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou if (mIsBeingDragged) { runOnPageScrollsInitialized(this::snapToDestination); } mEdgeGlowLeft.onRelease(); mEdgeGlowRight.onRelease(); mEdgeGlowLeft.onRelease(ev); mEdgeGlowRight.onRelease(ev); resetTouchState(); break; Loading
src/com/android/launcher3/Workspace.java +2 −2 Original line number Diff line number Diff line Loading @@ -125,8 +125,8 @@ import com.android.launcher3.widget.PendingAppWidgetHostView; import com.android.launcher3.widget.WidgetManagerHelper; import com.android.launcher3.widget.dragndrop.AppWidgetHostViewDragListener; import com.android.launcher3.widget.util.WidgetSizes; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayCallbacks; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy; import java.util.ArrayList; import java.util.Iterator; Loading Loading @@ -1237,7 +1237,7 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T> mLauncher.onPageEndTransition(); } public void setLauncherOverlay(LauncherOverlay overlay) { public void setLauncherOverlay(LauncherOverlayTouchProxy overlay) { final EdgeEffectCompat newEffect; if (overlay == null) { newEffect = new EdgeEffectCompat(getContext()); Loading
src/com/android/launcher3/util/EdgeEffectCompat.java +11 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.util; import android.content.Context; import android.view.MotionEvent; import android.widget.EdgeEffect; import com.android.launcher3.Utilities; Loading Loading @@ -43,4 +44,14 @@ public class EdgeEffectCompat extends EdgeEffect { return deltaDistance; } } public float onPullDistance(float deltaDistance, float displacement, MotionEvent ev) { return onPullDistance(deltaDistance, displacement); } public void onFlingVelocity(int velocity) { } public void onRelease(MotionEvent ev) { onRelease(); } }
src/com/android/launcher3/util/OverlayEdgeEffect.java +48 −6 Original line number Diff line number Diff line Loading @@ -17,10 +17,13 @@ package com.android.launcher3.util; import android.content.Context; import android.graphics.Canvas; import android.os.SystemClock; import android.view.MotionEvent; import android.widget.EdgeEffect; import com.android.launcher3.BuildConfig; import com.android.launcher3.Utilities; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlay; import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverlayTouchProxy; /** * Extension of {@link EdgeEffect} which shows the Launcher overlay Loading @@ -28,11 +31,11 @@ import com.android.systemui.plugins.shared.LauncherOverlayManager.LauncherOverla public class OverlayEdgeEffect extends EdgeEffectCompat { protected float mDistance; protected final LauncherOverlay mOverlay; protected final LauncherOverlayTouchProxy mOverlay; protected boolean mIsScrolling; protected final boolean mIsRtl; public OverlayEdgeEffect(Context context, LauncherOverlay overlay) { public OverlayEdgeEffect(Context context, LauncherOverlayTouchProxy overlay) { super(context); mOverlay = overlay; mIsRtl = Utilities.isRtl(context.getResources()); Loading @@ -44,12 +47,30 @@ public class OverlayEdgeEffect extends EdgeEffectCompat { } public float onPullDistance(float deltaDistance, float displacement) { // Fallback implementation, will never actually get called if (BuildConfig.IS_DEBUG_DEVICE) { throw new RuntimeException("Wrong method called"); } MotionEvent mv = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_MOVE, displacement, 0, 0); try { return onPullDistance(deltaDistance, displacement, mv); } finally { mv.recycle(); } } @Override public float onPullDistance(float deltaDistance, float displacement, MotionEvent ev) { mDistance = Math.max(0f, deltaDistance + mDistance); if (!mIsScrolling) { mOverlay.onScrollInteractionBegin(); int originalAction = ev.getAction(); ev.setAction(MotionEvent.ACTION_DOWN); mOverlay.onOverlayMotionEvent(ev, 0); ev.setAction(originalAction); mIsScrolling = true; } mOverlay.onScrollChange(mDistance, mIsRtl); mOverlay.onOverlayMotionEvent(ev, mDistance); return mDistance > 0 ? deltaDistance : 0; } Loading @@ -63,9 +84,30 @@ public class OverlayEdgeEffect extends EdgeEffectCompat { @Override public void onRelease() { // Fallback implementation, will never actually get called if (BuildConfig.IS_DEBUG_DEVICE) { throw new RuntimeException("Wrong method called"); } MotionEvent mv = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, mDistance, 0, 0); onRelease(mv); mv.recycle(); } @Override public void onFlingVelocity(int velocity) { mOverlay.onFlingVelocity(velocity); } @Override public void onRelease(MotionEvent ev) { if (mIsScrolling) { int originalAction = ev.getAction(); ev.setAction(MotionEvent.ACTION_UP); mOverlay.onOverlayMotionEvent(ev, mDistance); ev.setAction(originalAction); mDistance = 0; mOverlay.onScrollInteractionEnd(); mIsScrolling = false; } } Loading