abstracting fallback views to support container instead of activity
Test: Built and tested locally Flag: NONE just abstracting in this cl Bug:292269949 Change-Id: I0ce5efb4f193211216430f373605107c87de2c1a
This commit is contained in:
1 parent
f0123c9129
commit
f29dc7c5ec
28 files changed
+515
-194
No files matched your search
@@ -11,6 +11,7 @@ import android.view.WindowInsets;
|
||||
|
||||
import com.android.launcher3.graphics.SysUiScrim;
|
||||
import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.statemanager.StatefulContainer;
|
||||
import com.android.launcher3.util.window.WindowManagerProxy;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -20,7 +21,7 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
|
||||
private final Rect mTempRect = new Rect();
|
||||
|
||||
private final StatefulActivity mActivity;
|
||||
private final StatefulContainer mStatefulContainer;
|
||||
|
||||
@ViewDebug.ExportedProperty(category = "launcher")
|
||||
private static final List<Rect> SYSTEM_GESTURE_EXCLUSION_RECT =
|
||||
@@ -36,24 +37,25 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
|
||||
public LauncherRootView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mActivity = StatefulActivity.fromContext(context);
|
||||
mStatefulContainer = StatefulContainer.fromContext(context);
|
||||
mSysUiScrim = new SysUiScrim(this);
|
||||
}
|
||||
|
||||
private void handleSystemWindowInsets(Rect insets) {
|
||||
// Update device profile before notifying the children.
|
||||
mActivity.getDeviceProfile().updateInsets(insets);
|
||||
mStatefulContainer.getDeviceProfile().updateInsets(insets);
|
||||
boolean resetState = !insets.equals(mInsets);
|
||||
setInsets(insets);
|
||||
|
||||
if (resetState) {
|
||||
mActivity.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
|
||||
mStatefulContainer.getStateManager().reapplyState(true /* cancelCurrentAnimation */);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
||||
mActivity.handleConfigurationChanged(mActivity.getResources().getConfiguration());
|
||||
mStatefulContainer.handleConfigurationChanged(
|
||||
mStatefulContainer.getContext().getResources().getConfiguration());
|
||||
|
||||
insets = WindowManagerProxy.INSTANCE.get(getContext())
|
||||
.normalizeWindowInsets(getContext(), insets, mTempRect);
|
||||
@@ -72,7 +74,7 @@ public class LauncherRootView extends InsettableFrameLayout {
|
||||
}
|
||||
|
||||
public void dispatchInsets() {
|
||||
mActivity.getDeviceProfile().updateInsets(mInsets);
|
||||
mStatefulContainer.getDeviceProfile().updateInsets(mInsets);
|
||||
super.setInsets(mInsets);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class DragLayer extends BaseDragLayer<Launcher> implements LauncherOverla
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
mControllers = mActivity.createTouchControllers();
|
||||
mControllers = mContainer.createTouchControllers();
|
||||
}
|
||||
|
||||
public ViewGroupFocusHelper getFocusIndicatorHelper() {
|
||||
@@ -134,15 +134,15 @@ public class DragLayer extends BaseDragLayer<Launcher> implements LauncherOverla
|
||||
}
|
||||
|
||||
private boolean isEventOverAccessibleDropTargetBar(MotionEvent ev) {
|
||||
return isInAccessibleDrag() && isEventOverView(mActivity.getDropTargetBar(), ev);
|
||||
return isInAccessibleDrag() && isEventOverView(mContainer.getDropTargetBar(), ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptHoverEvent(MotionEvent ev) {
|
||||
if (mActivity == null || mActivity.getWorkspace() == null) {
|
||||
if (mContainer == null || mContainer.getWorkspace() == null) {
|
||||
return false;
|
||||
}
|
||||
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity);
|
||||
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mContainer);
|
||||
if (!(topView instanceof Folder)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -197,7 +197,7 @@ public class DragLayer extends BaseDragLayer<Launcher> implements LauncherOverla
|
||||
|
||||
|
||||
private boolean isInAccessibleDrag() {
|
||||
return mActivity.getAccessibilityDelegate().isInAccessibleDrag();
|
||||
return mContainer.getAccessibilityDelegate().isInAccessibleDrag();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,12 +210,12 @@ public class DragLayer extends BaseDragLayer<Launcher> implements LauncherOverla
|
||||
|
||||
@Override
|
||||
public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) {
|
||||
View topView = AbstractFloatingView.getTopOpenViewWithType(mActivity,
|
||||
View topView = AbstractFloatingView.getTopOpenViewWithType(mContainer,
|
||||
AbstractFloatingView.TYPE_ACCESSIBLE);
|
||||
if (topView != null) {
|
||||
addAccessibleChildToList(topView, childrenForAccessibility);
|
||||
if (isInAccessibleDrag()) {
|
||||
addAccessibleChildToList(mActivity.getDropTargetBar(), childrenForAccessibility);
|
||||
addAccessibleChildToList(mContainer.getDropTargetBar(), childrenForAccessibility);
|
||||
}
|
||||
} else {
|
||||
super.addChildrenForAccessibility(childrenForAccessibility);
|
||||
@@ -420,14 +420,14 @@ public class DragLayer extends BaseDragLayer<Launcher> implements LauncherOverla
|
||||
public void onViewAdded(View child) {
|
||||
super.onViewAdded(child);
|
||||
updateChildIndices();
|
||||
mActivity.onDragLayerHierarchyChanged();
|
||||
mContainer.onDragLayerHierarchyChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View child) {
|
||||
super.onViewRemoved(child);
|
||||
updateChildIndices();
|
||||
mActivity.onDragLayerHierarchyChanged();
|
||||
mContainer.onDragLayerHierarchyChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,10 +32,10 @@ import android.view.View;
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.AnimatedFloat;
|
||||
import com.android.launcher3.statemanager.StatefulContainer;
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.util.ScreenOnTracker;
|
||||
import com.android.launcher3.util.ScreenOnTracker.ScreenOnListener;
|
||||
@@ -84,7 +84,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
|
||||
private final int mBottomMaskHeight;
|
||||
|
||||
private final View mRoot;
|
||||
private final BaseDraggingActivity mActivity;
|
||||
private final StatefulContainer mContainer;
|
||||
private final boolean mHideSysUiScrim;
|
||||
private boolean mSkipScrimAnimationForTest = false;
|
||||
|
||||
@@ -94,8 +94,8 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
|
||||
|
||||
public SysUiScrim(View view) {
|
||||
mRoot = view;
|
||||
mActivity = BaseDraggingActivity.fromContext(view.getContext());
|
||||
DisplayMetrics dm = mActivity.getResources().getDisplayMetrics();
|
||||
mContainer = StatefulContainer.fromContext(view.getContext());
|
||||
DisplayMetrics dm = mContainer.getContext().getResources().getDisplayMetrics();
|
||||
|
||||
mTopMaskHeight = ResourceUtils.pxFromDp(TOP_MASK_HEIGHT_DP, dm);
|
||||
mBottomMaskHeight = ResourceUtils.pxFromDp(BOTTOM_MASK_HEIGHT_DP, dm);
|
||||
@@ -130,7 +130,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
|
||||
|
||||
ObjectAnimator oa = mSysUiAnimMultiplier.animateToValue(1);
|
||||
oa.setDuration(600);
|
||||
oa.setStartDelay(mActivity.getWindow().getTransitionBackgroundFadeDuration());
|
||||
oa.setStartDelay(mContainer.getWindow().getTransitionBackgroundFadeDuration());
|
||||
oa.start();
|
||||
mAnimateScrimOnNextDraw = false;
|
||||
}
|
||||
@@ -166,19 +166,19 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
|
||||
* horizontal
|
||||
*/
|
||||
public void onInsetsChanged(Rect insets) {
|
||||
DeviceProfile dp = mActivity.getDeviceProfile();
|
||||
DeviceProfile dp = mContainer.getDeviceProfile();
|
||||
mDrawTopScrim = insets.top > 0;
|
||||
mDrawBottomScrim = !dp.isVerticalBarLayout() && !dp.isGestureMode && !dp.isTaskbarPresent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAttachedToWindow(View view) {
|
||||
ScreenOnTracker.INSTANCE.get(mActivity).addListener(mScreenOnListener);
|
||||
ScreenOnTracker.INSTANCE.get(mContainer.getContext()).addListener(mScreenOnListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(View view) {
|
||||
ScreenOnTracker.INSTANCE.get(mActivity).removeListener(mScreenOnListener);
|
||||
ScreenOnTracker.INSTANCE.get(mContainer.getContext()).removeListener(mScreenOnListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +213,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener {
|
||||
}
|
||||
|
||||
private Bitmap createDitheredAlphaMask(int height, @ColorInt int[] colors, float[] positions) {
|
||||
DisplayMetrics dm = mActivity.getResources().getDisplayMetrics();
|
||||
DisplayMetrics dm = mContainer.getContext().getResources().getDisplayMetrics();
|
||||
int width = ResourceUtils.pxFromDp(ALPHA_MASK_BITMAP_WIDTH_DP, dm);
|
||||
Bitmap dst = Bitmap.createBitmap(width, height, Bitmap.Config.ALPHA_8);
|
||||
Canvas c = new Canvas(dst);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
mControllers = new TouchController[]{new CloseAllAppsTouchController(),
|
||||
mActivity.getDragController()};
|
||||
mContainer.getDragController()};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,10 +79,10 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
mAppsView = findViewById(R.id.apps_view);
|
||||
// Setup workspace
|
||||
mWorkspace = findViewById(R.id.workspace_grid);
|
||||
mPinnedAppsAdapter = new PinnedAppsAdapter(mActivity, mAppsView.getAppsStore(),
|
||||
mPinnedAppsAdapter = new PinnedAppsAdapter(mContainer, mAppsView.getAppsStore(),
|
||||
this::onIconLongClicked);
|
||||
mWorkspace.setAdapter(mPinnedAppsAdapter);
|
||||
mWorkspace.setNumColumns(mActivity.getDeviceProfile().inv.numColumns);
|
||||
mWorkspace.setNumColumns(mContainer.getDeviceProfile().inv.numColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +112,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||
setMeasuredDimension(width, height);
|
||||
|
||||
DeviceProfile grid = mActivity.getDeviceProfile();
|
||||
DeviceProfile grid = mContainer.getDeviceProfile();
|
||||
int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
@@ -153,17 +153,17 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
|
||||
@Override
|
||||
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
|
||||
if (!mActivity.isAppDrawerShown()) {
|
||||
if (!mContainer.isAppDrawerShown()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AbstractFloatingView.getTopOpenView(mActivity) != null) {
|
||||
if (AbstractFloatingView.getTopOpenView(mContainer) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN
|
||||
&& !isEventOverView(mActivity.getAppsView(), ev)) {
|
||||
mActivity.showAppDrawer(false);
|
||||
&& !isEventOverView(mContainer.getAppsView(), ev)) {
|
||||
mContainer.showAppDrawer(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -178,7 +178,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
if (!(v instanceof BubbleTextView)) {
|
||||
return false;
|
||||
}
|
||||
if (PopupContainerWithArrow.getOpen(mActivity) != null) {
|
||||
if (PopupContainerWithArrow.getOpen(mContainer) != null) {
|
||||
// There is already an items container open, so don't open this one.
|
||||
v.clearFocus();
|
||||
return false;
|
||||
@@ -187,32 +187,32 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
if (!ShortcutUtil.supportsShortcuts(item)) {
|
||||
return false;
|
||||
}
|
||||
PopupDataProvider popupDataProvider = mActivity.getPopupDataProvider();
|
||||
PopupDataProvider popupDataProvider = mContainer.getPopupDataProvider();
|
||||
if (popupDataProvider == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// order of this list will reflect in the popup
|
||||
List<SystemShortcut> systemShortcuts = new ArrayList<>();
|
||||
systemShortcuts.add(APP_INFO.getShortcut(mActivity, item, v));
|
||||
systemShortcuts.add(APP_INFO.getShortcut(mContainer, item, v));
|
||||
// Hide redundant pin shortcut for app drawer icons if drag-n-drop is enabled.
|
||||
if (!FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN.get() || !mActivity.isAppDrawerShown()) {
|
||||
if (!FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN.get() || !mContainer.isAppDrawerShown()) {
|
||||
systemShortcuts.add(mPinnedAppsAdapter.getSystemShortcut(item, v));
|
||||
}
|
||||
int deepShortcutCount = popupDataProvider.getShortcutCountForItem(item);
|
||||
final PopupContainerWithArrow<SecondaryDisplayLauncher> container;
|
||||
container = (PopupContainerWithArrow) mActivity.getLayoutInflater().inflate(
|
||||
R.layout.popup_container, mActivity.getDragLayer(), false);
|
||||
container = (PopupContainerWithArrow) mContainer.getLayoutInflater().inflate(
|
||||
R.layout.popup_container, mContainer.getDragLayer(), false);
|
||||
container.populateAndShowRows((BubbleTextView) v, deepShortcutCount,
|
||||
systemShortcuts);
|
||||
container.requestFocus();
|
||||
|
||||
if (!FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN.get() || !mActivity.isAppDrawerShown()) {
|
||||
if (!FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN.get() || !mContainer.isAppDrawerShown()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
DragOptions options = new DragOptions();
|
||||
DeviceProfile grid = mActivity.getDeviceProfile();
|
||||
DeviceProfile grid = mContainer.getDeviceProfile();
|
||||
options.intrinsicIconScaleFactor = (float) grid.allAppsIconSizePx / grid.iconSizePx;
|
||||
options.preDragCondition = container.createPreDragCondition(false);
|
||||
if (options.preDragCondition == null) {
|
||||
@@ -229,7 +229,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
mDragView = dragObject.dragView;
|
||||
if (!shouldStartDrag(0)) {
|
||||
mDragView.setOnScaleAnimEndCallback(() ->
|
||||
mActivity.beginDragShared(v, mActivity.getAppsView(), options));
|
||||
mContainer.beginDragShared(v, mContainer.getAppsView(), options));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
}
|
||||
};
|
||||
}
|
||||
mActivity.beginDragShared(v, mActivity.getAppsView(), options);
|
||||
mContainer.beginDragShared(v, mContainer.getAppsView(), options);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
|
||||
|
||||
import static com.android.launcher3.LauncherState.FLAG_NON_INTERACTIVE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -195,15 +196,15 @@ public abstract class StatefulActivity<STATE_TYPE extends BaseState<STATE_TYPE>>
|
||||
mOldRotation = rotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logic for when device configuration changes (rotation, screen size change, multi-window,
|
||||
* etc.)
|
||||
*/
|
||||
protected abstract void onHandleConfigurationChanged();
|
||||
|
||||
/**
|
||||
* Enter staged split directly from the current running app.
|
||||
* @param leftOrTop if the staged split will be positioned left or top.
|
||||
*/
|
||||
public void enterStageSplitFromRunningApp(boolean leftOrTop) { }
|
||||
}
|
||||
@@ -20,6 +20,12 @@ package com.android.launcher3.statemanager;
|
||||
import static com.android.launcher3.LauncherState.FLAG_CLOSE_POPUPS;
|
||||
import static com.android.launcher3.statemanager.BaseState.FLAG_NON_INTERACTIVE;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.res.Configuration;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.CallSuper;
|
||||
|
||||
import com.android.launcher3.AbstractFloatingView;
|
||||
@@ -35,6 +41,23 @@ import java.util.List;
|
||||
public interface StatefulContainer<STATE_TYPE extends BaseState<STATE_TYPE>> extends
|
||||
ActivityContext {
|
||||
|
||||
/**
|
||||
* Returns an instance of an implementation of StatefulContainer
|
||||
*
|
||||
* @param context will find instance of StatefulContainer from given context.
|
||||
*/
|
||||
static <T extends StatefulContainer> T fromContext(Context context) {
|
||||
if (context instanceof StatefulContainer) {
|
||||
return (T) context;
|
||||
} else if (context instanceof ContextWrapper) {
|
||||
return fromContext(((ContextWrapper) context).getBaseContext());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Cannot find StatefulContainer in parent tree");
|
||||
}
|
||||
}
|
||||
|
||||
Context getContext();
|
||||
|
||||
/**
|
||||
* Creates a factory for atomic state animations
|
||||
*/
|
||||
@@ -54,12 +77,15 @@ public interface StatefulContainer<STATE_TYPE extends BaseState<STATE_TYPE>> ext
|
||||
|
||||
/**
|
||||
* Called when transition to state ends
|
||||
*
|
||||
* @param state current state of State_Type
|
||||
*/
|
||||
default void onStateSetEnd(STATE_TYPE state) { }
|
||||
default void onStateSetEnd(STATE_TYPE state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when transition to state starts
|
||||
*
|
||||
* @param state current state of State_Type
|
||||
*/
|
||||
@CallSuper
|
||||
@@ -71,6 +97,7 @@ public interface StatefulContainer<STATE_TYPE extends BaseState<STATE_TYPE>> ext
|
||||
|
||||
/**
|
||||
* Returns true if the activity is in the provided state
|
||||
*
|
||||
* @param state current state of State_Type
|
||||
*/
|
||||
default boolean isInState(STATE_TYPE state) {
|
||||
@@ -81,4 +108,8 @@ public interface StatefulContainer<STATE_TYPE extends BaseState<STATE_TYPE>> ext
|
||||
* Returns true if state change should transition with animation
|
||||
*/
|
||||
boolean shouldAnimateStateChange();
|
||||
|
||||
default void handleConfigurationChanged(Configuration configuration){
|
||||
//no op
|
||||
}
|
||||
}
|
||||
@@ -168,21 +168,14 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_TARGET_INSETS: {
|
||||
return getUIProperty(Bundle::putParcelable, activity -> {
|
||||
WindowInsets insets = activity.getWindow()
|
||||
.getDecorView().getRootWindowInsets();
|
||||
return Insets.max(
|
||||
insets.getSystemGestureInsets(),
|
||||
insets.getSystemWindowInsets());
|
||||
}, this::getCurrentActivity);
|
||||
return getUIProperty(Bundle::putParcelable, insets -> Insets.max(
|
||||
insets.getSystemGestureInsets(),
|
||||
insets.getSystemWindowInsets()), this::getWindowInsets);
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_WINDOW_INSETS: {
|
||||
return getUIProperty(Bundle::putParcelable, activity -> {
|
||||
WindowInsets insets = activity.getWindow()
|
||||
.getDecorView().getRootWindowInsets();
|
||||
return insets.getSystemWindowInsets();
|
||||
}, this::getCurrentActivity);
|
||||
return getUIProperty(Bundle::putParcelable,
|
||||
WindowInsets::getSystemWindowInsets, this::getWindowInsets);
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_CELL_LAYOUT_BOARDER_HEIGHT: {
|
||||
@@ -192,13 +185,13 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_SYSTEM_GESTURE_REGION: {
|
||||
return getUIProperty(Bundle::putParcelable, activity -> {
|
||||
WindowInsetsCompat insets = WindowInsetsCompat.toWindowInsetsCompat(
|
||||
activity.getWindow().getDecorView().getRootWindowInsets());
|
||||
return getUIProperty(Bundle::putParcelable, windowInsets -> {
|
||||
WindowInsetsCompat insets =
|
||||
WindowInsetsCompat.toWindowInsetsCompat(windowInsets);
|
||||
return insets.getInsets(WindowInsetsCompat.Type.ime()
|
||||
| WindowInsetsCompat.Type.systemGestures())
|
||||
.toPlatformInsets();
|
||||
}, this::getCurrentActivity);
|
||||
}, this::getWindowInsets);
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_ICON_HEIGHT: {
|
||||
@@ -486,8 +479,9 @@ public class TestInformationHandler implements ResourceBasedOverride {
|
||||
|| LauncherAppState.getInstance(mContext).getModel().isModelLoaded();
|
||||
}
|
||||
|
||||
protected Activity getCurrentActivity() {
|
||||
return Launcher.ACTIVITY_TRACKER.getCreatedActivity();
|
||||
protected WindowInsets getWindowInsets(){
|
||||
return Launcher.ACTIVITY_TRACKER.getCreatedActivity().getWindow().getDecorView()
|
||||
.getRootWindowInsets();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ActivityNotFoundException;
|
||||
@@ -46,6 +47,7 @@ import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.AccessibilityDelegate;
|
||||
import android.view.Window;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowInsetsController;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@@ -80,6 +82,7 @@ import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.Preconditions;
|
||||
import com.android.launcher3.util.RunnableList;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.launcher3.util.ViewCache;
|
||||
import com.android.launcher3.widget.picker.model.WidgetPickerDataProvider;
|
||||
|
||||
@@ -172,7 +175,16 @@ public interface ActivityContext {
|
||||
/**
|
||||
* The root view to support drag-and-drop and popup support.
|
||||
*/
|
||||
BaseDragLayer getDragLayer();
|
||||
BaseDragLayer<?> getDragLayer();
|
||||
|
||||
/**
|
||||
* @see Activity#getWindow()
|
||||
* @return Window
|
||||
*/
|
||||
@Nullable
|
||||
default Window getWindow() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The all apps container, if it exists in this context.
|
||||
@@ -216,6 +228,11 @@ public interface ActivityContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default SystemUiController getSystemUiController() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for actions taken on drop targets that require launcher
|
||||
*/
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
protected final RectF mSystemGestureRegion = new RectF();
|
||||
private int mTouchDispatchState = 0;
|
||||
|
||||
protected final T mActivity;
|
||||
protected final T mContainer;
|
||||
private final MultiValueAlpha mMultiValueAlpha;
|
||||
|
||||
// All the touch controllers for the view
|
||||
@@ -121,7 +121,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
|
||||
public BaseDragLayer(Context context, AttributeSet attrs, int alphaChannelCount) {
|
||||
super(context, attrs);
|
||||
mActivity = ActivityContext.lookupContext(context);
|
||||
mContainer = ActivityContext.lookupContext(context);
|
||||
mMultiValueAlpha = new MultiValueAlpha(this, alphaChannelCount);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
}
|
||||
mTouchCompleteListener = null;
|
||||
} else if (action == MotionEvent.ACTION_DOWN) {
|
||||
mActivity.finishAutoCancelActionMode();
|
||||
mContainer.finishAutoCancelActionMode();
|
||||
}
|
||||
return findActiveController(ev);
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
private TouchController findControllerToHandleTouch(MotionEvent ev) {
|
||||
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity);
|
||||
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mContainer);
|
||||
if (topView != null
|
||||
&& (isEventWithinSystemGestureRegion(ev)
|
||||
|| topView.canInterceptEventsInSystemGestureRegion())
|
||||
@@ -207,7 +207,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
@Override
|
||||
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
|
||||
// Shortcuts can appear above folder
|
||||
View topView = AbstractFloatingView.getTopOpenViewWithType(mActivity,
|
||||
View topView = AbstractFloatingView.getTopOpenViewWithType(mContainer,
|
||||
AbstractFloatingView.TYPE_ACCESSIBLE);
|
||||
if (topView != null) {
|
||||
if (child == topView) {
|
||||
@@ -222,7 +222,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
|
||||
@Override
|
||||
public void addChildrenForAccessibility(ArrayList<View> childrenForAccessibility) {
|
||||
View topView = AbstractFloatingView.getTopOpenViewWithType(mActivity,
|
||||
View topView = AbstractFloatingView.getTopOpenViewWithType(mContainer,
|
||||
AbstractFloatingView.TYPE_ACCESSIBLE);
|
||||
if (topView != null) {
|
||||
// Only add the top view as a child for accessibility when it is open
|
||||
@@ -458,7 +458,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
|
||||
@Override
|
||||
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
|
||||
View topView = AbstractFloatingView.getTopOpenView(mActivity);
|
||||
View topView = AbstractFloatingView.getTopOpenView(mContainer);
|
||||
if (topView != null) {
|
||||
return topView.requestFocus(direction, previouslyFocusedRect);
|
||||
} else {
|
||||
@@ -468,7 +468,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
|
||||
@Override
|
||||
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
|
||||
View topView = AbstractFloatingView.getTopOpenView(mActivity);
|
||||
View topView = AbstractFloatingView.getTopOpenView(mContainer);
|
||||
if (topView != null) {
|
||||
topView.addFocusables(views, direction);
|
||||
} else {
|
||||
@@ -555,7 +555,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
Insets gestureInsets = insets.getMandatorySystemGestureInsets();
|
||||
int gestureInsetBottom = gestureInsets.bottom;
|
||||
Insets imeInset = insets.getInsets(WindowInsets.Type.ime());
|
||||
DeviceProfile dp = mActivity.getDeviceProfile();
|
||||
DeviceProfile dp = mContainer.getDeviceProfile();
|
||||
if (dp.isTaskbarPresent) {
|
||||
// Ignore taskbar gesture insets to avoid interfering with TouchControllers.
|
||||
gestureInsetBottom = ResourceUtils.getNavbarSize(
|
||||
|
||||
@@ -29,7 +29,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Px;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.android.launcher3.BaseActivity;
|
||||
import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
|
||||
@@ -143,7 +142,8 @@ public class ScrimView extends View implements Insettable {
|
||||
|
||||
private SystemUiController getSystemUiController() {
|
||||
if (mSystemUiController == null) {
|
||||
mSystemUiController = BaseActivity.fromContext(getContext()).getSystemUiController();
|
||||
mSystemUiController =
|
||||
ActivityContext.lookupContext(getContext()).getSystemUiController();
|
||||
}
|
||||
return mSystemUiController;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user