diff --git a/res/xml/azerty.xml b/res/xml/azerty.xml
index a5841fa..e419b60 100644
--- a/res/xml/azerty.xml
+++ b/res/xml/azerty.xml
@@ -25,20 +25,20 @@
-
+
-
-
+
-
+
-
-
+
+
+
diff --git a/res/xml/qwerty.xml b/res/xml/qwerty.xml
new file mode 100644
index 0000000..ca2f92b
--- /dev/null
+++ b/res/xml/qwerty.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index 73df0a1..aa687ff 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -6,6 +6,7 @@ import java.util.HashMap;
class KeyValue
{
public static final int EVENT_NONE = -1;
+ public static final int EVENT_CONFIG = -2;
public static final char CHAR_NONE = '\0';
public static final int FLAG_KEEP_ON = 1;
@@ -121,6 +122,7 @@ class KeyValue
new KeyValue("8", "8", '8', KeyEvent.KEYCODE_8, 0);
new KeyValue("9", "9", '9', KeyEvent.KEYCODE_9, 0);
+ new KeyValue("config", "Conf", CHAR_NONE, EVENT_CONFIG, 0);
new KeyValue("enter", "↵", CHAR_NONE, KeyEvent.KEYCODE_ENTER, 0);
new KeyValue("up", "↑", CHAR_NONE, KeyEvent.KEYCODE_DPAD_UP, 0);
new KeyValue("right", "→", CHAR_NONE, KeyEvent.KEYCODE_DPAD_RIGHT, 0);
diff --git a/srcs/juloo.keyboard2/Keyboard2.java b/srcs/juloo.keyboard2/Keyboard2.java
index 30ef5fc..d3d03cd 100644
--- a/srcs/juloo.keyboard2/Keyboard2.java
+++ b/srcs/juloo.keyboard2/Keyboard2.java
@@ -10,13 +10,13 @@ public class Keyboard2 extends InputMethodService
public static final String TAG = "Keyboard_2.0";
private KeyboardData _keyboardData;
- private Keyboard2View _inputView;
+ private Keyboard2View _inputView = null;
@Override
public void onCreate()
{
super.onCreate();
- _keyboardData = new KeyboardData(getResources().getXml(R.xml.azerty));
+ setKeyboard(R.xml.azerty);
}
@Override
@@ -27,11 +27,42 @@ public class Keyboard2 extends InputMethodService
return (_inputView);
}
+ private void setKeyboard(int res)
+ {
+ _keyboardData = new KeyboardData(getResources().getXml(res));
+ if (_inputView != null)
+ _inputView.setKeyboard(this, _keyboardData);
+ }
+
public void handleKeyUp(KeyValue key, int flags)
{
if (getCurrentInputConnection() == null)
return ;
- if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0)
+ if (key.getEventCode() == KeyValue.EVENT_CONFIG)
+ {
+ // TODO improve this shit
+ final CharSequence layouts[] = new CharSequence[]{"Azerty", "Qwerty"};
+ final int layout_res[] = new int[]{R.xml.azerty, R.xml.qwerty};
+ final Keyboard2 self = this;
+ android.app.AlertDialog dialog = new android.app.AlertDialog.Builder(this)
+ .setTitle("Change keyboard layout")
+ .setItems(layouts, new android.content.DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(android.content.DialogInterface dialog, int which)
+ {
+ self.setKeyboard(layout_res[which]);
+ }
+ })
+ .create();
+ android.view.WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
+ lp.token = _inputView.getWindowToken();
+ lp.type = android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
+ dialog.getWindow().setAttributes(lp);
+ dialog.getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
+ dialog.show();
+ }
+ else if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0)
handleMetaKeyUp(key, flags);
else if (key.getEventCode() == KeyEvent.KEYCODE_DEL)
handleDelKey(1, 0);
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index b30e955..c079a7a 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -75,6 +75,8 @@ public class Keyboard2View extends View
{
_ime = ime;
_keyboard = keyboardData;
+ requestLayout();
+ invalidate();
}
@Override