Skip to content

Commit

Permalink
Merge branch 'release/v0.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanM04 committed Jan 24, 2020
2 parents fcb4eb4 + 01da375 commit cd620d6
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
flutter-version: 1.12.13+hotfix.5
- name: Google services
run: echo $GOOGLE_SERVICES > android/app/google-services.json
run: echo $GOOGLE_SERVICES | base64 --decode > android/app/google-services.json
env:
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
- run: flutter pub get
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Tengo problemas, no me peguen.
## Setup

1. Agregar `android/app/google-services.json` de Firebase. Firebase debe tener las aplicaciones `com.juanm04.animu` y `com.juanm04.animu.dev` con las llaves de desarrollo SHA
2. Agregar el `google-services.json` a modo de secreto al repositorio de GitHub.
2. Agregar el `google-services.json` a modo de secreto al repositorio de GitHub (`cat android/app/google-services.json | base64 | xclip -selection clipboard`).
3. Ejecturar `flutter pub get`.

## To-do
Expand Down
10 changes: 9 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'dart:async';

import 'package:animu/screens/browse.dart';
import 'package:animu/screens/saved_animes.dart';
import 'package:animu/screens/settings/settings.dart';
import 'package:animu/screens/splash_screen/splash_screen.dart';
import 'package:animu/services/backup.dart';
import 'package:animu/services/error.dart';
import 'package:animu/utils/notifiers.dart';
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:firebase_analytics/observer.dart';
Expand All @@ -18,7 +21,12 @@ class TabInfo {
TabInfo(this.title, this.icon, this.widget);
}

void main() => runApp(MyApp());
void main() {
runZoned(
() => runApp(MyApp()),
onError: ErrorService.report,
);
}

class MyApp extends StatelessWidget {
@override
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/settings/about.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:animu/utils/global.dart';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';
import 'package:share/share.dart';
Expand Down Expand Up @@ -41,7 +42,7 @@ class About extends StatelessWidget {
onPressed: () {
Share.share(
(shareMessages..shuffle()).first +
'\nDescargá Animú en https://animu.juanm04.com',
'\nDescargá Animú en ${Global.appUrl}',
);
},
),
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/splash_screen/splash_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:animu/screens/splash_screen/updater.dart';
import 'package:animu/utils/global.dart';
import 'package:animu/utils/models.dart';
import 'package:animu/utils/watching_states.dart';
import 'package:connectivity/connectivity.dart';
Expand Down Expand Up @@ -43,7 +44,7 @@ class _SplashScreenState extends State<SplashScreen> {
Future<void> checkUpdates() async {
var dio = new Dio();
var response = await dio
.get('https://api.github.com/repos/JuanM04/animu/releases/latest');
.get('https://api.github.com/repos/${Global.repo}/releases/latest');

Map lastRelease = response.data;

Expand Down
5 changes: 3 additions & 2 deletions lib/screens/splash_screen/updater.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:animu/services/error.dart';
import 'package:animu/widgets/dialog_button.dart';
import 'package:flutter/material.dart';
import 'package:ota_update/ota_update.dart';
Expand Down Expand Up @@ -37,8 +38,8 @@ class _UpdaterState extends State<Updater> {
});
},
);
} catch (e) {
print('Failed to make OTA update. Details: $e');
} catch (e, s) {
ErrorService.report(e, s);
}
}

Expand Down
9 changes: 5 additions & 4 deletions lib/services/backup.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:animu/services/error.dart';
import 'package:animu/services/requests.dart';
import 'package:animu/utils/helpers.dart';
import 'package:animu/utils/models.dart';
Expand Down Expand Up @@ -47,8 +48,8 @@ class BackupService {
}
}
return await user;
} catch (e) {
print(e);
} catch (e, s) {
ErrorService.report(e, s);
return null;
}
}
Expand All @@ -57,8 +58,8 @@ class BackupService {
try {
await _auth.signOut();
return true;
} catch (e) {
print(e);
} catch (e, s) {
ErrorService.report(e, s);
return false;
}
}
Expand Down
34 changes: 34 additions & 0 deletions lib/services/error.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:animu/utils/global.dart';
import 'package:sentry/sentry.dart';

