From 38ca9d7911fa7d86b969c32130f5f532f761c241 Mon Sep 17 00:00:00 2001 From: ligi Date: Thu, 5 Mar 2020 03:10:32 +0100 Subject: [PATCH] Prevent creationg shortcut with empty label - closes #250 --- .../java/org/ligi/passandroid/ui/PassViewActivityBase.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/org/ligi/passandroid/ui/PassViewActivityBase.kt b/android/src/main/java/org/ligi/passandroid/ui/PassViewActivityBase.kt index 5b171d86..1ad9d3d7 100644 --- a/android/src/main/java/org/ligi/passandroid/ui/PassViewActivityBase.kt +++ b/android/src/main/java/org/ligi/passandroid/ui/PassViewActivityBase.kt @@ -156,7 +156,10 @@ open class PassViewActivityBase : PassAndroidActivity() { } else { BitmapFactory.decodeResource(resources, R.drawable.ic_launcher) } - val name: CharSequence = currentPass.description ?: "shortcut" + val name: CharSequence = currentPass.description.let { + if (it.isNullOrEmpty()) "pass" else it + } + val targetIntent = Intent(this, PassViewActivity::class.java) .setAction(Intent.ACTION_MAIN) .putExtra(EXTRA_KEY_UUID, currentPass.id) @@ -166,6 +169,7 @@ open class PassViewActivityBase : PassAndroidActivity() { .setIcon(IconCompat.createWithBitmap(shortcutIcon)) .build() ShortcutManagerCompat.requestPinShortcut(this, shortcutInfo, null) + } inner class UpdateAsync : Runnable {