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 e4d0adf0c0..7c4f3ecd01 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.config.FeatureFlags; 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 @@ import java.util.stream.IntStream; * 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 mPredictedApps; private HotseatEduDialog mActiveDialog; @@ -77,9 +63,6 @@ public class HotseatEduController { mLauncher = launcher; mHotseat = launcher.getHotseat(); mOnOnboardingComplete = runnable; - mNotificationManager = mLauncher.getSystemService(NotificationManager.class); - createNotificationChannel(); - mNotification = createNotification(); } /** @@ -216,11 +199,6 @@ public class HotseatEduController { return pageId; } - - void removeNotification() { - mNotificationManager.cancel(ONBOARDING_NOTIFICATION_ID); - } - void moveHotseatItems() { mHotseat.removeAllViewsInLayout(); if (!mNewItems.isEmpty()) { @@ -258,45 +236,9 @@ public class HotseatEduController { void setPredictedApps(List 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 @@ public class HotseatEduController { mActiveDialog.setHotseatEduController(this); mActiveDialog.show(mPredictedApps); } - - static class NotificationHandler implements - ActivityTracker.SchedulerCallback { - @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 e2acf9358d..05bcb57adc 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.InvariantDeviceProfile; 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 class HotseatPredictionController implements DragController.DragListener, */ 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 9ae6080830..494a98dcf5 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.allapps.DiscoveryBounce; 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; @@ -98,6 +99,20 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { } } + @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); diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml index c841170c4c..be1d47b9f2 100644 --- a/quickstep/res/values/strings.xml +++ b/quickstep/res/values/strings.xml @@ -63,12 +63,6 @@ Close - - - Easily access your most-used apps - - Pixel predicts apps you\’ll need next, right on your Home screen. Tap to set up. - Get app suggestions on the bottom row of your Home screen