summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/DeviceProfile.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2015-09-23 14:55:17 -0700
committerTony Wickham <twickham@google.com>2015-10-08 16:58:05 -0700
commit55616cd363202eccf7a9f9a5af00d12997c24b19 (patch)
tree7db3ed1d04502aed75792514d21949d1f4fd0152 /src/com/android/launcher3/DeviceProfile.java
parent53d3be63a5ab056280279bcb13089faae0e7796f (diff)
downloadandroid_packages_apps_Trebuchet-55616cd363202eccf7a9f9a5af00d12997c24b19.tar.gz
android_packages_apps_Trebuchet-55616cd363202eccf7a9f9a5af00d12997c24b19.tar.bz2
android_packages_apps_Trebuchet-55616cd363202eccf7a9f9a5af00d12997c24b19.zip
Added launcher callback to specify search bar height.
The search bar can now be be normal or tall. When it is set to tall, the hotseat and page indicators move down so that the workspace isn't compressed quite as much. Change-Id: Id92a946eab3a93524999f92efd847a501a95f002
Diffstat (limited to 'src/com/android/launcher3/DeviceProfile.java')
-rw-r--r--src/com/android/launcher3/DeviceProfile.java41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 47c5ccc9e..0abfc6771 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -84,7 +84,8 @@ public class DeviceProfile {
public int hotseatCellWidthPx;
public int hotseatCellHeightPx;
public int hotseatIconSizePx;
- private int hotseatBarHeightPx;
+ private int hotseatBarHeightNormalPx, hotseatBarHeightShortPx;
+ private int hotseatBarHeightPx; // One of the above.
// All apps
public int allAppsNumCols;
@@ -95,7 +96,9 @@ public class DeviceProfile {
// QSB
private int searchBarSpaceWidthPx;
- private int searchBarSpaceHeightPx;
+ private int searchBarSpaceHeightNormalPx, searchBarSpaceHeightTallPx;
+ private int searchBarSpaceHeightPx; // One of the above.
+ private int searchBarHeight = LauncherCallbacks.SEARCH_BAR_HEIGHT_NORMAL;
public DeviceProfile(Context context, InvariantDeviceProfile inv,
Point minSize, Point maxSize,
@@ -198,8 +201,10 @@ public class DeviceProfile {
// Search Bar
searchBarSpaceWidthPx = Math.min(widthPx,
res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width));
- searchBarSpaceHeightPx = getSearchBarTopOffset()
+ searchBarSpaceHeightNormalPx = getSearchBarTopOffset()
+ res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height);
+ searchBarSpaceHeightTallPx = getSearchBarTopOffset()
+ + res.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height_tall);
// Calculate the actual text height
Paint textPaint = new Paint();
@@ -211,7 +216,8 @@ public class DeviceProfile {
dragViewScale = (iconSizePx + scaleDps) / iconSizePx;
// Hotseat
- hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx;
+ hotseatBarHeightNormalPx = iconSizePx + 4 * edgeMarginPx;
+ hotseatBarHeightShortPx = iconSizePx + 2 * edgeMarginPx;
hotseatCellWidthPx = iconSizePx;
hotseatCellHeightPx = iconSizePx;
@@ -252,10 +258,10 @@ public class DeviceProfile {
Rect bounds = new Rect();
if (isVerticalBarLayout()) {
if (isLayoutRtl) {
- bounds.set(availableWidthPx - searchBarSpaceHeightPx, edgeMarginPx,
+ bounds.set(availableWidthPx - searchBarSpaceHeightNormalPx, edgeMarginPx,
availableWidthPx, availableHeightPx - edgeMarginPx);
} else {
- bounds.set(0, edgeMarginPx, searchBarSpaceHeightPx,
+ bounds.set(0, edgeMarginPx, searchBarSpaceHeightNormalPx,
availableHeightPx - edgeMarginPx);
}
} else {
@@ -287,11 +293,11 @@ public class DeviceProfile {
if (isVerticalBarLayout()) {
// Pad the left and right of the workspace with search/hotseat bar sizes
if (isLayoutRtl) {
- padding.set(hotseatBarHeightPx, edgeMarginPx,
+ padding.set(hotseatBarHeightNormalPx, edgeMarginPx,
searchBarBounds.width(), edgeMarginPx);
} else {
padding.set(searchBarBounds.width(), edgeMarginPx,
- hotseatBarHeightPx, edgeMarginPx);
+ hotseatBarHeightNormalPx, edgeMarginPx);
}
} else {
if (isTablet) {
@@ -341,7 +347,7 @@ public class DeviceProfile {
// The rect returned will be extended to below the system ui that covers the workspace
Rect getHotseatRect() {
if (isVerticalBarLayout()) {
- return new Rect(availableWidthPx - hotseatBarHeightPx, 0,
+ return new Rect(availableWidthPx - hotseatBarHeightNormalPx, 0,
Integer.MAX_VALUE, availableHeightPx);
} else {
return new Rect(0, availableHeightPx - hotseatBarHeightPx,
@@ -357,8 +363,9 @@ public class DeviceProfile {
}
/**
- * When {@code true}, hotseat is on the bottom row when in landscape mode.
- * If {@code false}, hotseat is on the right column when in landscape mode.
+ * When {@code true}, the device is in landscape mode and the hotseat is on the right column.
+ * When {@code false}, either device is in portrait mode or the device is in landscape mode and
+ * the hotseat is on the bottom row.
*/
boolean isVerticalBarLayout() {
return isLandscape && transposeLayoutWithOrientation;
@@ -386,11 +393,19 @@ public class DeviceProfile {
// Layout the search bar space
View searchBar = launcher.getSearchDropTargetBar();
lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
+ searchBarHeight = launcher.getSearchBarHeight();
+ if (searchBarHeight == LauncherCallbacks.SEARCH_BAR_HEIGHT_TALL) {
+ hotseatBarHeightPx = hotseatBarHeightShortPx;
+ searchBarSpaceHeightPx = searchBarSpaceHeightTallPx;
+ } else {
+ hotseatBarHeightPx = hotseatBarHeightNormalPx;
+ searchBarSpaceHeightPx = searchBarSpaceHeightNormalPx;
+ }
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
lp.gravity = Gravity.LEFT;
- lp.width = searchBarSpaceHeightPx;
+ lp.width = searchBarSpaceHeightNormalPx;
LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar);
targets.setOrientation(LinearLayout.VERTICAL);
@@ -424,7 +439,7 @@ public class DeviceProfile {
// Vertical hotseat -- The hotseat is fixed in the layout to be on the right of the
// screen regardless of RTL
lp.gravity = Gravity.RIGHT;
- lp.width = hotseatBarHeightPx;
+ lp.width = hotseatBarHeightNormalPx;
lp.height = LayoutParams.MATCH_PARENT;
hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx);
} else if (isTablet) {