Fix kotlin nullable errors in Launcher3
Fix kotlin nullable errors that were exposed by setting the retention of android.annotation.NonNull and android.annotation.Nullable to class retention. Bug: 294110802 Test: builds (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:2608381792389b60ba37c08afcea09dca3c6ff9c) Merged-In: I26edfec35dca14abe90b08e3c74de0446eda95d2 Change-Id: I26edfec35dca14abe90b08e3c74de0446eda95d2
This commit is contained in:
committed by
Cherrypicker Worker
parent
bb637e04f0
commit
e892df24ca
@@ -101,10 +101,10 @@ constructor(
|
||||
@SuppressLint("UseSwitchCompatOrMaterialCode")
|
||||
override fun onFinishInflate() {
|
||||
super.onFinishInflate()
|
||||
val taskbarSwitchOption = findViewById<LinearLayout>(R.id.taskbar_switch_option)
|
||||
val alwaysShowTaskbarSwitch = findViewById<Switch>(R.id.taskbar_pinning_switch)
|
||||
val taskbarSwitchOption = requireViewById<LinearLayout>(R.id.taskbar_switch_option)
|
||||
val alwaysShowTaskbarSwitch = requireViewById<Switch>(R.id.taskbar_pinning_switch)
|
||||
val navigationModeChangeOption =
|
||||
findViewById<LinearLayout>(R.id.navigation_mode_switch_option)
|
||||
requireViewById<LinearLayout>(R.id.navigation_mode_switch_option)
|
||||
alwaysShowTaskbarSwitch.isChecked = alwaysShowTaskbarOn
|
||||
taskbarSwitchOption.setOnClickListener {
|
||||
alwaysShowTaskbarSwitch.isClickable = true
|
||||
|
||||
@@ -156,18 +156,19 @@ 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) {
|
||||
private fun getShortcutInfo(intent: Intent?, user: UserHandle): ShortcutInfo? {
|
||||
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)
|
||||
intentPackage, 0 /* flags */, user)
|
||||
return ShortcutInfo.Builder(context, shortcutId).build()
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
Log.w(TAG, "Failed to create a ShortcutInfo for " + intent.getPackage())
|
||||
@@ -250,7 +251,7 @@ class SplitSelectDataHolder(
|
||||
* convert [secondIntent]
|
||||
*/
|
||||
private fun convertIntentsToFinalTypes() {
|
||||
initialShortcut = getShortcutInfo(initialIntent, initialUser)
|
||||
initialShortcut = getShortcutInfo(initialIntent, checkNotNull(initialUser))
|
||||
initialPendingIntent = getPendingIntent(initialIntent, initialUser)
|
||||
initialIntent = null
|
||||
|
||||
@@ -264,7 +265,7 @@ class SplitSelectDataHolder(
|
||||
return
|
||||
}
|
||||
|
||||
secondShortcut = getShortcutInfo(secondIntent, secondUser)
|
||||
secondShortcut = getShortcutInfo(secondIntent, checkNotNull(secondUser))
|
||||
secondPendingIntent = getPendingIntent(secondIntent, secondUser)
|
||||
secondIntent = null
|
||||
}
|
||||
@@ -405,4 +406,4 @@ class SplitSelectDataHolder(
|
||||
writer.println("$prefix\tinitialShortcut= $initialShortcut")
|
||||
writer.println("$prefix\tsecondShortcut= $secondShortcut")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user