blob: c9b0ec9e838dafb76e18cec15639585d652d3736 [file] [log] [blame]
Adam Powell45f1e082010-12-10 14:20:13 -08001/*
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.internal.widget;
18
19import android.content.Context;
20import android.content.res.TypedArray;
21import android.util.AttributeSet;
Adam Powell6ecf3d12010-12-19 13:14:58 -080022import android.view.MotionEvent;
Adam Powell45f1e082010-12-10 14:20:13 -080023import android.widget.FrameLayout;
24
25/**
26 * This class acts as a container for the action bar view and action mode context views.
27 * It applies special styles as needed to help handle animated transitions between them.
28 * @hide
29 */
30public class ActionBarContainer extends FrameLayout {
Adam Powell01feaee2011-02-10 15:05:05 -080031 private boolean mIsTransitioning;
32
Adam Powell45f1e082010-12-10 14:20:13 -080033 public ActionBarContainer(Context context) {
34 this(context, null);
35 }
36
37 public ActionBarContainer(Context context, AttributeSet attrs) {
38 super(context, attrs);
39
40 TypedArray a = context.obtainStyledAttributes(attrs,
41 com.android.internal.R.styleable.ActionBar);
42 setBackgroundDrawable(a.getDrawable(com.android.internal.R.styleable.ActionBar_background));
43 a.recycle();
44 }
Adam Powell6ecf3d12010-12-19 13:14:58 -080045
Adam Powell01feaee2011-02-10 15:05:05 -080046 /**
47 * Set the action bar into a "transitioning" state. While transitioning
48 * the bar will block focus and touch from all of its descendants. This
49 * prevents the user from interacting with the bar while it is animating
50 * in or out.
51 *
52 * @param isTransitioning true if the bar is currently transitioning, false otherwise.
53 */
54 public void setTransitioning(boolean isTransitioning) {
55 mIsTransitioning = isTransitioning;
56 setDescendantFocusability(isTransitioning ? FOCUS_BLOCK_DESCENDANTS
57 : FOCUS_AFTER_DESCENDANTS);
58 }
59
60 @Override
61 public boolean onInterceptTouchEvent(MotionEvent ev) {
62 return mIsTransitioning || super.onInterceptTouchEvent(ev);
63 }
64
Adam Powell6ecf3d12010-12-19 13:14:58 -080065 @Override
66 public boolean onTouchEvent(MotionEvent ev) {
67 super.onTouchEvent(ev);
68 return true;
69 }
Adam Powell45f1e082010-12-10 14:20:13 -080070}