From fcc8e12401a0fc264350cef921f6c50129f689f1 Mon Sep 17 00:00:00 2001 From: juha Date: Thu, 1 Aug 2019 02:28:57 +0300 Subject: [PATCH 1/2] fix multiple sessions starting at view changes --- .../src/main/java/com/termux/app/TermuxActivity.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/termux-app/terminal-term/src/main/java/com/termux/app/TermuxActivity.java b/termux-app/terminal-term/src/main/java/com/termux/app/TermuxActivity.java index 448d6adda..4caa78bf9 100644 --- a/termux-app/terminal-term/src/main/java/com/termux/app/TermuxActivity.java +++ b/termux-app/terminal-term/src/main/java/com/termux/app/TermuxActivity.java @@ -517,7 +517,17 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) { if (mTermService == null) return; // Activity might have been destroyed. try { - addNewSession(false, null); + if (mListViewAdapter.getCount() == 0) { + Log.i( EmulatorDebug.LOG_TAG,"Adding new session: onServiceConnected: "+componentName.flattenToShortString()+", "+service.toString()); + + addNewSession(false, null); + } else { + // activate the first session + TerminalSession activatedSession = mListViewAdapter.getItem(0); + switchToSession(activatedSession); + getDrawer().closeDrawers(); + + } } catch (WindowManager.BadTokenException e) { // Activity finished - ignore. } From 75771b06c4dae9289e6b6e92bc67cd9bee0107be Mon Sep 17 00:00:00 2001 From: juha Date: Thu, 1 Aug 2019 00:51:45 +0300 Subject: [PATCH 2/2] session migrates to external display when available + immersive fullscreen when hardware keyboard is present + if hardware input & external display available, display kept on This is to support a more "desktop mode" linux when the device is docked (having both hardware keyboard and an external display). --- .../src/main/AndroidManifest.xml | 1 + .../java/com/termux/app/TermuxActivity.java | 89 ++++++++++++++++++- .../java/com/termux/app/TermuxService.java | 22 ++++- .../java/com/termux/app/TermuxViewClient.java | 5 +- 4 files changed, 112 insertions(+), 5 deletions(-) diff --git a/termux-app/terminal-term/src/main/AndroidManifest.xml b/termux-app/terminal-term/src/main/AndroidManifest.xml index c0845f8d9..daa9b6fff 100644 --- a/termux-app/terminal-term/src/main/AndroidManifest.xml +++ b/termux-app/terminal-term/src/main/AndroidManifest.xml @@ -13,6 +13,7 @@ + = android.os.Build.VERSION_CODES.O) { + ActivityOptions options = ActivityOptions.makeBasic(); + DisplayManager dm = (DisplayManager)getSystemService(DISPLAY_SERVICE); + Display ds[] = dm.getDisplays(); + ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); + for(Display d: ds) { + if ((d.getState() > Display.STATE_OFF) && ((d.getFlags() & Display.FLAG_PRESENTATION) != 0) && ((d.getFlags() & Display.FLAG_PRIVATE) == 0)) { + options.setLaunchBounds(null); + options.setLaunchDisplayId(d.getDisplayId()); + break; + } + } + startActivity(si, options.toBundle()); + } else + startActivity(si); } } else if (action != null) { Log.e(EmulatorDebug.LOG_TAG, "Unknown TermuxService action: '" + action + "'"); diff --git a/termux-app/terminal-term/src/main/java/com/termux/app/TermuxViewClient.java b/termux-app/terminal-term/src/main/java/com/termux/app/TermuxViewClient.java index c3dd9fd20..551cc3dde 100644 --- a/termux-app/terminal-term/src/main/java/com/termux/app/TermuxViewClient.java +++ b/termux-app/terminal-term/src/main/java/com/termux/app/TermuxViewClient.java @@ -1,12 +1,14 @@ package com.termux.app; import android.content.Context; +import android.content.res.Configuration; import android.media.AudioManager; import androidx.drawerlayout.widget.DrawerLayout; import android.view.Gravity; import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; +import android.view.View; import android.view.inputmethod.InputMethodManager; import com.termux.terminal.KeyHandler; @@ -39,8 +41,7 @@ public float onScale(float scale) { @Override public void onSingleTapUp(MotionEvent e) { - InputMethodManager mgr = (InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE); - mgr.showSoftInput(mActivity.mTerminalView, InputMethodManager.SHOW_IMPLICIT); + mActivity.makeFullscreen(); } @Override