Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion res/xml/numeric.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<row height="0.95">
<key width="1.5" key0="switch_text" key2="ctrl"/>
<key width="1.5" key0="0" key3="f11_placeholder" key4="f12_placeholder"/>
<key width="0.75" key0="." key1=":" key2="," key3=";"/>
<key width="0.75" key0="decimal_separator" key1=":" key2="group_separator" key3=";" key4="loc swap_separator"/>
<key width="0.75" key0="space" key1="&quot;" key2="'" key4="_"/>
<key width="1.5" key0="enter" key1="±" key2="action" key3="="/>
</row>
Expand Down
2 changes: 1 addition & 1 deletion res/xml/numpad.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</row>
<row height="0.95">
<key key0="0"/>
<key key0="."/>
<key key0="decimal_separator" key1="loc group_separator" key2="loc swap_separator"/>
<key key0="="/>
<key key0="+"/>
</row>
Expand Down
2 changes: 2 additions & 0 deletions srcs/juloo.keyboard2/ExtraKeyCheckBoxPreference.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class ExtraKeyCheckBoxPreference extends CheckBoxPreference
"£",
"switch_greekmath",
"capslock",
"group_separator",
"swap_separator",
"copy",
"paste",
"cut",
Expand Down
1 change: 1 addition & 0 deletions srcs/juloo.keyboard2/KeyEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public static interface IReceiver
public void switch_layout(int layout_id);

public void set_shift_state(boolean state, boolean lock);
public void set_swap_separator_state(boolean state, boolean lock);

public InputConnection getCurrentInputConnection();
}
Expand Down
13 changes: 13 additions & 0 deletions srcs/juloo.keyboard2/KeyModifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public static KeyValue modify(KeyValue k, Pointers.Modifiers mods)
if (r == null)
{
r = k;
if (KeyValue.Kind.Separator == r.getKind())
r = apply_separator_replacement(r, mods);
/* Order: Fn, Shift, accents */
for (int i = 0; i < n_mods; i++)
r = modify(r, mods.get(i));
Expand Down Expand Up @@ -137,6 +139,17 @@ else if (k == KeyValue.getKeyByName("f12_placeholder"))
return (name == null) ? k : KeyValue.getKeyByName(name);
}

private static KeyValue apply_separator_replacement(KeyValue k, Pointers.Modifiers mods) {
boolean swap_separator = mods.contains(KeyValue.Modifier.SWAP_SEPARATOR);
if ("decimal_separator".equals(k.getString())) {
return k.withString(swap_separator ? "," : ".");
}
if ("group_separator".equals(k.getString())) {
return k.withString(swap_separator ? "." : ",");
}
return k;
}

private static String apply_fn_keyevent(int code)
{
switch (code)
Expand Down
15 changes: 14 additions & 1 deletion srcs/juloo.keyboard2/KeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static enum Event
// Must be evaluated in the reverse order of their values.
public static enum Modifier
{
SWAP_SEPARATOR,
SHIFT,
CTRL,
ALT,
Expand Down Expand Up @@ -70,7 +71,7 @@ public static enum Editing

public static enum Kind
{
Char, String, Keyevent, Event, Modifier, Editing
Char, String, Keyevent, Event, Modifier, Editing, Separator
}

// Behavior flags.
Expand Down Expand Up @@ -275,6 +276,12 @@ private static void addEditingKey(String name, String symbol, Editing action)
FLAG_SPECIAL | FLAG_SECONDARY | FLAG_SMALLER_FONT);
}

private static void addSeparatorKey(String name)
{
addKey(name, name, Kind.Separator, 0, 0);
}


// Within VALUE_BITS
private static int placeholder_unique_id = 0;

Expand Down Expand Up @@ -326,6 +333,10 @@ private static void addPlaceholderKey(String name)
addEventKey("action", "Action", Event.ACTION, FLAG_SMALLER_FONT); // Will always be replaced
addEventKey("capslock", 0x12, Event.CAPS_LOCK, 0);

addModifierKey("swap_separator", 0x15, Modifier.SWAP_SEPARATOR, FLAG_LOCKED);
addSeparatorKey("decimal_separator");
addSeparatorKey("group_separator");

addKeyeventKey("esc", "Esc", KeyEvent.KEYCODE_ESCAPE, FLAG_SMALLER_FONT);
addKeyeventKey("enter", 0x0E, KeyEvent.KEYCODE_ENTER, 0);
addKeyeventKey("up", 0x05, KeyEvent.KEYCODE_DPAD_UP, FLAG_PRECISE_REPEAT);
Expand Down Expand Up @@ -391,6 +402,8 @@ static void addKeyDescr(String name, String descr)
/* Keys description is shown in the settings. */
addKeyDescr("capslock", "Caps lock");
addKeyDescr("switch_greekmath", "Greek & math symbols");
addKeyDescr("group_separator", "',' on Numpad");
addKeyDescr("swap_separator", "swap '.' and ',' on Numpad");
}

// Substitute for [assert], which has no effect on Android.
Expand Down
6 changes: 5 additions & 1 deletion srcs/juloo.keyboard2/Keyboard2.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.util.Log;
import android.util.LogPrinter;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
Expand Down Expand Up @@ -319,6 +318,11 @@ public void set_shift_state(boolean state, boolean lock)
_keyboardView.set_shift_state(state, lock);
}

public void set_swap_separator_state(boolean state, boolean lock)
{
_keyboardView.set_swap_separator_state(state, lock);
}

public void switch_text()
{
_keyboardView.setKeyboard(_currentTextLayout);
Expand Down
22 changes: 22 additions & 0 deletions srcs/juloo.keyboard2/Keyboard2View.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class Keyboard2View extends View
private KeyboardData _keyboard;
private KeyValue _shift_kv;
private KeyboardData.Key _shift_key;
private KeyValue _swap_separator_kv;
private KeyboardData.Key _swap_separator_key;

private Pointers _pointers;

Expand Down Expand Up @@ -89,6 +91,15 @@ public void setKeyboard(KeyboardData kw)
_shift_kv = _shift_kv.withFlags(_shift_kv.getFlags() | KeyValue.FLAG_LOCK);
_shift_key = _keyboard.findKeyWithValue(_shift_kv);
}

_swap_separator_kv = KeyValue.getKeyByName("swap_separator");
_swap_separator_key = _keyboard.findKeyWithValue(_swap_separator_kv);

if (_swap_separator_key == null)
{
_swap_separator_kv = _swap_separator_kv.withFlags(_swap_separator_kv.getFlags() | KeyValue.FLAG_LOCK);
_swap_separator_key = _keyboard.findKeyWithValue(_swap_separator_kv);
}
reset();
}

Expand All @@ -112,6 +123,17 @@ public void set_shift_state(boolean state, boolean lock)
invalidate();
}

public void set_swap_separator_state(boolean state, boolean lock)
{
if (_keyboard == null || _swap_separator_key == null)
return;
if (state)
_pointers.add_fake_pointer(_swap_separator_kv, _swap_separator_key, lock);
else
_pointers.remove_fake_pointer(_swap_separator_kv, _swap_separator_key);
invalidate();
}

public KeyValue modifyKey(KeyValue k, Pointers.Modifiers mods)
{
return KeyModifier.modify(k, mods);
Expand Down
8 changes: 8 additions & 0 deletions srcs/juloo.keyboard2/Pointers.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,14 @@ private Modifiers(KeyValue.Modifier[] m, int s)

public KeyValue.Modifier get(int i) { return _mods[_size - 1 - i]; }
public int size() { return _size; }
public boolean contains(KeyValue.Modifier mod)
{
for (int i = 0; i < _mods.length; i++)
{
if (_mods[i] == mod) return true;
}
return false;
}

@Override
public int hashCode() { return Arrays.hashCode(_mods); }
Expand Down
7 changes: 7 additions & 0 deletions srcs/special_font/15.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.