Merge "Show a snackbar on predicted icon longpress" into ub-launcher3-rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-18 23:34:58 +00:00
committed by Android (Google) Code Review
2 changed files with 21 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ import android.app.prediction.AppTargetEvent;
import android.content.ComponentName;
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 true;

View File

@@ -38,6 +38,7 @@ public class OnboardingPrefs<T extends Launcher> {
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<T extends Launcher> {
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();
}
}