diff --git a/app/src/main/java/com/termux/x11/MainActivity.java b/app/src/main/java/com/termux/x11/MainActivity.java index 883052b81..036e21d3e 100644 --- a/app/src/main/java/com/termux/x11/MainActivity.java +++ b/app/src/main/java/com/termux/x11/MainActivity.java @@ -96,8 +96,7 @@ public class MainActivity extends AppCompatActivity implements View.OnApplyWindo public static Prefs prefs = null; - private static boolean oldFullscreen = false; - private static boolean oldHideCutout = false; + private static boolean oldFullscreen = false, oldHideCutout = false, oldXrMode = false; private final SharedPreferences.OnSharedPreferenceChangeListener preferencesChangedListener = (__, key) -> onPreferencesChanged(key); private final BroadcastReceiver receiver = new BroadcastReceiver() { @@ -162,6 +161,7 @@ protected void onCreate(Bundle savedInstanceState) { oldFullscreen = prefs.fullscreen.get(); oldHideCutout = prefs.hideCutout.get(); + oldXrMode = prefs.xrMode.get(); prefs.get().registerOnSharedPreferenceChangeListener(preferencesChangedListener); @@ -514,6 +514,12 @@ void tryConnect() { void onPreferencesChanged(String key) { prefs.recheckStoringSecondaryDisplayPreferences(); + if (oldXrMode != prefs.xrMode.get() && XrActivity.isSupported() && + prefs.xrMode.get() != this instanceof XrActivity) { + startActivity(Intent.makeRestartActivityTask(getComponentName())); + finish(); + } + if ("additionalKbdVisible".equals(key)) return;