Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e557bac0 authored by Adam Cohen's avatar Adam Cohen
Browse files

Merging from ub-launcher3-rvc-dev @ build 6552182

Bug:150504032
Test: manual, presubmit on the source branch
x20/teams/android-launcher/merge/ub-launcher3-rvc-dev_rvc-dev_6552182.html

Change-Id: I795aafd151c6ce53077e1aebb97567eedd84f274
Merged-In: I795aafd151c6ce53077e1aebb97567eedd84f274
parents 614c185e 73763959
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -51,6 +51,7 @@ message ContainerInfo {
    WidgetsContainer widgets_container = 5;
    WidgetsContainer widgets_container = 5;
    PredictionContainer prediction_container = 6;
    PredictionContainer prediction_container = 6;
    SearchResultContainer search_result_container = 7;
    SearchResultContainer search_result_container = 7;
    ShortcutsContainer shortcuts_container = 8;
  }
  }
}
}


@@ -69,6 +70,11 @@ message PredictionContainer {
message SearchResultContainer {
message SearchResultContainer {
}
}


// Container for package specific shortcuts to deep links and notifications.
// Typically shown as popup window by longpressing on an icon.
message ShortcutsContainer {
}

enum Origin {
enum Origin {
  UNKNOWN = 0;
  UNKNOWN = 0;
  DEFAULT_LAYOUT = 1;       // icon automatically placed in workspace, folder, hotseat
  DEFAULT_LAYOUT = 1;       // icon automatically placed in workspace, folder, hotseat
+3 −70
Original line number Original line Diff line number Diff line
@@ -15,17 +15,9 @@
 */
 */
package com.android.launcher3.hybridhotseat;
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.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.view.View;
import android.view.View;


import androidx.core.app.NotificationCompat;

import com.android.launcher3.CellLayout;
import com.android.launcher3.CellLayout;
import com.android.launcher3.Hotseat;
import com.android.launcher3.Hotseat;
import com.android.launcher3.InvariantDeviceProfile;
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.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
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.GridOccupancy;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ArrowTipView;
import com.android.launcher3.views.ArrowTipView;
import com.android.launcher3.views.Snackbar;
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
 * Controller class for managing user onboaridng flow for hybrid hotseat
 */
 */
public class HotseatEduController {
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 KEY_HOTSEAT_EDU_SEEN = "hotseat_edu_seen";
    public static final String HOTSEAT_EDU_ACTION =
            "com.android.launcher3.action.SHOW_HYBRID_HOTSEAT_EDU";
    private static final String SETTINGS_ACTION =
    private static final String SETTINGS_ACTION =
            "android.settings.ACTION_CONTENT_SUGGESTIONS_SETTINGS";
            "android.settings.ACTION_CONTENT_SUGGESTIONS_SETTINGS";


    private final Launcher mLauncher;
    private final Launcher mLauncher;
    private final Hotseat mHotseat;
    private final Hotseat mHotseat;
    private final NotificationManager mNotificationManager;
    private final Notification mNotification;
    private List<WorkspaceItemInfo> mPredictedApps;
    private List<WorkspaceItemInfo> mPredictedApps;
    private HotseatEduDialog mActiveDialog;
    private HotseatEduDialog mActiveDialog;


@@ -77,9 +63,6 @@ public class HotseatEduController {
        mLauncher = launcher;
        mLauncher = launcher;
        mHotseat = launcher.getHotseat();
        mHotseat = launcher.getHotseat();
        mOnOnboardingComplete = runnable;
        mOnOnboardingComplete = runnable;
        mNotificationManager = mLauncher.getSystemService(NotificationManager.class);
        createNotificationChannel();
        mNotification = createNotification();
    }
    }


    /**
    /**
@@ -216,11 +199,6 @@ public class HotseatEduController {
        return pageId;
        return pageId;
    }
    }



    void removeNotification() {
        mNotificationManager.cancel(ONBOARDING_NOTIFICATION_ID);
    }

    void moveHotseatItems() {
    void moveHotseatItems() {
        mHotseat.removeAllViewsInLayout();
        mHotseat.removeAllViewsInLayout();
        if (!mNewItems.isEmpty()) {
        if (!mNewItems.isEmpty()) {
@@ -258,45 +236,9 @@ public class HotseatEduController {


    void setPredictedApps(List<WorkspaceItemInfo> predictedApps) {
    void setPredictedApps(List<WorkspaceItemInfo> predictedApps) {
        mPredictedApps = 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() {
    void destroy() {
        removeNotification();
        if (mActiveDialog != null) {
        if (mActiveDialog != null) {
            mActiveDialog.setHotseatEduController(null);
            mActiveDialog.setHotseatEduController(null);
        }
        }
@@ -334,14 +276,5 @@ public class HotseatEduController {
        mActiveDialog.setHotseatEduController(this);
        mActiveDialog.setHotseatEduController(this);
        mActiveDialog.show(mPredictedApps);
        mActiveDialog.show(mPredictedApps);
    }
    }

    static class NotificationHandler implements
            ActivityTracker.SchedulerCallback<QuickstepLauncher> {
        @Override
        public boolean init(QuickstepLauncher activity, boolean alreadyOnHome) {
            activity.getHotseatPredictionController().showEdu();
            return true;
        }
    }
}
}
+1 −3
Original line number Original line Diff line number Diff line
@@ -41,7 +41,6 @@ import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsStore;
import com.android.launcher3.allapps.AllAppsStore;
@@ -148,8 +147,7 @@ public class HotseatPredictionController implements DragController.DragListener,
     */
     */
    public void showEdu() {
    public void showEdu() {
        if (mHotseatEduController == null) return;
        if (mHotseatEduController == null) return;
        mLauncher.getStateManager().goToState(LauncherState.NORMAL, true,
        mHotseatEduController.showEdu();
                () -> mHotseatEduController.showEdu());
    }
    }


    @Override
    @Override
+15 −0
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.hybridhotseat.HotseatEduController;
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
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
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        super.onConfigurationChanged(newConfig);
+2 −1
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
@@ -188,7 +189,7 @@ public class QuickstepAtomicAnimationFactory extends
            }
            }
        } else if (toState == NORMAL && fromState == OVERVIEW_PEEK) {
        } else if (toState == NORMAL && fromState == OVERVIEW_PEEK) {
            // Keep fully visible until the very end (when overview is offscreen) to make invisible.
            // Keep fully visible until the very end (when overview is offscreen) to make invisible.
            config.setInterpolator(ANIM_OVERVIEW_FADE, t -> t < 1 ? 0 : 1);
            config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
        } else if (toState == OVERVIEW_PEEK && fromState == NORMAL) {
        } else if (toState == OVERVIEW_PEEK && fromState == NORMAL) {
            config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
            config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7);
            config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7);
Loading