Merge "Update notification dot renderer when we update the taskbar icon size." into tm-qpr-dev

This commit is contained in:
Jon Miranda
2023-02-03 01:34:05 +00:00
committed by Android (Google) Code Review
3 changed files with 33 additions and 18 deletions

View File

@@ -286,22 +286,20 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
* the icon size
*/
private void matchDeviceProfile(DeviceProfile originDeviceProfile, Resources resources) {
mDeviceProfile = originDeviceProfile.copy(this);
// Taskbar should match the number of icons of hotseat
mDeviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
// Same QSB width to have a smooth animation
mDeviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
// Update the size of the icons
updateIconSize(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;
private void updateIconSize(Resources resources) {
mDeviceProfile.iconSizePx = resources.getDimensionPixelSize(
DisplayController.isTransientTaskbar(this)
? R.dimen.transient_taskbar_icon_size
: R.dimen.taskbar_icon_size);
mDeviceProfile.updateIconSize(1f, resources);
// Update icon size
deviceProfile.iconSizePx = resources.getDimensionPixelSize(
DisplayController.isTransientTaskbar(TaskbarActivityContext.this)
? R.dimen.transient_taskbar_icon_size
: R.dimen.taskbar_icon_size);
deviceProfile.updateIconSize(1f, resources);
}).build();
}
/**

View File

@@ -57,6 +57,7 @@ import com.android.launcher3.util.WindowBounds;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.function.Consumer;
@SuppressLint("NewApi")
public class DeviceProfile {
@@ -67,6 +68,7 @@ public class DeviceProfile {
public static final PointF DEFAULT_SCALE = new PointF(1.0f, 1.0f);
public static final ViewScaleProvider DEFAULT_PROVIDER = itemInfo -> DEFAULT_SCALE;
public static final Consumer<DeviceProfile> DEFAULT_DIMENSION_PROVIDER = dp -> {};
// Ratio of empty space, qsb should take up to appear visually centered.
private final float mQsbCenterFactor;
@@ -271,7 +273,8 @@ public class DeviceProfile {
DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
SparseArray<DotRenderer> dotRendererCache, boolean isMultiWindowMode,
boolean transposeLayoutWithOrientation, boolean isMultiDisplay, boolean isGestureMode,
@NonNull final ViewScaleProvider viewScaleProvider) {
@NonNull final ViewScaleProvider viewScaleProvider,
@NonNull final Consumer<DeviceProfile> dimensionOverrideProvider) {
this.inv = inv;
this.isLandscape = windowBounds.isLandscape();
@@ -571,6 +574,8 @@ public class DeviceProfile {
mViewScaleProvider = viewScaleProvider;
dimensionOverrideProvider.accept(this);
// This is done last, after iconSizePx is calculated above.
mDotRendererWorkSpace = createDotRenderer(iconSizePx, dotRendererCache);
mDotRendererAllApps = createDotRenderer(allAppsIconSizePx, dotRendererCache);
@@ -1752,6 +1757,8 @@ public class DeviceProfile {
private SparseArray<DotRenderer> mDotRendererCache;
private Consumer<DeviceProfile> mOverrideProvider;
public Builder(Context context, InvariantDeviceProfile inv, Info info) {
mContext = context;
mInv = inv;
@@ -1788,6 +1795,11 @@ public class DeviceProfile {
return this;
}
public Builder withDimensionsOverride(Consumer<DeviceProfile> overrideProvider) {
mOverrideProvider = overrideProvider;
return this;
}
/**
* Set the viewScaleProvider for the builder
*
@@ -1817,9 +1829,12 @@ public class DeviceProfile {
if (mViewScaleProvider == null) {
mViewScaleProvider = DEFAULT_PROVIDER;
}
if (mOverrideProvider == null) {
mOverrideProvider = DEFAULT_DIMENSION_PROVIDER;
}
return new DeviceProfile(mContext, mInv, mInfo, mWindowBounds, mDotRendererCache,
mIsMultiWindowMode, mTransposeLayoutWithOrientation, mIsMultiDisplay,
mIsGestureMode, mViewScaleProvider);
mIsGestureMode, mViewScaleProvider, mOverrideProvider);
}
}

View File

@@ -20,6 +20,7 @@ import android.graphics.PointF
import android.graphics.Rect
import android.util.SparseArray
import androidx.test.core.app.ApplicationProvider
import com.android.launcher3.DeviceProfile.DEFAULT_DIMENSION_PROVIDER
import com.android.launcher3.DeviceProfile.DEFAULT_PROVIDER
import com.android.launcher3.util.DisplayController.Info
import com.android.launcher3.util.WindowBounds
@@ -60,7 +61,8 @@ abstract class DeviceProfileBaseTest {
transposeLayoutWithOrientation,
useTwoPanels,
isGestureMode,
DEFAULT_PROVIDER
DEFAULT_PROVIDER,
DEFAULT_DIMENSION_PROVIDER
)
protected fun initializeVarsForPhone(