mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-12-23 22:48:54 +01:00
Persist current selected layout
This commit is contained in:
parent
c57d896d8d
commit
15de829138
@ -66,6 +66,7 @@ final class Config
|
||||
|
||||
public final IKeyEventHandler handler;
|
||||
public boolean orientation_landscape = false;
|
||||
public int current_layout; // Index in 'layouts' of the currently used layout
|
||||
|
||||
private Config(SharedPreferences prefs, Resources res, IKeyEventHandler h)
|
||||
{
|
||||
@ -154,6 +155,15 @@ final class Config
|
||||
extra_keys_param = ExtraKeysPreference.get_extra_keys(_prefs);
|
||||
extra_keys_custom = CustomExtraKeysPreference.get(_prefs);
|
||||
pin_entry_enabled = _prefs.getBoolean("pin_entry_enabled", true);
|
||||
current_layout = _prefs.getInt("current_layout", 0);
|
||||
}
|
||||
|
||||
public void set_current_layout(int l)
|
||||
{
|
||||
current_layout = l;
|
||||
SharedPreferences.Editor e = _prefs.edit();
|
||||
e.putInt("current_layout", l);
|
||||
e.apply();
|
||||
}
|
||||
|
||||
KeyValue action_key()
|
||||
|
@ -29,11 +29,9 @@ public class Keyboard2 extends InputMethodService
|
||||
{
|
||||
private Keyboard2View _keyboardView;
|
||||
private KeyEventHandler _keyeventhandler;
|
||||
// If not 'null', the layout to use instead of [_currentTextLayout].
|
||||
/** If not 'null', the layout to use instead of [_config.current_layout]. */
|
||||
private KeyboardData _currentSpecialLayout;
|
||||
/** Current layout index in [Config.layouts]. */
|
||||
private int _currentTextLayout;
|
||||
// Layout associated with the currently selected locale. Not 'null'.
|
||||
/** Layout associated with the currently selected locale. Not 'null'. */
|
||||
private KeyboardData _localeTextLayout;
|
||||
private ViewGroup _emojiPane = null;
|
||||
public int actionId; // Action performed by the Action key.
|
||||
@ -46,10 +44,11 @@ public class Keyboard2 extends InputMethodService
|
||||
if (_currentSpecialLayout != null)
|
||||
return _currentSpecialLayout;
|
||||
KeyboardData layout = null;
|
||||
if (_currentTextLayout >= _config.layouts.size())
|
||||
_currentTextLayout = 0;
|
||||
if (_currentTextLayout < _config.layouts.size())
|
||||
layout = _config.layouts.get(_currentTextLayout);
|
||||
int layout_i = _config.current_layout;
|
||||
if (layout_i >= _config.layouts.size())
|
||||
layout_i = 0;
|
||||
if (layout_i < _config.layouts.size())
|
||||
layout = _config.layouts.get(layout_i);
|
||||
if (layout == null)
|
||||
layout = _localeTextLayout;
|
||||
return layout;
|
||||
@ -63,9 +62,9 @@ public class Keyboard2 extends InputMethodService
|
||||
|
||||
void setTextLayout(int l)
|
||||
{
|
||||
if (l == _currentTextLayout)
|
||||
if (l == _config.current_layout)
|
||||
return;
|
||||
_currentTextLayout = l;
|
||||
_config.set_current_layout(l);
|
||||
_currentSpecialLayout = null;
|
||||
_keyboardView.setKeyboard(current_layout());
|
||||
}
|
||||
@ -73,7 +72,7 @@ public class Keyboard2 extends InputMethodService
|
||||
void incrTextLayout(int delta)
|
||||
{
|
||||
int s = _config.layouts.size();
|
||||
setTextLayout((_currentTextLayout + delta + s) % s);
|
||||
setTextLayout((_config.current_layout + delta + s) % s);
|
||||
}
|
||||
|
||||
void setSpecialLayout(KeyboardData l)
|
||||
|
Loading…
Reference in New Issue
Block a user