mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
Simplifying taskbar recreation logic
Using the same config changes as used by the Launcher activity to avoid any inconsistencies Bug: 269409332 Test: Tentative fix, can't reproduce the original bug Flag: N/A Change-Id: I3d7503cf13e6b3112151f1db520486d87871584c
This commit is contained in:
@@ -49,7 +49,6 @@ import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Process;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.Trace;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
@@ -128,8 +127,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
|
||||
private static final String IME_DRAWS_IME_NAV_BAR_RES_NAME = "config_imeDrawsImeNavBar";
|
||||
|
||||
private static final boolean ENABLE_THREE_BUTTON_TASKBAR =
|
||||
SystemProperties.getBoolean("persist.debug.taskbar_three_button", false);
|
||||
private static final String TAG = "TaskbarActivityContext";
|
||||
|
||||
private static final String WINDOW_TITLE = "Taskbar";
|
||||
@@ -169,30 +166,27 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
|
||||
unfoldTransitionProgressProvider) {
|
||||
super(windowContext);
|
||||
|
||||
applyDeviceProfile(launcherDp);
|
||||
|
||||
final Resources resources = getResources();
|
||||
|
||||
matchDeviceProfile(launcherDp, getResources());
|
||||
|
||||
mNavMode = DisplayController.getNavigationMode(windowContext);
|
||||
mImeDrawsImeNavBar = getBoolByName(IME_DRAWS_IME_NAV_BAR_RES_NAME, resources, false);
|
||||
mIsSafeModeEnabled = TraceHelper.allowIpcs("isSafeMode",
|
||||
() -> getPackageManager().isSafeMode());
|
||||
|
||||
// TODO(b/244231596) For shared Taskbar window, update this value in applyDeviceProfile()
|
||||
// instead so to get correct value when recreating the taskbar
|
||||
SettingsCache settingsCache = SettingsCache.INSTANCE.get(this);
|
||||
mIsUserSetupComplete = settingsCache.getValue(
|
||||
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
|
||||
mIsNavBarForceVisible = settingsCache.getValue(
|
||||
Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);
|
||||
|
||||
// TODO(b/244231596) For shared Taskbar window, update this value in init() instead so
|
||||
// to get correct value when recreating the taskbar
|
||||
mIsNavBarKidsMode = settingsCache.getValue(
|
||||
Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);
|
||||
mIsNavBarForceVisible = mIsNavBarKidsMode;
|
||||
|
||||
// Get display and corners first, as views might use them in constructor.
|
||||
Display display = windowContext.getDisplay();
|
||||
Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
|
||||
? windowContext.getApplicationContext()
|
||||
: windowContext.getApplicationContext().createDisplayContext(display);
|
||||
Context c = getApplicationContext();
|
||||
mWindowManager = c.getSystemService(WindowManager.class);
|
||||
mLeftCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_LEFT);
|
||||
mRightCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT);
|
||||
@@ -267,6 +261,38 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
bubbleControllersOptional);
|
||||
}
|
||||
|
||||
/** Updates {@link DeviceProfile} instances for any Taskbar windows. */
|
||||
public void updateDeviceProfile(DeviceProfile launcherDp) {
|
||||
applyDeviceProfile(launcherDp);
|
||||
|
||||
mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
|
||||
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
|
||||
// Reapply fullscreen to take potential new screen size into account.
|
||||
setTaskbarWindowFullscreen(mIsFullscreen);
|
||||
|
||||
dispatchDeviceProfileChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the original DeviceProfile, match the number of hotseat icons and qsb width and update
|
||||
* the icon size
|
||||
*/
|
||||
private void applyDeviceProfile(DeviceProfile originDeviceProfile) {
|
||||
mDeviceProfile = originDeviceProfile.toBuilder(this)
|
||||
.withDimensionsOverride(deviceProfile -> {
|
||||
// Taskbar should match the number of icons of hotseat
|
||||
deviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
|
||||
// Same QSB width to have a smooth animation
|
||||
deviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
|
||||
|
||||
// Update icon size
|
||||
deviceProfile.iconSizePx = deviceProfile.taskbarIconSize;
|
||||
deviceProfile.updateIconSize(1f, getResources());
|
||||
}).build();
|
||||
mNavMode = DisplayController.getNavigationMode(this);
|
||||
}
|
||||
|
||||
|
||||
public void init(@NonNull TaskbarSharedState sharedState) {
|
||||
mLastRequestedNonFullscreenHeight = getDefaultTaskbarWindowHeight();
|
||||
mWindowLayoutParams =
|
||||
@@ -308,19 +334,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
return mDeviceProfile;
|
||||
}
|
||||
|
||||
/** Updates {@link DeviceProfile} instances for any Taskbar windows. */
|
||||
public void updateDeviceProfile(DeviceProfile launcherDp, NavigationMode navMode) {
|
||||
mNavMode = navMode;
|
||||
mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
|
||||
matchDeviceProfile(launcherDp, getResources());
|
||||
|
||||
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
|
||||
// Reapply fullscreen to take potential new screen size into account.
|
||||
setTaskbarWindowFullscreen(mIsFullscreen);
|
||||
|
||||
dispatchDeviceProfileChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchDeviceProfileChanged() {
|
||||
super.dispatchDeviceProfileChanged();
|
||||
@@ -328,24 +341,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
getDeviceProfile().toSmallString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the original DeviceProfile, match the number of hotseat icons and qsb width and update
|
||||
* the icon size
|
||||
*/
|
||||
private void matchDeviceProfile(DeviceProfile originDeviceProfile, Resources resources) {
|
||||
mDeviceProfile = originDeviceProfile.toBuilder(this)
|
||||
.withDimensionsOverride(deviceProfile -> {
|
||||
// Taskbar should match the number of icons of hotseat
|
||||
deviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
|
||||
// Same QSB width to have a smooth animation
|
||||
deviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
|
||||
|
||||
// Update icon size
|
||||
deviceProfile.iconSizePx = deviceProfile.taskbarIconSize;
|
||||
deviceProfile.updateIconSize(1f, resources);
|
||||
}).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the View bounds of transient taskbar.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user