From 99588c3cb1369a7608478167a0880906ff3bb0fc Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Mon, 19 Aug 2013 00:15:00 +0000 Subject: [PATCH] Filled tunnel row layout with tunnel data --- res/values/strings.xml | 12 +++ .../router/adapter/TunnelEntryAdapter.java | 3 +- .../android/router/loader/TunnelEntry.java | 90 ++++++++++++++++++- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index dcbcbb98b..2b4812020 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -72,5 +72,17 @@ <string name="settings_label_expl_backupQuantity">Backup quantity</string> <string name="settings_desc_expl_backupQuantity">How many tunnel backups</string> + <string name="i2ptunnel_type_client">Standard client</string> + <string name="i2ptunnel_type_httpclient">HTTP client</string> + <string name="i2ptunnel_type_ircclient">IRC client</string> + <string name="i2ptunnel_type_server">Standard server</string> + <string name="i2ptunnel_type_httpserver">HTTP server</string> + <string name="i2ptunnel_type_sockstunnel">SOCKS 4/4a/5 proxy</string> + <string name="i2ptunnel_type_socksirctunnel">SOCKS IRC proxy</string> + <string name="i2ptunnel_type_connectclient">CONNECT/SSL/HTTPS proxy</string> + <string name="i2ptunnel_type_ircserver">IRC server</string> + <string name="i2ptunnel_type_streamrclient">Streamr client</string> + <string name="i2ptunnel_type_streamrserver">Streamr server</string> + <string name="i2ptunnel_type_httpbidirserver">HTTP bidir</string> <string name="i2ptunnel_not_initialized">Tunnels are not initialized yet, please reload in two minutes.</string> </resources> \ No newline at end of file diff --git a/src/net/i2p/android/router/adapter/TunnelEntryAdapter.java b/src/net/i2p/android/router/adapter/TunnelEntryAdapter.java index ad679119d..790766883 100644 --- a/src/net/i2p/android/router/adapter/TunnelEntryAdapter.java +++ b/src/net/i2p/android/router/adapter/TunnelEntryAdapter.java @@ -38,7 +38,7 @@ public class TunnelEntryAdapter extends ArrayAdapter<TunnelEntry> { name.setText(tunnel.getName()); TextView type = (TextView) v.findViewById(R.id.tunnel_type); - type.setText(tunnel.getType()); + type.setText(tunnel.getTypeName()); TextView ifacePort = (TextView) v.findViewById(R.id.tunnel_interface_port); ifacePort.setText(tunnel.getIfacePort()); @@ -47,6 +47,7 @@ public class TunnelEntryAdapter extends ArrayAdapter<TunnelEntry> { details.setText(tunnel.getDetails()); ImageView status = (ImageView) v.findViewById(R.id.tunnel_status); + status.setImageDrawable(tunnel.getStatusIcon()); return v; } diff --git a/src/net/i2p/android/router/loader/TunnelEntry.java b/src/net/i2p/android/router/loader/TunnelEntry.java index 6d522595c..99cbd0cfe 100644 --- a/src/net/i2p/android/router/loader/TunnelEntry.java +++ b/src/net/i2p/android/router/loader/TunnelEntry.java @@ -1,5 +1,7 @@ package net.i2p.android.router.loader; +import android.graphics.drawable.Drawable; +import net.i2p.android.router.R; import net.i2p.i2ptunnel.TunnelController; public class TunnelEntry { @@ -37,11 +39,95 @@ public class TunnelEntry { return mController.getType(); } + public String getTypeName() { + if ("client".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_client); + else if ("httpclient".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_httpclient); + else if ("ircclient".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_ircclient); + else if ("server".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_server); + else if ("httpserver".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_httpserver); + else if ("sockstunnel".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_sockstunnel); + else if ("socksirctunnel".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_socksirctunnel); + else if ("connectclient".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_connectclient); + else if ("ircserver".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_ircserver); + else if ("streamrclient".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_streamrclient); + else if ("streamrserver".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_streamrserver); + else if ("httpbidirserver".equals(mController.getType())) + return mLoader.getContext().getResources() + .getString(R.string.i2ptunnel_type_httpbidirserver); + else + return mController.getType(); + } + public String getIfacePort() { - return "127.0.0.1:1234"; + String host = ""; + String port = ""; + if (isClient()) { + if ("streamrclient".equals(getType())) + host = mController.getTargetHost(); + else + host = mController.getListenOnInterface(); + port = mController.getListenPort(); + } else { + if ("streamrserver".equals(getType())) + host = mController.getListenOnInterface(); + else + host = mController.getTargetHost(); + port = mController.getTargetPort(); + if (host.indexOf(':') >= 0) + host = '[' + host + ']'; + } + return host + ":" + port; } public String getDetails() { - return "Details"; + String details; + if (isClient()) { + if ("client".equals(getType()) || + "ircclient".equals(getType()) || + "streamrclient".equals(getType())) + details = mController.getTargetDestination(); + else + details = mController.getProxyList(); + } else + details = ""; + return details; + } + + public Drawable getStatusIcon() { + if (mController.getIsRunning()) { + if (isClient() && mController.getIsStandby()) + return mLoader.getContext().getResources() + .getDrawable(R.drawable.local_inprogress); + else + return mLoader.getContext().getResources() + .getDrawable(R.drawable.local_up); + } else if (mController.getIsStarting()) + return mLoader.getContext().getResources() + .getDrawable(R.drawable.local_inprogress); + else + return mLoader.getContext().getResources() + .getDrawable(R.drawable.local_down); } } -- GitLab