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

Commit eafd0c7a authored by Pinyao Ting's avatar Pinyao Ting Committed by Android (Google) Code Review
Browse files

Merge "show dot in deep shortcuts when notification contains exactly identical...

Merge "show dot in deep shortcuts when notification contains exactly identical set of person" into ub-launcher3-master
parents 1c7b8267 49a3e699
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -45,18 +45,6 @@ public class DeepShortcutManager {

    private DeepShortcutManager() { }

    public static boolean supportsShortcuts(ItemInfo info) {
        return false;
    }

    public static boolean supportsDeepShortcuts(ItemInfo info) {
        return false;
    }

    public static String getShortcutIdIfApplicable(ItemInfo info) {
        return null;
    }

    /**
     * Queries for the shortcuts with the package name and provided ids.
     *
+7 −0
Original line number Diff line number Diff line
@@ -32,9 +32,11 @@ import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_SEEN;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.Person;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.ShortcutInfo;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.util.Base64;
@@ -244,4 +246,9 @@ public class UiFactory extends RecentsUiFactory {
        }
        return new ScaleAndTranslation(1.1f, 0f, 0f);
    }

    public static Person[] getPersons(ShortcutInfo si) {
        Person[] persons = si.getPersons();
        return persons == null ? Utilities.EMPTY_PERSON_ARRAY : persons;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
import com.android.launcher3.util.PendingRequestArgs;
import com.android.launcher3.util.RaceConditionTracker;
import com.android.launcher3.util.ShortcutUtil;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
@@ -2489,7 +2490,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
                        KeyEvent.KEYCODE_O, KeyEvent.META_CTRL_ON));
            }
            if (currentFocus.getTag() instanceof ItemInfo
                    && DeepShortcutManager.supportsShortcuts((ItemInfo) currentFocus.getTag())) {
                    && ShortcutUtil.supportsShortcuts((ItemInfo) currentFocus.getTag())) {
                shortcutInfos.add(new KeyboardShortcutInfo(
                        getString(R.string.shortcuts_menu_with_notifications_description),
                        KeyEvent.KEYCODE_S, KeyEvent.META_CTRL_ON));
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.ItemInfoWithIcon.FLAG_ICON_BADGED;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.Person;
import android.app.WallpaperManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -97,6 +98,9 @@ public final class Utilities {
    private static final Matrix sMatrix = new Matrix();
    private static final Matrix sInverseMatrix = new Matrix();

    public static final String[] EMPTY_STRING_ARRAY = new String[0];
    public static final Person[] EMPTY_PERSON_ARRAY = new Person[0];

    public static final boolean ATLEAST_Q = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;

    public static final boolean ATLEAST_P =
+23 −0
Original line number Diff line number Diff line
@@ -16,17 +16,23 @@

package com.android.launcher3;

import android.app.Person;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.uioverrides.UiFactory;
import com.android.launcher3.util.ContentWriter;

import java.util.Arrays;

/**
 * Represents a launchable icon on the workspaces and in folders.
 */
@@ -82,11 +88,18 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {

    public int status;

    /**
     * A set of person's Id associated with the WorkspaceItemInfo, this is only used if the item
     * represents a deep shortcut.
     */
    @NonNull private String[] personKeys = Utilities.EMPTY_STRING_ARRAY;

    /**
     * The installation progress [0-100] of the package that this shortcut represents.
     */
    private int mInstallProgress;


    public WorkspaceItemInfo() {
        itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
    }
@@ -98,6 +111,7 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
        iconResource = info.iconResource;
        status = info.status;
        mInstallProgress = info.mInstallProgress;
        personKeys = info.personKeys.clone();
    }

    /** TODO: Remove this.  It's only called by ApplicationInfo.makeWorkspaceItem. */
@@ -175,6 +189,10 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
            runtimeStatusFlags |= FLAG_DISABLED_BY_PUBLISHER;
        }
        disabledMessage = shortcutInfo.getDisabledMessage();

        Person[] persons = UiFactory.getPersons(shortcutInfo);
        personKeys = persons.length == 0 ? Utilities.EMPTY_STRING_ARRAY
            : Arrays.stream(persons).map(Person::getKey).sorted().toArray(String[]::new);
    }

    /** Returns the WorkspaceItemInfo id associated with the deep shortcut. */
@@ -183,6 +201,11 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon {
                getIntent().getStringExtra(ShortcutKey.EXTRA_SHORTCUT_ID) : null;
    }

    @NonNull
    public String[] getPersonKeys() {
        return personKeys;
    }

    @Override
    public ComponentName getTargetComponent() {
        ComponentName cn = super.getTargetComponent();
Loading