Skip to content

Commit

Permalink
Make changing xrMode preference restart activity to apply changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
twaik committed Jul 15, 2024
1 parent 1cc9125 commit e220d29
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/src/main/java/com/termux/x11/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit e220d29

Please sign in to comment.