From 184391599b3b2946a485fc31e3b6896d2ab6f303 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 28 May 2022 01:48:39 +0530 Subject: Fix ClipboardService crash (#1928) * Fix clipboard service crash on API 31 * all: use ints directly for SDK version checks I much prefer it this way --- .../main/java/dev/msfjarvis/aps/util/shortcuts/ShortcutHandler.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/src/main/java/dev/msfjarvis/aps/util/shortcuts') diff --git a/app/src/main/java/dev/msfjarvis/aps/util/shortcuts/ShortcutHandler.kt b/app/src/main/java/dev/msfjarvis/aps/util/shortcuts/ShortcutHandler.kt index 59eda23e..2ca881ed 100644 --- a/app/src/main/java/dev/msfjarvis/aps/util/shortcuts/ShortcutHandler.kt +++ b/app/src/main/java/dev/msfjarvis/aps/util/shortcuts/ShortcutHandler.kt @@ -42,7 +42,7 @@ constructor( * [MAX_SHORTCUT_COUNT] and older items are removed by a simple LRU sweep. */ fun addDynamicShortcut(item: PasswordItem, intent: Intent) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return + if (Build.VERSION.SDK_INT < 25) return val shortcutManager: ShortcutManager = context.getSystemService() ?: return val shortcut = buildShortcut(item, intent) val shortcuts = shortcutManager.dynamicShortcuts @@ -67,7 +67,7 @@ constructor( * a no-op if the user's default launcher does not support pinned shortcuts. */ fun addPinnedShortcut(item: PasswordItem, intent: Intent) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return + if (Build.VERSION.SDK_INT < 26) return val shortcutManager: ShortcutManager = context.getSystemService() ?: return if (!shortcutManager.isRequestPinShortcutSupported) { logcat { "addPinnedShortcut: pin shortcuts unsupported" } @@ -78,7 +78,7 @@ constructor( } /** Creates a [ShortcutInfo] from [item] and assigns [intent] to it. */ - @RequiresApi(Build.VERSION_CODES.N_MR1) + @RequiresApi(25) private fun buildShortcut(item: PasswordItem, intent: Intent): ShortcutInfo { return ShortcutInfo.Builder(context, item.fullPathToParent) .setShortLabel(item.toString()) @@ -93,7 +93,7 @@ constructor( * data, which ensures that the get/set dance in [addDynamicShortcut] does not cause invalidation * of icon assets, resulting in invisible icons in all but the newest launcher shortcut. */ - @RequiresApi(Build.VERSION_CODES.N_MR1) + @RequiresApi(25) private fun rebuildShortcut(shortcut: ShortcutInfo): ShortcutInfo { // Non-null assertions are fine since we know these values aren't null. return ShortcutInfo.Builder(context, shortcut.id) -- cgit v1.2.3