From 44c1b5e03d55c346b939d62f7f73ceb71de25543 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Thu, 18 Jun 2020 10:19:19 -0700 Subject: [PATCH] Show a snackbar on predicted icon longpress The first time a user long presses a predicted icon, suppress drag/drop and show a snackbar about app predictions. Bug: 159170242 Test: Manual Change-Id: I5f853a9774b38ad9fad22ff55feff417a801f52c --- .../hybridhotseat/HotseatPredictionController.java | 13 +++++++++++++ src/com/android/launcher3/util/OnboardingPrefs.java | 8 ++++++++ 2 files changed, 21 insertions(+) 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 30a34e46eb..80d7cbd850 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 @@ -32,6 +32,7 @@ import android.content.ComponentName; import android.content.Intent; import android.os.Process; import android.util.Log; +import android.view.HapticFeedbackConstants; import android.view.View; import android.view.ViewGroup; @@ -69,6 +70,7 @@ import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntArray; +import com.android.launcher3.util.OnboardingPrefs; import com.android.launcher3.views.ArrowTipView; import com.android.launcher3.views.Snackbar; @@ -120,6 +122,17 @@ public class HotseatPredictionController implements DragController.DragListener, private final View.OnLongClickListener mPredictionLongClickListener = v -> { if (!ItemLongClickListener.canStartDrag(mLauncher)) return false; if (mLauncher.getWorkspace().isSwitchingState()) return false; + if (!mLauncher.getOnboardingPrefs().getBoolean( + OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN)) { + Intent intent = new Intent(SETTINGS_ACTION); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Snackbar.show(mLauncher, R.string.hotseat_tip_gaps_filled, + R.string.hotseat_prediction_settings, null, + () -> mLauncher.startActivity(intent)); + mLauncher.getOnboardingPrefs().markChecked(OnboardingPrefs.HOTSEAT_LONGPRESS_TIP_SEEN); + mLauncher.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + return true; + } // Start the drag mLauncher.getWorkspace().beginDragShared(v, this, new DragOptions()); return false; diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java index 90a1c82661..e3bd1b91a5 100644 --- a/src/com/android/launcher3/util/OnboardingPrefs.java +++ b/src/com/android/launcher3/util/OnboardingPrefs.java @@ -38,6 +38,7 @@ public class OnboardingPrefs { public static final String SHELF_BOUNCE_COUNT = "launcher.shelf_bounce_count"; public static final String ALL_APPS_COUNT = "launcher.all_apps_count"; public static final String HOTSEAT_DISCOVERY_TIP_COUNT = "launcher.hotseat_discovery_tip_count"; + public static final String HOTSEAT_LONGPRESS_TIP_SEEN = "launcher.hotseat_longpress_tip_seen"; /** * Events that either have happened or have not (booleans). @@ -111,4 +112,11 @@ public class OnboardingPrefs { mSharedPrefs.edit().putInt(eventKey, count).apply(); return hasReachedMaxCount(count, eventKey); } + + /** + * Marks on-boarding preference boolean at true + */ + public void markChecked(String flag) { + mSharedPrefs.edit().putBoolean(flag, true).apply(); + } }