diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt index a347908473..17d10d3574 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt @@ -101,10 +101,10 @@ constructor( @SuppressLint("UseSwitchCompatOrMaterialCode") override fun onFinishInflate() { super.onFinishInflate() - val taskbarSwitchOption = findViewById(R.id.taskbar_switch_option) - val alwaysShowTaskbarSwitch = findViewById(R.id.taskbar_pinning_switch) + val taskbarSwitchOption = requireViewById(R.id.taskbar_switch_option) + val alwaysShowTaskbarSwitch = requireViewById(R.id.taskbar_pinning_switch) val navigationModeChangeOption = - findViewById(R.id.navigation_mode_switch_option) + requireViewById(R.id.navigation_mode_switch_option) alwaysShowTaskbarSwitch.isChecked = alwaysShowTaskbarOn taskbarSwitchOption.setOnClickListener { alwaysShowTaskbarSwitch.isClickable = true diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt index 9b50c5d77b..c45c66741d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt @@ -97,8 +97,8 @@ constructor( override fun onFinishInflate() { super.onFinishInflate() - content = findViewById(R.id.content) - arrow = findViewById(R.id.arrow) + content = requireViewById(R.id.content) + arrow = requireViewById(R.id.arrow) arrow.background = RoundedArrowDrawable( arrowWidth, diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt index e99fa50e61..de4175ddc1 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt @@ -93,7 +93,7 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) : tooltipStep = TOOLTIP_STEP_FEATURES inflateTooltip(R.layout.taskbar_edu_swipe) tooltip?.run { - findViewById(R.id.swipe_animation).supportLightTheme() + requireViewById(R.id.swipe_animation).supportLightTheme() show() } } @@ -112,10 +112,10 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) : tooltipStep = TOOLTIP_STEP_NONE inflateTooltip(R.layout.taskbar_edu_features) tooltip?.run { - val splitscreenAnim = findViewById(R.id.splitscreen_animation) - val suggestionsAnim = findViewById(R.id.suggestions_animation) - val settingsAnim = findViewById(R.id.settings_animation) - val settingsEdu = findViewById(R.id.settings_edu) + val splitscreenAnim = requireViewById(R.id.splitscreen_animation) + val suggestionsAnim = requireViewById(R.id.suggestions_animation) + val settingsAnim = requireViewById(R.id.settings_animation) + val settingsEdu = requireViewById(R.id.settings_edu) splitscreenAnim.supportLightTheme() suggestionsAnim.supportLightTheme() settingsAnim.supportLightTheme() @@ -186,7 +186,7 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) : private fun createAccessibilityDelegate() = object : View.AccessibilityDelegate() { override fun performAccessibilityAction( - host: View?, + host: View, action: Int, args: Bundle? ): Boolean { @@ -197,22 +197,22 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) : return super.performAccessibilityAction(host, action, args) } - override fun onPopulateAccessibilityEvent(host: View?, event: AccessibilityEvent?) { + override fun onPopulateAccessibilityEvent(host: View, event: AccessibilityEvent) { super.onPopulateAccessibilityEvent(host, event) - if (event?.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { - event.text?.add(host?.context?.getText(R.string.taskbar_edu_a11y_title)) + if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { + event.text.add(host.context?.getText(R.string.taskbar_edu_a11y_title)) } } override fun onInitializeAccessibilityNodeInfo( - host: View?, - info: AccessibilityNodeInfo? + host: View, + info: AccessibilityNodeInfo ) { super.onInitializeAccessibilityNodeInfo(host, info) - info?.addAction( + info.addAction( AccessibilityNodeInfo.AccessibilityAction( R.id.close, - host?.context?.getText(R.string.taskbar_edu_close) + host.context?.getText(R.string.taskbar_edu_close) ) ) } diff --git a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt index 5eb240ec7c..5a5ff8e880 100644 --- a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt @@ -192,13 +192,13 @@ class VoiceInteractionWindowController(val context: TaskbarActivityContext) : removeOnAttachStateChangeListener(pendingAttachedToWindowListener) pendingAttachedToWindowListener = object : View.OnAttachStateChangeListener { - override fun onViewAttachedToWindow(v: View?) { + override fun onViewAttachedToWindow(v: View) { onAttachedToWindow() removeOnAttachStateChangeListener(this) pendingAttachedToWindowListener = null } - override fun onViewDetachedFromWindow(v: View?) {} + override fun onViewDetachedFromWindow(v: View) {} } addOnAttachStateChangeListener(pendingAttachedToWindowListener) } diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt index 5c7f2be2e0..931f692fa2 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt @@ -61,11 +61,12 @@ class NavButtonLayoutFactory { phoneMode: Boolean, @Rotation surfaceRotation: Int ): NavButtonLayoutter { - val navButtonContainer = navButtonsView.findViewById(ID_END_NAV_BUTTONS) + val navButtonContainer = + navButtonsView.requireViewById(ID_END_NAV_BUTTONS) val endContextualContainer = - navButtonsView.findViewById(ID_END_CONTEXTUAL_BUTTONS) + navButtonsView.requireViewById(ID_END_CONTEXTUAL_BUTTONS) val startContextualContainer = - navButtonsView.findViewById(ID_START_CONTEXTUAL_BUTTONS) + navButtonsView.requireViewById(ID_START_CONTEXTUAL_BUTTONS) val isPhoneNavMode = phoneMode && isThreeButtonNav val isPhoneGestureMode = phoneMode && !isThreeButtonNav return when { diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt index ae500a170b..69c4197d36 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt +++ b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt @@ -160,18 +160,23 @@ class SplitSelectDataHolder( */ fun setSecondTask(pendingIntent: PendingIntent) { secondPendingIntent = pendingIntent - secondUser = pendingIntent.creatorUserHandle!! + secondUser = pendingIntent.creatorUserHandle } private fun getShortcutInfo(intent: Intent?, user: UserHandle?): ShortcutInfo? { - if (intent?.getPackage() == null) { + val intentPackage = intent?.getPackage() + if (intentPackage == null) { return null } val shortcutId = intent.getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID) ?: return null try { - val context: Context = context.createPackageContextAsUser( - intent.getPackage(), 0 /* flags */, user) + val context: Context = + if (user != null) { + context.createPackageContextAsUser(intentPackage, 0 /* flags */, user) + } else { + context.createPackageContext(intentPackage, 0 /* *flags */) + } return ShortcutInfo.Builder(context, shortcutId).build() } catch (e: PackageManager.NameNotFoundException) { Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage()) @@ -421,4 +426,4 @@ class SplitSelectDataHolder( writer.println("$prefix\tinitialShortcut= $initialShortcut") writer.println("$prefix\tsecondShortcut= $secondShortcut") } -} \ No newline at end of file +} diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt index 8ee0fbb671..b373911f3d 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt @@ -121,7 +121,7 @@ class TaskMenuViewWithArrow : ArrowPopup { override fun onFinishInflate() { super.onFinishInflate() - optionLayout = findViewById(R.id.menu_option_layout) + optionLayout = requireViewById(R.id.menu_option_layout) } private fun populateAndShowForTask( @@ -193,8 +193,8 @@ class TaskMenuViewWithArrow : ArrowPopup { mActivityContext.layoutInflater.inflate(R.layout.task_view_menu_option, this, false) as LinearLayout menuOption.setIconAndLabelFor( - menuOptionView.findViewById(R.id.icon), - menuOptionView.findViewById(R.id.text) + menuOptionView.requireViewById(R.id.icon), + menuOptionView.requireViewById(R.id.text) ) val lp = menuOptionView.layoutParams as LayoutParams lp.width = menuWidth diff --git a/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt b/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt index 4fa5352a1c..04735f20b1 100644 --- a/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt +++ b/tests/src/com/android/launcher3/model/GridSizeMigrationUtilTest.kt @@ -189,7 +189,7 @@ class GridSizeMigrationUtilTest { intentIndex = c.getColumnIndex(INTENT) val cellXIndex = c.getColumnIndex(CELLX) val cellYIndex = c.getColumnIndex(CELLY) - val locMap = HashMap() + val locMap = HashMap() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = Point(c.getInt(cellXIndex), c.getInt(cellYIndex)) @@ -435,13 +435,13 @@ class GridSizeMigrationUtilTest { c.close() } - private fun parseLocMap(c: Cursor): Map> { + private fun parseLocMap(c: Cursor): Map> { // Check workspace items val intentIndex = c.getColumnIndex(INTENT) val screenIndex = c.getColumnIndex(SCREEN) val cellXIndex = c.getColumnIndex(CELLX) val cellYIndex = c.getColumnIndex(CELLY) - val locMap = mutableMapOf>() + val locMap = mutableMapOf>() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = Triple(c.getInt(screenIndex), c.getInt(cellXIndex), c.getInt(cellYIndex)) @@ -653,7 +653,7 @@ class GridSizeMigrationUtilTest { val screenIndex = c.getColumnIndex(SCREEN) // Get in which screen the icon is - val locMap = HashMap() + val locMap = HashMap() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = c.getInt(screenIndex) @@ -715,7 +715,7 @@ class GridSizeMigrationUtilTest { val screenIndex = c.getColumnIndex(SCREEN) // Get in which screen the icon is - val locMap = HashMap() + val locMap = HashMap() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = c.getInt(screenIndex) @@ -775,7 +775,7 @@ class GridSizeMigrationUtilTest { val screenIndex = c.getColumnIndex(SCREEN) // Get in which screen the icon is - val locMap = HashMap() + val locMap = HashMap() while (c.moveToNext()) { locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] = c.getInt(screenIndex)