Adds an flag guarded extension point for long press nav handle behavior am: eea784aea8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/23377577 Change-Id: Iddd58d5f864b268776edddbce9460c20a168e7ed Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -269,6 +269,9 @@
|
||||
<dimen name="floating_rotation_button_taskbar_left_margin">20dp</dimen>
|
||||
<dimen name="floating_rotation_button_taskbar_bottom_margin">10dp</dimen>
|
||||
|
||||
<!-- Copied from frameworks/base/packages/SystemUI -->
|
||||
<dimen name="navigation_home_handle_width">108dp</dimen>
|
||||
|
||||
<!-- Taskbar -->
|
||||
<dimen name="taskbar_size">@*android:dimen/taskbar_frame_height</dimen>
|
||||
<dimen name="taskbar_ime_size">48dp</dimen>
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
<string name="model_delegate_class" translatable="false">com.android.launcher3.model.QuickstepModelDelegate</string>
|
||||
|
||||
<string name="nav_handle_long_press_handler_class" translatable="false"></string>
|
||||
|
||||
<string name="secondary_display_predictions_class" translatable="false">com.android.launcher3.secondarydisplay.SecondaryDisplayPredictionsImpl</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -42,6 +42,7 @@ public interface InputConsumer {
|
||||
int TYPE_TASKBAR_STASH = 1 << 12;
|
||||
int TYPE_STATUS_BAR = 1 << 13;
|
||||
int TYPE_CURSOR_HOVER = 1 << 14;
|
||||
int TYPE_NAV_HANDLE_LONG_PRESS = 1 << 15;
|
||||
|
||||
String[] NAMES = new String[] {
|
||||
"TYPE_NO_OP", // 0
|
||||
@@ -59,6 +60,7 @@ public interface InputConsumer {
|
||||
"TYPE_TASKBAR_STASH", // 12
|
||||
"TYPE_STATUS_BAR", // 13
|
||||
"TYPE_CURSOR_HOVER", // 14
|
||||
"TYPE_NAV_HANDLE_LONG_PRESS", // 15
|
||||
};
|
||||
|
||||
InputConsumer NO_OP = () -> TYPE_NO_OP;
|
||||
|
||||
@@ -105,6 +105,7 @@ import com.android.launcher3.util.TraceHelper;
|
||||
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.AssistantInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.DeviceLockedInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.NavHandleLongPressInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.OneHandedModeInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.OtherActivityInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.OverviewInputConsumer;
|
||||
@@ -884,6 +885,8 @@ public class TouchInteractionService extends Service
|
||||
+ "using TaskbarUnstashInputConsumer");
|
||||
base = new TaskbarUnstashInputConsumer(this, base, mInputMonitorCompat, tac);
|
||||
}
|
||||
} else if (canStartSystemGesture && FeatureFlags.ENABLE_LONG_PRESS_NAV_HANDLE.get()) {
|
||||
base = new NavHandleLongPressInputConsumer(this, base, mInputMonitorCompat);
|
||||
}
|
||||
|
||||
if (mDeviceState.isBubblesExpanded()) {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.quickstep.inputconsumers;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
|
||||
/**
|
||||
* Class for extending nav handle long press behavior
|
||||
*/
|
||||
public class NavHandleLongPressHandler implements ResourceBasedOverride {
|
||||
|
||||
/** Creates NavHandleLongPressHandler as specified by overrides */
|
||||
public static NavHandleLongPressHandler newInstance(Context context) {
|
||||
return Overrides.getObject(NavHandleLongPressHandler.class, context,
|
||||
R.string.nav_handle_long_press_handler_class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when nav handle is long pressed.
|
||||
*
|
||||
* @return if the long press was consumed, meaning other input consumers should receive a
|
||||
* cancel event
|
||||
*/
|
||||
public boolean onLongPress() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.quickstep.inputconsumers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.quickstep.InputConsumer;
|
||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
|
||||
/**
|
||||
* Listens for a long press
|
||||
*/
|
||||
public class NavHandleLongPressInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
private final GestureDetector mLongPressDetector;
|
||||
private final NavHandleLongPressHandler mNavHandleLongPressHandler;
|
||||
private final float mNavHandleWidth;
|
||||
private final float mScreenWidth;
|
||||
|
||||
public NavHandleLongPressInputConsumer(Context context, InputConsumer delegate,
|
||||
InputMonitorCompat inputMonitor) {
|
||||
super(delegate, inputMonitor);
|
||||
mNavHandleWidth = context.getResources()
|
||||
.getDimensionPixelSize(R.dimen.navigation_home_handle_width);
|
||||
mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
|
||||
|
||||
mNavHandleLongPressHandler = NavHandleLongPressHandler.newInstance(context);
|
||||
|
||||
mLongPressDetector = new GestureDetector(context, new SimpleOnGestureListener() {
|
||||
@Override
|
||||
public void onLongPress(MotionEvent motionEvent) {
|
||||
if (isInArea(motionEvent.getRawX())) {
|
||||
if (mNavHandleLongPressHandler.onLongPress()) {
|
||||
setActive(motionEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE_NAV_HANDLE_LONG_PRESS | mDelegate.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMotionEvent(MotionEvent ev) {
|
||||
mLongPressDetector.onTouchEvent(ev);
|
||||
if (mState != STATE_ACTIVE) {
|
||||
mDelegate.onMotionEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isInArea(float x) {
|
||||
float areaFromMiddle = mNavHandleWidth / 2.0f;
|
||||
float distFromMiddle = Math.abs(mScreenWidth / 2.0f - x);
|
||||
|
||||
return distFromMiddle < areaFromMiddle;
|
||||
}
|
||||
}
|
||||
@@ -253,6 +253,10 @@ public final class FeatureFlags {
|
||||
"INJECT_FALLBACK_APP_CORPUS_RESULTS", DISABLED,
|
||||
"Inject fallback app corpus result when AiAi fails to return it.");
|
||||
|
||||
public static final BooleanFlag ENABLE_LONG_PRESS_NAV_HANDLE =
|
||||
getDebugFlag(282993230, "ENABLE_LONG_PRESS_NAV_HANDLE", DISABLED,
|
||||
"Enables long pressing on the bottom bar nav handle to trigger events.");
|
||||
|
||||
// TODO(Block 17): Clean up flags
|
||||
public static final BooleanFlag ENABLE_TASKBAR_PINNING = getDebugFlag(270396583,
|
||||
"ENABLE_TASKBAR_PINNING", DISABLED,
|
||||
|
||||
Reference in New Issue
Block a user