Explain rootless alert status

This commit is contained in:
ajp_anton
2026-08-18 02:03:15 +00:00
parent 7fac006ad3
commit 77a725ae30
5 changed files with 76 additions and 0 deletions
@@ -0,0 +1,38 @@
package se.ajpanton.notificationsmaster
import android.content.ComponentName
import android.content.Intent
import android.os.Bundle
import android.provider.Settings
import android.view.View
import androidx.fragment.app.Fragment
import se.ajpanton.notificationsmaster.alerts.AlertConfigurationStore
import se.ajpanton.notificationsmaster.capture.NotificationCaptureService
import se.ajpanton.notificationsmaster.databinding.FragmentAlertStatusBinding
class AlertStatusFragment : Fragment(R.layout.fragment_alert_status) {
private var binding: FragmentAlertStatusBinding? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding = FragmentAlertStatusBinding.bind(view)
binding!!.notificationAccess.setOnClickListener { startActivity(Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS)) }
}
override fun onResume() {
super.onResume()
val context = requireContext()
val config = AlertConfigurationStore(context).load()
val access = context.getSystemService(android.app.NotificationManager::class.java)
.isNotificationListenerAccessGranted(ComponentName(context, NotificationCaptureService::class.java))
binding?.status?.text = buildString {
append(if (access) "Notification access is enabled." else "Notification access is disabled.")
append("\n\nCustom alerts are ")
append(if (config.enabled) "enabled" else "disabled")
append(" with ${config.rules.count { it.enabled }} active rule")
append(if (config.rules.count { it.enabled } == 1) "." else "s.")
}
binding?.notificationAccess?.text = if (access) "Notification access enabled" else "Enable notification access"
}
override fun onDestroyView() { binding = null; super.onDestroyView() }
}
@@ -155,6 +155,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
page == Page.VIEW_LOGS -> ViewLogsFragment()
page == Page.SETTINGS -> SettingsFragment()
page == Page.ALERTS -> AlertsFragment()
page == Page.ALERT_STATUS -> AlertStatusFragment()
page == Page.PROFILES -> ProfilesFragment()
page == Page.RULES -> RulesFragment()
page == Page.APPS -> AppsFragment()
@@ -350,6 +351,7 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
VIEW_LOGS(R.id.nav_view_logs, R.string.page_view_logs),
SETTINGS(R.id.nav_settings, R.string.page_settings),
ALERTS(R.id.nav_alerts, R.string.page_alerts),
ALERT_STATUS(R.id.nav_alert_status, R.string.page_alert_status),
PROFILES(R.id.nav_profiles, R.string.page_profiles),
RULES(R.id.nav_rules, R.string.page_rules),
APPS(R.id.nav_apps, R.string.page_apps),