1818import android .content .Context ;
1919import android .util .AttributeSet ;
2020import android .view .View ;
21- import android .view .View .OnClickListener ;
2221import android .widget .LinearLayout ;
2322
2423import com .android .internal .R ;
24+ import com .android .internal .policy .impl .keyguard .PagedView .PageSwitchListener ;
2525
26- public class KeyguardWidgetRegion extends LinearLayout {
26+ public class KeyguardWidgetRegion extends LinearLayout implements PageSwitchListener {
2727 KeyguardGlowStripView mLeftStrip ;
2828 KeyguardGlowStripView mRightStrip ;
2929 KeyguardWidgetPager mPager ;
30+ private int mPage = 0 ;
3031
3132 public KeyguardWidgetRegion (Context context ) {
3233 this (context , null , 0 );
@@ -46,6 +47,7 @@ protected void onFinishInflate() {
4647 mLeftStrip = (KeyguardGlowStripView ) findViewById (R .id .left_strip );
4748 mRightStrip = (KeyguardGlowStripView ) findViewById (R .id .right_strip );
4849 mPager = (KeyguardWidgetPager ) findViewById (R .id .app_widget_container );
50+ mPager .setPageSwitchListener (this );
4951
5052 setSoundEffectsEnabled (false );
5153 setOnClickListener (new OnClickListener () {
@@ -57,7 +59,16 @@ public void onClick(View v) {
5759 }
5860
5961 public void showPagingFeedback () {
60- mLeftStrip .makeEmGo ();
61- mRightStrip .makeEmGo ();
62+ if (mPage < mPager .getPageCount () - 1 ) {
63+ mLeftStrip .makeEmGo ();
64+ }
65+ if (mPage > 0 ) {
66+ mRightStrip .makeEmGo ();
67+ }
68+ }
69+
70+ @ Override
71+ public void onPageSwitch (View newPage , int newPageIndex ) {
72+ mPage = newPageIndex ;
6273 }
6374}
0 commit comments