Don't invert the pin entry layout

The pin entry layout shouldn't be inverted as the letter indications
would be meaningless and the order would be opposite to what the option
specifies.

The enter and action key are swapped as the automatic swapping is also
removed.
This commit is contained in:
Jules Aguillon 2024-02-14 22:41:35 +01:00
parent f369b5d90b
commit d96577963e
3 changed files with 30 additions and 3 deletions

View File

@ -22,6 +22,6 @@
<key shift="1.0" key0="*" key1="switch_text" key3="switch_numeric"/>
<key key0="0" key3="+" key4="space"/>
<key key0="\#" key7="up" key6="right" key5="left" key8="down"/>
<key key0="enter" key2="action"/>
<key key0="action" key2="enter"/>
</row>
</keyboard>

View File

@ -325,6 +325,27 @@ public final class Config
});
}
/** Modify the pin entry layout. [main_kw] is used to map the digits into the
same script. */
public KeyboardData modify_pinentry(KeyboardData kw, KeyboardData main_kw)
{
final KeyModifier.Map_char map_digit = KeyModifier.modify_numpad_script(main_kw.numpad_script);
return kw.mapKeys(new KeyboardData.MapKeyValues() {
public KeyValue apply(KeyValue key, boolean localized)
{
switch (key.getKind())
{
case Char:
String modified = map_digit.apply(key.getChar());
if (modified != null)
return key.withSymbol(modified);
break;
}
return key;
}
});
}
private float get_dip_pref(DisplayMetrics dm, String pref_name, float def)
{
float value;

View File

@ -88,13 +88,19 @@ public class Keyboard2 extends InputMethodService
return KeyboardData.load(getResources(), layout_id);
}
/** Load a layout that contains a numpad (eg. the pin entry). */
/** Load a layout that contains a numpad. */
KeyboardData loadNumpad(int layout_id)
{
return _config.modify_numpad(KeyboardData.load(getResources(), layout_id),
current_layout_unmodified());
}
KeyboardData loadPinentry(int layout_id)
{
return _config.modify_pinentry(KeyboardData.load(getResources(), layout_id),
current_layout_unmodified());
}
@Override
public void onCreate()
{
@ -230,7 +236,7 @@ public class Keyboard2 extends InputMethodService
case InputType.TYPE_CLASS_PHONE:
case InputType.TYPE_CLASS_DATETIME:
if (_config.pin_entry_enabled)
return loadNumpad(R.xml.pin);
return loadPinentry(R.xml.pin);
else
return loadNumpad(R.xml.numeric);
default: