Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Joe Onorato | 79de0c5 | 2010-05-26 17:03:26 -0400 | [diff] [blame] | 17 | package com.android.systemui.statusbar; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 18 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 19 | import android.app.Notification; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 20 | import android.content.Context; |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 21 | import android.content.res.Configuration; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 22 | import android.content.res.Resources; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 23 | import android.graphics.Canvas; |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 24 | import android.graphics.Paint; |
| 25 | import android.graphics.Rect; |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 26 | import android.graphics.drawable.Drawable; |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 27 | import android.graphics.drawable.Icon; |
Jeff Sharkey | ded653b | 2012-09-27 19:09:24 -0700 | [diff] [blame] | 28 | import android.os.UserHandle; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 29 | import android.text.TextUtils; |
Daniel Sandler | 05e2414 | 2011-11-10 11:56:49 -0500 | [diff] [blame] | 30 | import android.util.AttributeSet; |
Joe Onorato | f9ec03c | 2010-09-23 15:09:18 -0700 | [diff] [blame] | 31 | import android.util.Log; |
Anthony Chen | 55e8e1e | 2016-01-08 10:31:46 -0800 | [diff] [blame] | 32 | import android.util.TypedValue; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 33 | import android.view.ViewDebug; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 34 | import android.view.accessibility.AccessibilityEvent; |
Winson | c0d7058 | 2016-01-29 10:24:39 -0800 | [diff] [blame] | 35 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 36 | import com.android.internal.statusbar.StatusBarIcon; |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 37 | import com.android.systemui.R; |
| 38 | |
John Spurlock | de84f0e | 2013-06-12 12:41:00 -0400 | [diff] [blame] | 39 | import java.text.NumberFormat; |
| 40 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 41 | public class StatusBarIconView extends AnimatedImageView { |
| 42 | private static final String TAG = "StatusBarIconView"; |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 43 | private boolean mAlwaysScaleIcon; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 44 | |
| 45 | private StatusBarIcon mIcon; |
| 46 | @ViewDebug.ExportedProperty private String mSlot; |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 47 | private Drawable mNumberBackground; |
| 48 | private Paint mNumberPain; |
| 49 | private int mNumberX; |
| 50 | private int mNumberY; |
| 51 | private String mNumberText; |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 52 | private Notification mNotification; |
Jason Monk | 3b23007 | 2015-05-29 11:11:29 -0400 | [diff] [blame] | 53 | private final boolean mBlocked; |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 54 | private int mDensity; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 55 | |
John Spurlock | e6f0a71 | 2013-09-03 16:23:49 -0400 | [diff] [blame] | 56 | public StatusBarIconView(Context context, String slot, Notification notification) { |
Jason Monk | 3b23007 | 2015-05-29 11:11:29 -0400 | [diff] [blame] | 57 | this(context, slot, notification, false); |
| 58 | } |
| 59 | |
| 60 | public StatusBarIconView(Context context, String slot, Notification notification, |
| 61 | boolean blocked) { |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 62 | super(context); |
Jason Monk | 3b23007 | 2015-05-29 11:11:29 -0400 | [diff] [blame] | 63 | mBlocked = blocked; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 64 | mSlot = slot; |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 65 | mNumberPain = new Paint(); |
| 66 | mNumberPain.setTextAlign(Paint.Align.CENTER); |
Alan Viverette | 4a357cd | 2015-03-18 18:37:18 -0700 | [diff] [blame] | 67 | mNumberPain.setColor(context.getColor(R.drawable.notification_number_text_color)); |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 68 | mNumberPain.setAntiAlias(true); |
Christoph Studer | a0506e7 | 2014-07-31 20:27:39 +0200 | [diff] [blame] | 69 | setNotification(notification); |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 70 | maybeUpdateIconScale(); |
| 71 | setScaleType(ScaleType.CENTER); |
| 72 | mDensity = context.getResources().getDisplayMetrics().densityDpi; |
| 73 | } |
Daniel Sandler | 26c84b1 | 2011-07-27 00:09:40 -0400 | [diff] [blame] | 74 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 75 | private void maybeUpdateIconScale() { |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 76 | // We do not resize and scale system icons (on the right), only notification icons (on the |
| 77 | // left). |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 78 | if (mNotification != null || mAlwaysScaleIcon) { |
| 79 | updateIconScale(); |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 80 | } |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 81 | } |
Daniel Sandler | abff032 | 2011-09-27 11:19:34 -0400 | [diff] [blame] | 82 | |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 83 | private void updateIconScale() { |
| 84 | Resources res = mContext.getResources(); |
| 85 | final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size); |
| 86 | final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size); |
| 87 | final float scale = (float)imageBounds / (float)outerBounds; |
| 88 | setScaleX(scale); |
| 89 | setScaleY(scale); |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | protected void onConfigurationChanged(Configuration newConfig) { |
| 94 | super.onConfigurationChanged(newConfig); |
| 95 | int density = newConfig.densityDpi; |
| 96 | if (density != mDensity) { |
| 97 | mDensity = density; |
| 98 | maybeUpdateIconScale(); |
| 99 | updateDrawable(); |
| 100 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Christoph Studer | a0506e7 | 2014-07-31 20:27:39 +0200 | [diff] [blame] | 103 | public void setNotification(Notification notification) { |
| 104 | mNotification = notification; |
| 105 | setContentDescription(notification); |
| 106 | } |
| 107 | |
Daniel Sandler | 05e2414 | 2011-11-10 11:56:49 -0500 | [diff] [blame] | 108 | public StatusBarIconView(Context context, AttributeSet attrs) { |
| 109 | super(context, attrs); |
Jason Monk | 3b23007 | 2015-05-29 11:11:29 -0400 | [diff] [blame] | 110 | mBlocked = false; |
Selim Cinek | 3e7592d | 2016-04-11 09:35:54 +0800 | [diff] [blame^] | 111 | mAlwaysScaleIcon = true; |
| 112 | updateIconScale(); |
| 113 | mDensity = context.getResources().getDisplayMetrics().densityDpi; |
Daniel Sandler | 05e2414 | 2011-11-10 11:56:49 -0500 | [diff] [blame] | 114 | } |
| 115 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 116 | private static boolean streq(String a, String b) { |
Joe Onorato | 66d7d01 | 2010-05-14 10:05:10 -0700 | [diff] [blame] | 117 | if (a == b) { |
| 118 | return true; |
| 119 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 120 | if (a == null && b != null) { |
| 121 | return false; |
| 122 | } |
| 123 | if (a != null && b == null) { |
| 124 | return false; |
| 125 | } |
| 126 | return a.equals(b); |
| 127 | } |
| 128 | |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 129 | public boolean equalIcons(Icon a, Icon b) { |
| 130 | if (a == b) return true; |
| 131 | if (a.getType() != b.getType()) return false; |
| 132 | switch (a.getType()) { |
| 133 | case Icon.TYPE_RESOURCE: |
| 134 | return a.getResPackage().equals(b.getResPackage()) && a.getResId() == b.getResId(); |
| 135 | case Icon.TYPE_URI: |
| 136 | return a.getUriString().equals(b.getUriString()); |
| 137 | default: |
| 138 | return false; |
| 139 | } |
| 140 | } |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 141 | /** |
| 142 | * Returns whether the set succeeded. |
| 143 | */ |
| 144 | public boolean set(StatusBarIcon icon) { |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 145 | final boolean iconEquals = mIcon != null && equalIcons(mIcon.icon, icon.icon); |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 146 | final boolean levelEquals = iconEquals |
| 147 | && mIcon.iconLevel == icon.iconLevel; |
| 148 | final boolean visibilityEquals = mIcon != null |
| 149 | && mIcon.visible == icon.visible; |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 150 | final boolean numberEquals = mIcon != null |
| 151 | && mIcon.number == icon.number; |
| 152 | mIcon = icon.clone(); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 153 | setContentDescription(icon.contentDescription); |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 154 | if (!iconEquals) { |
Fabrice Di Meglio | 82fca5d | 2013-01-09 15:42:31 -0800 | [diff] [blame] | 155 | if (!updateDrawable(false /* no clear */)) return false; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 156 | } |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 157 | if (!levelEquals) { |
| 158 | setImageLevel(icon.iconLevel); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 159 | } |
Daniel Sandler | 26c84b1 | 2011-07-27 00:09:40 -0400 | [diff] [blame] | 160 | |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 161 | if (!numberEquals) { |
John Spurlock | 0153478 | 2014-01-13 11:59:22 -0500 | [diff] [blame] | 162 | if (icon.number > 0 && getContext().getResources().getBoolean( |
Joe Onorato | 8595a3d | 2010-11-19 18:12:07 -0800 | [diff] [blame] | 163 | R.bool.config_statusBarShowNumber)) { |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 164 | if (mNumberBackground == null) { |
| 165 | mNumberBackground = getContext().getResources().getDrawable( |
| 166 | R.drawable.ic_notification_overlay); |
| 167 | } |
| 168 | placeNumber(); |
| 169 | } else { |
| 170 | mNumberBackground = null; |
| 171 | mNumberText = null; |
| 172 | } |
| 173 | invalidate(); |
| 174 | } |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 175 | if (!visibilityEquals) { |
Jason Monk | 3b23007 | 2015-05-29 11:11:29 -0400 | [diff] [blame] | 176 | setVisibility(icon.visible && !mBlocked ? VISIBLE : GONE); |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 177 | } |
Joe Onorato | 005847b | 2010-06-04 16:08:02 -0400 | [diff] [blame] | 178 | return true; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Fabrice Di Meglio | 82fca5d | 2013-01-09 15:42:31 -0800 | [diff] [blame] | 181 | public void updateDrawable() { |
| 182 | updateDrawable(true /* with clear */); |
| 183 | } |
| 184 | |
| 185 | private boolean updateDrawable(boolean withClear) { |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 186 | if (mIcon == null) { |
| 187 | return false; |
| 188 | } |
Fabrice Di Meglio | 82fca5d | 2013-01-09 15:42:31 -0800 | [diff] [blame] | 189 | Drawable drawable = getIcon(mIcon); |
| 190 | if (drawable == null) { |
John Spurlock | cd686b5 | 2013-06-05 10:13:46 -0400 | [diff] [blame] | 191 | Log.w(TAG, "No icon for slot " + mSlot); |
Fabrice Di Meglio | 82fca5d | 2013-01-09 15:42:31 -0800 | [diff] [blame] | 192 | return false; |
| 193 | } |
| 194 | if (withClear) { |
| 195 | setImageDrawable(null); |
| 196 | } |
| 197 | setImageDrawable(drawable); |
| 198 | return true; |
| 199 | } |
| 200 | |
Joe Onorato | f551054 | 2010-06-01 07:46:41 -0700 | [diff] [blame] | 201 | private Drawable getIcon(StatusBarIcon icon) { |
| 202 | return getIcon(getContext(), icon); |
| 203 | } |
| 204 | |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 205 | /** |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 206 | * Returns the right icon to use for this item |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 207 | * |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 208 | * @param context Context to use to get resources |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 209 | * @return Drawable for this item, or null if the package or item could not |
| 210 | * be found |
| 211 | */ |
Anthony Chen | 55e8e1e | 2016-01-08 10:31:46 -0800 | [diff] [blame] | 212 | public static Drawable getIcon(Context context, StatusBarIcon statusBarIcon) { |
| 213 | int userId = statusBarIcon.user.getIdentifier(); |
Dan Sandler | d63f932 | 2015-05-06 15:18:49 -0400 | [diff] [blame] | 214 | if (userId == UserHandle.USER_ALL) { |
Xiaohui Chen | 87d0e25 | 2015-07-30 15:38:16 -0700 | [diff] [blame] | 215 | userId = UserHandle.USER_SYSTEM; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 216 | } |
Anthony Chen | 55e8e1e | 2016-01-08 10:31:46 -0800 | [diff] [blame] | 217 | |
| 218 | Drawable icon = statusBarIcon.icon.loadDrawableAsUser(context, userId); |
| 219 | |
| 220 | TypedValue typedValue = new TypedValue(); |
| 221 | context.getResources().getValue(R.dimen.status_bar_icon_scale_factor, typedValue, true); |
| 222 | float scaleFactor = typedValue.getFloat(); |
| 223 | |
| 224 | // No need to scale the icon, so return it as is. |
| 225 | if (scaleFactor == 1.f) { |
| 226 | return icon; |
| 227 | } |
| 228 | |
| 229 | return new ScalingDrawableWrapper(icon, scaleFactor); |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 230 | } |
Joe Onorato | b77f53b | 2010-05-28 19:59:51 -0400 | [diff] [blame] | 231 | |
| 232 | public StatusBarIcon getStatusBarIcon() { |
| 233 | return mIcon; |
| 234 | } |
Joe Onorato | f9ec03c | 2010-09-23 15:09:18 -0700 | [diff] [blame] | 235 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 236 | @Override |
| 237 | public void onInitializeAccessibilityEvent(AccessibilityEvent event) { |
| 238 | super.onInitializeAccessibilityEvent(event); |
| 239 | if (mNotification != null) { |
| 240 | event.setParcelableData(mNotification); |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | @Override |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 245 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { |
| 246 | super.onSizeChanged(w, h, oldw, oldh); |
| 247 | if (mNumberBackground != null) { |
| 248 | placeNumber(); |
| 249 | } |
| 250 | } |
| 251 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 252 | @Override |
Jorim Jaggi | 66ac133 | 2015-01-21 19:22:26 +0100 | [diff] [blame] | 253 | public void onRtlPropertiesChanged(int layoutDirection) { |
| 254 | super.onRtlPropertiesChanged(layoutDirection); |
| 255 | updateDrawable(); |
| 256 | } |
| 257 | |
| 258 | @Override |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 259 | protected void onDraw(Canvas canvas) { |
| 260 | super.onDraw(canvas); |
| 261 | |
| 262 | if (mNumberBackground != null) { |
| 263 | mNumberBackground.draw(canvas); |
| 264 | canvas.drawText(mNumberText, mNumberX, mNumberY, mNumberPain); |
| 265 | } |
| 266 | } |
| 267 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 268 | @Override |
Joe Onorato | f9ec03c | 2010-09-23 15:09:18 -0700 | [diff] [blame] | 269 | protected void debug(int depth) { |
| 270 | super.debug(depth); |
| 271 | Log.d("View", debugIndent(depth) + "slot=" + mSlot); |
| 272 | Log.d("View", debugIndent(depth) + "icon=" + mIcon); |
| 273 | } |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 274 | |
| 275 | void placeNumber() { |
Daniel Sandler | ebce011 | 2011-06-16 16:44:51 -0400 | [diff] [blame] | 276 | final String str; |
John Spurlock | 0153478 | 2014-01-13 11:59:22 -0500 | [diff] [blame] | 277 | final int tooBig = getContext().getResources().getInteger( |
Daniel Sandler | ebce011 | 2011-06-16 16:44:51 -0400 | [diff] [blame] | 278 | android.R.integer.status_bar_notification_info_maxnum); |
| 279 | if (mIcon.number > tooBig) { |
John Spurlock | 0153478 | 2014-01-13 11:59:22 -0500 | [diff] [blame] | 280 | str = getContext().getResources().getString( |
Daniel Sandler | ebce011 | 2011-06-16 16:44:51 -0400 | [diff] [blame] | 281 | android.R.string.status_bar_notification_info_overflow); |
| 282 | } else { |
| 283 | NumberFormat f = NumberFormat.getIntegerInstance(); |
| 284 | str = f.format(mIcon.number); |
| 285 | } |
| 286 | mNumberText = str; |
| 287 | |
Joe Onorato | 6c01a11 | 2010-10-04 17:38:47 -0400 | [diff] [blame] | 288 | final int w = getWidth(); |
| 289 | final int h = getHeight(); |
| 290 | final Rect r = new Rect(); |
| 291 | mNumberPain.getTextBounds(str, 0, str.length(), r); |
| 292 | final int tw = r.right - r.left; |
| 293 | final int th = r.bottom - r.top; |
| 294 | mNumberBackground.getPadding(r); |
| 295 | int dw = r.left + tw + r.right; |
| 296 | if (dw < mNumberBackground.getMinimumWidth()) { |
| 297 | dw = mNumberBackground.getMinimumWidth(); |
| 298 | } |
| 299 | mNumberX = w-r.right-((dw-r.right-r.left)/2); |
| 300 | int dh = r.top + th + r.bottom; |
| 301 | if (dh < mNumberBackground.getMinimumWidth()) { |
| 302 | dh = mNumberBackground.getMinimumWidth(); |
| 303 | } |
| 304 | mNumberY = h-r.bottom-((dh-r.top-th-r.bottom)/2); |
| 305 | mNumberBackground.setBounds(w-dw, h-dh, w, h); |
| 306 | } |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 307 | |
| 308 | private void setContentDescription(Notification notification) { |
| 309 | if (notification != null) { |
| 310 | CharSequence tickerText = notification.tickerText; |
| 311 | if (!TextUtils.isEmpty(tickerText)) { |
| 312 | setContentDescription(tickerText); |
| 313 | } |
| 314 | } |
| 315 | } |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 316 | |
| 317 | public String toString() { |
John Spurlock | 209bede | 2013-07-17 12:23:27 -0400 | [diff] [blame] | 318 | return "StatusBarIconView(slot=" + mSlot + " icon=" + mIcon |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 319 | + " notification=" + mNotification + ")"; |
| 320 | } |
Jason Monk | 3b23007 | 2015-05-29 11:11:29 -0400 | [diff] [blame] | 321 | |
| 322 | public String getSlot() { |
| 323 | return mSlot; |
| 324 | } |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 325 | } |