refactor: remove sentry and crowdin (#730)

We no longer use sentry and crowdin.
This commit is contained in:
Aunali321 2023-03-05 14:42:46 +05:30 committed by GitHub
parent 68ccefc59f
commit 5617535a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 198 additions and 283 deletions

3
.env
View File

@ -1,3 +0,0 @@
sentryDSN=
apiKey=
appId=

View File

@ -145,8 +145,6 @@
"exportSectionTitle": "Import & export", "exportSectionTitle": "Import & export",
"aboutLabel": "About", "aboutLabel": "About",
"snackbarMessage": "Copied to clipboard", "snackbarMessage": "Copied to clipboard",
"sentryLabel": "Sentry logging",
"sentryHint": "Send anonymous logs to help us improve ReVanced Manager",
"restartAppForChanges": "Restart the app to apply changes", "restartAppForChanges": "Restart the app to apply changes",
"deleteKeystoreLabel": "Delete keystore", "deleteKeystoreLabel": "Delete keystore",
"deleteKeystoreHint": "Delete the keystore used to sign the app", "deleteKeystoreHint": "Delete the keystore used to sign the app",

View File

@ -1,4 +1,3 @@
import 'package:revanced_manager/services/crowdin_api.dart';
import 'package:revanced_manager/services/github_api.dart'; import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
@ -38,7 +37,6 @@ import 'package:stacked_services/stacked_services.dart';
LazySingleton(classType: PatcherAPI), LazySingleton(classType: PatcherAPI),
LazySingleton(classType: RevancedAPI), LazySingleton(classType: RevancedAPI),
LazySingleton(classType: GithubAPI), LazySingleton(classType: GithubAPI),
LazySingleton(classType: CrowdinAPI),
LazySingleton(classType: Toast), LazySingleton(classType: Toast),
], ],
) )

View File

@ -4,15 +4,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/services/crowdin_api.dart';
import 'package:revanced_manager/services/github_api.dart'; import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/revanced_api.dart'; import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart'; import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:revanced_manager/utils/environment.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:stacked_themes/stacked_themes.dart'; import 'package:stacked_themes/stacked_themes.dart';
import 'package:timezone/data/latest.dart' as tz; import 'package:timezone/data/latest.dart' as tz;
@ -25,36 +22,12 @@ Future main() async {
await locator<ManagerAPI>().initialize(); await locator<ManagerAPI>().initialize();
final String apiUrl = locator<ManagerAPI>().getApiUrl(); final String apiUrl = locator<ManagerAPI>().getApiUrl();
await locator<RevancedAPI>().initialize(apiUrl); await locator<RevancedAPI>().initialize(apiUrl);
await locator<CrowdinAPI>().initialize();
final bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
final String repoUrl = locator<ManagerAPI>().getRepoUrl(); final String repoUrl = locator<ManagerAPI>().getRepoUrl();
locator<GithubAPI>().initialize(repoUrl); locator<GithubAPI>().initialize(repoUrl);
await locator<PatcherAPI>().initialize(); await locator<PatcherAPI>().initialize();
tz.initializeTimeZones(); tz.initializeTimeZones();
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
await SentryFlutter.init(
(options) {
options
..dsn = isSentryEnabled ? Environment.sentryDSN : ''
..environment = 'alpha'
..release = '0.1'
..tracesSampleRate = 1.0
..anrEnabled = true
..enableOutOfMemoryTracking = true
..sampleRate = isSentryEnabled ? 1.0 : 0.0
..beforeSend = (event, hint) {
if (isSentryEnabled) {
return event;
} else {
return null;
}
} as BeforeSendCallback?;
},
appRunner: () {
runApp(const MyApp());
},
);
runApp(const MyApp()); runApp(const MyApp());
} }

View File

