diff --git a/app/src/main/java/se/ajpanton/notificationsmaster/DebugNotificationsFragment.kt b/app/src/main/java/se/ajpanton/notificationsmaster/DebugNotificationsFragment.kt
deleted file mode 100644
index 024837e..0000000
--- a/app/src/main/java/se/ajpanton/notificationsmaster/DebugNotificationsFragment.kt
+++ /dev/null
@@ -1,82 +0,0 @@
-package se.ajpanton.notificationsmaster
-
-import android.Manifest
-import android.os.Bundle
-import android.view.View
-import android.widget.Toast
-import androidx.activity.result.contract.ActivityResultContracts
-import androidx.fragment.app.Fragment
-import se.ajpanton.notificationsmaster.databinding.FragmentDebugNotificationsBinding
-import se.ajpanton.notificationsmaster.debug.DebugNotifications
-
-class DebugNotificationsFragment : Fragment(R.layout.fragment_debug_notifications) {
- private var binding: FragmentDebugNotificationsBinding? = null
- private var pendingCount: Int? = null
- private var pendingCycle = false
- private var updatingCycle = false
- private val permissionRequest = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
- val context = context ?: return@registerForActivityResult
- if (granted) {
- pendingCount?.let { DebugNotifications.setCount(context, it) }
- if (pendingCycle) DebugNotifications.setCycling(context, true)
- } else {
- Toast.makeText(context, R.string.debug_notification_permission_required, Toast.LENGTH_SHORT).show()
- }
- pendingCount = null
- pendingCycle = false
- refresh()
- }
-
- override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
- binding = FragmentDebugNotificationsBinding.bind(view)
- binding!!.debugMinus10.setOnClickListener { changeCount(-10) }
- binding!!.debugMinus1.setOnClickListener { changeCount(-1) }
- binding!!.debugPlus1.setOnClickListener { changeCount(1) }
- binding!!.debugPlus10.setOnClickListener { changeCount(10) }
- binding!!.debugReset.setOnClickListener { setCount(0) }
- binding!!.debugCycle.setOnCheckedChangeListener { _, enabled ->
- if (updatingCycle) return@setOnCheckedChangeListener
- if (enabled && !DebugNotifications.hasPermission(requireContext())) {
- pendingCycle = true
- permissionRequest.launch(Manifest.permission.POST_NOTIFICATIONS)
- } else {
- DebugNotifications.setCycling(requireContext(), enabled)
- }
- }
- }
-
- override fun onResume() {
- super.onResume()
- activity?.title = getString(R.string.page_debug_notifications)
- DebugNotifications.apply(requireContext())
- refresh()
- }
-
- override fun onDestroyView() {
- binding = null
- super.onDestroyView()
- }
-
- private fun changeCount(delta: Int) = setCount(DebugNotifications.count(requireContext()) + delta)
-
- private fun setCount(count: Int) {
- val desired = count.coerceIn(0, DebugNotifications.MAX_COUNT)
- if (desired > 0 && !DebugNotifications.hasPermission(requireContext())) {
- pendingCount = desired
- permissionRequest.launch(Manifest.permission.POST_NOTIFICATIONS)
- return
- }
- DebugNotifications.setCount(requireContext(), desired)
- refresh()
- }
-
- private fun refresh() {
- val context = context ?: return
- val count = DebugNotifications.count(context)
- binding?.debugCount?.text = count.toString()
- binding?.debugCycle?.isEnabled = count > 0
- updatingCycle = true
- binding?.debugCycle?.isChecked = DebugNotifications.isCycling(context)
- updatingCycle = false
- }
-}
diff --git a/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt b/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt
index c5e974e..9ef0337 100644
--- a/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt
+++ b/app/src/main/java/se/ajpanton/notificationsmaster/MainActivity.kt
@@ -180,7 +180,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
page == Page.APPS -> AppsFragment()
page == Page.NOTIFICATION_VISIBILITY -> NotificationVisibilityFragment()
page == Page.CARDS_LAYOUT -> CardsLayoutFragment()
- page == Page.DEBUG_NOTIFICATIONS -> DebugNotificationsFragment()
page == Page.MISCELLANEOUS -> MiscellaneousFragment()
page == Page.LOG_DISPLAY -> LogDisplayFragment()
page == Page.FILTER_LOGGING -> FilterLoggingFragment()
@@ -387,7 +386,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
APPS(R.id.nav_apps, R.string.page_apps),
NOTIFICATION_VISIBILITY(R.id.nav_notification_visibility, R.string.page_notification_visibility),
CARDS_LAYOUT(R.id.nav_cards_layout, R.string.page_cards_layout),
- DEBUG_NOTIFICATIONS(R.id.nav_debug_notifications, R.string.page_debug_notifications),
MISCELLANEOUS(R.id.nav_miscellaneous, R.string.page_miscellaneous),
LOG_DISPLAY(R.id.nav_log_display, R.string.page_log_display),
FILTER_LOGGING(R.id.nav_filter_logging, R.string.page_filter_logging),
diff --git a/app/src/main/java/se/ajpanton/notificationsmaster/MiscellaneousFragment.kt b/app/src/main/java/se/ajpanton/notificationsmaster/MiscellaneousFragment.kt
index cb43b46..fa790ca 100644
--- a/app/src/main/java/se/ajpanton/notificationsmaster/MiscellaneousFragment.kt
+++ b/app/src/main/java/se/ajpanton/notificationsmaster/MiscellaneousFragment.kt
@@ -1,16 +1,35 @@
package se.ajpanton.notificationsmaster
+import android.Manifest
import android.os.Bundle
import android.view.View
+import android.widget.Toast
+import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.Fragment
import com.google.android.material.switchmaterial.SwitchMaterial
import se.ajpanton.notificationsmaster.databinding.FragmentMiscellaneousBinding
+import se.ajpanton.notificationsmaster.debug.DebugNotifications
import se.ajpanton.notificationsmaster.visibility.SystemUiMiscSettings
import se.ajpanton.notificationsmaster.visibility.VisibilityPolicyStore
class MiscellaneousFragment : Fragment(R.layout.fragment_miscellaneous) {
private var binding: FragmentMiscellaneousBinding? = null
private lateinit var store: VisibilityPolicyStore
+ private var pendingCount: Int? = null
+ private var pendingCycle = false
+ private var updatingCycle = false
+ private val permissionRequest = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
+ val context = context ?: return@registerForActivityResult
+ if (granted) {
+ pendingCount?.let { DebugNotifications.setCount(context, it) }
+ if (pendingCycle) DebugNotifications.setCycling(context, true)
+ } else {
+ Toast.makeText(context, R.string.debug_notification_permission_required, Toast.LENGTH_SHORT).show()
+ }
+ pendingCount = null
+ pendingCycle = false
+ refreshDebugNotifications()
+ }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
binding = FragmentMiscellaneousBinding.bind(view)
@@ -26,11 +45,27 @@ class MiscellaneousFragment : Fragment(R.layout.fragment_miscellaneous) {
bind(binding!!.showAodBatteryPercent, settings.showAodBatteryPercentWhenUnplugged) { current, checked ->
current.copy(showAodBatteryPercentWhenUnplugged = checked)
}
+ binding!!.debugMinus10.setOnClickListener { changeDebugCount(-10) }
+ binding!!.debugMinus1.setOnClickListener { changeDebugCount(-1) }
+ binding!!.debugPlus1.setOnClickListener { changeDebugCount(1) }
+ binding!!.debugPlus10.setOnClickListener { changeDebugCount(10) }
+ binding!!.debugReset.setOnClickListener { setDebugCount(0) }
+ binding!!.debugCycle.setOnCheckedChangeListener { _, enabled ->
+ if (updatingCycle) return@setOnCheckedChangeListener
+ if (enabled && !DebugNotifications.hasPermission(requireContext())) {
+ pendingCycle = true
+ permissionRequest.launch(Manifest.permission.POST_NOTIFICATIONS)
+ } else {
+ DebugNotifications.setCycling(requireContext(), enabled)
+ }
+ }
}
override fun onResume() {
super.onResume()
activity?.title = getString(R.string.page_miscellaneous)
+ DebugNotifications.apply(requireContext())
+ refreshDebugNotifications()
}
override fun onDestroyView() {
@@ -48,4 +83,27 @@ class MiscellaneousFragment : Fragment(R.layout.fragment_miscellaneous) {
store.update { policy -> policy.copy(systemUiMisc = update(policy.systemUiMisc, checked)) }
}
}
+
+ private fun changeDebugCount(delta: Int) = setDebugCount(DebugNotifications.count(requireContext()) + delta)
+
+ private fun setDebugCount(count: Int) {
+ val desired = count.coerceIn(0, DebugNotifications.MAX_COUNT)
+ if (desired > 0 && !DebugNotifications.hasPermission(requireContext())) {
+ pendingCount = desired
+ permissionRequest.launch(Manifest.permission.POST_NOTIFICATIONS)
+ return
+ }
+ DebugNotifications.setCount(requireContext(), desired)
+ refreshDebugNotifications()
+ }
+
+ private fun refreshDebugNotifications() {
+ val context = context ?: return
+ val count = DebugNotifications.count(context)
+ binding?.debugCount?.text = count.toString()
+ binding?.debugCycle?.isEnabled = count > 0
+ updatingCycle = true
+ binding?.debugCycle?.isChecked = DebugNotifications.isCycling(context)
+ updatingCycle = false
+ }
}
diff --git a/app/src/main/res/layout/fragment_cards_layout.xml b/app/src/main/res/layout/fragment_cards_layout.xml
index 9da2338..79fbe7d 100644
--- a/app/src/main/res/layout/fragment_cards_layout.xml
+++ b/app/src/main/res/layout/fragment_cards_layout.xml
@@ -12,7 +12,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/fragment_miscellaneous.xml b/app/src/main/res/layout/fragment_miscellaneous.xml
index 1a39ca9..7bd61fb 100644
--- a/app/src/main/res/layout/fragment_miscellaneous.xml
+++ b/app/src/main/res/layout/fragment_miscellaneous.xml
@@ -15,13 +15,6 @@
android:layout_height="wrap_content"
android:text="@string/keep_aod_visible_during_calls" />
-
-
-
-
+
+
+ android:text="@string/debug_notifications_description"
+ android:textSize="14sp" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/drawer_menu.xml b/app/src/main/res/menu/drawer_menu.xml
index 30dcd9a..8f93e3a 100644
--- a/app/src/main/res/menu/drawer_menu.xml
+++ b/app/src/main/res/menu/drawer_menu.xml
@@ -26,9 +26,6 @@
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 410e14a..0b1e4bd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -18,7 +18,6 @@
Rules
Apps
Notifications
- Debug icons
Cards layout
Miscellaneous
Filter apps
@@ -29,14 +28,10 @@
Rules
Apps
Cards layout
- Debug icons
Miscellaneous
Filter logging
Filter apps
Keep AOD visible during calls
- Prevents OneUI from hiding the always-on display while a call is active.
Show battery % on lockscreen when unplugged
- Shows the battery percentage even when the phone is not charging.
Show battery % on AOD when unplugged
- Shows the battery percentage in the bottom AOD area even when the phone is not charging.