2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 package com
.android
.systemui
.statusbar
;
19 import android
.content
.Context
;
20 import android
.graphics
.Rect
;
21 import android
.util
.AttributeSet
;
22 import android
.view
.ViewGroup
;
24 import com
.android
.systemui
.statusbar
.stack
.NotificationStackScrollLayout
;
26 public class DismissViewButton
extends AlphaOptimizedButton
{
28 public DismissViewButton(Context context
) {
32 public DismissViewButton(Context context
, AttributeSet attrs
) {
33 this(context
, attrs
, 0);
36 public DismissViewButton(Context context
, AttributeSet attrs
, int defStyleAttr
) {
37 this(context
, attrs
, defStyleAttr
, 0);
40 public DismissViewButton(Context context
, AttributeSet attrs
, int defStyleAttr
,
42 super(context
, attrs
, defStyleAttr
, defStyleRes
);
46 * This method returns the drawing rect for the view which is different from the regular
47 * drawing rect, since we layout all children in the {@link NotificationStackScrollLayout} at
48 * position 0 and usually the translation is neglected. The standard implementation doesn't
49 * account for translation.
51 * @param outRect The (scrolled) drawing bounds of the view.
54 public void getDrawingRect(Rect outRect
) {
55 super.getDrawingRect(outRect
);
56 float translationX
= ((ViewGroup
) mParent
).getTranslationX();
57 float translationY
= ((ViewGroup
) mParent
).getTranslationY();
58 outRect
.left
+= translationX
;
59 outRect
.right
+= translationX
;
60 outRect
.top
+= translationY
;
61 outRect
.bottom
+= translationY
;