feat(compose/emojis): add category of recent emojis

This commit is contained in:
FineFindus
2023-01-02 16:44:14 +01:00
parent 32c94c8948
commit 0b6128bcdd
3 changed files with 53 additions and 4 deletions

View File

@@ -9,6 +9,8 @@ import android.os.Build;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import org.joinmastodon.android.model.Emoji;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
@@ -39,6 +41,9 @@ public class GlobalUserPreferences{
private final static Type recentLanguagesType = new TypeToken<Map<String, List<String>>>() {}.getType();
public static Map<String, List<String>> recentLanguages;
private final static Type recentEmojisType = new TypeToken<Map<String, Integer>>() {}.getType();
public static Map<String, Integer> recentEmojis;
private static SharedPreferences getPrefs(){
return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE);
}
@@ -68,6 +73,7 @@ public class GlobalUserPreferences{
enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", true);
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>());
recentEmojis=fromJson(prefs.getString("recentEmojis", "{}"), recentEmojisType, new HashMap<>());
publishButtonText=prefs.getString("publishButtonText", "");
try {
@@ -104,6 +110,7 @@ public class GlobalUserPreferences{
.putInt("theme", theme.ordinal())
.putString("color", color.name())
.putString("recentLanguages", gson.toJson(recentLanguages))
.putString("recentEmojis", gson.toJson(recentEmojis))
.apply();
}