mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-04-30 05:54:26 +02:00
feat: make firebase crashlytics optional.
This commit is contained in:
parent
79aca0e579
commit
f31a60d9bb
@ -106,7 +106,7 @@
|
|||||||
"teamSectionTitle": "Team",
|
"teamSectionTitle": "Team",
|
||||||
"infoSectionTitle": "Info",
|
"infoSectionTitle": "Info",
|
||||||
"advancedSectionTitle": "Advanced",
|
"advancedSectionTitle": "Advanced",
|
||||||
"privacySectionTitle": "Privacy",
|
"logsSectionTitle": "Logs",
|
||||||
"darkThemeLabel": "Dark Mode",
|
"darkThemeLabel": "Dark Mode",
|
||||||
"darkThemeHint": "Welcome to the Dark Side",
|
"darkThemeHint": "Welcome to the Dark Side",
|
||||||
"dynamicThemeLabel": "Material You",
|
"dynamicThemeLabel": "Material You",
|
||||||
@ -134,6 +134,8 @@
|
|||||||
"snackbarMessage": "Copied to clipboard",
|
"snackbarMessage": "Copied to clipboard",
|
||||||
"sentryLabel": "Sentry Logging",
|
"sentryLabel": "Sentry Logging",
|
||||||
"sentryHint": "Send anonymous logs to help us improve ReVanced Manager",
|
"sentryHint": "Send anonymous logs to help us improve ReVanced Manager",
|
||||||
|
"firebaseCrashlyticsLabel": "Firebase Crashlytics",
|
||||||
|
"firebaseCrashlyticsHint": "Send anonymous crash reports to help us improve ReVanced Manager",
|
||||||
"restartAppForChanges": "Restart the app to apply changes"
|
"restartAppForChanges": "Restart the app to apply changes"
|
||||||
},
|
},
|
||||||
"appInfoView": {
|
"appInfoView": {
|
||||||
|
@ -23,12 +23,24 @@ Future main() async {
|
|||||||
await locator<ManagerAPI>().initialize();
|
await locator<ManagerAPI>().initialize();
|
||||||
String apiUrl = locator<ManagerAPI>().getApiUrl();
|
String apiUrl = locator<ManagerAPI>().getApiUrl();
|
||||||
await locator<RevancedAPI>().initialize(apiUrl);
|
await locator<RevancedAPI>().initialize(apiUrl);
|
||||||
// Remove this line if you are building from source and don't have firebase
|
|
||||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
||||||
bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
|
bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
|
||||||
|
bool isCrashlyticsEnabled = locator<ManagerAPI>().isCrashlyticsEnabled();
|
||||||
|
// Remove this line if you are building from source and don't have firebase config
|
||||||
|
if (isCrashlyticsEnabled) {
|
||||||
|
await Firebase.initializeApp(
|
||||||
|
options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
);
|
||||||
|
Firebase.app().setAutomaticDataCollectionEnabled(true);
|
||||||
|
}
|
||||||
|
await Firebase.initializeApp(
|
||||||
|
options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
);
|
||||||
|
Firebase.app().setAutomaticDataCollectionEnabled(false);
|
||||||
locator<GithubAPI>().initialize();
|
locator<GithubAPI>().initialize();
|
||||||
await locator<PatcherAPI>().initialize();
|
await locator<PatcherAPI>().initialize();
|
||||||
tz.initializeTimeZones();
|
tz.initializeTimeZones();
|
||||||
|
|
||||||
|
// Remove this line if you are building from source and don't have sentry configured
|
||||||
await SentryFlutter.init(
|
await SentryFlutter.init(
|
||||||
(options) {
|
(options) {
|
||||||
options
|
options
|
||||||
@ -52,9 +64,9 @@ Future main() async {
|
|||||||
},
|
},
|
||||||
appRunner: () {
|
appRunner: () {
|
||||||
// Pass all uncaught errors from the framework to Crashlytics.
|
// Pass all uncaught errors from the framework to Crashlytics.
|
||||||
FlutterError.onError =
|
if (isCrashlyticsEnabled) {
|
||||||
FirebaseCrashlytics.instance.recordFlutterFatalError;
|
FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
|
||||||
|
}
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -91,6 +91,15 @@ class ManagerAPI {
|
|||||||
print('Sentry status: $value');
|
print('Sentry status: $value');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isCrashlyticsEnabled() {
|
||||||
|
return _prefs.getBool('crashlyticsEnabled') ?? true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setCrashlyticsStatus(bool value) async {
|
||||||
|
await _prefs.setBool('crashlyticsEnabled', value);
|
||||||
|
print('Crashlytics status: $value');
|
||||||
|
}
|
||||||
|
|
||||||
List<PatchedApplication> getPatchedApps() {
|
List<PatchedApplication> getPatchedApps() {
|
||||||
List<String> apps = _prefs.getStringList('patchedApps') ?? [];
|
List<String> apps = _prefs.getStringList('patchedApps') ?? [];
|
||||||
return apps.map((a) => PatchedApplication.fromJson(jsonDecode(a))).toList();
|
return apps.map((a) => PatchedApplication.fromJson(jsonDecode(a))).toList();
|
||||||
|
@ -140,7 +140,7 @@ class SettingsView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
_settingsDivider,
|
_settingsDivider,
|
||||||
SettingsSection(
|
SettingsSection(
|
||||||
title: 'settingsView.privacySectionTitle',
|
title: 'settingsView.logsSectionTitle',
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
CustomSwitchTile(
|
CustomSwitchTile(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
@ -158,6 +158,24 @@ class SettingsView extends StatelessWidget {
|
|||||||
value: model.isSentryEnabled(),
|
value: model.isSentryEnabled(),
|
||||||
onTap: (value) => model.useSentry(value),
|
onTap: (value) => model.useSentry(value),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
CustomSwitchTile(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
|
title: I18nText(
|
||||||
|
'settingsView.firebaseCrashlyticsLabel',
|
||||||
|
child: const Text(
|
||||||
|
'',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle:
|
||||||
|
I18nText('settingsView.firebaseCrashlyticsHint'),
|
||||||
|
value: model.isCrashlyticsEnabled(),
|
||||||
|
onTap: (value) => model.useCrashlytics(value),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
_settingsDivider,
|
_settingsDivider,
|
||||||
|
@ -327,6 +327,16 @@ class SettingsViewModel extends BaseViewModel {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isCrashlyticsEnabled() {
|
||||||
|
return _managerAPI.isCrashlyticsEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void useCrashlytics(bool value) {
|
||||||
|
_managerAPI.setCrashlyticsStatus(value);
|
||||||
|
_toast.showBottom('settingsView.restartAppForChanges');
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<int> getSdkVersion() async {
|
Future<int> getSdkVersion() async {
|
||||||
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
|
AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
|
||||||
return info.version.sdkInt ?? -1;
|
return info.version.sdkInt ?? -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user