Explain rootless alert status
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/page_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/notification_access"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Without optional system integration, Android keeps the source app’s own sound and vibration. Matching custom alerts play in addition; they do not replace it."
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
@@ -12,6 +12,9 @@
|
||||
<item
|
||||
android:id="@+id/nav_alerts"
|
||||
android:title="@string/navigation_indented_alerts" />
|
||||
<item
|
||||
android:id="@+id/nav_alert_status"
|
||||
android:title="@string/navigation_indented_alert_status" />
|
||||
<item
|
||||
android:id="@+id/nav_profiles"
|
||||
android:title="@string/navigation_indented_profiles" />
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<string name="page_view_logs">View logs</string>
|
||||
<string name="page_settings">Settings</string>
|
||||
<string name="page_alerts">Alerts</string>
|
||||
<string name="page_alert_status">Alert status</string>
|
||||
<string name="page_profiles">Profiles</string>
|
||||
<string name="page_rules">Rules</string>
|
||||
<string name="page_apps">Apps</string>
|
||||
@@ -16,6 +17,7 @@
|
||||
<string name="page_filter_logging">Filter logging</string>
|
||||
<string name="navigation_indented_log_display">    Log display</string>
|
||||
<string name="navigation_indented_alerts">    Alerts</string>
|
||||
<string name="navigation_indented_alert_status">    Alert status</string>
|
||||
<string name="navigation_indented_profiles">    Profiles</string>
|
||||
<string name="navigation_indented_rules">    Rules</string>
|
||||
<string name="navigation_indented_apps">    Apps</string>
|
||||
|
||||
Reference in New Issue
Block a user