From ebeaa5265f91c8ab68058df702465d45c3131d6f Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Thu, 23 Jul 2015 14:54:30 -0700 Subject: Add a confirm dialog for the disconnect all action. --- .../main/java/org/connectbot/HostListActivity.java | 37 +++++++++++++++------- 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'app/src/main/java/org/connectbot/HostListActivity.java') 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() { -- cgit v1.2.3