talmantel / CheapTripAndroid

0 stars 3 forks source link

Incorrect locale selection from soft keyboard language #37

Closed denis-luttcev closed 3 years ago

denis-luttcev commented 3 years ago

It is caused by the need to get the language of the current input (regardless of the device locale) and use it when generating the results (see #20).

Initial solution: get InputMethodSubtype that provides locale and languageTag properties for current soft keyboard. Unfortunately, locale is deprecated in API level 24; but languageTag is correct for English keyboard only, otherwise it is empty always.

I have tried using locale despite deprication and it worked fine on my device, but on devices from OA abnormal behavior was observed: with a Russian keyboard, Russian letters were displayed in the input field, but the autocomplete options were displayed in English and vice versa.

I was unable to reproduce this bug, so I cannot reliably establish the cause of it. As I suppose, this could be due to the incorrect operation of the deprecated locale on some modern devices.

The implementation was being redone to use languageTag (see 773c822), but this solution is not universal and is suitable as long as only Russian and English are supported.

Recommended to go back and find the best solution.

denis-luttcev commented 3 years ago

Both of these options appear to be dead ends. As testing has shown, locale and languageTag work incorrect on devices with API level 29+, and languageTag not supported on devices with API level 21.

denis-luttcev commented 3 years ago

The implementation was changed to the selection of the language by the entered characters using a regular expression.