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.content.res.Configuration; 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 DismissViewButton mDismissButton; 28 29 public DismissView(Context context, AttributeSet attrs) { 30 super(context, attrs); 31 } 32 33 @Override 34 protected View findContentView() { 35 return findViewById(R.id.dismiss_text); 36 } 37 38 @Override 39 protected void onFinishInflate() { 40 super.onFinishInflate(); 41 mDismissButton = (DismissViewButton) findContentView(); 42 } 43 44 public void setOnButtonClickListener(OnClickListener listener) { 45 mContent.setOnClickListener(listener); 46 } 47 48 public boolean isOnEmptySpace(float touchX, float touchY) { 49 return touchX < mContent.getX() 50 || touchX > mContent.getX() + mContent.getWidth() 51 || touchY < mContent.getY() 52 || touchY > mContent.getY() + mContent.getHeight(); 53 } 54 55 @Override 56 protected void onConfigurationChanged(Configuration newConfig) { 57 super.onConfigurationChanged(newConfig); 58 mDismissButton.setText(R.string.clear_all_notifications_text); 59 } 60 61 public boolean isButtonVisible() { 62 return mDismissButton.getAlpha() != 0.0f; 63 } 64 } 65