diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/org/connectbot/ConsoleActivity.java | 78 | ||||
-rw-r--r-- | src/org/connectbot/TerminalView.java | 4 | ||||
-rw-r--r-- | src/org/connectbot/service/TerminalBridge.java | 5 | ||||
-rw-r--r-- | src/org/connectbot/service/TerminalManager.java | 17 |
4 files changed, 86 insertions, 18 deletions
diff --git a/src/org/connectbot/ConsoleActivity.java b/src/org/connectbot/ConsoleActivity.java index 059632a..6157b8f 100644 --- a/src/org/connectbot/ConsoleActivity.java +++ b/src/org/connectbot/ConsoleActivity.java @@ -105,6 +105,8 @@ public class ConsoleActivity extends Activity { protected TerminalBridge copySource = null; private int lastTouchRow, lastTouchCol; + private boolean forcedOrientation = false; + private ServiceConnection connection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { bound = ((TerminalManager.TerminalBinder) service).getService(); @@ -308,22 +310,6 @@ public class ConsoleActivity extends Activity { WindowManager.LayoutParams.FLAG_FULLSCREEN); } - String rotateDefault; - if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) - rotateDefault = PreferenceConstants.ROTATION_PORTRAIT; - else - rotateDefault = PreferenceConstants.ROTATION_LANDSCAPE; - - String rotate = prefs.getString(PreferenceConstants.ROTATION, rotateDefault); - if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate)) - rotate = rotateDefault; - - // request a forced orientation if requested by user - if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); - else if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - // TODO find proper way to disable volume key beep if it exists. setVolumeControlStream(AudioManager.STREAM_MUSIC); @@ -557,6 +543,30 @@ public class ConsoleActivity extends Activity { } + /** + * + */ + private void configureOrientation() { + String rotateDefault; + if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) + rotateDefault = PreferenceConstants.ROTATION_PORTRAIT; + else + rotateDefault = PreferenceConstants.ROTATION_LANDSCAPE; + + String rotate = prefs.getString(PreferenceConstants.ROTATION, rotateDefault); + if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate)) + rotate = rotateDefault; + + // request a forced orientation if requested by user + if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + forcedOrientation = true; + } else if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + forcedOrientation = true; + } + } + @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -723,6 +733,26 @@ public class ConsoleActivity extends Activity { } @Override + public void onPause() { + super.onPause(); + Log.d(TAG, "onPause called"); + + if (bound != null) + bound.setResizeAllowed(false); + } + + @Override + public void onResume() { + super.onResume(); + Log.d(TAG, "onResume called"); + + configureOrientation(); + + if (bound != null) + bound.setResizeAllowed(true); + } + + @Override public void onStop() { super.onStop(); @@ -848,4 +878,20 @@ public class ConsoleActivity extends Activity { view.requestFocus(); } } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + Log.d(TAG, String.format("onConfigurationChanged; requestedOrientation=%d, newConfig.orientation=%d", getRequestedOrientation(), newConfig.orientation)); + if (forcedOrientation && bound != null) { + if ((newConfig.orientation != Configuration.ORIENTATION_LANDSCAPE && + getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) || + (newConfig.orientation != Configuration.ORIENTATION_PORTRAIT && + getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)) + bound.setResizeAllowed(false); + else + bound.setResizeAllowed(true); + } + } } diff --git a/src/org/connectbot/TerminalView.java b/src/org/connectbot/TerminalView.java index 0722634..5bff54e 100644 --- a/src/org/connectbot/TerminalView.java +++ b/src/org/connectbot/TerminalView.java @@ -121,8 +121,8 @@ public class TerminalView extends View implements FontSizeChangedListener { @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); - if (notifications) - bridge.parentChanged(this); + + bridge.parentChanged(this); scaleCursors(); } diff --git a/src/org/connectbot/service/TerminalBridge.java b/src/org/connectbot/service/TerminalBridge.java index ec0a35c..1bdcc38 100644 --- a/src/org/connectbot/service/TerminalBridge.java +++ b/src/org/connectbot/service/TerminalBridge.java @@ -1175,6 +1175,11 @@ public class TerminalBridge implements VDUDisplay, OnKeyListener, InteractiveCal * terminal size information and request a PTY resize. */ public final synchronized void parentChanged(TerminalView parent) { + if (manager != null && !manager.isResizeAllowed()) { + Log.d(TAG, "Resize is not allowed now"); + return; + } + this.parent = parent; int width = parent.getWidth(); int height = parent.getHeight(); diff --git a/src/org/connectbot/service/TerminalManager.java b/src/org/connectbot/service/TerminalManager.java index 27812d8..03f46ae 100644 --- a/src/org/connectbot/service/TerminalManager.java +++ b/src/org/connectbot/service/TerminalManager.java @@ -107,6 +107,9 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen private NotificationManager notificationManager; private boolean wantBellVibration; + + private boolean resizeAllowed = true; + private static final int NOTIFICATION_ID = 1; @Override @@ -370,6 +373,8 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen public boolean onUnbind(Intent intent) { Log.i(TAG, "Someone unbound from TerminalManager"); + setResizeAllowed(true); + if (bridges.size() == 0) stopWithDelay(); @@ -499,4 +504,16 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen PreferenceConstants.BUMPY_ARROWS, true); } } + + /** + * Allow {@link TerminalBridge} to resize when the parent has changed. + * @param resizeAllowed + */ + public void setResizeAllowed(boolean resizeAllowed) { + this.resizeAllowed = resizeAllowed; + } + + public boolean isResizeAllowed() { + return resizeAllowed; + } } |