abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/LauncherActivity.java
diff options
context:
space:
mode:
authorJules Aguillon2023-04-02 13:28:10 +0200
committerJules Aguillon2023-04-02 13:29:53 +0200
commit351355b3a769d2b584733ad0e8924dfe75939fb6 (patch)
tree9256361692887ea9cf82e14f33118062a936abd9 /srcs/juloo.keyboard2/LauncherActivity.java
parent3caca59ff43e09578838d213b9c2f94c072b0832 (diff)
downloadunexpected-keyboard-351355b3a769d2b584733ad0e8924dfe75939fb6.tar.gz
unexpected-keyboard-351355b3a769d2b584733ad0e8924dfe75939fb6.zip
Launcher activity: Input box
For trying the keyboard without having to mess with an other app.
Diffstat (limited to 'srcs/juloo.keyboard2/LauncherActivity.java')
-rw-r--r--srcs/juloo.keyboard2/LauncherActivity.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/srcs/juloo.keyboard2/LauncherActivity.java b/srcs/juloo.keyboard2/LauncherActivity.java
index 83217a8..d54ff60 100644
--- a/srcs/juloo.keyboard2/LauncherActivity.java
+++ b/srcs/juloo.keyboard2/LauncherActivity.java
@@ -7,20 +7,52 @@ import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
+import android.view.KeyCharacterMap;
+import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
public class LauncherActivity extends Activity
{
+ /** Text is replaced when receiving key events. */
+ TextView _tryhere_text;
+ EditText _tryhere_area;
+
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.launcher_activity);
+ _tryhere_text = (TextView)findViewById(R.id.launcher_tryhere_text);
+ _tryhere_area = (EditText)findViewById(R.id.launcher_tryhere_area);
+ _tryhere_area.addOnUnhandledKeyEventListener(
+ this.new Tryhere_OnUnhandledKeyEventListener());
}
public void launch_imesettings(View _btn)
{
startActivity(new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS));
}
+
+ final class Tryhere_OnUnhandledKeyEventListener implements View.OnUnhandledKeyEventListener
+ {
+ public boolean onUnhandledKeyEvent(View v, KeyEvent ev)
+ {
+ // Key release of modifiers would erase interesting data
+ if (KeyEvent.isModifierKey(ev.getKeyCode()))
+ return false;
+ StringBuilder s = new StringBuilder();
+ if (ev.isAltPressed()) s.append("Alt+");
+ if (ev.isShiftPressed()) s.append("Shift+");
+ if (ev.isCtrlPressed()) s.append("Ctrl+");
+ if (ev.isMetaPressed()) s.append("Meta+");
+ // s.append(ev.getDisplayLabel());
+ String kc = KeyEvent.keyCodeToString(ev.getKeyCode());
+ s.append(kc.replaceFirst("^KEYCODE_", ""));
+ _tryhere_text.setText(s.toString());
+ return true;
+ }
+ }
}