Merge branch '0000-t-block-user-on-murena-channel' into 'develop'

Block user on the murena channel

See merge request e/os/ntfy-android!9
This commit is contained in:
Jonathan Klee 2024-07-04 05:46:45 +00:00
commit 6f9d4bff5a
6 changed files with 15 additions and 67 deletions

View file

@ -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<Notification>)
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

View file

@ -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

View file

@ -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,

View file

@ -26,51 +26,4 @@
app:layoutManager="LinearLayoutManager"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/detail_no_notifications" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_sms_gray_48dp"
android:id="@+id/detail_no_notifications_image"/>
<TextView
android:id="@+id/detail_no_notifications_text"
android:text="@string/detail_no_notifications_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:padding="10dp" android:gravity="center_horizontal"
android:paddingStart="50dp" android:paddingEnd="50dp"/>
<TextView
android:text="@string/detail_how_to_intro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/detail_how_to_intro"
android:layout_marginTop="20dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"/>
<TextView
android:text="@string/detail_how_to_example"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/detail_how_to_example"
android:layout_marginTop="7dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"/>
<TextView
android:text="@string/detail_how_to_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/detail_how_to_link"
android:layout_marginTop="7dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:linksClickable="true"
android:autoLink="web"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -10,7 +10,7 @@
- https://developer.android.com/guide/topics/ui/look-and-feel/themes
-->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/e_accent_dark</item>
<item name="colorAccent">@color/e_accent_dark</item> <!-- checkboxes, text fields -->
<item name="android:colorBackground">@color/black_900</item> <!-- background -->

View file

@ -1,6 +1,6 @@
<resources>
<!-- Main app theme; dark theme styles see values-night/styles.xml -->
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/e_accent_light</item>
<item name="colorAccent">@color/e_accent_light</item> <!-- checkboxes, text fields -->
<item name="android:colorBackground">@color/white</item> <!-- background -->