Home | History | Annotate | Download | only in tablet
      1 /*
      2  * Copyright (C) 2010 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.systemui.statusbar.tablet;
     18 
     19 import android.animation.Animator;
     20 import android.animation.ObjectAnimator;
     21 import android.animation.ValueAnimator;
     22 import android.content.Context;
     23 import android.content.res.Resources;
     24 import android.content.res.TypedArray;
     25 import android.graphics.Canvas;
     26 import android.graphics.Rect;
     27 import android.graphics.drawable.Drawable;
     28 import android.util.AttributeSet;
     29 import android.util.Slog;
     30 import android.view.LayoutInflater;
     31 import android.view.View;
     32 import android.view.ViewGroup;
     33 import android.view.animation.AccelerateInterpolator;
     34 import android.widget.FrameLayout;
     35 import android.widget.ImageView;
     36 import android.widget.LinearLayout;
     37 import android.widget.TextView;
     38 
     39 import com.android.systemui.R;
     40 
     41 public class NotificationLinearLayout extends LinearLayout {
     42     private static final String TAG = "NotificationLinearLayout";
     43 
     44     Drawable mItemGlow;
     45     int mInsetLeft;
     46     Rect mTmp = new Rect();
     47 
     48     public NotificationLinearLayout(Context context, AttributeSet attrs) {
     49         this(context, attrs, 0);
     50     }
     51 
     52     public NotificationLinearLayout(Context context, AttributeSet attrs, int defStyle) {
     53         super(context, attrs, defStyle);
     54 
     55         final Resources res = context.getResources();
     56 
     57         mItemGlow = res.getDrawable(R.drawable.notify_item_glow_bottom);
     58 
     59         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NotificationLinearLayout,
     60                 defStyle, 0);
     61         mInsetLeft = a.getDimensionPixelSize(R.styleable.NotificationLinearLayout_insetLeft, 0);
     62         a.recycle();
     63     }
     64 
     65     @Override
     66     public void onFinishInflate() {
     67         super.onFinishInflate();
     68         setWillNotDraw(false);
     69     }
     70 
     71     @Override
     72     public void onDraw(Canvas canvas) {
     73         super.onDraw(canvas);
     74 
     75         final Rect padding = mTmp;
     76         final Drawable glow = mItemGlow;
     77         glow.getPadding(padding);
     78         final int glowHeight = glow.getIntrinsicHeight();
     79         final int insetLeft = mInsetLeft;
     80 
     81         final int N = getChildCount();
     82         for (int i=0; i<N; i++) {
     83             final View child = getChildAt(i);
     84 
     85             final int childBottom = child.getBottom();
     86 
     87             glow.setBounds(child.getLeft() - padding.left + insetLeft, childBottom,
     88                     child.getRight() - padding.right, childBottom + glowHeight);
     89             glow.draw(canvas);
     90         }
     91     }
     92 }
     93