Skip to content

Commit 0ca9723

Browse files
Brian ColonnaAndroid (Google) Code Review
authored andcommitted
Merge "FUL uses square aspect ratio for all layouts fixes b/7426399" into jb-mr1-lockscreen-dev
2 parents 1863738 + 68d257d commit 0ca9723

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)