Skip to content

Commit c1aa6a5

Browse files
author
Jim Miller
committed
Integrate keyguard paging hint
Bug 7232481 Change-Id: I1959ae61b8f5afd055158dad67bdceecc4870d24
1 parent 1ed143e commit c1aa6a5

File tree

14 files changed

+302
-45
lines changed

14 files changed

+302
-45
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,10 @@
2727
android:gravity="center_vertical"
2828
android:orientation="horizontal">
2929

30-
<com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
31-
android:id="@+id/app_widget_container"
30+
<include layout="@layout/keyguard_widget_region"
3231
android:layout_width="0dip"
3332
android:layout_height="230dip"
34-
android:gravity="center"
35-
android:layout_weight=".45"
36-
android:visibility="gone">
37-
38-
<!-- TODO: Remove this once supported as a widget -->
39-
<include layout="@layout/keyguard_status_view"/>
40-
<include layout="@layout/keyguard_transport_control_view"/>
41-
42-
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
43-
33+
android:layout_weight=".45"/>
4434

4535
<com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
4636
android:id="@+id/view_flipper"

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,10 @@
2626
android:layout_height="match_parent"
2727
android:orientation="horizontal">
2828

29-
<com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
30-
android:id="@+id/app_widget_container"
29+
<include layout="@layout/keyguard_widget_region"
3130
android:layout_width="0dip"
3231
android:layout_height="match_parent"
33-
android:layout_weight="1"
34-
android:visibility="gone">
35-
36-
<!-- TODO: Remove this once supported as a widget -->
37-
<include layout="@layout/keyguard_status_view"/>
38-
<include layout="@layout/keyguard_transport_control_view"/>
39-
40-
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
32+
android:layout_weight="1"/>
4133

4234
<FrameLayout
4335
android:layout_width="0dip"

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,10 @@
2727
android:layout_height="match_parent"
2828
android:gravity="center_horizontal">
2929

30-
<com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
31-
android:id="@+id/app_widget_container"
30+
<include layout="@layout/keyguard_widget_region"
3231
android:layout_width="match_parent"
3332
android:layout_height="0dip"
34-
android:layout_weight="0.4"
35-
android:visibility="gone">
36-
37-
<!-- TODO: Remove this once supported as a widget -->
38-
<include layout="@layout/keyguard_status_view"/>
39-
<include layout="@layout/keyguard_transport_control_view"/>
40-
41-
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
33+
android:layout_weight="0.4"/>
4234

4335
<com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper
4436
android:id="@+id/view_flipper"

core/res/res/layout/keyguard_selector_view.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,13 @@
2626
android:layout_height="match_parent"
2727
android:orientation="vertical">
2828

29-
<com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
30-
android:id="@+id/app_widget_container"
29+
<include layout="@layout/keyguard_widget_region"
3130
android:layout_width="match_parent"
3231
android:layout_height="0dip"
3332
android:layout_weight="0.45"
3433
android:layout_marginTop="35dip"
3534
android:layout_marginLeft="33dip"
36-
android:layout_marginRight="33dip"
37-
android:visibility="gone">
38-
<!-- TODO: Remove this when supported as a widget -->
39-
<include layout="@layout/keyguard_status_view"/>
40-
<include layout="@layout/keyguard_transport_control_view"/>
41-
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
35+
android:layout_marginRight="33dip"/>
4236

