OSDN Git Service

Add preference for enabling notification count in system tray
authorBraden Farmer <farmerbb@gmail.com>
Sat, 23 May 2020 16:52:38 +0000 (10:52 -0600)
committerBraden Farmer <farmerbb@gmail.com>
Sat, 23 May 2020 16:52:38 +0000 (10:52 -0600)
12 files changed:
app/src/main/java/com/farmerbb/taskbar/fragment/RecentAppsFragment.java
app/src/main/java/com/farmerbb/taskbar/ui/TaskbarController.java
app/src/main/java/com/farmerbb/taskbar/util/Constants.java
app/src/main/res/values-de/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-nl/strings.xml
app/src/main/res/values-pl/strings.xml
app/src/main/res/values-ru/strings.xml
app/src/main/res/values-tr/strings.xml
app/src/main/res/values-zh-rCN/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/tb_pref_recent_apps.xml

index f5f55ed..0b666dc 100644 (file)
@@ -16,6 +16,7 @@
 package com.farmerbb.taskbar.fragment;
 
 import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
 import android.content.ActivityNotFoundException;
 import android.content.Intent;
 import android.content.SharedPreferences;
@@ -74,10 +75,13 @@ public class RecentAppsFragment extends SettingsFragment implements SharedPrefer
         bindPreferenceSummaryToValue(findPreference(PREF_FULL_LENGTH));
         bindPreferenceSummaryToValue(findPreference(PREF_CENTERED_ICONS));
 
-        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
+        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            findPreference(PREF_NOTIFICATION_COUNT).setOnPreferenceClickListener(this);
             bindPreferenceSummaryToValue(findPreference(PREF_SYS_TRAY));
-        else
+        } else {
+            getPreferenceScreen().removePreference(findPreference(PREF_NOTIFICATION_COUNT));
             getPreferenceScreen().removePreference(findPreference(PREF_SYS_TRAY));
+        }
 
         updateMaxNumOfRecents(false);
         updateRefreshFrequency(false);
@@ -98,6 +102,7 @@ public class RecentAppsFragment extends SettingsFragment implements SharedPrefer
     }
 
     @SuppressLint("SetTextI18n")
+    @TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
     @Override
     public boolean onPreferenceClick(final Preference p) {
         final SharedPreferences pref = U.getSharedPreferences(getActivity());
@@ -206,6 +211,13 @@ public class RecentAppsFragment extends SettingsFragment implements SharedPrefer
                 AlertDialog dialog2 = builder2.create();
                 dialog2.show();
                 break;
+            case PREF_NOTIFICATION_COUNT:
+                try {
+                    startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
+                } catch (ActivityNotFoundException e) {
+                    U.showToast(getActivity(), R.string.tb_lock_device_not_supported);
+                }
+                break;
         }
 
         return super.onPreferenceClick(p);
