TrackingView.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
1package com.android.server.status; 2 3import android.content.Context; 4import android.util.AttributeSet; 5import android.view.Display; 6import android.view.KeyEvent; 7import android.view.WindowManager; 8import android.widget.LinearLayout; 9 10 11public class TrackingView extends LinearLayout { 12 final Display mDisplay; 13 StatusBarService mService; 14 boolean mTracking; 15 int mStartX, mStartY; 16 17 public TrackingView(Context context, AttributeSet attrs) { 18 super(context, attrs); 19 mDisplay = ((WindowManager)context.getSystemService( 20 Context.WINDOW_SERVICE)).getDefaultDisplay(); 21 } 22 23 @Override 24 protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 25 super.onLayout(changed, left, top, right, bottom); 26 mService.updateAvailableHeight(); 27 } 28 29 @Override 30 public boolean dispatchKeyEvent(KeyEvent event) { 31 boolean down = event.getAction() == KeyEvent.ACTION_DOWN; 32 switch (event.getKeyCode()) { 33 case KeyEvent.KEYCODE_BACK: 34 if (down) { 35 mService.deactivate(); 36 } 37 return true; 38 } 39 return super.dispatchKeyEvent(event); 40 } 41 42 @Override 43 protected void onAttachedToWindow() { 44 super.onAttachedToWindow(); 45 mService.onTrackingViewAttached(); 46 } 47} 48