diff options
author | Kenny Root <kenny@the-b.org> | 2009-06-15 18:04:20 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2009-06-15 18:04:20 +0000 |
commit | a477004c678e5c583c57b7c450bd06f7555a44fa (patch) | |
tree | 5cd0d2f3f45bbac03b46e548b2249d10973defee | |
parent | 0d7746cfa924e42cb360f022013d088d43cb5ba6 (diff) | |
download | connectbot-a477004c678e5c583c57b7c450bd06f7555a44fa.tar.gz connectbot-a477004c678e5c583c57b7c450bd06f7555a44fa.tar.bz2 connectbot-a477004c678e5c583c57b7c450bd06f7555a44fa.zip |
Add hints for transport destination formats (username@hostname, etc)
git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@300 df292f66-193f-0410-a5fc-6d59da041ff2
24 files changed, 252 insertions, 54 deletions
diff --git a/res/layout/act_hostlist.xml b/res/layout/act_hostlist.xml index e9960c9..3e47809 100644 --- a/res/layout/act_hostlist.xml +++ b/res/layout/act_hostlist.xml @@ -34,12 +34,13 @@ <EditText android:id="@+id/front_quickconnect" - android:singleLine="true" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:hint="@string/hint_userhost" + android:hint="username@hostname:port" android:layout_toRightOf="@+id/transport_selection" android:layout_alignTop="@+id/transport_selection" + android:inputType="textEmailAddress" + android:layout_alignBottom="@+id/transport_selection" /> <ListView diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index da1cb44..60367a8 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Use the format 'username@hostname:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Use the format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">username</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostname</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 481c63a..1bd7ccf 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">bruger@værtsnavn</string> - <string name="list_format_error">Anvend formatet "bruger@værtsnavn:port"</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Anvend formatet "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">bruger</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">værtsnavn</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Administrer offentlige nøgler</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 5e16615..ae394b7 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Verwenden Sie das Format 'benutzername@hostname:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Verwenden Sie das Format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">benutzername</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostname</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Pubkeys verwalten</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 83d2847..cea3557 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">usuario@equipo</string> - <string name="list_format_error">Use el formato 'usuario@equipo:puerto'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Use el formato "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">usuario</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">equipo</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">puerto</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml index f88b0cb..6344117 100644 --- a/res/values-eu/strings.xml +++ b/res/values-eu/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Use the format 'username@hostname:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Use the format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">username</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostname</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 0311896..9d080c0 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Utilisez le format 'utilisateur@serveur:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Utilisez le format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">utilisateur</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">serveur</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Gérer les clés publiques</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-id/strings.xml b/res/values-id/strings.xml index 8422368..7a1bfcf 100644 --- a/res/values-id/strings.xml +++ b/res/values-id/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">pengguna@namahost</string> - <string name="list_format_error">Gunakan format 'namapengguna@namahost:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Gunakan format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">namapengguna</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">namahost</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Pelihara Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index e45bdc2..0d0a068 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">utente@host</string> - <string name="list_format_error">Usare il formato 'utente@host:porta'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Usare il formato "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">utente</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">host</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">porta</string> <string name="list_menu_pubkeys">Gestione chiavi pubbliche</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index 72d2724..c8a3e4b 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">bruker@vert</string> - <string name="list_format_error">Bruk formatet 'bruker@vert:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Bruk formatet "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">bruker</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">vert</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 5b6f96a..8795acd 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">gebruiker@hostnaam</string> - <string name="list_format_error">Gebruik het formaat 'gebruikersnaam@hostnaam:poort'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Gebruik het formaat "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">gebruikersnaam</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostnaam</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">poort</string> <string name="list_menu_pubkeys">Beheer Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 4e619eb..e3d4638 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">użytkownik@nazwa_hosta</string> - <string name="list_format_error">Użyj formatu 'użytkownik@nazwa_hosta:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Użyj formatu "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">użytkownik</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">nazwa_hosta</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Zarządzaj kluczami publicznymi</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index dbaeb8f..875c0ef 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Use the format 'username@hostname:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Use the format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">username</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostname</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index caaf391..97cfd28 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">användarnamn@värdnamn</string> - <string name="list_format_error">Använd formatet "användarnamn@värdnamn:port"</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Använd formatet "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">användarnamn</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">värdnamn</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Hantera publika nycklar</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index e24e027..05c09fd 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Use the format 'username@hostname:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Use the format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">username</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostname</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml index 544475d..09bd915 100644 --- a/res/values-zh-rHK/strings.xml +++ b/res/values-zh-rHK/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Use the format 'username@hostname:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Use the format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">username</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostname</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/res/values/strings.xml b/res/values/strings.xml index bbc23f2..e076ab6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -288,7 +288,15 @@ <!-- The string to present in the quick-connect box to hint the user to the format for connecting to hosts. --> <string name="hint_userhost">user@hostname</string> - <string name="list_format_error">Use the format 'username@hostname:port'</string> + <!-- Hint given to user when the format they're using is incorrect in the quick-connect box. --> + <string name="list_format_error">Use the format "%1$s"</string> + + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_username">username</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_hostname">hostname</string> + <!-- Part of the formatting hints that will be used like: username@hostname:port --> + <string name="format_port">port</string> <string name="list_menu_pubkeys">Manage Pubkeys</string> <!-- Selection choice to sort hosts by color. --> diff --git a/src/org/connectbot/HostListActivity.java b/src/org/connectbot/HostListActivity.java index 7280176..7d0a687 100644 --- a/src/org/connectbot/HostListActivity.java +++ b/src/org/connectbot/HostListActivity.java @@ -80,6 +80,7 @@ public class HostListActivity extends ListActivity { private MenuItem sortlast; private Spinner transportSpinner; + private TextView quickconnect; protected Handler updateHandler = new Handler() { @Override @@ -197,18 +198,11 @@ public class HostListActivity extends ListActivity { // launch off to console details HostBean host = (HostBean) parent.getAdapter().getItem(position); + Uri uri = host.getUri(); - // create a specific uri that represents this host - Uri uri = Uri.parse(String.format("%s://%s@%s:%d/#%s", - Uri.encode(host.getProtocol()), - Uri.encode(host.getUsername()), - Uri.encode(host.getHostname()), - host.getPort(), - Uri.encode(host.getNickname()))); Intent contents = new Intent(Intent.ACTION_VIEW, uri); contents.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - if (makingShortcut) { // create shortcut if requested ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(HostListActivity.this, R.drawable.icon); @@ -230,37 +224,19 @@ public class HostListActivity extends ListActivity { this.registerForContextMenu(list); - final TextView text = (TextView) this.findViewById(R.id.front_quickconnect); - text.setVisibility(makingShortcut ? View.GONE : View.VISIBLE); - text.setOnKeyListener(new OnKeyListener() { + quickconnect = (TextView) this.findViewById(R.id.front_quickconnect); + quickconnect.setVisibility(makingShortcut ? View.GONE : View.VISIBLE); + quickconnect.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if(event.getAction() == KeyEvent.ACTION_UP) return false; if(keyCode != KeyEvent.KEYCODE_ENTER) return false; - Uri uri = TransportFactory.getUri((String) transportSpinner - .getSelectedItem(), text.getText().toString()); - - if (uri == null) { - text.setError(getString(R.string.list_format_error)); - return false; - } - - HostBean host = TransportFactory.getTransport(uri.getScheme()).createHost(uri); - host.setColor(HostDatabase.COLOR_GRAY); - host.setPubkeyId(HostDatabase.PUBKEYID_ANY); - hostdb.saveHost(host); - - Intent intent = new Intent(HostListActivity.this, ConsoleActivity.class); - intent.setData(uri); - HostListActivity.this.startActivity(intent); - - return true; + return startConsoleActivity(); } - }); - text.requestFocus(); + quickconnect.requestFocus(); transportSpinner = (Spinner)findViewById(R.id.transport_selection); ArrayAdapter<String> transportSelection = new ArrayAdapter<String>(this, @@ -268,7 +244,20 @@ public class HostListActivity extends ListActivity { transportSelection.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); transportSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> arg0, View view, int position, long id) { - text.requestFocus(); + String formatHint = TransportFactory.getFormatHint( + (String) transportSpinner.getSelectedItem(), + HostListActivity.this); + + quickconnect.setHint(formatHint); + + // Start ConsoleActivity immediately if the hint is empty. + if ("".equals(formatHint)) { + quickconnect.setEnabled(false); + startConsoleActivity(); + } else { + quickconnect.setEnabled(true); + quickconnect.requestFocus(); + } } public void onNothingSelected(AdapterView<?> arg0) { } }); @@ -403,6 +392,34 @@ public class HostListActivity extends ListActivity { }); } + /** + * @param text + * @return + */ + private boolean startConsoleActivity() { + Uri uri = TransportFactory.getUri((String) transportSpinner + .getSelectedItem(), quickconnect.getText().toString()); + + if (uri == null) { + quickconnect.setError(getString(R.string.list_format_error, + TransportFactory.getFormatHint( + (String) transportSpinner.getSelectedItem(), + HostListActivity.this))); + return false; + } + + HostBean host = TransportFactory.getTransport(uri.getScheme()).createHost(uri); + host.setColor(HostDatabase.COLOR_GRAY); + host.setPubkeyId(HostDatabase.PUBKEYID_ANY); + hostdb.saveHost(host); + + Intent intent = new Intent(HostListActivity.this, ConsoleActivity.class); + intent.setData(uri); + HostListActivity.this.startActivity(intent); + + return true; + } + protected void updateList() { Editor edit = prefs.edit(); edit.putBoolean(PreferenceConstants.SORT_BY_COLOR, sortedByColor); diff --git a/src/org/connectbot/bean/HostBean.java b/src/org/connectbot/bean/HostBean.java index 8dd9d42..3dcdee5 100644 --- a/src/org/connectbot/bean/HostBean.java +++ b/src/org/connectbot/bean/HostBean.java @@ -265,10 +265,14 @@ public class HostBean extends AbstractBean { */ public Uri getUri() { StringBuilder sb = new StringBuilder(); - sb.append("ssh://") - .append(Uri.encode(username)) - .append('@') - .append(Uri.encode(hostname)) + sb.append(protocol) + .append("://"); + + if (username != null) + sb.append(Uri.encode(username)) + .append('@'); + + sb.append(Uri.encode(hostname)) .append(':') .append(port) .append("/#") diff --git a/src/org/connectbot/transport/AbsTransport.java b/src/org/connectbot/transport/AbsTransport.java index f1a664a..582d4e7 100644 --- a/src/org/connectbot/transport/AbsTransport.java +++ b/src/org/connectbot/transport/AbsTransport.java @@ -27,6 +27,7 @@ import org.connectbot.bean.PortForwardBean; import org.connectbot.service.TerminalBridge; import org.connectbot.service.TerminalManager; +import android.content.Context; import android.net.Uri; /** @@ -234,4 +235,12 @@ public abstract class AbsTransport { * @return */ public abstract HostBean createHost(Uri uri); + + /** + * @param context context containing the correct resources + * @return string that hints at the format for connection + */ + public static String getFormatHint(Context context) { + return "???"; + } } diff --git a/src/org/connectbot/transport/Local.java b/src/org/connectbot/transport/Local.java index 71ccb45..dcdf40d 100644 --- a/src/org/connectbot/transport/Local.java +++ b/src/org/connectbot/transport/Local.java @@ -31,6 +31,7 @@ import org.connectbot.service.TerminalBridge; import org.connectbot.service.TerminalManager; import org.connectbot.util.HostDatabase; +import android.content.Context; import android.net.Uri; import android.util.Log; @@ -212,4 +213,8 @@ public class Local extends AbsTransport { selection.put(HostDatabase.FIELD_HOST_PROTOCOL, PROTOCOL); selection.put(HostDatabase.FIELD_HOST_NICKNAME, uri.getFragment()); } + + public static String getFormatHint(Context context) { + return ""; + } } diff --git a/src/org/connectbot/transport/SSH.java b/src/org/connectbot/transport/SSH.java index 276cc1b..62ea9d6 100644 --- a/src/org/connectbot/transport/SSH.java +++ b/src/org/connectbot/transport/SSH.java @@ -45,6 +45,7 @@ import org.connectbot.util.HostDatabase; import org.connectbot.util.PubkeyDatabase; import org.connectbot.util.PubkeyUtils; +import android.content.Context; import android.net.Uri; import android.util.Log; @@ -782,4 +783,11 @@ public class SSH extends AbsTransport implements ConnectionMonitor, InteractiveC public void setCompression(boolean compression) { this.compression = compression; } + + public static String getFormatHint(Context context) { + return String.format("%s@%s:%s", + context.getString(R.string.format_username), + context.getString(R.string.format_hostname), + context.getString(R.string.format_port)); + } } diff --git a/src/org/connectbot/transport/Telnet.java b/src/org/connectbot/transport/Telnet.java index e0d67a7..72e1b2b 100644 --- a/src/org/connectbot/transport/Telnet.java +++ b/src/org/connectbot/transport/Telnet.java @@ -27,11 +27,13 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.connectbot.R; import org.connectbot.bean.HostBean; import org.connectbot.service.TerminalBridge; import org.connectbot.service.TerminalManager; import org.connectbot.util.HostDatabase; +import android.content.Context; import android.net.Uri; import android.util.Log; import de.mud.telnet.TelnetProtocolHandler; @@ -281,4 +283,10 @@ public class Telnet extends AbsTransport { port = DEFAULT_PORT; selection.put(HostDatabase.FIELD_HOST_PORT, Integer.toString(port)); } + + public static String getFormatHint(Context context) { + return String.format("%s:%s", + context.getString(R.string.format_hostname), + context.getString(R.string.format_port)); + } } diff --git a/src/org/connectbot/transport/TransportFactory.java b/src/org/connectbot/transport/TransportFactory.java index e5b893a..7e64363 100644 --- a/src/org/connectbot/transport/TransportFactory.java +++ b/src/org/connectbot/transport/TransportFactory.java @@ -18,6 +18,7 @@ package org.connectbot.transport; +import android.content.Context; import android.net.Uri; import android.util.Log; @@ -83,4 +84,21 @@ public class TransportFactory { return false; } } + + /** + * @param protocol text name of protocol + * @param context + * @return expanded format hint + */ + public static String getFormatHint(String protocol, Context context) { + if (SSH.getProtocolName().equals(protocol)) { + return SSH.getFormatHint(context); + } else if (Telnet.getProtocolName().equals(protocol)) { + return Telnet.getFormatHint(context); + } else if (Local.getProtocolName().equals(protocol)) { + return Local.getFormatHint(context); + } else { + return AbsTransport.getFormatHint(context); + } + } } |