Integrate changes from lockscreen proto app

Fix padding/layout issues in MultiPaneChallengeLayout

Change-Id: I610b4c0cc321a690fa29d071d6a960c05ffbe3a7
This commit is contained in:
Adam Powell
2012-10-24 14:00:04 -07:00
parent ee0f615ffd
commit c0657fb36c
4 changed files with 31 additions and 17 deletions

View File

@@ -47,7 +47,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
androidprv:layout_childType="challenge" androidprv:layout_childType="challenge"
androidprv:layout_centerWithinArea="0.55"> android:layout_gravity="center_horizontal|bottom">
<com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper <com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
android:id="@+id/view_flipper" android:id="@+id/view_flipper"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@@ -18,7 +18,7 @@
--> -->
<merge xmlns:android="http://schemas.android.com/apk/res/android"> <merge xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="@layout/keyguard_glow_pad_view" <include layout="@layout/keyguard_glow_pad_view"
android:layout_width="@dimen/kg_glow_pad_size" android:layout_width="wrap_content"
android:layout_height="@dimen/kg_glow_pad_size" android:layout_height="wrap_content"
android:layout_gravity="center" /> android:layout_gravity="center" />
</merge> </merge>

View File

@@ -100,9 +100,6 @@
devices to account for the widget pager padding --> devices to account for the widget pager padding -->
<dimen name="kg_runway_lights_top_margin">-30dp</dimen> <dimen name="kg_runway_lights_top_margin">-30dp</dimen>
<!-- Margin around the various security views -->
<dimen name="keyguard_security_view_margin">100dp</dimen>
<!-- Margin around the various security views --> <!-- Margin around the various security views -->
<dimen name="keyguard_muliuser_selector_margin">24dp</dimen> <dimen name="keyguard_muliuser_selector_margin">24dp</dimen>

View File

@@ -133,10 +133,11 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
measureChildWithMargins(child, adjustedWidthSpec, 0, adjustedHeightSpec, 0); measureChildWithMargins(child, adjustedWidthSpec, 0, adjustedHeightSpec, 0);
// Only subtract out space from one dimension. Favor vertical. // 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)) { if (Gravity.isVertical(lp.gravity)) {
heightUsed = child.getMeasuredHeight(); heightUsed += child.getMeasuredHeight() * 1.5f;
} else if (Gravity.isHorizontal(lp.gravity)) { } 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 adjustedWidth;
final int adjustedHeight; final int adjustedHeight;
if (fixedLayoutHorizontal) { 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; adjustedHeight = height;
} else if (fixedLayoutVertical) { } else if (fixedLayoutVertical) {
final int paddedHeight = height - padding.top - padding.bottom;
adjustedWidth = width; adjustedWidth = width;
adjustedHeight = (int) (height * lp.centerWithinArea + 0.5f); adjustedHeight = (int) (paddedHeight * lp.centerWithinArea + 0.5f);
} else { } else {
adjustedWidth = width; adjustedWidth = width;
adjustedHeight = height; adjustedHeight = height;
@@ -248,17 +251,24 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
top = fixedLayoutVertical ? top = fixedLayoutVertical ?
padding.top + (adjustedHeight - childHeight) / 2 : padding.top; padding.top + (adjustedHeight - childHeight) / 2 : padding.top;
bottom = top + childHeight; bottom = top + childHeight;
if (adjustPadding && isVertical) padding.top = bottom; if (adjustPadding && isVertical) {
padding.top = bottom;
padding.bottom += childHeight / 2;
}
break; break;
case Gravity.BOTTOM: case Gravity.BOTTOM:
bottom = fixedLayoutVertical bottom = fixedLayoutVertical
? height - padding.bottom - (adjustedHeight - childHeight) / 2 ? height - padding.bottom - (adjustedHeight - childHeight) / 2
: height - padding.bottom; : height - padding.bottom;
top = bottom - childHeight; top = bottom - childHeight;
if (adjustPadding && isVertical) padding.bottom = top; if (adjustPadding && isVertical) {
padding.bottom = height - top;
padding.top += childHeight / 2;
}
break; break;
case Gravity.CENTER_VERTICAL: 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; bottom = top + childHeight;
break; break;
} }
@@ -267,17 +277,24 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
left = fixedLayoutHorizontal ? left = fixedLayoutHorizontal ?
padding.left + (adjustedWidth - childWidth) / 2 : padding.left; padding.left + (adjustedWidth - childWidth) / 2 : padding.left;
right = left + childWidth; right = left + childWidth;
if (adjustPadding && isHorizontal && !isVertical) padding.left = right; if (adjustPadding && isHorizontal && !isVertical) {
padding.left = right;
padding.right += childWidth / 2;
}
break; break;
case Gravity.RIGHT: case Gravity.RIGHT:
right = fixedLayoutHorizontal right = fixedLayoutHorizontal
? width - padding.right - (adjustedWidth - childWidth) / 2 ? width - padding.right - (adjustedWidth - childWidth) / 2
: width - padding.right; : width - padding.right;
left = right - childWidth; left = right - childWidth;
if (adjustPadding && isHorizontal && !isVertical) padding.right = left; if (adjustPadding && isHorizontal && !isVertical) {
padding.right = width - left;
padding.left += childWidth / 2;
}
break; break;
case Gravity.CENTER_HORIZONTAL: case Gravity.CENTER_HORIZONTAL:
left = (width - childWidth) / 2; final int paddedWidth = width - padding.left - padding.right;
left = (paddedWidth - childWidth) / 2;
right = left + childWidth; right = left + childWidth;
break; break;
} }