Copy to clipboard
This commit is contained in:
parent
94d45eee3b
commit
474ab18090
3 changed files with 19 additions and 6 deletions
|
@ -92,12 +92,12 @@ class AddFragment(private val viewModel: SubscriptionsViewModel, private val onS
|
||||||
subscribeButton.isEnabled = false
|
subscribeButton.isEnabled = false
|
||||||
} else if (useAnotherServerCheckbox.isChecked) {
|
} else if (useAnotherServerCheckbox.isChecked) {
|
||||||
subscribeButton.isEnabled = topic.isNotBlank()
|
subscribeButton.isEnabled = topic.isNotBlank()
|
||||||
&& "[-_A-Za-z0-9]+".toRegex().matches(topic)
|
&& "[-_A-Za-z0-9]{1,64}".toRegex().matches(topic)
|
||||||
&& baseUrl.isNotBlank()
|
&& baseUrl.isNotBlank()
|
||||||
&& "^https?://.+".toRegex().matches(baseUrl)
|
&& "^https?://.+".toRegex().matches(baseUrl)
|
||||||
} else {
|
} else {
|
||||||
subscribeButton.isEnabled = topic.isNotBlank()
|
subscribeButton.isEnabled = topic.isNotBlank()
|
||||||
&& "[-_A-Za-z0-9]+".toRegex().matches(topic)
|
&& "[-_A-Za-z0-9]{1,64}".toRegex().matches(topic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package io.heckel.ntfy.ui
|
package io.heckel.ntfy.ui
|
||||||
|
|
||||||
|
import android.R.attr.label
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
|
@ -17,16 +21,12 @@ import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.android.volley.VolleyError
|
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.R
|
||||||
import io.heckel.ntfy.app.Application
|
import io.heckel.ntfy.app.Application
|
||||||
import io.heckel.ntfy.data.Notification
|
import io.heckel.ntfy.data.Notification
|
||||||
import io.heckel.ntfy.data.topicShortUrl
|
import io.heckel.ntfy.data.topicShortUrl
|
||||||
import io.heckel.ntfy.data.topicUrl
|
|
||||||
import io.heckel.ntfy.msg.ApiService
|
import io.heckel.ntfy.msg.ApiService
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -203,9 +203,21 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback {
|
||||||
private fun onNotificationClick(notification: Notification) {
|
private fun onNotificationClick(notification: Notification) {
|
||||||
if (actionMode != null) {
|
if (actionMode != null) {
|
||||||
handleActionModeClick(notification)
|
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) {
|
private fun onNotificationLongClick(notification: Notification) {
|
||||||
if (actionMode == null) {
|
if (actionMode == null) {
|
||||||
beginActionMode(notification)
|
beginActionMode(notification)
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
<string name="detail_refresh_message_result">%1$d notification(s) added</string>
|
<string name="detail_refresh_message_result">%1$d notification(s) added</string>
|
||||||
<string name="detail_refresh_message_no_results">No new notifications found</string>
|
<string name="detail_refresh_message_no_results">No new notifications found</string>
|
||||||
<string name="detail_refresh_message_error">Could not refresh topic: %1$s</string>
|
<string name="detail_refresh_message_error">Could not refresh topic: %1$s</string>
|
||||||
|
<string name="detail_copied_to_clipboard_message">Copied to clipboard</string>
|
||||||
|
|
||||||
<!-- Detail activity: Action bar -->
|
<!-- Detail activity: Action bar -->
|
||||||
<string name="detail_menu_test">Send test notification</string>
|
<string name="detail_menu_test">Send test notification</string>
|
||||||
|
|
Loading…
Reference in a new issue