summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-02-01 14:15:20 -0800
committerTony Wickham <twickham@google.com>2016-02-01 14:15:37 -0800
commit8a75806c1a22b79d6c343f0057f1cc55b2a62ed3 (patch)
treed2c238e98e44884d113036611a80c6200a9c5f54
parent6362683acb884ec72fe10f1cf394d178d3918a96 (diff)
downloadandroid_packages_apps_Trebuchet-8a75806c1a22b79d6c343f0057f1cc55b2a62ed3.tar.gz
android_packages_apps_Trebuchet-8a75806c1a22b79d6c343f0057f1cc55b2a62ed3.tar.bz2
android_packages_apps_Trebuchet-8a75806c1a22b79d6c343f0057f1cc55b2a62ed3.zip
Add extra space for the search bar.
Also fixed a broken test. Change-Id: I1c270e69617528ea30f0e26a2101673e9b9fa63c
-rw-r--r--res/values/dimens.xml9
-rw-r--r--src/com/android/launcher3/DeviceProfile.java17
-rw-r--r--tests/src/com/android/launcher3/InvariantDeviceProfileTest.java21
3 files changed, 28 insertions, 19 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 1025abaa6..076853e8d 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -20,13 +20,16 @@
<!-- Dynamic Grid -->
<dimen name="dynamic_grid_edge_margin">6dp</dimen>
<dimen name="dynamic_grid_search_bar_height">48dp</dimen>
- <!-- We want 32dp extra for the tall search bar. -->
- <dimen name="dynamic_grid_search_bar_height_tall">80dp</dimen>
+ <!-- We want 46dp extra for the tall search bar. -->
+ <dimen name="dynamic_grid_search_bar_height_tall">94dp</dimen>
<dimen name="qsb_internal_padding_top">8dp</dimen>
<dimen name="qsb_internal_padding_bottom">8dp</dimen>
+ <dimen name="dynamic_grid_search_bar_extra_top_padding">0dp</dimen>
+ <!-- Reduce the space between the status bar and the search bar when the search bar is tall -->
+ <dimen name="dynamic_grid_search_bar_negative_top_padding_short">-4dp</dimen>
<dimen name="dynamic_grid_search_bar_bottom_padding">4dp</dimen>
<!-- Reduce the padding between the search bar and workspace when the search bar is tall -->
- <dimen name="dynamic_grid_search_bar_bottom_padding_short">-6dp</dimen>
+ <dimen name="dynamic_grid_search_bar_bottom_negative_padding_short">-6dp</dimen>
<dimen name="dynamic_grid_search_bar_bottom_padding_tablet">16dp</dimen>
<dimen name="dynamic_grid_page_indicator_height">20dp</dimen>
<dimen name="dynamic_grid_icon_drawable_padding">4dp</dimen>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index c6da5844a..61c4b1a22 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -103,6 +103,8 @@ public class DeviceProfile {
// QSB
private int searchBarWidgetInternalPaddingTop, searchBarWidgetInternalPaddingBottom;
private int searchBarTopPaddingPx;
+ private int tallSearchBarNegativeTopPaddingPx, normalSearchBarTopExtraPaddingPx;
+ private int searchBarTopExtraPaddingPx; // One of the above.
private int normalSearchBarBottomPaddingPx, tallSearchBarBottomPaddingPx;
private int searchBarBottomPaddingPx; // One of the above.
private int normalSearchBarSpaceHeightPx, tallSearchBarSpaceHeightPx;
@@ -216,6 +218,10 @@ public class DeviceProfile {
R.dimen.qsb_internal_padding_top);
searchBarWidgetInternalPaddingBottom = res.getDimensionPixelSize(
R.dimen.qsb_internal_padding_bottom);
+ normalSearchBarTopExtraPaddingPx = res.getDimensionPixelSize(
+ R.dimen.dynamic_grid_search_bar_extra_top_padding);
+ tallSearchBarNegativeTopPaddingPx = res.getDimensionPixelSize(
+ R.dimen.dynamic_grid_search_bar_negative_top_padding_short);
if (isTablet && !isVerticalBarLayout()) {
searchBarTopPaddingPx = searchBarWidgetInternalPaddingTop;
normalSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom +
@@ -225,8 +231,9 @@ public class DeviceProfile {
searchBarTopPaddingPx = searchBarWidgetInternalPaddingTop;
normalSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom +
res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_bottom_padding);
- tallSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom +
- res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_bottom_padding_short);
+ tallSearchBarBottomPaddingPx = searchBarWidgetInternalPaddingBottom
+ + res.getDimensionPixelSize(
+ R.dimen.dynamic_grid_search_bar_bottom_negative_padding_short);
}
// Calculate the actual text height
@@ -272,7 +279,7 @@ public class DeviceProfile {
/** Returns the amount of extra space to allocate to the search bar for vertical padding. */
private int getSearchBarTotalVerticalPadding() {
- return searchBarTopPaddingPx + searchBarBottomPaddingPx;
+ return searchBarTopPaddingPx + searchBarTopExtraPaddingPx + searchBarBottomPaddingPx;
}
/** Returns the width and height of the search bar, ignoring any padding. */
@@ -427,10 +434,13 @@ public class DeviceProfile {
hotseatBarHeightPx = shortHotseatBarHeightPx;
searchBarSpaceHeightPx = tallSearchBarSpaceHeightPx;
searchBarBottomPaddingPx = tallSearchBarBottomPaddingPx;
+ searchBarTopExtraPaddingPx = isPhone ? tallSearchBarNegativeTopPaddingPx
+ : normalSearchBarTopExtraPaddingPx;
} else {
hotseatBarHeightPx = normalHotseatBarHeightPx;
searchBarSpaceHeightPx = normalSearchBarSpaceHeightPx;
searchBarBottomPaddingPx = normalSearchBarBottomPaddingPx;
+ searchBarTopExtraPaddingPx = normalSearchBarTopExtraPaddingPx;
}
}
@@ -445,6 +455,7 @@ public class DeviceProfile {
lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
lp.width = searchBarBounds.width();
lp.height = searchBarBounds.height();
+ lp.topMargin = searchBarTopExtraPaddingPx;
if (hasVerticalBarLayout) {
// Vertical search bar space -- The search bar is fixed in the layout to be on the left
// of the screen regardless of RTL
diff --git a/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java b/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
index db3f72f3a..21df60109 100644
--- a/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
+++ b/tests/src/com/android/launcher3/InvariantDeviceProfileTest.java
@@ -108,15 +108,9 @@ public class InvariantDeviceProfileTest extends AndroidTestCase {
if (!android.os.Build.DEVICE.equals("hammerhead")) {
return;
}
- assertEquals(mInvariantProfile.numRows, 4);
- assertEquals(mInvariantProfile.numColumns, 4);
- assertEquals((int) mInvariantProfile.numHotseatIcons, 5);
-
- DeviceProfile landscapeProfile = mInvariantProfile.landscapeProfile;
- DeviceProfile portraitProfile = mInvariantProfile.portraitProfile;
-
- assertEquals(portraitProfile.allAppsNumCols, 3);
- assertEquals(landscapeProfile.allAppsNumCols, 5); // not used
+ assertEquals(4, mInvariantProfile.numRows);
+ assertEquals(4, mInvariantProfile.numColumns);
+ assertEquals(5, mInvariantProfile.numHotseatIcons);
}
// Add more tests for other devices, however, running them once on a single device is enough
@@ -172,10 +166,11 @@ public class InvariantDeviceProfileTest extends AndroidTestCase {
Rect landscapeBounds = landscapeProfile.getSearchBarBounds(true); // RTL shouldn't matter.
int landscapeHeight = (int) Utilities.dpiFromPx(landscapeBounds.height(),
resources.getDisplayMetrics());
- if (portraitProfile.isTablet) {
- assertEquals(8 + 80 + 24, portraitHeight);
+ if (portraitProfile.isPhone) {
+ // This fails on some devices due to http://b/26884580 (portraitHeight is 101, not 100).
+ assertEquals(4 + 94 + 2, portraitHeight);
} else {
- assertEquals(8 + 80 + 2, portraitHeight);
+ assertEquals(8 + 94 + 24, portraitHeight);
}
// Make sure the height that we pass in the widget options bundle is the height of the
// search bar + 8dps padding top and bottom.
@@ -183,7 +178,7 @@ public class InvariantDeviceProfileTest extends AndroidTestCase {
int portraitWidgetOptsHeight = portraitDimens.y;
Point landscapeDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(resources);
int landscapeWidgetOptsHeight = landscapeDimens.y;
- assertEquals(8 + 80 + 8, (int) Utilities.dpiFromPx(portraitWidgetOptsHeight,
+ assertEquals(8 + 94 + 8, (int) Utilities.dpiFromPx(portraitWidgetOptsHeight,
resources.getDisplayMetrics()));
if (!landscapeProfile.isVerticalBarLayout()) {
assertEquals(portraitHeight, landscapeHeight);