Skip to content

Commit b07e89f

Browse files
Adam CohenAndroid (Google) Code Review
authored andcommitted
Merge "Integrate overscroll into KeyguardWidgetView." into jb-mr1-dev
2 parents 694121c + f2dfc35 commit b07e89f

File tree

10 files changed

+226
-93
lines changed

10 files changed

+226
-93
lines changed
2.16 KB
Loading
1.42 KB
Loading

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

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

29-
<com.android.internal.policy.impl.keyguard.KeyguardWidgetView
29+
<com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
3030
android:id="@+id/app_widget_container"
3131
android:layout_width="0dip"
3232
android:layout_height="match_parent"
@@ -35,8 +35,8 @@
3535

3636
<!-- TODO: Remove this once supported as a widget -->
3737
<include layout="@layout/keyguard_status_view"/>
38+
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
3839

39-
</com.android.internal.policy.impl.keyguard.KeyguardWidgetView>
4040

4141
<ViewFlipper
4242
android:id="@+id/view_flipper"

core/res/res/layout/keyguard_selector_view.xml

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

29-
<com.android.internal.policy.impl.keyguard.KeyguardWidgetView
29+
<com.android.internal.policy.impl.keyguard.KeyguardWidgetPager
3030
android:id="@+id/app_widget_container"
3131
android:layout_width="match_parent"
3232
android:layout_height="0dip"
3333
android:layout_weight="1"
3434
android:visibility="gone">
3535
<!-- TODO: Remove this once supported as a widget -->
3636
<include layout="@layout/keyguard_status_view"/>
37-
</com.android.internal.policy.impl.keyguard.KeyguardWidgetView>
37+
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
3838

3939
<RelativeLayout
4040
android:layout_width="wrap_content"

core/res/res/layout/keyguard_status_view.xml

Lines changed: 75 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,97 +18,102 @@
1818
-->
1919

2020
<!-- This is a view that shows general status information in Keyguard. -->
21-
<com.android.internal.policy.impl.keyguard.KeyguardStatusView
21+
<com.android.internal.policy.impl.keyguard.KeyguardWidgetFrame
2222
xmlns:android="http://schemas.android.com/apk/res/android"
23-
android:orientation="vertical"
2423
android:layout_width="wrap_content"
2524
android:layout_height="wrap_content"
2625
android:gravity="center_horizontal">
2726

28-
<com.android.internal.widget.DigitalClock android:id="@+id/time"
29-
android:layout_marginTop="@*android:dimen/keyguard_lockscreen_status_line_clockfont_top_margin"
30-
android:layout_marginBottom="12dip"
31-
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin"
32-
android:layout_gravity="end">
27+
<com.android.internal.policy.impl.keyguard.KeyguardStatusView
28+
android:orientation="vertical"
29+
android:layout_width="match_parent"
30+
android:layout_height="match_parent"
31+
android:gravity="center_horizontal">
3332

34-
<!-- Because we can't have multi-tone fonts, we render two TextViews, one on
35-
top of the other. Hence the redundant layout... -->
36-
<TextView android:id="@*android:id/timeDisplayBackground"
37-
android:layout_width="wrap_content"
38-
android:layout_height="wrap_content"
39-
android:singleLine="true"
40-
android:ellipsize="none"
41-
android:textSize="@*android:dimen/keyguard_lockscreen_clock_font_size"
42-
android:textAppearance="?android:attr/textAppearanceMedium"
43-
android:layout_marginBottom="6dip"
44-
android:textColor="@*android:color/lockscreen_clock_background"
45-
/>
33+
<com.android.internal.widget.DigitalClock android:id="@+id/time"
34+
android:layout_marginTop="@*android:dimen/keyguard_lockscreen_status_line_clockfont_top_margin"
35+
android:layout_marginBottom="12dip"
36+
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin"
37+
android:layout_gravity="end">
4638

