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

Commit 5656caec authored by jasonwshsu's avatar jasonwshsu
Browse files

Correct shortcut summary to have different software types of shortcut result

Root Cause: Did not consider different software types shortcut in AccessibilityShortcutPreferenceFragment

Solution: Add support for different software shortcut types

Bug: 263451053
Test: manual change shortcut type and check
Change-Id: Ic425fdab790d4bbf1de6418ada382e420a9860fc
parent 66199949
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -322,6 +322,18 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
                getComponentName());
    };

    private static CharSequence getSoftwareShortcutTypeSummary(Context context) {
        int resId;
        if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
            resId = R.string.accessibility_shortcut_edit_summary_software;
        } else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
            resId = R.string.accessibility_shortcut_edit_summary_software_gesture;
        } else {
            resId = R.string.accessibility_shortcut_edit_summary_software;
        }
        return context.getText(resId);
    }

    /**
     * This method will be invoked when a button in the tutorial dialog is clicked.
     *
@@ -429,11 +441,9 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
                getComponentName().flattenToString(), AccessibilityUtil.UserShortcutType.SOFTWARE);

        final List<CharSequence> list = new ArrayList<>();
        final CharSequence softwareTitle = context.getText(
                R.string.accessibility_shortcut_edit_summary_software);

        if (hasShortcutType(shortcutTypes, AccessibilityUtil.UserShortcutType.SOFTWARE)) {
            list.add(softwareTitle);
            list.add(getSoftwareShortcutTypeSummary(context));
        }
        if (hasShortcutType(shortcutTypes, AccessibilityUtil.UserShortcutType.HARDWARE)) {
            final CharSequence hardwareTitle = context.getText(
@@ -443,7 +453,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted

        // Show software shortcut if first time to use.
        if (list.isEmpty()) {
            list.add(softwareTitle);
            list.add(getSoftwareShortcutTypeSummary(context));
        }

        return CaseMap.toTitle().wholeString().noLowercase().apply(Locale.getDefault(), /* iter= */