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
17package com.android.systemui.statusbar;
18
19import android.app.Notification;
20import android.content.Context;
21import android.content.res.Configuration;
22import android.graphics.PorterDuff;
23import android.util.AttributeSet;
24import android.widget.ImageView;
25import android.widget.TextView;
26
27import com.android.internal.util.NotificationColorUtil;
28import com.android.systemui.R;
29import com.android.systemui.statusbar.phone.IconMerger;
30
31/**
32 * A view to display all the overflowing icons on Keyguard.
33 */
34public class NotificationOverflowIconsView extends IconMerger {
35
36    private TextView mMoreText;
37    private int mTintColor;
38    private int mIconSize;
39    private NotificationColorUtil mNotificationColorUtil;
40
41    public NotificationOverflowIconsView(Context context, AttributeSet attrs) {
42        super(context, attrs);
43    }
44
45    @Override
46    protected void onFinishInflate() {
47        super.onFinishInflate();
48        mNotificationColorUtil = NotificationColorUtil.getInstance(getContext());
49        mTintColor = getResources().getColor(R.color.keyguard_overflow_content_color);
50        mIconSize = getResources().getDimensionPixelSize(
51                com.android.internal.R.dimen.status_bar_icon_size);
52    }
53
54    public void setMoreText(TextView moreText) {
55        mMoreText = moreText;
56    }
57
58    public void addNotification(NotificationData.Entry notification) {
59        StatusBarIconView v = new StatusBarIconView(getContext(), "",
60                notification.notification.getNotification());
61        v.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
62        addView(v, mIconSize, mIconSize);
63        v.set(notification.icon.getStatusBarIcon());
64        applyColor(notification.notification.getNotification(), v);
65        updateMoreText();
66    }
67
68    private void applyColor(Notification notification, StatusBarIconView view) {
69        view.setColorFilter(mTintColor, PorterDuff.Mode.MULTIPLY);
70    }
71
72    private void updateMoreText() {
73        mMoreText.setText(
74                getResources().getString(R.string.keyguard_more_overflow_text, getChildCount()));
75    }
76}
77