Search in sources :

Example 76 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project platform_frameworks_base by android.

the class InputMethodManagerService method getShortcutInputMethodsAndSubtypes.

// TODO: We should change the return type from List to List<Parcelable>
@SuppressWarnings("rawtypes")
@Override
public List getShortcutInputMethodsAndSubtypes() {
    synchronized (mMethodMap) {
        ArrayList<Object> ret = new ArrayList<>();
        if (mShortcutInputMethodsAndSubtypes.size() == 0) {
            // If there are no selected shortcut subtypes, the framework will try to find
            // the most applicable subtype from all subtypes whose mode is
            // SUBTYPE_MODE_VOICE. This is an exceptional case, so we will hardcode the mode.
            Pair<InputMethodInfo, InputMethodSubtype> info = findLastResortApplicableShortcutInputMethodAndSubtypeLocked(InputMethodUtils.SUBTYPE_MODE_VOICE);
            if (info != null) {
                ret.add(info.first);
                ret.add(info.second);
            }
            return ret;
        }
        for (InputMethodInfo imi : mShortcutInputMethodsAndSubtypes.keySet()) {
            ret.add(imi);
            for (InputMethodSubtype subtype : mShortcutInputMethodsAndSubtypes.get(imi)) {
                ret.add(subtype);
            }
        }
        return ret;
    }
}
Also used : InputMethodSubtype(android.view.inputmethod.InputMethodSubtype) ArrayList(java.util.ArrayList) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 77 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project platform_frameworks_base by android.

the class InputMethodManagerService method setInputMethodEnabledLocked.

boolean setInputMethodEnabledLocked(String id, boolean enabled) {
    // Make sure this is a valid input method.
    InputMethodInfo imm = mMethodMap.get(id);
    if (imm == null) {
        throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
    }
    List<Pair<String, ArrayList<String>>> enabledInputMethodsList = mSettings.getEnabledInputMethodsAndSubtypeListLocked();
    if (enabled) {
        for (Pair<String, ArrayList<String>> pair : enabledInputMethodsList) {
            if (pair.first.equals(id)) {
                // Nothing to do. The previous state was enabled.
                return true;
            }
        }
        mSettings.appendAndPutEnabledInputMethodLocked(id, false);
        // Previous state was disabled.
        return false;
    } else {
        StringBuilder builder = new StringBuilder();
        if (mSettings.buildAndPutEnabledInputMethodsStrRemovingIdLocked(builder, enabledInputMethodsList, id)) {
            // Disabled input method is currently selected, switch to another one.
            final String selId = mSettings.getSelectedInputMethod();
            if (id.equals(selId) && !chooseNewDefaultIMELocked()) {
                Slog.i(TAG, "Can't find new IME, unsetting the current input method.");
                resetSelectedInputMethodAndSubtypeLocked("");
            }
            // Previous state was enabled.
            return true;
        } else {
            // Nothing to do.  The previous state was disabled.
            return false;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) InputMethodInfo(android.view.inputmethod.InputMethodInfo) Pair(android.util.Pair)

Example 78 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project platform_frameworks_base by android.

the class InputMethodManagerService method setCurrentInputMethodSubtype.

@Override
public boolean setCurrentInputMethodSubtype(InputMethodSubtype subtype) {
    // TODO: Make this work even for non-current users?
    if (!calledFromValidUser()) {
        return false;
    }
    synchronized (mMethodMap) {
        if (subtype != null && mCurMethodId != null) {
            InputMethodInfo imi = mMethodMap.get(mCurMethodId);
            int subtypeId = InputMethodUtils.getSubtypeIdFromHashCode(imi, subtype.hashCode());
            if (subtypeId != NOT_A_SUBTYPE_ID) {
                setInputMethodLocked(mCurMethodId, subtypeId);
                return true;
            }
        }
        return false;
    }
}
Also used : InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 79 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project platform_frameworks_base by android.

the class UiAutomatorTestCase method setDummyIme.

private void setDummyIme() throws RemoteException {
    IInputMethodManager im = IInputMethodManager.Stub.asInterface(ServiceManager.getService(Context.INPUT_METHOD_SERVICE));
    List<InputMethodInfo> infos = im.getInputMethodList();
    String id = null;
    for (InputMethodInfo info : infos) {
        if (DUMMY_IME_PACKAGE.equals(info.getComponent().getPackageName())) {
            id = info.getId();
        }
    }
    if (id == null) {
        throw new RuntimeException(String.format("Required testing fixture missing: IME package (%s)", DUMMY_IME_PACKAGE));
    }
    im.setInputMethod(null, id);
}
Also used : IInputMethodManager(com.android.internal.view.IInputMethodManager) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 80 with InputMethodInfo

use of android.view.inputmethod.InputMethodInfo in project platform_frameworks_base by android.

the class Ime method runList.

/**
     * Execute the list sub-command.
     */
private void runList() {
    String opt;
    boolean all = false;
    boolean brief = false;
    while ((opt = nextOption()) != null) {
        if (opt.equals("-a")) {
            all = true;
        } else if (opt.equals("-s")) {
            brief = true;
        } else {
            System.err.println("Error: Unknown option: " + opt);
            showUsage();
            return;
        }
    }
    List<InputMethodInfo> methods;
    if (!all) {
        try {
            methods = mImm.getEnabledInputMethodList();
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(IMM_NOT_RUNNING_ERR);
            return;
        }
    } else {
        try {
            methods = mImm.getInputMethodList();
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(IMM_NOT_RUNNING_ERR);
            return;
        }
    }
    if (methods != null) {
        Printer pr = new PrintStreamPrinter(System.out);
        for (int i = 0; i < methods.size(); i++) {
            InputMethodInfo imi = methods.get(i);
            if (brief) {
                System.out.println(imi.getId());
            } else {
                System.out.println(imi.getId() + ":");
                imi.dump(pr, "  ");
            }
        }
    }
}
Also used : PrintStreamPrinter(android.util.PrintStreamPrinter) RemoteException(android.os.RemoteException) PrintStreamPrinter(android.util.PrintStreamPrinter) Printer(android.util.Printer) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Aggregations

InputMethodInfo (android.view.inputmethod.InputMethodInfo)309 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)113 ArrayList (java.util.ArrayList)80 RemoteException (android.os.RemoteException)53 ServiceInfo (android.content.pm.ServiceInfo)34 ComponentName (android.content.ComponentName)33 Intent (android.content.Intent)33 Context (android.content.Context)32 InputMethodManager (android.view.inputmethod.InputMethodManager)29 ApplicationInfo (android.content.pm.ApplicationInfo)27 PendingIntent (android.app.PendingIntent)24 Test (org.junit.Test)24 ResolveInfo (android.content.pm.ResolveInfo)19 ImeSubtypeListItem (com.android.internal.inputmethod.InputMethodSubtypeSwitchingController.ImeSubtypeListItem)15 InputMethodPreference (com.android.settingslib.inputmethod.InputMethodPreference)14 List (java.util.List)14 PackageManager (android.content.pm.PackageManager)13 Drawable (android.graphics.drawable.Drawable)13 SmallTest (android.test.suitebuilder.annotation.SmallTest)12 Printer (android.util.Printer)12