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.util.AttributeSet;
21 import android.view.View;
22 import android.widget.TextView;
23 
24 import com.android.systemui.R;
25 import com.android.systemui.ViewInvertHelper;
26 import com.android.systemui.statusbar.phone.NotificationPanelView;
27 
28 /**
29  * Container view for overflowing notification icons on Keyguard.
30  */
31 public class NotificationOverflowContainer extends ActivatableNotificationView {
32 
33     private NotificationOverflowIconsView mIconsView;
34     private ViewInvertHelper mViewInvertHelper;
35     private boolean mDark;
36     private View mContent;
37 
NotificationOverflowContainer(Context context, AttributeSet attrs)38     public NotificationOverflowContainer(Context context, AttributeSet attrs) {
39         super(context, attrs);
40     }
41 
42     @Override
onFinishInflate()43     protected void onFinishInflate() {
44         super.onFinishInflate();
45         mIconsView = (NotificationOverflowIconsView) findViewById(R.id.overflow_icons_view);
46         mIconsView.setMoreText((TextView) findViewById(R.id.more_text));
47         mIconsView.setOverflowIndicator(findViewById(R.id.more_icon_overflow));
48         mContent = findViewById(R.id.content);
49         mViewInvertHelper = new ViewInvertHelper(mContent,
50                 NotificationPanelView.DOZE_ANIMATION_DURATION);
51     }
52 
53     @Override
setDark(boolean dark, boolean fade, long delay)54     public void setDark(boolean dark, boolean fade, long delay) {
55         super.setDark(dark, fade, delay);
56         if (mDark == dark) return;
57         mDark = dark;
58         if (fade) {
59             mViewInvertHelper.fade(dark, delay);
60         } else {
61             mViewInvertHelper.update(dark);
62         }
63     }
64 
65     @Override
getContentView()66     protected View getContentView() {
67         return mContent;
68     }
69 
getIconsView()70     public NotificationOverflowIconsView getIconsView() {
71         return mIconsView;
72     }
73 
getContentHeightFromActualHeight(int actualHeight)74     protected int getContentHeightFromActualHeight(int actualHeight) {
75         int realActualHeight = actualHeight;
76         if (hasBottomDecor()) {
77             realActualHeight -= getBottomDecorHeight();
78         }
79         realActualHeight = Math.max(getMinHeight(), realActualHeight);
80         return realActualHeight;
81     }
82 }
83