Loading packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +41 −9 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.view.accessibility.AccessibilityEvent; import android.widget.ImageView; import java.text.NumberFormat; import java.util.ArrayList; import com.android.internal.statusbar.StatusBarIcon; Loading @@ -55,7 +56,7 @@ public class StatusBarIconView extends AnimatedImageView { private String mNumberText; private Notification mNotification; private boolean mShowNotificationCount; private SettingsObserver mObserver; private GlobalSettingsObserver mObserver; public StatusBarIconView(Context context, String slot, Notification notification) { super(context); Loading @@ -74,7 +75,7 @@ public class StatusBarIconView extends AnimatedImageView { Settings.System.STATUS_BAR_NOTIF_COUNT, 0) == 1; setContentDescription(notification); mObserver = new SettingsObserver(new Handler()); mObserver = GlobalSettingsObserver.getInstance(context); // We do not resize and scale system icons (on the right), only notification icons (on the // left). Loading Loading @@ -251,7 +252,7 @@ public class StatusBarIconView extends AnimatedImageView { super.onAttachedToWindow(); if (mObserver != null) { mObserver.observe(); mObserver.attach(this); } } Loading @@ -260,7 +261,7 @@ public class StatusBarIconView extends AnimatedImageView { super.onDetachedFromWindow(); if (mObserver != null) { mObserver.unobserve(); mObserver.detach(this); } } Loading Loading @@ -318,24 +319,55 @@ public class StatusBarIconView extends AnimatedImageView { + " notification=" + mNotification + ")"; } class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { static class GlobalSettingsObserver extends ContentObserver { private static GlobalSettingsObserver sInstance; private ArrayList<StatusBarIconView> mIconViews = new ArrayList<StatusBarIconView> (); private Context mContext; GlobalSettingsObserver(Handler handler, Context context) { super(handler); mContext = context.getApplicationContext(); } static GlobalSettingsObserver getInstance(Context context) { if (sInstance == null) { sInstance = new GlobalSettingsObserver(new Handler(), context); } return sInstance; } void attach(StatusBarIconView sbiv) { if (mIconViews.isEmpty()) { observe(); } mIconViews.add(sbiv); } void detach(StatusBarIconView sbiv) { mIconViews.remove(sbiv); if (mIconViews.isEmpty()) { unobserve(); } } void observe() { mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor(Settings.System.STATUS_BAR_NOTIF_COUNT), false, this); } void unobserve() { mContext.getContentResolver().unregisterContentObserver(this); } @Override public void onChange(boolean selfChange) { mShowNotificationCount = Settings.System.getInt( mContext.getContentResolver(), boolean showIconCount = Settings.System.getInt(mContext.getContentResolver(), Settings.System.STATUS_BAR_NOTIF_COUNT, 0) == 1; set(mIcon, true); for (StatusBarIconView sbiv : mIconViews) { sbiv.mShowNotificationCount = showIconCount; sbiv.set(sbiv.mIcon, true); } } } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +41 −9 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import android.view.accessibility.AccessibilityEvent; import android.widget.ImageView; import java.text.NumberFormat; import java.util.ArrayList; import com.android.internal.statusbar.StatusBarIcon; Loading @@ -55,7 +56,7 @@ public class StatusBarIconView extends AnimatedImageView { private String mNumberText; private Notification mNotification; private boolean mShowNotificationCount; private SettingsObserver mObserver; private GlobalSettingsObserver mObserver; public StatusBarIconView(Context context, String slot, Notification notification) { super(context); Loading @@ -74,7 +75,7 @@ public class StatusBarIconView extends AnimatedImageView { Settings.System.STATUS_BAR_NOTIF_COUNT, 0) == 1; setContentDescription(notification); mObserver = new SettingsObserver(new Handler()); mObserver = GlobalSettingsObserver.getInstance(context); // We do not resize and scale system icons (on the right), only notification icons (on the // left). Loading Loading @@ -251,7 +252,7 @@ public class StatusBarIconView extends AnimatedImageView { super.onAttachedToWindow(); if (mObserver != null) { mObserver.observe(); mObserver.attach(this); } } Loading @@ -260,7 +261,7 @@ public class StatusBarIconView extends AnimatedImageView { super.onDetachedFromWindow(); if (mObserver != null) { mObserver.unobserve(); mObserver.detach(this); } } Loading Loading @@ -318,24 +319,55 @@ public class StatusBarIconView extends AnimatedImageView { + " notification=" + mNotification + ")"; } class SettingsObserver extends ContentObserver { SettingsObserver(Handler handler) { static class GlobalSettingsObserver extends ContentObserver { private static GlobalSettingsObserver sInstance; private ArrayList<StatusBarIconView> mIconViews = new ArrayList<StatusBarIconView> (); private Context mContext; GlobalSettingsObserver(Handler handler, Context context) { super(handler); mContext = context.getApplicationContext(); } static GlobalSettingsObserver getInstance(Context context) { if (sInstance == null) { sInstance = new GlobalSettingsObserver(new Handler(), context); } return sInstance; } void attach(StatusBarIconView sbiv) { if (mIconViews.isEmpty()) { observe(); } mIconViews.add(sbiv); } void detach(StatusBarIconView sbiv) { mIconViews.remove(sbiv); if (mIconViews.isEmpty()) { unobserve(); } } void observe() { mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor(Settings.System.STATUS_BAR_NOTIF_COUNT), false, this); } void unobserve() { mContext.getContentResolver().unregisterContentObserver(this); } @Override public void onChange(boolean selfChange) { mShowNotificationCount = Settings.System.getInt( mContext.getContentResolver(), boolean showIconCount = Settings.System.getInt(mContext.getContentResolver(), Settings.System.STATUS_BAR_NOTIF_COUNT, 0) == 1; set(mIcon, true); for (StatusBarIconView sbiv : mIconViews) { sbiv.mShowNotificationCount = showIconCount; sbiv.set(sbiv.mIcon, true); } } } }