diff options
author | Kenny Root <kenny@the-b.org> | 2015-07-29 17:17:49 -0700 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2015-07-29 17:17:49 -0700 |
commit | ca740c38f5178ad47a2dbb5b1041be232e865a2d (patch) | |
tree | 36f3f3073983fb9600e626559f32e876dc4c68e9 | |
parent | afe62e4079d9e5c3cfb5702e45ed2656409b054a (diff) | |
parent | 41a1eb43266d64c3fe8f519ed00d16f6436d1cae (diff) | |
download | connectbot-ca740c38f5178ad47a2dbb5b1041be232e865a2d.tar.gz connectbot-ca740c38f5178ad47a2dbb5b1041be232e865a2d.tar.bz2 connectbot-ca740c38f5178ad47a2dbb5b1041be232e865a2d.zip |
Merge in PRs again
For some reason these got clobbered.
-rw-r--r-- | app/src/main/java/org/connectbot/ConsoleActivity.java | 63 | ||||
-rw-r--r-- | app/src/main/java/org/connectbot/HostListActivity.java | 37 | ||||
-rw-r--r-- | app/src/main/res/values/strings.xml | 4 |
3 files changed, 80 insertions, 24 deletions
diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java index e7a8f7d..79f1269 100644 --- a/app/src/main/java/org/connectbot/ConsoleActivity.java +++ b/app/src/main/java/org/connectbot/ConsoleActivity.java @@ -48,6 +48,7 @@ import android.os.Message; import android.preference.PreferenceManager; import android.text.ClipboardManager; import android.util.Log; +import android.view.ContextMenu; import android.view.GestureDetector; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -324,6 +325,7 @@ public class ConsoleActivity extends Activity { inflater = LayoutInflater.from(this); flip = (ViewFlipper) findViewById(R.id.console_flip); + registerForContextMenu(flip); empty = (TextView) findViewById(android.R.id.empty); stringPromptGroup = (RelativeLayout) findViewById(R.id.console_password_group); @@ -455,7 +457,7 @@ public class ConsoleActivity extends Activity { }); // detect fling gestures to switch between terminals - final GestureDetector detect = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { + final GestureDetector detect = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { private float totalY = 0; @Override @@ -480,7 +482,13 @@ public class ConsoleActivity extends Activity { } - return false; + return super.onFling(e1, e2, velocityX, velocityY); + } + + @Override + public void onLongPress(MotionEvent e) { + super.onLongPress(e); + openContextMenu(flip); } @@ -500,7 +508,8 @@ public class ConsoleActivity extends Activity { } // activate consider if within x tolerance - if (Math.abs(e1.getX() - e2.getX()) < ViewConfiguration.getTouchSlop() * 4) { + int touchSlop = ViewConfiguration.get(ConsoleActivity.this).getScaledTouchSlop(); + if (Math.abs(e1.getX() - e2.getX()) < touchSlop * 4) { View flip = findCurrentView(R.id.console_flip); if (flip == null) return false; @@ -622,7 +631,8 @@ public class ConsoleActivity extends Activity { } // pass any touch events back to detector - return detect.onTouchEvent(event); + detect.onTouchEvent(event); + return true; } }); @@ -726,14 +736,7 @@ public class ConsoleActivity extends Activity { paste.setEnabled(clipboard.hasText() && sessionOpen); paste.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - // force insert of clipboard text into current console - TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); - TerminalBridge bridge = terminalView.bridge; - - // pull string from clipboard and generate all events to force down - String clip = clipboard.getText().toString(); - bridge.injectString(clip); - + pasteIntoTerminal(); return true; } }); @@ -874,6 +877,32 @@ public class ConsoleActivity extends Activity { } @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + final View view = findCurrentView(R.id.console_flip); + boolean activeTerminal = (view instanceof TerminalView); + boolean sessionOpen = false; + + if (activeTerminal) { + TerminalBridge bridge = ((TerminalView) view).bridge; + sessionOpen = bridge.isSessionOpen(); + } + + MenuItem paste = menu.add(R.string.console_menu_paste); + if (hardKeyboard) + paste.setAlphabeticShortcut('v'); + paste.setIcon(android.R.drawable.ic_menu_edit); + paste.setEnabled(clipboard.hasText() && sessionOpen); + paste.setOnMenuItemClickListener(new OnMenuItemClickListener() { + public boolean onMenuItemClick(MenuItem item) { + pasteIntoTerminal(); + return true; + } + }); + + + } + + @Override public void onStart() { super.onStart(); @@ -1114,6 +1143,16 @@ public class ConsoleActivity extends Activity { } } + private void pasteIntoTerminal() { + // force insert of clipboard text into current console + TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip); + TerminalBridge bridge = terminalView.bridge; + + // pull string from clipboard and generate all events to force down + String clip = clipboard.getText().toString(); + bridge.injectString(clip); + } + /** * Adds a new TerminalBridge to the current set of views in our ViewFlipper. * diff --git a/app/src/main/java/org/connectbot/HostListActivity.java b/app/src/main/java/org/connectbot/HostListActivity.java index f0fdf16..a0d7901 100644 --- a/app/src/main/java/org/connectbot/HostListActivity.java +++ b/app/src/main/java/org/connectbot/HostListActivity.java @@ -442,27 +442,40 @@ public class HostListActivity extends ListActivity { * Disconnects all active connections and closes the activity if appropriate. */ private void disconnectAll() { - // TODO(jklein24): Show a confirm dialog before actually disconnecting. if (bound == null) { waitingForDisconnectAll = true; return; } - bound.disconnectAll(true, false); - updateHandler.sendEmptyMessage(-1); - waitingForDisconnectAll = false; - - if (closeOnDisconnectAll) { - // Clear the intent so that the activity can be relaunched without closing. - // TODO(jlklein): Find a better way to do this. - setIntent(new Intent()); - finish(); - } + new AlertDialog.Builder(HostListActivity.this) + .setMessage(getString(R.string.disconnect_all_message)) + .setPositiveButton(R.string.disconnect_all_pos, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + bound.disconnectAll(true, false); + updateHandler.sendEmptyMessage(-1); + waitingForDisconnectAll = false; + + // Clear the intent so that the activity can be relaunched without closing. + // TODO(jlklein): Find a better way to do this. + setIntent(new Intent()); + + if (closeOnDisconnectAll) { + finish(); + } + } + }) + .setNegativeButton(R.string.disconnect_all_neg, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + waitingForDisconnectAll = false; + // Clear the intent so that the activity can be relaunched without closing. + // TODO(jlklein): Find a better way to do this. + setIntent(new Intent()); + } + }).create().show(); } /** - * @param text * @return */ private boolean startConsoleActivity() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b6860a..67f478d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -425,6 +425,10 @@ <string name="delete_pos">"Yes, delete"</string> <string name="delete_neg">"Cancel"</string> + <string name="disconnect_all_message">"Are you sure you want to disconnect from all connected hosts?"</string> + <string name="disconnect_all_pos">"Yes, disconnect"</string> + <string name="disconnect_all_neg">"Cancel"</string> + <!-- Button to agree to license terms. --> <string name="wizard_agree">"Agree"</string> <!-- Button to go to the next page in the first time start-up wizard. --> |