index ddadefe..ee6dc11 100644 (file)
@@ -202,6 +202,7 @@ public class TaskbarController extends UIController {
     };
 
     private BroadcastReceiver notificationCountReceiver = new BroadcastReceiver() {
+        @SuppressLint("SetTextI18n")
         @Override
         public void onReceive(Context context, Intent intent) {
             int count = intent.getIntExtra("count", 0);
index 05c8608..0ae18a2 100644 (file)
@@ -151,6 +151,7 @@ public class Constants {
     public static final String PREF_MANAGE_APP_DATA = "manage_app_data";
     public static final String PREF_MAX_NUM_OF_RECENTS = "max_num_of_recents";
     public static final String PREF_NAVIGATION_BAR_BUTTONS = "navigation_bar_buttons";
+    public static final String PREF_NOTIFICATION_COUNT = "notification_count";
     public static final String PREF_NOTIFICATION_SETTINGS = "notification_settings";
     public static final String PREF_OPEN_TASKBAR_SETTINGS = "open_taskbar_settings";
     public static final String PREF_PIN_APP = "pin_app";
index bd18709..ddededa 100644 (file)
     <string name="tb_pref_dim_screen_description">Press the home button to manually activate</string>
     <string name="tb_desktop_mode_is_active">Desktop mode is active</string>
 
-    <string name="tb_pref_change_wallpaper_global">Apply to phone and desktop</string>
+    <string name="tb_pref_change_wallpaper_global">Apply to entire device</string>
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
-    <string name="tb_pref_remove_desktop_wallpaper">Remove desktop wallpaper</string>
+    <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
+
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
 
 </resources>
index 8a90256..466dca8 100644 (file)
     <string name="tb_pref_dim_screen_description">Press the home button to manually activate</string>
     <string name="tb_desktop_mode_is_active">Desktop mode is active</string>
 
-    <string name="tb_pref_change_wallpaper_global">Apply to phone and desktop</string>
+    <string name="tb_pref_change_wallpaper_global">Apply to entire device</string>
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
-    <string name="tb_pref_remove_desktop_wallpaper">Remove desktop wallpaper</string>
+    <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
+
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
 
 </resources>
\ No newline at end of file
index 4340963..9160ce4 100644 (file)
     <string name="tb_pref_dim_screen_description">Press the home button to manually activate</string>
     <string name="tb_desktop_mode_is_active">Desktop mode is active</string>
 
-    <string name="tb_pref_change_wallpaper_global">Apply to phone and desktop</string>
+    <string name="tb_pref_change_wallpaper_global">Apply to entire device</string>
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
-    <string name="tb_pref_remove_desktop_wallpaper">Remove desktop wallpaper</string>
+    <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
+
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
 
 </resources>
index 08494fe..c6d4b7f 100644 (file)
@@ -478,8 +478,11 @@ W takim przypadku może być konieczne flashowanie niestandardowego ROM-u w celu
     <string name="tb_pref_dim_screen_description">Press the home button to manually activate</string>
     <string name="tb_desktop_mode_is_active">Desktop mode is active</string>
 
-    <string name="tb_pref_change_wallpaper_global">Apply to phone and desktop</string>
+    <string name="tb_pref_change_wallpaper_global">Apply to entire device</string>
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
-    <string name="tb_pref_remove_desktop_wallpaper">Remove desktop wallpaper</string>
+    <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
+
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
 
 </resources>
\ No newline at end of file
index e520806..9b89407 100644 (file)
     <string name="tb_pref_dim_screen_description">Press the home button to manually activate</string>
     <string name="tb_desktop_mode_is_active">Desktop mode is active</string>
 
-    <string name="tb_pref_change_wallpaper_global">Apply to phone and desktop</string>
+    <string name="tb_pref_change_wallpaper_global">Apply to entire device</string>
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
-    <string name="tb_pref_remove_desktop_wallpaper">Remove desktop wallpaper</string>
+    <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
+
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
 
 </resources>
\ No newline at end of file
index d7533d6..e66cd82 100644 (file)
@@ -453,8 +453,11 @@ Bu durumda, bu cihazdaki serbest biçimli modu kullanmak için özel bir ROM fla
     <string name="tb_pref_dim_screen_description">Press the home button to manually activate</string>
     <string name="tb_desktop_mode_is_active">Desktop mode is active</string>
 
-    <string name="tb_pref_change_wallpaper_global">Apply to phone and desktop</string>
+    <string name="tb_pref_change_wallpaper_global">Apply to entire device</string>
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
-    <string name="tb_pref_remove_desktop_wallpaper">Remove desktop wallpaper</string>
+    <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
+
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
 
 </resources>
\ No newline at end of file
index 3997f60..9dbfd6c 100644 (file)
     <string name="tb_pref_dim_screen_description">Press the home button to manually activate</string>
     <string name="tb_desktop_mode_is_active">Desktop mode is active</string>
 
-    <string name="tb_pref_change_wallpaper_global">Apply to phone and desktop</string>
+    <string name="tb_pref_change_wallpaper_global">Apply to entire device</string>
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
-    <string name="tb_pref_remove_desktop_wallpaper">Remove desktop wallpaper</string>
+    <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
+
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
 
 </resources>
\ No newline at end of file
index aafd558..84699f2 100644 (file)
     <string name="tb_pref_change_wallpaper_desktop">Apply to desktop only</string>
     <string name="tb_pref_remove_desktop_wallpaper">Use device wallpaper</string>
 
+    <string name="tb_pref_notification_count_title">Show notification count in status area</string>
+    <string name="tb_pref_notification_count_description">Requires notification access</string>
+
 </resources>
index 71ad052..e2e9b78 100644 (file)
         android:title="@string/tb_pref_title_sys_tray"
         android:summary="@string/tb_pref_description_sys_tray"/>
 
+    <Preference
+        android:key="notification_count"
+        android:dependency="sys_tray"
+        android:title="@string/tb_pref_notification_count_title"
+        android:summary="@string/tb_pref_notification_count_description"/>
+
     <PreferenceCategory android:key="dummy" android:title="\n\n" />
 
 </PreferenceScreen>