Search in sources :

Example 1 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier in project android_frameworks_base by DirtyUnicorns.

the class InputManagerService method onShellCommand.

public int onShellCommand(Shell shell, String cmd) {
    if (TextUtils.isEmpty(cmd)) {
        shell.onHelp();
        return 1;
    }
    if (cmd.equals("setlayout")) {
        if (!checkCallingPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT, "onShellCommand()")) {
            throw new SecurityException("Requires SET_KEYBOARD_LAYOUT permission");
        }
        InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(shell.getNextArgRequired(), Integer.parseInt(shell.getNextArgRequired()));
        String descriptor = shell.getNextArgRequired();
        int vid = Integer.decode(shell.getNextArgRequired());
        int pid = Integer.decode(shell.getNextArgRequired());
        InputDeviceIdentifier id = new InputDeviceIdentifier(descriptor, vid, pid);
        setKeyboardLayoutForInputDeviceInner(id, handle, shell.getNextArgRequired());
    }
    return 0;
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle) InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier)

Example 2 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier in project android_frameworks_base by AOSPA.

the class InputManagerService method onShellCommand.

public int onShellCommand(Shell shell, String cmd) {
    if (TextUtils.isEmpty(cmd)) {
        shell.onHelp();
        return 1;
    }
    if (cmd.equals("setlayout")) {
        if (!checkCallingPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT, "onShellCommand()")) {
            throw new SecurityException("Requires SET_KEYBOARD_LAYOUT permission");
        }
        InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(shell.getNextArgRequired(), Integer.parseInt(shell.getNextArgRequired()));
        String descriptor = shell.getNextArgRequired();
        int vid = Integer.decode(shell.getNextArgRequired());
        int pid = Integer.decode(shell.getNextArgRequired());
        InputDeviceIdentifier id = new InputDeviceIdentifier(descriptor, vid, pid);
        setKeyboardLayoutForInputDeviceInner(id, handle, shell.getNextArgRequired());
    }
    return 0;
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle) InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier)

Example 3 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndLanguageSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.language_settings);
    final Activity activity = getActivity();
    mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mInputMethodSettingValues = InputMethodSettingValuesWrapper.getInstance(activity);
    try {
        mDefaultInputMethodSelectorVisibility = Integer.valueOf(getString(R.string.input_method_selector_visibility_default_value));
    } catch (NumberFormatException e) {
    }
    if (activity.getAssets().getLocales().length == 1) {
        // No "Select language" pref if there's only one system locale available.
        getPreferenceScreen().removePreference(findPreference(KEY_PHONE_LANGUAGE));
    } else {
        mLanguagePref = findPreference(KEY_PHONE_LANGUAGE);
    }
    if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
        mShowInputMethodSelectorPref = (ListPreference) findPreference(KEY_INPUT_METHOD_SELECTOR);
        mShowInputMethodSelectorPref.setOnPreferenceChangeListener(this);
        // TODO: Update current input method name on summary
        updateInputMethodSelectorSummary(loadInputMethodSelectorVisibility());
    }
    new VoiceInputOutputSettings(this).onCreate();
    // Get references to dynamically constructed categories.
    mHardKeyboardCategory = (PreferenceCategory) findPreference("hard_keyboard");
    mKeyboardSettingsCategory = (PreferenceCategory) findPreference("keyboard_settings_category");
    mGameControllerCategory = (PreferenceCategory) findPreference("game_controller_settings_category");
    final Intent startingIntent = activity.getIntent();
    // Filter out irrelevant features if invoked from IME settings button.
    mShowsOnlyFullImeAndKeyboardList = Settings.ACTION_INPUT_METHOD_SETTINGS.equals(startingIntent.getAction());
    if (mShowsOnlyFullImeAndKeyboardList) {
        getPreferenceScreen().removeAll();
        if (mHardKeyboardCategory != null) {
            getPreferenceScreen().addPreference(mHardKeyboardCategory);
        }
        if (SHOW_INPUT_METHOD_SWITCHER_SETTINGS) {
            getPreferenceScreen().addPreference(mShowInputMethodSelectorPref);
        }
        if (mKeyboardSettingsCategory != null) {
            mKeyboardSettingsCategory.removeAll();
            getPreferenceScreen().addPreference(mKeyboardSettingsCategory);
        }
    }
    // Build hard keyboard and game controller preference categories.
    mIm = (InputManager) activity.getSystemService(Context.INPUT_SERVICE);
    updateInputDevices();
    // Spell Checker
    final Preference spellChecker = findPreference(KEY_SPELL_CHECKERS);
    if (spellChecker != null) {
        // Note: KEY_SPELL_CHECKERS preference is marked as persistent="false" in XML.
        InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(spellChecker);
        final Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setClass(activity, SubSettings.class);
        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, SpellCheckersSettings.class.getName());
        intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.spellcheckers_settings_title);
        spellChecker.setIntent(intent);
    }
    mHandler = new Handler();
    mSettingsObserver = new SettingsObserver(mHandler, activity);
    mDpm = (DevicePolicyManager) (getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE));
    // If we've launched from the keyboard layout notification, go ahead and just show the
    // keyboard layout dialog.
    final InputDeviceIdentifier identifier = startingIntent.getParcelableExtra(Settings.EXTRA_INPUT_DEVICE_IDENTIFIER);
    if (mShowsOnlyFullImeAndKeyboardList && identifier != null) {
        showKeyboardLayoutDialog(identifier);
    }
    updateCurrentImeName();
}
Also used : InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier) VoiceInputOutputSettings(com.android.settings.VoiceInputOutputSettings) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) SettingsActivity(com.android.settings.SettingsActivity) KeyboardLayoutPickerActivity(com.android.settings.Settings.KeyboardLayoutPickerActivity) Activity(android.app.Activity) Handler(android.os.Handler) Intent(android.content.Intent)

