0.6.11 - noone cares or reads this anyway, the repo is for issues, and the code so bad, it's practically obfuscated

This commit is contained in:
exttex 2021-04-16 20:21:35 +02:00
parent 9f850a6f30
commit aa7f82b399
11 changed files with 111 additions and 31 deletions

View File

@ -634,14 +634,19 @@ class HomePageSection {
);
String layout = json['layout'];
//No ads there
if (layout == 'ads') return null;
if (layout == 'horizontal-grid' || layout == 'grid') {
switch (layout) {
case 'ads':
return null;
case 'horizontal-grid':
hps.layout = HomePageSectionLayout.ROW;
} else {
//Currently only row layout
break;
case 'grid':
hps.layout = HomePageSectionLayout.GRID;
break;
default:
return null;
}
//Parse items
for (var i in (json['items']??[])) {
HomePageItem hpi = HomePageItem.fromPrivateJson(i);
@ -747,7 +752,8 @@ enum HomePageItemType {
}
enum HomePageSectionLayout {
ROW
ROW,
GRID
}
enum RepeatType {

View File

@ -368,6 +368,7 @@ Map<String, dynamic> _$HomePageSectionToJson(HomePageSection instance) =>
const _$HomePageSectionLayoutEnumMap = {
HomePageSectionLayout.ROW: 'ROW',
HomePageSectionLayout.GRID: 'GRID',
};
DeezerChannel _$DeezerChannelFromJson(Map<String, dynamic> json) {

View File

@ -392,13 +392,18 @@ class DownloadManager {
for (Track t in tracks) {
//Check if library
List rawTrack = await db.query('Tracks', where: 'id == ?', whereArgs: [t.id], columns: ['favorite']);
if (rawTrack.length > 0 && rawTrack[0]['favorite'] == 0) {
if (rawTrack.length > 0) {
//Count occurrences in playlists and albums
List albums = await db.rawQuery('SELECT (id) FROM Albums WHERE tracks LIKE "%${t.id}%"');
List playlists = await db.rawQuery('SELECT (id) FROM Playlists WHERE tracks LIKE "%${t.id}%"');
if (albums.length + playlists.length == 0) {
if (albums.length + playlists.length == 0 && rawTrack[0]['favorite'] == 0) {
//Safe to remove
await db.delete('Tracks', where: 'id == ?', whereArgs: [t.id]);
} else {
await db.update('Tracks', {'offline': 0}, where: 'id == ?', whereArgs: [t.id]);
}
}
//Remove file
try {
File(p.join(offlinePath, t.id)).delete();
@ -407,8 +412,6 @@ class DownloadManager {
}
}
}
}
}
Future removeOfflineAlbum(String id) async {
//Get album

View File

@ -619,6 +619,8 @@ class AudioPlayerTask extends BackgroundAudioTask {
@override
Future onUpdateQueue(List<MediaItem> q) async {
//just_audio
_shuffle = false;
_originalQueue = null;
_player.stop();
if (_audioSource != null) _audioSource.clear();
//Filter duplicate IDs

File diff suppressed because one or more lines are too long

View File

@ -373,6 +373,11 @@ const language_en_us = {
"Options": "Options",
"Invalid/Unsupported URL": "Invalid/Unsupported URL",
"Please wait...": "Please wait...",
"Login using email": "Login using email"
"Login using email": "Login using email",
//0.6.11, offline text OCD lol
"Track removed from offline!": "Track removed from offline!",
"Removed album from offline!": "Removed album from offline!",
"Playlist removed from offline!": "Playlist removed from offline!"
}
};

View File

@ -286,6 +286,7 @@ class _MakeAlbumOfflineState extends State<MakeAlbumOffline> {
return;
}
downloadManager.removeOfflineAlbum(widget.album.id);
Fluttertoast.showToast(msg: "Removed album from offline!".i18n, gravity: ToastGravity.BOTTOM, toastLength: Toast.LENGTH_SHORT);
setState(() {
_offline = false;
});
@ -1098,6 +1099,7 @@ class _MakePlaylistOfflineState extends State<MakePlaylistOffline> {
return;
}
downloadManager.removeOfflinePlaylist(widget.playlist.id);
Fluttertoast.showToast(msg: "Playlist removed from offline!".i18n, gravity: ToastGravity.BOTTOM, toastLength: Toast.LENGTH_SHORT);
setState(() {
_offline = false;
});

View File

@ -145,16 +145,23 @@ class _HomePageScreenState extends State<HomePageScreen> {
return ErrorScreen();
return Column(
children: List.generate(_homePage.sections.length, (i) {
return HomepageSectionWidget(_homePage.sections[i]);
switch (_homePage.sections[i].layout) {
case HomePageSectionLayout.ROW:
return HomepageRowSection(_homePage.sections[i]);
case HomePageSectionLayout.GRID:
return HomePageGridSection(_homePage.sections[i]);
default:
return HomepageRowSection(_homePage.sections[i]);
}
},
));
}
}
class HomepageSectionWidget extends StatelessWidget {
class HomepageRowSection extends StatelessWidget {
final HomePageSection section;
HomepageSectionWidget(this.section);
HomepageRowSection(this.section);
@override
Widget build(BuildContext context) {
@ -213,6 +220,41 @@ class HomepageSectionWidget extends StatelessWidget {
}
}
class HomePageGridSection extends StatelessWidget {
final HomePageSection section;
HomePageGridSection(this.section);
@override
Widget build(BuildContext context) {
return ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
title: Padding(
padding: EdgeInsets.symmetric(vertical: 4.0, horizontal: 6.0),
child: Text(
section.title??'',
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w900
),
),
),
subtitle: Wrap(
alignment: WrapAlignment.spaceAround,
children: List.generate(section.items.length, (i) {
//Item
return HomePageItemWidget(section.items[i]);
}),
),
);
}
}
class HomePageItemWidget extends StatelessWidget {

View File

@ -323,6 +323,7 @@ class MenuSheet {
onTap: () async {
if (isOffline) {
await downloadManager.removeOfflineTracks([track]);
Fluttertoast.showToast(msg: "Track removed from offline!".i18n, gravity: ToastGravity.BOTTOM, toastLength: Toast.LENGTH_SHORT);
} else {
await downloadManager.addOfflineTrack(track, private: true, context: context);
}

View File

@ -77,13 +77,18 @@ class PlayerBar extends StatelessWidget {
overflow: TextOverflow.clip,
maxLines: 1,
),
trailing: Row(
trailing: IconTheme(
data: IconThemeData(
color: settings.isDark ? Colors.white : Colors.grey[600]
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
PrevNextButton(iconSize, prev: true, hidePrev: true,),
PlayPauseButton(iconSize),
PrevNextButton(iconSize)
],
),
)
),
),

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:audio_service/audio_service.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:freezer/api/cache.dart';
import 'package:freezer/api/deezer.dart';
import 'package:freezer/api/download.dart';
@ -379,6 +380,18 @@ class _PlayerScreenVerticalState extends State<PlayerScreenVertical> {
updateColor();
},
),
IconButton(
icon: Icon(Icons.file_download),
onPressed: () async {
Track t = Track.fromMediaItem(AudioService.currentMediaItem);
if (await downloadManager.addOfflineTrack(t, private: false, context: context, isSingleton: true) != false)
Fluttertoast.showToast(
msg: 'Downloads added!'.i18n,
gravity: ToastGravity.BOTTOM,
toastLength: Toast.LENGTH_SHORT
);
},
),
QualityInfoWidget(),
RepeatButton(ScreenUtil().setWidth(46)),
PlayerMenuButton()