aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/org
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-03-23 16:22:32 +0000
committerKenny Root <kenny@the-b.org>2015-03-23 16:25:06 +0000
commitf0ca96308b23643df1208acfe72015b46ae70067 (patch)
tree265bc747a3b5383075ecb12d99c3c89dcd5a2274 /app/src/main/java/org
parent89ee9588459755193dfff3df45f4494d53b25854 (diff)
parentf129a9b52110ffafec4400e17d78881c50307d8a (diff)
downloadconnectbot-f0ca96308b23643df1208acfe72015b46ae70067.tar.gz
connectbot-f0ca96308b23643df1208acfe72015b46ae70067.tar.bz2
connectbot-f0ca96308b23643df1208acfe72015b46ae70067.zip
Merge remote-tracking branch 'origin/master'
Conflicts: app/src/main/java/org/connectbot/HostListActivity.java app/src/main/java/org/connectbot/service/TerminalKeyListener.java
Diffstat (limited to 'app/src/main/java/org')
-rw-r--r--app/src/main/java/org/connectbot/ConsoleActivity.java2
-rw-r--r--app/src/main/java/org/connectbot/HostListActivity.java14
-rw-r--r--app/src/main/java/org/connectbot/service/TerminalKeyListener.java71
-rw-r--r--app/src/main/java/org/connectbot/util/PreferenceConstants.java10
4 files changed, 84 insertions, 13 deletions
diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java
index 1e14d16..5118e99 100644
--- a/app/src/main/java/org/connectbot/ConsoleActivity.java
+++ b/app/src/main/java/org/connectbot/ConsoleActivity.java
@@ -420,7 +420,7 @@ public class ConsoleActivity extends Activity {
TerminalView terminal = (TerminalView)flip;
TerminalKeyListener handler = terminal.bridge.getKeyHandler();
- handler.metaPress(TerminalKeyListener.OUR_CTRL_ON);
+ handler.metaPress(TerminalKeyListener.OUR_CTRL_ON, true);
hideEmulatedKeys();
}
});
diff --git a/app/src/main/java/org/connectbot/HostListActivity.java b/app/src/main/java/org/connectbot/HostListActivity.java
index b46b148..c97e69e 100644
--- a/app/src/main/java/org/connectbot/HostListActivity.java
+++ b/app/src/main/java/org/connectbot/HostListActivity.java
@@ -165,11 +165,23 @@ public class HostListActivity extends ListActivity {
// detect HTC Dream and apply special preferences
if (Build.MANUFACTURER.equals("HTC") && Build.DEVICE.equals("dream")) {
+ SharedPreferences.Editor editor = prefs.edit();
+ boolean doCommit = false;
if (!prefs.contains(PreferenceConstants.SHIFT_FKEYS) &&
!prefs.contains(PreferenceConstants.CTRL_FKEYS)) {
- SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(PreferenceConstants.SHIFT_FKEYS, true);
editor.putBoolean(PreferenceConstants.CTRL_FKEYS, true);
+ doCommit = true;
+ }
+ if (!prefs.contains(PreferenceConstants.STICKY_MODIFIERS)) {
+ editor.putString(PreferenceConstants.STICKY_MODIFIERS, PreferenceConstants.YES);
+ doCommit = true;
+ }
+ if (!prefs.contains(PreferenceConstants.KEYMODE)) {
+ editor.putString(PreferenceConstants.KEYMODE, PreferenceConstants.KEYMODE_RIGHT);
+ doCommit = true;
+ }
+ if (doCommit) {
editor.commit();
}
}
diff --git a/app/src/main/java/org/connectbot/service/TerminalKeyListener.java b/app/src/main/java/org/connectbot/service/TerminalKeyListener.java
index 64fae56..6cd01b0 100644
--- a/app/src/main/java/org/connectbot/service/TerminalKeyListener.java
+++ b/app/src/main/java/org/connectbot/service/TerminalKeyListener.java
@@ -64,6 +64,14 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
// backport constants from api level 11
private final static int KEYCODE_ESCAPE = 111;
+ private final static int KEYCODE_CTRL_LEFT = 113;
+ private final static int KEYCODE_CTRL_RIGHT = 114;
+ private final static int KEYCODE_INSERT = 124;
+ private final static int KEYCODE_FORWARD_DEL = 112;
+ private final static int KEYCODE_MOVE_HOME = 122;
+ private final static int KEYCODE_MOVE_END = 123;
+ private final static int KEYCODE_PAGE_DOWN = 93;
+ private final static int KEYCODE_PAGE_UP = 92;
private final static int HC_META_CTRL_ON = 0x1000;
private final static int HC_META_CTRL_LEFT_ON = 0x2000;
private final static int HC_META_CTRL_RIGHT_ON = 0x4000;
@@ -81,6 +89,7 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
private boolean shiftedNumbersAreFKeysOnHardKeyboard;
private boolean controlNumbersAreFKeysOnSoftKeyboard;
private boolean volumeKeysChangeFontSize;
+ private int stickyMetas;
private int ourMetaState = 0;
@@ -234,6 +243,10 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
return true;
}
}
+ if (keyCode == KEYCODE_CTRL_LEFT || keyCode == KEYCODE_CTRL_RIGHT) {
+ metaPress(OUR_CTRL_ON);
+ return true;
+ }
}
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
@@ -258,7 +271,7 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
sendEscape();
ourMetaState &= ~OUR_CTRL_ON;
} else
- metaPress(OUR_CTRL_ON);
+ metaPress(OUR_CTRL_ON, true);
}
bridge.redraw();
return true;
@@ -292,7 +305,10 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
int uchar = event.getUnicodeChar(derivedMetaState & ~HC_META_CTRL_MASK);
int ucharWithoutAlt = event.getUnicodeChar(
derivedMetaState & ~(HC_META_ALT_MASK | HC_META_CTRL_MASK));
- if (uchar != ucharWithoutAlt) {
+ if (uchar == 0) {
+ // Keymap doesn't know the key with alt on it, so just go with the unmodified version
+ uchar = ucharWithoutAlt;
+ } else if (uchar != ucharWithoutAlt) {
// The alt key was used to modify the character returned; therefore, drop the alt
// modifier from the state so we don't end up sending alt+key.
derivedMetaState &= ~HC_META_ALT_MASK;
@@ -405,6 +421,31 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
bridge.tryKeyVibrate();
}
return true;
+
+ case KEYCODE_INSERT:
+ ((vt320) buffer).keyPressed(vt320.KEY_INSERT, ' ',
+ getStateForBuffer());
+ return true;
+ case KEYCODE_FORWARD_DEL:
+ ((vt320) buffer).keyPressed(vt320.KEY_DELETE, ' ',
+ getStateForBuffer());
+ return true;
+ case KEYCODE_MOVE_HOME:
+ ((vt320) buffer).keyPressed(vt320.KEY_HOME, ' ',
+ getStateForBuffer());
+ return true;
+ case KEYCODE_MOVE_END:
+ ((vt320) buffer).keyPressed(vt320.KEY_END, ' ',
+ getStateForBuffer());
+ return true;
+ case KEYCODE_PAGE_UP:
+ ((vt320) buffer).keyPressed(vt320.KEY_PAGE_UP, ' ',
+ getStateForBuffer());
+ return true;
+ case KEYCODE_PAGE_DOWN:
+ ((vt320) buffer).keyPressed(vt320.KEY_PAGE_DOWN, ' ',
+ getStateForBuffer());
+ return true;
}
} catch (IOException e) {
@@ -493,17 +534,25 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
*
* @param code
*/
- public void metaPress(int code) {
+ public void metaPress(int code, boolean forceSticky) {
if ((ourMetaState & (code << 1)) != 0) {
ourMetaState &= ~(code << 1);
} else if ((ourMetaState & code) != 0) {
ourMetaState &= ~code;
ourMetaState |= code << 1;
- } else
+ } else if (forceSticky || (stickyMetas & code) != 0) {
ourMetaState |= code;
+ } else {
+ // skip redraw
+ return;
+ }
bridge.redraw();
}
+ public void metaPress(int code) {
+ metaPress(code, false);
+ }
+
public void setTerminalKeyMode(String keymode) {
this.keymode = keymode;
}
@@ -538,18 +587,28 @@ public class TerminalKeyListener implements OnKeyListener, OnSharedPreferenceCha
if (PreferenceConstants.KEYMODE.equals(key) ||
PreferenceConstants.SHIFT_FKEYS.equals(key) ||
PreferenceConstants.CTRL_FKEYS.equals(key) ||
- PreferenceConstants.VOLUME_FONT.equals(key)) {
+ PreferenceConstants.VOLUME_FONT.equals(key) ||
+ PreferenceConstants.STICKY_MODIFIERS.equals(key)) {
updatePrefs();
}
}
private void updatePrefs() {
- keymode = prefs.getString(PreferenceConstants.KEYMODE, PreferenceConstants.KEYMODE_RIGHT);
+ keymode = prefs.getString(PreferenceConstants.KEYMODE, PreferenceConstants.KEYMODE_NONE);
shiftedNumbersAreFKeysOnHardKeyboard =
prefs.getBoolean(PreferenceConstants.SHIFT_FKEYS, false);
controlNumbersAreFKeysOnSoftKeyboard =
prefs.getBoolean(PreferenceConstants.CTRL_FKEYS, false);
volumeKeysChangeFontSize = prefs.getBoolean(PreferenceConstants.VOLUME_FONT, true);
+ String stickyModifiers = prefs.getString(PreferenceConstants.STICKY_MODIFIERS,
+ PreferenceConstants.NO);
+ if (PreferenceConstants.ALT.equals(stickyModifiers)) {
+ stickyMetas = OUR_ALT_ON;
+ } else if (PreferenceConstants.YES.equals(stickyModifiers)) {
+ stickyMetas = OUR_SHIFT_ON | OUR_CTRL_ON | OUR_ALT_ON;
+ } else {
+ stickyMetas = 0;
+ }
}
public void setCharset(String encoding) {
diff --git a/app/src/main/java/org/connectbot/util/PreferenceConstants.java b/app/src/main/java/org/connectbot/util/PreferenceConstants.java
index ad29c39..d3cd832 100644
--- a/app/src/main/java/org/connectbot/util/PreferenceConstants.java
+++ b/app/src/main/java/org/connectbot/util/PreferenceConstants.java
@@ -30,11 +30,6 @@ public class PreferenceConstants {
public static final boolean PRE_HONEYCOMB = SDK_INT < 11;
public static final String MEMKEYS = "memkeys";
- public static final String UPDATE = "update";
-
- public static final String UPDATE_DAILY = "Daily";
- public static final String UPDATE_WEEKLY = "Weekly";
- public static final String UPDATE_NEVER = "Never";
public static final String LAST_CHECKED = "lastchecked";
@@ -56,6 +51,7 @@ public class PreferenceConstants {
public static final String KEYMODE_RIGHT = "Use right-side keys";
public static final String KEYMODE_LEFT = "Use left-side keys";
+ public static final String KEYMODE_NONE = "none";
public static final String CAMERA = "camera";
@@ -85,6 +81,10 @@ public class PreferenceConstants {
public static final String SHIFT_FKEYS = "shiftfkeys";
public static final String CTRL_FKEYS = "ctrlfkeys";
public static final String VOLUME_FONT = "volumefont";
+ public static final String STICKY_MODIFIERS = "stickymodifiers";
+ public static final String YES = "yes";
+ public static final String NO = "no";
+ public static final String ALT = "alt";
/* Backup identifiers */
public static final String BACKUP_PREF_KEY = "prefs";