@ -1,63 +0,0 @@
import 'package:dio/dio.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:injectable/injectable.dart' hide Environment;
import 'package:revanced_manager/utils/environment.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
@lazySingleton
class CrowdinAPI {
late Dio _dio = Dio();
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final apiKey = Environment.crowdinKEY;
Future<void> initialize() async {
try {
_dio = Dio(
BaseOptions(
baseUrl: 'https://api.crowdin.com/api/v2',
),
);
_dio.interceptors.add(_dioCacheManager.interceptor);
_dio.addSentry(
captureFailedRequests: true,
);
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
}
}
Future<void> clearAllCache() async {
try {
await _dioCacheManager.clearAll();
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
}
}
Future<List> getLanguages() async {
try {
final response = await _dio.get(
'/projects',
options: buildCacheOptions(
const Duration(hours: 6),
maxStale: const Duration(days: 1),
options: Options(
headers: {
'Authorization': 'Bearer $apiKey',
},
contentType: 'application/json',
),
),
);
final List targetLanguages =
await response.data['data'][0]['data']['targetLanguages'];
return targetLanguages;
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return [];
}
}
}

View File

@ -4,11 +4,10 @@ import 'dart:io';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart'; import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
@lazySingleton @lazySingleton
class GithubAPI { class GithubAPI {
@ -38,19 +37,20 @@ class GithubAPI {
); );
_dio.interceptors.add(_dioCacheManager.interceptor); _dio.interceptors.add(_dioCacheManager.interceptor);
_dio.addSentry( } on Exception catch (e) {
captureFailedRequests: true, if (kDebugMode) {
); print(e);
} on Exception catch (e, s) { }
await Sentry.captureException(e, stackTrace: s);
} }
} }
Future<void> clearAllCache() async { Future<void> clearAllCache() async {
try { try {
await _dioCacheManager.clearAll(); await _dioCacheManager.clearAll();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
@ -61,8 +61,10 @@ class GithubAPI {
options: _cacheOptions, options: _cacheOptions,
); );
return response.data[0]; return response.data[0];
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return null; return null;
} }
} }
@ -92,11 +94,13 @@ class GithubAPI {
'\n' as String, '\n' as String,
) )
.toList(); .toList();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
return List.empty(); print(e);
} }
} }
return [];
}
Future<File?> getLatestReleaseFile(String extension, String repoName) async { Future<File?> getLatestReleaseFile(String extension, String repoName) async {
try { try {
@ -112,9 +116,10 @@ class GithubAPI {
); );
} }
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
return null; print(e);
}
} }
return null; return null;
} }
@ -127,10 +132,12 @@ class GithubAPI {
final List<dynamic> list = jsonDecode(f.readAsStringSync()); final List<dynamic> list = jsonDecode(f.readAsStringSync());
patches = list.map((patch) => Patch.fromJson(patch)).toList(); patches = list.map((patch) => Patch.fromJson(patch)).toList();
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
return List.empty(); print(e);
} }
}
return patches; return patches;
} }
@ -142,9 +149,12 @@ class GithubAPI {
} else { } else {
return 'Unknown'; return 'Unknown';
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
return ''; print(e);
}
return 'Unknown';
} }
} }
} }

View File

@ -1,6 +1,7 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
@ -10,7 +11,6 @@ import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/github_api.dart'; import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/revanced_api.dart'; import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/services/root_api.dart'; import 'package:revanced_manager/services/root_api.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@lazySingleton @lazySingleton
@ -98,14 +98,6 @@ class ManagerAPI {
await _prefs.setBool('useDarkTheme', value); await _prefs.setBool('useDarkTheme', value);
} }
bool isSentryEnabled() {
return _prefs.getBool('sentryEnabled') ?? true;
}
Future<void> setSentryStatus(bool value) async {
await _prefs.setBool('sentryEnabled', value);
}
bool areUniversalPatchesEnabled() { bool areUniversalPatchesEnabled() {
return _prefs.getBool('universalPatchesEnabled') ?? false; return _prefs.getBool('universalPatchesEnabled') ?? false;
} }
@ -179,8 +171,10 @@ class ManagerAPI {
try { try {
_revancedAPI.clearAllCache(); _revancedAPI.clearAllCache();
_githubAPI.clearAllCache(); _githubAPI.clearAllCache();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
@ -196,8 +190,10 @@ class ManagerAPI {
} else { } else {
return await _githubAPI.getPatches(repoName); return await _githubAPI.getPatches(repoName);
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return []; return [];
} }
} }
@ -213,8 +209,10 @@ class ManagerAPI {
} else { } else {
return await _githubAPI.getLatestReleaseFile('.jar', repoName); return await _githubAPI.getLatestReleaseFile('.jar', repoName);
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return null; return null;
} }
} }
@ -230,8 +228,10 @@ class ManagerAPI {
} else { } else {
return await _githubAPI.getLatestReleaseFile('.apk', repoName); return await _githubAPI.getLatestReleaseFile('.apk', repoName);
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return null; return null;
} }
} }

