mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 00:06:47 +00:00
Merge changes I7b9e6e7f,I9729cd40 into sc-dev
* changes: 2/ Notify adjust touch slop when one handed mode activated 1/ Provides feasibility to adjust touch slop in TouchController
This commit is contained in:
@@ -51,7 +51,7 @@ import com.android.quickstep.views.RecentsView;
|
||||
* first home screen instead of to Overview.
|
||||
*/
|
||||
public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouchController {
|
||||
|
||||
private static final float ONE_HANDED_ACTIVATED_SLOP_MULTIPLIER = 2.5f;
|
||||
|
||||
// How much of the movement to use for translating overview after swipe and hold.
|
||||
private static final float OVERVIEW_MOVEMENT_FACTOR = 0.25f;
|
||||
@@ -260,4 +260,14 @@ public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouch
|
||||
private float dpiFromPx(float pixels) {
|
||||
return Utilities.dpiFromPx(pixels, mLauncher.getResources().getDisplayMetrics().densityDpi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOneHandedModeStateChanged(boolean activated) {
|
||||
if (activated) {
|
||||
mDetector.setTouchSlopMultiplier(ONE_HANDED_ACTIVATED_SLOP_MULTIPLIER);
|
||||
} else {
|
||||
// Reset touch slop multiplier to default 1.0f
|
||||
mDetector.setTouchSlopMultiplier(1f /* default */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,9 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
|
||||
public abstract void onAssistantVisibilityChanged(float visibility);
|
||||
|
||||
/** Called when one handed mode activated or deactivated. */
|
||||
public abstract void onOneHandedModeStateChanged(boolean activated);
|
||||
|
||||
public abstract AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState,
|
||||
boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback);
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ public final class FallbackActivityInterface extends
|
||||
// set to zero prior to this class becoming active.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOneHandedModeStateChanged(boolean activated) {
|
||||
// Do nothing for FallbackActivityInterface
|
||||
}
|
||||
|
||||
/** 6 */
|
||||
@Override
|
||||
public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState,
|
||||
|
||||
@@ -104,6 +104,15 @@ public final class LauncherActivityInterface extends
|
||||
launcher.onAssistantVisibilityChanged(visibility);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOneHandedModeStateChanged(boolean activated) {
|
||||
Launcher launcher = getCreatedActivity();
|
||||
if (launcher == null) {
|
||||
return;
|
||||
}
|
||||
launcher.onOneHandedStateChanged(activated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState,
|
||||
boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
|
||||
|
||||
@@ -111,6 +111,11 @@ public final class OverviewComponentObserver {
|
||||
if (mDeviceState.isHomeDisabled() != mIsHomeDisabled) {
|
||||
updateOverviewTargets();
|
||||
}
|
||||
|
||||
// Notify ALL_APPS touch controller when one handed mode state activated or deactivated
|
||||
if (mDeviceState.isOneHandedModeEnabled()) {
|
||||
mActivityInterface.onOneHandedModeStateChanged(mDeviceState.isOneHandedModeActive());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOverviewTargets(Intent unused) {
|
||||
|
||||
@@ -576,6 +576,14 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
mHotseat.getQsb().setAlpha(1f - visibility);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when one handed mode activated and deactivated.
|
||||
* @param activated true if one handed mode activated, false otherwise.
|
||||
*/
|
||||
public void onOneHandedStateChanged(boolean activated) {
|
||||
mDragLayer.onOneHandedModeStateChanged(activated);
|
||||
}
|
||||
|
||||
private void initDeviceProfile(InvariantDeviceProfile idp) {
|
||||
// Load configuration-specific DeviceProfile
|
||||
mDeviceProfile = idp.getDeviceProfile(this);
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.graphics.Scrim;
|
||||
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -519,4 +520,14 @@ public class DragLayer extends BaseDragLayer<Launcher> {
|
||||
public Scrim getWorkspaceDragScrim() {
|
||||
return mWorkspaceDragScrim;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when one handed mode state changed.
|
||||
* @param activated true if one handed mode activated, false otherwise.
|
||||
*/
|
||||
public void onOneHandedModeStateChanged(boolean activated) {
|
||||
for (TouchController controller : mControllers) {
|
||||
controller.onOneHandedModeStateChanged(activated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,8 @@ public class SingleAxisSwipeDetector extends BaseSwipeDetector {
|
||||
|
||||
private int mScrollDirections;
|
||||
|
||||
private float mTouchSlopMultiplier = 1f;
|
||||
|
||||
public SingleAxisSwipeDetector(@NonNull Context context, @NonNull Listener l,
|
||||
@NonNull Direction dir) {
|
||||
this(ViewConfiguration.get(context), l, dir, Utilities.isRtl(context.getResources()));
|
||||
@@ -115,6 +117,19 @@ public class SingleAxisSwipeDetector extends BaseSwipeDetector {
|
||||
mDir = dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides feasibility to adjust touch slop when visible window size changed. When visible
|
||||
* bounds translate become smaller, multiply a larger multiplier could ensure the UX
|
||||
* more consistent.
|
||||
*
|
||||
* @see #shouldScrollStart(PointF)
|
||||
*
|
||||
* @param touchSlopMultiplier the value to multiply original touch slop.
|
||||
*/
|
||||
public void setTouchSlopMultiplier(float touchSlopMultiplier) {
|
||||
mTouchSlopMultiplier = touchSlopMultiplier;
|
||||
}
|
||||
|
||||
public void setDetectableScrollConditions(int scrollDirectionFlags, boolean ignoreSlop) {
|
||||
mScrollDirections = scrollDirectionFlags;
|
||||
mIgnoreSlopWhenSettling = ignoreSlop;
|
||||
@@ -133,7 +148,7 @@ public class SingleAxisSwipeDetector extends BaseSwipeDetector {
|
||||
@Override
|
||||
protected boolean shouldScrollStart(PointF displacement) {
|
||||
// Reject cases where the angle or slop condition is not met.
|
||||
float minDisplacement = Math.max(mTouchSlop,
|
||||
float minDisplacement = Math.max(mTouchSlop * mTouchSlopMultiplier,
|
||||
Math.abs(mDir.extractOrthogonalDirection(displacement)));
|
||||
if (Math.abs(mDir.extractDirection(displacement)) < minDisplacement) {
|
||||
return false;
|
||||
|
||||
@@ -32,5 +32,10 @@ public interface TouchController {
|
||||
*/
|
||||
boolean onControllerInterceptTouchEvent(MotionEvent ev);
|
||||
|
||||
/**
|
||||
* Called when one handed mode state changed
|
||||
*/
|
||||
default void onOneHandedModeStateChanged(boolean activated) { }
|
||||
|
||||
default void dump(String prefix, PrintWriter writer) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user