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.content.res.Configuration; 22 import android.graphics.PorterDuff; 23 import android.util.AttributeSet; 24 import android.widget.ImageView; 25 import android.widget.TextView; 26 27 import com.android.internal.util.NotificationColorUtil; 28 import com.android.systemui.R; 29 import com.android.systemui.statusbar.phone.IconMerger; 30 31 /** 32 * A view to display all the overflowing icons on Keyguard. 33 */ 34 public class NotificationOverflowIconsView extends IconMerger { 35 36 private TextView mMoreText; 37 private int mTintColor; 38 private int mIconSize; 39 private NotificationColorUtil mNotificationColorUtil; 40 NotificationOverflowIconsView(Context context, AttributeSet attrs)41 public NotificationOverflowIconsView(Context context, AttributeSet attrs) { 42 super(context, attrs); 43 } 44 45 @Override onFinishInflate()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 setMoreText(TextView moreText)54 public void setMoreText(TextView moreText) { 55 mMoreText = moreText; 56 } 57 addNotification(NotificationData.Entry notification)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 applyColor(Notification notification, StatusBarIconView view)68 private void applyColor(Notification notification, StatusBarIconView view) { 69 view.setColorFilter(mTintColor, PorterDuff.Mode.MULTIPLY); 70 } 71 updateMoreText()72 private void updateMoreText() { 73 mMoreText.setText( 74 getResources().getString(R.string.keyguard_more_overflow_text, getChildCount())); 75 } 76 } 77