From 3455f8d0f6c1e7a2b9eb3fb64d534276d2932038 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Fri, 11 May 2018 20:02:20 -0700 Subject: [PATCH] Fixing crash on keyboard shortcuts popup Bug: 76218025 Test: Manual Change-Id: I11c9005764c7b0492138dc17716a0c6c4578798e --- src/com/android/launcher3/Launcher.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 521ad48a38..b45ee2d69b 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2291,16 +2291,18 @@ public class Launcher extends BaseDraggingActivity shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.all_apps_button_label), KeyEvent.KEYCODE_A, KeyEvent.META_CTRL_ON)); } - View currentFocus = getCurrentFocus(); - if (new CustomActionsPopup(this, currentFocus).canShow()) { - shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.custom_actions), - KeyEvent.KEYCODE_O, KeyEvent.META_CTRL_ON)); - } - if (currentFocus.getTag() instanceof ItemInfo - && DeepShortcutManager.supportsShortcuts((ItemInfo) currentFocus.getTag())) { - shortcutInfos.add(new KeyboardShortcutInfo( - getString(R.string.shortcuts_menu_with_notifications_description), - KeyEvent.KEYCODE_S, KeyEvent.META_CTRL_ON)); + final View currentFocus = getCurrentFocus(); + if (currentFocus != null) { + if (new CustomActionsPopup(this, currentFocus).canShow()) { + shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.custom_actions), + KeyEvent.KEYCODE_O, KeyEvent.META_CTRL_ON)); + } + if (currentFocus.getTag() instanceof ItemInfo + && DeepShortcutManager.supportsShortcuts((ItemInfo) currentFocus.getTag())) { + shortcutInfos.add(new KeyboardShortcutInfo( + getString(R.string.shortcuts_menu_with_notifications_description), + KeyEvent.KEYCODE_S, KeyEvent.META_CTRL_ON)); + } } if (!shortcutInfos.isEmpty()) { data.add(new KeyboardShortcutGroup(getString(R.string.home_screen), shortcutInfos));