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