mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 01:16:49 +00:00
Have separate DeviceProfile instances for taskbar and all apps windows.
We want to scale down the DeviceProfile for taskbar, but the all apps
window should rely on the original DeviceProfile.
Test: Manual
Fix: 232907361
Change-Id: Ia09f674ada9e445c1d7278fa94c536ea9de13ef9
Merged-In: Ia09f674ada9e445c1d7278fa94c536ea9de13ef9
(cherry picked from commit a9a78117c7)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user