mirror of
https://github.com/stonega/tsacdop
synced 2025-02-17 20:10:37 +01:00
Auto delete downloads after played.
This commit is contained in:
parent
7af2cb5a09
commit
e8882a62b8
@ -57,6 +57,7 @@ const String hidePodcastDiscoveryKey = 'hidePodcastDiscoveryKey';
|
|||||||
const String searchEngineKey = 'searchEngineKey';
|
const String searchEngineKey = 'searchEngineKey';
|
||||||
const String markListenedAfterSkipKey = 'markListenedAfterSkipKey';
|
const String markListenedAfterSkipKey = 'markListenedAfterSkipKey';
|
||||||
const String downloadPositionKey = 'downloadPositionKey';
|
const String downloadPositionKey = 'downloadPositionKey';
|
||||||
|
const String deleteAfterPlayedKey = 'removeAfterPlayedKey';
|
||||||
|
|
||||||
class KeyValueStorage {
|
class KeyValueStorage {
|
||||||
final String key;
|
final String key;
|
||||||
|
@ -1091,7 +1091,8 @@ class DBHelper {
|
|||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<EpisodeBrief>> getOutdatedEpisode(int deadline) async {
|
Future<List<EpisodeBrief>> getOutdatedEpisode(int deadline,
|
||||||
|
{bool deletePlayed}) async {
|
||||||
var dbClient = await database;
|
var dbClient = await database;
|
||||||
var episodes = <EpisodeBrief>[];
|
var episodes = <EpisodeBrief>[];
|
||||||
List<Map> list = await dbClient.rawQuery(
|
List<Map> list = await dbClient.rawQuery(
|
||||||
@ -1100,18 +1101,45 @@ class DBHelper {
|
|||||||
P.imagePath, P.primaryColor FROM Episodes E INNER JOIN PodcastLocal P ON E.feed_id = P.id
|
P.imagePath, P.primaryColor FROM Episodes E INNER JOIN PodcastLocal P ON E.feed_id = P.id
|
||||||
WHERE E.download_date < ? AND E.enclosure_url != E.media_id
|
WHERE E.download_date < ? AND E.enclosure_url != E.media_id
|
||||||
ORDER BY E.milliseconds DESC""", [deadline]);
|
ORDER BY E.milliseconds DESC""", [deadline]);
|
||||||
for (var i in list) {
|
if (list.isNotEmpty) {
|
||||||
episodes.add(EpisodeBrief(
|
for (var i in list) {
|
||||||
i['title'],
|
episodes.add(EpisodeBrief(
|
||||||
i['enclosure_url'],
|
i['title'],
|
||||||
i['enclosure_length'],
|
i['enclosure_url'],
|
||||||
i['milliseconds'],
|
i['enclosure_length'],
|
||||||
i['feed_title'],
|
i['milliseconds'],
|
||||||
i['primaryColor'],
|
i['feed_title'],
|
||||||
i['duration'],
|
i['primaryColor'],
|
||||||
i['explicit'],
|
i['duration'],
|
||||||
i['imagePath'],
|
i['explicit'],
|
||||||
i['is_new']));
|
i['imagePath'],
|
||||||
|
i['is_new']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deletePlayed) {
|
||||||
|
List<Map> results = await dbClient.rawQuery(
|
||||||
|
"""SELECT E.title, E.enclosure_url, E.enclosure_length, E.is_new,
|
||||||
|
E.milliseconds, P.title as feed_title, E.duration, E.explicit,
|
||||||
|
P.imagePath, P.primaryColor FROM Episodes E INNER JOIN PodcastLocal P
|
||||||
|
ON E.feed_id = P.id LEFT JOIN PlayHistory H ON E.enclosure_url =
|
||||||
|
H.enclosure_url WHERE E.enclosure_url != E.media_id
|
||||||
|
GROUP BY E.enclosure_url HAVING SUM(H.listen_time) > 0 ORDER BY
|
||||||
|
E.milliseconds DESC""");
|
||||||
|
if (results.isNotEmpty) {
|
||||||
|
for (var i in results) {
|
||||||
|
episodes.add(EpisodeBrief(
|
||||||
|
i['title'],
|
||||||
|
i['enclosure_url'],
|
||||||
|
i['enclosure_length'],
|
||||||
|
i['milliseconds'],
|
||||||
|
i['feed_title'],
|
||||||
|
i['primaryColor'],
|
||||||
|
i['duration'],
|
||||||
|
i['explicit'],
|
||||||
|
i['imagePath'],
|
||||||
|
i['is_new']));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return episodes;
|
return episodes;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,11 @@ class _StorageSettingState extends State<StorageSetting>
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> _getDelteAfterPlayed() async {
|
||||||
|
final storage = KeyValueStorage(deleteAfterPlayedKey);
|
||||||
|
return await storage.getBool(defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _setAutoDeleteDays(int days) async {
|
Future<void> _setAutoDeleteDays(int days) async {
|
||||||
var storage = KeyValueStorage(autoDeleteKey);
|
var storage = KeyValueStorage(autoDeleteKey);
|
||||||
await storage.saveInt(days);
|
await storage.saveInt(days);
|
||||||
@ -83,6 +88,11 @@ class _StorageSettingState extends State<StorageSetting>
|
|||||||
await storage.saveInt(index);
|
await storage.saveInt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _setDeleteAfterPlayed(bool boo) async {
|
||||||
|
final storage = KeyValueStorage(deleteAfterPlayedKey);
|
||||||
|
await storage.saveBool(boo);
|
||||||
|
}
|
||||||
|
|
||||||
double _value;
|
double _value;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -117,186 +127,219 @@ class _StorageSettingState extends State<StorageSetting>
|
|||||||
backgroundColor: Theme.of(context).primaryColor,
|
backgroundColor: Theme.of(context).primaryColor,
|
||||||
),
|
),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Column(
|
child: SingleChildScrollView(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: <Widget>[
|
mainAxisSize: MainAxisSize.min,
|
||||||
Padding(
|
children: <Widget>[
|
||||||
padding: EdgeInsets.all(10.0),
|
Padding(
|
||||||
),
|
padding: EdgeInsets.all(10.0),
|
||||||
Container(
|
),
|
||||||
height: 30.0,
|
Container(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 70),
|
height: 30.0,
|
||||||
alignment: Alignment.centerLeft,
|
padding: EdgeInsets.symmetric(horizontal: 70),
|
||||||
child: Text(s.network,
|
alignment: Alignment.centerLeft,
|
||||||
style: context.textTheme.bodyText1
|
child: Text(s.network,
|
||||||
.copyWith(color: context.accentColor)),
|
style: context.textTheme.bodyText1
|
||||||
),
|
.copyWith(color: context.accentColor)),
|
||||||
Selector<SettingState, bool>(
|
),
|
||||||
selector: (_, settings) => settings.downloadUsingData,
|
Selector<SettingState, bool>(
|
||||||
builder: (_, data, __) {
|
selector: (_, settings) => settings.downloadUsingData,
|
||||||
return ListTile(
|
builder: (_, data, __) {
|
||||||
onTap: () => settings.downloadUsingData = !data,
|
|
||||||
contentPadding: EdgeInsets.only(
|
|
||||||
left: 70.0, right: 25, bottom: 10, top: 10),
|
|
||||||
title: Text(s.settingsNetworkCellular),
|
|
||||||
subtitle: Text(s.settingsNetworkCellularDes),
|
|
||||||
trailing: Transform.scale(
|
|
||||||
scale: 0.9,
|
|
||||||
child: Switch(
|
|
||||||
value: data,
|
|
||||||
onChanged: (value) =>
|
|
||||||
settings.downloadUsingData = value,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
FutureBuilder<bool>(
|
|
||||||
future: _getAutoDownloadNetwork(),
|
|
||||||
initialData: false,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () async {
|
onTap: () => settings.downloadUsingData = !data,
|
||||||
_setAudtDownloadNetwork(!snapshot.data);
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
contentPadding: EdgeInsets.only(
|
contentPadding: EdgeInsets.only(
|
||||||
left: 70.0, right: 25, bottom: 10, top: 10),
|
left: 70.0, right: 25, bottom: 10, top: 10),
|
||||||
title: Text(s.settingsNetworkCellularAuto),
|
title: Text(s.settingsNetworkCellular),
|
||||||
subtitle: Text(s.settingsNetworkCellularAutoDes),
|
subtitle: Text(s.settingsNetworkCellularDes),
|
||||||
trailing: Transform.scale(
|
trailing: Transform.scale(
|
||||||
scale: 0.9,
|
scale: 0.9,
|
||||||
child: Switch(
|
child: Switch(
|
||||||
value: snapshot.data,
|
value: data,
|
||||||
onChanged: (value) async {
|
onChanged: (value) =>
|
||||||
await _setAudtDownloadNetwork(value);
|
settings.downloadUsingData = value,
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
Divider(height: 1),
|
),
|
||||||
Padding(
|
FutureBuilder<bool>(
|
||||||
padding: EdgeInsets.all(10.0),
|
future: _getAutoDownloadNetwork(),
|
||||||
),
|
initialData: false,
|
||||||
Container(
|
builder: (context, snapshot) {
|
||||||
height: 30.0,
|
return ListTile(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 70),
|
onTap: () async {
|
||||||
alignment: Alignment.centerLeft,
|
_setAudtDownloadNetwork(!snapshot.data);
|
||||||
child: Text(s.settingStorage,
|
setState(() {});
|
||||||
style: context.textTheme.bodyText1
|
},
|
||||||
.copyWith(color: context.accentColor)),
|
contentPadding: EdgeInsets.only(
|
||||||
),
|
left: 70.0, right: 25, bottom: 10, top: 10),
|
||||||
ListTile(
|
title: Text(s.settingsNetworkCellularAuto),
|
||||||
onTap: () => Navigator.push(context,
|
subtitle: Text(s.settingsNetworkCellularAutoDes),
|
||||||
MaterialPageRoute(builder: (context) => DownloadsManage())),
|
trailing: Transform.scale(
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 70.0),
|
scale: 0.9,
|
||||||
title: Text(s.download),
|
child: Switch(
|
||||||
subtitle: Text(s.settingsManageDownloadDes),
|
value: snapshot.data,
|
||||||
),
|
onChanged: (value) async {
|
||||||
FutureBuilder<int>(
|
await _setAudtDownloadNetwork(value);
|
||||||
future: _getDownloadPasition(),
|
setState(() {});
|
||||||
initialData: 0,
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
Divider(height: 1),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.all(10.0),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
height: 30.0,
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 70),
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Text(s.settingStorage,
|
||||||
|
style: context.textTheme.bodyText1
|
||||||
|
.copyWith(color: context.accentColor)),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
onTap: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => DownloadsManage())),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 70.0),
|
||||||
|
title: Text(s.download),
|
||||||
|
subtitle: Text(s.settingsManageDownloadDes),
|
||||||
|
),
|
||||||
|
FutureBuilder<int>(
|
||||||
|
future: _getDownloadPasition(),
|
||||||
|
initialData: 0,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
return ListTile(
|
||||||
|
contentPadding: EdgeInsets.fromLTRB(70, 10, 20, 10),
|
||||||
|
title: Text(s.settingsDownloadPosition),
|
||||||
|
subtitle: Text(
|
||||||
|
_dirs == null ? '' : _dirs[snapshot.data],
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis),
|
||||||
|
onTap: () => generalSheet(
|
||||||
|
context,
|
||||||
|
title: s.settingsDownloadPosition,
|
||||||
|
child: Column(children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
for (var dir in _dirs)
|
||||||
|
ListTile(
|
||||||
|
title: Text(dir),
|
||||||
|
onTap: () =>
|
||||||
|
_setDownloadPosition(_dirs.indexOf(dir)),
|
||||||
|
trailing: Radio<int>(
|
||||||
|
value: _dirs.indexOf(dir),
|
||||||
|
groupValue: snapshot.data,
|
||||||
|
onChanged: _setDownloadPosition),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
FutureBuilder<int>(
|
||||||
|
future: _getAutoDeleteDays(),
|
||||||
|
initialData: 30,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
contentPadding: EdgeInsets.fromLTRB(70, 10, 20, 10),
|
contentPadding: EdgeInsets.only(left: 70.0, right: 20),
|
||||||
title: Text(s.settingsDownloadPosition),
|
title: Text(s.settingsAutoDelete),
|
||||||
subtitle: Text(_dirs == null ? '' : _dirs[snapshot.data],
|
subtitle: Text(s.settingsAutoDeleteDes),
|
||||||
maxLines: 2, overflow: TextOverflow.ellipsis),
|
trailing: MyDropdownButton(
|
||||||
onTap: () => generalSheet(
|
hint: snapshot.data == -1
|
||||||
context,
|
? Text(s.daysCount(0))
|
||||||
title: s.settingsDownloadPosition,
|
: Text(s.daysCount(snapshot.data)),
|
||||||
child: Column(children: [
|
underline: Center(),
|
||||||
SizedBox(
|
elevation: 1,
|
||||||
height: 10,
|
value: snapshot.data,
|
||||||
),
|
onChanged: (value) async {
|
||||||
for (var dir in _dirs)
|
await _setAutoDeleteDays(value);
|
||||||
ListTile(
|
},
|
||||||
title: Text(dir),
|
items: <int>[-1, 5, 10, 15, 30]
|
||||||
onTap: () =>
|
.map<DropdownMenuItem<int>>((e) {
|
||||||
_setDownloadPosition(_dirs.indexOf(dir)),
|
return DropdownMenuItem<int>(
|
||||||
trailing: Radio<int>(
|
value: e,
|
||||||
value: _dirs.indexOf(dir),
|
child: e == -1
|
||||||
groupValue: snapshot.data,
|
? Text(s.daysCount(0))
|
||||||
onChanged: _setDownloadPosition),
|
: Text(s.daysCount(e)));
|
||||||
),
|
}).toList()),
|
||||||
SizedBox(
|
|
||||||
height: 30,
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}),
|
},
|
||||||
FutureBuilder<int>(
|
|
||||||
future: _getAutoDeleteDays(),
|
|
||||||
initialData: 30,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
return ListTile(
|
|
||||||
contentPadding: EdgeInsets.only(left: 70.0, right: 20),
|
|
||||||
title: Text(s.settingsAutoDelete),
|
|
||||||
subtitle: Text(s.settingsAutoDeleteDes),
|
|
||||||
trailing: MyDropdownButton(
|
|
||||||
hint: snapshot.data == -1
|
|
||||||
? Text(s.daysCount(0))
|
|
||||||
: Text(s.daysCount(snapshot.data)),
|
|
||||||
underline: Center(),
|
|
||||||
elevation: 1,
|
|
||||||
value: snapshot.data,
|
|
||||||
onChanged: (value) async {
|
|
||||||
await _setAutoDeleteDays(value);
|
|
||||||
},
|
|
||||||
items: <int>[-1, 5, 10, 15, 30]
|
|
||||||
.map<DropdownMenuItem<int>>((e) {
|
|
||||||
return DropdownMenuItem<int>(
|
|
||||||
value: e,
|
|
||||||
child: e == -1
|
|
||||||
? Text(s.daysCount(0))
|
|
||||||
: Text(s.daysCount(e)));
|
|
||||||
}).toList()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
contentPadding: EdgeInsets.only(left: 70.0, right: 25),
|
|
||||||
// leading: Icon(Icons.colorize),
|
|
||||||
title: Text(s.settingsAudioCache),
|
|
||||||
subtitle: Text(s.settingsAudioCacheDes),
|
|
||||||
trailing: Text.rich(TextSpan(
|
|
||||||
text: '${(_value ~/ 100) * 100}',
|
|
||||||
style: GoogleFonts.teko(
|
|
||||||
textStyle: context.textTheme.headline6
|
|
||||||
.copyWith(color: context.accentColor)),
|
|
||||||
children: [
|
|
||||||
TextSpan(text: ' Mb', style: context.textTheme.subtitle2),
|
|
||||||
])),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(left: 50.0, right: 20.0, bottom: 10.0),
|
|
||||||
child: SliderTheme(
|
|
||||||
data: Theme.of(context).sliderTheme.copyWith(
|
|
||||||
showValueIndicator: ShowValueIndicator.always,
|
|
||||||
trackHeight: 2,
|
|
||||||
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 6)),
|
|
||||||
child: Slider(
|
|
||||||
label: '${_value ~/ 100 * 100} Mb',
|
|
||||||
activeColor: context.accentColor,
|
|
||||||
inactiveColor: context.primaryColorDark,
|
|
||||||
value: _value,
|
|
||||||
min: 100,
|
|
||||||
max: 1000,
|
|
||||||
divisions: 9,
|
|
||||||
onChanged: (val) {
|
|
||||||
setState(() {
|
|
||||||
_value = val;
|
|
||||||
});
|
|
||||||
cacheStorage.saveInt((val * 1024 * 1024).toInt());
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
),
|
FutureBuilder<bool>(
|
||||||
Divider(height: 1),
|
future: _getDelteAfterPlayed(),
|
||||||
],
|
initialData: false,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
return ListTile(
|
||||||
|
onTap: () async {
|
||||||
|
_setDeleteAfterPlayed(snapshot.data);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
contentPadding: EdgeInsets.only(left: 70.0, right: 25),
|
||||||
|
title: Text('Delete download after played'),
|
||||||
|
subtitle: Text('Delete after played'),
|
||||||
|
trailing: Transform.scale(
|
||||||
|
scale: 0.9,
|
||||||
|
child: Switch(
|
||||||
|
value: snapshot.data,
|
||||||
|
onChanged: (value) async {
|
||||||
|
await _setDeleteAfterPlayed(value);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
ListTile(
|
||||||
|
contentPadding: EdgeInsets.only(left: 70.0, right: 25),
|
||||||
|
// leading: Icon(Icons.colorize),
|
||||||
|
title: Text(s.settingsAudioCache),
|
||||||
|
subtitle: Text(s.settingsAudioCacheDes),
|
||||||
|
trailing: Text.rich(TextSpan(
|
||||||
|
text: '${(_value ~/ 100) * 100}',
|
||||||
|
style: GoogleFonts.teko(
|
||||||
|
textStyle: context.textTheme.headline6
|
||||||
|
.copyWith(color: context.accentColor)),
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: ' Mb', style: context.textTheme.subtitle2),
|
||||||
|
])),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
EdgeInsets.only(left: 50.0, right: 20.0, bottom: 10.0),
|
||||||
|
child: SliderTheme(
|
||||||
|
data: Theme.of(context).sliderTheme.copyWith(
|
||||||
|
showValueIndicator: ShowValueIndicator.always,
|
||||||
|
trackHeight: 2,
|
||||||
|
thumbShape:
|
||||||
|
RoundSliderThumbShape(enabledThumbRadius: 6)),
|
||||||
|
child: Slider(
|
||||||
|
label: '${_value ~/ 100 * 100} Mb',
|
||||||
|
activeColor: context.accentColor,
|
||||||
|
inactiveColor: context.primaryColorDark,
|
||||||
|
value: _value,
|
||||||
|
min: 100,
|
||||||
|
max: 1000,
|
||||||
|
divisions: 9,
|
||||||
|
onChanged: (val) {
|
||||||
|
setState(() {
|
||||||
|
_value = val;
|
||||||
|
});
|
||||||
|
cacheStorage.saveInt((val * 1024 * 1024).toInt());
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(height: 1),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -335,7 +335,7 @@ class DownloadState extends ChangeNotifier {
|
|||||||
taskId: task.taskId, shouldDeleteContent: false);
|
taskId: task.taskId, shouldDeleteContent: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future delTask(EpisodeBrief episode) async {
|
Future<void> delTask(EpisodeBrief episode) async {
|
||||||
var task = episodeToTask(episode);
|
var task = episodeToTask(episode);
|
||||||
await FlutterDownloader.remove(
|
await FlutterDownloader.remove(
|
||||||
taskId: task.taskId, shouldDeleteContent: true);
|
taskId: task.taskId, shouldDeleteContent: true);
|
||||||
@ -350,22 +350,25 @@ class DownloadState extends ChangeNotifier {
|
|||||||
_removeTask(episode);
|
_removeTask(episode);
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeTask(EpisodeBrief episode) {
|
void _removeTask(EpisodeBrief episode) {
|
||||||
_episodeTasks.removeWhere((element) => element.episode == episode);
|
_episodeTasks.removeWhere((element) => element.episode == episode);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
_autoDelete() async {
|
Future<void> _autoDelete() async {
|
||||||
developer.log('Start auto delete outdated episodes');
|
developer.log('Start auto delete outdated episodes');
|
||||||
var autoDeleteStorage = KeyValueStorage(autoDeleteKey);
|
final autoDeleteStorage = KeyValueStorage(autoDeleteKey);
|
||||||
var autoDelete = await autoDeleteStorage.getInt();
|
final deletePlayedStorage = KeyValueStorage(deleteAfterPlayedKey);
|
||||||
|
final autoDelete = await autoDeleteStorage.getInt();
|
||||||
|
final deletePlayed = await deletePlayedStorage.getBool(defaultValue: false);
|
||||||
if (autoDelete == 0) {
|
if (autoDelete == 0) {
|
||||||
await autoDeleteStorage.saveInt(30);
|
await autoDeleteStorage.saveInt(30);
|
||||||
} else if (autoDelete > 0) {
|
} else if (autoDelete > 0) {
|
||||||
var deadline = DateTime.now()
|
var deadline = DateTime.now()
|
||||||
.subtract(Duration(days: autoDelete))
|
.subtract(Duration(days: autoDelete))
|
||||||
.millisecondsSinceEpoch;
|
.millisecondsSinceEpoch;
|
||||||
var episodes = await dbHelper.getOutdatedEpisode(deadline);
|
var episodes = await dbHelper.getOutdatedEpisode(deadline,
|
||||||
|
deletePlayed: deletePlayed);
|
||||||
if (episodes.isNotEmpty) {
|
if (episodes.isNotEmpty) {
|
||||||
for (var episode in episodes) {
|
for (var episode in episodes) {
|
||||||
await delTask(episode);
|
await delTask(episode);
|
||||||
|
@ -362,7 +362,7 @@ class GroupList extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Load groups from storage at start.
|
/// Load groups from storage at start.
|
||||||
Future loadGroups() async {
|
Future<void> loadGroups() async {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
_groupStorage.getGroups().then((loadgroups) async {
|
_groupStorage.getGroups().then((loadgroups) async {
|
||||||
@ -376,7 +376,7 @@ class GroupList extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Update podcasts of each group
|
/// Update podcasts of each group
|
||||||
Future updateGroups() async {
|
Future<void> updateGroups() async {
|
||||||
for (var group in _groups) {
|
for (var group in _groups) {
|
||||||
await group.getPodcasts();
|
await group.getPodcasts();
|
||||||
}
|
}
|
||||||
@ -384,7 +384,7 @@ class GroupList extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add new group.
|
/// Add new group.
|
||||||
Future addGroup(PodcastGroup podcastGroup) async {
|
Future<void> addGroup(PodcastGroup podcastGroup) async {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
_groups.add(podcastGroup);
|
_groups.add(podcastGroup);
|
||||||
await _saveGroup();
|
await _saveGroup();
|
||||||
@ -393,7 +393,7 @@ class GroupList extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Remove group.
|
/// Remove group.
|
||||||
Future delGroup(PodcastGroup podcastGroup) async {
|
Future<void> delGroup(PodcastGroup podcastGroup) async {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
for (var podcast in podcastGroup.podcastList) {
|
for (var podcast in podcastGroup.podcastList) {
|
||||||
if (!_groups.first.podcastList.contains(podcast)) {
|
if (!_groups.first.podcastList.contains(podcast)) {
|
||||||
|
@ -496,6 +496,11 @@ class SettingState extends ChangeNotifier {
|
|||||||
var speedList = await KeyValueStorage(speedListKey).getStringList();
|
var speedList = await KeyValueStorage(speedListKey).getStringList();
|
||||||
var hidePodcastDiscovery = await KeyValueStorage(hidePodcastDiscoveryKey)
|
var hidePodcastDiscovery = await KeyValueStorage(hidePodcastDiscoveryKey)
|
||||||
.getBool(defaultValue: false);
|
.getBool(defaultValue: false);
|
||||||
|
final markListenedAfterSKip =
|
||||||
|
await KeyValueStorage(markListenedAfterSkipKey)
|
||||||
|
.getBool(defaultValue: false);
|
||||||
|
final deleteAfterPlayed = await KeyValueStorage(deleteAfterPlayedKey)
|
||||||
|
.getBool(defaultValue: false);
|
||||||
|
|
||||||
return SettingsBackup(
|
return SettingsBackup(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -527,7 +532,9 @@ class SettingState extends ChangeNotifier {
|
|||||||
notificationLayout: notificationLayout,
|
notificationLayout: notificationLayout,
|
||||||
showNotesFont: showNotesFont,
|
showNotesFont: showNotesFont,
|
||||||
speedList: speedList,
|
speedList: speedList,
|
||||||
hidePodcastDiscovery: hidePodcastDiscovery);
|
hidePodcastDiscovery: hidePodcastDiscovery,
|
||||||
|
markListenedAfterSkip: markListenedAfterSKip,
|
||||||
|
deleteAfterPlayed: deleteAfterPlayed);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> restore(SettingsBackup backup) async {
|
Future<void> restore(SettingsBackup backup) async {
|
||||||
@ -563,6 +570,10 @@ class SettingState extends ChangeNotifier {
|
|||||||
.saveInt(backup.notificationLayout);
|
.saveInt(backup.notificationLayout);
|
||||||
await showNotesFontStorage.saveInt(backup.showNotesFont);
|
await showNotesFontStorage.saveInt(backup.showNotesFont);
|
||||||
await KeyValueStorage(speedListKey).saveStringList(backup.speedList);
|
await KeyValueStorage(speedListKey).saveStringList(backup.speedList);
|
||||||
|
await KeyValueStorage(markListenedAfterSkipKey)
|
||||||
|
.saveBool(backup.markListenedAfterSkip);
|
||||||
|
await KeyValueStorage(deleteAfterPlayedKey)
|
||||||
|
.saveBool(backup.deleteAfterPlayed);
|
||||||
|
|
||||||
if (backup.locale == '') {
|
if (backup.locale == '') {
|
||||||
await localeStorage.saveStringList([]);
|
await localeStorage.saveStringList([]);
|
||||||
|
@ -29,6 +29,8 @@ class SettingsBackup {
|
|||||||
final int showNotesFont;
|
final int showNotesFont;
|
||||||
final List<String> speedList;
|
final List<String> speedList;
|
||||||
final bool hidePodcastDiscovery;
|
final bool hidePodcastDiscovery;
|
||||||
|
final bool markListenedAfterSkip;
|
||||||
|
final bool deleteAfterPlayed;
|
||||||
|
|
||||||
SettingsBackup(
|
SettingsBackup(
|
||||||
{this.theme,
|
{this.theme,
|
||||||
@ -60,7 +62,9 @@ class SettingsBackup {
|
|||||||
this.notificationLayout,
|
this.notificationLayout,
|
||||||
this.showNotesFont,
|
this.showNotesFont,
|
||||||
this.speedList,
|
this.speedList,
|
||||||
this.hidePodcastDiscovery});
|
this.hidePodcastDiscovery,
|
||||||
|
this.markListenedAfterSkip,
|
||||||
|
this.deleteAfterPlayed});
|
||||||
|
|
||||||
Map<String, Object> toJson() {
|
Map<String, Object> toJson() {
|
||||||
return {
|
return {
|
||||||
@ -92,7 +96,9 @@ class SettingsBackup {
|
|||||||
'notificationLayout': notificationLayout,
|
'notificationLayout': notificationLayout,
|
||||||
'showNotesFont': showNotesFont,
|
'showNotesFont': showNotesFont,
|
||||||
'speedList': speedList,
|
'speedList': speedList,
|
||||||
'hidePodcastDiscovery': hidePodcastDiscovery
|
'hidePodcastDiscovery': hidePodcastDiscovery,
|
||||||
|
'markListenedAfterSkip': markListenedAfterSkip,
|
||||||
|
'deleteAfterPlayed': deleteAfterPlayed
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +134,8 @@ class SettingsBackup {
|
|||||||
notificationLayout: json['notificationLayout'] as int,
|
notificationLayout: json['notificationLayout'] as int,
|
||||||
showNotesFont: json['showNotesFont'] as int,
|
showNotesFont: json['showNotesFont'] as int,
|
||||||
speedList: speedList,
|
speedList: speedList,
|
||||||
hidePodcastDiscovery: json['hidePodcastDiscovery'] as bool);
|
hidePodcastDiscovery: json['hidePodcastDiscovery'] as bool,
|
||||||
|
markListenedAfterSkip: json['markListenedAfterSkip'] as bool,
|
||||||
|
deleteAfterPlayed: json['deleteAfterPlayed'] as bool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user