Skip to content

Commit 68d257d

Browse files
author
Brian Colonna
committed
FUL uses square aspect ratio for all layouts fixes b/7426399
When the referenced bug was filed, face unlock was only showing as a tiny sliver on tablet layouts. Due to other changes in the lockscreen branch, it was no longer a sliver, but was still an incorrect layout, with a width much greater than height. This change makes face unlock square for all layouts. The face unlock RelativeLayout was replaced with a custom FaceUnlockView derived from RelativeLayout. The new view forces a square layout using the same technique used by LockPatternView. Note that there is still a bug where the pattern view covers the widget area on portrait tablet layouts. The face unlock view has this same issue, but may resolve itself when the pattern bug is fixed. Also note there are two other Face Unlock tablet bugs that existed before this change (and therefore are not caused by this change): - flash during transition from spotlight animation to camera preview - PIN backup is upper-left instead of centered Change-Id: I550eccfa3924f230a9dc43f0a9b59f1ea55a9273
1 parent 70aa528 commit 68d257d

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.internal.widget;
18+
19+
import android.content.Context;
20+
import android.util.AttributeSet;
21+
import android.util.Log;
22+
import android.view.View;
23+
import android.widget.RelativeLayout;
24+
25+
public class FaceUnlockView extends RelativeLayout {
26+
private static final String TAG = "FaceUnlockView";
27+
28+
public FaceUnlockView(Context context) {
29+
this(context, null);
30+
}
31+
32+
public FaceUnlockView(Context context, AttributeSet attrs) {
33+
super(context, attrs);
34+
}
35+
36+
private int resolveMeasured(int measureSpec, int desired)
37+
{
38+
int result = 0;
39+
int specSize = MeasureSpec.getSize(measureSpec);
40+
switch (MeasureSpec.getMode(measureSpec)) {
41+
case MeasureSpec.UNSPECIFIED:
42+
result = desired;
43+
break;
44+
case MeasureSpec.AT_MOST:
45+
result = Math.max(specSize, desired);
46+
break;
47+
case MeasureSpec.EXACTLY:
48+
default:
49+
result = specSize;
50+
}
51+
return result;
52+
}
53+
54+
@Override
55+
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
56+
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
57+
58+
final int minimumWidth = getSuggestedMinimumWidth();
59+
final int minimumHeight = getSuggestedMinimumHeight();
60+
int viewWidth = resolveMeasured(widthMeasureSpec, minimumWidth);
61+
int viewHeight = resolveMeasured(heightMeasureSpec, minimumHeight);
62+
63+
viewWidth = viewHeight = Math.min(viewWidth, viewHeight);
64+
Log.v(TAG, "FaceUnlockView dimensions: " + viewWidth + "x" + viewHeight);
65+
setMeasuredDimension(viewWidth, viewHeight);
66+
}
67+
}

core/res/res/layout/keyguard_face_unlock_view.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
android:layout_height="wrap_content"
3131
/>
3232

33-
<RelativeLayout
33+
<com.android.internal.widget.FaceUnlockView
3434
android:id="@+id/face_unlock_area_view"
3535
android:layout_width="match_parent"
36-
android:layout_height="@*android:dimen/face_unlock_height"
36+
android:layout_height="0dp"
3737
android:background="@*android:drawable/intro_bg"
3838
android:gravity="center"
3939
android:layout_weight="1">
@@ -55,8 +55,7 @@
5555
android:background="#00000000"
5656
android:src="@*android:drawable/ic_facial_backup"
5757
/>
58-
59-
</RelativeLayout>
58+
</com.android.internal.widget.FaceUnlockView>
6059

6160
<include layout="@layout/keyguard_emergency_carrier_area"
6261
android:id="@+id/keyguard_selector_fade_container"

0 commit comments

Comments
 (0)