diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2014-10-24 16:26:52 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2014-11-07 12:55:48 -0800 |
commit | 8dfe2da6985d38f23fd3426101574c093f509907 (patch) | |
tree | 296a9bf929193dc10b11eab6deaa384c6b8292fb | |
parent | b1b201c9af7a53b9ceedb4873b541f85619e6850 (diff) | |
download | android_packages_apps_Trebuchet-8dfe2da6985d38f23fd3426101574c093f509907.tar.gz android_packages_apps_Trebuchet-8dfe2da6985d38f23fd3426101574c093f509907.tar.bz2 android_packages_apps_Trebuchet-8dfe2da6985d38f23fd3426101574c093f509907.zip |
Adding some spacing between overview panel items
Bug: 18293488
Change-Id: I8731c4d2ad34571a4a3a21b03a5fbae0ba66332f
-rw-r--r-- | res/values/dimens.xml | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 38 |
2 files changed, 33 insertions, 9 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 20bc7ccf9..493f29c69 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -25,8 +25,8 @@ <dimen name="dynamic_grid_workspace_page_spacing">8dp</dimen> <dimen name="dynamic_grid_overview_min_icon_zone_height">80dp</dimen> <dimen name="dynamic_grid_overview_max_icon_zone_height">120dp</dimen> - <dimen name="dynamic_grid_overview_bar_item_width">48dp</dimen> - <dimen name="dynamic_grid_overview_bar_spacer_width">68dp</dimen> + <dimen name="dynamic_grid_overview_bar_item_width">80dp</dimen> + <dimen name="dynamic_grid_overview_bar_spacer_width">20dp</dimen> <!-- Cling --> <dimen name="cling_migration_logo_height">240dp</dimen> diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index b2366bb2b..bd7a7726a 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; @@ -703,11 +704,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(); @@ -872,10 +868,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; + } + } + } } } } |