aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Horimoto <khorimoto@gmail.com>2015-10-08 15:09:06 -0700
committerKyle Horimoto <khorimoto@gmail.com>2015-10-08 15:09:06 -0700
commitb4959c33480dd2f85323f26cf6db474a79fd6864 (patch)
tree12e39cb485594e84c6e4857bb428bbb739c69b04
parent908e389961eb31d8d53f8d0dadbfeda2556d4219 (diff)
downloadconnectbot-b4959c33480dd2f85323f26cf6db474a79fd6864.tar.gz
connectbot-b4959c33480dd2f85323f26cf6db474a79fd6864.tar.bz2
connectbot-b4959c33480dd2f85323f26cf6db474a79fd6864.zip
Cleaned up code.
-rw-r--r--app/src/main/java/org/connectbot/EditHostActivity.java19
-rw-r--r--app/src/main/java/org/connectbot/HostEditorFragment.java6
2 files changed, 19 insertions, 6 deletions
diff --git a/app/src/main/java/org/connectbot/EditHostActivity.java b/app/src/main/java/org/connectbot/EditHostActivity.java
index 792e362..4fcf64c 100644
--- a/app/src/main/java/org/connectbot/EditHostActivity.java
+++ b/app/src/main/java/org/connectbot/EditHostActivity.java
@@ -94,19 +94,22 @@ public class EditHostActivity extends AppCompatActivity implements HostEditorFra
// Note that the lists must be explicitly declared as ArrayLists because Bundle only accepts
// ArrayLists of Strings.
ArrayList<String> pubkeyNames = new ArrayList<>();
+ ArrayList<String> pubkeyValues = new ArrayList<>();
+
+ // First, add default pubkey names and values (e.g., "use any" and "don't use any").
TypedArray defaultPubkeyNames = getResources().obtainTypedArray(R.array.list_pubkeyids);
for (int i = 0; i < defaultPubkeyNames.length(); i++) {
pubkeyNames.add(defaultPubkeyNames.getString(i));
}
- for (CharSequence cs : mPubkeyDb.allValues(PubkeyDatabase.FIELD_PUBKEY_NICKNAME)) {
- pubkeyNames.add(cs.toString());
- }
-
- ArrayList<String> pubkeyValues = new ArrayList<>();
TypedArray defaultPubkeyValues = getResources().obtainTypedArray(R.array.list_pubkeyids_value);
for (int i = 0; i < defaultPubkeyValues.length(); i++) {
pubkeyValues.add(defaultPubkeyValues.getString(i));
}
+
+ // Now, add pubkeys which have been added by the user.
+ for (CharSequence cs : mPubkeyDb.allValues(PubkeyDatabase.FIELD_PUBKEY_NICKNAME)) {
+ pubkeyNames.add(cs.toString());
+ }
for (CharSequence cs : mPubkeyDb.allValues("_id")) {
pubkeyValues.add(cs.toString());
}
@@ -131,6 +134,8 @@ public class EditHostActivity extends AppCompatActivity implements HostEditorFra
menu);
mSaveHostButton = menu.getItem(0);
+
+ // If the new host is being created, it can't be added until modifications have been made.
mSaveHostButton.setEnabled(!mIsCreating);
return super.onCreateOptionsMenu(menu);
@@ -205,7 +210,9 @@ public class EditHostActivity extends AppCompatActivity implements HostEditorFra
mSaveHostButton.setEnabled(false);
}
- public static class CharsetHolder {
+ // Private static class used to generate a list of available Charsets. Note that this class
+ // must not be initialized by the UI thread because it blocks on disk access.
+ private static class CharsetHolder {
private static boolean mInitialized = false;
// Map from Charset display name to Charset value (i.e., unique ID).
diff --git a/app/src/main/java/org/connectbot/HostEditorFragment.java b/app/src/main/java/org/connectbot/HostEditorFragment.java
index d2ff8b9..56022d7 100644
--- a/app/src/main/java/org/connectbot/HostEditorFragment.java
+++ b/app/src/main/java/org/connectbot/HostEditorFragment.java
@@ -553,6 +553,12 @@ public class HostEditorFragment extends Fragment {
handleHostChange();
}
+ /**
+ * Handles a change in the host caused by the user adjusting the values of one of the widgets
+ * in this fragment. If the change has resulted in a valid host, the new value is sent back
+ * to the listener; however, if the change ha resulted in an invalid host, the listener is
+ * notified.
+ */
private void handleHostChange() {
String protocol = (String) mTransportSpinner.getSelectedItem();
String quickConnectString = mQuickConnectField.getText().toString();