blob: 4666873ce707835b3d987f36fad47964e15679f1 [file] [log] [blame]
Winson Chung8e4ec312010-10-13 17:22:51 -07001/*
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
17package com.android.launcher2;
18
19import android.content.Context;
20import android.util.AttributeSet;
21import android.view.MotionEvent;
22import android.widget.LinearLayout;
23
24/**
25 * The linear layout used strictly for the widget tab of the customization tray
26 */
27public class PagedViewWidgetLayout extends LinearLayout {
28 static final String TAG = "PagedViewWidgetLayout";
29
30 public PagedViewWidgetLayout(Context context) {
31 this(context, null);
32 }
33
34 public PagedViewWidgetLayout(Context context, AttributeSet attrs) {
35 this(context, attrs, 0);
36 }
37
38 public PagedViewWidgetLayout(Context context, AttributeSet attrs, int defStyle) {
39 super(context, attrs, defStyle);
40 }
41
42 @Override
43 public boolean onTouchEvent(MotionEvent event) {
44 // We eat up the touch events here, since the PagedView (which uses the same swiping
45 // touch code as Workspace previously) uses onInterceptTouchEvent() to determine when
46 // the user is scrolling between pages. This means that if the pages themselves don't
47 // handle touch events, it gets forwarded up to PagedView itself, and it's own
48 // onTouchEvent() handling will prevent further intercept touch events from being called
49 // (it's the same view in that case). This is not ideal, but to prevent more changes,
50 // we just always mark the touch event as handled.
51 return super.onTouchEvent(event) || true;
52 }
53
54 @Override
55 protected boolean onSetAlpha(int alpha) {
56 return true;
57 }
58
59 @Override
60 public void setAlpha(float alpha) {
61 setChildrenAlpha(alpha);
62 super.setAlpha(alpha);
63 }
64
65 private void setChildrenAlpha(float alpha) {
66 final int childCount = getChildCount();
67 for (int i = 0; i < childCount; i++) {
68 getChildAt(i).setAlpha(alpha);
69 }
70 }
71}