mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
revert: "refactor: update deprecated and minor code refactors (#710)"
This reverts commit 6829d3cdea
.
Signed-off-by: EvadeMaster <93124920+EvadeMaster@users.noreply.github.com>
This commit is contained in:
parent
6d60541626
commit
68ccefc59f
@ -12,8 +12,6 @@ include: package:flutter_lints/flutter.yaml
|
|||||||
analyzer:
|
analyzer:
|
||||||
exclude:
|
exclude:
|
||||||
- lib/utils/env_class.g.dart
|
- lib/utils/env_class.g.dart
|
||||||
- "**/*.locator.dart"
|
|
||||||
- "**/*.router.dart"
|
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
|
@ -15,7 +15,6 @@ import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
|||||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_view.dart';
|
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_view.dart';
|
||||||
import 'package:revanced_manager/ui/views/settings/settings_view.dart';
|
import 'package:revanced_manager/ui/views/settings/settings_view.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/appInfoView/app_info_view.dart';
|
import 'package:revanced_manager/ui/widgets/appInfoView/app_info_view.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
|
||||||
import 'package:stacked/stacked_annotations.dart';
|
import 'package:stacked/stacked_annotations.dart';
|
||||||
import 'package:stacked_services/stacked_services.dart';
|
import 'package:stacked_services/stacked_services.dart';
|
||||||
|
|
||||||
@ -41,10 +40,6 @@ import 'package:stacked_services/stacked_services.dart';
|
|||||||
LazySingleton(classType: GithubAPI),
|
LazySingleton(classType: GithubAPI),
|
||||||
LazySingleton(classType: CrowdinAPI),
|
LazySingleton(classType: CrowdinAPI),
|
||||||
LazySingleton(classType: Toast),
|
LazySingleton(classType: Toast),
|
||||||
Presolve(
|
|
||||||
classType: SharedPreferences,
|
|
||||||
presolveUsing: SharedPreferences.getInstance,
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
class AppSetup {}
|
class AppSetup {}
|
||||||
|
@ -4,6 +4,7 @@ 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';
|
||||||
@ -12,25 +13,27 @@ 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:revanced_manager/utils/environment.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:stacked_themes/stacked_themes.dart';
|
||||||
import 'package:timezone/data/latest.dart' as tz;
|
import 'package:timezone/data/latest.dart' as tz;
|
||||||
|
|
||||||
|
late SharedPreferences prefs;
|
||||||
Future main() async {
|
Future main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
await ThemeManager.initialise();
|
||||||
await setupLocator();
|
await setupLocator();
|
||||||
final manager = locator<ManagerAPI>();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await manager.initialize();
|
await locator<ManagerAPI>().initialize();
|
||||||
final String apiUrl = manager.getApiUrl();
|
final String apiUrl = locator<ManagerAPI>().getApiUrl();
|
||||||
final bool isSentryEnabled = manager.isSentryEnabled();
|
await locator<RevancedAPI>().initialize(apiUrl);
|
||||||
final String repoUrl = manager.getRepoUrl();
|
await locator<CrowdinAPI>().initialize();
|
||||||
|
final bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
|
||||||
await Future.wait([
|
final String repoUrl = locator<ManagerAPI>().getRepoUrl();
|
||||||
locator<RevancedAPI>().initialize(apiUrl),
|
|
||||||
locator<PatcherAPI>().initialize(),
|
|
||||||
]);
|
|
||||||
locator<GithubAPI>().initialize(repoUrl);
|
locator<GithubAPI>().initialize(repoUrl);
|
||||||
|
await locator<PatcherAPI>().initialize();
|
||||||
tz.initializeTimeZones();
|
tz.initializeTimeZones();
|
||||||
|
prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
return SentryFlutter.init(
|
await SentryFlutter.init(
|
||||||
(options) {
|
(options) {
|
||||||
options
|
options
|
||||||
..dsn = isSentryEnabled ? Environment.sentryDSN : ''
|
..dsn = isSentryEnabled ? Environment.sentryDSN : ''
|
||||||
@ -48,8 +51,11 @@ Future main() async {
|
|||||||
}
|
}
|
||||||
} as BeforeSendCallback?;
|
} as BeforeSendCallback?;
|
||||||
},
|
},
|
||||||
appRunner: () => runApp(const MyApp()),
|
appRunner: () {
|
||||||
|
runApp(const MyApp());
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
|
@ -7,14 +7,11 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
|||||||
|
|
||||||
@lazySingleton
|
@lazySingleton
|
||||||
class CrowdinAPI {
|
class CrowdinAPI {
|
||||||
CrowdinAPI() {
|
late Dio _dio = Dio();
|
||||||
initialize();
|
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
|
||||||
}
|
final apiKey = Environment.crowdinKEY;
|
||||||
Dio _dio = Dio();
|
|
||||||
DioCacheManager get _dioCacheManager => DioCacheManager(CacheConfig());
|
|
||||||
String get apiKey => Environment.crowdinKEY;
|
|
||||||
|
|
||||||
void initialize() {
|
Future<void> initialize() async {
|
||||||
try {
|
try {
|
||||||
_dio = Dio(
|
_dio = Dio(
|
||||||
BaseOptions(
|
BaseOptions(
|
||||||
@ -27,7 +24,7 @@ class CrowdinAPI {
|
|||||||
captureFailedRequests: true,
|
captureFailedRequests: true,
|
||||||
);
|
);
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +32,7 @@ class CrowdinAPI {
|
|||||||
try {
|
try {
|
||||||
await _dioCacheManager.clearAll();
|
await _dioCacheManager.clearAll();
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +56,7 @@ class CrowdinAPI {
|
|||||||
|
|
||||||
return targetLanguages;
|
return targetLanguages;
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class GithubAPI {
|
|||||||
captureFailedRequests: true,
|
captureFailedRequests: true,
|
||||||
);
|
);
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class GithubAPI {
|
|||||||
try {
|
try {
|
||||||
await _dioCacheManager.clearAll();
|
await _dioCacheManager.clearAll();
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class GithubAPI {
|
|||||||
);
|
);
|
||||||
return response.data[0];
|
return response.data[0];
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ class GithubAPI {
|
|||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return List.empty();
|
return List.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ class GithubAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -128,7 +128,7 @@ class GithubAPI {
|
|||||||
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, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return List.empty();
|
return List.empty();
|
||||||
}
|
}
|
||||||
return patches;
|
return patches;
|
||||||
@ -143,7 +143,7 @@ class GithubAPI {
|
|||||||
return 'Unknown';
|
return 'Unknown';
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
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: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';
|
||||||
@ -18,10 +17,10 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
class ManagerAPI {
|
class ManagerAPI {
|
||||||
final RevancedAPI _revancedAPI = locator<RevancedAPI>();
|
final RevancedAPI _revancedAPI = locator<RevancedAPI>();
|
||||||
final GithubAPI _githubAPI = locator<GithubAPI>();
|
final GithubAPI _githubAPI = locator<GithubAPI>();
|
||||||
final SharedPreferences _prefs = locator<SharedPreferences>();
|
|
||||||
final RootAPI _rootAPI = RootAPI();
|
final RootAPI _rootAPI = RootAPI();
|
||||||
final String patcherRepo = 'revanced-patcher';
|
final String patcherRepo = 'revanced-patcher';
|
||||||
final String cliRepo = 'revanced-cli';
|
final String cliRepo = 'revanced-cli';
|
||||||
|
late SharedPreferences _prefs;
|
||||||
String storedPatchesFile = '/selected-patches.json';
|
String storedPatchesFile = '/selected-patches.json';
|
||||||
String defaultApiUrl = 'https://releases.revanced.app/';
|
String defaultApiUrl = 'https://releases.revanced.app/';
|
||||||
String defaultRepoUrl = 'https://api.github.com';
|
String defaultRepoUrl = 'https://api.github.com';
|
||||||
@ -32,6 +31,7 @@ class ManagerAPI {
|
|||||||
String defaultManagerRepo = 'revanced/revanced-manager';
|
String defaultManagerRepo = 'revanced/revanced-manager';
|
||||||
|
|
||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
|
_prefs = await SharedPreferences.getInstance();
|
||||||
storedPatchesFile =
|
storedPatchesFile =
|
||||||
(await getApplicationDocumentsDirectory()).path + storedPatchesFile;
|
(await getApplicationDocumentsDirectory()).path + storedPatchesFile;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ class ManagerAPI {
|
|||||||
_revancedAPI.clearAllCache();
|
_revancedAPI.clearAllCache();
|
||||||
_githubAPI.clearAllCache();
|
_githubAPI.clearAllCache();
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ class ManagerAPI {
|
|||||||
return await _githubAPI.getPatches(repoName);
|
return await _githubAPI.getPatches(repoName);
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +214,7 @@ class ManagerAPI {
|
|||||||
return await _githubAPI.getLatestReleaseFile('.jar', repoName);
|
return await _githubAPI.getLatestReleaseFile('.jar', repoName);
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ class ManagerAPI {
|
|||||||
return await _githubAPI.getLatestReleaseFile('.apk', repoName);
|
return await _githubAPI.getLatestReleaseFile('.apk', repoName);
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ class PatcherAPI {
|
|||||||
_patches = await _managerAPI.getPatches();
|
_patches = await _managerAPI.getPatches();
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
_patches = List.empty();
|
_patches = List.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ class PatcherAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +152,7 @@ class PatcherAPI {
|
|||||||
}
|
}
|
||||||
return originalFilePath;
|
return originalFilePath;
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return originalFilePath;
|
return originalFilePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ class PatcherAPI {
|
|||||||
selectedPatches.add(settingsPatch);
|
selectedPatches.add(settingsPatch);
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,11 +207,11 @@ class PatcherAPI {
|
|||||||
'keyStoreFilePath': _keyStoreFile.path,
|
'keyStoreFilePath': _keyStoreFile.path,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e, s) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print(e);
|
print(e);
|
||||||
}
|
}
|
||||||
rethrow;
|
throw await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ class PatcherAPI {
|
|||||||
return await DeviceApps.isAppInstalled(patchedApp.packageName);
|
return await DeviceApps.isAppInstalled(patchedApp.packageName);
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,15 +244,11 @@ class PatcherAPI {
|
|||||||
try {
|
try {
|
||||||
if (_outFile != null) {
|
if (_outFile != null) {
|
||||||
final String newName = _getFileName(appName, version);
|
final String newName = _getFileName(appName, version);
|
||||||
CRFileSaver.saveFileWithDialog(
|
CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
|
||||||
SaveFileDialogParams(
|
sourceFilePath: _outFile!.path, destinationFileName: newName,),);
|
||||||
sourceFilePath: _outFile!.path,
|
|
||||||
destinationFileName: newName,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +263,7 @@ class PatcherAPI {
|
|||||||
ShareExtend.share(shareFile.path, 'file');
|
ShareExtend.share(shareFile.path, 'file');
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class RevancedAPI {
|
|||||||
captureFailedRequests: true,
|
captureFailedRequests: true,
|
||||||
);
|
);
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ class RevancedAPI {
|
|||||||
try {
|
try {
|
||||||
await _dioCacheManager.clearAll();
|
await _dioCacheManager.clearAll();
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ class RevancedAPI {
|
|||||||
contributors[name] = repo['contributors'];
|
contributors[name] = repo['contributors'];
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return contributors;
|
return contributors;
|
||||||
@ -80,7 +80,7 @@ class RevancedAPI {
|
|||||||
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, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return List.empty();
|
return List.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ class RevancedAPI {
|
|||||||
(t['name'] as String).endsWith(extension),
|
(t['name'] as String).endsWith(extension),
|
||||||
);
|
);
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ class RevancedAPI {
|
|||||||
return release['version'];
|
return release['version'];
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -133,7 +133,7 @@ class RevancedAPI {
|
|||||||
return await DefaultCacheManager().getSingleFile(url);
|
return await DefaultCacheManager().getSingleFile(url);
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -154,7 +154,7 @@ class RevancedAPI {
|
|||||||
return format(timestamp, locale: 'en_short');
|
return format(timestamp, locale: 'en_short');
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -11,7 +11,7 @@ class RootAPI {
|
|||||||
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, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ class RootAPI {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ class RootAPI {
|
|||||||
return apps.map((pack) => pack.trim()).toList();
|
return apps.map((pack) => pack.trim()).toList();
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return List.empty();
|
return List.empty();
|
||||||
}
|
}
|
||||||
return List.empty();
|
return List.empty();
|
||||||
@ -126,7 +126,7 @@ class RootAPI {
|
|||||||
await mountApk(packageName, originalFilePath);
|
await mountApk(packageName, originalFilePath);
|
||||||
return true;
|
return true;
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ class AppSelectorViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
_toast.showBottom('appSelectorView.errorMessage');
|
_toast.showBottom('appSelectorView.errorMessage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
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, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
_toast.showBottom('homeView.errorDownloadMessage');
|
_toast.showBottom('homeView.errorDownloadMessage');
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
_toast.showBottom('homeView.errorInstallMessage');
|
_toast.showBottom('homeView.errorInstallMessage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
),
|
),
|
||||||
).then((value) => FlutterBackground.enableBackgroundExecution());
|
).then((value) => FlutterBackground.enableBackgroundExecution());
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,13 +131,14 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
_app.apkFilePath,
|
_app.apkFilePath,
|
||||||
_patches,
|
_patches,
|
||||||
);
|
);
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e, s) {
|
||||||
update(
|
update(
|
||||||
-100.0,
|
-100.0,
|
||||||
'Aborting...',
|
'Aborting...',
|
||||||
'An error occurred! Aborting\nError:\n$e',
|
'An error occurred! Aborting\nError:\n$e',
|
||||||
);
|
);
|
||||||
rethrow;
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
|
throw await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
update(-100.0, 'Aborting...', 'No app or patches selected! Aborting');
|
update(-100.0, 'Aborting...', 'No app or patches selected! Aborting');
|
||||||
@ -145,13 +146,14 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
if (FlutterBackground.isBackgroundExecutionEnabled) {
|
if (FlutterBackground.isBackgroundExecutionEnabled) {
|
||||||
try {
|
try {
|
||||||
FlutterBackground.disableBackgroundExecution();
|
FlutterBackground.disableBackgroundExecution();
|
||||||
} on Exception {
|
} on Exception catch (e, s) {
|
||||||
rethrow;
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await Wakelock.disable();
|
await Wakelock.disable();
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +212,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +220,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
try {
|
try {
|
||||||
_patcherAPI.exportPatchedFile(_app.name, _app.version);
|
_patcherAPI.exportPatchedFile(_app.name, _app.version);
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +228,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
try {
|
try {
|
||||||
_patcherAPI.sharePatchedFile(_app.name, _app.version);
|
_patcherAPI.sharePatchedFile(_app.name, _app.version);
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +243,7 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
locator<PatcherViewModel>().selectedPatches.clear();
|
locator<PatcherViewModel>().selectedPatches.clear();
|
||||||
locator<PatcherViewModel>().notifyListeners();
|
locator<PatcherViewModel>().notifyListeners();
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ import 'package:stacked/stacked.dart';
|
|||||||
|
|
||||||
@lazySingleton
|
@lazySingleton
|
||||||
class NavigationViewModel extends IndexTrackingViewModel {
|
class NavigationViewModel extends IndexTrackingViewModel {
|
||||||
final prefs = locator<SharedPreferences>();
|
|
||||||
Future<void> initialize(BuildContext context) async {
|
Future<void> initialize(BuildContext context) async {
|
||||||
locator<Toast>().initialize(context);
|
locator<Toast>().initialize(context);
|
||||||
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
if (prefs.getBool('permissionsRequested') == null) {
|
if (prefs.getBool('permissionsRequested') == null) {
|
||||||
await prefs.setBool('permissionsRequested', true);
|
await prefs.setBool('permissionsRequested', true);
|
||||||
RootAPI().hasRootPermissions().then(
|
RootAPI().hasRootPermissions().then(
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
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:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
|
import 'package:revanced_manager/main.dart';
|
||||||
import 'package:revanced_manager/services/crowdin_api.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';
|
||||||
@ -16,14 +17,23 @@ final _settingViewModel = SettingsViewModel();
|
|||||||
|
|
||||||
class SUpdateLanguage extends BaseViewModel {
|
class SUpdateLanguage extends BaseViewModel {
|
||||||
final CrowdinAPI _crowdinAPI = locator<CrowdinAPI>();
|
final CrowdinAPI _crowdinAPI = locator<CrowdinAPI>();
|
||||||
final SharedPreferences _prefs = locator<SharedPreferences>();
|
|
||||||
final Toast _toast = locator<Toast>();
|
final Toast _toast = locator<Toast>();
|
||||||
|
late SharedPreferences _prefs;
|
||||||
String selectedLanguage = 'English';
|
String selectedLanguage = 'English';
|
||||||
String get selectedLanguageLocale => _prefs.getString('language') ?? 'en_US';
|
String selectedLanguageLocale = prefs.getString('language') ?? 'en_US';
|
||||||
List languages = [];
|
List languages = [];
|
||||||
|
|
||||||
|
Future<void> initialize() async {
|
||||||
|
_prefs = await SharedPreferences.getInstance();
|
||||||
|
selectedLanguageLocale =
|
||||||
|
_prefs.getString('language') ?? selectedLanguageLocale;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> updateLanguage(BuildContext context, String? value) async {
|
Future<void> updateLanguage(BuildContext context, String? value) async {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
selectedLanguageLocale = value;
|
||||||
|
_prefs = await SharedPreferences.getInstance();
|
||||||
await _prefs.setString('language', value);
|
await _prefs.setString('language', value);
|
||||||
await FlutterI18n.refresh(context, Locale(value));
|
await FlutterI18n.refresh(context, Locale(value));
|
||||||
timeago.setLocaleMessages(value, timeago.EnMessages());
|
timeago.setLocaleMessages(value, timeago.EnMessages());
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'dart:io';
|
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';
|
||||||
@ -75,18 +74,14 @@ 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(
|
await CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
|
||||||
SaveFileDialogParams(
|
sourceFilePath: outFile.path, destinationFileName: 'selected_patches_$dateTime.json',),);
|
||||||
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, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
Sentry.captureException(e, stackTrace: s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +101,7 @@ class SettingsViewModel extends BaseViewModel {
|
|||||||
_toast.showBottom('settingsView.importedPatches');
|
_toast.showBottom('settingsView.importedPatches');
|
||||||
}
|
}
|
||||||
} on Exception catch (e, s) {
|
} on Exception catch (e, s) {
|
||||||
Sentry.captureException(e, stackTrace: s).ignore();
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
_toast.showBottom('settingsView.jsonSelectorErrorMessage');
|
_toast.showBottom('settingsView.jsonSelectorErrorMessage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user