Skip to content

Commit eeabf94

Browse files
Jim MillerAndroid (Google) Code Review
authored andcommitted
Merge "Allow pattern to start from outside pattern view" into jb-mr1-dev
2 parents 5bf7800 + 5737534 commit eeabf94

File tree

9 files changed

+122
-51
lines changed

9 files changed

+122
-51
lines changed

core/res/res/layout-land/keyguard_host_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
3939

4040

41-
<ViewFlipper
41+
<com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
4242
android:id="@+id/view_flipper"
4343
android:layout_width="0dip"
4444
android:layout_height="match_parent"
@@ -48,6 +48,6 @@
4848
<!-- SelectorView is always used, so add it here. The rest are loaded dynamically -->
4949
<include layout="@layout/keyguard_selector_view"/>
5050

51-
</ViewFlipper>
51+
</com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper>
5252

5353
</com.android.internal.policy.impl.keyguard.KeyguardHostView>

core/res/res/layout-port/keyguard_host_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
android:gravity="center_horizontal"
2929
android:clipChildren="false">
3030

31-
<ViewFlipper
31+
<com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
3232
android:id="@+id/view_flipper"
3333
android:layout_height="match_parent"
3434
android:gravity="center">
3535

3636
<!-- SelectorView is always used, so add it here. The rest are loaded dynamically -->
3737
<include layout="@layout/keyguard_selector_view"/>
3838

39-
</ViewFlipper>
39+
</com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper>
4040

4141
</com.android.internal.policy.impl.keyguard.KeyguardHostView>
4242

core/res/res/layout-sw600dp-land/keyguard_host_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
android:layout_weight="1"
4545
android:gravity="center">
4646

47-
<ViewFlipper
47+
<com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
4848
android:id="@+id/view_flipper"
4949
android:layout_width="@dimen/kg_security_view_width"
5050
android:layout_height="match_parent"
@@ -55,7 +55,7 @@
5555
<!-- SelectorView is always used, so add it here. The rest are loaded dynamically -->
5656
<include layout="@layout/keyguard_selector_view"/>
5757

58-
</ViewFlipper>
58+
</com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper>
5959

6060
</FrameLayout>
6161

core/res/res/layout-sw600dp-port/keyguard_host_view.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
4242

43-
<ViewFlipper
43+
<com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
4444
android:id="@+id/view_flipper"
4545
android:layout_width="@dimen/kg_security_view_width"
4646
android:layout_height="0dip"
@@ -50,7 +50,7 @@
5050
<!-- SelectorView is always used, so add it here. The rest are loaded dynamically -->
5151
<include layout="@layout/keyguard_selector_view"/>
5252

53-
</ViewFlipper>
53+
</com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper>
5454

5555
</com.android.internal.policy.impl.keyguard.KeyguardHostView>
5656

core/res/res/layout/keyguard_pattern_view.xml

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,36 @@
2323
<com.android.internal.policy.impl.keyguard.KeyguardPatternView
2424
xmlns:android="http://schemas.android.com/apk/res/android"
2525
android:id="@+id/keyguard_pattern_view"
26+
android:orientation="vertical"
2627
android:layout_width="match_parent"
27-
android:layout_height="match_parent">
28-
29-
<GridLayout
30-
android:orientation="vertical"
28+
android:layout_height="match_parent"
29+
android:gravity="center_horizontal">
30+
31+
<include layout="@layout/keyguard_navigation"/>
32+
33+
<Space android:layout_gravity="fill" />
34+
35+
<Button android:id="@+id/forgot_password_button"
36+
android:layout_gravity="right"
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
40+
android:drawableLeft="@*android:drawable/lockscreen_forgot_password_button"
41+
android:drawablePadding="0dip"
42+
android:visibility="gone"/>
43+
44+
<!-- We need MATCH_PARENT here only to force the size of the parent to be passed to
45+
the pattern view for it to compute its size. This is an unusual case, caused by
46+
LockPatternView's requirement to maintain a square aspect ratio based on the width
47+
of the screen. -->
48+
<com.android.internal.widget.LockPatternView
49+
android:id="@+id/lockPatternView"
3150
android:layout_width="match_parent"
3251
android:layout_height="match_parent"
33-
android:gravity="center_horizontal">
34-
35-
<include layout="@layout/keyguard_navigation"/>
36-
37-
<Space android:layout_gravity="fill" />
38-
39-
<Button android:id="@+id/forgot_password_button"
40-
android:layout_gravity="right"
41-
android:layout_width="wrap_content"
42-
android:layout_height="wrap_content"
43-
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
44-
android:drawableLeft="@*android:drawable/lockscreen_forgot_password_button"
45-
android:drawablePadding="0dip"
46-
android:visibility="gone"/>
47-
48-
<!-- We need MATCH_PARENT here only to force the size of the parent to be passed to
49-
the pattern view for it to compute its size. This is an unusual case, caused by
50-
LockPatternView's requirement to maintain a square aspect ratio based on the width
51-
of the screen. -->
52-
<com.android.internal.widget.LockPatternView
53-
android:id="@+id/lockPatternView"
54-
android:layout_width="match_parent"
55-
android:layout_height="match_parent"
56-
android:layout_marginEnd="8dip"
57-
android:layout_marginBottom="4dip"
58-
android:layout_marginStart="8dip"
59-
android:layout_gravity="center_horizontal"
60-
/>
61-
62-
</GridLayout>
52+
android:layout_marginEnd="8dip"
53+
android:layout_marginBottom="4dip"
54+
android:layout_marginStart="8dip"
55+
android:layout_gravity="center_horizontal"
56+
/>
6357

