diff options
author | Kenny Root <kenny@the-b.org> | 2009-01-13 10:19:41 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2009-01-13 10:19:41 +0000 |
commit | e7fb922562baed08711ef93342cfe72a00c6a32b (patch) | |
tree | 7a5c221762febfa9c7f827761d6a5083371e57a9 /src | |
parent | 5a5683a115b16a5ba0997baa54981f17253741e9 (diff) | |
download | connectbot-e7fb922562baed08711ef93342cfe72a00c6a32b.tar.gz connectbot-e7fb922562baed08711ef93342cfe72a00c6a32b.tar.bz2 connectbot-e7fb922562baed08711ef93342cfe72a00c6a32b.zip |
Workaround for ViewAnimator bug
* Was causing the last still-connected hosts to not show the correct options menu after a preceeding connection was closed.
Diffstat (limited to 'src')
-rw-r--r-- | src/org/connectbot/ConsoleActivity.java | 18 | ||||
-rw-r--r-- | src/org/connectbot/util/ViewFlipperFixed.java | 64 |
2 files changed, 74 insertions, 8 deletions
diff --git a/src/org/connectbot/ConsoleActivity.java b/src/org/connectbot/ConsoleActivity.java index 5bc7c4c..211ec45 100644 --- a/src/org/connectbot/ConsoleActivity.java +++ b/src/org/connectbot/ConsoleActivity.java @@ -23,6 +23,7 @@ import org.connectbot.bean.PortForwardBean; import org.connectbot.service.PromptHelper; import org.connectbot.service.TerminalBridge; import org.connectbot.service.TerminalManager; +import org.connectbot.util.ViewFlipperFixed; import android.app.Activity; import android.app.AlertDialog; @@ -62,7 +63,6 @@ import android.widget.EditText; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; -import android.widget.ViewFlipper; import de.mud.terminal.vt320; public class ConsoleActivity extends Activity { @@ -70,7 +70,7 @@ public class ConsoleActivity extends Activity { protected static final int REQUEST_EDIT = 1; - protected ViewFlipper flip = null; + protected ViewFlipperFixed flip = null; protected TerminalManager bound = null; protected LayoutInflater inflater = null; @@ -310,7 +310,7 @@ public class ConsoleActivity extends Activity { inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); - flip = (ViewFlipper)findViewById(R.id.console_flip); + flip = (ViewFlipperFixed)findViewById(R.id.console_flip); empty = (TextView)findViewById(android.R.id.empty); stringPromptGroup = (RelativeLayout) findViewById(R.id.console_password_group); @@ -687,9 +687,10 @@ public class ConsoleActivity extends Activity { protected void shiftLeft() { View overlay; - + boolean shouldAnimate = flip.getChildCount() > 1; + // Only show animation if there is something else to go to. - if (flip.getChildCount() > 1) { + if (shouldAnimate) { // keep current overlay from popping up again overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) @@ -702,7 +703,7 @@ public class ConsoleActivity extends Activity { ConsoleActivity.this.updateDefault(); - if (flip.getChildCount() > 1) { + if (shouldAnimate) { // show overlay on new slide and start fade overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) @@ -714,9 +715,10 @@ public class ConsoleActivity extends Activity { protected void shiftRight() { View overlay; + boolean shouldAnimate = flip.getChildCount() > 1; // Only show animation if there is something else to go to. - if (flip.getChildCount() > 1) { + if (shouldAnimate) { // keep current overlay from popping up again overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) @@ -729,7 +731,7 @@ public class ConsoleActivity extends Activity { ConsoleActivity.this.updateDefault(); - if (flip.getChildCount() > 1) { + if (shouldAnimate) { // show overlay on new slide and start fade overlay = findCurrentView(R.id.terminal_overlay); if (overlay != null) diff --git a/src/org/connectbot/util/ViewFlipperFixed.java b/src/org/connectbot/util/ViewFlipperFixed.java new file mode 100644 index 0000000..157864c --- /dev/null +++ b/src/org/connectbot/util/ViewFlipperFixed.java @@ -0,0 +1,64 @@ +/* + ConnectBot: simple, powerful, open-source SSH client for Android + Copyright (C) 2007-2008 Kenny Root, Jeffrey Sharkey + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +package org.connectbot.util; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.ViewFlipper; + +/** + * @author Kenny Root + * + * This class simply overrides ViewFlipper until a fix can be released + * for tracking removal of views from a ViewAnimator. + * + * REMOVE THIS CLASS WHEN ViewAnimator IN ANDROID IS FIXED TO TRACK + * REMOVAL OF CHILD VIEWS! See also res/layout/act_console.xml + */ +public class ViewFlipperFixed extends ViewFlipper { + + /** + * @param context + */ + public ViewFlipperFixed(Context context) { + super(context); + // TODO Auto-generated constructor stub + } + + /** + * @param context + * @param attrs + */ + public ViewFlipperFixed(Context context, AttributeSet attrs) { + super(context, attrs); + // TODO Auto-generated constructor stub + } + + /** + * @param index child index + */ + @Override + public void removeViewAt(int index) { + // TODO Auto-generated method stub + super.removeViewAt(index); + + // Since we can't override removeViewInternal, we might as well do this. + if (getDisplayedChild() >= getChildCount()) + setDisplayedChild(index - 1); + } +} |