Example 4 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class InputMethodAndLanguageSettings method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (mIntentWaitingForResult != null) {
        InputDeviceIdentifier inputDeviceIdentifier = mIntentWaitingForResult.getParcelableExtra(KeyboardLayoutPickerFragment.EXTRA_INPUT_DEVICE_IDENTIFIER);
        mIntentWaitingForResult = null;
        showKeyboardLayoutDialog(inputDeviceIdentifier);
    }
}
Also used : InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier)

Example 5 with InputDeviceIdentifier

use of android.hardware.input.InputDeviceIdentifier in project android_frameworks_base by crdroidandroid.

the class InputManagerService method onShellCommand.

public int onShellCommand(Shell shell, String cmd) {
    if (TextUtils.isEmpty(cmd)) {
        shell.onHelp();
        return 1;
    }
    if (cmd.equals("setlayout")) {
        if (!checkCallingPermission(android.Manifest.permission.SET_KEYBOARD_LAYOUT, "onShellCommand()")) {
            throw new SecurityException("Requires SET_KEYBOARD_LAYOUT permission");
        }
        InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(shell.getNextArgRequired(), Integer.parseInt(shell.getNextArgRequired()));
        String descriptor = shell.getNextArgRequired();
        int vid = Integer.decode(shell.getNextArgRequired());
        int pid = Integer.decode(shell.getNextArgRequired());
        InputDeviceIdentifier id = new InputDeviceIdentifier(descriptor, vid, pid);
        setKeyboardLayoutForInputDeviceInner(id, handle, shell.getNextArgRequired());
    }
    return 0;
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle) InputDeviceIdentifier(android.hardware.input.InputDeviceIdentifier)

Aggregations

InputDeviceIdentifier (android.hardware.input.InputDeviceIdentifier)8 InputMethodSubtypeHandle (com.android.internal.inputmethod.InputMethodSubtypeHandle)5 SwitchPreference (android.support.v14.preference.SwitchPreference)2 ListPreference (android.support.v7.preference.ListPreference)2 Preference (android.support.v7.preference.Preference)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 KeyboardLayout (android.hardware.input.KeyboardLayout)1 Handler (android.os.Handler)1 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1 InputDevice (android.view.InputDevice)1 KeyboardLayoutPickerActivity (com.android.settings.Settings.KeyboardLayoutPickerActivity)1 SettingsActivity (com.android.settings.SettingsActivity)1 VoiceInputOutputSettings (com.android.settings.VoiceInputOutputSettings)1