Adam Powell | 45f1e08 | 2010-12-10 14:20:13 -0800 | [diff] [blame] | 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.internal.widget; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.content.res.TypedArray; |
| 21 | import android.util.AttributeSet; |
Adam Powell | 6ecf3d1 | 2010-12-19 13:14:58 -0800 | [diff] [blame] | 22 | import android.view.MotionEvent; |
Adam Powell | 45f1e08 | 2010-12-10 14:20:13 -0800 | [diff] [blame] | 23 | import 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 | */ |
| 30 | public class ActionBarContainer extends FrameLayout { |
Adam Powell | 01feaee | 2011-02-10 15:05:05 -0800 | [diff] [blame] | 31 | private boolean mIsTransitioning; |
| 32 | |
Adam Powell | 45f1e08 | 2010-12-10 14:20:13 -0800 | [diff] [blame] | 33 | 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 Powell | 6ecf3d1 | 2010-12-19 13:14:58 -0800 | [diff] [blame] | 45 | |
Adam Powell | 01feaee | 2011-02-10 15:05:05 -0800 | [diff] [blame] | 46 | /** |
| 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 Powell | 6ecf3d1 | 2010-12-19 13:14:58 -0800 | [diff] [blame] | 65 | @Override |
| 66 | public boolean onTouchEvent(MotionEvent ev) { |
| 67 | super.onTouchEvent(ev); |
| 68 | return true; |
| 69 | } |
Adam Powell | 45f1e08 | 2010-12-10 14:20:13 -0800 | [diff] [blame] | 70 | } |