diff --git a/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt
index 834440d..36b7df8 100644
--- a/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt
+++ b/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt
@@ -92,12 +92,12 @@ class AddFragment(private val viewModel: SubscriptionsViewModel, private val onS
subscribeButton.isEnabled = false
} else if (useAnotherServerCheckbox.isChecked) {
subscribeButton.isEnabled = topic.isNotBlank()
- && "[-_A-Za-z0-9]+".toRegex().matches(topic)
+ && "[-_A-Za-z0-9]{1,64}".toRegex().matches(topic)
&& baseUrl.isNotBlank()
&& "^https?://.+".toRegex().matches(baseUrl)
} else {
subscribeButton.isEnabled = topic.isNotBlank()
- && "[-_A-Za-z0-9]+".toRegex().matches(topic)
+ && "[-_A-Za-z0-9]{1,64}".toRegex().matches(topic)
}
}
}
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 9bf7b2f..efe9558 100644
--- a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt
+++ b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt
@@ -1,6 +1,10 @@
package io.heckel.ntfy.ui
+import android.R.attr.label
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
@@ -17,16 +21,12 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView
import com.android.volley.VolleyError
-import com.android.volley.toolbox.StringRequest
-import com.android.volley.toolbox.Volley
import io.heckel.ntfy.R
import io.heckel.ntfy.app.Application
import io.heckel.ntfy.data.Notification
import io.heckel.ntfy.data.topicShortUrl
-import io.heckel.ntfy.data.topicUrl
import io.heckel.ntfy.msg.ApiService
import kotlinx.coroutines.Dispatchers
-import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import java.util.*
@@ -203,9 +203,21 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback {
private fun onNotificationClick(notification: Notification) {
if (actionMode != null) {
handleActionModeClick(notification)
+ } else {
+ copyToClipboard(notification)
}
}
+ private fun copyToClipboard(notification: Notification) {
+ val message = notification.message + "\n\n" + Date(notification.timestamp * 1000).toString()
+ val clipboard: ClipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
+ val clip = ClipData.newPlainText("notification message", message)
+ clipboard.setPrimaryClip(clip)
+ Toast
+ .makeText(this, getString(R.string.detail_copied_to_clipboard_message), Toast.LENGTH_LONG)
+ .show()
+ }
+
private fun onNotificationLongClick(notification: Notification) {
if (actionMode == null) {
beginActionMode(notification)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 86285ef..6d5e71b 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -53,6 +53,7 @@
%1$d notification(s) added
No new notifications found
Could not refresh topic: %1$s
+ Copied to clipboard
Send test notification