0.6.3 - Playlist search, few other things i forgot
This commit is contained in:
parent
e9d97986b5
commit
e029c41b43
|
@ -19,6 +19,7 @@
|
|||
android:name="io.flutter.app.FlutterApplication"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="Freezer"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<service
|
||||
|
|
|
@ -326,7 +326,7 @@ public class Deezer {
|
|||
artists += ", " + artist;
|
||||
}
|
||||
tag.addField(FieldKey.ARTIST, artists.substring(2));
|
||||
tag.setField(FieldKey.TRACK, Integer.toString(publicTrack.getInt("track_position")));
|
||||
tag.setField(FieldKey.TRACK, String.format("%02d", publicTrack.getInt("track_position")));
|
||||
tag.setField(FieldKey.DISC_NO, Integer.toString(publicTrack.getInt("disk_number")));
|
||||
tag.setField(FieldKey.ALBUM_ARTIST, publicAlbum.getJSONObject("artist").getString("name"));
|
||||
tag.setField(FieldKey.YEAR, publicTrack.getString("release_date").substring(0, 4));
|
||||
|
|
|
@ -180,6 +180,11 @@ public class MainActivity extends FlutterActivity {
|
|||
intentPreload = null;
|
||||
return;
|
||||
}
|
||||
//Get architecture
|
||||
if (call.method.equals("arch")) {
|
||||
result.success(System.getProperty("os.arch"));
|
||||
return;
|
||||
}
|
||||
|
||||
result.error("0", "Not implemented!", "Not implemented!");
|
||||
})));
|
||||
|
|
|
@ -45,8 +45,6 @@ JNIEXPORT void JNICALL Java_f_f_freezer_Deezer_decryptFile(JNIEnv *env, jobject
|
|||
fwrite(decrypted, sizeof(unsigned char), sizeof(decrypted), ofile);
|
||||
} else {
|
||||
int written = fwrite(buffer, sizeof(unsigned char), (size_t)read, ofile);
|
||||
if (read != 2048)
|
||||
__android_log_print(ANDROID_LOG_WARN, "DECRYPTOR", "READ: %d, WRITE: %d", read, written);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="23.686956"
|
||||
android:viewportHeight="23.686956"
|
||||
android:tint="#FFFFFF">
|
||||
<group android:translateX="-0.15652174"
|
||||
android:translateY="-0.15652174">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M12,21.35l-1.45,-1.32C5.4,15.36 2,12.28 2,8.5 2,5.42 4.42,3 7.5,3c1.74,0 3.41,0.81 4.5,2.09C13.09,3.81 14.76,3 16.5,3 19.58,3 22,5.42 22,8.5c0,3.78 -3.4,6.86 -8.55,11.54L12,21.35z"/>
|
||||
</group>
|
||||
</vector>
|
Binary file not shown.
After Width: | Height: | Size: 418 B |
Binary file not shown.
After Width: | Height: | Size: 293 B |
Binary file not shown.
After Width: | Height: | Size: 546 B |
Binary file not shown.
After Width: | Height: | Size: 789 B |
|
@ -53,11 +53,14 @@ class Cache {
|
|||
@JsonKey(name: 'searchHistory2', toJson: _searchHistoryToJson, fromJson: _searchHistoryFromJson)
|
||||
List<SearchHistoryItem> searchHistory;
|
||||
|
||||
|
||||
//If download threads warning was shown
|
||||
@JsonKey(defaultValue: false)
|
||||
bool threadsWarning;
|
||||
|
||||
//Last time update check
|
||||
@JsonKey(defaultValue: 0)
|
||||
int lastUpdateCheck;
|
||||
|
||||
Cache({this.libraryTracks});
|
||||
|
||||
//Wrapper to test if track is favorite against cache
|
||||
|
|
|
@ -33,7 +33,8 @@ Cache _$CacheFromJson(Map<String, dynamic> json) {
|
|||
SortType.DEFAULT
|
||||
..searchHistory =
|
||||
Cache._searchHistoryFromJson(json['searchHistory2'] as List)
|
||||
..threadsWarning = json['threadsWarning'] as bool ?? false;
|
||||
..threadsWarning = json['threadsWarning'] as bool ?? false
|
||||
..lastUpdateCheck = json['lastUpdateCheck'] as int ?? 0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$CacheToJson(Cache instance) => <String, dynamic>{
|
||||
|
@ -48,6 +49,7 @@ Map<String, dynamic> _$CacheToJson(Cache instance) => <String, dynamic>{
|
|||
'trackSort': _$SortTypeEnumMap[instance.trackSort],
|
||||
'searchHistory2': Cache._searchHistoryToJson(instance.searchHistory),
|
||||
'threadsWarning': instance.threadsWarning,
|
||||
'lastUpdateCheck': instance.lastUpdateCheck,
|
||||
};
|
||||
|
||||
T _$enumDecode<T>(
|
||||
|
@ -94,6 +96,7 @@ const _$AlbumSortTypeEnumMap = {
|
|||
AlbumSortType.REVERSE: 'REVERSE',
|
||||
AlbumSortType.ALPHABETIC: 'ALPHABETIC',
|
||||
AlbumSortType.ARTIST: 'ARTIST',
|
||||
AlbumSortType.DATE: 'DATE',
|
||||
};
|
||||
|
||||
const _$ArtistSortTypeEnumMap = {
|
||||
|
|
|
@ -168,7 +168,8 @@ class DeezerAPI {
|
|||
return Artist.fromPrivateJson(
|
||||
data['results']['DATA'],
|
||||
topJson: data['results']['TOP'],
|
||||
albumsJson: data['results']['ALBUMS']
|
||||
albumsJson: data['results']['ALBUMS'],
|
||||
highlight: data['results']['HIGHLIGHT']
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ class Track {
|
|||
'favorite': (favorite??0)?1:0,
|
||||
'diskNumber': diskNumber,
|
||||
'explicit': explicit?1:0,
|
||||
'favoriteDate': favoriteDate
|
||||
// 'favoriteDate': favoriteDate
|
||||
};
|
||||
factory Track.fromSQL(Map<String, dynamic> data) => Track(
|
||||
id: data['trackId']??data['id'], //If loading from downloads table
|
||||
|
@ -174,7 +174,7 @@ class Track {
|
|||
favorite: (data['favorite'] == 1) ? true:false,
|
||||
diskNumber: data['diskNumber'],
|
||||
explicit: (data['explicit'] == 1) ? true:false,
|
||||
favoriteDate: data['favoriteDate']
|
||||
// favoriteDate: data['favoriteDate']
|
||||
);
|
||||
|
||||
factory Track.fromJson(Map<String, dynamic> json) => _$TrackFromJson(json);
|
||||
|
@ -238,7 +238,7 @@ class Album {
|
|||
'library': (library??false)?1:0,
|
||||
'type': AlbumType.values.indexOf(type),
|
||||
'releaseDate': releaseDate,
|
||||
'favoriteDate': favoriteDate
|
||||
// 'favoriteDate': favoriteDate
|
||||
};
|
||||
factory Album.fromSQL(Map<String, dynamic> data) => Album(
|
||||
id: data['id'],
|
||||
|
@ -255,13 +255,39 @@ class Album {
|
|||
library: (data['library'] == 1) ? true:false,
|
||||
type: AlbumType.values[data['type']],
|
||||
releaseDate: data['releaseDate'],
|
||||
favoriteDate: data['favoriteDate']
|
||||
// favoriteDate: data['favoriteDate']
|
||||
);
|
||||
|
||||
factory Album.fromJson(Map<String, dynamic> json) => _$AlbumFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AlbumToJson(this);
|
||||
}
|
||||
|
||||
enum ArtistHighlightType {
|
||||
ALBUM
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class ArtistHighlight {
|
||||
dynamic data;
|
||||
ArtistHighlightType type;
|
||||
String title;
|
||||
|
||||
ArtistHighlight({this.data, this.type, this.title});
|
||||
|
||||
factory ArtistHighlight.fromPrivateJson(Map<dynamic, dynamic> json) {
|
||||
if (json == null || json['ITEM'] == null) return null;
|
||||
switch (json['TYPE']) {
|
||||
case 'album':
|
||||
return ArtistHighlight(data: Album.fromPrivateJson(json['ITEM']), type: ArtistHighlightType.ALBUM, title: json['TITLE']);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//JSON
|
||||
factory ArtistHighlight.fromJson(Map<String, dynamic> json) => _$ArtistHighlightFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ArtistHighlightToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Artist {
|
||||
String id;
|
||||
|
@ -275,8 +301,9 @@ class Artist {
|
|||
bool library;
|
||||
bool radio;
|
||||
String favoriteDate;
|
||||
ArtistHighlight highlight;
|
||||
|
||||
Artist({this.id, this.name, this.albums, this.albumCount, this.topTracks, this.picture, this.fans, this.offline, this.library, this.radio, this.favoriteDate});
|
||||
Artist({this.id, this.name, this.albums, this.albumCount, this.topTracks, this.picture, this.fans, this.offline, this.library, this.radio, this.favoriteDate, this.highlight});
|
||||
|
||||
String get fansString => NumberFormat.compact().format(fans);
|
||||
|
||||
|
@ -285,6 +312,7 @@ class Artist {
|
|||
Map<dynamic, dynamic> json, {
|
||||
Map<dynamic, dynamic> albumsJson = const {},
|
||||
Map<dynamic, dynamic> topJson = const {},
|
||||
Map<dynamic, dynamic> highlight = null,
|
||||
bool library = false
|
||||
}) {
|
||||
//Get wether radio is available
|
||||
|
@ -301,7 +329,8 @@ class Artist {
|
|||
topTracks: (topJson['data']??[]).map<Track>((dynamic data) => Track.fromPrivateJson(data)).toList(),
|
||||
library: library,
|
||||
radio: _radio,
|
||||
favoriteDate: json['DATE_FAVORITE']
|
||||
favoriteDate: json['DATE_FAVORITE'],
|
||||
highlight: ArtistHighlight.fromPrivateJson(highlight)
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toSQL({off = false}) => {
|
||||
|
@ -315,7 +344,7 @@ class Artist {
|
|||
'offline': off?1:0,
|
||||
'library': (library??false)?1:0,
|
||||
'radio': radio?1:0,
|
||||
'favoriteDate': favoriteDate
|
||||
// 'favoriteDate': favoriteDate
|
||||
};
|
||||
factory Artist.fromSQL(Map<String, dynamic> data) => Artist(
|
||||
id: data['id'],
|
||||
|
@ -332,7 +361,7 @@ class Artist {
|
|||
offline: (data['offline'] == 1)?true:false,
|
||||
library: (data['library'] == 1)?true:false,
|
||||
radio: (data['radio'] == 1)?true:false,
|
||||
favoriteDate: data['favoriteDate']
|
||||
// favoriteDate: data['favoriteDate']
|
||||
);
|
||||
|
||||
factory Artist.fromJson(Map<String, dynamic> json) => _$ArtistFromJson(json);
|
||||
|
|
|
@ -129,6 +129,25 @@ const _$AlbumTypeEnumMap = {
|
|||
AlbumType.FEATURED: 'FEATURED',
|
||||
};
|
||||
|
||||
ArtistHighlight _$ArtistHighlightFromJson(Map<String, dynamic> json) {
|
||||
return ArtistHighlight(
|
||||
data: json['data'],
|
||||
type: _$enumDecodeNullable(_$ArtistHighlightTypeEnumMap, json['type']),
|
||||
title: json['title'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$ArtistHighlightToJson(ArtistHighlight instance) =>
|
||||
<String, dynamic>{
|
||||
'data': instance.data,
|
||||
'type': _$ArtistHighlightTypeEnumMap[instance.type],
|
||||
'title': instance.title,
|
||||
};
|
||||
|
||||
const _$ArtistHighlightTypeEnumMap = {
|
||||
ArtistHighlightType.ALBUM: 'ALBUM',
|
||||
};
|
||||
|
||||
Artist _$ArtistFromJson(Map<String, dynamic> json) {
|
||||
return Artist(
|
||||
id: json['id'] as String,
|
||||
|
@ -150,6 +169,9 @@ Artist _$ArtistFromJson(Map<String, dynamic> json) {
|
|||
library: json['library'] as bool,
|
||||
radio: json['radio'] as bool,
|
||||
favoriteDate: json['favoriteDate'] as String,
|
||||
highlight: json['highlight'] == null
|
||||
? null
|
||||
: ArtistHighlight.fromJson(json['highlight'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -165,6 +187,7 @@ Map<String, dynamic> _$ArtistToJson(Artist instance) => <String, dynamic>{
|
|||
'library': instance.library,
|
||||
'radio': instance.radio,
|
||||
'favoriteDate': instance.favoriteDate,
|
||||
'highlight': instance.highlight,
|
||||
};
|
||||
|
||||
Playlist _$PlaylistFromJson(Map<String, dynamic> json) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:disk_space/disk_space.dart';
|
||||
import 'package:filesize/filesize.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -271,6 +271,16 @@ const language_en_us = {
|
|||
"Authorization error!": "Authorization error!",
|
||||
"Logged out!": "Logged out!",
|
||||
"Lyrics": "Lyrics",
|
||||
"Player gradient background": "Player gradient background"
|
||||
"Player gradient background": "Player gradient background",
|
||||
|
||||
//0.6.3 Strings:
|
||||
"Updates": "Updates",
|
||||
"You are running latest version!": "You are running latest version!",
|
||||
"New update available!": "New update available!",
|
||||
"Current version: ": "Current version: ",
|
||||
"Unsupported platform!": "Unsupported platform!",
|
||||
"Freezer Updates": "Freezer Updates",
|
||||
"Update to latest version in the settings.": "Update to latest version in the settings.",
|
||||
"Release date": "Release date"
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:freezer/api/definitions.dart';
|
|||
import 'package:freezer/ui/library.dart';
|
||||
import 'package:freezer/ui/login_screen.dart';
|
||||
import 'package:freezer/ui/search.dart';
|
||||
import 'package:freezer/ui/updater.dart';
|
||||
import 'package:i18n_extension/i18n_widget.dart';
|
||||
import 'package:move_to_background/move_to_background.dart';
|
||||
import 'package:freezer/translations.i18n.dart';
|
||||
|
@ -172,6 +173,11 @@ class _MainScreenState extends State<MainScreen> with SingleTickerProviderStateM
|
|||
_loadPreloadInfo();
|
||||
_prepareQuickActions();
|
||||
|
||||
//Check for updates on background
|
||||
Future.delayed(Duration(seconds: 5), () {
|
||||
FreezerVersions.checkUpdate();
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ const supportedLocales = [
|
|||
const Locale('ur', 'PK'),
|
||||
const Locale('hi', 'IN'),
|
||||
const Locale('sk', 'SK'),
|
||||
const Locale('cs', 'CZ'),
|
||||
const Locale('fil', 'PH')
|
||||
];
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ class ArtistDetails extends StatelessWidget {
|
|||
rounded: true,
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width / 2 - 8,
|
||||
width: MediaQuery.of(context).size.width / 2 - 24,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
@ -410,6 +410,32 @@ class ArtistDetails extends StatelessWidget {
|
|||
),
|
||||
FreezerDivider(),
|
||||
Container(height: 12.0,),
|
||||
//Highlight
|
||||
if (artist.highlight != null)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 2.0),
|
||||
child: Text(
|
||||
artist.highlight.title,
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0
|
||||
),
|
||||
),
|
||||
),
|
||||
if (artist.highlight.type == ArtistHighlightType.ALBUM)
|
||||
AlbumTile(
|
||||
artist.highlight.data,
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => AlbumDetails(artist.highlight.data)));
|
||||
},
|
||||
),
|
||||
Container(height: 8.0)
|
||||
],
|
||||
),
|
||||
//Top tracks
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 2.0),
|
||||
|
|
|
@ -502,7 +502,8 @@ enum AlbumSortType {
|
|||
DEFAULT,
|
||||
REVERSE,
|
||||
ALPHABETIC,
|
||||
ARTIST
|
||||
ARTIST,
|
||||
DATE
|
||||
}
|
||||
|
||||
class LibraryAlbums extends StatefulWidget {
|
||||
|
@ -530,6 +531,9 @@ class _LibraryAlbumsState extends State<LibraryAlbums> {
|
|||
case AlbumSortType.ARTIST:
|
||||
albums.sort((a, b) => a.artists[0].name.toLowerCase().compareTo(b.artists[0].name.toLowerCase()));
|
||||
return albums;
|
||||
case AlbumSortType.DATE:
|
||||
albums.sort((a, b) => DateTime.parse(a.releaseDate).compareTo(DateTime.parse(b.releaseDate)));
|
||||
return albums;
|
||||
}
|
||||
return albums;
|
||||
}
|
||||
|
@ -581,6 +585,10 @@ class _LibraryAlbumsState extends State<LibraryAlbums> {
|
|||
value: AlbumSortType.ARTIST,
|
||||
child: Text('Artist'.i18n, style: popupMenuTextStyle()),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: AlbumSortType.DATE,
|
||||
child: Text('Release date'.i18n, style: popupMenuTextStyle()),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(width: 8.0),
|
||||
|
@ -829,14 +837,15 @@ class _LibraryPlaylistsState extends State<LibraryPlaylists> {
|
|||
List<Playlist> _playlists;
|
||||
PlaylistSortType _sort = PlaylistSortType.DEFAULT;
|
||||
ScrollController _scrollController = ScrollController();
|
||||
String _filter = '';
|
||||
|
||||
List<Playlist> get _sorted {
|
||||
List<Playlist> playlists = List.from(_playlists);
|
||||
List<Playlist> playlists = List.from(_playlists.where((p) => p.title.toLowerCase().contains(_filter.toLowerCase())));
|
||||
switch (_sort) {
|
||||
case PlaylistSortType.DEFAULT:
|
||||
return _playlists;
|
||||
return playlists;
|
||||
case PlaylistSortType.REVERSE:
|
||||
return _playlists.reversed.toList();
|
||||
return playlists.reversed.toList();
|
||||
case PlaylistSortType.USER:
|
||||
playlists.sort((a, b) => (a.user.name??deezerAPI.userName).toLowerCase().compareTo((b.user.name??deezerAPI.userName).toLowerCase()));
|
||||
return playlists;
|
||||
|
@ -923,6 +932,24 @@ class _LibraryPlaylistsState extends State<LibraryPlaylists> {
|
|||
child: ListView(
|
||||
controller: _scrollController,
|
||||
children: <Widget>[
|
||||
//Search
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: TextField(
|
||||
onChanged: (String s) => setState(() => _filter = s),
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Search'.i18n,
|
||||
fillColor: Theme.of(context).bottomAppBarColor,
|
||||
filled: true,
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey)
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Colors.grey)
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Create new playlist'.i18n),
|
||||
leading: LeadingIcon(Icons.playlist_add, color: Color(0xff009a85)),
|
||||
|
@ -965,7 +992,7 @@ class _LibraryPlaylistsState extends State<LibraryPlaylists> {
|
|||
),
|
||||
|
||||
if (_playlists != null)
|
||||
...List.generate(_playlists.length, (int i) {
|
||||
...List.generate(_sorted.length, (int i) {
|
||||
Playlist p = (_sorted??[])[i];
|
||||
return PlaylistTile(
|
||||
p,
|
||||
|
|
|
@ -16,6 +16,7 @@ import 'package:freezer/ui/downloads_screen.dart';
|
|||
import 'package:freezer/ui/elements.dart';
|
||||
import 'package:freezer/ui/error.dart';
|
||||
import 'package:freezer/ui/home_screen.dart';
|
||||
import 'package:freezer/ui/updater.dart';
|
||||
import 'package:i18n_extension/i18n_widget.dart';
|
||||
import 'package:language_pickers/language_pickers.dart';
|
||||
import 'package:language_pickers/languages.dart';
|
||||
|
@ -141,9 +142,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Updates'.i18n),
|
||||
leading: LeadingIcon(Icons.update, color: Color(0xff2ba766)),
|
||||
onTap: () => Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => UpdaterScreen()
|
||||
)),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('About'.i18n),
|
||||
leading: LeadingIcon(Icons.info, color: Color(0xff2ba766)),
|
||||
leading: LeadingIcon(Icons.info, color: Colors.grey),
|
||||
onTap: () => Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => CreditsScreen()
|
||||
)),
|
||||
|
@ -1282,9 +1290,6 @@ class _CreditsScreenState extends State<CreditsScreen> {
|
|||
ListTile(
|
||||
title: Text('Deemix'),
|
||||
subtitle: Text('Better app <3'),
|
||||
onTap: () {
|
||||
launch('https://codeberg.org/RemixDev/deemix');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Xandar Null'),
|
||||
|
|
|
@ -178,6 +178,7 @@ class PlaylistTile extends StatelessWidget {
|
|||
|
||||
String get subtitle {
|
||||
if (playlist.user == null || playlist.user.name == null || playlist.user.name == '' || playlist.user.id == deezerAPI.userId) {
|
||||
if (playlist.trackCount == null) return '';
|
||||
return '${playlist.trackCount} ' + 'Tracks'.i18n;
|
||||
}
|
||||
return playlist.user.name;
|
||||
|
@ -246,6 +247,7 @@ class PlaylistCardTile extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
height: 180.0,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
onLongPress: onHold,
|
||||
|
@ -290,6 +292,7 @@ class SmartTrackListTile extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 200.0,
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
|
@ -298,18 +301,43 @@ class SmartTrackListTile extends StatelessWidget {
|
|||
children: <Widget>[
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: CachedImage(
|
||||
child: Stack(
|
||||
children: [
|
||||
CachedImage(
|
||||
width: 128,
|
||||
height: 128,
|
||||
url: smartTrackList.cover.thumb,
|
||||
rounded: true,
|
||||
),
|
||||
Container(
|
||||
width: 128.0,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 6.0),
|
||||
child: Text(
|
||||
smartTrackList.title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
shadows: [
|
||||
Shadow(
|
||||
offset: Offset(1, 1),
|
||||
blurRadius: 2,
|
||||
color: Colors.black
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
Container(
|
||||
width: 144.0,
|
||||
child: Text(
|
||||
smartTrackList.title,
|
||||
maxLines: 1,
|
||||
smartTrackList.subtitle,
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
|
|
|
@ -0,0 +1,265 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:freezer/api/cache.dart';
|
||||
import 'package:freezer/api/download.dart';
|
||||
import 'package:freezer/ui/elements.dart';
|
||||
import 'package:freezer/translations.i18n.dart';
|
||||
import 'package:freezer/ui/error.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:open_file/open_file.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'dart:convert';
|
||||
|
||||
|
||||
class UpdaterScreen extends StatefulWidget {
|
||||
@override
|
||||
_UpdaterScreenState createState() => _UpdaterScreenState();
|
||||
}
|
||||
|
||||
class _UpdaterScreenState extends State<UpdaterScreen> {
|
||||
|
||||
bool _loading = true;
|
||||
bool _error = false;
|
||||
FreezerVersions _versions;
|
||||
String _current;
|
||||
String _arch;
|
||||
double _progress = 0.0;
|
||||
bool _buttonEnabled = true;
|
||||
|
||||
Future _load() async {
|
||||
//Load current version
|
||||
PackageInfo info = await PackageInfo.fromPlatform();
|
||||
setState(() => _current = info.version);
|
||||
|
||||
//Get architecture
|
||||
_arch = await DownloadManager.platform.invokeMethod("arch");
|
||||
if (_arch == 'armv8l')
|
||||
_arch = 'arm32';
|
||||
|
||||
//Load from website
|
||||
try {
|
||||
FreezerVersions versions = await FreezerVersions.fetch();
|
||||
setState(() {
|
||||
_versions = versions;
|
||||
_loading = false;
|
||||
});
|
||||
} catch (e, st) {
|
||||
print(e + st);
|
||||
_error = true;
|
||||
_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
FreezerDownload get _versionDownload {
|
||||
return _versions.versions[0].downloads.firstWhere((d) => d.version.toLowerCase().contains(_arch.toLowerCase()), orElse: () => null);
|
||||
}
|
||||
|
||||
Future _download() async {
|
||||
String url = _versionDownload.directUrl;
|
||||
//Start request
|
||||
http.Client client = new http.Client();
|
||||
http.StreamedResponse res = await client.send(http.Request('GET', Uri.parse(url)));
|
||||
int size = res.contentLength;
|
||||
//Open file
|
||||
String path = p.join((await getExternalStorageDirectory()).path, 'update.apk');
|
||||
File file = File(path);
|
||||
IOSink fileSink = file.openWrite();
|
||||
//Update progress
|
||||
Future.doWhile(() async {
|
||||
int received = await file.length();
|
||||
setState(() => _progress = received/size);
|
||||
return received != size;
|
||||
});
|
||||
//Pipe
|
||||
await res.stream.pipe(fileSink);
|
||||
fileSink.close();
|
||||
|
||||
OpenFile.open(path);
|
||||
setState(() => _buttonEnabled = true);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_load();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: FreezerAppBar('Updates'.i18n),
|
||||
body: ListView(
|
||||
children: [
|
||||
|
||||
if (_error)
|
||||
ErrorScreen(),
|
||||
|
||||
if (_loading)
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [CircularProgressIndicator()],
|
||||
),
|
||||
),
|
||||
|
||||
if (!_error && !_loading && _versions.latest == _current)
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
'You are running latest version!'.i18n,
|
||||
style: TextStyle(
|
||||
fontSize: 26.0
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
if (!_error && !_loading && _versions.latest != _current)
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
'New update available!'.i18n + ' ' + _versions.latest,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
Container(height: 8.0),
|
||||
Text(
|
||||
'Current version: ' + _current,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontStyle: FontStyle.italic
|
||||
),
|
||||
),
|
||||
Container(height: 8.0),
|
||||
FreezerDivider(),
|
||||
Container(height: 8.0),
|
||||
Text(
|
||||
'Changelog',
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 8),
|
||||
child: Text(
|
||||
_versions.versions[0].changelog,
|
||||
style: TextStyle(fontSize: 16.0),
|
||||
),
|
||||
),
|
||||
FreezerDivider(),
|
||||
Container(height: 8.0),
|
||||
//Available download
|
||||
if (_versionDownload != null)
|
||||
Column(children: [
|
||||
RaisedButton(
|
||||
child: Text('Download'.i18n + ' (${_versionDownload.version})'),
|
||||
onPressed: _buttonEnabled ? () {
|
||||
setState(() => _buttonEnabled = false);
|
||||
_download();
|
||||
}:null
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: LinearProgressIndicator(value: _progress),
|
||||
)
|
||||
]),
|
||||
//Unsupported arch
|
||||
if (_versionDownload == null)
|
||||
Text(
|
||||
'Unsupported platform!'.i18n + ' $_arch',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16.0),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class FreezerVersions {
|
||||
String latest;
|
||||
List<FreezerVersion> versions;
|
||||
|
||||
FreezerVersions({this.latest, this.versions});
|
||||
|
||||
factory FreezerVersions.fromJson(Map data) => FreezerVersions(
|
||||
latest: data['android']['latest'],
|
||||
versions: data['android']['versions'].map<FreezerVersion>((v) => FreezerVersion.fromJson(v)).toList()
|
||||
);
|
||||
|
||||
//Fetch from website API
|
||||
static Future<FreezerVersions> fetch() async {
|
||||
http.Response response = await http.get('https://freezer.life/api/versions');
|
||||
return FreezerVersions.fromJson(jsonDecode(response.body));
|
||||
}
|
||||
|
||||
static Future checkUpdate() async {
|
||||
//Check only each 24h
|
||||
int updateDelay = 86400000;
|
||||
if ((DateTime.now().millisecondsSinceEpoch - (cache.lastUpdateCheck??0)) < updateDelay) return;
|
||||
cache.lastUpdateCheck = DateTime.now().millisecondsSinceEpoch;
|
||||
await cache.save();
|
||||
|
||||
FreezerVersions versions = await FreezerVersions.fetch();
|
||||
|
||||
//Load current version
|
||||
PackageInfo info = await PackageInfo.fromPlatform();
|
||||
if (info.version == versions.latest) return;
|
||||
|
||||
//Get architecture
|
||||
String _arch = await DownloadManager.platform.invokeMethod("arch");
|
||||
if (_arch == 'armv8l')
|
||||
_arch = 'arm32';
|
||||
//Check compatible architecture
|
||||
if (versions.versions[0].downloads.firstWhere((d) => d.version.toLowerCase().contains(_arch.toLowerCase()), orElse: () => null) == null) return;
|
||||
|
||||
//Show notification
|
||||
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||
const AndroidInitializationSettings androidInitializationSettings = AndroidInitializationSettings('drawable/ic_logo');
|
||||
final InitializationSettings initializationSettings = InitializationSettings(androidInitializationSettings, null);
|
||||
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
|
||||
AndroidNotificationDetails androidNotificationDetails = AndroidNotificationDetails('freezerupdates', 'Freezer Updates'.i18n, 'Freezer Updates'.i18n);
|
||||
NotificationDetails notificationDetails = NotificationDetails(androidNotificationDetails, null);
|
||||
await flutterLocalNotificationsPlugin.show(0, 'New update available!'.i18n, 'Update to latest version in the settings.'.i18n, notificationDetails);
|
||||
}
|
||||
}
|
||||
|
||||
class FreezerVersion {
|
||||
String version;
|
||||
String changelog;
|
||||
List<FreezerDownload> downloads;
|
||||
|
||||
FreezerVersion({this.version, this.changelog, this.downloads});
|
||||
|
||||
factory FreezerVersion.fromJson(Map data) => FreezerVersion(
|
||||
version: data['version'],
|
||||
changelog: data['changelog'],
|
||||
downloads: data['downloads'].map<FreezerDownload>((d) => FreezerDownload.fromJson(d)).toList()
|
||||
);
|
||||
}
|
||||
|
||||
class FreezerDownload {
|
||||
String version;
|
||||
String directUrl;
|
||||
|
||||
FreezerDownload({this.version, this.directUrl});
|
||||
|
||||
factory FreezerDownload.fromJson(Map data) => FreezerDownload(
|
||||
version: data['version'],
|
||||
directUrl: data['links'].first['url']
|
||||
);
|
||||
}
|
62
pubspec.lock
62
pubspec.lock
|
@ -7,14 +7,14 @@ packages:
|
|||
name: _fe_analyzer_shared
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "11.0.0"
|
||||
version: "12.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.40.4"
|
||||
version: "0.40.6"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -77,14 +77,14 @@ packages:
|
|||
name: build_resolvers
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
version: "1.4.3"
|
||||
build_runner:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: build_runner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.10.3"
|
||||
version: "1.10.4"
|
||||
build_runner_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -112,7 +112,7 @@ packages:
|
|||
name: cached_network_image
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.2+1"
|
||||
version: "2.3.3"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -182,14 +182,14 @@ packages:
|
|||
name: connectivity_for_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.1+2"
|
||||
version: "0.3.1+4"
|
||||
connectivity_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: connectivity_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.0+5"
|
||||
version: "0.1.0+7"
|
||||
connectivity_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -245,7 +245,7 @@ packages:
|
|||
name: dart_style
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.7"
|
||||
version: "1.3.9"
|
||||
dio:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -288,6 +288,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0-nullsafety.1"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -559,7 +566,7 @@ packages:
|
|||
name: node_interop
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
version: "1.2.0"
|
||||
node_io:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -581,6 +588,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.0"
|
||||
open_file:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: open_file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -594,7 +608,7 @@ packages:
|
|||
name: package_info
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.4.3"
|
||||
version: "0.4.3+2"
|
||||
palette_generator:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -636,14 +650,14 @@ packages:
|
|||
name: path_provider_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.4+4"
|
||||
version: "0.0.4+6"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
version: "1.0.4"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -741,7 +755,7 @@ packages:
|
|||
name: quiver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
version: "2.1.5"
|
||||
random_string:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -769,7 +783,7 @@ packages:
|
|||
name: share
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.5+2"
|
||||
version: "0.6.5+4"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -795,7 +809,7 @@ packages:
|
|||
name: source_gen
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.9.7+1"
|
||||
version: "0.9.8"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -816,7 +830,7 @@ packages:
|
|||
name: sqflite
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.1+1"
|
||||
version: "1.3.2+1"
|
||||
sqflite_common:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -900,42 +914,42 @@ packages:
|
|||
name: url_launcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.7.4"
|
||||
version: "5.7.10"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+1"
|
||||
version: "0.0.1+4"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+8"
|
||||
version: "0.0.1+9"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
version: "1.0.9"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.4+1"
|
||||
version: "0.1.5+1"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+1"
|
||||
version: "0.0.1+3"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -986,5 +1000,5 @@ packages:
|
|||
source: hosted
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.10.0-110 <2.11.0"
|
||||
flutter: ">=1.20.0 <2.0.0"
|
||||
dart: ">=2.10.2 <2.11.0"
|
||||
flutter: ">=1.22.2 <2.0.0"
|
||||
|
|
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 0.6.2+1
|
||||
version: 0.6.3+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.8.0 <3.0.0"
|
||||
|
@ -72,6 +72,7 @@ dependencies:
|
|||
photo_view: ^0.10.2
|
||||
draggable_scrollbar: ^0.0.4
|
||||
scrobblenaut: ^2.0.4
|
||||
open_file: ^3.0.3
|
||||
|
||||
audio_session: ^0.0.9
|
||||
audio_service:
|
||||
|
|
Loading…
Reference in New Issue