diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt index bdc717b..5011e7b 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt @@ -76,8 +76,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra notifier = NotificationService(this) appBaseUrl = getString(R.string.app_base_url) - // Show 'Back' button - supportActionBar?.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setDisplayHomeAsUpEnabled(false) // Handle direct deep links to topic "ntfy://..." val url = intent?.data @@ -88,6 +87,10 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra } } + override fun onBackPressed() { + finishAffinity() + } + private fun maybeSubscribeAndLoadView(url: Uri) { if (url.pathSegments.size != 1) { Log.w(TAG, "Invalid link $url. Aborting.") @@ -168,24 +171,12 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra val topicUrl = topicShortUrl(subscriptionBaseUrl, subscriptionTopic) title = subscriptionDisplayName - // Set "how to instructions" - val howToExample: TextView = findViewById(R.id.detail_how_to_example) - howToExample.linksClickable = true - - val howToText = getString(R.string.detail_how_to_example, topicUrl) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - howToExample.text = Html.fromHtml(howToText, Html.FROM_HTML_MODE_LEGACY) - } else { - howToExample.text = Html.fromHtml(howToText) - } - // Swipe to refresh mainListContainer = findViewById(R.id.detail_notification_list_container) mainListContainer.setOnRefreshListener { refresh() } mainListContainer.setColorSchemeResources(Colors.refreshProgressIndicator) // Update main list based on viewModel (& its datasource/livedata) - val noEntriesText: View = findViewById(R.id.detail_no_notifications) val onNotificationClick = { n: Notification -> onNotificationClick(n) } val onNotificationLongClick = { n: Notification -> onNotificationLongClick(n) } @@ -199,10 +190,8 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra adapter.submitList(it as MutableList) if (it.isEmpty()) { mainListContainer.visibility = View.GONE - noEntriesText.visibility = View.VISIBLE } else { mainListContainer.visibility = View.VISIBLE - noEntriesText.visibility = View.GONE } // Cancel notifications that still have popups diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt index b44acab..25d1cdf 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt @@ -207,6 +207,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc val defaultTopic = TOPIC_MURENA val hasTestTopic = subscriptions.any { it.topic == defaultTopic } if (hasTestTopic) { + showMurenaSub() return@launch } @@ -216,7 +217,7 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc topic = defaultTopic, instant = true, dedicatedChannels = false, - mutedUntil = 0, + mutedUntil = Repository.MUTED_UNTIL_FOREVER, minPriority = Repository.MIN_PRIORITY_USE_GLOBAL, autoDelete = Repository.AUTO_DELETE_USE_GLOBAL, insistent = Repository.INSISTENT_MAX_PRIORITY_USE_GLOBAL, @@ -230,9 +231,14 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc lastActive = Date().time / 1000 ) viewModel.add(subscription) + showMurenaSub() } } + private suspend fun showMurenaSub() { + startDetailView(repository.getSubscriptions().find { it.topic == "murena_notification" }!!) + } + private fun maybeRequestNotificationPermission() { // Android 13 (SDK 33) requires that we ask for permission to post notifications // https://developer.android.com/develop/ui/views/notifications/notification-permission diff --git a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt index e30f0ed..778d43a 100644 --- a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +++ b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt @@ -84,7 +84,7 @@ class BroadcastReceiver : android.content.BroadcastReceiver() { topic = topic, instant = true, // No Firebase, always instant! dedicatedChannels = false, - mutedUntil = 0, + mutedUntil = Repository.MUTED_UNTIL_FOREVER, minPriority = Repository.MIN_PRIORITY_USE_GLOBAL, autoDelete = Repository.AUTO_DELETE_USE_GLOBAL, insistent = Repository.INSISTENT_MAX_PRIORITY_USE_GLOBAL, diff --git a/app/src/main/res/layout/activity_detail.xml b/app/src/main/res/layout/activity_detail.xml index 67a2df3..e8548a9 100644 --- a/app/src/main/res/layout/activity_detail.xml +++ b/app/src/main/res/layout/activity_detail.xml @@ -26,51 +26,4 @@ app:layoutManager="LinearLayoutManager"/> - - - - - - - - diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 6733324..565fd3c 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -10,7 +10,7 @@ - https://developer.android.com/guide/topics/ui/look-and-feel/themes --> -