2 * Copyright (C) 2012 The Android Open Source Project Licensed under the Apache
3 * License, Version 2.0 (the "License"); you may not use this file except in
4 * compliance with the License. You may obtain a copy of the License at
5 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
6 * or agreed to in writing, software distributed under the License is
7 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the specific language
9 * governing permissions and limitations under the License.
12 package com.cyanogenmod.eleven.widgets;
14 import android.content.Context;
15 import android.util.AttributeSet;
16 import android.view.View;
17 import android.view.ViewGroup;
18 import android.widget.FrameLayout;
21 * A FrameLayout whose contents are kept beneath an
22 * {@link AlphaTouchInterceptorOverlay}. If necessary, you can specify your own
23 * alpha-layer and manually manage its z-order.
25 public class FrameLayoutWithOverlay extends FrameLayout {
27 private final AlphaTouchInterceptorOverlay mOverlay;
30 * @param context The {@link Context} to use
31 * @param attrs The attributes of the XML tag that is inflating the view.
33 public FrameLayoutWithOverlay(final Context context, final AttributeSet attrs) {
34 super(context, attrs);
36 /* Programmatically create touch-interceptor View. */
37 mOverlay = new AlphaTouchInterceptorOverlay(context);
43 * After adding the View, bring the overlay to the front to ensure it's
47 public void addView(final View child, final int index, final ViewGroup.LayoutParams params) {
48 super.addView(child, index, params);
49 mOverlay.bringToFront();
53 * Delegate to overlay: set the View that it will use as its alpha-layer. If
54 * none is set, the overlay will use its own alpha layer. Only necessary to
55 * set this if some child views need to appear above the alpha-layer.
57 protected void setAlphaLayer(final View layer) {
58 mOverlay.setAlphaLayer(layer);
61 /** Delegate to overlay: set the alpha value on the alpha layer. */
62 public void setAlphaLayerValue(final float alpha) {
63 mOverlay.setAlphaLayerValue(alpha);
66 /** Delegate to overlay. */
67 public void setOverlayOnClickListener(final OnClickListener listener) {
68 mOverlay.setOverlayOnClickListener(listener);
71 /** Delegate to overlay. */
72 public void setOverlayClickable(final boolean clickable) {
73 mOverlay.setOverlayClickable(clickable);