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 import android.view.ViewGroup; 24 import android.widget.ImageButton; 25 import com.android.systemui.R; 26 import com.android.systemui.statusbar.stack.NotificationStackScrollLayout; 27 28 public class DismissViewImageButton extends ImageButton { DismissViewImageButton(Context context)29 public DismissViewImageButton(Context context) { 30 super(context); 31 } 32 DismissViewImageButton(Context context, AttributeSet attrs)33 public DismissViewImageButton(Context context, AttributeSet attrs) { 34 super(context, attrs); 35 } 36 DismissViewImageButton(Context context, AttributeSet attrs, int defStyleAttr)37 public DismissViewImageButton(Context context, AttributeSet attrs, int defStyleAttr) { 38 super(context, attrs, defStyleAttr); 39 } 40 DismissViewImageButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)41 public DismissViewImageButton(Context context, AttributeSet attrs, int defStyleAttr, 42 int defStyleRes) { 43 super(context, attrs, defStyleAttr, defStyleRes); 44 } 45 46 /** 47 * This method returns the drawing rect for the view which is different from the regular 48 * drawing rect, since we layout all children in the {@link NotificationStackScrollLayout} at 49 * position 0 and usually the translation is neglected. The standard implementation doesn't 50 * account for translation. 51 * 52 * @param outRect The (scrolled) drawing bounds of the view. 53 */ 54 @Override getDrawingRect(Rect outRect)55 public void getDrawingRect(Rect outRect) { 56 super.getDrawingRect(outRect); 57 float translationX = ((ViewGroup) mParent).getTranslationX(); 58 float translationY = ((ViewGroup) mParent).getTranslationY(); 59 outRect.left += translationX; 60 outRect.right += translationX; 61 outRect.top += translationY; 62 outRect.bottom += translationY; 63 } 64 } 65