From 23a2bda614003a01cf00ef964a7588acd0aae8a4 Mon Sep 17 00:00:00 2001 From: Greg Alexander Date: Sun, 16 Jun 2019 19:37:16 -0400 Subject: [PATCH] Limit to only displaying 5 IPs at once (the android emulator sets up about 20 interfaces somehow, which really spams the screen). --- .../main/java/org/galexander/sshd/SimpleSSHD.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/galexander/sshd/SimpleSSHD.java b/app/src/main/java/org/galexander/sshd/SimpleSSHD.java index bacaf92..e4d8f41 100644 --- a/app/src/main/java/org/galexander/sshd/SimpleSSHD.java +++ b/app/src/main/java/org/galexander/sshd/SimpleSSHD.java @@ -214,6 +214,7 @@ public class SimpleSSHD extends Activity public static String get_ip(boolean pretty) { String ret = ""; + int num_ips = 0; try { List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { @@ -226,14 +227,16 @@ public class SimpleSSHD extends Activity if (i != -1) { ip = ip.substring(0,i); } - if (pretty) { - if (!ret.equals("")) { - ret += "\n"; - } - ret += "IP: "+ ip; - } else { + if (!pretty) { return ip; } + if (num_ips++ >= 5) { + return ret+"..."; + } + if (num_ips > 1) { + ret += "\n"; + } + ret += "IP: " + ip; } } }