diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-10-17 10:25:14 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-10-17 12:07:13 -0700 |
commit | 420d54544e1386862d80a131d19a68049a879bf1 (patch) | |
tree | 4b316dc4f5a4f17075dfefb84230c457c0ef4f9c /src/com/android/launcher3/LauncherAppState.java | |
parent | 55ba0dcaaf65ca6a9ce8f973d100b4619724d3b4 (diff) | |
download | packages_apps_Trebuchet-420d54544e1386862d80a131d19a68049a879bf1.tar.gz packages_apps_Trebuchet-420d54544e1386862d80a131d19a68049a879bf1.tar.bz2 packages_apps_Trebuchet-420d54544e1386862d80a131d19a68049a879bf1.zip |
Using a common class for observing secure settings
Bug: 117519297
Change-Id: Ie9d948130aea50bf10c9fc625fdb16f4cfc4712e
Diffstat (limited to 'src/com/android/launcher3/LauncherAppState.java')
-rw-r--r-- | src/com/android/launcher3/LauncherAppState.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index b02182c57..6bf581277 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -16,7 +16,7 @@ package com.android.launcher3; -import static com.android.launcher3.SettingsActivity.NOTIFICATION_BADGING; +import static com.android.launcher3.util.SecureSettingsObserver.newNotificationSettingsObserver; import android.content.ComponentName; import android.content.ContentProviderClient; @@ -33,7 +33,7 @@ import com.android.launcher3.icons.IconCache; import com.android.launcher3.notification.NotificationListener; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.Preconditions; -import com.android.launcher3.util.SettingsObserver; +import com.android.launcher3.util.SecureSettingsObserver; public class LauncherAppState { @@ -48,7 +48,7 @@ public class LauncherAppState { private final IconCache mIconCache; private final WidgetPreviewLoader mWidgetCache; private final InvariantDeviceProfile mInvariantDeviceProfile; - private final SettingsObserver mNotificationBadgingObserver; + private final SecureSettingsObserver mNotificationBadgingObserver; public static LauncherAppState getInstance(final Context context) { return INSTANCE.get(context); @@ -99,17 +99,17 @@ public class LauncherAppState { mNotificationBadgingObserver = null; } else { // Register an observer to rebind the notification listener when badging is re-enabled. - mNotificationBadgingObserver = new SettingsObserver.Secure( - mContext.getContentResolver()) { - @Override - public void onSettingChanged(boolean isNotificationBadgingEnabled) { - if (isNotificationBadgingEnabled) { - NotificationListener.requestRebind(new ComponentName( - mContext, NotificationListener.class)); - } - } - }; - mNotificationBadgingObserver.register(NOTIFICATION_BADGING); + mNotificationBadgingObserver = + newNotificationSettingsObserver(mContext, this::onNotificationSettingsChanged); + mNotificationBadgingObserver.register(); + mNotificationBadgingObserver.dispatchOnChange(); + } + } + + protected void onNotificationSettingsChanged(boolean isNotificationBadgingEnabled) { + if (isNotificationBadgingEnabled) { + NotificationListener.requestRebind(new ComponentName( + mContext, NotificationListener.class)); } } |