[Android] don't load forge.profile.properties when the user is using the obb directory

- until google permits unrestricted access outside the app-specific directory on certain apps via flag, the option to use obb as entrypoint is required since accessing outside the scoped storage is really not recommended (https://issuetracker.google.com/issues?q=scoped%20storage%20slow).
This commit is contained in:
Anthony Calosa
2021-04-27 21:04:51 +08:00
parent 045d7bb5ae
commit 77e56e8da9
4 changed files with 25 additions and 22 deletions

View File

@@ -88,7 +88,7 @@ public class Forge implements ApplicationListener {
if (GuiBase.getInterface() == null) {
clipboard = clipboard0;
deviceAdapter = deviceAdapter0;
GuiBase.setUsingAppDirectory(assetDir0.contains("forge.app"));
GuiBase.setUsingAppDirectory(assetDir0.contains("forge.app")); //obb directory on android uses the package name as entrypoint
GuiBase.setInterface(new GuiMobile(assetDir0));
GuiBase.enablePropertyConfig(value);
isPortraitMode = androidOrientation;

View File

@@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import forge.gui.GuiBase;
import org.apache.commons.lang3.StringUtils;
import com.badlogic.gdx.utils.Align;
@@ -133,26 +134,28 @@ public class FilesPage extends TabPage<SettingsScreen> {
ForgeProfileProperties.setDecksDir(newDir);
}
};
lstItems.addItem(new StorageOption(localizer.getMessage("lblDataLocation"), ForgeProfileProperties.getUserDir()) {
@Override
protected void onDirectoryChanged(String newDir) {
ForgeProfileProperties.setUserDir(newDir);
if (!GuiBase.isUsingAppDirectory()) {
lstItems.addItem(new StorageOption(localizer.getMessage("lblDataLocation"), ForgeProfileProperties.getUserDir()) {
@Override
protected void onDirectoryChanged(String newDir) {
ForgeProfileProperties.setUserDir(newDir);
//ensure decks option is updated if needed
decksOption.updateDir(ForgeProfileProperties.getDecksDir());
}
}, 1);
lstItems.addItem(new StorageOption(localizer.getMessage("lblImageCacheLocation"), ForgeProfileProperties.getCacheDir()) {
@Override
protected void onDirectoryChanged(String newDir) {
ForgeProfileProperties.setCacheDir(newDir);
//ensure decks option is updated if needed
decksOption.updateDir(ForgeProfileProperties.getDecksDir());
}
}, 1);
lstItems.addItem(new StorageOption(localizer.getMessage("lblImageCacheLocation"), ForgeProfileProperties.getCacheDir()) {
@Override
protected void onDirectoryChanged(String newDir) {
ForgeProfileProperties.setCacheDir(newDir);
//ensure card pics option is updated if needed
cardPicsOption.updateDir(ForgeProfileProperties.getCardPicsDir());
}
}, 1);
lstItems.addItem(cardPicsOption, 1);
lstItems.addItem(decksOption, 1);
//ensure card pics option is updated if needed
cardPicsOption.updateDir(ForgeProfileProperties.getCardPicsDir());
}
}, 1);
lstItems.addItem(cardPicsOption, 1);
lstItems.addItem(decksOption, 1);
}
}
@Override