Remove dependency on Launcher notification for hotseat edu
Doc: go/hybrid-hotseat-tips
Allow launcher to show hotseat education with intent action "launcher.show_hotseat_edu"
Bug: 157683315
Test: Manual
Change-Id: I62c79b821b79cf1adb831e2f79f6f0f02166ca42
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
index e4d0adf..7c4f3ec 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
@@ -15,17 +15,9 @@
*/
package com.android.launcher3.hybridhotseat;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
import android.content.Intent;
-import android.content.res.Configuration;
-import android.os.Build;
import android.view.View;
-import androidx.core.app.NotificationCompat;
-
import com.android.launcher3.CellLayout;
import com.android.launcher3.Hotseat;
import com.android.launcher3.InvariantDeviceProfile;
@@ -37,11 +29,8 @@
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
-import com.android.launcher3.uioverrides.QuickstepLauncher;
-import com.android.launcher3.util.ActivityTracker;
import com.android.launcher3.util.GridOccupancy;
import com.android.launcher3.util.IntArray;
-import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ArrowTipView;
import com.android.launcher3.views.Snackbar;
@@ -54,18 +43,15 @@
* Controller class for managing user onboaridng flow for hybrid hotseat
*/
public class HotseatEduController {
+
public static final String KEY_HOTSEAT_EDU_SEEN = "hotseat_edu_seen";
-
- private static final String NOTIFICATION_CHANNEL_ID = "launcher_onboarding";
- private static final int ONBOARDING_NOTIFICATION_ID = 7641;
-
+ public static final String HOTSEAT_EDU_ACTION =
+ "com.android.launcher3.action.SHOW_HYBRID_HOTSEAT_EDU";
private static final String SETTINGS_ACTION =
"android.settings.ACTION_CONTENT_SUGGESTIONS_SETTINGS";
private final Launcher mLauncher;
private final Hotseat mHotseat;
- private final NotificationManager mNotificationManager;
- private final Notification mNotification;
private List<WorkspaceItemInfo> mPredictedApps;
private HotseatEduDialog mActiveDialog;
@@ -77,9 +63,6 @@
mLauncher = launcher;
mHotseat = launcher.getHotseat();
mOnOnboardingComplete = runnable;
- mNotificationManager = mLauncher.getSystemService(NotificationManager.class);
- createNotificationChannel();
- mNotification = createNotification();
}
/**
@@ -216,11 +199,6 @@
return pageId;
}
-
- void removeNotification() {
- mNotificationManager.cancel(ONBOARDING_NOTIFICATION_ID);
- }
-
void moveHotseatItems() {
mHotseat.removeAllViewsInLayout();
if (!mNewItems.isEmpty()) {
@@ -258,45 +236,9 @@
void setPredictedApps(List<WorkspaceItemInfo> predictedApps) {
mPredictedApps = predictedApps;
- if (!mPredictedApps.isEmpty()
- && mLauncher.getOrientation() == Configuration.ORIENTATION_PORTRAIT) {
- mNotificationManager.notify(ONBOARDING_NOTIFICATION_ID, mNotification);
- }
- else {
- removeNotification();
- }
- }
-
- private void createNotificationChannel() {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
- CharSequence name = mLauncher.getString(R.string.hotseat_edu_prompt_title);
- int importance = NotificationManager.IMPORTANCE_LOW;
- NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name,
- importance);
- mNotificationManager.createNotificationChannel(channel);
- }
-
- private Notification createNotification() {
- Intent intent = new Intent(mLauncher.getApplicationContext(), mLauncher.getClass());
- intent = new NotificationHandler().addToIntent(intent);
-
- CharSequence name = mLauncher.getString(R.string.hotseat_edu_prompt_title);
- String description = mLauncher.getString(R.string.hotseat_edu_prompt_content);
- NotificationCompat.Builder builder = new NotificationCompat.Builder(mLauncher,
- NOTIFICATION_CHANNEL_ID)
- .setContentTitle(name)
- .setOngoing(true)
- .setColor(Themes.getColorAccent(mLauncher))
- .setContentIntent(PendingIntent.getActivity(mLauncher, 0, intent,
- PendingIntent.FLAG_CANCEL_CURRENT))
- .setSmallIcon(R.drawable.hotseat_edu_notification_icon)
- .setContentText(description);
- return builder.build();
-
}
void destroy() {
- removeNotification();
if (mActiveDialog != null) {
mActiveDialog.setHotseatEduController(null);
}
@@ -334,14 +276,5 @@
mActiveDialog.setHotseatEduController(this);
mActiveDialog.show(mPredictedApps);
}
-
- static class NotificationHandler implements
- ActivityTracker.SchedulerCallback<QuickstepLauncher> {
- @Override
- public boolean init(QuickstepLauncher activity, boolean alreadyOnHome) {
- activity.getHotseatPredictionController().showEdu();
- return true;
- }
- }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
index e2acf93..05bcb57 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
@@ -41,7 +41,6 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
-import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsStore;
@@ -148,8 +147,7 @@
*/
public void showEdu() {
if (mHotseatEduController == null) return;
- mLauncher.getStateManager().goToState(LauncherState.NORMAL, true,
- () -> mHotseatEduController.showEdu());
+ mHotseatEduController.showEdu();
}
@Override
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index 9ae6080..494a98d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -44,6 +44,7 @@
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.Folder;
+import com.android.launcher3.hybridhotseat.HotseatEduController;
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
@@ -99,6 +100,20 @@
}
@Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ if (HotseatEduController.HOTSEAT_EDU_ACTION.equals(intent.getAction())
+ && mHotseatPredictionController != null) {
+ boolean alreadyOnHome = hasWindowFocus() && ((intent.getFlags()
+ & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
+ != Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
+ getStateManager().goToState(NORMAL, alreadyOnHome, () -> {
+ mHotseatPredictionController.showEdu();
+ });
+ }
+ }
+
+ @Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
onStateOrResumeChanging(false /* inTransition */);
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index c841170..be1d47b 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -63,12 +63,6 @@
<!-- Content description for a close button. [CHAR LIMIT=NONE] -->
<string name="gesture_tutorial_close_button_content_description" translatable="false">Close</string>
-
- <!-- Hotseat migration notification title -->
- <string name="hotseat_edu_prompt_title">Easily access your most-used apps</string>
- <!-- Hotseat migration notification content -->
- <string name="hotseat_edu_prompt_content">Pixel predicts apps you\’ll need next, right on your Home screen. Tap to set up.</string>
-
<!-- Hotseat educational strings for users who don't qualify for migration -->
<string name="hotseat_edu_title_migrate">Get app suggestions on the bottom row of your Home screen</string>