View File

@ -13,7 +13,6 @@ import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/root_api.dart'; import 'package:revanced_manager/services/root_api.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:share_extend/share_extend.dart'; import 'package:share_extend/share_extend.dart';
@lazySingleton @lazySingleton
@ -49,8 +48,10 @@ class PatcherAPI {
if (_patches.isEmpty) { if (_patches.isEmpty) {
_patches = await _managerAPI.getPatches(); _patches = await _managerAPI.getPatches();
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
_patches = List.empty(); _patches = List.empty();
} }
} }
@ -91,9 +92,10 @@ class PatcherAPI {
filteredApps.add(app); filteredApps.add(app);
} }
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
continue; print(e);
}
} }
} }
} }
@ -151,8 +153,10 @@ class PatcherAPI {
); );
} }
return originalFilePath; return originalFilePath;
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return originalFilePath; return originalFilePath;
} }
} }
@ -173,9 +177,10 @@ class PatcherAPI {
if (settingsPatch != null) { if (settingsPatch != null) {
selectedPatches.add(settingsPatch); selectedPatches.add(settingsPatch);
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
// ignore print(e);
}
} }
} }
final File? patchBundleFile = await _managerAPI.downloadPatches(); final File? patchBundleFile = await _managerAPI.downloadPatches();
@ -207,11 +212,10 @@ class PatcherAPI {
'keyStoreFilePath': _keyStoreFile.path, 'keyStoreFilePath': _keyStoreFile.path,
}, },
); );
} on Exception catch (e, s) { } on Exception catch (e) {
if (kDebugMode) { if (kDebugMode) {
print(e); print(e);
} }
throw await Sentry.captureException(e, stackTrace: s);
} }
} }
} }
@ -232,8 +236,10 @@ class PatcherAPI {
await AppInstaller.installApk(_outFile!.path); await AppInstaller.installApk(_outFile!.path);
return await DeviceApps.isAppInstalled(patchedApp.packageName); return await DeviceApps.isAppInstalled(patchedApp.packageName);
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return false; return false;
} }
} }
@ -244,11 +250,17 @@ class PatcherAPI {
try { try {
if (_outFile != null) { if (_outFile != null) {
final String newName = _getFileName(appName, version); final String newName = _getFileName(appName, version);
CRFileSaver.saveFileWithDialog(SaveFileDialogParams( CRFileSaver.saveFileWithDialog(
sourceFilePath: _outFile!.path, destinationFileName: newName,),); SaveFileDialogParams(
sourceFilePath: _outFile!.path,
destinationFileName: newName,
),
);
}
} on Exception catch (e) {
if (kDebugMode) {
print(e);
} }
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
} }
} }
@ -262,8 +274,10 @@ class PatcherAPI {
final File shareFile = _outFile!.copySync(newPath); final File shareFile = _outFile!.copySync(newPath);
ShareExtend.share(shareFile.path, 'file'); ShareExtend.share(shareFile.path, 'file');
} }
} on Exception catch (e, s) { } on Exception catch (e) {
Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }

View File

