mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-09 12:04:03 +08:00
sessions: failsafe session is now accessible via separate launcher icon
Also enables session autoclosing so no more "annoying" messages about "process completed - press enter". There autoclosing will be performed on exit codes '0' and '130'. On Android TV devices old behaviour will be used - auto close enabled for all sessions when amount of running sessions >1.
This commit is contained in:
committed by
Fredrik Fornwall
parent
bda80547ad
commit
fe41cd486f
@@ -216,8 +216,8 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
|
||||
final ViewPager viewPager = findViewById(R.id.viewpager);
|
||||
if (mSettings.mShowExtraKeys) viewPager.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
|
||||
|
||||
ViewGroup.LayoutParams layoutParams = viewPager.getLayoutParams();
|
||||
layoutParams.height = layoutParams.height * mSettings.mExtraKeys.length;
|
||||
viewPager.setLayoutParams(layoutParams);
|
||||
@@ -367,8 +367,18 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
showToast(toToastTitle(finishedSession) + " - exited", true);
|
||||
}
|
||||
|
||||
if (mTermService.getSessions().size() > 1) {
|
||||
removeFinishedSession(finishedSession);
|
||||
if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
|
||||
// On Android TV devices we need to use older behaviour because we may
|
||||
// not be able to have multiple launcher icons.
|
||||
if (mTermService.getSessions().size() > 1) {
|
||||
removeFinishedSession(finishedSession);
|
||||
}
|
||||
} else {
|
||||
// Once we have a separate launcher icon for the failsafe session, it
|
||||
// should be safe to auto-close session on exit code '0' or '130'.
|
||||
if (finishedSession.getExitStatus() == 0 || finishedSession.getExitStatus() == 130) {
|
||||
removeFinishedSession(finishedSession);
|
||||
}
|
||||
}
|
||||
|
||||
mListViewAdapter.notifyDataSetChanged();
|
||||
@@ -465,8 +475,13 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
TermuxInstaller.setupIfNeeded(TermuxActivity.this, () -> {
|
||||
if (mTermService == null) return; // Activity might have been destroyed.
|
||||
try {
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
boolean launchFailsafe = false;
|
||||
if (bundle != null) {
|
||||
launchFailsafe = bundle.getBoolean(TermuxFailsafeActivity.TERMUX_FAILSAFE_SESSION_ACTION, false);
|
||||
}
|
||||
clearTemporaryDirectory();
|
||||
addNewSession(false, null);
|
||||
addNewSession(launchFailsafe, null);
|
||||
} catch (WindowManager.BadTokenException e) {
|
||||
// Activity finished - ignore.
|
||||
}
|
||||
|
19
app/src/main/java/com/termux/app/TermuxFailsafeActivity.java
Normal file
19
app/src/main/java/com/termux/app/TermuxFailsafeActivity.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.termux.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
public final class TermuxFailsafeActivity extends Activity {
|
||||
|
||||
public static final String TERMUX_FAILSAFE_SESSION_ACTION = "com.termux.app.failsafe_session";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Intent intent = new Intent(TermuxFailsafeActivity.this, TermuxActivity.class);
|
||||
intent.putExtra(TERMUX_FAILSAFE_SESSION_ACTION, true);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user