Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jei committed Jun 17, 2020
2 parents 0d30615 + 472c2b6 commit 9684f97
Show file tree
Hide file tree
Showing 29 changed files with 636 additions and 186 deletions.
48 changes: 48 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Contributing to Tormented Player
I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer

## Develop with Github
I use github to host code, to track issues and feature requests, as well as accept pull requests.

## Report bugs using Github's [issues](https://github.com/Jei/tormentedplayer/issues)
I use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/Jei/tormentedplayer/issues); it's that easy!
Alternatively, you can send an email to [[email protected]](mailto:[email protected]).

## Write bug reports with detail, background, and sample code

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

People *love* thorough bug reports. I'm not even kidding.

## I Use [GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (I use [GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)). I actively welcome your pull requests:

1. Fork the repo and create your branch from `develop`.
2. If you've added code that should be tested, add tests.
3. Run `flutter test` and ensure the test suite passes.
4. Make sure your code lints.
5. Issue that pull request!

## Use a Consistent Coding Style
I haven't set up strict checks on code style yet. In the meantime, I ask you to enable linting in your editor (it should already be enabled by default on Android Studio) and lint your code before submitting a PR.

## Keep it simple

The less changes you want to merge, the easier it will be to review them. Prefer multiple small PRs to a single monolithic PR.