@ -4,13 +4,12 @@ import 'dart:io';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart'; import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart'; import 'package:injectable/injectable.dart';
import 'package:native_dio_client/native_dio_client.dart'; import 'package:native_dio_client/native_dio_client.dart';
import 'package:revanced_manager/models/patch.dart'; import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/utils/check_for_gms.dart'; import 'package:revanced_manager/utils/check_for_gms.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:timeago/timeago.dart'; import 'package:timeago/timeago.dart';
@lazySingleton @lazySingleton
@ -42,19 +41,20 @@ class RevancedAPI {
log('ReVanced API: Using CronetEngine + $isGMSInstalled'); log('ReVanced API: Using CronetEngine + $isGMSInstalled');
} }
_dio.interceptors.add(_dioCacheManager.interceptor); _dio.interceptors.add(_dioCacheManager.interceptor);
_dio.addSentry( } on Exception catch (e) {
captureFailedRequests: true, if (kDebugMode) {
); print(e);
} on Exception catch (e, s) { }
await Sentry.captureException(e, stackTrace: s);
} }
} }
Future<void> clearAllCache() async { Future<void> clearAllCache() async {
try { try {
await _dioCacheManager.clearAll(); await _dioCacheManager.clearAll();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
@ -67,8 +67,10 @@ class RevancedAPI {
final String name = repo['name']; final String name = repo['name'];
contributors[name] = repo['contributors']; contributors[name] = repo['contributors'];
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return {}; return {};
} }
return contributors; return contributors;
@ -79,8 +81,10 @@ class RevancedAPI {
final response = await _dio.get('/patches', options: _cacheOptions); final response = await _dio.get('/patches', options: _cacheOptions);
final List<dynamic> patches = response.data; final List<dynamic> patches = response.data;
return patches.map((patch) => Patch.fromJson(patch)).toList(); return patches.map((patch) => Patch.fromJson(patch)).toList();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return List.empty(); return List.empty();
} }
} }
@ -97,8 +101,10 @@ class RevancedAPI {
t['repository'] == repoName && t['repository'] == repoName &&
(t['name'] as String).endsWith(extension), (t['name'] as String).endsWith(extension),
); );
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return null; return null;
} }
} }
@ -115,8 +121,10 @@ class RevancedAPI {
if (release != null) { if (release != null) {
return release['version']; return release['version'];
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return null; return null;
} }
return null; return null;
@ -132,8 +140,10 @@ class RevancedAPI {
final String url = release['browser_download_url']; final String url = release['browser_download_url'];
return await DefaultCacheManager().getSingleFile(url); return await DefaultCacheManager().getSingleFile(url);
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return null; return null;
} }
return null; return null;
@ -153,8 +163,10 @@ class RevancedAPI {
DateTime.parse(release['timestamp'] as String); DateTime.parse(release['timestamp'] as String);
return format(timestamp, locale: 'en_short'); return format(timestamp, locale: 'en_short');
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return null; return null;
} }
return null; return null;

View File

@ -1,5 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:root/root.dart'; import 'package:root/root.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class RootAPI { class RootAPI {
final String _managerDirPath = '/data/local/tmp/revanced-manager'; final String _managerDirPath = '/data/local/tmp/revanced-manager';
@ -10,8 +10,10 @@ class RootAPI {
try { try {
final bool? isRooted = await Root.isRootAvailable(); final bool? isRooted = await Root.isRootAvailable();
return isRooted != null && isRooted; return isRooted != null && isRooted;
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return false; return false;
} }
} }
@ -24,8 +26,10 @@ class RootAPI {
return isRooted != null && isRooted; return isRooted != null && isRooted;
} }
return false; return false;
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return false; return false;
} }
} }
@ -78,8 +82,10 @@ class RootAPI {
apps.removeWhere((pack) => pack.isEmpty); apps.removeWhere((pack) => pack.isEmpty);
return apps.map((pack) => pack.trim()).toList(); return apps.map((pack) => pack.trim()).toList();
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return List.empty(); return List.empty();
} }
return List.empty(); return List.empty();
@ -125,8 +131,10 @@ class RootAPI {
await installApk(packageName, patchedFilePath); await installApk(packageName, patchedFilePath);
await mountApk(packageName, originalFilePath); await mountApk(packageName, originalFilePath);
return true; return true;
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return false; return false;
} }
} }

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/models/patched_application.dart';
@ -9,7 +10,6 @@ import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
class AppSelectorViewModel extends BaseViewModel { class AppSelectorViewModel extends BaseViewModel {
@ -87,8 +87,10 @@ class AppSelectorViewModel extends BaseViewModel {
locator<PatcherViewModel>().loadLastSelectedPatches(); locator<PatcherViewModel>().loadLastSelectedPatches();
} }
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
_toast.showBottom('appSelectorView.errorMessage'); _toast.showBottom('appSelectorView.errorMessage');
} }
} }

