Skip to content

Commit

Permalink
Add Config.loadSkins() and fix crashes for Android versions < Oreo
Browse files Browse the repository at this point in the history
  • Loading branch information
kairusds committed Jan 8, 2022
1 parent 954bc7f commit dafbcd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/ru/nsu/ccfit/zuev/osu/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ public static void loadConfig(final Context context) {
soundVolume = prefs.getInt("soundvolume", 100) / 100f;
bgmVolume = prefs.getInt("bgmvolume", 100) / 100f;
cursorSize = prefs.getInt("cursorSize", 50) / 100f;
}catch(RuntimeException e) { // migrate to integers to prevent crash
}catch(RuntimeException e) { // use valid integer since this makes the game crash on android m
prefs.edit()
.putInt("offset", Integer.parseInt(prefs.getString("offset", "0")))
.putInt("bgbrightness", Integer.parseInt(prefs.getString("bgbrightness", "25")))
.putInt("soundvolume", Integer.parseInt(prefs.getString("soundvolume", "100")))
.putInt("bgmvolume", Integer.parseInt(prefs.getString("bgmvolume", "100")))
.putInt("cursorSize", Integer.parseInt(prefs.getString("cursorSize", "50")))
.putInt("offset", 0)
.putInt("bgbrightness", 25)
.putInt("soundvolume", 100)
.putInt("bgmvolume", 100)
.putInt("cursorSize", 50)
.commit();
Config.loadConfig(context);
}
Expand Down Expand Up @@ -196,14 +196,6 @@ public static void loadConfig(final Context context) {
comboColors[i - 1] = RGBColor.hex2Rgb(ColorPickerPreference.convertToRGB(prefs.getInt("combo" + i, 0xff000000)));
}

// skins
File[] folders = FileUtils.listFiles(new File(skinTopPath), file -> file.isDirectory() && !file.getName().startsWith("."));
skins = new HashMap<String, String>();
for(File folder : folders) {
skins.put(folder.getName(), folder.getPath());
Debug.i("skins: " + folder.getName() + " - " + folder.getPath());
}

// beatmaps
DELETE_OSZ = prefs.getBoolean("deleteosz", true);
SCAN_DOWNLOAD = prefs.getBoolean("scandownload", false);
Expand Down Expand Up @@ -767,6 +759,15 @@ public static String getDefaultCorePath() {
return defaultCorePath;
}

public static void loadSkins() {
File[] folders = FileUtils.listFiles(new File(skinTopPath), file -> file.isDirectory() && !file.getName().startsWith("."));
skins = new HashMap<String, String>();
for(File folder : folders) {
skins.put(folder.getName(), folder.getPath());
Debug.i("skins: " + folder.getName() + " - " + folder.getPath());
}
}

public static Map<String, String> getSkins(){
return skins;
}
Expand Down
1 change: 1 addition & 0 deletions src/ru/nsu/ccfit/zuev/osu/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public void run() {
GlobalManager.getInstance().init();
analytics.logEvent(FirebaseAnalytics.Event.APP_OPEN, null);
GlobalManager.getInstance().setLoadingProgress(50);
Config.loadSkins();
checkNewSkins();
checkNewBeatmaps();
if (!LibraryManager.getInstance().loadLibraryCache(MainActivity.this, true)) {
Expand Down

0 comments on commit dafbcd0

Please sign in to comment.