mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-11-08 19:46:10 +01:00
sessions: let failsafe session will be accessible from separate launcher icon
This commit is contained in:
parent
593e70334e
commit
fd5509a843
4 changed files with 51 additions and 5 deletions
|
|
@ -44,14 +44,25 @@
|
|||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.termux.app.TermuxFailsafeActivity"
|
||||
android:label="@string/app_failsafe_mode" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.termux.app.TermuxHelpActivity"
|
||||
android:exported="false"
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
<resources>
|
||||
<string name="application_name">Termux</string>
|
||||
<string name="shared_user_label">Termux user</string>
|
||||
<string name="app_failsafe_mode">Termux (failsafe)</string>
|
||||
<string name="termux_exec_permission_label">Termux:Execute</string>
|
||||
<string name="termux_exec_permission_desc">Allows application to execute arbitrary shell commands within Termux.</string>
|
||||
<string name="new_session">New session</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue