Search in sources :

Example 1 with SimpleStringSplitter

use of android.text.TextUtils.SimpleStringSplitter in project platform_frameworks_base by android.

the class InputMethodUtils method parseInputMethodsAndSubtypesString.

/**
     * Parses the setting stored input methods and subtypes string value.
     *
     * @param inputMethodsAndSubtypesString The input method subtypes value stored in settings.
     * @return Map from input method ID to set of input method subtypes IDs.
     */
@VisibleForTesting
public static ArrayMap<String, ArraySet<String>> parseInputMethodsAndSubtypesString(@Nullable final String inputMethodsAndSubtypesString) {
    final ArrayMap<String, ArraySet<String>> imeMap = new ArrayMap<>();
    if (TextUtils.isEmpty(inputMethodsAndSubtypesString)) {
        return imeMap;
    }
    final SimpleStringSplitter typeSplitter = new SimpleStringSplitter(INPUT_METHOD_SEPARATOR);
    final SimpleStringSplitter subtypeSplitter = new SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR);
    List<Pair<String, ArrayList<String>>> allImeSettings = InputMethodSettings.buildInputMethodsAndSubtypeList(inputMethodsAndSubtypesString, typeSplitter, subtypeSplitter);
    for (Pair<String, ArrayList<String>> ime : allImeSettings) {
        ArraySet<String> subtypes = new ArraySet<>();
        if (ime.second != null) {
            subtypes.addAll(ime.second);
        }
        imeMap.put(ime.first, subtypes);
    }
    return imeMap;
}
Also used : ArraySet(android.util.ArraySet) ArrayList(java.util.ArrayList) ArrayMap(android.util.ArrayMap) SimpleStringSplitter(android.text.TextUtils.SimpleStringSplitter) Pair(android.util.Pair) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 2 with SimpleStringSplitter

use of android.text.TextUtils.SimpleStringSplitter in project XobotOS by xamarin.

the class AccessibilityInjector method ensureWebContentKeyBindings.

/**
     * Ensures that the Web content key bindings are loaded.
     */
private void ensureWebContentKeyBindings() {
    if (sBindings.size() > 0) {
        return;
    }
    String webContentKeyBindingsString = Settings.Secure.getString(mWebView.getContext().getContentResolver(), Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS);
    SimpleStringSplitter semiColonSplitter = new SimpleStringSplitter(';');
    semiColonSplitter.setString(webContentKeyBindingsString);
    while (semiColonSplitter.hasNext()) {
        String bindingString = semiColonSplitter.next();
        if (TextUtils.isEmpty(bindingString)) {
            Log.e(LOG_TAG, "Disregarding malformed Web content key binding: " + webContentKeyBindingsString);
            continue;
        }
        String[] keyValueArray = bindingString.split("=");
        if (keyValueArray.length != 2) {
            Log.e(LOG_TAG, "Disregarding malformed Web content key binding: " + bindingString);
            continue;
        }
        try {
            long keyCodeAndModifiers = Long.decode(keyValueArray[0].trim());
            String[] actionStrings = keyValueArray[1].split(":");
            int[] actions = new int[actionStrings.length];
            for (int i = 0, count = actions.length; i < count; i++) {
                actions[i] = Integer.decode(actionStrings[i].trim());
            }
            sBindings.add(new AccessibilityWebContentKeyBinding(keyCodeAndModifiers, actions));
        } catch (NumberFormatException nfe) {
            Log.e(LOG_TAG, "Disregarding malformed key binding: " + bindingString);
        }
    }
}
Also used : SimpleStringSplitter(android.text.TextUtils.SimpleStringSplitter)

Example 3 with SimpleStringSplitter

use of android.text.TextUtils.SimpleStringSplitter in project android_frameworks_base by ResurrectionRemix.

the class InputMethodUtils method parseInputMethodsAndSubtypesString.

/**
     * Parses the setting stored input methods and subtypes string value.
     *
     * @param inputMethodsAndSubtypesString The input method subtypes value stored in settings.
     * @return Map from input method ID to set of input method subtypes IDs.
     */
@VisibleForTesting
public static ArrayMap<String, ArraySet<String>> parseInputMethodsAndSubtypesString(@Nullable final String inputMethodsAndSubtypesString) {
    final ArrayMap<String, ArraySet<String>> imeMap = new ArrayMap<>();
    if (TextUtils.isEmpty(inputMethodsAndSubtypesString)) {
        return imeMap;
    }
    final SimpleStringSplitter typeSplitter = new SimpleStringSplitter(INPUT_METHOD_SEPARATOR);
    final SimpleStringSplitter subtypeSplitter = new SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR);
    List<Pair<String, ArrayList<String>>> allImeSettings = InputMethodSettings.buildInputMethodsAndSubtypeList(inputMethodsAndSubtypesString, typeSplitter, subtypeSplitter);
    for (Pair<String, ArrayList<String>> ime : allImeSettings) {
        ArraySet<String> subtypes = new ArraySet<>();
        if (ime.second != null) {
            subtypes.addAll(ime.second);
        }
        imeMap.put(ime.first, subtypes);
    }
    return imeMap;
}
Also used : ArraySet(android.util.ArraySet) ArrayList(java.util.ArrayList) ArrayMap(android.util.ArrayMap) SimpleStringSplitter(android.text.TextUtils.SimpleStringSplitter) Pair(android.util.Pair) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 4 with SimpleStringSplitter

