From e7fb922562baed08711ef93342cfe72a00c6a32b Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 13 Jan 2009 10:19:41 +0000 Subject: Workaround for ViewAnimator bug * Was causing the last still-connected hosts to not show the correct options menu after a preceeding connection was closed. --- res/layout/act_console.xml | 3 +- src/org/connectbot/ConsoleActivity.java | 18 ++++---- src/org/connectbot/util/ViewFlipperFixed.java | 64 +++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 src/org/connectbot/util/ViewFlipperFixed.java diff --git a/res/layout/act_console.xml b/res/layout/act_console.xml index 34d7459..29b60d8 100644 --- a/res/layout/act_console.xml +++ b/res/layout/act_console.xml @@ -31,7 +31,8 @@ android:gravity="center" /> - + 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 . +*/ +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); + } +} -- cgit v1.2.3