4337
<RelativeLayout
4438
android:layout_width="wrap_content"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
**
4+
** Copyright 2012, The Android Open Source Project
5+
**
6+
** Licensed under the Apache License, Version 2.0 (the "License")
7+
** you may not use this file except in compliance with the License.
8+
** You may obtain a copy of the License at
9+
**
10+
** http://www.apache.org/licenses/LICENSE-2.0
11+
**
12+
** Unless required by applicable law or agreed to in writing, software
13+
** distributed under the License is distributed on an "AS IS" BASIS,
14+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
** See the License for the specific language governing permissions and
16+
** limitations under the License.
17+
*/
18+
-->
19+
20+
<!-- This is the selector widget that allows the user to select an action. -->
21+
<com.android.internal.policy.impl.keyguard.KeyguardWidgetRegion
22+
xmlns:prvandroid="http://schemas.android.com/apk/prv/res/android"
23+
xmlns:android="http://schemas.android.com/apk/res/android"
24+
android:id="@+id/kg_widget_region"
25+
android:visibility="gone"
26+
android:gravity="center"
27+
android:orientation="vertical">
28+
<Space
29+
android:layout_width="match_parent"
30+
android:layout_height="0dip"
31+
android:layout_weight="1" />
32+
<com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
33+
android:id="@+id/app_widget_container"
34+
android:layout_width="match_parent"
35+
android:layout_height="@dimen/kg_widget_container_height">
36+
<!-- TODO: Remove this when supported as a widget -->
37+
<include layout="@layout/keyguard_status_view"/>
38+
<include layout="@layout/keyguard_transport_control_view"/>
39+
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
40+
<LinearLayout
41+
android:layout_width="match_parent"
42+
android:layout_height="0dip"
43+
android:layout_weight="1"
44+
android:orientation="horizontal">
45+
<com.android.internal.policy.impl.keyguard.KeyguardGlowStripView
46+
android:id="@+id/left_strip"
47+
android:layout_width="0dip"
48+
android:layout_height="match_parent"
49+
android:layout_weight="1"
50+
prvandroid:numDots="5"
51+
prvandroid:dotSize="7dip"
52+
prvandroid:leftToRight="false"
53+
prvandroid:glowDot="@*android:drawable/ic_lockscreen_glowdot" />
54+
<Space
55+
android:layout_width="0dip"
56+
android:layout_height="match_parent"
57+
android:layout_weight="1"/>
58+
<com.android.internal.policy.impl.keyguard.KeyguardGlowStripView
59+
android:id="@+id/right_strip"
60+
android:layout_width="0dip"
61+
android:layout_height="match_parent"
62+
android:layout_weight="1"
63+
prvandroid:numDots="5"
64+
prvandroid:dotSize="7dip"
65+
prvandroid:leftToRight="true"
66+
prvandroid:glowDot="@*android:drawable/ic_lockscreen_glowdot" />
67+
</LinearLayout>
68+
</com.android.internal.policy.impl.keyguard.KeyguardWidgetRegion>

core/res/res/values/attrs.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5773,4 +5773,11 @@
57735773
<attr name="scrollIndicatorPaddingRight" format="dimension" />
57745774
</declare-styleable>
57755775

5776+
<declare-styleable name="KeyguardGlowStripView">
5777+
<attr name="dotSize" format="dimension" />
5778+
<attr name="numDots" format="integer" />
5779+
<attr name="glowDot" format="reference" />
5780+
<attr name="leftToRight" format="boolean" />
5781+
</declare-styleable>
5782+
57765783
</resources>

core/res/res/values/dimens.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@
285285
<!-- Space reserved at the bottom of secure views (pin/pattern/password/SIM pin/SIM puk) -->
286286
<dimen name="kg_secure_padding_height">46dp</dimen>
287287

288+
<!-- The height of the widget container -->
289+
<dimen name="kg_widget_container_height">200dp</dimen>
290+
288291
<!-- Touch slop for the global toggle accessibility gesture -->
289292
<dimen name="accessibility_touch_slop">80dip</dimen>
290293

core/res/res/values/symbols.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,7 @@
10751075
<java-symbol type="layout" name="notification_template_inbox" />
10761076
<java-symbol type="layout" name="keyguard_multi_user_avatar" />
10771077
<java-symbol type="layout" name="keyguard_multi_user_selector_widget" />
1078+
<java-symbol type="layout" name="keyguard_widget_region" />
10781079
<java-symbol type="layout" name="sms_short_code_confirmation_dialog" />
10791080

10801081
<java-symbol type="anim" name="slide_in_child_bottom" />
@@ -1283,6 +1284,10 @@
12831284
<java-symbol type="id" name="keyguard_users_grid" />
12841285
<java-symbol type="id" name="clock_text" />
12851286
<java-symbol type="id" name="clock_view" />
1287+
<java-symbol type="id" name="kg_widget_region" />
1288+
<java-symbol type="id" name="left_strip" />
1289+
<java-symbol type="id" name="right_strip" />
1290+
12861291
<java-symbol type="integer" name="config_carDockRotation" />
12871292
<java-symbol type="integer" name="config_defaultUiModeType" />
12881293
<java-symbol type="integer" name="config_deskDockRotation" />

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.lang.ref.WeakReference;
3434
import java.text.DateFormatSymbols;
3535
import java.util.Calendar;
36-
3736
import com.android.internal.R;
3837

