Add settings backup and restore.
Change outline button shape.
This commit is contained in:
parent
f47758b104
commit
8cca497d63
|
@ -142,10 +142,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"homeToprightMenuAbout" : MessageLookupByLibrary.simpleMessage("About"),
|
||||
"homeToprightMenuImportOMPL" : MessageLookupByLibrary.simpleMessage("Import OMPL"),
|
||||
"homeToprightMenuRefreshAll" : MessageLookupByLibrary.simpleMessage("Refresh all"),
|
||||
"homeToprightMenuSettings" : MessageLookupByLibrary.simpleMessage("Settings"),
|
||||
"hostedOn" : m7,
|
||||
"hoursAgo" : m8,
|
||||
"hoursCount" : m9,
|
||||
"import" : MessageLookupByLibrary.simpleMessage("Import"),
|
||||
"introFourthPage" : MessageLookupByLibrary.simpleMessage("You can long press on episode card for quick actions."),
|
||||
"introSecondPage" : MessageLookupByLibrary.simpleMessage("Subscribe podcast via search or import OMPL file."),
|
||||
"introThirdPage" : MessageLookupByLibrary.simpleMessage("You can create new group for podcasts."),
|
||||
|
@ -208,6 +208,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"searchPodcast" : MessageLookupByLibrary.simpleMessage("Search podcast"),
|
||||
"secondsAgo" : m22,
|
||||
"settingStorage" : MessageLookupByLibrary.simpleMessage("Storage"),
|
||||
"settings" : MessageLookupByLibrary.simpleMessage("Settings"),
|
||||
"settingsAccentColor" : MessageLookupByLibrary.simpleMessage("Accent color"),
|
||||
"settingsAccentColorDes" : MessageLookupByLibrary.simpleMessage("Include the ovelay color"),
|
||||
"settingsAppIntro" : MessageLookupByLibrary.simpleMessage("App Intro"),
|
||||
|
@ -228,8 +229,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"settingsDiscovery" : MessageLookupByLibrary.simpleMessage("Discovery Features Again"),
|
||||
"settingsEnableSyncing" : MessageLookupByLibrary.simpleMessage("Enable Syncing"),
|
||||
"settingsEnableSyncingDes" : MessageLookupByLibrary.simpleMessage("Refresh all podcasts in the background to get leatest episodes"),
|
||||
"settingsExport" : MessageLookupByLibrary.simpleMessage("Export"),
|
||||
"settingsExportDes" : MessageLookupByLibrary.simpleMessage("Export OMPL file of all podcasts"),
|
||||
"settingsExportDes" : MessageLookupByLibrary.simpleMessage("Export and import app settings"),
|
||||
"settingsFeedback" : MessageLookupByLibrary.simpleMessage("Feedback"),
|
||||
"settingsFeedbackDes" : MessageLookupByLibrary.simpleMessage("Bugs and features request"),
|
||||
"settingsHistory" : MessageLookupByLibrary.simpleMessage("History"),
|
||||
|
@ -273,6 +273,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"skipSecondsAtStart" : MessageLookupByLibrary.simpleMessage("Skip seconds at start"),
|
||||
"sleepTimer" : MessageLookupByLibrary.simpleMessage("Sleep timer"),
|
||||
"subscribe" : MessageLookupByLibrary.simpleMessage("Subscribe"),
|
||||
"subscribeExportDes" : MessageLookupByLibrary.simpleMessage("Export OMPL file of all podcasts"),
|
||||
"systemDefault" : MessageLookupByLibrary.simpleMessage("System default"),
|
||||
"timeLastPlayed" : m23,
|
||||
"timeLeft" : m24,
|
||||
|
|
|
@ -142,10 +142,10 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"homeToprightMenuAbout" : MessageLookupByLibrary.simpleMessage("关于"),
|
||||
"homeToprightMenuImportOMPL" : MessageLookupByLibrary.simpleMessage("导入OMPL"),
|
||||
"homeToprightMenuRefreshAll" : MessageLookupByLibrary.simpleMessage("全部刷新"),
|
||||
"homeToprightMenuSettings" : MessageLookupByLibrary.simpleMessage("设置"),
|
||||
"hostedOn" : m7,
|
||||
"hoursAgo" : m8,
|
||||
"hoursCount" : m9,
|
||||
"import" : MessageLookupByLibrary.simpleMessage("导入"),
|
||||
"introFourthPage" : MessageLookupByLibrary.simpleMessage("您可以长按节目打开快捷菜单。"),
|
||||
"introSecondPage" : MessageLookupByLibrary.simpleMessage("您可以通过搜索订阅播客,也可以直接导入OMPL文件。"),
|
||||
"introThirdPage" : MessageLookupByLibrary.simpleMessage("您可以创建分组,上下滑动切换分组。"),
|
||||
|
@ -208,6 +208,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"searchPodcast" : MessageLookupByLibrary.simpleMessage("搜索播客"),
|
||||
"secondsAgo" : m22,
|
||||
"settingStorage" : MessageLookupByLibrary.simpleMessage("储存空间"),
|
||||
"settings" : MessageLookupByLibrary.simpleMessage("设置"),
|
||||
"settingsAccentColor" : MessageLookupByLibrary.simpleMessage("次要颜色"),
|
||||
"settingsAccentColorDes" : MessageLookupByLibrary.simpleMessage("包括溢出颜色"),
|
||||
"settingsAppIntro" : MessageLookupByLibrary.simpleMessage("引导页"),
|
||||
|
@ -228,8 +229,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"settingsDiscovery" : MessageLookupByLibrary.simpleMessage("再次功能介绍"),
|
||||
"settingsEnableSyncing" : MessageLookupByLibrary.simpleMessage("开启自动更新"),
|
||||
"settingsEnableSyncingDes" : MessageLookupByLibrary.simpleMessage("在后台更新所有订阅播客"),
|
||||
"settingsExport" : MessageLookupByLibrary.simpleMessage("导出"),
|
||||
"settingsExportDes" : MessageLookupByLibrary.simpleMessage("导出 OMPL 文件"),
|
||||
"settingsExportDes" : MessageLookupByLibrary.simpleMessage("导出及恢复所有设置项"),
|
||||
"settingsFeedback" : MessageLookupByLibrary.simpleMessage("反馈"),
|
||||
"settingsFeedbackDes" : MessageLookupByLibrary.simpleMessage("意见与建议"),
|
||||
"settingsHistory" : MessageLookupByLibrary.simpleMessage("历史记录"),
|
||||
|
@ -273,6 +273,7 @@ class MessageLookup extends MessageLookupByLibrary {
|
|||
"skipSecondsAtStart" : MessageLookupByLibrary.simpleMessage("开头跳过秒数"),
|
||||
"sleepTimer" : MessageLookupByLibrary.simpleMessage("睡眠模式"),
|
||||
"subscribe" : MessageLookupByLibrary.simpleMessage("订阅"),
|
||||
"subscribeExportDes" : MessageLookupByLibrary.simpleMessage("导出 OMPL 文件"),
|
||||
"systemDefault" : MessageLookupByLibrary.simpleMessage("系统默认"),
|
||||
"timeLastPlayed" : m23,
|
||||
"timeLeft" : m24,
|
||||
|
|
|
@ -701,16 +701,6 @@ class S {
|
|||
);
|
||||
}
|
||||
|
||||
/// `Settings`
|
||||
String get homeToprightMenuSettings {
|
||||
return Intl.message(
|
||||
'Settings',
|
||||
name: 'homeToprightMenuSettings',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Hosted on {host}`
|
||||
String hostedOn(Object host) {
|
||||
return Intl.message(
|
||||
|
@ -747,6 +737,16 @@ class S {
|
|||
);
|
||||
}
|
||||
|
||||
/// `Import`
|
||||
String get import {
|
||||
return Intl.message(
|
||||
'Import',
|
||||
name: 'import',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `You can long press on episode card for quick actions.`
|
||||
String get introFourthPage {
|
||||
return Intl.message(
|
||||
|
@ -1369,6 +1369,16 @@ class S {
|
|||
);
|
||||
}
|
||||
|
||||
/// `Settings`
|
||||
String get settings {
|
||||
return Intl.message(
|
||||
'Settings',
|
||||
name: 'settings',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Accent color`
|
||||
String get settingsAccentColor {
|
||||
return Intl.message(
|
||||
|
@ -1569,20 +1579,10 @@ class S {
|
|||
);
|
||||
}
|
||||
|
||||
/// `Export`
|
||||
String get settingsExport {
|
||||
return Intl.message(
|
||||
'Export',
|
||||
name: 'settingsExport',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `Export OMPL file of all podcasts`
|
||||
/// `Export and import app settings`
|
||||
String get settingsExportDes {
|
||||
return Intl.message(
|
||||
'Export OMPL file of all podcasts',
|
||||
'Export and import app settings',
|
||||
name: 'settingsExportDes',
|
||||
desc: '',
|
||||
args: [],
|
||||
|
@ -2029,6 +2029,16 @@ class S {
|
|||
);
|
||||
}
|
||||
|
||||
/// `Export OMPL file of all podcasts`
|
||||
String get subscribeExportDes {
|
||||
return Intl.message(
|
||||
'Export OMPL file of all podcasts',
|
||||
name: 'subscribeExportDes',
|
||||
desc: '',
|
||||
args: [],
|
||||
);
|
||||
}
|
||||
|
||||
/// `System default`
|
||||
String get systemDefault {
|
||||
return Intl.message(
|
||||
|
|
|
@ -422,6 +422,9 @@ class _SearchResultState extends State<SearchResult>
|
|||
child: !_issubscribe
|
||||
? OutlineButton(
|
||||
highlightedBorderColor: context.accentColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100.0),
|
||||
side: BorderSide(color: context.accentColor)),
|
||||
splashColor: context.accentColor.withOpacity(0.8),
|
||||
child: Text(s.subscribe,
|
||||
style: TextStyle(
|
||||
|
@ -436,6 +439,9 @@ class _SearchResultState extends State<SearchResult>
|
|||
})
|
||||
: OutlineButton(
|
||||
color: context.accentColor.withOpacity(0.8),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100.0),
|
||||
side: BorderSide(color: Colors.grey[500])),
|
||||
highlightedBorderColor: Colors.grey[500],
|
||||
disabledTextColor: Colors.grey[500],
|
||||
child: Text(s.subscribe),
|
||||
|
|
|
@ -102,9 +102,7 @@ class _PopupMenuState extends State<PopupMenu> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var refreshWorker = Provider.of<RefreshWorker>(context, listen: false);
|
||||
|
||||
final s = context.s;
|
||||
|
||||
return PopupMenuButton<int>(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
|
@ -170,7 +168,7 @@ class _PopupMenuState extends State<PopupMenu> {
|
|||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 5.0),
|
||||
),
|
||||
Text(s.homeToprightMenuSettings),
|
||||
Text(s.settings),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -144,8 +144,6 @@
|
|||
"@homeToprightMenuImportOMPL": {},
|
||||
"homeToprightMenuRefreshAll": "Refresh all",
|
||||
"@homeToprightMenuRefreshAll": {},
|
||||
"homeToprightMenuSettings": "Settings",
|
||||
"@homeToprightMenuSettings": {},
|
||||
"hostedOn": "Hosted on {host}",
|
||||
"@hostedOn": {
|
||||
"placeholders": {
|
||||
|
@ -156,6 +154,8 @@
|
|||
"@hoursAgo": {},
|
||||
"hoursCount": "{count, plural, zero{0 hour} one{{count} hour} other{{count} hours}}",
|
||||
"@hoursCount": {},
|
||||
"import": "Import",
|
||||
"@import": {},
|
||||
"introFourthPage": "You can long press on episode card for quick actions.",
|
||||
"@introFourthPage": {},
|
||||
"introSecondPage": "Subscribe podcast via search or import OMPL file.",
|
||||
|
@ -317,6 +317,8 @@
|
|||
"@searchPodcast": {},
|
||||
"secondsAgo": "{count, plural, zero{Just now} one{{count} second ago} other{{count} seconds ago}}",
|
||||
"@secondsAgo": {},
|
||||
"settings": "Settings",
|
||||
"@settings": {},
|
||||
"settingsAccentColor": "Accent color",
|
||||
"@settingsAccentColor": {},
|
||||
"settingsAccentColorDes": "Include the ovelay color",
|
||||
|
@ -357,9 +359,7 @@
|
|||
"@settingsEnableSyncing": {},
|
||||
"settingsEnableSyncingDes": "Refresh all podcasts in the background to get leatest episodes",
|
||||
"@settingsEnableSyncingDes": {},
|
||||
"settingsExport": "Export",
|
||||
"@settingsExport": {},
|
||||
"settingsExportDes": "Export OMPL file of all podcasts",
|
||||
"settingsExportDes": "Export and import app settings",
|
||||
"@settingsExportDes": {},
|
||||
"settingsFeedback": "Feedback",
|
||||
"@settingsFeedback": {},
|
||||
|
@ -449,6 +449,8 @@
|
|||
"@sleepTimer": {},
|
||||
"subscribe": "Subscribe",
|
||||
"@subscribe": {},
|
||||
"subscribeExportDes": "Export OMPL file of all podcasts",
|
||||
"@subscribeExportDes": {},
|
||||
"systemDefault": "System default",
|
||||
"@systemDefault": {},
|
||||
"timeLastPlayed": "Last time {time}",
|
||||
|
|
|
@ -144,8 +144,6 @@
|
|||
"@homeToprightMenuImportOMPL": {},
|
||||
"homeToprightMenuRefreshAll": "全部刷新",
|
||||
"@homeToprightMenuRefreshAll": {},
|
||||
"homeToprightMenuSettings": "设置",
|
||||
"@homeToprightMenuSettings": {},
|
||||
"hostedOn": "平台 {host}",
|
||||
"@hostedOn": {
|
||||
"placeholders": {
|
||||
|
@ -156,6 +154,8 @@
|
|||
"@hoursAgo": {},
|
||||
"hoursCount": "{count, plural, zero{0小时} other{{count} 小时}}",
|
||||
"@hoursCount": {},
|
||||
"import": "导入",
|
||||
"@import": {},
|
||||
"introFourthPage": "您可以长按节目打开快捷菜单。",
|
||||
"@introFourthPage": {},
|
||||
"introSecondPage": "您可以通过搜索订阅播客,也可以直接导入OMPL文件。",
|
||||
|
@ -317,6 +317,8 @@
|
|||
"@searchPodcast": {},
|
||||
"secondsAgo": "{count, plural, zero{刚刚} other{{count}秒前}}",
|
||||
"@secondsAgo": {},
|
||||
"settings": "设置",
|
||||
"@settings": {},
|
||||
"settingsAccentColor": "次要颜色",
|
||||
"@settingsAccentColor": {},
|
||||
"settingsAccentColorDes": "包括溢出颜色",
|
||||
|
@ -357,9 +359,7 @@
|
|||
"@settingsEnableSyncing": {},
|
||||
"settingsEnableSyncingDes": "在后台更新所有订阅播客",
|
||||
"@settingsEnableSyncingDes": {},
|
||||
"settingsExport": "导出",
|
||||
"@settingsExport": {},
|
||||
"settingsExportDes": "导出 OMPL 文件",
|
||||
"settingsExportDes": "导出及恢复所有设置项",
|
||||
"@settingsExportDes": {},
|
||||
"settingsFeedback": "反馈",
|
||||
"@settingsFeedback": {},
|
||||
|
@ -449,6 +449,8 @@
|
|||
"@sleepTimer": {},
|
||||
"subscribe": "订阅",
|
||||
"@subscribe": {},
|
||||
"subscribeExportDes": "导出 OMPL 文件",
|
||||
"@subscribeExportDes": {},
|
||||
"systemDefault": "系统默认",
|
||||
"@systemDefault": {},
|
||||
"timeLastPlayed": "上次播放{time}",
|
||||
|
|
|
@ -326,7 +326,7 @@ class DBHelper {
|
|||
"""SELECT title, enclosure_url, seconds, seek_value, add_date FROM PlayHistory
|
||||
WHERE enclosure_url = ? ORDER BY add_date DESC LIMIT 1""",
|
||||
[episodeBrief.enclosureUrl]);
|
||||
return list.isEmpty
|
||||
return list.isNotEmpty
|
||||
? PlayHistory(list.first['title'], list.first['enclosure_url'],
|
||||
list.first['seconds'], list.first['seek_value'],
|
||||
playdate:
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:line_icons/line_icons.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:flutter_file_dialog/flutter_file_dialog.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tsacdop/type/settings_backup.dart';
|
||||
import 'package:wc_flutter_share/wc_flutter_share.dart';
|
||||
|
||||
import '../state/podcast_group.dart';
|
||||
import '../state/setting_state.dart';
|
||||
import '../util/context_extension.dart';
|
||||
import '../service/ompl_build.dart';
|
||||
|
||||
class DataBackup extends StatelessWidget {
|
||||
class DataBackup extends StatefulWidget {
|
||||
@override
|
||||
_DataBackupState createState() => _DataBackupState();
|
||||
}
|
||||
|
||||
class _DataBackupState extends State<DataBackup> {
|
||||
Future<File> _exportOmpl(BuildContext context) async {
|
||||
var groups = context.read<GroupList>().groups;
|
||||
var ompl = PodcastsBackup(groups).omplBuilder();
|
||||
|
@ -29,12 +39,12 @@ class DataBackup extends StatelessWidget {
|
|||
return file;
|
||||
}
|
||||
|
||||
Future<void> _saveOmpl(File file) async {
|
||||
Future<void> _saveFile(File file) async {
|
||||
final params = SaveFileDialogParams(sourceFilePath: file.path);
|
||||
await FlutterFileDialog.saveFile(params: params);
|
||||
}
|
||||
|
||||
Future<void> _shareOmpl(File file) async {
|
||||
Future<void> _shareFile(File file) async {
|
||||
final Uint8List bytes = await file.readAsBytes();
|
||||
await WcFlutterShare.share(
|
||||
sharePopupTitle: 'share Clip',
|
||||
|
@ -43,6 +53,56 @@ class DataBackup extends StatelessWidget {
|
|||
bytesOfFile: bytes.buffer.asUint8List());
|
||||
}
|
||||
|
||||
Future<File> _exportSetting(BuildContext context) async {
|
||||
var settings = context.read<SettingState>();
|
||||
SettingsBackup settingsBack = await settings.backup();
|
||||
var json = settingsBack.toJson();
|
||||
var tempdir = await getTemporaryDirectory();
|
||||
DateTime now = DateTime.now();
|
||||
String datePlus = now.year.toString() +
|
||||
now.month.toString() +
|
||||
now.day.toString() +
|
||||
now.second.toString();
|
||||
var file = File(join(tempdir.path, 'tsacdop_settings_$datePlus.json'));
|
||||
await file.writeAsString(json.toString());
|
||||
return file;
|
||||
}
|
||||
|
||||
Future _importSetting(String path, BuildContext context) async {
|
||||
final s = context.s;
|
||||
var settings = context.read<SettingState>();
|
||||
File file = File(path);
|
||||
try {
|
||||
String json = file.readAsStringSync();
|
||||
SettingsBackup backup = SettingsBackup.fromJson(jsonDecode(json));
|
||||
await settings.restore(backup);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastFileError,
|
||||
gravity: ToastGravity.TOP,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _getFilePath(BuildContext context) async {
|
||||
final s = context.s;
|
||||
try {
|
||||
String filePath = await FilePicker.getFilePath(type: FileType.any);
|
||||
if (filePath == '') {
|
||||
return;
|
||||
}
|
||||
print('File Path' + filePath);
|
||||
Fluttertoast.showToast(
|
||||
msg: s.toastReadFile,
|
||||
gravity: ToastGravity.TOP,
|
||||
);
|
||||
_importSetting(filePath, context);
|
||||
} on PlatformException catch (e) {
|
||||
print(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = context.s;
|
||||
|
@ -77,7 +137,7 @@ class DataBackup extends StatelessWidget {
|
|||
Padding(
|
||||
padding:
|
||||
EdgeInsets.only(left: 70.0, right: 20, top: 10, bottom: 10),
|
||||
child: Text(s.settingsExportDes),
|
||||
child: Text(s.subscribeExportDes),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 70.0, right: 20),
|
||||
|
@ -85,7 +145,10 @@ class DataBackup extends StatelessWidget {
|
|||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
OutlineButton(
|
||||
highlightedBorderColor: context.accentColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100.0),
|
||||
side: BorderSide(color: Colors.green[700])),
|
||||
highlightedBorderColor: Colors.green[700],
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
|
@ -100,10 +163,13 @@ class DataBackup extends StatelessWidget {
|
|||
),
|
||||
onPressed: () async {
|
||||
File file = await _exportOmpl(context);
|
||||
await _saveOmpl(file);
|
||||
await _saveFile(file);
|
||||
}),
|
||||
SizedBox(width: 50),
|
||||
SizedBox(width: 10),
|
||||
OutlineButton(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100.0),
|
||||
side: BorderSide(color: Colors.blue[700])),
|
||||
highlightedBorderColor: Colors.blue[700],
|
||||
child: Row(
|
||||
children: [
|
||||
|
@ -119,12 +185,98 @@ class DataBackup extends StatelessWidget {
|
|||
),
|
||||
onPressed: () async {
|
||||
File file = await _exportOmpl(context);
|
||||
await _shareOmpl(file);
|
||||
await _shareFile(file);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
Container(
|
||||
height: 30.0,
|
||||
padding: EdgeInsets.symmetric(horizontal: 70),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(s.settings,
|
||||
style: context.textTheme.bodyText1
|
||||
.copyWith(color: Theme.of(context).accentColor)),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.only(left: 70.0, right: 20, top: 10, bottom: 10),
|
||||
child: Text(s.settingsExportDes),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 70.0, right: 10),
|
||||
child: Wrap(children: [
|
||||
OutlineButton(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100.0),
|
||||
side: BorderSide(color: Colors.green[700])),
|
||||
highlightedBorderColor: Colors.green[700],
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
LineIcons.save,
|
||||
color: Colors.green[700],
|
||||
size: context.textTheme.headline6.fontSize,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(s.save,
|
||||
style: TextStyle(color: Colors.green[700])),
|
||||
],
|
||||
),
|
||||
onPressed: () async {
|
||||
File file = await _exportSetting(context);
|
||||
await _saveFile(file);
|
||||
}),
|
||||
SizedBox(width: 10),
|
||||
OutlineButton(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100.0),
|
||||
side: BorderSide(color: Colors.blue[700])),
|
||||
highlightedBorderColor: Colors.blue[700],
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.share,
|
||||
size: context.textTheme.headline6.fontSize,
|
||||
color: Colors.blue[700],
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(s.share,
|
||||
style: TextStyle(color: Colors.blue[700])),
|
||||
],
|
||||
),
|
||||
onPressed: () async {
|
||||
File file = await _exportSetting(context);
|
||||
await _shareFile(file);
|
||||
}),
|
||||
SizedBox(width: 10),
|
||||
OutlineButton(
|
||||
highlightedBorderColor: Colors.red[700],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(100.0),
|
||||
side: BorderSide(color: Colors.red[700])),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
LineIcons.file_import_solid,
|
||||
size: context.textTheme.headline6.fontSize,
|
||||
color: Colors.red[700],
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Text(s.import,
|
||||
style: TextStyle(color: Colors.red[700])),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
_getFilePath(context);
|
||||
}),
|
||||
]),
|
||||
),
|
||||
Divider()
|
||||
],
|
||||
)),
|
||||
);
|
||||
|
|
|
@ -139,9 +139,12 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
|
|||
onTap: () => _saveTapToOpenPopupMenu(!snapshot.data),
|
||||
title: Text(s.settingsTapToOpenPopupMenu),
|
||||
subtitle: Text(s.settingsTapToOpenPopupMenuDes),
|
||||
trailing: Switch(
|
||||
value: snapshot.data,
|
||||
onChanged: (bool boo) => _saveTapToOpenPopupMenu(boo)),
|
||||
trailing: Transform.scale(
|
||||
scale: 0.9,
|
||||
child: Switch(
|
||||
value: snapshot.data,
|
||||
onChanged: (bool boo) => _saveTapToOpenPopupMenu(boo)),
|
||||
),
|
||||
),
|
||||
),
|
||||
FutureBuilder<List<int>>(
|
||||
|
@ -151,6 +154,7 @@ class _PopupMenuSettingState extends State<PopupMenuSetting> {
|
|||
List<int> menu = snapshot.data;
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
children: menu.map<Widget>((int e) {
|
||||
int i = e % 10;
|
||||
|
|
|
@ -93,7 +93,7 @@ class _SettingsState extends State<Settings>
|
|||
),
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(s.homeToprightMenuSettings),
|
||||
title: Text(s.settings),
|
||||
elevation: 0,
|
||||
backgroundColor: context.primaryColor,
|
||||
),
|
||||
|
|
|
@ -781,8 +781,9 @@ class AudioPlayerTask extends BackgroundAudioTask {
|
|||
if (_skipState == null) {
|
||||
if (_playing == null) {
|
||||
_playing = true;
|
||||
int cache = await cacheStorage.getInt();
|
||||
cacheMax = cache == 0 ? 500 * 1024 * 1024 : cache;
|
||||
int cacheMax =
|
||||
await cacheStorage.getInt(defaultValue: 500 * 1024 * 1024);
|
||||
|
||||
// await AudioServiceBackground.setQueue(_queue);
|
||||
await _audioPlayer.setUrl(mediaItem.id, cacheMax);
|
||||
var duration = await _audioPlayer.durationFuture;
|
||||
|
|
|
@ -263,6 +263,7 @@ class SettingState extends ChangeNotifier {
|
|||
_accentSetColor = Color(color).withOpacity(1.0);
|
||||
} else {
|
||||
_accentSetColor = Colors.teal[500];
|
||||
await _saveAccentSetColor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,7 +367,7 @@ class SettingState extends ChangeNotifier {
|
|||
int autoUpdate = await autoupdateStorage.getInt();
|
||||
int updateInterval = await intervalStorage.getInt();
|
||||
int downloadUsingData = await downloadUsingDataStorage.getInt();
|
||||
int cacheMax = await cacheStorage.getInt();
|
||||
int cacheMax = await cacheStorage.getInt(defaultValue: 500 * 1024 * 1024);
|
||||
int podcastLayout = await podcastLayoutStorage.getInt();
|
||||
int recentLayout = await recentLayoutStorage.getInt();
|
||||
int favLayout = await favLayoutStorage.getInt();
|
||||
|
@ -406,4 +407,41 @@ class SettingState extends ChangeNotifier {
|
|||
defaultSleepTime: defaultSleepTime,
|
||||
tapToOpenPopupMenu: tapToOpenPopupMenu);
|
||||
}
|
||||
|
||||
Future<void> restore(SettingsBackup backup) async {
|
||||
await themeStorage.saveInt(backup.theme);
|
||||
await accentStorage.saveString(backup.accentColor);
|
||||
await realDarkStorage.saveInt(backup.realDark);
|
||||
await autoPlayStorage.saveInt(backup.autoPlay);
|
||||
await autoupdateStorage.saveInt(backup.autoUpdate);
|
||||
await intervalStorage.saveInt(backup.updateInterval);
|
||||
await downloadUsingDataStorage.saveInt(backup.downloadUsingData);
|
||||
await cacheStorage.saveInt(backup.cacheMax);
|
||||
await podcastLayoutStorage.saveInt(backup.podcastLayout);
|
||||
await recentLayoutStorage.saveInt(backup.recentLayout);
|
||||
await favLayoutStorage.saveInt(backup.favLayout);
|
||||
await downloadLayoutStorage.saveInt(backup.downloadLayout);
|
||||
await autoDownloadStorage.saveInt(backup.autoDownloadNetwork);
|
||||
await KeyValueStorage(episodePopupMenuKey)
|
||||
.saveStringList(backup.episodePopupMenu);
|
||||
await autoDeleteStorage.saveInt(backup.autoDelete);
|
||||
await autoSleepTimerStorage.saveInt(backup.autoSleepTimer);
|
||||
await autoSleepTimerStartStorage.saveInt(backup.autoSleepTimerStart);
|
||||
await autoSleepTimerEndStorage.saveInt(backup.autoSleepTimerEnd);
|
||||
await autoSleepTimerModeStorage.saveInt(backup.autoSleepTimerMode);
|
||||
await defaultSleepTimerStorage.saveInt(backup.defaultSleepTime);
|
||||
await KeyValueStorage(tapToOpenPopupMenuKey)
|
||||
.saveInt(backup.tapToOpenPopupMenu);
|
||||
await initData();
|
||||
await _getAutoUpdate();
|
||||
await _getDownloadUsingData();
|
||||
await _getSleepTimerData();
|
||||
await _getUpdateInterval().then((value) async {
|
||||
if (_autoUpdate) {
|
||||
await cancelWork();
|
||||
setWorkManager(_initUpdateTag);
|
||||
await saveShowIntro(2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue