changeset 419:9045b1af94e5

revert notifyUser() changes
author Carl Byington <carl@five-ten-sg.com>
date Wed, 29 Oct 2014 15:25:32 -0700
parents 39533be5cbe9
children e5f7c2584296
files src/com/five_ten_sg/connectbot/ConsoleActivity.java src/com/five_ten_sg/connectbot/TerminalView.java
diffstat 2 files changed, 24 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/ConsoleActivity.java	Wed Oct 29 13:28:59 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/ConsoleActivity.java	Wed Oct 29 15:25:32 2014 -0700
@@ -764,10 +764,12 @@
                     showEmulatedKeys();
                 }
 
-                // pass any touch events back to detector
+                // pass any touch events back to BOTH detectors
                 TerminalView terminalView = (TerminalView) findCurrentView(R.id.console_flip);
-                if ((terminalView != null) && terminalView.mScaleDetector.onTouchEvent(event)) return true;
-                return gestDetect.onTouchEvent(event);
+                boolean rc = false;
+                if ((terminalView != null) && terminalView.mScaleDetector.onTouchEvent(event)) rc = true;
+                if (gestDetect.onTouchEvent(event)) rc = true;
+                return rc;
             }
         });
     }
--- a/src/com/five_ten_sg/connectbot/TerminalView.java	Wed Oct 29 13:28:59 2014 -0700
+++ b/src/com/five_ten_sg/connectbot/TerminalView.java	Wed Oct 29 15:25:32 2014 -0700
@@ -72,6 +72,7 @@
     private Matrix scaleMatrix;
     private static final Matrix.ScaleToFit scaleType = Matrix.ScaleToFit.FILL;
 
+    private Toast notification = null;
     private String lastNotification = null;
     private volatile boolean notifications = true;
 
@@ -241,12 +242,24 @@
     }
 
     public void notifyUser(String message) {
-        if (!notifications) return;
-        // Don't keep telling the user the same thing.
-        if (lastNotification != null && lastNotification.equals(message)) return;
-        Toast notification = Toast.makeText(context, message, Toast.LENGTH_SHORT);
-        notification.show();
-        lastNotification = message;
+        try {
+            // ignore if don't want notifications
+            if (!notifications) return;
+            // Don't keep telling the user the same thing.
+            if (lastNotification != null && lastNotification.equals(message)) return;
+            // create or use old toast
+            if (notification == null) {
+                notification = Toast.makeText(context, message, Toast.LENGTH_SHORT);
+            }
+            else {
+                notification.setText(message);
+            }
+            notification.show();
+            lastNotification = message;
+        }
+        catch (Exception e) {
+            Log.e(TAG, "Problem while trying to notify user", e);
+        }
     }
 
     /**