mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 07:46:55 +00:00
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. This relands I26edfec35dca14abe90b08e3c74de0446eda95d2 with a fix in SplitSelectDataHolder.kt to call createPackageContext when user is null instead of asserting that it is not null. Bug: 294110802 Test: builds Test: WMShellFlickerServiceTests Change-Id: I4525d0fa83a1db9cc5cff90f340fc3f863537c01
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -93,7 +93,7 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
|
||||
tooltipStep = TOOLTIP_STEP_FEATURES
|
||||
inflateTooltip(R.layout.taskbar_edu_swipe)
|
||||
tooltip?.run {
|
||||
findViewById<LottieAnimationView>(R.id.swipe_animation).supportLightTheme()
|
||||
requireViewById<LottieAnimationView>(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<LottieAnimationView>(R.id.splitscreen_animation)
|
||||
val suggestionsAnim = findViewById<LottieAnimationView>(R.id.suggestions_animation)
|
||||
val settingsAnim = findViewById<LottieAnimationView>(R.id.settings_animation)
|
||||
val settingsEdu = findViewById<View>(R.id.settings_edu)
|
||||
val splitscreenAnim = requireViewById<LottieAnimationView>(R.id.splitscreen_animation)
|
||||
val suggestionsAnim = requireViewById<LottieAnimationView>(R.id.suggestions_animation)
|
||||
val settingsAnim = requireViewById<LottieAnimationView>(R.id.settings_animation)
|
||||
val settingsEdu = requireViewById<View>(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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -61,11 +61,12 @@ class NavButtonLayoutFactory {
|
||||
phoneMode: Boolean,
|
||||
@Rotation surfaceRotation: Int
|
||||
): NavButtonLayoutter {
|
||||
val navButtonContainer = navButtonsView.findViewById<LinearLayout>(ID_END_NAV_BUTTONS)
|
||||
val navButtonContainer =
|
||||
navButtonsView.requireViewById<LinearLayout>(ID_END_NAV_BUTTONS)
|
||||
val endContextualContainer =
|
||||
navButtonsView.findViewById<ViewGroup>(ID_END_CONTEXTUAL_BUTTONS)
|
||||
navButtonsView.requireViewById<ViewGroup>(ID_END_CONTEXTUAL_BUTTONS)
|
||||
val startContextualContainer =
|
||||
navButtonsView.findViewById<ViewGroup>(ID_START_CONTEXTUAL_BUTTONS)
|
||||
navButtonsView.requireViewById<ViewGroup>(ID_START_CONTEXTUAL_BUTTONS)
|
||||
val isPhoneNavMode = phoneMode && isThreeButtonNav
|
||||
val isPhoneGestureMode = phoneMode && !isThreeButtonNav
|
||||
return when {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ class TaskMenuViewWithArrow<T : BaseDraggingActivity> : ArrowPopup<T> {
|
||||
|
||||
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<T : BaseDraggingActivity> : ArrowPopup<T> {
|
||||
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
|
||||
|
||||
@@ -189,7 +189,7 @@ class GridSizeMigrationUtilTest {
|
||||
intentIndex = c.getColumnIndex(INTENT)
|
||||
val cellXIndex = c.getColumnIndex(CELLX)
|
||||
val cellYIndex = c.getColumnIndex(CELLY)
|
||||
val locMap = HashMap<String, Point>()
|
||||
val locMap = HashMap<String?, Point>()
|
||||
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<String, Triple<Int, Int, Int>> {
|
||||
private fun parseLocMap(c: Cursor): Map<String?, Triple<Int, Int, Int>> {
|
||||
// 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<String, Triple<Int, Int, Int>>()
|
||||
val locMap = mutableMapOf<String?, Triple<Int, Int, Int>>()
|
||||
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<String, Int>()
|
||||
val locMap = HashMap<String?, Int>()
|
||||
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<String, Int>()
|
||||
val locMap = HashMap<String?, Int>()
|
||||
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<String, Int>()
|
||||
val locMap = HashMap<String?, Int>()
|
||||
while (c.moveToNext()) {
|
||||
locMap[Intent.parseUri(c.getString(intentIndex), 0).getPackage()] =
|
||||
c.getInt(screenIndex)
|
||||
|
||||
Reference in New Issue
Block a user