1 /* 2 * Copyright (C) 2014 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.systemui.statusbar; 18 19 import android.content.Context; 20 import android.graphics.Rect; 21 import android.util.AttributeSet; 22 import android.view.View; 23 24 import com.android.systemui.R; 25 26 public class DismissView extends StackScrollerDecorView { 27 private boolean mDismissAllInProgress; 28 private DismissViewButton mDismissButton; 29 30 public DismissView(Context context, AttributeSet attrs) { 31 super(context, attrs); 32 } 33 34 @Override 35 protected View findContentView() { 36 return findViewById(R.id.dismiss_text); 37 } 38 39 @Override 40 protected void onFinishInflate() { 41 super.onFinishInflate(); 42 mDismissButton = (DismissViewButton) findContentView(); 43 } 44 45 public void setOnButtonClickListener(OnClickListener listener) { 46 mContent.setOnClickListener(listener); 47 } 48 49 public boolean isOnEmptySpace(float touchX, float touchY) { 50 return touchX < mContent.getX() 51 || touchX > mContent.getX() + mContent.getWidth() 52 || touchY < mContent.getY() 53 || touchY > mContent.getY() + mContent.getHeight(); 54 } 55 56 public void showClearButton() { 57 mDismissButton.showButton(); 58 } 59 60 public void setDismissAllInProgress(boolean dismissAllInProgress) { 61 if (dismissAllInProgress) { 62 setClipBounds(null); 63 } 64 mDismissAllInProgress = dismissAllInProgress; 65 } 66 67 @Override 68 public void setClipBounds(Rect clipBounds) { 69 if (mDismissAllInProgress) { 70 // we don't want any clipping to happen! 71 return; 72 } 73 super.setClipBounds(clipBounds); 74 } 75 76 public boolean isButtonVisible() { 77 return mDismissButton.isButtonStatic(); 78 } 79 } 80