public KeyboardLayoutSetAdapter(Context context) {
      super(context, android.R.layout.simple_spinner_item);
      setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

      // TODO: Should filter out already existing combinations of locale and layout.
      String[] layouts = SubtypeLocale.getPredefinedKeyboardLayoutSet();
      if (layouts == null) {
        SubtypeLocale.init(context);
        layouts = SubtypeLocale.getPredefinedKeyboardLayoutSet();
      }
      for (final String layout : layouts) {
        // This is a dummy subtype with NO_LANGUAGE, only for display.
        final InputMethodSubtype subtype =
            AdditionalSubtype.createAdditionalSubtype(SubtypeLocale.NO_LANGUAGE, layout, null);
        add(new KeyboardLayoutSetItem(subtype));
      }
    }
 private void showSubtypeAlreadyExistsToast(InputMethodSubtype subtype) {
   final Context context = getActivity();
   final Resources res = context.getResources();
   final String message =
       res.getString(
           R.string.custom_input_style_already_exists,
           SubtypeLocale.getSubtypeDisplayName(subtype, res));
   Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
 }
 public void setSubtype(InputMethodSubtype subtype) {
   mPreviousSubtype = mSubtype;
   mSubtype = subtype;
   if (isIncomplete()) {
     setTitle(null);
     setDialogTitle(R.string.add_style);
     setKey(KEY_NEW_SUBTYPE);
   } else {
     final String displayName =
         SubtypeLocale.getSubtypeDisplayName(subtype, getContext().getResources());
     setTitle(displayName);
     setDialogTitle(displayName);
     setKey(
         KEY_PREFIX
             + subtype.getLocale()
             + "_"
             + SubtypeLocale.getKeyboardLayoutSetName(subtype));
   }
 }
Example #4
0
 public static InputMethodSubtype findSubtypeByLocaleAndKeyboardLayoutSet(
     Context context, String localeString, String keyboardLayoutSetName) {
   final InputMethodInfo imi = getInputMethodInfoOfThisIme(context);
   final int count = imi.getSubtypeCount();
   for (int i = 0; i < count; i++) {
     final InputMethodSubtype subtype = imi.getSubtypeAt(i);
     final String layoutName = SubtypeLocale.getKeyboardLayoutSetName(subtype);
     if (localeString.equals(subtype.getLocale()) && keyboardLayoutSetName.equals(layoutName)) {
       return subtype;
     }
   }
   return null;
 }
 public SubtypeLocaleItem(String localeString) {
   this(localeString, SubtypeLocale.getSubtypeLocaleDisplayName(localeString));
 }
 private InputMethodSubtype findDuplicatedSubtype(InputMethodSubtype subtype) {
   final String localeString = subtype.getLocale();
   final String keyboardLayoutSetName = SubtypeLocale.getKeyboardLayoutSetName(subtype);
   return ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
       getActivity(), localeString, keyboardLayoutSetName);
 }
 public KeyboardLayoutSetItem(InputMethodSubtype subtype) {
   super(
       SubtypeLocale.getKeyboardLayoutSetName(subtype),
       SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype));
 }
 public static void init(LatinIME service) {
   SubtypeLocale.init(service);
   sInstance.initialize(service);
   sInstance.updateAllParameters();
 }