From 1540b4bdf52358b1cea5d92ad86de9ab564918f4 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Fri, 24 Jul 2015 18:15:56 -0700 Subject: Change bridges access through method This will help with unit testing. --- app/src/main/java/org/connectbot/ConsoleActivity.java | 11 +---------- app/src/main/java/org/connectbot/HostListActivity.java | 2 +- app/src/main/java/org/connectbot/service/TerminalManager.java | 11 ++++++++++- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java index 77f8a3f..e7a8f7d 100644 --- a/app/src/main/java/org/connectbot/ConsoleActivity.java +++ b/app/src/main/java/org/connectbot/ConsoleActivity.java @@ -145,9 +145,6 @@ public class ConsoleActivity extends Activity { // let manager know about our event handling services bound.disconnectHandler = disconnectHandler; - - Log.d(TAG, String.format("Connected to TerminalManager and found bridges.size=%d", bound.bridges.size())); - bound.setResizeAllowed(true); // clear out any existing bridges and record requested index @@ -169,7 +166,7 @@ public class ConsoleActivity extends Activity { } // create views for all bridges on this service - for (TerminalBridge bridge : bound.bridges) { + for (TerminalBridge bridge : bound.getBridges()) { final int currentIndex = addNewTerminalView(bridge); @@ -182,12 +179,6 @@ public class ConsoleActivity extends Activity { } public void onServiceDisconnected(ComponentName className) { - // tell each bridge to forget about our prompt handler - synchronized (bound.bridges) { - for (TerminalBridge bridge : bound.bridges) - bridge.promptHelper.setHandler(null); - } - flip.removeAllViews(); updateEmptyVisible(); bound = null; diff --git a/app/src/main/java/org/connectbot/HostListActivity.java b/app/src/main/java/org/connectbot/HostListActivity.java index 7946e9a..2fd9560 100644 --- a/app/src/main/java/org/connectbot/HostListActivity.java +++ b/app/src/main/java/org/connectbot/HostListActivity.java @@ -447,7 +447,7 @@ public class HostListActivity extends ListActivity { // Don't lose hosts that are connected via shortcuts but not in the database. if (bound != null) { - for (TerminalBridge bridge : bound.bridges) { + for (TerminalBridge bridge : bound.getBridges()) { if (!hosts.contains(bridge.host)) hosts.add(0, bridge.host); } diff --git a/app/src/main/java/org/connectbot/service/TerminalManager.java b/app/src/main/java/org/connectbot/service/TerminalManager.java index 8e7187f..1688d2a 100644 --- a/app/src/main/java/org/connectbot/service/TerminalManager.java +++ b/app/src/main/java/org/connectbot/service/TerminalManager.java @@ -70,7 +70,7 @@ import android.util.Log; public class TerminalManager extends Service implements BridgeDisconnectedListener, OnSharedPreferenceChangeListener { public final static String TAG = "CB.TerminalManager"; - public List bridges = new LinkedList(); + private List bridges = new LinkedList(); public Map> mHostBridgeMap = new HashMap>(); public Map> mNicknameBridgeMap = @@ -471,6 +471,10 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen } } + public List getBridges() { + return bridges; + } + public class TerminalBinder extends Binder { public TerminalManager getService() { return TerminalManager.this; @@ -518,6 +522,11 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen if (bridges.size() == 0) { stopWithDelay(); + } else { + // tell each bridge to forget about their previous prompt handler + for (TerminalBridge bridge : bridges) { + bridge.promptHelper.setHandler(null); + } } return true; -- cgit v1.2.3