blob: c9b0ec9e838dafb76e18cec15639585d652d3736 [file] [log] [blame]
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.internal.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.FrameLayout;
/**
* This class acts as a container for the action bar view and action mode context views.
* It applies special styles as needed to help handle animated transitions between them.
* @hide
*/
public class ActionBarContainer extends FrameLayout {
private boolean mIsTransitioning;
public ActionBarContainer(Context context) {
this(context, null);
}
public ActionBarContainer(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
com.android.internal.R.styleable.ActionBar);
setBackgroundDrawable(a.getDrawable(com.android.internal.R.styleable.ActionBar_background));
a.recycle();
}
/**
* Set the action bar into a "transitioning" state. While transitioning
* the bar will block focus and touch from all of its descendants. This
* prevents the user from interacting with the bar while it is animating
* in or out.
*
* @param isTransitioning true if the bar is currently transitioning, false otherwise.
*/
public void setTransitioning(boolean isTransitioning) {
mIsTransitioning = isTransitioning;
setDescendantFocusability(isTransitioning ? FOCUS_BLOCK_DESCENDANTS
: FOCUS_AFTER_DESCENDANTS);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return mIsTransitioning || super.onInterceptTouchEvent(ev);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
super.onTouchEvent(ev);
return true;
}
}