]> gitweb.stoutner.com Git - PrivacyCell.git/blobdiff - app/src/main/java/com/stoutner/privacycell/fragments/SettingsFragment.kt
Disable swiping to dismiss realtime notifications. https://redmine.stoutner.com/issue...
[PrivacyCell.git] / app / src / main / java / com / stoutner / privacycell / fragments / SettingsFragment.kt
index b5acce90fb45e06283ca471915c044a74f364b9f..9adae226fc76d8e34ae1016da741c705b01af433 100644 (file)
@@ -155,6 +155,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
 
         // Re-register the shared preference listener.
         sharedPreferences.registerOnSharedPreferenceChangeListener(sharedPreferenceChangeListener)
+
+        // Update the realtime monitoring preference summary.
+        updateRealtimeMonitoringSummary()
     }
 
     private fun getSharedPreferenceChangeListener(): OnSharedPreferenceChangeListener {
@@ -260,4 +263,18 @@ class SettingsFragment : PreferenceFragmentCompat() {
         // Restart the activity after 400 milliseconds, so that the app has enough time to save the change to the preference.
         restartHandler.postDelayed(restartRunnable, 400)
     }
+
+    fun updateRealtimeMonitoringSummary() {
+        // Update the summary according to the API.
+        if (Build.VERSION.SDK_INT >= 33) {  // The API >= 33.
+            // Set the summary according to the notification permission status.
+            if (ActivityCompat.checkSelfPermission(requireContext(), Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED)
+                realtimeMonitoringPreference.summary = getString(R.string.realtime_monitoring_summary)
+            else
+                realtimeMonitoringPreference.summary = (getString(R.string.realtime_monitoring_summary) + " " + getString(R.string.notification_permission_denied))
+        } else {  // The API is < 33.
+            // Set the realtime monitoring summary.
+            realtimeMonitoringPreference.summary = getString(R.string.realtime_monitoring_summary)
+        }
+    }
 }