Fix task bar crash in gesture nav mode with task bar / nav bar unification on
a11yButton is reserved for 3-button mode so it can be null. Also TaskbarNavLayoutter is used for large screen both in gesture nav and 3-button mode, so need to check isContextualButtonShowing to add contextual buttons
Fixes: 300849078
Test: Make sure that it doesn't crash in large screen gesture nav mode
Change-Id: I9d0694b7f4c95461f24efb2af1af905e68e3cd8d
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
index 9758d44..7529508 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/AbstractNavButtonLayoutter.kt
@@ -46,7 +46,7 @@
protected val startContextualContainer: ViewGroup,
protected val imeSwitcher: ImageView?,
protected val rotationButton: RotationButton?,
- protected val a11yButton: ImageView
+ protected val a11yButton: ImageView?
) : NavButtonLayoutter {
protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt
index f254ee8..e7847f3 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/KidsNavLayoutter.kt
@@ -35,7 +35,7 @@
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView
+ a11yButton: ImageView?
) :
AbstractNavButtonLayoutter(
resources,
@@ -114,7 +114,9 @@
startContextualContainer.addView(imeSwitcher)
imeSwitcher.layoutParams = getParamsToCenterView()
}
- endContextualContainer.addView(a11yButton)
+ if (a11yButton != null) {
+ endContextualContainer.addView(a11yButton)
+ }
if (rotationButton != null) {
endContextualContainer.addView(rotationButton.currentView)
rotationButton.currentView.layoutParams = getParamsToCenterView()
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt
index 7db1a37..c502cdb 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/NavButtonLayoutFactory.kt
@@ -58,7 +58,7 @@
navButtonsView: FrameLayout,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView,
+ a11yButton: ImageView?,
resources: Resources,
isKidsMode: Boolean,
isInSetup: Boolean,
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt
index c1dae40..d6ea7f0 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneGestureLayoutter.kt
@@ -31,7 +31,7 @@
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView
+ a11yButton: ImageView?
) :
AbstractNavButtonLayoutter(
resources,
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt
index efe9d4b..54edd21 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneLandscapeNavLayoutter.kt
@@ -36,7 +36,7 @@
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView,
+ a11yButton: ImageView?,
) :
AbstractNavButtonLayoutter(
resources,
@@ -113,7 +113,9 @@
startContextualContainer.addView(imeSwitcher)
imeSwitcher.layoutParams = getParamsToCenterView()
}
- startContextualContainer.addView(a11yButton)
+ if (a11yButton != null) {
+ startContextualContainer.addView(a11yButton)
+ }
if (rotationButton != null) {
startContextualContainer.addView(rotationButton.currentView)
rotationButton.currentView.layoutParams = getParamsToCenterView()
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt
index ad03e5b..34df282 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhonePortraitNavLayoutter.kt
@@ -35,7 +35,7 @@
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView,
+ a11yButton: ImageView?,
) :
AbstractNavButtonLayoutter(
resources,
@@ -111,7 +111,9 @@
endContextualContainer.addView(imeSwitcher)
imeSwitcher.layoutParams = getParamsToCenterView()
}
- endContextualContainer.addView(a11yButton)
+ if (a11yButton != null) {
+ endContextualContainer.addView(a11yButton)
+ }
if (rotationButton != null) {
endContextualContainer.addView(rotationButton.currentView)
rotationButton.currentView.layoutParams = getParamsToCenterView()
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt
index fd6e991..cfe1276 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/PhoneSeascapeNavLayoutter.kt
@@ -31,7 +31,7 @@
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView
+ a11yButton: ImageView?
) :
PhoneLandscapeNavLayoutter(
resources,
@@ -63,7 +63,9 @@
endContextualContainer.addView(imeSwitcher)
imeSwitcher.layoutParams = getParamsToCenterView()
}
- endContextualContainer.addView(a11yButton)
+ if (a11yButton != null) {
+ endContextualContainer.addView(a11yButton)
+ }
if (rotationButton != null) {
endContextualContainer.addView(rotationButton.currentView)
rotationButton.currentView.layoutParams = getParamsToCenterView()
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt
index db245b8..36f5150 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/SetupNavLayoutter.kt
@@ -32,7 +32,7 @@
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView
+ a11yButton: ImageView?
) :
AbstractNavButtonLayoutter(
resources,
@@ -72,7 +72,9 @@
startContextualContainer.addView(imeSwitcher)
imeSwitcher.layoutParams = getParamsToCenterView()
}
- endContextualContainer.addView(a11yButton)
+ if (a11yButton != null) {
+ endContextualContainer.addView(a11yButton)
+ }
if (rotationButton != null) {
endContextualContainer.addView(rotationButton.currentView)
rotationButton.currentView.layoutParams = getParamsToCenterView()
diff --git a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt
index 56e55bb..58dce69 100644
--- a/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/navbutton/TaskbarNavLayoutter.kt
@@ -26,7 +26,10 @@
import com.android.launcher3.R
import com.android.systemui.shared.rotation.RotationButton
-/** Layoutter for showing 3 button navigation on large screen */
+/**
+ * Layoutter for rendering task bar in large screen. {@param isContextualButtonShowing} is true in
+ * 3-button mode.
+ */
class TaskbarNavLayoutter(
resources: Resources,
navBarContainer: LinearLayout,
@@ -34,7 +37,7 @@
startContextualContainer: ViewGroup,
imeSwitcher: ImageView?,
rotationButton: RotationButton?,
- a11yButton: ImageView
+ a11yButton: ImageView?
) :
AbstractNavButtonLayoutter(
resources,
@@ -89,24 +92,28 @@
endContextualContainer.removeAllViews()
startContextualContainer.removeAllViews()
- val endContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- endContextualContainerParams.gravity = Gravity.END or Gravity.CENTER_VERTICAL
- endContextualContainer.layoutParams = endContextualContainerParams
+ if (isContextualButtonShowing) {
+ val endContextualContainerParams = FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
+ endContextualContainerParams.gravity = Gravity.END or Gravity.CENTER_VERTICAL
+ endContextualContainer.layoutParams = endContextualContainerParams
- val startContextualContainerParams = FrameLayout.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
- startContextualContainerParams.gravity = Gravity.START or Gravity.CENTER_VERTICAL
- startContextualContainer.layoutParams = startContextualContainerParams
+ val startContextualContainerParams = FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
+ startContextualContainerParams.gravity = Gravity.START or Gravity.CENTER_VERTICAL
+ startContextualContainer.layoutParams = startContextualContainerParams
- if (imeSwitcher != null) {
- startContextualContainer.addView(imeSwitcher)
- imeSwitcher.layoutParams = getParamsToCenterView()
- }
- endContextualContainer.addView(a11yButton)
- if (rotationButton != null) {
- endContextualContainer.addView(rotationButton.currentView)
- rotationButton.currentView.layoutParams = getParamsToCenterView()
+ if (imeSwitcher != null) {
+ startContextualContainer.addView(imeSwitcher)
+ imeSwitcher.layoutParams = getParamsToCenterView()
+ }
+ if (a11yButton != null) {
+ endContextualContainer.addView(a11yButton)
+ }
+ if (rotationButton != null) {
+ endContextualContainer.addView(rotationButton.currentView)
+ rotationButton.currentView.layoutParams = getParamsToCenterView()
+ }
}
}
}