Revert "Whatever the fuck this is. Hopefully it compiles on the first try"

This reverts commit bdac1d5bb4.
This commit is contained in:
LucasGGamerM
2022-12-22 09:01:30 -03:00
parent bdac1d5bb4
commit d9f6ef69fe
12 changed files with 1006 additions and 461 deletions

View File

@@ -4,8 +4,7 @@ import static org.joinmastodon.android.api.MastodonAPIController.gson;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import android.os.Build;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
@@ -33,6 +32,7 @@ public class GlobalUserPreferences{
private final static Type recentLanguagesType = new TypeToken<Map<String, List<String>>>() {}.getType();
public static Map<String, List<String>> recentLanguages;
public static Map<String, String> defaultLanguages;
private static SharedPreferences getPrefs(){
return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE);
@@ -59,13 +59,12 @@ public class GlobalUserPreferences{
voteButtonForSingleChoice=prefs.getBoolean("voteButtonForSingleChoice", true);
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>());
try {
color=ColorPreference.valueOf(prefs.getString("color", ColorPreference.PINK.name()));
} catch (IllegalArgumentException|ClassCastException ignored) {
// invalid color name or color was previously saved as integer
color=ColorPreference.PINK;
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
color=ColorPreference.values()[prefs.getInt("color", 0)];
}else{
color=ColorPreference.values()[prefs.getInt("color", 1)];
}
}
public static void save(){
@@ -82,15 +81,15 @@ public class GlobalUserPreferences{
.putBoolean("disableMarquee", disableMarquee)
.putBoolean("disableSwipe", disableSwipe)
.putInt("theme", theme.ordinal())
.putString("color", color.name())
.putString("recentLanguages", gson.toJson(recentLanguages))
.putInt("color", color.ordinal())
.apply();
}
public enum ColorPreference{
MATERIAL3,
PINK,
PURPLE,
PINK,
GREEN,
BLUE,
ORANGE,
@@ -104,4 +103,3 @@ public class GlobalUserPreferences{
DARK
}
}