47-
<TextView android:id="@*android:id/timeDisplayForeground"
48-
android:layout_width="wrap_content"
49-
android:layout_height="wrap_content"
50-
android:singleLine="true"
51-
android:ellipsize="none"
52-
android:textSize="@*android:dimen/keyguard_lockscreen_clock_font_size"
53-
android:textAppearance="?android:attr/textAppearanceMedium"
54-
android:layout_marginBottom="6dip"
55-
android:textColor="@*android:color/lockscreen_clock_foreground"
56-
android:layout_alignStart="@*android:id/timeDisplayBackground"
57-
android:layout_alignTop="@*android:id/timeDisplayBackground"
58-
/>
39+
<!-- Because we can't have multi-tone fonts, we render two TextViews, one on
40+
top of the other. Hence the redundant layout... -->
41+
<TextView android:id="@*android:id/timeDisplayBackground"
42+
android:layout_width="wrap_content"
43+
android:layout_height="wrap_content"
44+
android:singleLine="true"
45+
android:ellipsize="none"
46+
android:textSize="@*android:dimen/keyguard_lockscreen_clock_font_size"
47+
android:textAppearance="?android:attr/textAppearanceMedium"
48+
android:layout_marginBottom="6dip"
49+
android:textColor="@*android:color/lockscreen_clock_background"
50+
/>
51+
52+
<TextView android:id="@*android:id/timeDisplayForeground"
53+
android:layout_width="wrap_content"
54+
android:layout_height="wrap_content"
55+
android:singleLine="true"
56+
android:ellipsize="none"
57+
android:textSize="@*android:dimen/keyguard_lockscreen_clock_font_size"
58+
android:textAppearance="?android:attr/textAppearanceMedium"
59+
android:layout_marginBottom="6dip"
60+
android:textColor="@*android:color/lockscreen_clock_foreground"
61+
android:layout_alignStart="@*android:id/timeDisplayBackground"
62+
android:layout_alignTop="@*android:id/timeDisplayBackground"
63+
/>
64+
65+
</com.android.internal.widget.DigitalClock>
5966

60-
</com.android.internal.widget.DigitalClock>
67+
<LinearLayout
68+
android:orientation="horizontal"
69+
android:layout_gravity="end"
70+
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin">
6171

62-
<LinearLayout
63-
android:orientation="horizontal"
64-
android:layout_gravity="end"
65-
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin">
72+
<TextView
73+
android:id="@*android:id/date"
74+
android:layout_width="wrap_content"
75+
android:layout_height="wrap_content"
76+
android:singleLine="true"
77+
android:ellipsize="marquee"
78+
android:textAppearance="?android:attr/textAppearanceMedium"
79+
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
80+
/>
81+
82+
<TextView
83+
android:id="@*android:id/alarm_status"
84+
android:layout_width="wrap_content"
85+
android:layout_height="wrap_content"
86+
android:layout_marginStart="16dip"
87+
android:singleLine="true"
88+
android:ellipsize="marquee"
89+
android:textAppearance="?android:attr/textAppearanceMedium"
90+
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
91+
android:drawablePadding="4dip"
92+
/>
93+
94+
</LinearLayout>
6695

6796
<TextView
68-
android:id="@*android:id/date"
69-
android:layout_width="wrap_content"
70-
android:layout_height="wrap_content"
97+
android:id="@*android:id/status1"
98+
android:layout_gravity="end"
99+
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin"
71100
android:singleLine="true"
72101
android:ellipsize="marquee"
73102
android:textAppearance="?android:attr/textAppearanceMedium"
74103
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
104+
android:drawablePadding="4dip"
75105
/>
76106

77107
<TextView
78-
android:id="@*android:id/alarm_status"
79-
android:layout_width="wrap_content"
80-
android:layout_height="wrap_content"
81-
android:layout_marginStart="16dip"
108+
android:id="@*android:id/carrier"
109+
android:layout_gravity="end"
110+
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin"
82111
android:singleLine="true"
83112
android:ellipsize="marquee"
84113
android:textAppearance="?android:attr/textAppearanceMedium"
85114
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
86-
android:drawablePadding="4dip"
115+
android:textColor="?android:attr/textColorSecondary"
87116
/>
88117

