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:
EvadeMaster
2023-03-03 18:06:24 +07:00
parent 6d60541626
commit 68ccefc59f
15 changed files with 94 additions and 95 deletions

View File

@ -88,7 +88,7 @@ class AppSelectorViewModel extends BaseViewModel {
}
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s).ignore();
await Sentry.captureException(e, stackTrace: s);
_toast.showBottom('appSelectorView.errorMessage');
}
}

View File

@ -96,7 +96,7 @@ class HomeViewModel extends BaseViewModel {
int.parse(currentVersion.replaceAll(RegExp('[^0-9]'), ''));
return latestVersionInt > currentVersionInt;
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s).ignore();
await Sentry.captureException(e, stackTrace: s);
return false;
}
}
@ -138,7 +138,7 @@ class HomeViewModel extends BaseViewModel {
_toast.showBottom('homeView.errorDownloadMessage');
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s).ignore();
await Sentry.captureException(e, stackTrace: s);
_toast.showBottom('homeView.errorInstallMessage');
}
}

View File

@ -57,7 +57,7 @@ class InstallerViewModel extends BaseViewModel {
),
).then((value) => FlutterBackground.enableBackgroundExecution());
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s).ignore();
await Sentry.captureException(e, stackTrace: s);
// ignore
}
}
@ -131,13 +131,14 @@ class InstallerViewModel extends BaseViewModel {
_app.apkFilePath,
_patches,
);
} on Exception catch (e) {
} on Exception catch (e, s) {
update(
-100.0,
'Aborting...',
'An error occurred! Aborting\nError:\n$e',
);
rethrow;
await Sentry.captureException(e, stackTrace: s);
throw await Sentry.captureException(e, stackTrace: s);
}
} else {
update(-100.0, 'Aborting...', 'No app or patches selected! Aborting');
@ -145,13 +146,14 @@ class InstallerViewModel extends BaseViewModel {
if (FlutterBackground.isBackgroundExecutionEnabled) {
try {
FlutterBackground.disableBackgroundExecution();
} on Exception {
rethrow;
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
// ignore
}
}
await Wakelock.disable();
} 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) {
Sentry.captureException(e, stackTrace: s).ignore();
await Sentry.captureException(e, stackTrace: s);
}
}
@ -218,7 +220,7 @@ class InstallerViewModel extends BaseViewModel {
try {
_patcherAPI.exportPatchedFile(_app.name, _app.version);
} 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 {
_patcherAPI.sharePatchedFile(_app.name, _app.version);
} 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>().notifyListeners();
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s).ignore();
await Sentry.captureException(e, stackTrace: s);
}
}

View File

@ -15,9 +15,9 @@ import 'package:stacked/stacked.dart';
@lazySingleton
class NavigationViewModel extends IndexTrackingViewModel {
final prefs = locator<SharedPreferences>();
Future<void> initialize(BuildContext context) async {
locator<Toast>().initialize(context);
final SharedPreferences prefs = await SharedPreferences.getInstance();
if (prefs.getBool('permissionsRequested') == null) {
await prefs.setBool('permissionsRequested', true);
RootAPI().hasRootPermissions().then(

View File

@ -3,6 +3,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.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/toast.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
@ -16,14 +17,23 @@ final _settingViewModel = SettingsViewModel();
class SUpdateLanguage extends BaseViewModel {
final CrowdinAPI _crowdinAPI = locator<CrowdinAPI>();
final SharedPreferences _prefs = locator<SharedPreferences>();
final Toast _toast = locator<Toast>();
late SharedPreferences _prefs;
String selectedLanguage = 'English';
String get selectedLanguageLocale => _prefs.getString('language') ?? 'en_US';
String selectedLanguageLocale = prefs.getString('language') ?? 'en_US';
List languages = [];
Future<void> initialize() async {
_prefs = await SharedPreferences.getInstance();
selectedLanguageLocale =
_prefs.getString('language') ?? selectedLanguageLocale;
notifyListeners();
}
Future<void> updateLanguage(BuildContext context, String? value) async {
if (value != null) {
selectedLanguageLocale = value;
_prefs = await SharedPreferences.getInstance();
await _prefs.setString('language', value);
await FlutterI18n.refresh(context, Locale(value));
timeago.setLocaleMessages(value, timeago.EnMessages());

View File

@ -1,5 +1,4 @@
import 'dart:io';
import 'package:cr_file_saver/file_saver.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:file_picker/file_picker.dart';
@ -75,18 +74,14 @@ class SettingsViewModel extends BaseViewModel {
if (outFile.existsSync()) {
final String dateTime =
DateTime.now().toString().replaceAll(' ', '_').split('.').first;
await CRFileSaver.saveFileWithDialog(
SaveFileDialogParams(
sourceFilePath: outFile.path,
destinationFileName: 'selected_patches_$dateTime.json',
),
);
await CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
sourceFilePath: outFile.path, destinationFileName: 'selected_patches_$dateTime.json',),);
_toast.showBottom('settingsView.exportedPatches');
} else {
_toast.showBottom('settingsView.noExportFileFound');
}
} 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');
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s).ignore();
await Sentry.captureException(e, stackTrace: s);
_toast.showBottom('settingsView.jsonSelectorErrorMessage');
}
}