Release v0.3.4

This commit is contained in:
stonegate 2020-06-16 12:40:51 +08:00
parent 4d49bf086e
commit bbd9df64df
12 changed files with 60 additions and 39 deletions

View File

@ -56,6 +56,10 @@ If no api key added, the search function in the app won't work. But you can stil
Share_key is used for generate clip.
## Known Issue
- Playlist unstable
## Getting Started
This project is a starting point for a Flutter application.

View File

@ -99,6 +99,8 @@ class _DownloadListState extends State<DownloadList> {
color: Colors.red),
child: Text(
tasks[index].progress.toString() + '%',
textAlign: TextAlign.center,
maxLines: 1,
style: TextStyle(color: Colors.white),
))
: Container(),
@ -115,10 +117,7 @@ class _DownloadListState extends State<DownloadList> {
backgroundImage: FileImage(
File("${tasks[index].episode.imagePath}")),
),
trailing: Container(
width: 50,
height: 50,
child: _downloadButton(tasks[index], context)),
trailing: _downloadButton(tasks[index], context),
);
},
childCount: tasks.length,

View File

@ -40,16 +40,16 @@ class Import extends StatelessWidget {
if (autoDownloadNetwork == 1) {
List<EpisodeBrief> episodes = await dbHelper.getNewEpisodes('all');
// For safety
if (episodes.length < 100)
episodes.forEach((episode) {
downloader.startTask(episode, showNotification: true);
if (episodes.length < 100 && episodes.length > 0)
episodes.forEach((episode) async {
await downloader.startTask(episode, showNotification: true);
});
} else if (result == ConnectivityResult.wifi) {
List<EpisodeBrief> episodes = await dbHelper.getNewEpisodes('all');
//For safety
if (episodes.length < 100)
episodes.forEach((episode) {
downloader.startTask(episode, showNotification: true);
if (episodes.length < 100 && episodes.length > 0)
episodes.forEach((episode) async {
await downloader.startTask(episode, showNotification: true);
});
}
}

View File

@ -212,7 +212,7 @@ class _SlideIntroState extends State<SlideIntro> {
SlideLeftRoute(page: Home()));
Provider.of<SettingState>(context,
listen: false)
.saveShowIntro();
.saveShowIntro(1);
} else if (widget.goto == Goto.settings) {
Navigator.pop(context);
}

View File

@ -1010,6 +1010,7 @@ class DBHelper {
await txn.rawUpdate(
"UPDATE Episodes SET is_new = 0 WHERE enclosure_url = ?", [url]);
});
print('remove new episode');
}
Future<List<EpisodeBrief>> getLikedRssItem(int i, int sortBy) async {

View File

@ -43,7 +43,6 @@ class _DownloadsManageState extends State<DownloadsManage> {
_size = 0;
_fileNum = 0;
var dir = await getExternalStorageDirectory();
print(dir.path);
dir.list().forEach((d) {
var fileDir = Directory(d.path);
fileDir.list().forEach((file) async {
@ -124,7 +123,7 @@ class _DownloadsManageState extends State<DownloadsManage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(left: 20),
padding: const EdgeInsets.only(left: 10),
child: RichText(
text: TextSpan(
text: 'Total ',
@ -150,7 +149,9 @@ class _DownloadsManageState extends State<DownloadsManage> {
fontSize: 20,
)),
TextSpan(
text: (_size ~/ 1000000).toString(),
text: (_size ~/ 1000000) < 1000
? (_size ~/ 1000000).toString()
: (_size / 1000000000).toStringAsFixed(1),
style: GoogleFonts.cairo(
textStyle: TextStyle(
color: Theme.of(context).accentColor,
@ -158,7 +159,9 @@ class _DownloadsManageState extends State<DownloadsManage> {
)),
),
TextSpan(
text: ' Mb',
text: (_size ~/ 1000000) < 1000
? 'Mb'
: 'Gb',
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 20,

View File

@ -222,7 +222,8 @@ class _StorageSettingState extends State<StorageSetting>
onChanged: (value) async {
await _setAutoDeleteDays(value);
},
items: <int>[-1, 10, 30]
//TODO remove 1 before release
items: <int>[-1, 5, 10, 15, 30]
.map<DropdownMenuItem<int>>((e) {
return DropdownMenuItem<int>(
value: e,

View File

@ -113,7 +113,9 @@ class Playlist {
Future<int> delFromPlaylist(EpisodeBrief episodeBrief) async {
int index = _playlist.indexOf(episodeBrief);
_playlist.removeWhere((episode) => episode == episodeBrief);
_playlist.removeWhere(
(episode) => episode.enclosureUrl == episodeBrief.enclosureUrl);
print('delete' + episodeBrief.title);
await savePlaylist();
return index;
}
@ -244,6 +246,7 @@ class AudioPlayerNotifier extends ChangeNotifier {
}
episodeLoad(EpisodeBrief episode, {int startPosition = 0}) async {
print(episode.enclosureUrl);
final EpisodeBrief episodeNew =
await dbHelper.getRssItemWithUrl(episode.enclosureUrl);
//TODO load episode from last position when player running
@ -270,8 +273,9 @@ class AudioPlayerNotifier extends ChangeNotifier {
notifyListeners();
//await _queue.savePlaylist();
_startAudioService(startPosition, episodeNew.enclosureUrl);
if (episodeNew.isNew == 1)
dbHelper.removeEpisodeNewMark(episodeNew.enclosureUrl);
if (episodeNew.isNew == 1) {
await dbHelper.removeEpisodeNewMark(episodeNew.enclosureUrl);
}
}
}

View File

@ -50,15 +50,15 @@ class AutoDownloader {
}
bindBackgroundIsolate() {
print('start listen');
ReceivePort _port = ReceivePort();
bool isSuccess = IsolateNameServer.registerPortWithName(
_port.sendPort, 'auto_downloader_send_port');
if (!isSuccess) {
_unbindBackgroundIsolate();
//bindBackgroundIsolate();
IsolateNameServer.removePortNameMapping('auto_downloader_send_port');
bindBackgroundIsolate();
return;
}
print('start listen');
_port.listen((dynamic data) {
String id = data[0];
DownloadTaskStatus status = data[1];
@ -102,7 +102,7 @@ class AutoDownloader {
}
Future startTask(List<EpisodeBrief> episodes,
{bool showNotification = true}) async {
{bool showNotification = false}) async {
episodes.forEach((episode) async {
final dir = await getExternalStorageDirectory();
String localPath = path.join(dir.path, episode.feedTitle);

View File

@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:isolate';
import 'dart:ui';
import 'package:connectivity/connectivity.dart';
import 'package:flutter/foundation.dart';
@ -28,7 +27,7 @@ void callbackDispatcher() {
});
await FlutterDownloader.initialize();
AutoDownloader downloader = AutoDownloader();
downloader.bindBackgroundIsolate();
KeyValueStorage autoDownloadStorage =
KeyValueStorage(autoDownloadNetworkKey);
int autoDownloadNetwork = await autoDownloadStorage.getInt();
@ -36,13 +35,17 @@ void callbackDispatcher() {
if (autoDownloadNetwork == 1) {
List<EpisodeBrief> episodes = await dbHelper.getNewEpisodes('all');
// For safety
if (episodes.length < 100 && episodes.length > 0)
if (episodes.length < 100 && episodes.length > 0) {
downloader.bindBackgroundIsolate();
await downloader.startTask(episodes);
}
} else if (result == ConnectivityResult.wifi) {
List<EpisodeBrief> episodes = await dbHelper.getNewEpisodes('all');
//For safety
if (episodes.length < 100 && episodes.length > 0)
if (episodes.length < 100 && episodes.length > 0) {
downloader.bindBackgroundIsolate();
await downloader.startTask(episodes);
}
}
await lastWorkStorage.saveInt(1);
KeyValueStorage refreshstorage = KeyValueStorage(refreshdateKey);
@ -149,6 +152,7 @@ class SettingState extends ChangeNotifier {
notifyListeners();
}
int _initialShowIntor;
bool _showIntro;
bool get showIntro => _showIntro;
@ -163,13 +167,18 @@ class SettingState extends ChangeNotifier {
@override
void addListener(VoidCallback listener) {
super.addListener(listener);
_getTheme();
_getAccentSetColor();
_getAutoUpdate();
_getRealDark();
_getDownloadUsingData();
_getUpdateInterval().then((value) {
if (_initUpdateTag == 0) setWorkManager(24);
_getUpdateInterval().then((value) async {
if (_initUpdateTag == 0)
setWorkManager(24);
//Restart worker if anythin changed in worker callback.
//varsion 2 add auto download new episodes
else if (_autoUpdate && _initialShowIntor == 1) {
await cancelWork();
setWorkManager(_initUpdateTag);
await saveShowIntro(2);
}
});
}
@ -225,12 +234,12 @@ class SettingState extends ChangeNotifier {
}
Future _getShowIntro() async {
int i = await introStorage.getInt();
_showIntro = i == 0 ? true : false;
_initialShowIntor = await introStorage.getInt();
_showIntro = _initialShowIntor == 0 ? true : false;
}
Future saveShowIntro() async {
await introStorage.saveInt(1);
Future saveShowIntro(int i) async {
await introStorage.saveInt(i);
}
Future _getRealDark() async {

View File

@ -83,11 +83,11 @@ class EpisodeBrief {
}
@override
bool operator ==(Object episode) =>
bool operator == (Object episode) =>
episode is EpisodeBrief &&
episode.title == title &&
episode.enclosureUrl == enclosureUrl;
@override
int get hashCode => enclosureUrl.hashCode;
int get hashCode => enclosureUrl.hashCode + title.hashCode;
}

View File

@ -489,9 +489,9 @@ class EpisodeGrid extends StatelessWidget {
// _listenIndicater(context,
// episode: episodes[index],
// isListened: snapshot.data),
_isNewIndicator(episodes[index]),
_downloadIndicater(context,
episode: episodes[index]),
_isNewIndicator(episodes[index]),
_numberIndicater(context,
index: index, color: _c)
],