diff options
author | Kenny Root <kenny@the-b.org> | 2009-01-26 05:53:17 +0000 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2009-01-26 05:53:17 +0000 |
commit | 1fb036157d28396b66f483541a3d85e36b0a6cd7 (patch) | |
tree | 8fca68aef4d6c47e47e028ca1fc88e04a4613f09 /src | |
parent | e63ffdd0bc2ff5c5c8d648109cdacc1c601563d1 (diff) | |
download | connectbot-1fb036157d28396b66f483541a3d85e36b0a6cd7.tar.gz connectbot-1fb036157d28396b66f483541a3d85e36b0a6cd7.tar.bz2 connectbot-1fb036157d28396b66f483541a3d85e36b0a6cd7.zip |
Bitmap and notifications bug fix
* Try to free bitmaps immediately to avoid running afoul of the memory limits
* Don't display the screen size of orientation changes if we're exiting the activity
Diffstat (limited to 'src')
-rw-r--r-- | src/org/connectbot/ConsoleActivity.java | 24 | ||||
-rw-r--r-- | src/org/connectbot/TerminalView.java | 14 | ||||
-rw-r--r-- | src/org/connectbot/service/TerminalBridge.java | 14 |
3 files changed, 44 insertions, 8 deletions
diff --git a/src/org/connectbot/ConsoleActivity.java b/src/org/connectbot/ConsoleActivity.java index ab06d83..3bd20d8 100644 --- a/src/org/connectbot/ConsoleActivity.java +++ b/src/org/connectbot/ConsoleActivity.java @@ -698,14 +698,36 @@ public class ConsoleActivity extends Activity { } @Override + public void onPause() { + super.onPause(); + + /* Make sure our current TerminalView doesn't send a + * notification to the user about the screen size. + */ + View view = findCurrentView(R.id.console_flip); + if (view instanceof TerminalView) + ((TerminalView) view).setNotifications(false); + } + + @Override + public void onResume() { + super.onResume(); + + // Enable notifications for the current TerminalView. + View view = findCurrentView(R.id.console_flip); + if (view instanceof TerminalView) + ((TerminalView) view).setNotifications(true); + } + + @Override public void onStop() { super.onStop(); + unbindService(connection); // allow the screen to dim and fall asleep if(wakelock != null && wakelock.isHeld()) wakelock.release(); - } protected void shiftLeft() { diff --git a/src/org/connectbot/TerminalView.java b/src/org/connectbot/TerminalView.java index 9c199e3..cb7b465 100644 --- a/src/org/connectbot/TerminalView.java +++ b/src/org/connectbot/TerminalView.java @@ -57,6 +57,7 @@ public class TerminalView extends View implements FontSizeChangedListener { private Toast notification = null; private String lastNotification = null; + private boolean notifications = true; public TerminalView(Context context, TerminalBridge bridge) { super(context); @@ -118,7 +119,7 @@ public class TerminalView extends View implements FontSizeChangedListener { protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); bridge.parentChanged(this); - + scaleCursors(); } @@ -196,6 +197,9 @@ public class TerminalView extends View implements FontSizeChangedListener { } public void notifyUser(String message) { + if (!notifications) + return; + if (notification != null) { // Don't keep telling the user the same thing. if (lastNotification != null && lastNotification.equals(message)) @@ -219,4 +223,12 @@ public class TerminalView extends View implements FontSizeChangedListener { public void forceSize(int width, int height) { bridge.resizeComputed(width, height, getWidth(), getHeight()); } + + /** + * Sets the ability for the TerminalView to display Toast notifications to the user. + * @param value whether to enable notifications or not + */ + public void setNotifications(boolean value) { + notifications = value; + } } diff --git a/src/org/connectbot/service/TerminalBridge.java b/src/org/connectbot/service/TerminalBridge.java index 893a3a1..c014342 100644 --- a/src/org/connectbot/service/TerminalBridge.java +++ b/src/org/connectbot/service/TerminalBridge.java @@ -1124,7 +1124,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal * 1st press: next key to have meta state<br /> * 2nd press: meta state is locked on<br /> * 3rd press: disable meta state - * + * * @param code */ private void metaPress(int code) { @@ -1214,7 +1214,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal /** * Remove an {@link FontSizeChangedListener} from the list of listeners for * this bridge. - * + * * @param listener */ public void removeFontSizeChangedListener(FontSizeChangedListener listener) { @@ -1256,7 +1256,9 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal if(bitmap != null) newBitmap = (bitmap.getWidth() != width || bitmap.getHeight() != height); - if(newBitmap) { + if (newBitmap) { + if (bitmap != null) + bitmap.recycle(); bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); canvas.setBitmap(bitmap); } @@ -1306,7 +1308,7 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal fullRedraw = true; redraw(); - this.parent.notifyUser(String.format("%d x %d", termWidth, termHeight)); + parent.notifyUser(String.format("%d x %d", termWidth, termHeight)); Log.i(TAG, String.format("parentChanged() now width=%d, height=%d", termWidth, termHeight)); } @@ -1317,10 +1319,10 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal */ public synchronized void parentDestroyed() { parent = null; - if(bitmap != null) + canvas.setBitmap(null); + if (bitmap != null) bitmap.recycle(); bitmap = null; - canvas.setBitmap(null); } public void setVDUBuffer(VDUBuffer buffer) { |