diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarDividerPopupView.kt index 17d10d3574..a347908473 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 = requireViewById(R.id.taskbar_switch_option) - val alwaysShowTaskbarSwitch = requireViewById(R.id.taskbar_pinning_switch) + val taskbarSwitchOption = findViewById(R.id.taskbar_switch_option) + val alwaysShowTaskbarSwitch = findViewById(R.id.taskbar_pinning_switch) val navigationModeChangeOption = - requireViewById(R.id.navigation_mode_switch_option) + findViewById(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 c45c66741d..9b50c5d77b 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 = requireViewById(R.id.content) - arrow = requireViewById(R.id.arrow) + content = findViewById(R.id.content) + arrow = findViewById(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 de4175ddc1..e99fa50e61 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 { - requireViewById(R.id.swipe_animation).supportLightTheme() + findViewById(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 = 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) + 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) 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 5a5ff8e880..5eb240ec7c 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 931f692fa2..5c7f2be2e0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt +++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt @@ -61,12 +61,11 @@ class NavButtonLayoutFactory { phoneMode: Boolean, @Rotation surfaceRotation: Int ): NavButtonLayoutter { - val navButtonContainer = - navButtonsView.requireViewById(ID_END_NAV_BUTTONS) + val navButtonContainer = navButtonsView.findViewById(ID_END_NAV_BUTTONS) val endContextualContainer = - navButtonsView.requireViewById(ID_END_CONTEXTUAL_BUTTONS) + navButtonsView.findViewById(ID_END_CONTEXTUAL_BUTTONS) val startContextualContainer = - navButtonsView.requireViewById(ID_START_CONTEXTUAL_BUTTONS) + navButtonsView.findViewById(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 a632cec94c..ae500a170b 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt +++ b/quickstep/src/com/android/quickstep/util/SplitSelectDataHolder.kt @@ -160,19 +160,18 @@ class SplitSelectDataHolder( */ fun setSecondTask(pendingIntent: PendingIntent) { secondPendingIntent = pendingIntent - secondUser = pendingIntent.creatorUserHandle + secondUser = pendingIntent.creatorUserHandle!! } - private fun getShortcutInfo(intent: Intent?, user: UserHandle): ShortcutInfo? { - val intentPackage = intent?.getPackage() - if (intentPackage == null) { + private fun getShortcutInfo(intent: Intent?, user: UserHandle?): ShortcutInfo? { + if (intent?.getPackage() == null) { return null } val shortcutId = intent.getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID) ?: return null try { val context: Context = context.createPackageContextAsUser( - intentPackage, 0 /* flags */, user) + intent.getPackage(), 0 /* flags */, user) return ShortcutInfo.Builder(context, shortcutId).build() } catch (e: PackageManager.NameNotFoundException) { Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage()) @@ -255,7 +254,7 @@ class SplitSelectDataHolder( * convert [secondIntent] */ private fun convertIntentsToFinalTypes() { - initialShortcut = getShortcutInfo(initialIntent, checkNotNull(initialUser)) + initialShortcut = getShortcutInfo(initialIntent, initialUser) initialPendingIntent = getPendingIntent(initialIntent, initialUser) initialIntent = null @@ -269,7 +268,7 @@ class SplitSelectDataHolder( return } - secondShortcut = getShortcutInfo(secondIntent, checkNotNull(secondUser)) + secondShortcut = getShortcutInfo(secondIntent, secondUser) secondPendingIntent = getPendingIntent(secondIntent, secondUser) secondIntent = null } @@ -422,4 +421,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 b373911f3d..8ee0fbb671 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 = requireViewById(R.id.menu_option_layout) + optionLayout = findViewById(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.requireViewById(R.id.icon), - menuOptionView.requireViewById(R.id.text) + menuOptionView.findViewById(R.id.icon), + menuOptionView.findViewById(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 04735f20b1..4fa5352a1c 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)