89-
</LinearLayout>
90-
91-
<TextView
92-
android:id="@*android:id/status1"
93-
android:layout_gravity="end"
94-
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin"
95-
android:singleLine="true"
96-
android:ellipsize="marquee"
97-
android:textAppearance="?android:attr/textAppearanceMedium"
98-
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
99-
android:drawablePadding="4dip"
100-
/>
101-
102-
<TextView
103-
android:id="@*android:id/carrier"
104-
android:layout_gravity="end"
105-
android:layout_marginEnd="@*android:dimen/keyguard_lockscreen_status_line_font_right_margin"
106-
android:singleLine="true"
107-
android:ellipsize="marquee"
108-
android:textAppearance="?android:attr/textAppearanceMedium"
109-
android:textSize="@*android:dimen/keyguard_lockscreen_status_line_font_size"
110-
android:textColor="?android:attr/textColorSecondary"
111-
/>
112-
113-
</com.android.internal.policy.impl.keyguard.KeyguardStatusView>
114-
118+
</com.android.internal.policy.impl.keyguard.KeyguardStatusView>
119+
</com.android.internal.policy.impl.keyguard.KeyguardWidgetFrame>

core/res/res/values/dimens.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,6 @@
251251
<!-- Height of widget view in keyguard. -->
252252
<dimen name="kg_widget_view_height">0dp</dimen>
253253

254+
<!-- Padding surrounding each widget page -->
255+
<dimen name="kg_widget_page_padding">10dp</dimen>
254256
</resources>