View File

@ -4,6 +4,7 @@ import 'dart:io';
import 'package:app_installer/app_installer.dart'; import 'package:app_installer/app_installer.dart';
import 'package:cross_connectivity/cross_connectivity.dart'; import 'package:cross_connectivity/cross_connectivity.dart';
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart';
@ -18,7 +19,6 @@ import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/homeView/update_confirmation_dialog.dart'; import 'package:revanced_manager/ui/widgets/homeView/update_confirmation_dialog.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart'; import 'package:stacked_services/stacked_services.dart';
import 'package:timezone/timezone.dart' as tz; import 'package:timezone/timezone.dart' as tz;
@ -95,8 +95,10 @@ class HomeViewModel extends BaseViewModel {
final int currentVersionInt = final int currentVersionInt =
int.parse(currentVersion.replaceAll(RegExp('[^0-9]'), '')); int.parse(currentVersion.replaceAll(RegExp('[^0-9]'), ''));
return latestVersionInt > currentVersionInt; return latestVersionInt > currentVersionInt;
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
return false; return false;
} }
} }
@ -137,8 +139,10 @@ class HomeViewModel extends BaseViewModel {
} else { } else {
_toast.showBottom('homeView.errorDownloadMessage'); _toast.showBottom('homeView.errorDownloadMessage');
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
_toast.showBottom('homeView.errorInstallMessage'); _toast.showBottom('homeView.errorInstallMessage');
} }
} }

View File

