[android] Added trimming of keyboard locale value to avoid passing whitespace as kbd locale

This commit is contained in:
Александр Зацепин 2018-01-11 11:53:59 +03:00 committed by Arsentiy Milchakov
parent 49f618f651
commit e24fd3f70f

View file

@ -37,16 +37,20 @@ public class Language
@NonNull
public static String getKeyboardLocale()
{
final InputMethodManager imm = (InputMethodManager) MwmApplication.get().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
{
final InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
if (ims != null && !TextUtils.isEmpty(ims.getLocale()))
{
return ims.getLocale();
}
}
Context context = MwmApplication.get();
InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null)
return getDefaultLocale();
return getDefaultLocale();
final InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
if (ims == null)
return getDefaultLocale();
String locale = ims.getLocale();
if (TextUtils.isEmpty(locale.trim()))
return getDefaultLocale();
return locale;
}
}