summaryrefslogtreecommitdiff
path: root/quickstep/src
diff options
context:
space:
mode:
authorBrian Isganitis <brianji@google.com>2022-05-27 17:25:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-05-27 17:25:16 +0000
commitdeaf8985f61c378c7c7d19d8a4835353d9fa9e76 (patch)
tree61fabfe135e5654c635e995a7646126c9fe8e46f /quickstep/src
parente8a4e0e2dce6fec12ec0e2e841bb50f641f71d2d (diff)
parentafd72f07264756332a820a4af98ceac2b97d09da (diff)
downloadLauncher3-deaf8985f61c378c7c7d19d8a4835353d9fa9e76.tar.gz
Merge "Have separate DeviceProfile instances for taskbar and all apps windows." into tm-dev
Diffstat (limited to 'quickstep/src')
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java11
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java2
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java14
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java6
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java18
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java28
6 files changed, 38 insertions, 41 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
index 4e1f54c9a2..b4052e3d71 100644
--- a/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/BaseTaskbarContext.java
@@ -19,7 +19,6 @@ import android.content.Context;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DeviceProfile.DeviceProfileListenable;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.util.Themes;
@@ -36,8 +35,6 @@ public abstract class BaseTaskbarContext extends ContextThemeWrapper implements
protected final LayoutInflater mLayoutInflater;
private final List<OnDeviceProfileChangeListener> mDPChangeListeners = new ArrayList<>();
- protected DeviceProfile mDeviceProfile;
-
public BaseTaskbarContext(Context windowContext) {
super(windowContext, Themes.getActivityThemeRes(windowContext));
mLayoutInflater = LayoutInflater.from(this).cloneInContext(this);
@@ -49,18 +46,10 @@ public abstract class BaseTaskbarContext extends ContextThemeWrapper implements
}
@Override
- public final DeviceProfile getDeviceProfile() {
- return mDeviceProfile;
- }
-
- @Override
public final List<OnDeviceProfileChangeListener> getOnDeviceProfileChangeListeners() {
return mDPChangeListeners;
}
- /** Updates the {@link DeviceProfile} instance to the latest representation of the screen. */
- public abstract void updateDeviceProfile(DeviceProfile dp);
-
/** Callback invoked when a drag is initiated within this context. */
public abstract void onDragStart();
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index cbdbdb91e0..5d576f7bf5 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -522,7 +522,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
if (button.getVisibility() == View.VISIBLE) {
parent.getDescendantRectRelativeToSelf(button, mTempRect);
if (mHitboxExtender.extendedHitboxEnabled()) {
- mTempRect.bottom += mContext.mDeviceProfile.getTaskbarOffsetY();
+ mTempRect.bottom += mContext.getDeviceProfile().getTaskbarOffsetY();
}
outRegion.op(mTempRect, Op.UNION);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index ed1001cead..95da118948 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -111,6 +111,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
private final WindowManager mWindowManager;
private final @Nullable RoundedCorner mLeftCorner, mRightCorner;
+ private DeviceProfile mDeviceProfile;
private WindowManager.LayoutParams mWindowLayoutParams;
private boolean mIsFullscreen;
// The size we should return to when we call setTaskbarWindowFullscreen(false)
@@ -135,7 +136,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
unfoldTransitionProgressProvider) {
super(windowContext);
- mDeviceProfile = dp;
+ mDeviceProfile = dp.copy(this);
final Resources resources = getResources();
@@ -198,7 +199,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
new TaskbarAutohideSuspendController(this),
new TaskbarPopupController(this),
new TaskbarForceVisibleImmersiveController(this),
- new TaskbarAllAppsController(this),
+ new TaskbarAllAppsController(this, dp),
new TaskbarInsetsController(this));
}
@@ -214,8 +215,14 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
@Override
+ public DeviceProfile getDeviceProfile() {
+ return mDeviceProfile;
+ }
+
+ /** Updates {@link DeviceProfile} instances for any Taskbar windows. */
public void updateDeviceProfile(DeviceProfile dp) {
- mDeviceProfile = dp;
+ mControllers.taskbarAllAppsController.updateDeviceProfile(dp);
+ mDeviceProfile = dp.copy(this);
updateIconSize(getResources());
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
@@ -230,7 +237,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mDeviceProfile.updateIconSize(1, resources);
float iconScale = taskbarIconSize / mDeviceProfile.iconSizePx;
mDeviceProfile.updateIconSize(iconScale, resources);
- mDeviceProfile.updateAllAppsIconSize(1, resources); // Leave all apps unscaled.
}
@VisibleForTesting
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index ef7bab9832..06262c0a25 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -148,7 +148,7 @@ public class TaskbarManager {
// Config change might be handled without re-creating the taskbar
if (mTaskbarActivityContext != null) {
if (dp != null && dp.isTaskbarPresent) {
- mTaskbarActivityContext.updateDeviceProfile(dp.copy(mContext));
+ mTaskbarActivityContext.updateDeviceProfile(dp);
}
mTaskbarActivityContext.onConfigurationChanged(configDiff);
}
@@ -274,8 +274,8 @@ public class TaskbarManager {
return;
}
- mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp.copy(mContext),
- mNavButtonController, mUnfoldProgressProvider);
+ mTaskbarActivityContext = new TaskbarActivityContext(mContext, dp, mNavButtonController,
+ mUnfoldProgressProvider);
mTaskbarActivityContext.init(mSharedState);
if (mActivity != null) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
index 1cdbdb228b..e2f752212e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java
@@ -19,7 +19,6 @@ import static android.view.KeyEvent.ACTION_UP;
import static android.view.KeyEvent.KEYCODE_BACK;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
-import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION;
import android.content.Context;
@@ -78,14 +77,13 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
TaskbarStashController taskbarStashController) {
super(taskbarContext.createWindowContext(TYPE_APPLICATION_OVERLAY, null));
mTaskbarContext = taskbarContext;
- mDeviceProfile = taskbarContext.getDeviceProfile();
+ mWindowController = windowController;
mDragController = new TaskbarDragController(this);
mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this));
mDragLayer = new TaskbarAllAppsDragLayer(this);
TaskbarAllAppsSlideInView slideInView = (TaskbarAllAppsSlideInView) mLayoutInflater.inflate(
R.layout.taskbar_all_apps, mDragLayer, false);
- mWindowController = windowController;
mAllAppsViewController = new TaskbarAllAppsViewController(
this,
slideInView,
@@ -102,6 +100,11 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
}
@Override
+ public DeviceProfile getDeviceProfile() {
+ return mWindowController.getDeviceProfile();
+ }
+
+ @Override
public TaskbarDragController getDragController() {
return mDragController;
}
@@ -142,15 +145,6 @@ class TaskbarAllAppsContext extends BaseTaskbarContext {
}
@Override
- public void updateDeviceProfile(DeviceProfile dp) {
- mDeviceProfile = dp;
-
- AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
-
- dispatchDeviceProfileChanged();
- }
-
- @Override
public void onDragStart() {}
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
index eaf93843ac..6fd98db19a 100644
--- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java
@@ -19,6 +19,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static com.android.launcher3.AbstractFloatingView.TYPE_ALL;
+import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE;
import android.content.Context;
import android.graphics.PixelFormat;
@@ -31,7 +32,6 @@ import androidx.annotation.Nullable;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
-import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
import com.android.launcher3.appprediction.PredictionRowView;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
@@ -55,7 +55,7 @@ import java.util.Optional;
* Application data may be bound while the window does not exist, so this controller will store
* the models for the next all apps session.
*/
-public final class TaskbarAllAppsController implements OnDeviceProfileChangeListener {
+public final class TaskbarAllAppsController {
private static final String WINDOW_TITLE = "Taskbar All Apps";
@@ -70,6 +70,7 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
}
};
+ private DeviceProfile mDeviceProfile;
private TaskbarControllers mControllers;
/** Window context for all apps if it is open. */
private @Nullable TaskbarAllAppsContext mAllAppsContext;
@@ -79,7 +80,8 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
private int mAppsModelFlags;
private List<ItemInfo> mPredictedApps;
- public TaskbarAllAppsController(TaskbarActivityContext context) {
+ public TaskbarAllAppsController(TaskbarActivityContext context, DeviceProfile dp) {
+ mDeviceProfile = dp;
mTaskbarContext = context;
mProxyView = new TaskbarAllAppsProxyView(mTaskbarContext);
mLayoutParams = createLayoutParams();
@@ -146,7 +148,6 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
this,
mControllers.taskbarStashController);
mAllAppsContext.getDragController().init(mControllers);
- mTaskbarContext.addOnDeviceProfileChangeListener(this);
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
Optional.ofNullable(mAllAppsContext.getSystemService(WindowManager.class))
.ifPresent(m -> m.addView(mAllAppsContext.getDragLayer(), mLayoutParams));
@@ -184,13 +185,25 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
/** Destroys the controller and any All Apps window if present. */
public void onDestroy() {
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
- mTaskbarContext.removeOnDeviceProfileChangeListener(this);
Optional.ofNullable(mAllAppsContext)
.map(c -> c.getSystemService(WindowManager.class))
.ifPresent(m -> m.removeView(mAllAppsContext.getDragLayer()));
mAllAppsContext = null;
}
+ /** Updates {@link DeviceProfile} instance for Taskbar's All Apps window. */
+ public void updateDeviceProfile(DeviceProfile dp) {
+ mDeviceProfile = dp;
+ Optional.ofNullable(mAllAppsContext).ifPresent(c -> {
+ AbstractFloatingView.closeAllOpenViewsExcept(c, false, TYPE_REBIND_SAFE);
+ c.dispatchDeviceProfileChanged();
+ });
+ }
+
+ DeviceProfile getDeviceProfile() {
+ return mDeviceProfile;
+ }
+
private LayoutParams createLayoutParams() {
LayoutParams layoutParams = new LayoutParams(
TYPE_APPLICATION_OVERLAY,
@@ -205,11 +218,6 @@ public final class TaskbarAllAppsController implements OnDeviceProfileChangeList
return layoutParams;
}
- @Override
- public void onDeviceProfileChanged(DeviceProfile dp) {
- Optional.ofNullable(mAllAppsContext).ifPresent(c -> c.updateDeviceProfile(dp));
- }
-
/**
* Proxy view connecting taskbar drag layer to the all apps window.
* <p>