@ -1,5 +1,6 @@
// ignore_for_file: use_build_context_synchronously // ignore_for_file: use_build_context_synchronously
import 'package:device_apps/device_apps.dart'; import 'package:device_apps/device_apps.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_background/flutter_background.dart'; import 'package:flutter_background/flutter_background.dart';
@ -14,7 +15,6 @@ import 'package:revanced_manager/services/root_api.dart';
import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:wakelock/wakelock.dart'; import 'package:wakelock/wakelock.dart';
@ -56,9 +56,10 @@ class InstallerViewModel extends BaseViewModel {
), ),
), ),
).then((value) => FlutterBackground.enableBackgroundExecution()); ).then((value) => FlutterBackground.enableBackgroundExecution());
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
// ignore print(e);
} // ignore
} }
} }
await Wakelock.enable(); await Wakelock.enable();
@ -131,14 +132,15 @@ class InstallerViewModel extends BaseViewModel {
_app.apkFilePath, _app.apkFilePath,
_patches, _patches,
); );
} on Exception catch (e, s) { } on Exception catch (e) {
update( update(
-100.0, -100.0,
'Aborting...', 'Aborting...',
'An error occurred! Aborting\nError:\n$e', 'An error occurred! Aborting\nError:\n$e',
); );
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
throw await Sentry.captureException(e, stackTrace: s); print(e);
}
} }
} else { } else {
update(-100.0, 'Aborting...', 'No app or patches selected! Aborting'); update(-100.0, 'Aborting...', 'No app or patches selected! Aborting');
@ -146,14 +148,17 @@ class InstallerViewModel extends BaseViewModel {
if (FlutterBackground.isBackgroundExecutionEnabled) { if (FlutterBackground.isBackgroundExecutionEnabled) {
try { try {
FlutterBackground.disableBackgroundExecution(); FlutterBackground.disableBackgroundExecution();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
// ignore print(e);
} // ignore
} }
} }
await Wakelock.disable(); await Wakelock.disable();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
@ -211,24 +216,30 @@ class InstallerViewModel extends BaseViewModel {
await _managerAPI.savePatchedApp(_app); await _managerAPI.savePatchedApp(_app);
} }
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
void exportResult() { void exportResult() {
try { try {
_patcherAPI.exportPatchedFile(_app.name, _app.version); _patcherAPI.exportPatchedFile(_app.name, _app.version);
} on Exception catch (e, s) { } on Exception catch (e) {
Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
void shareResult() { void shareResult() {
try { try {
_patcherAPI.sharePatchedFile(_app.name, _app.version); _patcherAPI.sharePatchedFile(_app.name, _app.version);
} on Exception catch (e, s) { } on Exception catch (e) {
Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
@ -242,8 +253,10 @@ class InstallerViewModel extends BaseViewModel {
locator<PatcherViewModel>().selectedApp = null; locator<PatcherViewModel>().selectedApp = null;
locator<PatcherViewModel>().selectedPatches.clear(); locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().notifyListeners(); locator<PatcherViewModel>().notifyListeners();
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }

View File

@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/main.dart'; import 'package:revanced_manager/main.dart';
import 'package:revanced_manager/services/crowdin_api.dart';
import 'package:revanced_manager/services/toast.dart'; import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart'; import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart'; import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
@ -16,7 +15,6 @@ import 'package:timeago/timeago.dart' as timeago;
final _settingViewModel = SettingsViewModel(); final _settingViewModel = SettingsViewModel();
class SUpdateLanguage extends BaseViewModel { class SUpdateLanguage extends BaseViewModel {
final CrowdinAPI _crowdinAPI = locator<CrowdinAPI>();
final Toast _toast = locator<Toast>(); final Toast _toast = locator<Toast>();
late SharedPreferences _prefs; late SharedPreferences _prefs;
String selectedLanguage = 'English'; String selectedLanguage = 'English';
@ -43,7 +41,6 @@ class SUpdateLanguage extends BaseViewModel {
} }
Future<void> initLang() async { Future<void> initLang() async {
languages = await _crowdinAPI.getLanguages();
languages.sort((a, b) => a['name'].compareTo(b['name'])); languages.sort((a, b) => a['name'].compareTo(b['name']));
notifyListeners(); notifyListeners();
} }

View File

@ -49,8 +49,6 @@ class SettingsView extends StatelessWidget {
_settingsDivider, _settingsDivider,
SExportSection(), SExportSection(),
_settingsDivider, _settingsDivider,
// SLoggingSection(),
// _settingsDivider,
SInfoSection(), SInfoSection(),
], ],
), ),

View File

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:cr_file_saver/file_saver.dart'; import 'package:cr_file_saver/file_saver.dart';
import 'package:device_info_plus/device_info_plus.dart'; import 'package:device_info_plus/device_info_plus.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:logcat/logcat.dart'; import 'package:logcat/logcat.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/app/app.locator.dart';
@ -11,7 +12,6 @@ import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart'; import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_language.dart'; import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_language.dart';
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_theme.dart'; import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_theme.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:share_extend/share_extend.dart'; import 'package:share_extend/share_extend.dart';
import 'package:stacked/stacked.dart'; import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart'; import 'package:stacked_services/stacked_services.dart';
@ -28,16 +28,6 @@ class SettingsViewModel extends BaseViewModel {
_navigationService.navigateTo(Routes.contributorsView); _navigationService.navigateTo(Routes.contributorsView);
} }
bool isSentryEnabled() {
return _managerAPI.isSentryEnabled();
}
void useSentry(bool value) {
_managerAPI.setSentryStatus(value);
_toast.showBottom('settingsView.restartAppForChanges');
notifyListeners();
}
bool areUniversalPatchesEnabled() { bool areUniversalPatchesEnabled() {
return _managerAPI.areUniversalPatchesEnabled(); return _managerAPI.areUniversalPatchesEnabled();
} }
@ -74,14 +64,20 @@ class SettingsViewModel extends BaseViewModel {
if (outFile.existsSync()) { if (outFile.existsSync()) {
final String dateTime = final String dateTime =
DateTime.now().toString().replaceAll(' ', '_').split('.').first; DateTime.now().toString().replaceAll(' ', '_').split('.').first;
await CRFileSaver.saveFileWithDialog(SaveFileDialogParams( await CRFileSaver.saveFileWithDialog(
sourceFilePath: outFile.path, destinationFileName: 'selected_patches_$dateTime.json',),); SaveFileDialogParams(
sourceFilePath: outFile.path,
destinationFileName: 'selected_patches_$dateTime.json',
),
);
_toast.showBottom('settingsView.exportedPatches'); _toast.showBottom('settingsView.exportedPatches');
} else { } else {
_toast.showBottom('settingsView.noExportFileFound'); _toast.showBottom('settingsView.noExportFileFound');
} }
} on Exception catch (e, s) { } on Exception catch (e) {
Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
} }
} }
@ -100,8 +96,10 @@ class SettingsViewModel extends BaseViewModel {
} }
_toast.showBottom('settingsView.importedPatches'); _toast.showBottom('settingsView.importedPatches');
} }
} on Exception catch (e, s) { } on Exception catch (e) {
await Sentry.captureException(e, stackTrace: s); if (kDebugMode) {
print(e);
}
_toast.showBottom('settingsView.jsonSelectorErrorMessage'); _toast.showBottom('settingsView.jsonSelectorErrorMessage');
} }
} }