class ErrorService {
static final _sentry = SentryClient(dsn: Global.errorsDSN);

static bool get isInDebugMode {
// Assume you're in production mode.
bool inDebugMode = false;

// Assert expressions are only evaluated during development. They are ignored
// in production. Therefore, this code only sets `inDebugMode` to true
// in a development environment.
assert(inDebugMode = true);

return inDebugMode;
}

static void report(Object e, StackTrace s) {
try {
if (isInDebugMode) {
print(e);
} else {
_sentry.captureException(
exception: e,
stackTrace: s,
);
}
} catch (sentryError) {
print('Sending report to sentry.io failed: $sentryError');
print('Original error: $e');
}
}
}
26 changes: 14 additions & 12 deletions lib/services/requests.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'dart:convert';

import 'package:animu/services/error.dart';
import 'package:animu/utils/global.dart';
import 'package:animu/utils/models.dart';
import 'package:dio/dio.dart';
import 'package:graphql/client.dart';

class RequestsService {
static final _httpLink =
HttpLink(uri: 'https://animeflv.juanm04.com/graphql');
static final _httpLink = HttpLink(uri: Global.requestsEndpoint);
static final _client = GraphQLClient(
cache: InMemoryCache(),
link: _httpLink,
Expand Down Expand Up @@ -40,8 +41,9 @@ class RequestsService {
},
);
return response.data['episodeSources'];
} catch (e) {
return await getEpisodeSources(animeSlug: animeSlug, episode: episode);
} catch (e, s) {
ErrorService.report(e, s);
return null;
}
}

Expand Down Expand Up @@ -75,8 +77,8 @@ class RequestsService {
),
),
);
} catch (e) {
print(e);
} catch (e, s) {
ErrorService.report(e, s);
return null;
}
}
Expand All @@ -87,8 +89,8 @@ class RequestsService {
await new Dio().get(url.replaceFirst('embed.php', 'check.php'));

return response.data;
} catch (e) {
print(e);
} catch (e, s) {
ErrorService.report(e, s);
return null;
}
}
Expand All @@ -113,8 +115,8 @@ class RequestsService {
return new List<Anime>.from(
animes.map((map) => Anime.fromMap(map)),
);
} catch (e) {
print(e);
} catch (e, s) {
ErrorService.report(e, s);
return null;
}
}
Expand All @@ -139,8 +141,8 @@ class RequestsService {
);

return Anime.fromMap(response.data['anime']);
} catch (e) {
print(e);
} catch (e, s) {
ErrorService.report(e, s);
return null;
}
}
Expand Down
7 changes: 7 additions & 0 deletions lib/utils/global.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Global {
static final appUrl = 'https://animu.juanm04.com';
static final requestsEndpoint = 'https://animeflv.juanm04.com/graphql';
static final errorsDSN =
'https://c67cfc459f304dac8f043c3bad519336@sentry.io/1898336';
static final repo = 'JuanM04/animu';
}
4 changes: 3 additions & 1 deletion lib/utils/notifiers.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:convert';

import 'package:animu/services/error.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

Expand Down Expand Up @@ -38,7 +39,8 @@ class VLCNotifier with ChangeNotifier {
}),
);
return jsonDecode(response.data);
} catch (e) {
} catch (e, s) {
ErrorService.report(e, s);
return null;
}
}
Expand Down
14 changes: 14 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.5"
sentry:
dependency: "direct main"
description:
name: sentry
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0+1"
share:
dependency: "direct main"
description:
Expand Down Expand Up @@ -686,6 +693,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
usage:
dependency: transitive
description:
name: usage
url: "https://pub.dartlang.org"
source: hosted
version: "3.4.1"
uuid_enhanced:
dependency: transitive
description:
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Ver anime sin complicaciones.
# 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.8.1
version: 0.8.2

environment:
sdk: ">=2.6.0 <3.0.0"
Expand Down Expand Up @@ -39,6 +39,7 @@ dependencies:
provider: ^4.0.2
pub_semver: ^1.4.2
screen: ^0.0.5
sentry: ^3.0.0+1
share: ^0.6.3+5
video_player: ^0.10.5+2

Expand Down

0 comments on commit cd620d6

Please # to comment.