Skip to content

Commit 5f69f38

Browse files
committed
hide multiuser selector when IME is up.
Bug: 7437062 Change-Id: I7d1b2cf8e74b5ac8546aa9ae7545b69ab3584633
1 parent bb5c941 commit 5f69f38

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

core/res/res/values-land/dimens.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,9 @@
5656
<!-- Bottom padding for the widget pager -->
5757
<dimen name="kg_widget_pager_bottom_padding">0dp</dimen>
5858

59+
<!-- If the height if keyguard drops below this threshold (most likely
60+
due to the appearance of the IME), then drop the multiuser selector.
61+
Landscape's layout allows this to be smaller than for portrait. -->
62+
<dimen name="kg_squashed_layout_threshold">400dp</dimen>
63+
5964
</resources>

core/res/res/values/dimens.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,9 @@
330330
<!-- Size of the region along the edge of the screen that will accept
331331
swipes to scroll the widget area. -->
332332
<dimen name="kg_edge_swipe_region_size">24dp</dimen>
333+
334+
<!-- If the height if keyguard drops below this threshold (most likely
335+
due to the appearance of the IME), then drop the multiuser selector. -->
336+
<dimen name="kg_squashed_layout_threshold">600dp</dimen>
337+
333338
</resources>

core/res/res/values/symbols.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,7 @@
12341234
<java-symbol type="dimen" name="keyguard_avatar_frame_stroke_width" />
12351235
<java-symbol type="dimen" name="keyguard_avatar_frame_shadow_radius" />
12361236
<java-symbol type="dimen" name="kg_edge_swipe_region_size" />
1237+
<java-symbol type="dimen" name="kg_squashed_layout_threshold" />
12371238
<java-symbol type="drawable" name="ic_jog_dial_sound_off" />
12381239
<java-symbol type="drawable" name="ic_jog_dial_sound_on" />
12391240
<java-symbol type="drawable" name="ic_jog_dial_unlock" />

policy/src/com/android/internal/policy/impl/keyguard/MultiPaneChallengeLayout.java

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class MultiPaneChallengeLayout extends ViewGroup implements ChallengeLayo
4747
private OnBouncerStateChangedListener mBouncerListener;
4848

4949
private final Rect mTempRect = new Rect();
50+
private final Context mContext;
5051

5152
private final OnClickListener mScrimClickListener = new OnClickListener() {
5253
@Override
@@ -66,6 +67,8 @@ public MultiPaneChallengeLayout(Context context, AttributeSet attrs) {
6667
public MultiPaneChallengeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
6768
super(context, attrs, defStyleAttr);
6869

70+
mContext = context;
71+
6972
final TypedArray a = context.obtainStyledAttributes(attrs,
7073
R.styleable.MultiPaneChallengeLayout, defStyleAttr, 0);
7174
mOrientation = a.getInt(R.styleable.MultiPaneChallengeLayout_orientation,
@@ -173,6 +176,8 @@ protected void onMeasure(int widthSpec, int heightSpec) {
173176
throw new IllegalArgumentException(
174177
"MultiPaneChallengeLayout must be measured with an exact size");
175178
}
179+
float squashedLayoutThreshold =
180+
mContext.getResources().getDimension(R.dimen.kg_squashed_layout_threshold);
176181

177182
final int width = MeasureSpec.getSize(widthSpec);
178183
final int height = MeasureSpec.getSize(heightSpec);
@@ -208,28 +213,32 @@ protected void onMeasure(int widthSpec, int heightSpec) {
208213
mUserSwitcherView = child;
209214

210215
if (child.getVisibility() == GONE) continue;
211-
212-
int adjustedWidthSpec = widthSpec;
213-
int adjustedHeightSpec = heightSpec;
214-
if (lp.maxWidth >= 0) {
215-
adjustedWidthSpec = MeasureSpec.makeMeasureSpec(
216-
Math.min(lp.maxWidth, MeasureSpec.getSize(widthSpec)),
217-
MeasureSpec.EXACTLY);
218-
}
219-
if (lp.maxHeight >= 0) {
220-
adjustedHeightSpec = MeasureSpec.makeMeasureSpec(
221-
Math.min(lp.maxHeight, MeasureSpec.getSize(heightSpec)),
222-
MeasureSpec.EXACTLY);
223-
}
224-
// measureChildWithMargins will resolve layout direction for the LayoutParams
225-
measureChildWithMargins(child, adjustedWidthSpec, 0, adjustedHeightSpec, 0);
226-
227-
// Only subtract out space from one dimension. Favor vertical.
228-
// Offset by 1.5x to add some balance along the other edge.
229-
if (Gravity.isVertical(lp.gravity)) {
230-
heightUsed += child.getMeasuredHeight() * 1.5f;
231-
} else if (Gravity.isHorizontal(lp.gravity)) {
232-
widthUsed += child.getMeasuredWidth() * 1.5f;
216+
if (height < squashedLayoutThreshold) {
217+
int zero = MeasureSpec.makeMeasureSpec(0, MeasureSpec.EXACTLY);
218+
measureChild(child, zero, zero);
219+
} else {
220+
int adjustedWidthSpec = widthSpec;
221+
int adjustedHeightSpec = heightSpec;
222+
if (lp.maxWidth >= 0) {
223+
adjustedWidthSpec = MeasureSpec.makeMeasureSpec(
224+
Math.min(lp.maxWidth, MeasureSpec.getSize(widthSpec)),
225+
MeasureSpec.EXACTLY);
226+
}
227+
if (lp.maxHeight >= 0) {
228+
adjustedHeightSpec = MeasureSpec.makeMeasureSpec(
229+
Math.min(lp.maxHeight, MeasureSpec.getSize(heightSpec)),
230+
MeasureSpec.EXACTLY);
231+
}
232+
// measureChildWithMargins will resolve layout direction for the LayoutParams
233+
measureChildWithMargins(child, adjustedWidthSpec, 0, adjustedHeightSpec, 0);
234+
235+
// Only subtract out space from one dimension. Favor vertical.
236+
// Offset by 1.5x to add some balance along the other edge.
237+
if (Gravity.isVertical(lp.gravity)) {
238+
heightUsed += child.getMeasuredHeight() * 1.5f;
239+
} else if (Gravity.isHorizontal(lp.gravity)) {
240+
widthUsed += child.getMeasuredWidth() * 1.5f;
241+
}
233242
}
234243
} else if (lp.childType == LayoutParams.CHILD_TYPE_SCRIM) {
235244
setScrimView(child);

0 commit comments

Comments
 (0)