1d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi/* 2d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * Copyright (C) 2014 The Android Open Source Project 3d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * 4d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * Licensed under the Apache License, Version 2.0 (the "License"); 5d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * you may not use this file except in compliance with the License. 6d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * You may obtain a copy of the License at 7d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * 8d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * http://www.apache.org/licenses/LICENSE-2.0 9d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * 10d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * Unless required by applicable law or agreed to in writing, software 11d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * distributed under the License is distributed on an "AS IS" BASIS, 12d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * See the License for the specific language governing permissions and 14d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * limitations under the License 15d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi */ 16d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 17d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggipackage com.android.systemui.statusbar; 18d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 19d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport android.app.Notification; 20d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport android.content.Context; 21b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggiimport android.content.res.Configuration; 22d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport android.graphics.PorterDuff; 23d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport android.util.AttributeSet; 24d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport android.widget.ImageView; 25d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport android.widget.TextView; 26d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 27b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggiimport com.android.internal.util.NotificationColorUtil; 28d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport com.android.systemui.R; 29d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggiimport com.android.systemui.statusbar.phone.IconMerger; 30d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 31d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi/** 32d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi * A view to display all the overflowing icons on Keyguard. 33d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi */ 34d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggipublic class NotificationOverflowIconsView extends IconMerger { 35d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 36d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi private TextView mMoreText; 37d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi private int mTintColor; 38b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi private int mIconSize; 3905c362d5645367c816069aa138b597b77f317aa4Dan Sandler private NotificationColorUtil mNotificationColorUtil; 40d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 41d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi public NotificationOverflowIconsView(Context context, AttributeSet attrs) { 42d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi super(context, attrs); 43d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi } 44d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 45d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi @Override 46d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi protected void onFinishInflate() { 47d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi super.onFinishInflate(); 4805c362d5645367c816069aa138b597b77f317aa4Dan Sandler mNotificationColorUtil = NotificationColorUtil.getInstance(getContext()); 49d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi mTintColor = getResources().getColor(R.color.keyguard_overflow_content_color); 50b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi mIconSize = getResources().getDimensionPixelSize( 51b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi com.android.internal.R.dimen.status_bar_icon_size); 52d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi } 53d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 54d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi public void setMoreText(TextView moreText) { 55d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi mMoreText = moreText; 56d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi } 57d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 58d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi public void addNotification(NotificationData.Entry notification) { 59d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi StatusBarIconView v = new StatusBarIconView(getContext(), "", 60d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi notification.notification.getNotification()); 61d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi v.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 62b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi addView(v, mIconSize, mIconSize); 63d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi v.set(notification.icon.getStatusBarIcon()); 64b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi applyColor(notification.notification.getNotification(), v); 65d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi updateMoreText(); 66d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi } 67d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi 68b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi private void applyColor(Notification notification, StatusBarIconView view) { 6913b8159e9037d431dd5159635aa409116fa42562Dan Sandler view.setColorFilter(mTintColor, PorterDuff.Mode.MULTIPLY); 70b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi } 71b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi 72d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi private void updateMoreText() { 73b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi mMoreText.setText( 74b741f053394b6e8f59bdf72bb47e9f4484fbb808Jorim Jaggi getResources().getString(R.string.keyguard_more_overflow_text, getChildCount())); 75d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi } 76d4a57440ca5fc8461959176475b0fcd8a6e05871Jorim Jaggi} 77