From 84853ab563f3276098b0226857ec88325a1bee2d Mon Sep 17 00:00:00 2001 From: Michael W Date: Mon, 16 Apr 2018 21:07:10 +0200 Subject: Settings: Fix notification light app hint * The old code doesn't work when the entry in the database is not available, because it will cause parsePackageList() to return false, resulting in no execution of the code taking care of displaying the hint * Move the hint to a new function and call it at the appropriate places to display the hint when no entry to the database was ever made Thanks to @mikeioannina for noticing the missing hint Change-Id: Ie3fb39cfa7e7b04a3536f98e93e2168d7367961d --- .../NotificationLightSettings.java | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/com/android/settings/notificationlight/NotificationLightSettings.java b/src/com/android/settings/notificationlight/NotificationLightSettings.java index 3b02d36c9..f0b546ac7 100644 --- a/src/com/android/settings/notificationlight/NotificationLightSettings.java +++ b/src/com/android/settings/notificationlight/NotificationLightSettings.java @@ -276,6 +276,7 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem Context context = getActivity(); if (!parsePackageList()) { + maybeDisplayApplicationHint(context); return; } @@ -302,17 +303,22 @@ public class NotificationLightSettings extends SettingsPreferenceFragment implem } } - /* Display a pref explaining how to add apps */ - if (mApplicationPrefList.getPreferenceCount() == 0) { - String summary = getResources().getString( - R.string.notification_light_no_apps_summary); - String useCustom = getResources().getString( - R.string.notification_light_use_custom); - Preference pref = new Preference(context); - pref.setSummary(String.format(summary, useCustom)); - pref.setEnabled(false); - mApplicationPrefList.addPreference(pref); - } + maybeDisplayApplicationHint(context); + } + } + + private void maybeDisplayApplicationHint(Context context) + { + /* Display a pref explaining how to add apps */ + if (mApplicationPrefList != null && mApplicationPrefList.getPreferenceCount() == 0) { + String summary = getResources().getString( + R.string.notification_light_no_apps_summary); + String useCustom = getResources().getString( + R.string.notification_light_use_custom); + Preference pref = new Preference(context); + pref.setSummary(String.format(summary, useCustom)); + pref.setEnabled(false); + mApplicationPrefList.addPreference(pref); } } -- cgit v1.2.3