diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index d4f66e2ee1..867ce1769d 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -449,11 +449,13 @@ 32dp 36dp + 28dp 24dp 12dp 16dp 6dp 8dp + @dimen/bubblebar_icon_spacing 12dp 1dp diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java index 24b91395f8..94e9e94f9f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarViewController.java @@ -31,6 +31,7 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.anim.AnimatedFloat; import com.android.launcher3.taskbar.TaskbarActivityContext; @@ -62,6 +63,7 @@ public class BubbleBarViewController { private final TaskbarActivityContext mActivity; private final BubbleBarView mBarView; private int mIconSize; + private int mBubbleBarPadding; // Initialized in init. private BubbleStashController mBubbleStashController; @@ -110,10 +112,9 @@ public class BubbleBarViewController { mTaskbarStashController = controllers.taskbarStashController; mTaskbarInsetsController = controllers.taskbarInsetsController; mBubbleBarViewAnimator = new BubbleBarViewAnimator(mBarView, mBubbleStashController); - + onBubbleBarConfigurationChanged(/* animate= */ false); mActivity.addOnDeviceProfileChangeListener( - dp -> updateBubbleBarIconSize(dp.taskbarIconSize, /* animate= */ true)); - updateBubbleBarIconSize(mActivity.getDeviceProfile().taskbarIconSize, /* animate= */ false); + dp -> onBubbleBarConfigurationChanged(/* animate= */ true)); mBubbleBarScale.updateValue(1f); mBubbleClickListener = v -> onBubbleClicked(v); mBubbleBarClickListener = v -> onBubbleBarClicked(); @@ -334,27 +335,60 @@ public class BubbleBarViewController { // Modifying view related properties. // - private void updateBubbleBarIconSize(int newIconSize, boolean animate) { + /** Notifies controller of configuration change, so bubble bar can be adjusted */ + public void onBubbleBarConfigurationChanged(boolean animate) { + int newIconSize; + int newPadding; Resources res = mActivity.getResources(); + if (mBubbleStashController.isBubblesShowingOnHome()) { + newIconSize = getBubbleBarIconSizeFromDeviceProfile(res); + newPadding = getBubbleBarPaddingFromDeviceProfile(res); + } else { + // the bubble bar is shown inside the persistent task bar, use preset sizes + newIconSize = res.getDimensionPixelSize(R.dimen.bubblebar_icon_size_persistent_taskbar); + newPadding = res.getDimensionPixelSize( + R.dimen.bubblebar_icon_spacing_persistent_taskbar); + } + updateBubbleBarIconSizeAndPadding(newIconSize, newPadding, animate); + } + + + private int getBubbleBarIconSizeFromDeviceProfile(Resources res) { + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); DisplayMetrics dm = res.getDisplayMetrics(); float smallIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, APP_ICON_SMALL_DP, dm); float mediumIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, APP_ICON_MEDIUM_DP, dm); - float largeIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, - APP_ICON_LARGE_DP, dm); float smallMediumThreshold = (smallIconSize + mediumIconSize) / 2f; - float mediumLargeThreshold = (mediumIconSize + largeIconSize) / 2f; - mIconSize = newIconSize <= smallMediumThreshold + int taskbarIconSize = deviceProfile.taskbarIconSize; + return taskbarIconSize <= smallMediumThreshold ? res.getDimensionPixelSize(R.dimen.bubblebar_icon_size_small) : res.getDimensionPixelSize(R.dimen.bubblebar_icon_size); - float bubbleBarPadding = newIconSize >= mediumLargeThreshold + + } + + private int getBubbleBarPaddingFromDeviceProfile(Resources res) { + DeviceProfile deviceProfile = mActivity.getDeviceProfile(); + DisplayMetrics dm = res.getDisplayMetrics(); + float mediumIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + APP_ICON_MEDIUM_DP, dm); + float largeIconSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, + APP_ICON_LARGE_DP, dm); + float mediumLargeThreshold = (mediumIconSize + largeIconSize) / 2f; + return deviceProfile.taskbarIconSize >= mediumLargeThreshold ? res.getDimensionPixelSize(R.dimen.bubblebar_icon_spacing_large) : res.getDimensionPixelSize(R.dimen.bubblebar_icon_spacing); + } + + private void updateBubbleBarIconSizeAndPadding(int iconSize, int padding, boolean animate) { + if (mIconSize == iconSize && mBubbleBarPadding == padding) return; + mIconSize = iconSize; + mBubbleBarPadding = padding; if (animate) { - mBarView.animateBubbleBarIconSize(mIconSize, bubbleBarPadding); + mBarView.animateBubbleBarIconSize(iconSize, padding); } else { - mBarView.setIconSizeAndPadding(mIconSize, bubbleBarPadding); + mBarView.setIconSizeAndPadding(iconSize, padding); } }