aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJeremy Klein <jlklein@google.com>2015-08-07 14:48:32 -0700
committerJeremy Klein <jlklein@google.com>2015-08-07 16:55:27 -0700
commitdd3a93c0522bb967f22ac24893389bec091dc163 (patch)
tree9fa71c5d7d4c9105275b07da2aa9677ae35f26a1 /app
parentfbe5b14ebf73f906b7df857f546e527bd42bef76 (diff)
downloadconnectbot-dd3a93c0522bb967f22ac24893389bec091dc163.tar.gz
connectbot-dd3a93c0522bb967f22ac24893389bec091dc163.tar.bz2
connectbot-dd3a93c0522bb967f22ac24893389bec091dc163.zip
Fix an issue with prompt handling
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/org/connectbot/ConsoleActivity.java28
1 files changed, 22 insertions, 6 deletions
diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java
index 5e41b76..853d077 100644
--- a/app/src/main/java/org/connectbot/ConsoleActivity.java
+++ b/app/src/main/java/org/connectbot/ConsoleActivity.java
@@ -169,7 +169,7 @@ public class ConsoleActivity extends Activity {
adapter.notifyDataSetChanged();
requestedIndex = bound.getBridges().indexOf(requestedBridge);
- pager.setCurrentItem(requestedIndex == -1 ? 0 : requestedIndex);
+ setDisplayedTerminal(requestedIndex == -1 ? 0 : requestedIndex);
}
public void onServiceDisconnected(ComponentName className) {
@@ -207,6 +207,7 @@ public class ConsoleActivity extends Activity {
synchronized (pager) {
adapter.notifyDataSetChanged();
updateEmptyVisible();
+ updatePromptVisible();
// If we just closed the last bridge, go back to the previous activity.
if (pager.getChildCount() == 0) {
@@ -947,7 +948,7 @@ public class ConsoleActivity extends Activity {
}
}
- pager.setCurrentItem(requestedIndex);
+ setDisplayedTerminal(requestedIndex);
}
}
@@ -998,17 +999,17 @@ public class ConsoleActivity extends Activity {
*/
protected void updatePromptVisible() {
// check if our currently-visible terminalbridge is requesting any prompt services
- View view = adapter.getCurrentTerminalView();
+ TerminalView view = adapter.getCurrentTerminalView();
// Hide all the prompts in case a prompt request was canceled
hideAllPrompts();
- if (!(view instanceof TerminalView)) {
+ if (view == null) {
// we dont have an active view, so hide any prompts
return;
}
- PromptHelper prompt = ((TerminalView) view).bridge.promptHelper;
+ PromptHelper prompt = view.bridge.promptHelper;
if (String.class.equals(prompt.promptRequested)) {
stringPromptGroup.setVisibility(View.VISIBLE);
@@ -1084,6 +1085,17 @@ public class ConsoleActivity extends Activity {
}
}
+ /**
+ * Displays the child in the ViewPager at the requestedIndex and updates the prompts.
+ *
+ * @param requestedIndex the index of the terminal view to display
+ */
+ private void setDisplayedTerminal(int requestedIndex) {
+ pager.setCurrentItem(requestedIndex);
+ updatePromptVisible();
+ updateEmptyVisible();
+ }
+
private void pasteIntoTerminal() {
// force insert of clipboard text into current console
TerminalView terminalView = (TerminalView) adapter.getCurrentTerminalView();
@@ -1125,6 +1137,10 @@ public class ConsoleActivity extends Activity {
terminal.setId(R.id.console_flip);
view.addView(terminal, 0);
+ // Tag the view with its position so that it can be retrieved later.
+ // Unfortunately, position here != child position in the ViewPager.
+ view.setTag(position);
+
container.addView(view);
overlay.startAnimation(fade_out_delayed);
return view;
@@ -1169,7 +1185,7 @@ public class ConsoleActivity extends Activity {
}
public TerminalView getCurrentTerminalView() {
- View currentView = pager.getChildAt(pager.getCurrentItem());
+ View currentView = pager.findViewWithTag(pager.getCurrentItem());
if (currentView == null) return null;
return (TerminalView) currentView.findViewById(R.id.console_flip);
}