diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 912fff3..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,54 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the action will run. Triggers the workflow on push or pull request -# events but only for the master branch -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - uses: actions/setup-java@v1 - with: - java-version: '12.x' - - uses: subosito/flutter-action@v1 - with: - flutter-version: '1.18.0-11.1.pre' - channel: 'beta' - env: - KEY_ALIAS: ${{ secrets.KEY_ALIAS}} - KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} - KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} - ENCODED_KEYSTORE: ${{ secrets.ENCODED_KEYSTORE }} - # Runs a single command using the runners shell - - name: Run flutter doctor - run: flutter doctor - - # Runs a set of commands using the runners shell - - name: Update package - run: flutter update-packages --force-upgrade - - name: Configure env - run: | - echo $ENCODED_KEYSTORE | base64 -di > /home/runner/work/tsacdop/tsacdop/android/app/keystore.jks - dart tool/env.dart - - name: Build android version - run: flutter build appbundle --no-shrink - - uses: actions/upload-artifact@v1 - with: - name: release-apk - path: build/app/outputs/bundle/release/app-release.aab - - diff --git a/android/app/build.gradle b/android/app/build.gradle index 36a0660..9392a12 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -49,7 +49,7 @@ android { applicationId "com.stonegate.tsacdop" minSdkVersion 19 targetSdkVersion 28 - versionCode 12 + versionCode 14 versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/lib/home/about.dart b/lib/home/about.dart index 7313f31..654d761 100644 --- a/lib/home/about.dart +++ b/lib/home/about.dart @@ -4,7 +4,7 @@ import 'package:tsacdop/util/custompaint.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:line_icons/line_icons.dart'; -const String version = '0.3.0'; +const String version = '0.3.1'; class AboutApp extends StatelessWidget { _launchUrl(String url) async { diff --git a/lib/home/addpodcast.dart b/lib/home/addpodcast.dart index ac5a3c2..fe9687d 100644 --- a/lib/home/addpodcast.dart +++ b/lib/home/addpodcast.dart @@ -24,8 +24,7 @@ class MyHomePageDelegate extends SearchDelegate { String apiKey = environment['apiKey']; String url = "https://listennotes.p.rapidapi.com/api/v1/search?only_in=title%2Cdescription&q=" + - searchText + - "&sort_by_date=0&type=podcast"; + "$searchText&sort_by_date=0&type=podcast"; Response response = await Dio().get(url, options: Options(headers: { 'X-Mashape-Key': "$apiKey", @@ -81,57 +80,57 @@ class MyHomePageDelegate extends SearchDelegate { @override Widget buildSuggestions(BuildContext context) { - if (query.isEmpty) - return Center( - child: Container( - padding: EdgeInsets.only(top: 400), - child: Image( - image: Theme.of(context).brightness == Brightness.light - ? AssetImage('assets/listennotes.png') - : AssetImage('assets/listennotes_light.png'), - height: 20, - ), - )); - else if (rssExp.stringMatch(query) != null) - return FutureBuilder( - future: getRss(rssExp.stringMatch(query)), - builder: (context, snapshot) { - if (snapshot.hasError) - return invalidRss(); - else if (snapshot.hasData) - return SearchResult( - onlinePodcast: snapshot.data, - ); - else - return Container( - padding: EdgeInsets.only(top: 200), - alignment: Alignment.topCenter, - child: CircularProgressIndicator(), - ); - }, - ); - else - return FutureBuilder( - future: getList(query), - builder: (BuildContext context, AsyncSnapshot snapshot) { - if (!snapshot.hasData && query != null) - return Container( - padding: EdgeInsets.only(top: 200), - alignment: Alignment.topCenter, - child: CircularProgressIndicator(), - ); - List content = snapshot.data; - return ListView.builder( - scrollDirection: Axis.vertical, - itemCount: content.length, - itemBuilder: (BuildContext context, int index) { - return SearchResult( - onlinePodcast: content[index], - ); - }, - ); - }, - ); + // if (query.isEmpty) + return Center( + child: Container( + padding: EdgeInsets.only(top: 400), + child: Image( + image: Theme.of(context).brightness == Brightness.light + ? AssetImage('assets/listennotes.png') + : AssetImage('assets/listennotes_light.png'), + height: 20, + ), + )); + // else if (rssExp.stringMatch(query) != null) + // return FutureBuilder( + // future: getRss(rssExp.stringMatch(query)), + // builder: (context, snapshot) { + // if (snapshot.hasError) + // return invalidRss(); + // else if (snapshot.hasData) + // return SearchResult( + // onlinePodcast: snapshot.data, + // ); + // else + // return Container( + // padding: EdgeInsets.only(top: 200), + // alignment: Alignment.topCenter, + // child: CircularProgressIndicator(), + // ); + // }, + // ); + // else + // return FutureBuilder( + // future: getList(query), + // builder: (BuildContext context, AsyncSnapshot snapshot) { + // if (!snapshot.hasData && query != null) + // return Container( + // padding: EdgeInsets.only(top: 200), + // alignment: Alignment.topCenter, + // child: CircularProgressIndicator(), + // ); + // List content = snapshot.data; + // return ListView.builder( + // scrollDirection: Axis.vertical, + // itemCount: content.length, + // itemBuilder: (BuildContext context, int index) { + // return SearchResult( + // onlinePodcast: content[index], + // ); + // }, + // ); + // }, + // ); } @override @@ -257,7 +256,8 @@ class _SearchResultState extends State var subscribeWorker = Provider.of(context, listen: false); savePodcast(OnlinePodcast podcast) { - SubscribeItem item = SubscribeItem(podcast.rss, podcast.title, imgUrl: podcast.image); + SubscribeItem item = + SubscribeItem(podcast.rss, podcast.title, imgUrl: podcast.image); subscribeWorker.setSubscribeItem(item); } @@ -309,8 +309,7 @@ class _SearchResultState extends State child: !_issubscribe ? OutlineButton( highlightedBorderColor: context.accentColor, - splashColor: - context.accentColor.withOpacity(0.8), + splashColor: context.accentColor.withOpacity(0.8), child: Text('Subscribe', style: TextStyle( color: Theme.of(context).accentColor)), diff --git a/lib/home/home.dart b/lib/home/home.dart index d064e03..88b878b 100644 --- a/lib/home/home.dart +++ b/lib/home/home.dart @@ -447,256 +447,257 @@ class _RecentUpdateState extends State<_RecentUpdate> Widget build(BuildContext context) { super.build(context); var audio = Provider.of(context, listen: false); - return FutureBuilder>( - future: _getRssItem(_top, _group), - builder: (context, snapshot) { - if (snapshot.hasError) print(snapshot.error); - return (snapshot.hasData) - ? snapshot.data.length == 0 - ? Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(LineIcons.cloud_download_alt_solid, - size: 80, color: Colors.grey[500]), - Padding(padding: EdgeInsets.symmetric(vertical: 10)), - Text( - 'No episode received yet', - style: TextStyle(color: Colors.grey[500]), + return Selector( + selector: (_, worker) => worker.created, + builder: (context, created, child) { + return FutureBuilder>( + future: _getRssItem(_top, _group), + builder: (context, snapshot) { + if (snapshot.hasError) print(snapshot.error); + return (snapshot.hasData) + ? snapshot.data.length == 0 + ? Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(LineIcons.cloud_download_alt_solid, + size: 80, color: Colors.grey[500]), + Padding( + padding: EdgeInsets.symmetric(vertical: 10)), + Text( + 'No episode received yet', + style: TextStyle(color: Colors.grey[500]), + ) + ], + ), ) - ], - ), - ) - : NotificationListener( - onNotification: (ScrollNotification scrollInfo) { - if (scrollInfo.metrics.pixels == - scrollInfo.metrics.maxScrollExtent && - snapshot.data.length == _top) _loadMoreEpisode(); - return true; - }, - child: Selector( - selector: (_, worker) => worker.created, - builder: (context, created, child) { - return CustomScrollView( - key: PageStorageKey('update'), - physics: const AlwaysScrollableScrollPhysics(), - slivers: [ - SliverToBoxAdapter( - child: Container( - height: 40, - color: context.primaryColor, - child: Material( - color: Colors.transparent, - child: Row( - children: [ - Consumer( - builder: - (context, groupList, child) => - Material( - color: Colors.transparent, - child: PopupMenuButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all( - Radius.circular( - 10))), - elevation: 1, - tooltip: 'Groups fliter', - child: Container( - padding: - EdgeInsets.symmetric( - horizontal: 20), - height: 50, - child: Row( - mainAxisSize: - MainAxisSize.min, - children: [ - Text(_groupName), - Padding( - padding: EdgeInsets - .symmetric( - horizontal: - 5), - ), - Icon( - LineIcons - .filter_solid, - size: 18, - ) - ], - )), - itemBuilder: (context) => [ - PopupMenuItem( - child: Text('All'), - value: 'All') - ]..addAll(groupList.groups - .map< - PopupMenuEntry< - String>>((e) => - PopupMenuItem( - value: e.name, - child: - Text(e.name))) - .toList()), - onSelected: (value) { - if (value == 'All') { - setState(() { - _groupName = 'All'; - _group = ['All']; - }); - } else { - groupList.groups - .forEach((group) { - if (group.name == value) { - setState(() { - _groupName = value; - _group = - group.podcastList; - }); - } - }); - } - }, + : NotificationListener( + onNotification: (ScrollNotification scrollInfo) { + if (scrollInfo.metrics.pixels == + scrollInfo.metrics.maxScrollExtent && + snapshot.data.length == _top) + _loadMoreEpisode(); + return true; + }, + child: CustomScrollView( + key: PageStorageKey('update'), + physics: const AlwaysScrollableScrollPhysics(), + slivers: [ + SliverToBoxAdapter( + child: Container( + height: 40, + color: context.primaryColor, + child: Material( + color: Colors.transparent, + child: Row( + children: [ + Consumer( + builder: + (context, groupList, child) => + Material( + color: Colors.transparent, + child: PopupMenuButton( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all( + Radius.circular( + 10))), + elevation: 1, + tooltip: 'Groups fliter', + child: Container( + padding: + EdgeInsets.symmetric( + horizontal: 20), + height: 50, + child: Row( + mainAxisSize: + MainAxisSize.min, + children: [ + Text(_groupName), + Padding( + padding: EdgeInsets + .symmetric( + horizontal: + 5), + ), + Icon( + LineIcons + .filter_solid, + size: 18, + ) + ], + )), + itemBuilder: (context) => [ + PopupMenuItem( + child: Text('All'), + value: 'All') + ]..addAll(groupList.groups + .map< + PopupMenuEntry< + String>>((e) => + PopupMenuItem( + value: e.name, + child: + Text(e.name))) + .toList()), + onSelected: (value) { + if (value == 'All') { + setState(() { + _groupName = 'All'; + _group = ['All']; + }); + } else { + groupList.groups + .forEach((group) { + if (group.name == + value) { + setState(() { + _groupName = value; + _group = group + .podcastList; + }); + } + }); + } + }, + ), ), ), - ), - Spacer(), - FutureBuilder( - future: _getUpdateCounts(_group), - initialData: 0, - builder: (context, snapshot) { - return snapshot.data != 0 - ? Material( - color: - Colors.transparent, - child: IconButton( - tooltip: - 'Add new episodes to playlist', - icon: - // Icon(Icons.playlist_add), - SizedBox( - height: 16, - width: 21, - child: CustomPaint( - painter: AddToPlaylistPainter( - context - .textTheme.bodyText1.color, - Colors - .red))), - onPressed: - () async { - await audio - .addNewEpisode( - _group); - if (mounted) - setState(() {}); - Fluttertoast - .showToast( - msg: _groupName == - 'All' - ? '${snapshot.data} episode added to playlist' - : '${snapshot.data} episode in $_groupName added to playlist', - gravity: - ToastGravity - .BOTTOM, - ); - }), - ) - : Material( - color: - Colors.transparent, - child: IconButton( - tooltip: - 'Add new episodes to playlist', - icon: - // Icon(Icons.playlist_add), - SizedBox( - height: 16, - width: 21, - child: CustomPaint( - painter: AddToPlaylistPainter( - context - .textTheme - .bodyText1 - .color, - context - .textTheme - .bodyText1 - .color, - ))), - onPressed: () {}), - ); - }), - Material( - color: Colors.transparent, - child: IconButton( - tooltip: 'Change layout', - padding: EdgeInsets.zero, - onPressed: () { - if (_layout == Layout.three) - setState(() { - _layout = Layout.two; - }); - else - setState(() { - _layout = Layout.three; - }); - }, - icon: _layout == Layout.three - ? SizedBox( - height: 10, - width: 30, - child: CustomPaint( - painter: - LayoutPainter( - 0, - context - .textTheme - .bodyText1 - .color), + Spacer(), + FutureBuilder( + future: + _getUpdateCounts(_group), + initialData: 0, + builder: (context, snapshot) { + return snapshot.data != 0 + ? Material( + color: Colors + .transparent, + child: IconButton( + tooltip: + 'Add new episodes to playlist', + icon: + // Icon(Icons.playlist_add), + SizedBox( + height: + 16, + width: 21, + child: CustomPaint( + painter: AddToPlaylistPainter( + context.textTheme.bodyText1.color, + Colors.red))), + onPressed: () async { + await audio + .addNewEpisode( + _group); + if (mounted) + setState( + () {}); + Fluttertoast + .showToast( + msg: _groupName == + 'All' + ? '${snapshot.data} episode added to playlist' + : '${snapshot.data} episode in $_groupName added to playlist', + gravity: + ToastGravity + .BOTTOM, + ); + }), + ) + : Material( + color: Colors + .transparent, + child: IconButton( + tooltip: + 'Add new episodes to playlist', + icon: + // Icon(Icons.playlist_add), + SizedBox( + height: + 16, + width: 21, + child: CustomPaint( + painter: AddToPlaylistPainter( + context + .textTheme + .bodyText1 + .color, + context + .textTheme + .bodyText1 + .color, + ))), + onPressed: () {}), + ); + }), + Material( + color: Colors.transparent, + child: IconButton( + tooltip: 'Change layout', + padding: EdgeInsets.zero, + onPressed: () { + if (_layout == Layout.three) + setState(() { + _layout = Layout.two; + }); + else + setState(() { + _layout = Layout.three; + }); + }, + icon: _layout == Layout.three + ? SizedBox( + height: 10, + width: 30, + child: CustomPaint( + painter: LayoutPainter( + 0, + context + .textTheme + .bodyText1 + .color), + ), + ) + : SizedBox( + height: 10, + width: 30, + child: CustomPaint( + painter: LayoutPainter( + 1, + context + .textTheme + .bodyText1 + .color), + ), ), - ) - : SizedBox( - height: 10, - width: 30, - child: CustomPaint( - painter: - LayoutPainter( - 1, - context - .textTheme - .bodyText1 - .color), - ), - ), - )), - ], - ), - )), - ), - EpisodeGrid( - episodes: snapshot.data, - layout: _layout, - initNum: 9, - ), - SliverList( - delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - return _loadMore - ? Container( - height: 2, - child: LinearProgressIndicator()) - : Center(); - }, - childCount: 1, + )), + ], + ), + )), ), - ), - ]); - }, - )) - : Center(); - }, - ); + EpisodeGrid( + episodes: snapshot.data, + layout: _layout, + initNum: 9, + ), + SliverList( + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return _loadMore + ? Container( + height: 2, + child: LinearProgressIndicator()) + : Center(); + }, + childCount: 1, + ), + ), + ])) + : Center(); + }, + ); + }); } @override @@ -970,29 +971,31 @@ class _MyDownloadState extends State<_MyDownload> .toList() .reversed .toList(); - return episodes.length == 0 - ? SliverToBoxAdapter( - child: Padding( - padding: EdgeInsets.only(top: 100), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon(LineIcons.download_solid, - size: 80, color: Colors.grey[500]), - Padding(padding: EdgeInsets.symmetric(vertical: 10)), - Text( - 'No episode collected yet', - style: TextStyle(color: Colors.grey[500]), - ) - ], - ), - ), - ) - : EpisodeGrid( - episodes: episodes, - layout: _layout, - initNum: 0, - ); + return + //episodes.length == 0 + // ? SliverToBoxAdapter( + // child: Padding( + // padding: EdgeInsets.only(top: 100), + // child: Column( + // mainAxisAlignment: MainAxisAlignment.center, + // children: [ + // Icon(LineIcons.download_solid, + // size: 80, color: Colors.grey[500]), + // Padding(padding: EdgeInsets.symmetric(vertical: 10)), + // Text( + // 'No episode collected yet', + // style: TextStyle(color: Colors.grey[500]), + // ) + // ], + // ), + // ), + // ) + // : + EpisodeGrid( + episodes: episodes, + layout: _layout, + initNum: 0, + ); }, ), ], diff --git a/lib/state/subscribe_podcast.dart b/lib/state/subscribe_podcast.dart index ace68e5..ef61a60 100644 --- a/lib/state/subscribe_podcast.dart +++ b/lib/state/subscribe_podcast.dart @@ -36,7 +36,7 @@ class SubscribeWorker extends ChangeNotifier { SubscribeItem _subscribeItem; SubscribeItem _currentSubscribeItem = SubscribeItem('', ''); bool _created = false; - bool get created => _created; + bool get created=> _created; setSubscribeItem(SubscribeItem item) async { _subscribeItem = item; diff --git a/pubspec.yaml b/pubspec.yaml index 84881d2..513b38f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: tsacdop description: An easy-use podacasts player. -version: 0.3.0 +version: 0.3.1 environment: sdk: ">=2.6.0 <3.0.0" @@ -9,14 +9,9 @@ environment: dependencies: flutter: sdk: flutter - - cupertino_icons: ^0.1.3 - -dev_dependencies: - flutter_test: - sdk: flutter flutter_localizations: sdk: flutter + cupertino_icons: ^0.1.3 json_annotation: ^3.0.1 sqflite: ^1.3.0 flutter_html: ^0.11.1 @@ -55,43 +50,18 @@ dev_dependencies: line_icons: git: url: https://github.com/galonsos/line_icons.git + +dev_dependencies: + flutter_test: + sdk: flutter + dependency_overrides: - flutter_isolate: '1.0.0+13' - xml: '4.1.0' + flutter_isolate: "1.0.0+13" + xml: "4.1.0" flutter: assets: - assets/ - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. - # For details regarding adding assets from package dependencies, see - # https://flutter.io/assets-and-images/#from-packages - # To add custom fonts to your application, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.io/custom-fonts/#from-packages flutter_intl: enabled: true