mirror of
https://github.com/stonega/tsacdop
synced 2025-02-10 16:40:44 +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 rewindSeconds = await rewindSecondsStorage.getInt(defaultValue: 10);
|
||||||
var playerHeight =
|
var playerHeight =
|
||||||
await KeyValueStorage(playerHeightKey).getInt(defaultValue: 0);
|
await KeyValueStorage(playerHeightKey).getInt(defaultValue: 0);
|
||||||
|
var localeList = await localeStorage.getStringList();
|
||||||
|
var backupLocale =
|
||||||
|
localeList.isEmpty ? '' : '${'${localeList.first}-'}${localeList[1]}';
|
||||||
|
|
||||||
return SettingsBackup(
|
return SettingsBackup(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -467,7 +470,8 @@ class SettingState extends ChangeNotifier {
|
|||||||
tapToOpenPopupMenu: tapToOpenPopupMenu,
|
tapToOpenPopupMenu: tapToOpenPopupMenu,
|
||||||
fastForwardSeconds: fastForwardSeconds,
|
fastForwardSeconds: fastForwardSeconds,
|
||||||
rewindSeconds: rewindSeconds,
|
rewindSeconds: rewindSeconds,
|
||||||
playerHeight: playerHeight);
|
playerHeight: playerHeight,
|
||||||
|
locale: backupLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> restore(SettingsBackup backup) async {
|
Future<void> restore(SettingsBackup backup) async {
|
||||||
@ -498,6 +502,21 @@ class SettingState extends ChangeNotifier {
|
|||||||
await KeyValueStorage(playerHeightKey).saveInt(backup.playerHeight);
|
await KeyValueStorage(playerHeightKey).saveInt(backup.playerHeight);
|
||||||
await KeyValueStorage(tapToOpenPopupMenuKey)
|
await KeyValueStorage(tapToOpenPopupMenuKey)
|
||||||
.saveBool(backup.tapToOpenPopupMenu);
|
.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 initData();
|
||||||
await _getAutoUpdate();
|
await _getAutoUpdate();
|
||||||
await _getDownloadUsingData();
|
await _getDownloadUsingData();
|
||||||
|
@ -23,6 +23,7 @@ class SettingsBackup {
|
|||||||
final int fastForwardSeconds;
|
final int fastForwardSeconds;
|
||||||
final int rewindSeconds;
|
final int rewindSeconds;
|
||||||
final int playerHeight;
|
final int playerHeight;
|
||||||
|
final String locale;
|
||||||
SettingsBackup(
|
SettingsBackup(
|
||||||
{this.theme,
|
{this.theme,
|
||||||
this.accentColor,
|
this.accentColor,
|
||||||
@ -47,7 +48,8 @@ class SettingsBackup {
|
|||||||
this.tapToOpenPopupMenu,
|
this.tapToOpenPopupMenu,
|
||||||
this.fastForwardSeconds,
|
this.fastForwardSeconds,
|
||||||
this.rewindSeconds,
|
this.rewindSeconds,
|
||||||
this.playerHeight});
|
this.playerHeight,
|
||||||
|
this.locale});
|
||||||
|
|
||||||
Map<String, Object> toJson() {
|
Map<String, Object> toJson() {
|
||||||
return {
|
return {
|
||||||
@ -73,7 +75,8 @@ class SettingsBackup {
|
|||||||
'tapToOpenPopupMenu': tapToOpenPopupMenu,
|
'tapToOpenPopupMenu': tapToOpenPopupMenu,
|
||||||
'fastForwardSeconds': fastForwardSeconds,
|
'fastForwardSeconds': fastForwardSeconds,
|
||||||
'rewindSeconds': rewindSeconds,
|
'rewindSeconds': rewindSeconds,
|
||||||
'playerHeight': playerHeight
|
'playerHeight': playerHeight,
|
||||||
|
'locale': locale
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +105,7 @@ class SettingsBackup {
|
|||||||
tapToOpenPopupMenu: json['tapToOpenPopupMenu'] as bool,
|
tapToOpenPopupMenu: json['tapToOpenPopupMenu'] as bool,
|
||||||
fastForwardSeconds: json['fastForwardSeconds'] as int,
|
fastForwardSeconds: json['fastForwardSeconds'] as int,
|
||||||
rewindSeconds: json['rewindSeconds'] 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