diff --git a/app/src/main/java/ani/dantotsu/settings/saving/PrefWrapper.kt b/app/src/main/java/ani/dantotsu/settings/saving/PrefWrapper.kt index 83a502fa0c..dba1d771dd 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/PrefWrapper.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/PrefWrapper.kt @@ -3,6 +3,7 @@ package ani.dantotsu.settings.saving import android.annotation.SuppressLint import android.content.Context import android.content.SharedPreferences +import ani.dantotsu.settings.saving.internal.Compat import ani.dantotsu.settings.saving.internal.Location import ani.dantotsu.snackString @@ -26,6 +27,7 @@ object PrefWrapper { irrelevantPreferences = context.getSharedPreferences(Location.Irrelevant.location, Context.MODE_PRIVATE) animeDownloadsPreferences = context.getSharedPreferences(Location.AnimeDownloads.location, Context.MODE_PRIVATE) protectedPreferences = context.getSharedPreferences(Location.Protected.location, Context.MODE_PRIVATE) + Compat.importOldPrefs(context) } @Suppress("UNCHECKED_CAST") diff --git a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt index 3e686b5c9c..d0ca5e85db 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -44,6 +44,7 @@ enum class PrefName(val data: Pref) { SomethingSpecial(Pref(Location.Irrelevant, Boolean::class)), AllowOpeningLinks(Pref(Location.Irrelevant, Boolean::class)), SearchStyle(Pref(Location.Irrelevant, Int::class)), + HasUpdatedPrefs(Pref(Location.Irrelevant, Boolean::class)), //Protected DiscordToken(Pref(Location.Protected, String::class)), diff --git a/app/src/main/java/ani/dantotsu/settings/saving/internal/Compat.kt b/app/src/main/java/ani/dantotsu/settings/saving/internal/Compat.kt new file mode 100644 index 0000000000..8afdee7862 --- /dev/null +++ b/app/src/main/java/ani/dantotsu/settings/saving/internal/Compat.kt @@ -0,0 +1,18 @@ +package ani.dantotsu.settings.saving.internal + +import android.content.Context +import ani.dantotsu.settings.saving.PrefName +import ani.dantotsu.settings.saving.PrefWrapper + +class Compat { + companion object { + fun importOldPrefs(context: Context) { + if (PrefWrapper.getVal(PrefName.HasUpdatedPrefs, false)) return + val oldPrefs = context.getSharedPreferences("downloads_pref", Context.MODE_PRIVATE) + val jsonString = oldPrefs.getString("downloads_key", null) + PrefWrapper.setVal(PrefName.DownloadsKeys, jsonString) + oldPrefs.edit().clear().apply() + PrefWrapper.setVal(PrefName.HasUpdatedPrefs, true) + } + } +} \ No newline at end of file