Do not trim text in clipboard
This commit is contained in:
Tibor Kaputa 2023-10-11 09:53:37 +02:00 committed by GitHub
commit d310b7ad58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 3 deletions

View File

@ -24,7 +24,7 @@ class AddOrEditClipDialog(val activity: BaseSimpleActivity, val originalClip: Cl
activity.setupDialogStuff(binding.root, this) { alertDialog -> activity.setupDialogStuff(binding.root, this) { alertDialog ->
alertDialog.showKeyboard(binding.addClipValue) alertDialog.showKeyboard(binding.addClipValue)
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val clipValue = binding.addClipValue.value val clipValue = binding.addClipValue.text.toString()
if (clipValue.isEmpty()) { if (clipValue.isEmpty()) {
activity.toast(R.string.value_cannot_be_empty) activity.toast(R.string.value_cannot_be_empty)
return@setOnClickListener return@setOnClickListener

View File

@ -47,7 +47,7 @@ val Context.clipsDB: ClipsDao
fun Context.getCurrentClip(): String? { fun Context.getCurrentClip(): String? {
val clipboardManager = (getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager) val clipboardManager = (getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager)
return clipboardManager.primaryClip?.getItemAt(0)?.text?.trim()?.toString() return clipboardManager.primaryClip?.getItemAt(0)?.text?.toString()
} }
fun Context.getStrokeColor(): Int { fun Context.getStrokeColor(): Int {

View File

@ -8,7 +8,6 @@ class ClipsHelper(val context: Context) {
// make sure clips have unique values // make sure clips have unique values
fun insertClip(clip: Clip): Long { fun insertClip(clip: Clip): Long {
clip.value = clip.value.trim()
return if (context.clipsDB.getClipWithValue(clip.value) == null) { return if (context.clipsDB.getClipWithValue(clip.value) == null) {
context.clipsDB.insertOrUpdate(clip) context.clipsDB.insertOrUpdate(clip)
} else { } else {