From ab0e900fff24e88f1a1c4e888b1e9b812e0b75c0 Mon Sep 17 00:00:00 2001 From: adb2001 Date: Mon, 31 Aug 2015 20:59:01 +0200 Subject: Provide visual feedback for virtual keyboard --- .../main/java/org/connectbot/ConsoleActivity.java | 19 +- app/src/main/res/drawable/selector_keyboard.xml | 26 +++ app/src/main/res/layout-large/act_console.xml | 201 +------------------- app/src/main/res/layout/act_console.xml | 203 +-------------------- app/src/main/res/layout/inc_keyboard.xml | 203 +++++++++++++++++++++ app/src/main/res/values/colors.xml | 24 +++ app/src/main/res/values/styles.xml | 2 +- 7 files changed, 272 insertions(+), 406 deletions(-) create mode 100644 app/src/main/res/drawable/selector_keyboard.xml create mode 100644 app/src/main/res/layout/inc_keyboard.xml create mode 100644 app/src/main/res/values/colors.xml (limited to 'app') diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java index 4051a45..5dc741f 100644 --- a/app/src/main/java/org/connectbot/ConsoleActivity.java +++ b/app/src/main/java/org/connectbot/ConsoleActivity.java @@ -227,7 +227,7 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne /** * Handle repeatable virtual keys and touch events */ - public class KeyRepeater implements Runnable, OnTouchListener { + public class KeyRepeater implements Runnable, OnTouchListener, OnClickListener { private View mView; private Handler mHandler; private boolean mDown; @@ -236,6 +236,7 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne mView = view; mHandler = handler; mView.setOnTouchListener(this); + mView.setOnClickListener(this); mDown = false; } @@ -244,7 +245,7 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne mDown = true; mHandler.removeCallbacks(this); mHandler.postDelayed(this, KEYBOARD_REPEAT); - onEmulatedKeyClicked(mView); + mView.performClick(); } @Override @@ -259,27 +260,39 @@ public class ConsoleActivity extends AppCompatActivity implements BridgeDisconne case MotionEvent.ACTION_DOWN: mDown = false; mHandler.postDelayed(this, KEYBOARD_REPEAT_INITIAL); + mView.setPressed(true); return (true); case MotionEvent.ACTION_CANCEL: mHandler.removeCallbacks(this); + mView.setPressed(false); return (true); case MotionEvent.ACTION_UP: mHandler.removeCallbacks(this); + mView.setPressed(false); + if (!mDown) { - onEmulatedKeyClicked(mView); + mView.performClick(); } return (true); } return false; } + + @Override + public void onClick(View view) { + onEmulatedKeyClicked(view); + } } private void onEmulatedKeyClicked(View v) { TerminalView terminal = adapter.getCurrentTerminalView(); if (terminal == null) return; + if (BuildConfig.DEBUG) { + Log.d(TAG, "onEmulatedKeyClicked(" + v.getId() + ")"); + } TerminalKeyListener handler = terminal.bridge.getKeyHandler(); boolean hideKeys = false; diff --git a/app/src/main/res/drawable/selector_keyboard.xml b/app/src/main/res/drawable/selector_keyboard.xml new file mode 100644 index 0000000..a7c822d --- /dev/null +++ b/app/src/main/res/drawable/selector_keyboard.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/app/src/main/res/layout-large/act_console.xml b/app/src/main/res/layout-large/act_console.xml index 66f3d83..d0ad41b 100644 --- a/app/src/main/res/layout-large/act_console.xml +++ b/app/src/main/res/layout-large/act_console.xml @@ -138,205 +138,6 @@ - - - - - - -