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

Commit 6f22413c authored by PETER LIANG's avatar PETER LIANG Committed by Android (Google) Code Review
Browse files

Merge changes from topic "edit_menu_v2" into rvc-dev

* changes:
  Update the edit shortcut menu (4/n).
  Update the edit shortcut menu (3/n).
  Update the edit shortcut menu (2/n).
parents 02ee003a baf4f053
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ public final class ShortcutConstants {
    private ShortcutConstants() {}

    public static final char SERVICES_SEPARATOR = ':';
    public static final float DISABLED_ALPHA = 0.5f;
    public static final float ENABLED_ALPHA = 1.0f;

    /**
     * Annotation for different user shortcut type UI type.
@@ -79,6 +77,21 @@ public final class ShortcutConstants {
        int BOUNCE = 3;
    }

    /**
     * Annotation for different shortcut target.
     */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
            TargetType.ACCESSIBILITY_SERVICE,
            TargetType.ACCESSIBILITY_ACTIVITY,
            TargetType.WHITE_LISTING,
    })
    public @interface TargetType {
        int ACCESSIBILITY_SERVICE = 0;
        int ACCESSIBILITY_ACTIVITY = 1;
        int WHITE_LISTING = 2;
    }

    /**
     * Annotation for different shortcut menu mode.
     *
+27 −0
Original line number Diff line number Diff line
@@ -38,6 +38,33 @@ public final class ShortcutUtils {
    private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
            new TextUtils.SimpleStringSplitter(SERVICES_SEPARATOR);

    /**
     * Opts in component name into colon-separated {@link UserShortcutType}
     * key's string in Settings.
     *
     * @param context The current context.
     * @param shortcutType The preferred shortcut type user selected.
     * @param componentId The component id that need to be opted out from Settings.
     */
    public static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
            String componentId) {
        final StringJoiner joiner = new StringJoiner(String.valueOf(SERVICES_SEPARATOR));
        final String targetKey = convertToKey(shortcutType);
        final String targetString = Settings.Secure.getString(context.getContentResolver(),
                targetKey);

        if (hasValueInSettings(context, shortcutType, componentId)) {
            return;
        }

        if (!TextUtils.isEmpty(targetString)) {
            joiner.add(targetString);
        }
        joiner.add(componentId);

        Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
    }

    /**
     * Opts out component name into colon-separated {@code shortcutType} key's string in Settings.
     *
Loading