• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.systemui.statusbar.phone;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 import android.util.EventLog;
22 import android.view.MotionEvent;
23 import android.widget.FrameLayout;
24 
25 import com.android.systemui.EventLogTags;
26 
27 public class PanelHolder extends FrameLayout {
28     public static final boolean DEBUG_GESTURES = true;
29 
30     private int mSelectedPanelIndex = -1;
31     private PanelBar mBar;
32 
PanelHolder(Context context, AttributeSet attrs)33     public PanelHolder(Context context, AttributeSet attrs) {
34         super(context, attrs);
35         setChildrenDrawingOrderEnabled(true);
36     }
37 
38     @Override
onFinishInflate()39     protected void onFinishInflate() {
40         super.onFinishInflate();
41         setChildrenDrawingOrderEnabled(true);
42     }
43 
getPanelIndex(PanelView pv)44     public int getPanelIndex(PanelView pv) {
45         final int N = getChildCount();
46         for (int i=0; i<N; i++) {
47             final PanelView v = (PanelView) getChildAt(i);
48             if (pv == v) return i;
49         }
50         return -1;
51     }
52 
setSelectedPanel(PanelView pv)53     public void setSelectedPanel(PanelView pv) {
54         mSelectedPanelIndex = getPanelIndex(pv);
55     }
56 
57     @Override
getChildDrawingOrder(int childCount, int i)58     protected int getChildDrawingOrder(int childCount, int i) {
59         if (mSelectedPanelIndex == -1) {
60             return i;
61         } else {
62             if (i == childCount - 1) {
63                 return mSelectedPanelIndex;
64             } else if (i >= mSelectedPanelIndex) {
65                 return i + 1;
66             } else {
67                 return i;
68             }
69         }
70     }
71 
72     @Override
onTouchEvent(MotionEvent event)73     public boolean onTouchEvent(MotionEvent event) {
74         if (DEBUG_GESTURES) {
75             if (event.getActionMasked() != MotionEvent.ACTION_MOVE) {
76                 EventLog.writeEvent(EventLogTags.SYSUI_PANELHOLDER_TOUCH,
77                         event.getActionMasked(), (int) event.getX(), (int) event.getY());
78             }
79         }
80         return false;
81     }
82 
setBar(PanelBar panelBar)83     public void setBar(PanelBar panelBar) {
84         mBar = panelBar;
85     }
86 }
87