mirror of
https://github.com/stonega/tsacdop
synced 2025-02-09 08:08:46 +01:00
Language settings backup.
This commit is contained in:
parent
7ab21d59bc
commit
ed3caa1e01
@ -442,6 +442,9 @@ class SettingState extends ChangeNotifier {
|
||||
var rewindSeconds = await rewindSecondsStorage.getInt(defaultValue: 10);
|
||||
var playerHeight =
|
||||
await KeyValueStorage(playerHeightKey).getInt(defaultValue: 0);
|
||||
var localeList = await localeStorage.getStringList();
|
||||
var backupLocale =
|
||||
localeList.isEmpty ? '' : '${'${localeList.first}-'}${localeList[1]}';
|
||||
|
||||
return SettingsBackup(
|
||||
theme: theme,
|
||||
@ -467,7 +470,8 @@ class SettingState extends ChangeNotifier {
|
||||
tapToOpenPopupMenu: tapToOpenPopupMenu,
|
||||
fastForwardSeconds: fastForwardSeconds,
|
||||
rewindSeconds: rewindSeconds,
|
||||
playerHeight: playerHeight);
|
||||
playerHeight: playerHeight,
|
||||
locale: backupLocale);
|
||||
}
|
||||
|
||||
Future<void> restore(SettingsBackup backup) async {
|
||||
@ -498,6 +502,21 @@ class SettingState extends ChangeNotifier {
|
||||
await KeyValueStorage(playerHeightKey).saveInt(backup.playerHeight);
|
||||
await KeyValueStorage(tapToOpenPopupMenuKey)
|
||||
.saveBool(backup.tapToOpenPopupMenu);
|
||||
if (backup.locale == '') {
|
||||
await localeStorage.saveStringList([]);
|
||||
await S.load(Locale(Intl.systemLocale));
|
||||
} else {
|
||||
var localeList = backup.locale.split('-');
|
||||
var backupLocale;
|
||||
if (localeList[1] == 'null') {
|
||||
backupLocale = Locale(localeList.first);
|
||||
} else {
|
||||
backupLocale = Locale(localeList.first, localeList[1]);
|
||||
}
|
||||
await localeStorage.saveStringList(
|
||||
[backupLocale.languageCode, backupLocale.countryCode]);
|
||||
await S.load(backupLocale);
|
||||
}
|
||||
await initData();
|
||||
await _getAutoUpdate();
|
||||
await _getDownloadUsingData();
|
||||
|
@ -23,6 +23,7 @@ class SettingsBackup {
|
||||
final int fastForwardSeconds;
|
||||
final int rewindSeconds;
|
||||
final int playerHeight;
|
||||
final String locale;
|
||||
SettingsBackup(
|
||||
{this.theme,
|
||||
this.accentColor,
|
||||
@ -47,7 +48,8 @@ class SettingsBackup {
|
||||
this.tapToOpenPopupMenu,
|
||||
this.fastForwardSeconds,
|
||||
this.rewindSeconds,
|
||||
this.playerHeight});
|
||||
this.playerHeight,
|
||||
this.locale});
|
||||
|
||||
Map<String, Object> toJson() {
|
||||
return {
|
||||
@ -73,7 +75,8 @@ class SettingsBackup {
|
||||
'tapToOpenPopupMenu': tapToOpenPopupMenu,
|
||||
'fastForwardSeconds': fastForwardSeconds,
|
||||
'rewindSeconds': rewindSeconds,
|
||||
'playerHeight': playerHeight
|
||||
'playerHeight': playerHeight,
|
||||
'locale': locale
|
||||
};
|
||||
}
|
||||
|
||||
@ -102,6 +105,7 @@ class SettingsBackup {
|
||||
tapToOpenPopupMenu: json['tapToOpenPopupMenu'] as bool,
|
||||
fastForwardSeconds: json['fastForwardSeconds'] as int,
|
||||
rewindSeconds: json['rewindSeconds'] as int,
|
||||
playerHeight: json['playerHeight'] as int);
|
||||
playerHeight: json['playerHeight'] as int,
|
||||
locale: json['locale'] as String);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user