diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ead9ae5..3ed9572 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -57,6 +57,15 @@
android:value=".ui.MainActivity"/>
+
+
+
+
+
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 6a13f66..b95eb15 100644
--- a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt
+++ b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt
@@ -4,6 +4,7 @@ import android.app.AlertDialog
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
+import android.content.Intent
import android.os.Bundle
import android.text.Html
import android.view.ActionMode
@@ -220,15 +221,15 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
true
}
R.id.detail_menu_notifications_enabled -> {
- onNotificationSettingsClick(enable = false)
+ onMutedUntilClick(enable = false)
true
}
R.id.detail_menu_notifications_disabled_until -> {
- onNotificationSettingsClick(enable = true)
+ onMutedUntilClick(enable = true)
true
}
R.id.detail_menu_notifications_disabled_forever -> {
- onNotificationSettingsClick(enable = true)
+ onMutedUntilClick(enable = true)
true
}
R.id.detail_menu_enable_instant -> {
@@ -251,6 +252,10 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
onClearClick()
true
}
+ R.id.detail_menu_settings -> {
+ onSettingsClick()
+ true
+ }
R.id.detail_menu_unsubscribe -> {
onDeleteClick()
true
@@ -283,7 +288,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
}
}
- private fun onNotificationSettingsClick(enable: Boolean) {
+ private fun onMutedUntilClick(enable: Boolean) {
if (!enable) {
Log.d(TAG, "Showing notification settings dialog for ${topicShortUrl(subscriptionBaseUrl, subscriptionTopic)}")
val notificationFragment = NotificationFragment()
@@ -441,6 +446,11 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
dialog.show()
}
+ private fun onSettingsClick() {
+ Log.d(TAG, "Opening subscription settings for ${topicShortUrl(subscriptionBaseUrl, subscriptionTopic)}")
+ startActivity(Intent(this, DetailSettingsActivity::class.java))
+ }
+
private fun onDeleteClick() {
Log.d(TAG, "Deleting subscription ${topicShortUrl(subscriptionBaseUrl, subscriptionTopic)}")
diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt
new file mode 100644
index 0000000..62d674c
--- /dev/null
+++ b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt
@@ -0,0 +1,93 @@
+package io.heckel.ntfy.ui
+
+import android.Manifest
+import android.content.ClipData
+import android.content.ClipboardManager
+import android.content.Context
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.os.Build
+import android.os.Bundle
+import android.text.TextUtils
+import android.widget.Toast
+import androidx.annotation.Keep
+import androidx.appcompat.app.AppCompatActivity
+import androidx.appcompat.app.AppCompatDelegate
+import androidx.core.app.ActivityCompat
+import androidx.core.content.ContextCompat
+import androidx.fragment.app.DialogFragment
+import androidx.lifecycle.lifecycleScope
+import androidx.preference.*
+import androidx.preference.Preference.OnPreferenceClickListener
+import com.google.gson.Gson
+import io.heckel.ntfy.BuildConfig
+import io.heckel.ntfy.R
+import io.heckel.ntfy.db.Repository
+import io.heckel.ntfy.db.User
+import io.heckel.ntfy.log.Log
+import io.heckel.ntfy.service.SubscriberService
+import io.heckel.ntfy.service.SubscriberServiceManager
+import io.heckel.ntfy.util.formatBytes
+import io.heckel.ntfy.util.formatDateShort
+import io.heckel.ntfy.util.shortUrl
+import io.heckel.ntfy.util.toPriorityString
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import okhttp3.RequestBody.Companion.toRequestBody
+import java.util.*
+import java.util.concurrent.TimeUnit
+
+/**
+ * Subscription settings
+ */
+class DetailSettingsActivity : AppCompatActivity() {
+ private lateinit var repository: Repository
+ private lateinit var serviceManager: SubscriberServiceManager
+ private lateinit var settingsFragment: SettingsFragment
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_settings)
+
+ Log.d(TAG, "Create $this")
+
+ repository = Repository.getInstance(this)
+ serviceManager = SubscriberServiceManager(this)
+
+ if (savedInstanceState == null) {
+ settingsFragment = SettingsFragment() // Empty constructor!
+ supportFragmentManager
+ .beginTransaction()
+ .replace(R.id.settings_layout, settingsFragment)
+ .commit()
+ }
+
+ title = getString(R.string.detail_settings_title)
+
+ // Show 'Back' button
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ }
+
+ class SettingsFragment : PreferenceFragmentCompat() {
+ private lateinit var repository: Repository
+ private lateinit var serviceManager: SubscriberServiceManager
+
+ override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+ setPreferencesFromResource(R.xml.detail_preferences, rootKey)
+
+ // Dependencies (Fragments need a default constructor)
+ repository = Repository.getInstance(requireActivity())
+ serviceManager = SubscriberServiceManager(requireActivity())
+
+
+ // xxxxxxxxxxxxxxx
+ }
+
+ }
+
+ companion object {
+ private const val TAG = "NtfyDetailSettingsActiv"
+ }
+}
diff --git a/app/src/main/res/menu/menu_detail_action_bar.xml b/app/src/main/res/menu/menu_detail_action_bar.xml
index 95af4ae..a597f9e 100644
--- a/app/src/main/res/menu/menu_detail_action_bar.xml
+++ b/app/src/main/res/menu/menu_detail_action_bar.xml
@@ -14,5 +14,6 @@
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5fdf941..c326d17 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -162,6 +162,7 @@
Send test notification
Copy topic address
Clear all notifications
+ Subscription settings
Unsubscribe
@@ -173,6 +174,15 @@
Permanently delete
Cancel
+
+ Subscription settings
+ Login
+ For topics that require a login, you may pick the login user here. You can add/edit users in the main settings.
+ SubscriptionAuthUserKey
+ Login user
+ No user selected to log in to the topic
+ User %1$s selected as a login user
+
Pause notifications
Cancel
diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml
index 60528a0..6c4742c 100644
--- a/app/src/main/res/values/values.xml
+++ b/app/src/main/res/values/values.xml
@@ -1,5 +1,6 @@
+
- @string/notification_dialog_show_all
- @string/notification_dialog_30min
diff --git a/app/src/main/res/xml/detail_preferences.xml b/app/src/main/res/xml/detail_preferences.xml
new file mode 100644
index 0000000..69d36d3
--- /dev/null
+++ b/app/src/main/res/xml/detail_preferences.xml
@@ -0,0 +1,12 @@
+
+
+
+
+