Only run search edu when enabled, also make code more generic.

We only need to run the Search edu if it is enabled on devices. The code
itself is also made more generic in terms of method and variable names.

Fix: 330401405
Test: Enable and disable the search function and check whether the edu tooltip shows
up for each specific use case.
Flag: ACONFIG com.android.launcher3.enable_taskbar_pinning NEXTFOOD

Change-Id: I1cea3ee56922c0b47ae7e8379aad4b36570daa17
This commit is contained in:
Saumya Prakash
2024-04-10 22:14:38 +00:00
parent 782af232e3
commit 17cd6ca62a
10 changed files with 55 additions and 40 deletions
@@ -23,35 +23,35 @@
style="@style/TextAppearance.TaskbarEduTooltip.Title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/taskbar_edu_circle_to_search_title"
android:text="@string/taskbar_search_edu_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/circle_to_search_animation" />
app:layout_constraintBottom_toTopOf="@+id/search_edu_animation" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/circle_to_search_animation"
android:id="@+id/search_edu_animation"
android:layout_width="@dimen/taskbar_edu_swipe_lottie_width"
android:layout_height="@dimen/taskbar_edu_swipe_lottie_height"
android:layout_marginTop="@dimen/taskbar_edu_tooltip_vertical_margin"
app:layout_constraintBottom_toTopOf="@id/circle_to_search_text"
app:layout_constraintBottom_toTopOf="@id/search_edu_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/title"
app:lottie_rawRes="@raw/taskbar_edu_circle_to_search"
app:lottie_rawRes="@raw/taskbar_edu_search"
app:lottie_autoPlay="true"
app:lottie_loop="true" />
<TextView
android:id="@+id/circle_to_search_text"
android:id="@+id/search_edu_text"
style="@style/TextAppearance.TaskbarEduTooltip.Subtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="@dimen/taskbar_edu_circle_to_search_subtitle_text_size"
android:textSize="@dimen/taskbar_edu_search_subtitle_text_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/circle_to_search_animation"
app:layout_constraintTop_toBottomOf="@id/search_edu_animation"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
+1
View File
@@ -35,6 +35,7 @@
<string name="taskbar_view_callbacks_factory_class" translatable="false">com.android.launcher3.taskbar.TaskbarViewCallbacksFactory</string>
<string name="launcher_restore_event_logger_class" translatable="false">com.android.quickstep.LauncherRestoreEventLoggerImpl</string>
<string name="plugin_manager_wrapper_class" translatable="false">com.android.launcher3.uioverrides.plugins.PluginManagerWrapperImpl</string>
<string name="taskbar_edu_tooltip_controller_class" translatable="false">com.android.launcher3.taskbar.TaskbarEduTooltipController</string>
<string name="nav_handle_long_press_handler_class" translatable="false"></string>
<string name="assist_utils_class" translatable="false"></string>
+1 -1
View File
@@ -403,7 +403,7 @@
<dimen name="taskbar_edu_features_tooltip_width_with_one_feature">412dp</dimen>
<dimen name="taskbar_edu_features_tooltip_width_with_two_features">428dp</dimen>
<dimen name="taskbar_edu_features_tooltip_width_with_three_features">624dp</dimen>
<dimen name="taskbar_edu_circle_to_search_subtitle_text_size">12sp</dimen>
<dimen name="taskbar_edu_search_subtitle_text_size">12sp</dimen>
<!--- Taskbar Pinning -->
<dimen name="taskbar_pinning_popup_menu_width">300dp</dimen>
+3 -3
View File
@@ -275,10 +275,10 @@
<string name="taskbar_edu_pinning_title">Always show the Taskbar</string>
<!-- Text in dialog that shows a user how to pin the Taskbar. [CHAR_LIMIT 150] -->
<string name="taskbar_edu_pinning_standalone">To always show the Taskbar on the bottom of your screen, touch &amp; hold the divider</string>
<!-- Title in dialog that shows a user how to invoke the Circle to Search feature. [CHAR_LIMIT 150] -->
<string name="taskbar_edu_circle_to_search_title">Touch &amp; hold the action key to search what\'s on your screen</string>
<!-- Title in dialog that shows a user how to invoke the Search feature. [CHAR_LIMIT 150] -->
<string name="taskbar_search_edu_title">Touch &amp; hold the action key to search what\'s on your screen</string>
<!-- Message showed to user to disclose privacy information they need to accept in order to access the app. [CHAR LIMIT=200]-->
<string name="taskbar_edu_circle_to_search_disclosure">This product uses the selected part of your screen to search. Google\'s <xliff:g example="https://policies.google.com/privacy/embedded" id="begin_privacy_link">&lt;a href=\"%1$s\"&gt;</xliff:g>Privacy Policy<xliff:g id="end_privacy_link">&lt;/a&gt;</xliff:g> and <xliff:g example="https://policies.google.com/terms" id="begin_tos_link">&lt;a href=\"%2$s\"&gt;</xliff:g>Terms of Service<xliff:g id="end_tos_link">&lt;/a&gt;</xliff:g> apply.</string>
<string name="taskbar_edu_search_disclosure">This product uses the selected part of your screen to search. Google\'s <xliff:g example="https://policies.google.com/privacy/embedded" id="begin_privacy_link">&lt;a href=\"%1$s\"&gt;</xliff:g>Privacy Policy<xliff:g id="end_privacy_link">&lt;/a&gt;</xliff:g> and <xliff:g example="https://policies.google.com/terms" id="begin_tos_link">&lt;a href=\"%2$s\"&gt;</xliff:g>Terms of Service<xliff:g id="end_tos_link">&lt;/a&gt;</xliff:g> apply.</string>
<!-- Text on button to exit a tutorial [CHAR_LIMIT=16] -->
<string name="taskbar_edu_close">Close</string>
<!-- Text on button to finish a tutorial [CHAR_LIMIT=16] -->
@@ -16,7 +16,6 @@
package com.android.launcher3.taskbar;
import static com.android.launcher3.QuickstepTransitionManager.TRANSIENT_TASKBAR_TRANSITION_DURATION;
import static com.android.launcher3.config.FeatureFlags.enableSplitContextually;
import static com.android.launcher3.statemanager.BaseState.FLAG_NON_INTERACTIVE;
import static com.android.launcher3.taskbar.TaskbarEduTooltipControllerKt.TOOLTIP_STEP_FEATURES;
import static com.android.launcher3.taskbar.TaskbarLauncherStateController.FLAG_VISIBLE;
@@ -306,8 +305,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
*/
public void showEduOnAppLaunch() {
if (!shouldShowEduOnAppLaunch()) {
// Called in case the edu finishes and circle to search edu is still pending
mControllers.taskbarEduTooltipController.maybeShowCircleToSearchEdu();
// Called in case the edu finishes and search edu is still pending
mControllers.taskbarEduTooltipController.maybeShowSearchEdu();
return;
}
@@ -306,7 +306,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
new TaskbarTranslationController(this),
new TaskbarSpringOnStashController(this),
createTaskbarRecentAppsController(isPcMode),
new TaskbarEduTooltipController(this),
TaskbarEduTooltipController.newInstance(this),
new KeyboardQuickSwitchController(),
new TaskbarPinningController(this),
bubbleControllersOptional);
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.taskbar
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
@@ -42,8 +43,10 @@ import com.android.launcher3.config.FeatureFlags.enableTaskbarPinning
import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_EDU_OPEN
import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController
import com.android.launcher3.util.DisplayController
import com.android.launcher3.util.OnboardingPrefs.TASKBAR_CIRCLE_TO_SEARCH_EDU_SEEN
import com.android.launcher3.util.OnboardingPrefs.TASKBAR_EDU_TOOLTIP_STEP
import com.android.launcher3.util.OnboardingPrefs.TASKBAR_SEARCH_EDU_SEEN
import com.android.launcher3.util.ResourceBasedOverride
import com.android.launcher3.views.ActivityContext
import com.android.launcher3.views.BaseDragLayer
import com.android.quickstep.util.LottieAnimationColorUtils
import java.io.PrintWriter
@@ -72,9 +75,11 @@ private const val TOS_BASE_URL = "https://policies.google.com/terms?hl="
annotation class TaskbarEduTooltipStep
/** Controls stepping through the Taskbar tooltip EDU. */
class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
LoggableTaskbarController {
open class TaskbarEduTooltipController(context: Context) :
ResourceBasedOverride, LoggableTaskbarController {
protected val activityContext: TaskbarActivityContext = ActivityContext.lookupContext(context)
open val shouldShowSearchEdu = false
private val isTooltipEnabled: Boolean
get() = !Utilities.isRunningInTestHarness() && !activityContext.isPhoneMode
private val isOpen: Boolean
@@ -83,13 +88,13 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
get() = isTooltipEnabled && tooltipStep <= TOOLTIP_STEP_FEATURES
private lateinit var controllers: TaskbarControllers
// Keep track of whether the user has seen the Circle to Search Edu
private var userHasSeenCircleToSearchEdu: Boolean
// Keep track of whether the user has seen the Search Edu
private var userHasSeenSearchEdu: Boolean
get() {
return TASKBAR_CIRCLE_TO_SEARCH_EDU_SEEN.get(activityContext)
return TASKBAR_SEARCH_EDU_SEEN.get(activityContext)
}
private set(seen) {
LauncherPrefs.get(activityContext).put(TASKBAR_CIRCLE_TO_SEARCH_EDU_SEEN, seen)
LauncherPrefs.get(activityContext).put(TASKBAR_SEARCH_EDU_SEEN, seen)
}
@TaskbarEduTooltipStep
@@ -105,8 +110,8 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
fun init(controllers: TaskbarControllers) {
this.controllers = controllers
// We want to show the Circle To Search Edu right after pinning, so we post it here
activityContext.dragLayer.post { maybeShowCircleToSearchEdu() }
// We want to show the Search Edu right after pinning the taskbar, so we post it here
activityContext.dragLayer.post { maybeShowSearchEdu() }
}
/** Shows swipe EDU tooltip if it is the current [tooltipStep]. */
@@ -136,7 +141,7 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
fun maybeShowFeaturesEdu() {
if (!isTooltipEnabled || tooltipStep > TOOLTIP_STEP_FEATURES) {
maybeShowPinningEdu()
maybeShowCircleToSearchEdu()
maybeShowSearchEdu()
return
}
@@ -233,26 +238,26 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
}
/**
* Shows standalone Circle To Search EDU tooltip if this EDU has not been seen.
* Shows standalone Search EDU tooltip if this EDU has not been seen.
*
* We show this standalone edu for users to learn to how to trigger Circle To Search from the
* pinned taskbar
* We show this standalone edu for users to learn to how to trigger Search from the pinned
* taskbar
*/
fun maybeShowCircleToSearchEdu() {
fun maybeShowSearchEdu() {
if (
!enableTaskbarPinning() ||
!DisplayController.isPinnedTaskbar(activityContext) ||
!isTooltipEnabled ||
userHasSeenCircleToSearchEdu
!shouldShowSearchEdu ||
userHasSeenSearchEdu
) {
return
}
userHasSeenCircleToSearchEdu = true
inflateTooltip(R.layout.taskbar_edu_circle_to_search)
userHasSeenSearchEdu = true
inflateTooltip(R.layout.taskbar_edu_search)
tooltip?.run {
requireViewById<LottieAnimationView>(R.id.circle_to_search_animation)
.supportLightTheme()
val eduSubtitle: TextView = requireViewById(R.id.circle_to_search_text)
requireViewById<LottieAnimationView>(R.id.search_edu_animation).supportLightTheme()
val eduSubtitle: TextView = requireViewById(R.id.search_edu_text)
showDisclosureText(eduSubtitle)
updateLayoutParams<BaseDragLayer.LayoutParams> {
if (DisplayController.isTransientTaskbar(activityContext)) {
@@ -285,7 +290,7 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
*/
private fun TaskbarEduTooltip.showDisclosureText(
textView: TextView,
stringId: Int = R.string.taskbar_edu_circle_to_search_disclosure,
stringId: Int = R.string.taskbar_edu_search_disclosure,
) {
val locale = resources.configuration.locales[0]
val text =
@@ -395,6 +400,17 @@ class TaskbarEduTooltipController(val activityContext: TaskbarActivityContext) :
pw?.println("$prefix\tisOpen=$isOpen")
pw?.println("$prefix\ttooltipStep=$tooltipStep")
}
companion object {
@JvmStatic
fun newInstance(context: Context): TaskbarEduTooltipController {
return ResourceBasedOverride.Overrides.getObject(
TaskbarEduTooltipController::class.java,
context,
R.string.taskbar_edu_tooltip_controller_class
)
}
}
}
/**
+1
View File
@@ -76,6 +76,7 @@
<string name="taskbar_model_callbacks_factory_class" translatable="false"></string>
<string name="taskbar_view_callbacks_factory_class" translatable="false"></string>
<string name="launcher_restore_event_logger_class" translatable="false"></string>
<string name="taskbar_edu_tooltip_controller_class" translatable="false"></string>
<!-- Used for determining category of a widget presented in widget recommendations. -->
<string name="widget_recommendation_category_provider_class" translatable="false"></string>
<string name="api_wrapper_class" translatable="false"></string>
@@ -76,7 +76,5 @@ object OnboardingPrefs {
@JvmField
val HOTSEAT_LONGPRESS_TIP_SEEN = backedUpItem("launcher.hotseat_longpress_tip_seen", false)
@JvmField
val TASKBAR_CIRCLE_TO_SEARCH_EDU_SEEN =
backedUpItem("launcher.taskbar_circle_to_search_edu_seen", false)
@JvmField val TASKBAR_SEARCH_EDU_SEEN = backedUpItem("launcher.taskbar_search_edu_seen", false)
}