FileDocCategorySizeDatePackage
StatusBarView.javaAPI DocAndroid 1.5 API4120Wed May 06 22:42:00 BST 2009com.android.server.status

StatusBarView

public class StatusBarView extends android.widget.FrameLayout

Fields Summary
private static final String
TAG
StatusBarService
mService
boolean
mTracking
int
mStartX
int
mStartY
android.view.ViewGroup
mNotificationIcons
android.view.ViewGroup
mStatusIcons
android.view.View
mDate
FixedSizeDrawable
mBackground
Constructors Summary
public StatusBarView(android.content.Context context, android.util.AttributeSet attrs)


         
        super(context, attrs);
    
Methods Summary
private intgetDateSize(android.view.ViewGroup g, int w, int offset)

        final int N = g.getChildCount();
        for (int i=0; i<N; i++) {
            View v = g.getChildAt(i);
            int l = v.getLeft() + offset;
            int r = v.getRight() + offset;
            if (w >= l && w <= r) {
                return r;
            }
        }
        return -1;
    
private intgetViewOffset(android.view.View v)
Gets the left position of v in this view. Throws if v is not a child of this.

        int offset = 0;
        while (v != this) {
            offset += v.getLeft();
            ViewParent p = v.getParent();
            if (v instanceof View) {
                v = (View)p;
            } else {
                throw new RuntimeException(v + " is not a child of " + this);
            }
        }
        return offset;
    
protected voidonAttachedToWindow()

        super.onAttachedToWindow();
        mService.onBarViewAttached();
    
protected voidonFinishInflate()

        super.onFinishInflate();
        mNotificationIcons = (ViewGroup)findViewById(R.id.notificationIcons);
        mStatusIcons = (ViewGroup)findViewById(R.id.statusIcons);
        mDate = findViewById(R.id.date);

        mBackground = new FixedSizeDrawable(mDate.getBackground());
        mBackground.setFixedBounds(0, 0, 0, 0);
        mDate.setBackgroundDrawable(mBackground);
    
public booleanonInterceptTouchEvent(android.view.MotionEvent event)

        return mService.interceptTouchEvent(event)
                ? true : super.onInterceptTouchEvent(event);
    
protected voidonLayout(boolean changed, int l, int t, int r, int b)

        super.onLayout(changed, l, t, r, b);

        // put the date date view quantized to the icons
        int oldDateRight = mDate.getRight();
        int newDateRight;

        newDateRight = getDateSize(mNotificationIcons, oldDateRight,
                getViewOffset(mNotificationIcons));
        if (newDateRight < 0) {
            int offset = getViewOffset(mStatusIcons);
            if (oldDateRight < offset) {
                newDateRight = oldDateRight;
            } else {
                newDateRight = getDateSize(mStatusIcons, oldDateRight, offset);
                if (newDateRight < 0) {
                    newDateRight = r;
                }
            }
        }
        int max = r - getPaddingRight();
        if (newDateRight > max) {
            newDateRight = max;
        }

        mDate.layout(mDate.getLeft(), mDate.getTop(), newDateRight, mDate.getBottom());
        mBackground.setFixedBounds(-mDate.getLeft(), -mDate.getTop(), (r-l), (b-t));
    
protected voidonSizeChanged(int w, int h, int oldw, int oldh)

        super.onSizeChanged(w, h, oldw, oldh);
        mService.updateExpandedViewPos(StatusBarService.EXPANDED_LEAVE_ALONE);
    
public booleanonTouchEvent(android.view.MotionEvent event)
Ensure that, if there is no target under us to receive the touch, that we process it ourself. This makes sure that onInterceptTouchEvent() is always called for the entire gesture.

        if (event.getAction() != MotionEvent.ACTION_DOWN) {
            mService.interceptTouchEvent(event);
        }
        return true;