View File

@ -1,36 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/widgets/I18nText.dart';
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/settingsView/custom_switch_tile.dart';
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
final _settingsViewModel = SettingsViewModel();
class SLoggingSection extends StatelessWidget {
const SLoggingSection({super.key});
@override
Widget build(BuildContext context) {
return SettingsSection(
title: 'settingsView.logsSectionTitle',
children: <Widget>[
CustomSwitchTile(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
title: I18nText(
'settingsView.sentryLabel',
child: const Text(
'',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
),
subtitle: I18nText('settingsView.sentryHint'),
value: _settingsViewModel.isSentryEnabled(),
onTap: (value) => _settingsViewModel.useSentry(value),
),
],
);
}
}

View File

@ -1,5 +0,0 @@
// Dummy environment variables used for building the app locally. These automatically get set with correct values during workflow builds.
class Environment {
static const sentryDSN = '';
static const crowdinKEY = '';
}

View File

@ -10,7 +10,6 @@ environment:
sdk: ">=2.17.5 <3.0.0" sdk: ">=2.17.5 <3.0.0"
dependencies: dependencies:
sentry_flutter: ^6.12.2
animations: ^2.0.4 animations: ^2.0.4
app_installer: ^1.1.0 app_installer: ^1.1.0
collection: ^1.16.0 collection: ^1.16.0
@ -73,7 +72,6 @@ dependencies:
timezone: ^0.8.0 timezone: ^0.8.0
url_launcher: ^6.1.5 url_launcher: ^6.1.5
wakelock: ^0.6.2 wakelock: ^0.6.2
sentry_dio: ^6.12.2
flutter_dotenv: ^5.0.2 flutter_dotenv: ^5.0.2
pub_release: ^8.0.3 pub_release: ^8.0.3
flutter_markdown: ^0.6.13 flutter_markdown: ^0.6.13
@ -93,4 +91,3 @@ flutter:
uses-material-design: true uses-material-design: true
assets: assets:
- assets/i18n/ - assets/i18n/
- .env