use of android.text.TextUtils.SimpleStringSplitter in project android_frameworks_base by crdroidandroid.

the class InputMethodUtils method parseInputMethodsAndSubtypesString.

/**
     * Parses the setting stored input methods and subtypes string value.
     *
     * @param inputMethodsAndSubtypesString The input method subtypes value stored in settings.
     * @return Map from input method ID to set of input method subtypes IDs.
     */
@VisibleForTesting
public static ArrayMap<String, ArraySet<String>> parseInputMethodsAndSubtypesString(@Nullable final String inputMethodsAndSubtypesString) {
    final ArrayMap<String, ArraySet<String>> imeMap = new ArrayMap<>();
    if (TextUtils.isEmpty(inputMethodsAndSubtypesString)) {
        return imeMap;
    }
    final SimpleStringSplitter typeSplitter = new SimpleStringSplitter(INPUT_METHOD_SEPARATOR);
    final SimpleStringSplitter subtypeSplitter = new SimpleStringSplitter(INPUT_METHOD_SUBTYPE_SEPARATOR);
    List<Pair<String, ArrayList<String>>> allImeSettings = InputMethodSettings.buildInputMethodsAndSubtypeList(inputMethodsAndSubtypesString, typeSplitter, subtypeSplitter);
    for (Pair<String, ArrayList<String>> ime : allImeSettings) {
        ArraySet<String> subtypes = new ArraySet<>();
        if (ime.second != null) {
            subtypes.addAll(ime.second);
        }
        imeMap.put(ime.first, subtypes);
    }
    return imeMap;
}
Also used : ArraySet(android.util.ArraySet) ArrayList(java.util.ArrayList) ArrayMap(android.util.ArrayMap) SimpleStringSplitter(android.text.TextUtils.SimpleStringSplitter) Pair(android.util.Pair) VisibleForTesting(com.android.internal.annotations.VisibleForTesting)

Example 5 with SimpleStringSplitter

use of android.text.TextUtils.SimpleStringSplitter in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityInjectorFallback method ensureWebContentKeyBindings.

/**
     * Ensures that the Web content key bindings are loaded.
     */
private void ensureWebContentKeyBindings() {
    if (sBindings.size() > 0) {
        return;
    }
    String webContentKeyBindingsString = Settings.Secure.getString(mWebView.getContext().getContentResolver(), Settings.Secure.ACCESSIBILITY_WEB_CONTENT_KEY_BINDINGS);
    SimpleStringSplitter semiColonSplitter = new SimpleStringSplitter(';');
    semiColonSplitter.setString(webContentKeyBindingsString);
    while (semiColonSplitter.hasNext()) {
        String bindingString = semiColonSplitter.next();
        if (TextUtils.isEmpty(bindingString)) {
            Log.e(LOG_TAG, "Disregarding malformed Web content key binding: " + webContentKeyBindingsString);
            continue;
        }
        String[] keyValueArray = bindingString.split("=");
        if (keyValueArray.length != 2) {
            Log.e(LOG_TAG, "Disregarding malformed Web content key binding: " + bindingString);
            continue;
        }
        try {
            long keyCodeAndModifiers = Long.decode(keyValueArray[0].trim());
            String[] actionStrings = keyValueArray[1].split(":");
            int[] actions = new int[actionStrings.length];
            for (int i = 0, count = actions.length; i < count; i++) {
                actions[i] = Integer.decode(actionStrings[i].trim());
            }
            sBindings.add(new AccessibilityWebContentKeyBinding(keyCodeAndModifiers, actions));
        } catch (NumberFormatException nfe) {
            Log.e(LOG_TAG, "Disregarding malformed key binding: " + bindingString);
        }
    }
}
Also used : SimpleStringSplitter(android.text.TextUtils.SimpleStringSplitter)

Aggregations

SimpleStringSplitter (android.text.TextUtils.SimpleStringSplitter)7 ArrayMap (android.util.ArrayMap)5 ArraySet (android.util.ArraySet)5 Pair (android.util.Pair)5 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)5 ArrayList (java.util.ArrayList)5