Making navigation mode listener a singleton so that the change is dispatched
everywhere synchronously. Change-Id: Iee8c5957d78dfad3fb03e814de0367adcaa0c98b
This commit is contained in:
parent
814b615b62
commit
5743f8635b
|
@ -23,7 +23,6 @@ android_library {
|
|||
],
|
||||
srcs: [
|
||||
"tests/tapl/**/*.java",
|
||||
"quickstep/src/com/android/quickstep/SwipeUpSetting.java",
|
||||
"src/com/android/launcher3/util/SecureSettingsObserver.java",
|
||||
"src/com/android/launcher3/TestProtocol.java",
|
||||
],
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.android.launcher3.uioverrides.touchcontrollers.LandscapeStatesTouchCo
|
|||
import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.StatusBarTouchController;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.quickstep.OverviewInteractionState;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.views.IconRecentsView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -52,8 +52,8 @@ public abstract class RecentsUiFactory {
|
|||
list.add(new LandscapeStatesTouchController(launcher));
|
||||
list.add(new LandscapeEdgeSwipeController(launcher));
|
||||
} else {
|
||||
boolean allowDragToOverview = OverviewInteractionState.INSTANCE.get(launcher)
|
||||
.isSwipeUpGestureEnabled();
|
||||
boolean allowDragToOverview = SysUINavigationMode.INSTANCE.get(launcher)
|
||||
.getMode().hasGestures;
|
||||
list.add(new PortraitStatesTouchController(launcher, allowDragToOverview));
|
||||
}
|
||||
if (FeatureFlags.PULL_DOWN_STATUS_BAR && Utilities.IS_DEBUG_DEVICE
|
||||
|
|
|
@ -20,7 +20,6 @@ import static android.view.View.VISIBLE;
|
|||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.config.FeatureFlags.SWIPE_HOME;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
|
@ -39,7 +38,8 @@ import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchControlle
|
|||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.launcher3.util.UiThreadHelper;
|
||||
import com.android.launcher3.util.UiThreadHelper.AsyncCommand;
|
||||
import com.android.quickstep.OverviewInteractionState;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.SysUINavigationMode.Mode;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.systemui.shared.system.WindowManagerWrapper;
|
||||
|
||||
|
@ -58,15 +58,11 @@ public abstract class RecentsUiFactory {
|
|||
private static final float RECENTS_PREPARE_SCALE = 1.33f;
|
||||
|
||||
public static TouchController[] createTouchControllers(Launcher launcher) {
|
||||
boolean swipeUpEnabled = OverviewInteractionState.INSTANCE.get(launcher)
|
||||
.isSwipeUpGestureEnabled();
|
||||
boolean swipeUpToHome = swipeUpEnabled && SWIPE_HOME.get();
|
||||
|
||||
Mode mode = SysUINavigationMode.INSTANCE.get(launcher).getMode();
|
||||
|
||||
ArrayList<TouchController> list = new ArrayList<>();
|
||||
list.add(launcher.getDragController());
|
||||
|
||||
if (swipeUpToHome) {
|
||||
if (mode == Mode.NO_BUTTON) {
|
||||
list.add(new QuickSwitchTouchController(launcher));
|
||||
list.add(new FlingAndHoldTouchController(launcher));
|
||||
} else {
|
||||
|
@ -75,8 +71,8 @@ public abstract class RecentsUiFactory {
|
|||
list.add(new LandscapeEdgeSwipeController(launcher));
|
||||
} else {
|
||||
list.add(new PortraitStatesTouchController(launcher,
|
||||
swipeUpEnabled /* allowDragToOverview */));
|
||||
if (swipeUpEnabled) {
|
||||
mode.hasGestures /* allowDragToOverview */));
|
||||
if (mode.hasGestures) {
|
||||
list.add(new QuickSwitchTouchController(launcher));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ import com.android.launcher3.util.FlingBlockCheck;
|
|||
import com.android.launcher3.util.PendingAnimation;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.quickstep.OverviewInteractionState;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.quickstep.views.TaskView;
|
||||
|
||||
|
@ -123,8 +123,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
|
|||
if (mRecentsView.isTaskViewVisible(view) && mActivity.getDragLayer()
|
||||
.isEventOverView(view, ev)) {
|
||||
mTaskBeingDragged = view;
|
||||
if (!OverviewInteractionState.INSTANCE.get(mActivity)
|
||||
.isSwipeUpGestureEnabled()) {
|
||||
if (!SysUINavigationMode.INSTANCE.get(mActivity).getMode().hasGestures) {
|
||||
// Don't allow swipe down to open if we don't support swipe up
|
||||
// to enter overview.
|
||||
directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE;
|
||||
|
|
|
@ -44,10 +44,10 @@ import android.view.MotionEvent;
|
|||
import com.android.launcher3.MainThreadExecutor;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.compat.UserManagerCompat;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.logging.EventLogArray;
|
||||
import com.android.launcher3.util.LooperExecutor;
|
||||
import com.android.launcher3.util.UiThreadHelper;
|
||||
import com.android.quickstep.SysUINavigationMode.Mode;
|
||||
import com.android.systemui.shared.recents.IOverviewProxy;
|
||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
|
@ -315,8 +315,8 @@ public class TouchInteractionService extends Service {
|
|||
mOverviewComponentObserver.getActivityControlHelper();
|
||||
if (runningTaskInfo == null && !mSwipeSharedState.goingToLauncher) {
|
||||
return InputConsumer.NO_OP;
|
||||
} else if (mAssistantAvailable && mOverviewInteractionState.isSwipeUpGestureEnabled()
|
||||
&& FeatureFlags.ENABLE_ASSISTANT_GESTURE.get()
|
||||
} else if (mAssistantAvailable
|
||||
&& SysUINavigationMode.INSTANCE.get(this).getMode() == Mode.NO_BUTTON
|
||||
&& AssistantTouchConsumer.withinTouchRegion(this, event)) {
|
||||
return new AssistantTouchConsumer(this, mISystemUiProxy, !activityControl.isResumed()
|
||||
? createOtherActivityInputConsumer(event, runningTaskInfo) : null);
|
||||
|
|
|
@ -32,9 +32,7 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatProperty;
|
||||
import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
|
@ -44,7 +42,7 @@ import com.android.launcher3.anim.Interpolators;
|
|||
import com.android.launcher3.util.PendingAnimation;
|
||||
import com.android.launcher3.views.BaseDragLayer;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
import com.android.quickstep.OverviewInteractionState;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.hints.ChipsContainer;
|
||||
import com.android.quickstep.util.ClipAnimationHelper;
|
||||
import com.android.quickstep.util.ClipAnimationHelper.TransformParams;
|
||||
|
@ -132,7 +130,7 @@ public class LauncherRecentsView extends RecentsView<Launcher> {
|
|||
ClipAnimationHelper helper) {
|
||||
AnimatorSet anim = super.createAdjacentPageAnimForTaskLaunch(tv, helper);
|
||||
|
||||
if (!OverviewInteractionState.INSTANCE.get(mActivity).isSwipeUpGestureEnabled()) {
|
||||
if (!SysUINavigationMode.INSTANCE.get(mActivity).getMode().hasGestures) {
|
||||
// Hotseat doesn't move when opening recents with the button,
|
||||
// so don't animate it here either.
|
||||
return anim;
|
||||
|
|
|
@ -41,8 +41,11 @@ import com.android.launcher3.LauncherStateManager;
|
|||
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||
import com.android.launcher3.QuickstepAppTransitionManagerImpl;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.quickstep.OverviewInteractionState;
|
||||
import com.android.quickstep.RecentsModel;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
|
||||
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
|
||||
import com.android.systemui.shared.system.ActivityCompat;
|
||||
|
||||
|
@ -52,8 +55,11 @@ import java.util.zip.Deflater;
|
|||
|
||||
public class UiFactory extends RecentsUiFactory {
|
||||
|
||||
public static void setOnTouchControllersChangedListener(Context context, Runnable listener) {
|
||||
OverviewInteractionState.INSTANCE.get(context).setOnSwipeUpSettingChangedListener(listener);
|
||||
public static Runnable enableLiveTouchControllerChanges(DragLayer dl) {
|
||||
NavigationModeChangeListener listener = m -> dl.recreateControllers();
|
||||
SysUINavigationMode mode = SysUINavigationMode.INSTANCE.get(dl.getContext());
|
||||
mode.addModeChangeListener(listener);
|
||||
return () -> mode.removeModeChangeListener(listener);
|
||||
}
|
||||
|
||||
public static StateHandler[] getStateHandler(Launcher launcher) {
|
||||
|
@ -89,8 +95,8 @@ public class UiFactory extends RecentsUiFactory {
|
|||
|
||||
@Override
|
||||
public void onStateTransitionComplete(LauncherState finalState) {
|
||||
boolean swipeUpEnabled = OverviewInteractionState.INSTANCE.get(launcher)
|
||||
.isSwipeUpGestureEnabled();
|
||||
boolean swipeUpEnabled = SysUINavigationMode.INSTANCE.get(launcher).getMode()
|
||||
.hasGestures;
|
||||
LauncherState prevState = launcher.getStateManager().getLastState();
|
||||
|
||||
if (((swipeUpEnabled && finalState == OVERVIEW) || (!swipeUpEnabled
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
/**
|
||||
* Observer for the resource config that specifies the navigation bar mode.
|
||||
*/
|
||||
public class NavBarModeOverlayResourceObserver extends BroadcastReceiver {
|
||||
|
||||
private static final String TAG = "NavBarModeOverlayResourceObserver";
|
||||
|
||||
private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
|
||||
private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
|
||||
"config_navBarInteractionMode";
|
||||
|
||||
private final Context mContext;
|
||||
private final OnChangeListener mOnChangeListener;
|
||||
|
||||
public NavBarModeOverlayResourceObserver(Context context, OnChangeListener listener) {
|
||||
mContext = context;
|
||||
mOnChangeListener = listener;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED);
|
||||
filter.addDataScheme("package");
|
||||
mContext.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mOnChangeListener.onNavBarModeChanged(getSystemIntegerRes(context,
|
||||
NAV_BAR_INTERACTION_MODE_RES_NAME));
|
||||
}
|
||||
|
||||
public interface OnChangeListener {
|
||||
void onNavBarModeChanged(int mode);
|
||||
}
|
||||
|
||||
public static boolean isSwipeUpModeEnabled(Context context) {
|
||||
return QuickStepContract.isSwipeUpMode(getSystemIntegerRes(context,
|
||||
NAV_BAR_INTERACTION_MODE_RES_NAME));
|
||||
}
|
||||
|
||||
public static boolean isEdgeToEdgeModeEnabled(Context context) {
|
||||
return QuickStepContract.isGesturalMode(getSystemIntegerRes(context,
|
||||
NAV_BAR_INTERACTION_MODE_RES_NAME));
|
||||
}
|
||||
|
||||
public static boolean isLegacyModeEnabled(Context context) {
|
||||
return QuickStepContract.isLegacyMode(getSystemIntegerRes(context,
|
||||
NAV_BAR_INTERACTION_MODE_RES_NAME));
|
||||
}
|
||||
|
||||
private static int getSystemIntegerRes(Context context, String resName) {
|
||||
Resources res = context.getResources();
|
||||
int resId = res.getIdentifier(resName, "integer", "android");
|
||||
|
||||
if (resId != 0) {
|
||||
return res.getInteger(resId);
|
||||
} else {
|
||||
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,8 +30,8 @@ import com.android.launcher3.allapps.DiscoveryBounce;
|
|||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.UiThreadHelper;
|
||||
import com.android.quickstep.SysUINavigationMode.Mode;
|
||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
|
@ -56,10 +56,7 @@ public class OverviewInteractionState {
|
|||
|
||||
private static final int MSG_SET_PROXY = 200;
|
||||
private static final int MSG_SET_BACK_BUTTON_ALPHA = 201;
|
||||
private static final int MSG_SET_SWIPE_UP_ENABLED = 202;
|
||||
|
||||
// TODO: Discriminate between swipe up and edge to edge
|
||||
private final NavBarModeOverlayResourceObserver mSwipeUpSettingObserver;
|
||||
private static final int MSG_APPLY_FLAGS = 202;
|
||||
|
||||
private final Context mContext;
|
||||
private final Handler mUiHandler;
|
||||
|
@ -70,8 +67,6 @@ public class OverviewInteractionState {
|
|||
private boolean mSwipeUpEnabled;
|
||||
private float mBackButtonAlpha = 1;
|
||||
|
||||
private Runnable mOnSwipeUpSettingChangedListener;
|
||||
|
||||
private OverviewInteractionState(Context context) {
|
||||
mContext = context;
|
||||
|
||||
|
@ -81,20 +76,8 @@ public class OverviewInteractionState {
|
|||
mUiHandler = new Handler(this::handleUiMessage);
|
||||
mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage);
|
||||
|
||||
mSwipeUpEnabled = NavBarModeOverlayResourceObserver.isSwipeUpModeEnabled(mContext)
|
||||
|| NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(mContext);
|
||||
if (SwipeUpSetting.isSystemNavigationSettingAvailable()) {
|
||||
mSwipeUpSettingObserver = new NavBarModeOverlayResourceObserver(context,
|
||||
this::notifySwipeUpSettingChanged);
|
||||
mSwipeUpSettingObserver.register();
|
||||
resetHomeBounceSeenOnQuickstepEnabledFirstTime();
|
||||
} else {
|
||||
mSwipeUpSettingObserver = null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSwipeUpGestureEnabled() {
|
||||
return mSwipeUpEnabled;
|
||||
onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context)
|
||||
.addModeChangeListener(this::onNavigationModeChanged));
|
||||
}
|
||||
|
||||
public float getBackButtonAlpha() {
|
||||
|
@ -130,23 +113,13 @@ public class OverviewInteractionState {
|
|||
case MSG_SET_BACK_BUTTON_ALPHA:
|
||||
applyBackButtonAlpha((float) msg.obj, msg.arg1 == 1);
|
||||
return true;
|
||||
case MSG_SET_SWIPE_UP_ENABLED:
|
||||
mSwipeUpEnabled = msg.arg1 != 0;
|
||||
resetHomeBounceSeenOnQuickstepEnabledFirstTime();
|
||||
|
||||
if (mOnSwipeUpSettingChangedListener != null) {
|
||||
mOnSwipeUpSettingChangedListener.run();
|
||||
}
|
||||
case MSG_APPLY_FLAGS:
|
||||
break;
|
||||
}
|
||||
applyFlags();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setOnSwipeUpSettingChangedListener(Runnable listener) {
|
||||
mOnSwipeUpSettingChangedListener = listener;
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private void applyFlags() {
|
||||
if (mISystemUiProxy == null) {
|
||||
|
@ -176,16 +149,12 @@ public class OverviewInteractionState {
|
|||
}
|
||||
}
|
||||
|
||||
private void notifySwipeUpSettingChanged(int mode) {
|
||||
boolean swipeUpEnabled = !QuickStepContract.isLegacyMode(mode);
|
||||
boolean gesturalEnabled = QuickStepContract.isGesturalMode(mode);
|
||||
private void onNavigationModeChanged(SysUINavigationMode.Mode mode) {
|
||||
FeatureFlags.SWIPE_HOME.updateStorage(mContext, mode == Mode.NO_BUTTON);
|
||||
|
||||
FeatureFlags.SWIPE_HOME.updateStorage(mContext, gesturalEnabled);
|
||||
FeatureFlags.ENABLE_ASSISTANT_GESTURE.updateStorage(mContext, gesturalEnabled);
|
||||
|
||||
mUiHandler.removeMessages(MSG_SET_SWIPE_UP_ENABLED);
|
||||
mUiHandler.obtainMessage(MSG_SET_SWIPE_UP_ENABLED, swipeUpEnabled ? 1 : 0, 0).
|
||||
sendToTarget();
|
||||
mSwipeUpEnabled = mode.hasGestures;
|
||||
resetHomeBounceSeenOnQuickstepEnabledFirstTime();
|
||||
mBgHandler.obtainMessage(MSG_APPLY_FLAGS).sendToTarget();
|
||||
}
|
||||
|
||||
private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* 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.quickstep;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
|
||||
public final class SwipeUpSetting {
|
||||
private static final String TAG = "SwipeUpSetting";
|
||||
|
||||
private static final String SWIPE_UP_SETTING_AVAILABLE_RES_NAME =
|
||||
"config_swipe_up_gesture_setting_available";
|
||||
|
||||
public static boolean isSystemNavigationSettingAvailable() {
|
||||
return getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME);
|
||||
}
|
||||
|
||||
private static boolean getSystemBooleanRes(String resName) {
|
||||
Resources res = Resources.getSystem();
|
||||
int resId = res.getIdentifier(resName, "bool", "android");
|
||||
|
||||
if (resId != 0) {
|
||||
return res.getBoolean(resId);
|
||||
} else {
|
||||
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Observer for the resource config that specifies the navigation bar mode.
|
||||
*/
|
||||
public class SysUINavigationMode {
|
||||
|
||||
public enum Mode {
|
||||
THREE_BUTTONS(false),
|
||||
TWO_BUTTONS(true),
|
||||
NO_BUTTON(true);
|
||||
|
||||
public final boolean hasGestures;
|
||||
|
||||
Mode(boolean hasGestures) {
|
||||
this.hasGestures = hasGestures;
|
||||
}
|
||||
}
|
||||
|
||||
public static MainThreadInitializedObject<SysUINavigationMode> INSTANCE =
|
||||
new MainThreadInitializedObject<>(SysUINavigationMode::new);
|
||||
|
||||
private static final String TAG = "SysUINavigationMode";
|
||||
|
||||
private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
|
||||
private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
|
||||
"config_navBarInteractionMode";
|
||||
|
||||
private final Context mContext;
|
||||
private Mode mMode;
|
||||
|
||||
private final List<NavigationModeChangeListener> mChangeListeners = new ArrayList<>();
|
||||
|
||||
public SysUINavigationMode(Context context) {
|
||||
mContext = context;
|
||||
initializeMode();
|
||||
|
||||
IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED);
|
||||
filter.addDataScheme("package");
|
||||
mContext.registerReceiver(new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Mode oldMode = mMode;
|
||||
initializeMode();
|
||||
if (mMode != oldMode) {
|
||||
dispatchModeChange();
|
||||
}
|
||||
}
|
||||
}, filter);
|
||||
}
|
||||
|
||||
private void initializeMode() {
|
||||
int modeInt = getSystemIntegerRes(mContext, NAV_BAR_INTERACTION_MODE_RES_NAME);
|
||||
|
||||
if (QuickStepContract.isGesturalMode(modeInt)) {
|
||||
mMode = Mode.NO_BUTTON;
|
||||
} else if (QuickStepContract.isSwipeUpMode(modeInt)) {
|
||||
mMode = Mode.TWO_BUTTONS;
|
||||
} else {
|
||||
mMode = Mode.THREE_BUTTONS;
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchModeChange() {
|
||||
for (NavigationModeChangeListener listener : mChangeListeners) {
|
||||
listener.onNavigationModeChanged(mMode);
|
||||
}
|
||||
}
|
||||
|
||||
public Mode addModeChangeListener(NavigationModeChangeListener listener) {
|
||||
mChangeListeners.add(listener);
|
||||
return mMode;
|
||||
}
|
||||
|
||||
public void removeModeChangeListener(NavigationModeChangeListener listener) {
|
||||
mChangeListeners.remove(listener);
|
||||
}
|
||||
|
||||
public Mode getMode() {
|
||||
return mMode;
|
||||
}
|
||||
|
||||
private static int getSystemIntegerRes(Context context, String resName) {
|
||||
Resources res = context.getResources();
|
||||
int resId = res.getIdentifier(resName, "integer", "android");
|
||||
|
||||
if (resId != 0) {
|
||||
return res.getInteger(resId);
|
||||
} else {
|
||||
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public interface NavigationModeChangeListener {
|
||||
|
||||
void onNavigationModeChanged(Mode newMode);
|
||||
}
|
||||
}
|
|
@ -257,6 +257,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||
public ViewGroupFocusHelper mFocusHandler;
|
||||
|
||||
private RotationHelper mRotationHelper;
|
||||
private Runnable mCancelTouchController;
|
||||
|
||||
final Handler mHandler = new Handler();
|
||||
private final Runnable mHandleDeferredResume = this::handleDeferredResume;
|
||||
|
@ -946,7 +947,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||
|
||||
// Setup the drag layer
|
||||
mDragLayer.setup(mDragController, mWorkspace);
|
||||
UiFactory.setOnTouchControllersChangedListener(this, mDragLayer::recreateControllers);
|
||||
mCancelTouchController = UiFactory.enableLiveTouchControllerChanges(mDragLayer);
|
||||
|
||||
mWorkspace.setup(mDragController);
|
||||
// Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
|
||||
|
@ -1318,7 +1319,10 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||
unregisterReceiver(mScreenOffReceiver);
|
||||
mWorkspace.removeFolderListeners();
|
||||
|
||||
UiFactory.setOnTouchControllersChangedListener(this, null);
|
||||
if (mCancelTouchController != null) {
|
||||
mCancelTouchController.run();
|
||||
mCancelTouchController = null;
|
||||
}
|
||||
|
||||
// Stop callbacks from LauncherModel
|
||||
// It's possible to receive onDestroy after a new Launcher activity has
|
||||
|
|
|
@ -118,10 +118,6 @@ abstract class BaseFlags {
|
|||
"ENABLE_HINTS_IN_OVERVIEW", false,
|
||||
"Show chip hints and gleams on the overview screen");
|
||||
|
||||
public static final TogglableFlag ENABLE_ASSISTANT_GESTURE = new ToggleableGlobalSettingsFlag(
|
||||
"ENABLE_ASSISTANT_GESTURE", false,
|
||||
"Enable swipe up from the bottom right corner to start assistant");
|
||||
|
||||
public static void initialize(Context context) {
|
||||
// Avoid the disk read for user builds
|
||||
if (Utilities.IS_DEBUG_DEVICE) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.os.CancellationSignal;
|
|||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherStateManager.StateHandler;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
@ -33,7 +34,9 @@ public class UiFactory {
|
|||
launcher.getDragController(), new AllAppsSwipeController(launcher)};
|
||||
}
|
||||
|
||||
public static void setOnTouchControllersChangedListener(Context context, Runnable listener) { }
|
||||
public static Runnable enableLiveTouchControllerChanges(DragLayer dl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static StateHandler[] getStateHandler(Launcher launcher) {
|
||||
return new StateHandler[] {
|
||||
|
|
|
@ -30,7 +30,6 @@ else
|
|||
LOCAL_STATIC_JAVA_LIBRARIES += libSharedSystemUI
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \
|
||||
../quickstep/src/com/android/quickstep/SwipeUpSetting.java \
|
||||
../src/com/android/launcher3/util/SecureSettingsObserver.java \
|
||||
../src/com/android/launcher3/TestProtocol.java
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue