• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.notification.row;
18 
19 import android.annotation.ColorInt;
20 import android.content.Context;
21 import android.content.res.Configuration;
22 import android.util.AttributeSet;
23 import android.view.View;
24 
25 import com.android.systemui.R;
26 import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
27 
28 public class FooterView extends StackScrollerDecorView {
29     private final int mClearAllTopPadding;
30     private FooterViewButton mDismissButton;
31     private FooterViewButton mManageButton;
32 
FooterView(Context context, AttributeSet attrs)33     public FooterView(Context context, AttributeSet attrs) {
34         super(context, attrs);
35         mClearAllTopPadding = context.getResources().getDimensionPixelSize(
36                 R.dimen.clear_all_padding_top);
37     }
38 
39     @Override
findContentView()40     protected View findContentView() {
41         return findViewById(R.id.content);
42     }
43 
findSecondaryView()44     protected View findSecondaryView() {
45         return findViewById(R.id.dismiss_text);
46     }
47 
48     @Override
onFinishInflate()49     protected void onFinishInflate() {
50         super.onFinishInflate();
51         mDismissButton = (FooterViewButton) findSecondaryView();
52         mManageButton = findViewById(R.id.manage_text);
53     }
54 
setTextColor(@olorInt int color)55     public void setTextColor(@ColorInt int color) {
56         mManageButton.setTextColor(color);
57         mDismissButton.setTextColor(color);
58     }
59 
setManageButtonClickListener(OnClickListener listener)60     public void setManageButtonClickListener(OnClickListener listener) {
61         mManageButton.setOnClickListener(listener);
62     }
63 
setDismissButtonClickListener(OnClickListener listener)64     public void setDismissButtonClickListener(OnClickListener listener) {
65         mDismissButton.setOnClickListener(listener);
66     }
67 
isOnEmptySpace(float touchX, float touchY)68     public boolean isOnEmptySpace(float touchX, float touchY) {
69         return touchX < mContent.getX()
70                 || touchX > mContent.getX() + mContent.getWidth()
71                 || touchY < mContent.getY()
72                 || touchY > mContent.getY() + mContent.getHeight();
73     }
74 
75     @Override
onConfigurationChanged(Configuration newConfig)76     protected void onConfigurationChanged(Configuration newConfig) {
77         super.onConfigurationChanged(newConfig);
78         mDismissButton.setText(R.string.clear_all_notifications_text);
79         mDismissButton.setContentDescription(
80                 mContext.getString(R.string.accessibility_clear_all));
81         mManageButton.setText(R.string.manage_notifications_text);
82         mManageButton.setContentDescription(
83                 mContext.getString(R.string.accessibility_manage_notification));
84     }
85 
isButtonVisible()86     public boolean isButtonVisible() {
87         return mManageButton.getAlpha() != 0.0f;
88     }
89 
90     @Override
createExpandableViewState()91     public ExpandableViewState createExpandableViewState() {
92         return new FooterViewState();
93     }
94 
95     public class FooterViewState extends ExpandableViewState {
96         @Override
applyToView(View view)97         public void applyToView(View view) {
98             super.applyToView(view);
99             if (view instanceof FooterView) {
100                 FooterView footerView = (FooterView) view;
101                 boolean visible = this.clipTopAmount < mClearAllTopPadding;
102                 footerView.setContentVisible(visible && footerView.isVisible());
103             }
104         }
105     }
106 }
107