diff --git a/app/src/main/java/se/ajpanton/notificationsmaster/AlertStatusFragment.kt b/app/src/main/java/se/ajpanton/notificationsmaster/AlertStatusFragment.kt
deleted file mode 100644
index 11f4133..0000000
--- a/app/src/main/java/se/ajpanton/notificationsmaster/AlertStatusFragment.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-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() }
-}
diff --git a/app/src/main/java/se/ajpanton/notificationsmaster/AlertsFragment.kt b/app/src/main/java/se/ajpanton/notificationsmaster/AlertsFragment.kt
index 4da7938..975ce84 100644
--- a/app/src/main/java/se/ajpanton/notificationsmaster/AlertsFragment.kt
+++ b/app/src/main/java/se/ajpanton/notificationsmaster/AlertsFragment.kt
@@ -1,12 +1,19 @@
package se.ajpanton.notificationsmaster
+import android.app.NotificationManager
+import android.content.ComponentName
+import android.content.Intent
+import android.content.res.ColorStateList
import android.os.Bundle
+import android.provider.Settings
import android.view.View
import android.widget.ArrayAdapter
+import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import se.ajpanton.notificationsmaster.alerts.AlertConfigurationStore
import se.ajpanton.notificationsmaster.alerts.AlertQueueOverflow
import se.ajpanton.notificationsmaster.alerts.AlertQueueSettings
+import se.ajpanton.notificationsmaster.capture.NotificationCaptureService
import se.ajpanton.notificationsmaster.databinding.FragmentAlertsBinding
class AlertsFragment : Fragment(R.layout.fragment_alerts) {
@@ -26,9 +33,28 @@ class AlertsFragment : Fragment(R.layout.fragment_alerts) {
(1..10).map(Int::toString),
)
binding!!.queueLength.setSelection(configuration.queueSettings.maximumLength - 1, false)
+ binding!!.notificationAccess.setOnClickListener {
+ startActivity(Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS))
+ }
bindChanges()
}
+ override fun onResume() {
+ super.onResume()
+ val context = requireContext()
+ val access = context.getSystemService(NotificationManager::class.java)
+ .isNotificationListenerAccessGranted(ComponentName(context, NotificationCaptureService::class.java))
+ binding?.notificationAccess?.apply {
+ text = if (access) "Notification access enabled" else "Enable notification access"
+ backgroundTintList = ColorStateList.valueOf(
+ ContextCompat.getColor(
+ context,
+ if (access) R.color.notification_access_granted else R.color.notification_access_missing,
+ ),
+ )
+ }
+ }
+
override fun onDestroyView() {
binding = null
super.onDestroyView()
diff --git a/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt b/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt
index 8e60b09..4b3df88 100644
--- a/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt
+++ b/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt
@@ -163,7 +163,6 @@ 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()
@@ -371,7 +370,6 @@ 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),
diff --git a/app/src/main/res/layout/fragment_alert_status.xml b/app/src/main/res/layout/fragment_alert_status.xml
deleted file mode 100644
index 3d4a949..0000000
--- a/app/src/main/res/layout/fragment_alert_status.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/fragment_alerts.xml b/app/src/main/res/layout/fragment_alerts.xml
index c833c5d..542ee0e 100644
--- a/app/src/main/res/layout/fragment_alerts.xml
+++ b/app/src/main/res/layout/fragment_alerts.xml
@@ -9,6 +9,40 @@
android:orientation="vertical"
android:padding="@dimen/page_padding">
+
+
+
+
+
+
+
+
+
+
+
+
+ android:text="Alert queue"
+ android:textAppearance="?attr/textAppearanceHeadline6" />
+
+
-
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 79a66a9..da0101f 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -17,6 +17,8 @@
#34588E
#B00020
#183B5C9C
+ #2E7D32
+ #B3261E
#D9E2FF
#10264F
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 65b7f95..410e14a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -10,7 +10,6 @@
View logs
Settings
Alerts
- Alert status
Post up to 50 real, silent notifications to test icon filtering and layout.
Cycle between zero and the selected count every two seconds
Reset
@@ -26,7 +25,6 @@
Log display
Filter logging
Log display
- Alert status
Profiles
Rules
Apps