Merge "Better handle large display and text scaling on EDU tooltip." into udc-dev
diff --git a/quickstep/res/layout/taskbar_edu_features.xml b/quickstep/res/layout/taskbar_edu_features.xml
index 5cd7aaf..efbe7f8 100644
--- a/quickstep/res/layout/taskbar_edu_features.xml
+++ b/quickstep/res/layout/taskbar_edu_features.xml
@@ -13,29 +13,36 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
style="@style/TextAppearance.TaskbarEduTooltip.Title"
android:layout_width="0dp"
android:layout_height="wrap_content"
+ android:paddingBottom="@dimen/taskbar_edu_tooltip_vertical_margin"
android:text="@string/taskbar_edu_features"
+
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toTopOf="parent"
+ app:layout_constraintBottom_toTopOf="@id/splitscreen_animation"/>
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/splitscreen_animation"
android:layout_width="@dimen/taskbar_edu_features_lottie_width"
android:layout_height="@dimen/taskbar_edu_features_lottie_height"
- android:layout_marginTop="@dimen/taskbar_edu_tooltip_vertical_margin"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/title"
+
app:lottie_autoPlay="true"
- app:lottie_loop="true" />
+ app:lottie_loop="true"
+
+ app:layout_constraintEnd_toEndOf="@id/splitscreen_text"
+ app:layout_constraintStart_toStartOf="@id/splitscreen_text"
+ app:layout_constraintTop_toBottomOf="@id/title" />
<TextView
android:id="@+id/splitscreen_text"
@@ -43,8 +50,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/taskbar_edu_splitscreen"
- app:layout_constraintEnd_toEndOf="@id/splitscreen_animation"
- app:layout_constraintStart_toStartOf="@id/splitscreen_animation"
+
+ app:layout_constraintEnd_toStartOf="@id/settings_text"
+ app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/splitscreen_animation" />
<androidx.constraintlayout.widget.Group
@@ -57,13 +65,14 @@
android:id="@+id/settings_animation"
android:layout_width="@dimen/taskbar_edu_features_lottie_width"
android:layout_height="@dimen/taskbar_edu_features_lottie_height"
- android:layout_marginStart="@dimen/taskbar_edu_features_horizontal_spacing"
- android:layout_marginTop="@dimen/taskbar_edu_tooltip_vertical_margin"
- app:layout_constraintStart_toEndOf="@id/splitscreen_animation"
- app:layout_constraintTop_toBottomOf="@id/title"
+
app:lottie_autoPlay="true"
app:lottie_loop="true"
- app:lottie_rawRes="@raw/taskbar_edu_settings" />
+ app:lottie_rawRes="@raw/taskbar_edu_settings"
+
+ app:layout_constraintEnd_toEndOf="@id/settings_text"
+ app:layout_constraintStart_toStartOf="@id/settings_text"
+ app:layout_constraintTop_toBottomOf="@id/title" />
<TextView
android:id="@+id/settings_text"
@@ -71,21 +80,23 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/taskbar_edu_settings_persistent"
- app:layout_constraintEnd_toEndOf="@id/settings_animation"
- app:layout_constraintStart_toStartOf="@id/settings_animation"
+ android:layout_marginStart="@dimen/taskbar_edu_features_horizontal_spacing"
+
+ app:layout_constraintEnd_toStartOf="@id/suggestions_text"
+ app:layout_constraintStart_toEndOf="@id/splitscreen_text"
app:layout_constraintTop_toBottomOf="@id/settings_animation" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/suggestions_animation"
android:layout_width="@dimen/taskbar_edu_features_lottie_width"
android:layout_height="@dimen/taskbar_edu_features_lottie_height"
- android:layout_marginStart="@dimen/taskbar_edu_features_horizontal_spacing"
- android:layout_marginTop="@dimen/taskbar_edu_tooltip_vertical_margin"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toEndOf="@id/settings_animation"
- app:layout_constraintTop_toBottomOf="@id/title"
+
app:lottie_autoPlay="true"
- app:lottie_loop="true" />
+ app:lottie_loop="true"
+
+ app:layout_constraintEnd_toEndOf="@id/suggestions_text"
+ app:layout_constraintStart_toStartOf="@id/suggestions_text"
+ app:layout_constraintTop_toBottomOf="@id/title" />
<TextView
android:id="@+id/suggestions_text"
@@ -93,8 +104,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/taskbar_edu_suggestions"
- app:layout_constraintEnd_toEndOf="@id/suggestions_animation"
- app:layout_constraintStart_toStartOf="@id/suggestions_animation"
+ android:layout_marginStart="@dimen/taskbar_edu_features_horizontal_spacing"
+
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@id/settings_text"
app:layout_constraintTop_toBottomOf="@id/suggestions_animation" />
<androidx.constraintlayout.widget.Barrier
@@ -108,11 +121,12 @@
android:id="@+id/done_button"
style="@style/TaskbarEdu.Button.Done"
android:layout_width="wrap_content"
- android:layout_height="36dp"
+ android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/taskbar_edu_done"
android:textColor="?androidprv:attr/textColorOnAccent"
+
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/edu_barrier_bottom" />
-</merge>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/quickstep/res/layout/taskbar_edu_swipe.xml b/quickstep/res/layout/taskbar_edu_swipe.xml
index ebdfbb1..3f5e819 100644
--- a/quickstep/res/layout/taskbar_edu_swipe.xml
+++ b/quickstep/res/layout/taskbar_edu_swipe.xml
@@ -13,8 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
<TextView
android:id="@+id/title"
@@ -39,4 +41,4 @@
app:lottie_loop="true"
app:lottie_rawRes="@raw/taskbar_edu_stashing" />
-</merge>
\ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/quickstep/res/layout/taskbar_edu_tooltip.xml b/quickstep/res/layout/taskbar_edu_tooltip.xml
index 657066c..f3da8b0 100644
--- a/quickstep/res/layout/taskbar_edu_tooltip.xml
+++ b/quickstep/res/layout/taskbar_edu_tooltip.xml
@@ -17,7 +17,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
- android:layout_marginBottom="16dp"
+ android:layout_marginHorizontal="24dp"
+ android:paddingBottom="16dp"
android:clipChildren="false"
android:clipToPadding="false"
android:focusable="true"
@@ -25,7 +26,7 @@
android:gravity="center"
android:orientation="vertical">
- <androidx.constraintlayout.widget.ConstraintLayout
+ <FrameLayout
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 959fea7..6c7decd 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -340,6 +340,8 @@
<dimen name="taskbar_edu_features_lottie_width">170dp</dimen>
<dimen name="taskbar_edu_features_lottie_height">106dp</dimen>
<dimen name="taskbar_edu_features_horizontal_spacing">24dp</dimen>
+ <dimen name="taskbar_edu_features_tooltip_width_persistent">624dp</dimen>
+ <dimen name="taskbar_edu_features_tooltip_width_transient">428dp</dimen>
<!--- Taskbar Pinning -->
<dimen name="taskbar_pinning_popup_menu_width">300dp</dimen>
diff --git a/quickstep/res/values/styles.xml b/quickstep/res/values/styles.xml
index 6c12f11..e1afb26 100644
--- a/quickstep/res/values/styles.xml
+++ b/quickstep/res/values/styles.xml
@@ -200,7 +200,7 @@
<item name="android:background">@drawable/button_taskbar_edu_colored</item>
<item name="android:stateListAnimator">@null</item>
<item name="android:textSize">16sp</item>
- <item name="android:padding">4dp</item>
+ <item name="android:minHeight">36dp</item>
</style>
<style name="TextAppearance.TaskbarEduTooltip.Title" parent="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle">
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt
index 7f65e41..bcae06c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltip.kt
@@ -25,7 +25,9 @@
import android.view.MotionEvent.ACTION_DOWN
import android.view.View
import android.view.ViewGroup
+import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.animation.Interpolator
+import androidx.core.view.updateLayoutParams
import com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE
import com.android.app.animation.Interpolators.EMPHASIZED_DECELERATE
import com.android.app.animation.Interpolators.STANDARD
@@ -77,6 +79,18 @@
}
mIsOpen = true
activityContext.dragLayer.addView(this)
+
+ // Make sure we have enough height to display all of the content, which can be an issue on
+ // large text and display scaling configurations. If we run out of height, remove the width
+ // constraint to reduce the number of lines of text and hopefully free up some height.
+ activityContext.dragLayer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED)
+ if (
+ measuredHeight + activityContext.deviceProfile.taskbarHeight >=
+ activityContext.deviceProfile.availableHeightPx
+ ) {
+ updateLayoutParams { width = MATCH_PARENT }
+ }
+
openCloseAnimator = createOpenCloseAnimator(isOpening = true).apply { start() }
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
index 2c686b8..e99fa50 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduTooltipController.kt
@@ -19,11 +19,13 @@
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
-import android.view.ViewGroup
+import android.view.ViewGroup.LayoutParams.MATCH_PARENT
+import android.view.ViewGroup.MarginLayoutParams
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import androidx.annotation.IntDef
import androidx.annotation.LayoutRes
+import androidx.core.view.updateLayoutParams
import com.airbnb.lottie.LottieAnimationView
import com.android.launcher3.R
import com.android.launcher3.Utilities
@@ -127,11 +129,24 @@
settingsEdu.visibility = VISIBLE
}
- findViewById<View>(R.id.done_button)?.setOnClickListener { hide() }
- if (DisplayController.isTransientTaskbar(activityContext)) {
- (layoutParams as ViewGroup.MarginLayoutParams).bottomMargin +=
- activityContext.deviceProfile.taskbarHeight
+ // Set up layout parameters.
+ content.updateLayoutParams { width = MATCH_PARENT }
+ updateLayoutParams<MarginLayoutParams> {
+ if (DisplayController.isTransientTaskbar(activityContext)) {
+ width =
+ resources.getDimensionPixelSize(
+ R.dimen.taskbar_edu_features_tooltip_width_transient
+ )
+ bottomMargin += activityContext.deviceProfile.taskbarHeight
+ } else {
+ width =
+ resources.getDimensionPixelSize(
+ R.dimen.taskbar_edu_features_tooltip_width_persistent
+ )
+ }
}
+
+ findViewById<View>(R.id.done_button)?.setOnClickListener { hide() }
show()
}
}