3938
/**
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
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+
package com.android.internal.policy.impl.keyguard;
17+
18+
import android.animation.Animator;
19+
import android.animation.AnimatorListenerAdapter;
20+
import android.animation.ValueAnimator;
21+
import android.animation.ValueAnimator.AnimatorUpdateListener;
22+
import android.content.Context;
23+
import android.content.res.TypedArray;
24+
import android.graphics.Canvas;
25+
import android.graphics.drawable.Drawable;
26+
import android.util.AttributeSet;
27+
import android.view.animation.DecelerateInterpolator;
28+
import android.view.animation.Interpolator;
29+
import android.view.animation.LinearInterpolator;
30+
import android.widget.LinearLayout;
31+
32+
import com.android.internal.R;
33+
34+
/**
35+
* A layout which animates a strip of horizontal, pulsing dots on request. This is used
36+
* to indicate the presence of pages to the left / right.
37+
*/
38+
public class KeyguardGlowStripView extends LinearLayout {
39+
private static final int DURATION = 500;
40+
41+
private static final float SLIDING_WINDOW_SIZE = 0.4f;
42+
private int mDotStripTop;
43+
private int mHorizontalDotGap;
44+
45+
private int mDotSize;
46+
private int mNumDots;
47+
private Drawable mDotDrawable;
48+
private boolean mLeftToRight = true;
49+
50+
private float mAnimationProgress = 0f;
51+
private boolean mDrawDots = false;
52+
private ValueAnimator mAnimator;
53+
private Interpolator mDotAlphaInterpolator = new DecelerateInterpolator(0.5f);
54+
55+
public KeyguardGlowStripView(Context context) {
56+
this(context, null, 0);
57+
}
58+
59+
public KeyguardGlowStripView(Context context, AttributeSet attrs) {
60+
this(context, attrs, 0);
61+
}
62+
63+
public KeyguardGlowStripView(Context context, AttributeSet attrs, int defStyle) {
64+
super(context, attrs, defStyle);
65+
66+
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KeyguardGlowStripView);
67+
mDotSize = a.getDimensionPixelSize(R.styleable.KeyguardGlowStripView_dotSize, mDotSize);
68+
mNumDots = a.getInt(R.styleable.KeyguardGlowStripView_numDots, mNumDots);
69+
mDotDrawable = a.getDrawable(R.styleable.KeyguardGlowStripView_glowDot);
70+
mLeftToRight = a.getBoolean(R.styleable.KeyguardGlowStripView_leftToRight, mLeftToRight);
71+
}
72+
73+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
74+
int availableWidth = w - getPaddingLeft() - getPaddingRight();
75+
mHorizontalDotGap = (availableWidth - mDotSize * mNumDots) / (mNumDots - 1);
76+
mDotStripTop = getPaddingTop();
77+
invalidate();
78+
}
79+
80+
@Override
81+
protected void dispatchDraw(Canvas canvas) {
82+
super.dispatchDraw(canvas);
83+
84+
if (!mDrawDots) return;
85+
86+
int xOffset = getPaddingLeft();
87+
mDotDrawable.setBounds(0, 0, mDotSize, mDotSize);
88+
89+
for (int i = 0; i < mNumDots; i++) {
90+
// We fudge the relative position to provide a fade in of the first dot and a fade
91+
// out of the final dot.
92+
float relativeDotPosition = SLIDING_WINDOW_SIZE / 2 + ((1.0f * i) / (mNumDots - 1)) *
93+
(1 - SLIDING_WINDOW_SIZE);
94+
float distance = Math.abs(relativeDotPosition - mAnimationProgress);
95+
float alpha = Math.max(0, 1 - distance / (SLIDING_WINDOW_SIZE / 2));
96+
97+
alpha = mDotAlphaInterpolator.getInterpolation(alpha);
98+
99+
canvas.save();
100+
canvas.translate(xOffset, mDotStripTop);
101+
mDotDrawable.setAlpha((int) (alpha * 255));
102+
mDotDrawable.draw(canvas);
103+
canvas.restore();
104+
xOffset += mDotSize + mHorizontalDotGap;
105+
}
106+
}
107+
108+
public void makeEmGo() {
109+
if (mAnimator != null) {
110+
mAnimator.cancel();
111+
}
112+
float from = mLeftToRight ? 0f : 1f;
113+
float to = mLeftToRight ? 1f : 0f;
114+
mAnimator = ValueAnimator.ofFloat(from, to);
115+
mAnimator.setDuration(DURATION);
116+
mAnimator.setInterpolator(new LinearInterpolator());
117+
mAnimator.addListener(new AnimatorListenerAdapter() {
118+
@Override
119+
public void onAnimationEnd(Animator animation) {
120+
mDrawDots = false;
121+
// make sure we draw one frame at the end with everything gone.
122+
invalidate();
123+
}
124+
125+
@Override
126+
public void onAnimationStart(Animator animation) {
127+
mDrawDots = true;
128+
}
129+
});
130+
mAnimator.addUpdateListener(new AnimatorUpdateListener() {
131+
@Override
132+
public void onAnimationUpdate(ValueAnimator animation) {
133+
mAnimationProgress = (Float) animation.getAnimatedValue();
134+
invalidate();
135+
}
136+
});
137+
mAnimator.start();
138+
}
139+
}

0 commit comments

Comments
 (0)