Setting correct height for search bar widget options bundle.
- Seperate search bar height from its top and bottom paddings
- Report this height plus 8dps top and bottom for the widget options
- Use a separate bottom padding to adjust spacing between QSB and
the workspace
- Add tests to verify the height of the search bar in both normal and
tall modes (ran on Nexus 6, 7, and 10)
Change-Id: Ia7557785d1b38194eee869d0460456e8f33447d5
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d258141..9824e3e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -52,6 +52,7 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
@@ -3629,17 +3630,17 @@
DeviceProfile portraitProfile = app.getInvariantDeviceProfile().portraitProfile;
DeviceProfile landscapeProfile = app.getInvariantDeviceProfile().landscapeProfile;
float density = getResources().getDisplayMetrics().density;
- Rect searchBounds = portraitProfile.getSearchBarBounds(Utilities.isRtl(getResources()));
- int maxHeight = (int) (searchBounds.height() / density);
+ Point searchDimens = portraitProfile.getSearchBarDimensForWidgetOpts(getResources());
+ int maxHeight = (int) (searchDimens.y / density);
int minHeight = maxHeight;
- int maxWidth = (int) (searchBounds.width() / density);
+ int maxWidth = (int) (searchDimens.x / density);
int minWidth = maxWidth;
if (!landscapeProfile.isVerticalBarLayout()) {
- searchBounds = landscapeProfile.getSearchBarBounds(Utilities.isRtl(getResources()));
- maxHeight = (int) Math.max(maxHeight, searchBounds.height() / density);
- minHeight = (int) Math.min(minHeight, searchBounds.height() / density);
- maxWidth = (int) Math.max(maxWidth, searchBounds.width() / density);
- minWidth = (int) Math.min(minWidth, searchBounds.width() / density);
+ searchDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(getResources());
+ maxHeight = (int) Math.max(maxHeight, searchDimens.y / density);
+ minHeight = (int) Math.min(minHeight, searchDimens.y / density);
+ maxWidth = (int) Math.max(maxWidth, searchDimens.x / density);
+ minWidth = (int) Math.min(minWidth, searchDimens.x / density);
}
opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight);
opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight);