welcome: crash reporting opt-out
This commit is contained in:
parent
fe12767b4a
commit
ebe02f4dfb
4 changed files with 35 additions and 10 deletions
|
@ -7,6 +7,7 @@ import 'package:aves/widgets/home_page.dart';
|
|||
import 'package:aves/widgets/welcome_page.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:overlay_support/overlay_support.dart';
|
||||
|
@ -47,7 +48,16 @@ class _AvesAppState extends State<AvesApp> {
|
|||
}
|
||||
|
||||
Future<void> _setup() async {
|
||||
await Firebase.initializeApp().then((app) => FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError);
|
||||
await Firebase.initializeApp().then((app) {
|
||||
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
|
||||
FirebaseCrashlytics.instance.setCustomKey(
|
||||
'build_mode',
|
||||
kReleaseMode
|
||||
? 'release'
|
||||
: kProfileMode
|
||||
? 'profile'
|
||||
: 'debug');
|
||||
});
|
||||
await settings.init();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class Settings extends ChangeNotifier {
|
|||
|
||||
set hasAcceptedTerms(bool newValue) => setAndNotify(hasAcceptedTermsKey, newValue);
|
||||
|
||||
bool get isCrashlyticsEnabled => getBoolOrDefault(isCrashlyticsEnabledKey, false);
|
||||
bool get isCrashlyticsEnabled => getBoolOrDefault(isCrashlyticsEnabledKey, true);
|
||||
|
||||
set isCrashlyticsEnabled(bool newValue) {
|
||||
setAndNotify(isCrashlyticsEnabledKey, newValue);
|
||||
|
|
|
@ -14,6 +14,7 @@ import 'package:aves/widgets/common/data_providers/media_store_collection_provid
|
|||
import 'package:aves/widgets/common/routes.dart';
|
||||
import 'package:aves/widgets/filter_grids/albums_page.dart';
|
||||
import 'package:aves/widgets/fullscreen/fullscreen_page.dart';
|
||||
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:pedantic/pedantic.dart';
|
||||
|
@ -94,6 +95,7 @@ class _HomePageState extends State<HomePage> {
|
|||
_shortcutFilters = extraFilters != null ? (extraFilters as List).cast<String>() : null;
|
||||
}
|
||||
}
|
||||
unawaited(FirebaseCrashlytics.instance.setCustomKey('app_mode', AvesApp.mode.toString()));
|
||||
|
||||
if (AvesApp.mode != AppMode.view) {
|
||||
_mediaStore = MediaStoreSource();
|
||||
|
|
|
@ -52,6 +52,7 @@ class _WelcomePageState extends State<WelcomePage> {
|
|||
children: [
|
||||
..._buildTop(context),
|
||||
Flexible(child: _buildTerms(terms)),
|
||||
SizedBox(height: 16),
|
||||
..._buildBottomControls(context),
|
||||
],
|
||||
),
|
||||
|
@ -92,12 +93,23 @@ class _WelcomePageState extends State<WelcomePage> {
|
|||
}
|
||||
|
||||
List<Widget> _buildBottomControls(BuildContext context) {
|
||||
final checkbox = LabeledCheckbox(
|
||||
key: Key('agree-checkbox'),
|
||||
final checkboxes = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
LabeledCheckbox(
|
||||
value: settings.isCrashlyticsEnabled,
|
||||
onChanged: (v) => setState(() => settings.isCrashlyticsEnabled = v),
|
||||
text: 'Allow anonymous crash reporting',
|
||||
),
|
||||
LabeledCheckbox(
|
||||
key: Key('agree-termsCheckbox'),
|
||||
value: _hasAcceptedTerms,
|
||||
onChanged: (v) => setState(() => _hasAcceptedTerms = v),
|
||||
text: 'I agree to the terms and conditions',
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final button = RaisedButton(
|
||||
key: Key('continue-button'),
|
||||
child: Text('Continue'),
|
||||
|
@ -114,16 +126,17 @@ class _WelcomePageState extends State<WelcomePage> {
|
|||
}
|
||||
: null,
|
||||
);
|
||||
|
||||
return MediaQuery.of(context).orientation == Orientation.portrait
|
||||
? [
|
||||
checkbox,
|
||||
checkboxes,
|
||||
button,
|
||||
]
|
||||
: [
|
||||
SizedBox(height: 16),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
checkbox,
|
||||
checkboxes,
|
||||
Spacer(),
|
||||
button,
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue