From c0657fb36ce5ede652e8af084e484d07abfb449d Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Wed, 24 Oct 2012 14:00:04 -0700 Subject: [PATCH] Integrate changes from lockscreen proto app Fix padding/layout issues in MultiPaneChallengeLayout Change-Id: I610b4c0cc321a690fa29d071d6a960c05ffbe3a7 --- .../keyguard_host_view.xml | 2 +- .../keyguard_glow_pad_container.xml | 6 +-- core/res/res/values-sw720dp/dimens.xml | 3 -- .../keyguard/MultiPaneChallengeLayout.java | 37 ++++++++++++++----- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/core/res/res/layout-sw600dp-port/keyguard_host_view.xml b/core/res/res/layout-sw600dp-port/keyguard_host_view.xml index e100788bfe3dc..4a1a5bb66dadd 100644 --- a/core/res/res/layout-sw600dp-port/keyguard_host_view.xml +++ b/core/res/res/layout-sw600dp-port/keyguard_host_view.xml @@ -47,7 +47,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" androidprv:layout_childType="challenge" - androidprv:layout_centerWithinArea="0.55"> + android:layout_gravity="center_horizontal|bottom"> - \ No newline at end of file + diff --git a/core/res/res/values-sw720dp/dimens.xml b/core/res/res/values-sw720dp/dimens.xml index 67fe2c082bfda..d6d2b6621a0df 100644 --- a/core/res/res/values-sw720dp/dimens.xml +++ b/core/res/res/values-sw720dp/dimens.xml @@ -100,9 +100,6 @@ devices to account for the widget pager padding --> -30dp - - 100dp - 24dp diff --git a/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java b/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java index a12b020fc31f7..edab9010f9595 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java @@ -133,10 +133,11 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo measureChildWithMargins(child, adjustedWidthSpec, 0, adjustedHeightSpec, 0); // Only subtract out space from one dimension. Favor vertical. + // Offset by 1.5x to add some balance along the other edge. if (Gravity.isVertical(lp.gravity)) { - heightUsed = child.getMeasuredHeight(); + heightUsed += child.getMeasuredHeight() * 1.5f; } else if (Gravity.isHorizontal(lp.gravity)) { - widthUsed = child.getMeasuredWidth(); + widthUsed += child.getMeasuredWidth() * 1.5f; } } } @@ -224,11 +225,13 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo final int adjustedWidth; final int adjustedHeight; if (fixedLayoutHorizontal) { - adjustedWidth = (int) (width * lp.centerWithinArea + 0.5f); + final int paddedWidth = width - padding.left - padding.right; + adjustedWidth = (int) (paddedWidth * lp.centerWithinArea + 0.5f); adjustedHeight = height; } else if (fixedLayoutVertical) { + final int paddedHeight = height - padding.top - padding.bottom; adjustedWidth = width; - adjustedHeight = (int) (height * lp.centerWithinArea + 0.5f); + adjustedHeight = (int) (paddedHeight * lp.centerWithinArea + 0.5f); } else { adjustedWidth = width; adjustedHeight = height; @@ -248,17 +251,24 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo top = fixedLayoutVertical ? padding.top + (adjustedHeight - childHeight) / 2 : padding.top; bottom = top + childHeight; - if (adjustPadding && isVertical) padding.top = bottom; + if (adjustPadding && isVertical) { + padding.top = bottom; + padding.bottom += childHeight / 2; + } break; case Gravity.BOTTOM: bottom = fixedLayoutVertical ? height - padding.bottom - (adjustedHeight - childHeight) / 2 : height - padding.bottom; top = bottom - childHeight; - if (adjustPadding && isVertical) padding.bottom = top; + if (adjustPadding && isVertical) { + padding.bottom = height - top; + padding.top += childHeight / 2; + } break; case Gravity.CENTER_VERTICAL: - top = (height - childHeight) / 2; + final int paddedHeight = height - padding.top - padding.bottom; + top = padding.top + (paddedHeight - childHeight) / 2; bottom = top + childHeight; break; } @@ -267,17 +277,24 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo left = fixedLayoutHorizontal ? padding.left + (adjustedWidth - childWidth) / 2 : padding.left; right = left + childWidth; - if (adjustPadding && isHorizontal && !isVertical) padding.left = right; + if (adjustPadding && isHorizontal && !isVertical) { + padding.left = right; + padding.right += childWidth / 2; + } break; case Gravity.RIGHT: right = fixedLayoutHorizontal ? width - padding.right - (adjustedWidth - childWidth) / 2 : width - padding.right; left = right - childWidth; - if (adjustPadding && isHorizontal && !isVertical) padding.right = left; + if (adjustPadding && isHorizontal && !isVertical) { + padding.right = width - left; + padding.left += childWidth / 2; + } break; case Gravity.CENTER_HORIZONTAL: - left = (width - childWidth) / 2; + final int paddedWidth = width - padding.left - padding.right; + left = (paddedWidth - childWidth) / 2; right = left + childWidth; break; }