ActionBarContainer.java revision 01feaee3d9767ef1185783877e92244f14d7d4ba
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 17package com.android.internal.widget; 18 19import android.content.Context; 20import android.content.res.TypedArray; 21import android.util.AttributeSet; 22import android.view.MotionEvent; 23import 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 { 31 private boolean mIsTransitioning; 32 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 } 45 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 65 @Override 66 public boolean onTouchEvent(MotionEvent ev) { 67 super.onTouchEvent(ev); 68 return true; 69 } 70} 71