summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/DeviceProfile.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/DeviceProfile.java')
-rw-r--r--src/com/android/launcher3/DeviceProfile.java80
1 files changed, 36 insertions, 44 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index daf5556d4..d6aadcee1 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -33,6 +33,7 @@ import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
+import android.view.ViewGroup.MarginLayoutParams;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
@@ -75,7 +76,6 @@ public class DeviceProfile {
private float hotseatIconSize;
int defaultLayoutId;
- int defaultNoAllAppsLayoutId;
boolean isLandscape;
boolean isTablet;
@@ -122,9 +122,7 @@ public class DeviceProfile {
int allAppsNumRows;
int allAppsNumCols;
int searchBarSpaceWidthPx;
- int searchBarSpaceMaxWidthPx;
int searchBarSpaceHeightPx;
- int searchBarHeightPx;
int pageIndicatorHeightPx;
int allAppsButtonVisualSize;
@@ -136,7 +134,7 @@ public class DeviceProfile {
private ArrayList<DeviceProfileCallbacks> mCallbacks = new ArrayList<DeviceProfileCallbacks>();
DeviceProfile(String n, float w, float h, float r, float c,
- float is, float its, float hs, float his, int dlId, int dnalId) {
+ float is, float its, float hs, float his, int dlId) {
// Ensure that we have an odd number of hotseat items (since we need to place all apps)
if (!LauncherAppState.isDisableAllApps() && hs % 2 == 0) {
throw new RuntimeException("All Device Profiles must have an odd number of hotseat spaces");
@@ -152,7 +150,6 @@ public class DeviceProfile {
numHotseatIcons = hs;
hotseatIconSize = his;
defaultLayoutId = dlId;
- defaultNoAllAppsLayoutId = dnalId;
}
DeviceProfile() {
@@ -215,9 +212,6 @@ public class DeviceProfile {
// Snap to the closest default layout id
defaultLayoutId = closestProfile.defaultLayoutId;
- // Snap to the closest default no all-apps layout id
- defaultNoAllAppsLayoutId = closestProfile.defaultNoAllAppsLayoutId;
-
// Interpolate the icon size
points.clear();
for (DeviceProfile p : profiles) {
@@ -376,10 +370,10 @@ public class DeviceProfile {
hotseatIconSizePx = (int) (DynamicGrid.pxFromDp(hotseatIconSize, dm) * scale);
// Search Bar
- searchBarSpaceMaxWidthPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width);
- searchBarHeightPx = resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height);
- searchBarSpaceWidthPx = Math.min(searchBarSpaceMaxWidthPx, widthPx);
- searchBarSpaceHeightPx = searchBarHeightPx + getSearchBarTopOffset();
+ searchBarSpaceWidthPx = Math.min(widthPx,
+ resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_max_width));
+ searchBarSpaceHeightPx = getSearchBarTopOffset()
+ + resources.getDimensionPixelSize(R.dimen.dynamic_grid_search_bar_height);
// Calculate the actual text height
Paint textPaint = new Paint();
@@ -402,10 +396,6 @@ public class DeviceProfile {
folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
// All Apps
- Rect padding = getWorkspacePadding(isLandscape ?
- CellLayout.LANDSCAPE : CellLayout.PORTRAIT);
- int pageIndicatorOffset =
- resources.getDimensionPixelSize(R.dimen.apps_customize_page_indicator_offset);
allAppsCellWidthPx = allAppsIconSizePx;
allAppsCellHeightPx = allAppsIconSizePx + drawablePadding + iconTextSizePx;
int maxLongEdgeCellCount =
@@ -708,11 +698,6 @@ public class DeviceProfile {
return visibleChildren;
}
- int calculateOverviewModeWidth(int visibleChildCount) {
- return visibleChildCount * overviewModeBarItemWidthPx +
- (visibleChildCount-1) * overviewModeBarSpacerWidthPx;
- }
-
public void layout(Launcher launcher) {
FrameLayout.LayoutParams lp;
Resources res = launcher.getResources();
@@ -726,9 +711,6 @@ public class DeviceProfile {
lp.gravity = Gravity.TOP | Gravity.LEFT;
lp.width = searchBarSpaceHeightPx;
lp.height = LayoutParams.WRAP_CONTENT;
- searchBar.setPadding(
- 0, 2 * edgeMarginPx, 0,
- 2 * edgeMarginPx);
LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar);
targets.setOrientation(LinearLayout.VERTICAL);
@@ -737,27 +719,9 @@ public class DeviceProfile {
lp.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL;
lp.width = searchBarSpaceWidthPx;
lp.height = searchBarSpaceHeightPx;
- searchBar.setPadding(
- 2 * edgeMarginPx,
- getSearchBarTopOffset(),
- 2 * edgeMarginPx, 0);
}
searchBar.setLayoutParams(lp);
- // Layout the voice proxy
- View voiceButtonProxy = launcher.findViewById(R.id.voice_button_proxy);
- if (voiceButtonProxy != null) {
- if (hasVerticalBarLayout) {
- // TODO: MOVE THIS INTO SEARCH BAR MEASURE
- } else {
- lp = (FrameLayout.LayoutParams) voiceButtonProxy.getLayoutParams();
- lp.gravity = Gravity.TOP | Gravity.END;
- lp.width = (widthPx - searchBarSpaceWidthPx) / 2 +
- 2 * iconSizePx;
- lp.height = searchBarSpaceHeightPx;
- }
- }
-
// Layout the workspace
PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace);
lp = (FrameLayout.LayoutParams) workspace.getLayoutParams();
@@ -877,10 +841,38 @@ public class DeviceProfile {
Rect r = getOverviewModeButtonBarRect();
lp = (FrameLayout.LayoutParams) overviewMode.getLayoutParams();
lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
- lp.width = Math.min(availableWidthPx,
- calculateOverviewModeWidth(getVisibleChildCount(overviewMode)));
+
+ int visibleChildCount = getVisibleChildCount(overviewMode);
+ int totalItemWidth = visibleChildCount * overviewModeBarItemWidthPx;
+ int maxWidth = totalItemWidth + (visibleChildCount-1) * overviewModeBarSpacerWidthPx;
+
+ lp.width = Math.min(availableWidthPx, maxWidth);
lp.height = r.height();
overviewMode.setLayoutParams(lp);
+
+ if (lp.width > totalItemWidth && visibleChildCount > 1) {
+ // We have enough space. Lets add some margin too.
+ int margin = (lp.width - totalItemWidth) / (visibleChildCount-1);
+ View lastChild = null;
+
+ // Set margin of all visible children except the last visible child
+ for (int i = 0; i < visibleChildCount; i++) {
+ if (lastChild != null) {
+ MarginLayoutParams clp = (MarginLayoutParams) lastChild.getLayoutParams();
+ if (isLayoutRtl) {
+ clp.leftMargin = margin;
+ } else {
+ clp.rightMargin = margin;
+ }
+ lastChild.setLayoutParams(clp);
+ lastChild = null;
+ }
+ View thisChild = overviewMode.getChildAt(i);
+ if (thisChild.getVisibility() != View.GONE) {
+ lastChild = thisChild;
+ }
+ }
+ }
}
}
}