core/res/res/values/public.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@
12371237
<java-symbol type="dimen" name="navigation_bar_height_landscape" />
12381238
<java-symbol type="dimen" name="navigation_bar_width" />
12391239
<java-symbol type="dimen" name="status_bar_height" />
1240+
<java-symbol type="dimen" name="kg_widget_page_padding" />
12401241
<java-symbol type="drawable" name="ic_jog_dial_sound_off" />
12411242
<java-symbol type="drawable" name="ic_jog_dial_sound_on" />
12421243
<java-symbol type="drawable" name="ic_jog_dial_unlock" />
@@ -1254,6 +1255,8 @@
12541255
<java-symbol type="drawable" name="jog_tab_target_yellow" />
12551256
<java-symbol type="drawable" name="menu_background" />
12561257
<java-symbol type="drawable" name="stat_sys_secure" />
1258+
<java-symbol type="drawable" name="kg_widget_overscroll_layer_left" />
1259+
<java-symbol type="drawable" name="kg_widget_overscroll_layer_right" />
12571260
<java-symbol type="id" name="action_mode_bar_stub" />
12581261
<java-symbol type="id" name="alarm_status" />
12591262
<java-symbol type="id" name="backspace" />
@@ -3749,5 +3752,5 @@
37493752
<public type="attr" name="listPreferredItemPaddingStart" />
37503753
<public type="attr" name="listPreferredItemPaddingEnd" />
37513754
<public type="attr" name="singleUser" />
3752-
3755+
37533756
</resources>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class KeyguardHostView extends KeyguardViewBase {
7070
private static final int SECURITY_ACCOUNT_ID = R.id.keyguard_account_view;
7171

7272
private AppWidgetHost mAppWidgetHost;
73-
private ViewGroup mAppWidgetContainer;
73+
private KeyguardWidgetPager mAppWidgetContainer;
7474
private ViewFlipper mViewFlipper;
7575
private Button mEmergencyDialerButton;
7676
private boolean mEnableMenuKey;
@@ -121,7 +121,7 @@ protected void dispatchDraw(Canvas canvas) {
121121

122122
@Override
123123
protected void onFinishInflate() {
124-
mAppWidgetContainer = (ViewGroup) findViewById(R.id.app_widget_container);
124+
mAppWidgetContainer = (KeyguardWidgetPager) findViewById(R.id.app_widget_container);
125125
mAppWidgetContainer.setVisibility(VISIBLE);
126126

127127
// View Flipper
@@ -182,7 +182,7 @@ AppWidgetHost getAppWidgetHost() {
182182
}
183183

184184
void addWidget(AppWidgetHostView view) {
185-
mAppWidgetContainer.addView(view);
185+
mAppWidgetContainer.addWidget(view);
186186
}
187187

188188
private KeyguardSecurityCallback mCallback = new KeyguardSecurityCallback() {
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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.content.res.Resources;
21+
import android.graphics.Canvas;
22+
import android.graphics.Paint;
23+
import android.graphics.PorterDuff;
24+
import android.graphics.PorterDuffXfermode;
25+
import android.graphics.Rect;
26+
import android.graphics.drawable.Drawable;
27+
import android.graphics.drawable.NinePatchDrawable;
28+
import android.util.AttributeSet;
29+
import android.widget.FrameLayout;
30+
31+
import com.android.internal.R;
32+
33+
public class KeyguardWidgetFrame extends FrameLayout {
34+
private final static PorterDuffXfermode sAddBlendMode =
35+
new PorterDuffXfermode(PorterDuff.Mode.ADD);
36+
private static int sWidgetPagePadding;
37+
private static Drawable sLeftOverscrollDrawable;
38+
private static Drawable sRightOverscrollDrawable;
39+
40+
private Drawable mForegroundDrawable;
41+
private final Rect mForegroundRect = new Rect();
42+
private int mForegroundAlpha = 0;
43+
44+
public KeyguardWidgetFrame(Context context) {
45+
this(context, null, 0);
46+
}
47+
48+
public KeyguardWidgetFrame(Context context, AttributeSet attrs) {
49+
this(context, attrs, 0);
50+
}
51+
52+
public KeyguardWidgetFrame(Context context, AttributeSet attrs, int defStyle) {
53+
super(context, attrs, defStyle);
54+
if (sLeftOverscrollDrawable == null) {
55+
Resources res = context.getResources();
56+
sLeftOverscrollDrawable = res.getDrawable(
57+
com.android.internal.R.drawable.kg_widget_overscroll_layer_left);
58+
sRightOverscrollDrawable = res.getDrawable(
59+
com.android.internal.R.drawable.kg_widget_overscroll_layer_right);
60+
sWidgetPagePadding =
61+
res.getDimensionPixelSize(com.android.internal.R.dimen.kg_widget_page_padding);
62+
}
63+
setPadding(sWidgetPagePadding, sWidgetPagePadding, sWidgetPagePadding, sWidgetPagePadding);
64+
}
65+
66+
@Override
67+
protected void dispatchDraw(Canvas canvas) {
68+
super.dispatchDraw(canvas);
69+
if (mForegroundAlpha > 0) {
70+
mForegroundDrawable.setBounds(mForegroundRect);
71+
Paint p = ((NinePatchDrawable) mForegroundDrawable).getPaint();
72+
p.setXfermode(sAddBlendMode);
73+
mForegroundDrawable.draw(canvas);
74+
p.setXfermode(null);
75+
}
76+
}
77+
78+
@Override
79+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
80+
super.onSizeChanged(w, h, oldw, oldh);
81+
mForegroundRect.set(sWidgetPagePadding, sWidgetPagePadding,
82+
w - sWidgetPagePadding, h - sWidgetPagePadding);
83+
}
84+
85+
void setOverScrollAmount(float r, boolean left) {
86+
if (left && mForegroundDrawable != sLeftOverscrollDrawable) {
87+
mForegroundDrawable = sLeftOverscrollDrawable;
88+
} else if (!left && mForegroundDrawable != sRightOverscrollDrawable) {
89+
mForegroundDrawable = sRightOverscrollDrawable;
90+
}
91+
92+
mForegroundAlpha = (int) Math.round((r * 255));
93+
mForegroundDrawable.setAlpha(mForegroundAlpha);
94+
invalidate();
95+
}
96+
}

0 commit comments

Comments
 (0)