Merge "Delete PreviewSurfaceRendered (launcher3 fork)" into ub-launcher3-rvc-dev
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/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
index 5b396dd..9171422 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
@@ -51,6 +51,7 @@
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.VibratorWrapper;
+import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.views.FloatingIconView;
import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener;
import com.android.quickstep.util.ActiveGestureLog;
@@ -282,7 +283,8 @@
if (targets.minimizedHomeBounds != null && runningTaskTarget != null) {
Rect overviewStackBounds = mActivityInterface
.getOverviewWindowBounds(targets.minimizedHomeBounds, runningTaskTarget);
- dp = dp.getMultiWindowProfile(mContext, overviewStackBounds);
+ dp = dp.getMultiWindowProfile(mContext,
+ new WindowBounds(overviewStackBounds, targets.homeContentInsets));
} else {
// If we are not in multi-window mode, home insets should be same as system insets.
dp = dp.copy(mContext);
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>
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 0ac2784..d1d5e26 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -24,6 +24,7 @@
import android.content.Intent;
import android.content.pm.LauncherApps;
import android.content.res.Configuration;
+import android.graphics.Insets;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
@@ -35,6 +36,8 @@
import android.view.Display;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.WindowInsets.Type;
+import android.view.WindowMetrics;
import android.widget.Toast;
import androidx.annotation.Nullable;
@@ -51,6 +54,7 @@
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.TraceHelper;
+import com.android.launcher3.util.WindowBounds;
/**
* Extension of BaseActivity allowing support for drag-n-drop
@@ -272,15 +276,19 @@
protected abstract void reapplyUi();
- protected Rect getMultiWindowDisplaySize() {
+ protected WindowBounds getMultiWindowDisplaySize() {
if (Utilities.ATLEAST_R) {
- return new Rect(getWindowManager().getCurrentWindowMetrics().getBounds());
+ WindowMetrics wm = getWindowManager().getCurrentWindowMetrics();
+
+ Insets insets = wm.getWindowInsets().getInsets(Type.systemBars());
+ return new WindowBounds(wm.getBounds(),
+ new Rect(insets.left, insets.top, insets.right, insets.bottom));
}
// Note: Calls to getSize() can't rely on our cached DefaultDisplay since it can return
// the app window size
Display display = getWindowManager().getDefaultDisplay();
Point mwSize = new Point();
display.getSize(mwSize);
- return new Rect(0, 0, mwSize.x, mwSize.y);
+ return new WindowBounds(new Rect(0, 0, mwSize.x, mwSize.y), new Rect());
}
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 51b21aa..72831f4 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -29,6 +29,7 @@
import com.android.launcher3.icons.DotRenderer;
import com.android.launcher3.icons.IconNormalizer;
import com.android.launcher3.util.DefaultDisplay;
+import com.android.launcher3.util.WindowBounds;
public class DeviceProfile {
@@ -265,19 +266,16 @@
/**
* TODO: Move this to the builder as part of setMultiWindowMode
*/
- public DeviceProfile getMultiWindowProfile(Context context, Rect windowPosition) {
+ public DeviceProfile getMultiWindowProfile(Context context, WindowBounds windowBounds) {
// We take the minimum sizes of this profile and it's multi-window variant to ensure that
// the system decor is always excluded.
- Point mwSize = new Point(Math.min(availableWidthPx, windowPosition.width()),
- Math.min(availableHeightPx, windowPosition.height()));
+ Point mwSize = new Point(Math.min(availableWidthPx, windowBounds.availableSize.x),
+ Math.min(availableHeightPx, windowBounds.availableSize.y));
- // In multi-window mode, we can have widthPx = availableWidthPx
- // and heightPx = availableHeightPx because Launcher uses the InvariantDeviceProfiles'
- // widthPx and heightPx values where it's needed.
DeviceProfile profile = toBuilder(context)
.setSizeRange(mwSize, mwSize)
- .setSize(mwSize.x, mwSize.y)
- .setWindowPosition(windowPosition.left, windowPosition.top)
+ .setSize(windowBounds.bounds.width(), windowBounds.bounds.height())
+ .setWindowPosition(windowBounds.bounds.left, windowBounds.bounds.top)
.setMultiWindowMode(true)
.build();
@@ -299,7 +297,7 @@
}
/**
- * Inverse of {@link #getMultiWindowProfile(Context, Rect)}
+ * Inverse of {@link #getMultiWindowProfile(Context, WindowBounds)}
* @return device profile corresponding to the current orientation in non multi-window mode.
*/
public DeviceProfile getFullScreenProfile() {