mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-05 18:25:31 +08:00
Changed: Do not recreate TermuxActivity enabled in 6631599f
when TermuxService starts a session
Activity will only be recreated when `termux-reload-settings` is run or `night-mode` config does not equal current system mode when TermuxActivity is initially started. Running `termux-reload-settings` can cause some problems if some variable whose state should be maintained or reset is not being done so correctly, like termux session shortcuts weren't before 4fd48a5a
. It requires further testing and any bugs should be reported.
This commit is contained in:
@@ -180,7 +180,6 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
Logger.logDebug(LOG_TAG, "onCreate");
|
||||
isOnResumeAfterOnCreate = true;
|
||||
|
||||
@@ -846,9 +845,10 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
||||
|
||||
|
||||
|
||||
public static void updateTermuxActivityStyling(Context context) {
|
||||
public static void updateTermuxActivityStyling(Context context, boolean recreateActivity) {
|
||||
// Make sure that terminal styling is always applied.
|
||||
Intent stylingIntent = new Intent(TERMUX_ACTIVITY.ACTION_RELOAD_STYLE);
|
||||
stylingIntent.putExtra(TERMUX_ACTIVITY.EXTRA_RECREATE_ACTIVITY, recreateActivity);
|
||||
context.sendBroadcast(stylingIntent);
|
||||
}
|
||||
|
||||
@@ -889,7 +889,7 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
||||
return;
|
||||
case TERMUX_ACTIVITY.ACTION_RELOAD_STYLE:
|
||||
Logger.logDebug(LOG_TAG, "Received intent to reload styling");
|
||||
reloadActivityStyling();
|
||||
reloadActivityStyling(intent.getBooleanExtra(TERMUX_ACTIVITY.EXTRA_RECREATE_ACTIVITY, true));
|
||||
return;
|
||||
default:
|
||||
}
|
||||
@@ -897,7 +897,7 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadActivityStyling() {
|
||||
private void reloadActivityStyling(boolean recreateActivity) {
|
||||
if (mProperties != null) {
|
||||
mProperties.loadTermuxPropertiesFromDisk();
|
||||
|
||||
@@ -925,7 +925,10 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
||||
// To change the activity and drawer theme, activity needs to be recreated.
|
||||
// It will destroy the activity, including all stored variables and views, and onCreate()
|
||||
// will be called again. Extra keys input text, terminal sessions and transcripts will be preserved.
|
||||
TermuxActivity.this.recreate();
|
||||
if (recreateActivity) {
|
||||
Logger.logDebug(LOG_TAG, "Recreating activity");
|
||||
TermuxActivity.this.recreate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -540,7 +540,9 @@ public final class TermuxService extends Service implements AppShell.AppShellCli
|
||||
mTermuxTerminalSessionClient.termuxSessionListNotifyUpdated();
|
||||
|
||||
updateNotification();
|
||||
TermuxActivity.updateTermuxActivityStyling(this);
|
||||
|
||||
// No need to recreate the activity since it likely just started and theme should already have applied
|
||||
TermuxActivity.updateTermuxActivityStyling(this, false);
|
||||
|
||||
return newTermuxSession;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import java.util.Formatter;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Version: v0.34.0
|
||||
* Version: v0.35.0
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Changelog
|
||||
@@ -214,6 +214,9 @@ import java.util.List;
|
||||
*
|
||||
* - 0.34.0 (2021-10-26)
|
||||
* - Move `RESULT_SENDER` to `com.termux.shared.shell.command.ShellCommandConstants`.
|
||||
*
|
||||
* - 0.35.0 (2022-01-28)
|
||||
* - Add `TERMUX_APP.TERMUX_ACTIVITY.EXTRA_RECREATE_ACTIVITY`.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -864,6 +867,9 @@ public final class TermuxConstants {
|
||||
@Deprecated
|
||||
public static final String EXTRA_RELOAD_STYLE = TermuxConstants.TERMUX_PACKAGE_NAME + ".app.reload_style"; // Default: "com.termux.app.reload_style"
|
||||
|
||||
/** Intent {@code boolean} extra for whether to recreate activity for the TERMUX_ACTIVITY.ACTION_RELOAD_STYLE intent. */
|
||||
public static final String EXTRA_RECREATE_ACTIVITY = TERMUX_APP.TERMUX_ACTIVITY_NAME + ".EXTRA_RECREATE_ACTIVITY"; // Default: "com.termux.app.TermuxActivity.EXTRA_RECREATE_ACTIVITY"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user