summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-11-07 21:27:21 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-07 21:27:21 +0000
commit91078bb93aae898c0f84d4ba8bcc2d305aee25b6 (patch)
tree1df86c1a0a39a373cb7a93e8f09daaeaf23b4bac /src/com/android
parentac9ed8c9e5250f9e0c1d7176d8ec29a1d092c53f (diff)
parent8dfe2da6985d38f23fd3426101574c093f509907 (diff)
downloadandroid_packages_apps_Trebuchet-91078bb93aae898c0f84d4ba8bcc2d305aee25b6.tar.gz
android_packages_apps_Trebuchet-91078bb93aae898c0f84d4ba8bcc2d305aee25b6.tar.bz2
android_packages_apps_Trebuchet-91078bb93aae898c0f84d4ba8bcc2d305aee25b6.zip
am 8dfe2da6: Adding some spacing between overview panel items
* commit '8dfe2da6985d38f23fd3426101574c093f509907': Adding some spacing between overview panel items
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/DeviceProfile.java38
1 files changed, 31 insertions, 7 deletions
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;
+ }
+ }
+ }
}
}
}