6458
</com.android.internal.policy.impl.keyguard.KeyguardPatternView>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
import android.content.pm.UserInfo;
3333
import android.content.res.Resources;
3434
import android.graphics.Canvas;
35+
import android.graphics.Rect;
3536
import android.os.UserManager;
36-
import android.telephony.TelephonyManager;
3737
import android.util.AttributeSet;
3838
import android.util.Log;
3939
import android.util.Slog;
4040
import android.view.KeyEvent;
4141
import android.view.LayoutInflater;
42+
import android.view.MotionEvent;
4243
import android.view.View;
4344
import android.view.WindowManager;
4445
import android.view.animation.AnimationUtils;
45-
import android.widget.Button;
4646
import android.widget.RemoteViews.OnClickHandler;
4747
import android.widget.ViewFlipper;
4848

@@ -51,7 +51,6 @@
5151
import com.android.internal.widget.LockPatternUtils;
5252

5353
import java.io.File;
54-
import java.util.ArrayList;
5554
import java.util.List;
5655

5756
public class KeyguardHostView extends KeyguardViewBase {
@@ -77,6 +76,8 @@ public class KeyguardHostView extends KeyguardViewBase {
7776

7877
private KeyguardSecurityModel mSecurityModel;
7978

79+
private Rect mTempRect = new Rect();
80+
8081
public KeyguardHostView(Context context) {
8182
this(context, null);
8283
}
@@ -93,6 +94,17 @@ public KeyguardHostView(Context context, AttributeSet attrs) {
9394
setFocusableInTouchMode(true);
9495
}
9596

97+
@Override
98+
public boolean dispatchTouchEvent(MotionEvent ev) {
99+
boolean result = super.dispatchTouchEvent(ev);
100+
mTempRect.set(0, 0, 0, 0);
101+
offsetRectIntoDescendantCoords(mSecurityViewContainer, mTempRect);
102+
ev.offsetLocation(mTempRect.left, mTempRect.top);
103+
result = mSecurityViewContainer.dispatchTouchEvent(ev) || result;
104+
ev.offsetLocation(-mTempRect.left, -mTempRect.top);
105+
return result;
106+
}
107+
96108
@Override
97109
protected void dispatchDraw(Canvas canvas) {
98110
super.dispatchDraw(canvas);

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.accounts.AuthenticatorException;
2323
import android.accounts.OperationCanceledException;
2424
import android.content.Context;
25+
import android.graphics.Rect;
2526
import android.os.Bundle;
2627
import android.os.CountDownTimer;
2728
import android.os.SystemClock;
@@ -31,7 +32,7 @@
3132
import android.view.MotionEvent;
3233
import android.view.View;
3334
import android.widget.Button;
34-
import android.widget.LinearLayout;
35+
import android.widget.GridLayout;
3536

3637
import com.android.internal.widget.LockPatternUtils;
3738
import com.android.internal.widget.LockPatternView;
@@ -40,7 +41,7 @@
4041
import java.io.IOException;
4142
import java.util.List;
4243

43-
public class KeyguardPatternView extends LinearLayout implements KeyguardSecurityView {
44+
public class KeyguardPatternView extends GridLayout implements KeyguardSecurityView {
4445

4546
private static final String TAG = "SecurityPatternView";
4647
private static final boolean DEBUG = false;
@@ -83,6 +84,7 @@ public void run() {
8384
mLockPatternView.clearPattern();
8485
}
8586
};
87+
private Rect mTempRect = new Rect();
8688

8789
enum FooterMode {
8890
Normal,
@@ -156,13 +158,18 @@ private void updateFooter(FooterMode mode) {
156158

157159
@Override
158160
public boolean dispatchTouchEvent(MotionEvent ev) {
159-
final boolean result = super.dispatchTouchEvent(ev);
161+
boolean result = super.dispatchTouchEvent(ev);
160162
// as long as the user is entering a pattern (i.e sending a touch event that was handled
161163
// by this screen), keep poking the wake lock so that the screen will stay on.
162164
final long elapsed = SystemClock.elapsedRealtime() - mLastPokeTime;
163165
if (result && (elapsed > (UNLOCK_PATTERN_WAKE_INTERVAL_MS - 100))) {
164166
mLastPokeTime = SystemClock.elapsedRealtime();
165167
}
168+
mTempRect.set(0, 0, 0, 0);
169+
offsetRectIntoDescendantCoords(mLockPatternView, mTempRect);
170+
ev.offsetLocation(mTempRect.left, mTempRect.top);
171+
result = mLockPatternView.dispatchTouchEvent(ev) || result;
172+
ev.offsetLocation(-mTempRect.left, -mTempRect.top);
166173
return result;
167174
}
168175

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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.policy.impl.keyguard;
18+
19+
import android.content.Context;
20+
import android.graphics.Rect;
21+
import android.util.AttributeSet;
22+
import android.view.MotionEvent;
23+
import android.view.View;
24+
import android.widget.ViewFlipper;
25+
26+
/**
27+
* Subclass of the current view flipper that allows us to overload dispatchTouchEvent() so
28+
* we can emulate {@link WindowManager.LayoutParams#FLAG_SLIPPERY} within a view hierarchy.
29+
*
30+
*/
31+
public class KeyguardSecurityViewFlipper extends ViewFlipper {
32+
private Rect mTempRect = new Rect();
33+
34+
public KeyguardSecurityViewFlipper(Context context) {
35+
this(context, null);
36+
}
37+
38+
public KeyguardSecurityViewFlipper(Context context, AttributeSet attr) {
39+
super(context, attr);
40+
}
41+
42+
@Override
43+
public boolean dispatchTouchEvent(MotionEvent ev) {
44+
boolean result = super.dispatchTouchEvent(ev);
45+
mTempRect.set(0, 0, 0, 0);
46+
for (int i = 0; i < getChildCount(); i++) {
47+
View child = getChildAt(i);
48+
if (child.getVisibility() == View.VISIBLE) {
49+
offsetRectIntoDescendantCoords(child, mTempRect);
50+
ev.offsetLocation(mTempRect.left, mTempRect.top);
51+
result = child.dispatchTouchEvent(ev) || result;
52+
ev.offsetLocation(-mTempRect.left, -mTempRect.top);
53+
}
54+
}
55+
return result;
56+
}
57+
58+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public class KeyguardUpdateMonitor {
7373
private static final int MSG_PHONE_STATE_CHANGED = 306;
7474
private static final int MSG_CLOCK_VISIBILITY_CHANGED = 307;
7575
private static final int MSG_DEVICE_PROVISIONED = 308;
76-
protected static final int MSG_DPM_STATE_CHANGED = 309;
77-
protected static final int MSG_USER_SWITCHED = 310;
78-
protected static final int MSG_USER_REMOVED = 311;
76+
private static final int MSG_DPM_STATE_CHANGED = 309;
77+
private static final int MSG_USER_SWITCHED = 310;
78+
private static final int MSG_USER_REMOVED = 311;
7979

8080
private static KeyguardUpdateMonitor sInstance;
8181

0 commit comments

Comments
 (0)