Skip to content

Commit

Permalink
Merge pull request #9568 from JosJuice/android-delay-save-tab
Browse files Browse the repository at this point in the history
Android: Don't save settings immediately after switching platform tab
  • Loading branch information
leoetlino committed Mar 7, 2021
2 parents a5555c6 + 13cc327 commit ac687bc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
Expand Up @@ -279,4 +279,9 @@ public boolean getBooleanGlobal()
{
return NativeConfig.getBoolean(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}

public void setBooleanGlobal(int layer, boolean newValue)
{
NativeConfig.setBoolean(layer, mFile, mSection, mKey, newValue);
}
}
Expand Up @@ -78,4 +78,9 @@ public float getFloatGlobal()
{
return NativeConfig.getFloat(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}

public void setFloatGlobal(int layer, float newValue)
{
NativeConfig.setFloat(layer, mFile, mSection, mKey, newValue);
}
}
Expand Up @@ -147,4 +147,9 @@ public int getIntGlobal()
{
return NativeConfig.getInt(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}

public void setIntGlobal(int layer, int newValue)
{
NativeConfig.setInt(layer, mFile, mSection, mKey, newValue);
}
}
Expand Up @@ -109,4 +109,9 @@ public String getStringGlobal()
{
return NativeConfig.getString(NativeConfig.LAYER_ACTIVE, mFile, mSection, mKey, mDefaultValue);
}

public void setStringGlobal(int layer, String newValue)
{
NativeConfig.setString(layer, mFile, mSection, mKey, newValue);
}
}
Expand Up @@ -23,6 +23,7 @@
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.adapters.PlatformPagerAdapter;
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.NativeConfig;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
Expand Down Expand Up @@ -113,10 +114,17 @@ protected void onStart()
protected void onStop()
{
super.onStop();

if (isChangingConfigurations())
{
MainPresenter.skipRescanningLibrary();
}
else if (DirectoryInitialization.areDolphinDirectoriesReady())
{
// If the currently selected platform tab changed, save it to disk
NativeConfig.save(NativeConfig.LAYER_BASE);
}

StartupHandler.setSessionTime(this);
}

Expand Down Expand Up @@ -321,16 +329,7 @@ private void setPlatformTabsAndStartGameFileCacheService()
public void onTabSelected(@NonNull TabLayout.Tab tab)
{
super.onTabSelected(tab);

try (Settings settings = new Settings())
{
settings.loadSettings();

IntSetting.MAIN_LAST_PLATFORM_TAB.setInt(settings, tab.getPosition());

// Context is set to null to avoid toasts
settings.saveSettings(null, null);
}
IntSetting.MAIN_LAST_PLATFORM_TAB.setIntGlobal(NativeConfig.LAYER_BASE, tab.getPosition());
}
});

Expand Down

0 comments on commit ac687bc

Please sign in to comment.