StatusBarSettings: Fix NW traffic not being properly hidden from search

On devices with notches (those that obviously set the overlay config),
the network traffic monitor preference can still appear in settings
search results. Fix this by not depending on whether the user has ever
opened status bar settings. Additionally turn the static boolean variable
into non-static since it no longer makes sense.

Change-Id: I7d4ed3d8fc84949a67e6d5f98c9a6e8719385ab0
diff --git a/src/com/shiftos/shiftparts/statusbar/StatusBarSettings.java b/src/com/shiftos/shiftparts/statusbar/StatusBarSettings.java
index 88f1c46..e705573 100644
--- a/src/com/shiftos/shiftparts/statusbar/StatusBarSettings.java
+++ b/src/com/shiftos/shiftparts/statusbar/StatusBarSettings.java
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2014-2015 The CyanogenMod Project
- *               2017-2019 The LineageOS Project
+ *               2017-2020 The LineageOS Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@
 import com.shiftos.shiftparts.SettingsPreferenceFragment;
 import com.shiftos.shiftparts.search.BaseSearchIndexProvider;
 import com.shiftos.shiftparts.search.Searchable;
+import com.shiftos.shiftparts.utils.DeviceUtils;
 
 import java.util.Set;
 
@@ -74,7 +75,7 @@
     private PreferenceCategory mStatusBarClockCategory;
     private PreferenceScreen mNetworkTrafficPref;
 
-    private static boolean sHasNotch;
+    private boolean mHasNotch;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -83,10 +84,8 @@
 
         mNetworkTrafficPref = (PreferenceScreen) findPreference(NETWORK_TRAFFIC_SETTINGS);
 
-        sHasNotch = getResources().getBoolean(
-                com.shiftos.platform.internal.R.bool.config_haveNotch);
-
-        if (sHasNotch) {
+        mHasNotch = DeviceUtils.hasNotch(getActivity());
+        if (mHasNotch) {
             getPreferenceScreen().removePreference(mNetworkTrafficPref);
         }
 
@@ -143,7 +142,7 @@
             mStatusBarAmPm.setSummary(R.string.status_bar_am_pm_info);
         }
 
-        final boolean disallowCenteredClock = sHasNotch || getNetworkTrafficStatus() != 0;
+        final boolean disallowCenteredClock = mHasNotch || getNetworkTrafficStatus() != 0;
 
         // Adjust status bar preferences for RTL
         if (getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
@@ -215,7 +214,7 @@
     }
 
     private void updateNetworkTrafficStatus(int clockPosition) {
-        if (sHasNotch) {
+        if (mHasNotch) {
             // Unconditional no network traffic for you
             return;
         }
@@ -245,7 +244,7 @@
         public Set<String> getNonIndexableKeys(Context context) {
             final Set<String> result = new ArraySet<String>();
 
-            if (sHasNotch) {
+            if (DeviceUtils.hasNotch(context)) {
                 result.add(NETWORK_TRAFFIC_SETTINGS);
             }
             return result;
diff --git a/src/com/shiftos/shiftparts/utils/DeviceUtils.java b/src/com/shiftos/shiftparts/utils/DeviceUtils.java
index 51dcf7d..a957e16 100644
--- a/src/com/shiftos/shiftparts/utils/DeviceUtils.java
+++ b/src/com/shiftos/shiftparts/utils/DeviceUtils.java
@@ -37,6 +37,12 @@
 
 public class DeviceUtils {
 
+    /* returns whether the device has a notch or not. */
+    public static boolean hasNotch(Context context) {
+        return context.getResources().getBoolean(
+                com.shiftos.platform.internal.R.bool.config_haveNotch);
+    }
+
     /* returns whether the device has volume rocker or not. */
     public static boolean hasVolumeRocker(Context context) {
         final int deviceKeys = context.getResources().getInteger(