## Any contributions you make will be under the BSD 3-Clause license
In short, when you submit code changes, your submissions are understood to be under the same [BSD 3-Clause License](https://github.com/Jei/tormentedplayer/blob/master/LICENSE) that covers Flutter and this project. Feel free to contact me if that's a concern.
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# tormentedplayer
# Tormented Player

A Flutter client for Tormented Radio
Tormented Player is the unofficial mobile version of [Tormented Radio](https://tormentedradio.com/) by [@djdead](https://twitter.com/djdead).
Listen to your favourite industrial, EBM and synthpop music on your Android device.

## Getting Started
## Features

This project is a starting point for a Flutter application.
- Ads free;
- Album name and cover art provided by Last.fm;
- See a list of recently played songs;
- Play/stop the radio from the media notification.

A few resources to get you started if this is your first Flutter project:
## Feedbacks

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
For feedbacks and bug reports please submit an issue here following the guidelines in [CONTRIBUTING.md](https://github.com/Jei/tormentedplayer/blob/develop/CONTRIBUTING.md), or send and email to [[email protected]](mailto:[email protected]).

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
## Contributing

Read [CONTRIBUTING.md](https://github.com/Jei/tormentedplayer/blob/develop/CONTRIBUTING.md) to know how you can help developing this project.

## Support

This app is free. I will never ask you for money to use it or any of its features. I will not put ads in it either.

If you would like to support my work, consider [buying me a coffee](https://ko-fi.com/andreajonus)!
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ android {
applicationId "me.jonus.tormentedplayer"
minSdkVersion 16
targetSdkVersion 28
ndkVersion "21.1.6352462"
ndkVersion "21.2.6472646"
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
This is the initial release of the app.

If you enjoy Tormented Player, please leave a review. To report technical issues or for general inquiries, send an email to [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Listen to your favourite industrial, EBM and synthpop music on your Android devi

<h2><b>Features:</b></h2>
• Ads free;
• See a list of recently played songs;
• Album name and cover art provided by <a href="https://www.last.fm/home">Last.fm</a>;
• Play/stop the radio from the media notification;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions functions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 36 additions & 3 deletions lib/blocs/radio_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

import 'package:http/http.dart' show Client;
import 'package:rxdart/rxdart.dart';
import 'package:tormentedplayer/models/history_item.dart';
import 'package:tormentedplayer/models/track.dart';
import 'package:tormentedplayer/resources/repository.dart';
import 'package:tormentedplayer/services/audio.dart';
Expand All @@ -13,16 +14,37 @@ class RadioBloc {

final BehaviorSubject<Track> _apiTrackSubject = BehaviorSubject<Track>();
final BehaviorSubject<Track> _trackSubject = BehaviorSubject<Track>();
final BehaviorSubject<List<HistoryItem>> _historySubject =
BehaviorSubject<List<HistoryItem>>();

RadioBloc() {
// Stream of the current Track from the API (when the radio is off)
_apiTrackSubject.addStream(
ConcatStream([
Stream.value(null),
Stream.periodic(Duration(seconds: 10)),
// FIXME there must be a better way to wait for the radio service to be connected
Stream.fromFuture(Future.delayed(Duration(seconds: 2))),
Stream.periodic(Duration(seconds: 20)),
])
.where(_canFetch)
.switchMap((_) => Stream.fromFuture(_repository.fetchCurrentTrack()))
.transform(StreamTransformer<Track, Track>.fromHandlers(
handleData: (track, sink) async {
final currentTrack = _trackSubject.value;

// Request full data only if the track changed
if (track.title != currentTrack?.title ||
track.artist != currentTrack?.artist) {
try {
final fullTrack =
await _repository.fetchTrack(track.title, track.artist);
sink.add(fullTrack);
} catch (err) {
print(err);
sink.add(track);
}
}
},
))
// Check again for Audio activity, since the API call may complete later
.where(_canFetch),
cancelOnError: false,
Expand All @@ -43,12 +65,18 @@ class RadioBloc {
handleError: (err, trace, sink) {
print('Error while getting the current track: $err');
sink.add(Track());
throw(err);
throw err;
},
))
.distinct(_compareTracks),
cancelOnError: false,
); // Emit only when we have a different track

// Fetch the history every time we have a new track
_historySubject.addStream(
_trackSubject.stream.asyncMap((_) => _repository.fetchHistory()),
cancelOnError: false,
);
}

bool _validateTrack(Track track) =>
Expand Down Expand Up @@ -85,12 +113,17 @@ class RadioBloc {

RadioPlaybackState get playbackState => _radio.playbackState;

Stream<List<HistoryItem>> get historyStream => _historySubject.stream;

List<HistoryItem> get history => _historySubject.value;

startRadio() => _radio.start();

stopRadio() => _radio.stop();

dispose() {
_apiTrackSubject.close();
_trackSubject.close();
_historySubject.close();
}
}
10 changes: 8 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:audio_service/audio_service.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_analytics/observer.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:preferences/preferences.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -38,6 +39,10 @@ class MyAppState extends State<MyApp> {

@override
void initState() {
if (kDebugMode) {
analytics.setAnalyticsCollectionEnabled(false);
}

analytics.logAppOpen();

super.initState();
Expand All @@ -57,7 +62,8 @@ class MyAppState extends State<MyApp> {
providers: [
ChangeNotifierProvider<AppThemeMode>(
create: (context) => AppThemeMode(
initialValue: ThemeMode.values[PrefService.getInt('theme') ?? 0],
initialValue: ThemeMode.values[PrefService.getInt('theme') ??
AppThemeMode.defaultThemeMode.index],
),
),
Provider<RadioBloc>.value(
Expand All @@ -70,7 +76,7 @@ class MyAppState extends State<MyApp> {
title: 'Tormented Player',
theme: lightTheme,
darkTheme: darkTheme,
themeMode: appMode?.currentMode ?? ThemeMode.system,
themeMode: appMode?.currentMode ?? AppThemeMode.defaultThemeMode,
navigatorObservers: [
FirebaseAnalyticsObserver(analytics: analytics),
],
Expand Down
4 changes: 3 additions & 1 deletion lib/models/app_theme_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import 'package:flutter/material.dart';
class AppThemeMode extends ChangeNotifier {
ThemeMode _currentMode;

AppThemeMode({ ThemeMode initialValue = ThemeMode.system }) {
static const defaultThemeMode = ThemeMode.dark;

AppThemeMode({ ThemeMode initialValue = defaultThemeMode }) {
_currentMode = initialValue;
}

Expand Down
Loading

0 comments on commit 9684f97

Please sign in to comment.