Fix WidgetsBottomSheet inset bug after orientation change
Reset the inset upon orientation change
Test: Open bottom widgets picker. Rotate the screen from portrait
to landscape and then back to portrait. Observe the correct
inset is set.
Bug: 183601302
Change-Id: I88432a49b2601df843fe33911fd7acdde66d06c4
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index 155a285..f18b63e 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -20,6 +20,7 @@
import android.animation.PropertyValuesHolder;
import android.content.Context;
+import android.content.res.Configuration;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.IntProperty;
@@ -71,6 +72,7 @@
private Rect mInsets;
private final int mMaxTableHeight;
private int mMaxHorizontalSpan = 4;
+ private Configuration mCurrentConfiguration;
public WidgetsBottomSheet(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -85,6 +87,7 @@
// Set the max table height to 2 / 3 of the grid height so that the bottom picker won't
// take over the entire view vertically.
mMaxTableHeight = deviceProfile.inv.numRows * 2 / 3 * deviceProfile.cellHeightPx;
+ mCurrentConfiguration = new Configuration(getResources().getConfiguration());
}
@Override
@@ -212,6 +215,14 @@
}
@Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ if (mCurrentConfiguration.orientation != newConfig.orientation) {
+ mInsets.setEmpty();
+ }
+ mCurrentConfiguration.updateFrom(newConfig);
+ }
+
+ @Override
protected Pair<View, String> getAccessibilityTarget() {
return Pair.create(findViewById(R.id.title), getContext().getString(
mIsOpen ? R.string.widgets_list : R.string.widgets_list_closed));