chore: update dependencies (#772)

* chore: updated some dependencies

* refactor: reimplemented cache interceptor

* Revert "Updated dependencies & migrated breaking changes"

This reverts commit e6743b0d6b2552fdbf1c99d23e158e682362dd5d.

* chore: migrated flutter_local_notifications

* revert: reimplemented cache interceptor
This commit is contained in:
Aman Sikarwar
2023-04-18 19:45:29 +05:30
committed by GitHub
parent 37b583f560
commit 197770b68b
10 changed files with 199 additions and 92 deletions

View File

@ -3,7 +3,6 @@ import 'dart:io';
import 'package:app_installer/app_installer.dart';
import 'package:cross_connectivity/cross_connectivity.dart';
import 'package:device_apps/device_apps.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
@ -25,12 +24,14 @@ import 'package:timezone/timezone.dart' as tz;
@lazySingleton
class HomeViewModel extends BaseViewModel {
final NavigationService _navigationService = locator<NavigationService>();
final NavigationService _navigationService =
locator<NavigationService>();
final ManagerAPI _managerAPI = locator<ManagerAPI>();
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final GithubAPI _githubAPI = locator<GithubAPI>();
final Toast _toast = locator<Toast>();
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
final flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
DateTime? _lastUpdate;
bool showUpdatableApps = false;
List<PatchedApplication> patchedInstalledApps = [];
@ -41,8 +42,17 @@ class HomeViewModel extends BaseViewModel {
const InitializationSettings(
android: AndroidInitializationSettings('ic_notification'),
),
onSelectNotification: (p) =>
DeviceApps.openApp('app.revanced.manager.flutter'),
onDidReceiveNotificationResponse: (response) async {
if (response.id == 0) {
_toast.showBottom('homeView.installingMessage');
final File? managerApk = await _managerAPI.downloadManager();
if (managerApk != null) {
await AppInstaller.installApk(managerApk.path);
} else {
_toast.showBottom('homeView.errorDownloadMessage');
}
}
},
);
flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
@ -52,6 +62,19 @@ class HomeViewModel extends BaseViewModel {
if (!isConnected) {
_toast.showBottom('homeView.noConnection');
}
final NotificationAppLaunchDetails? notificationAppLaunchDetails =
await flutterLocalNotificationsPlugin
.getNotificationAppLaunchDetails();
if (notificationAppLaunchDetails?.didNotificationLaunchApp ??
false) {
_toast.showBottom('homeView.installingMessage');
final File? managerApk = await _managerAPI.downloadManager();
if (managerApk != null) {
await AppInstaller.installApk(managerApk.path);
} else {
_toast.showBottom('homeView.errorDownloadMessage');
}
}
_getPatchedApps();
_managerAPI.reAssessSavedApps().then((_) => _getPatchedApps());
}
@ -86,8 +109,10 @@ class HomeViewModel extends BaseViewModel {
}
Future<bool> hasManagerUpdates() async {
final String? latestVersion = await _managerAPI.getLatestManagerVersion();
final String currentVersion = await _managerAPI.getCurrentManagerVersion();
final String? latestVersion =
await _managerAPI.getLatestManagerVersion();
final String currentVersion =
await _managerAPI.getCurrentManagerVersion();
if (latestVersion != null) {
try {
final int latestVersionInt =
@ -171,7 +196,9 @@ class HomeViewModel extends BaseViewModel {
_toast.showBottom('homeView.updatesDisabled');
}
Future<void> showUpdateConfirmationDialog(BuildContext parentContext) {
Future<void> showUpdateConfirmationDialog(
BuildContext parentContext,
) {
return showModalBottomSheet(
context: parentContext,
isScrollControlled: true,

View File

@ -17,12 +17,14 @@ import 'package:stacked/stacked.dart';
class NavigationViewModel extends IndexTrackingViewModel {
Future<void> initialize(BuildContext context) async {
locator<Toast>().initialize(context);
final SharedPreferences prefs = await SharedPreferences.getInstance();
final SharedPreferences prefs =
await SharedPreferences.getInstance();
if (prefs.getBool('permissionsRequested') == null) {
await prefs.setBool('permissionsRequested', true);
RootAPI().hasRootPermissions().then(
(value) => Permission.requestInstallPackages.request().then(
(value) => Permission.ignoreBatteryOptimizations.request(),
(value) =>
Permission.ignoreBatteryOptimizations.request(),
),
);
}
@ -37,7 +39,8 @@ class NavigationViewModel extends IndexTrackingViewModel {
SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
systemNavigationBarIconBrightness:
DynamicTheme.of(context)!.theme.brightness == Brightness.light
DynamicTheme.of(context)!.theme.brightness ==
Brightness.light
? Brightness.dark
: Brightness.light,
),

View File

@ -17,7 +17,8 @@ import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
class SettingsViewModel extends BaseViewModel {
final NavigationService _navigationService = locator<NavigationService>();
final NavigationService _navigationService =
locator<NavigationService>();
final ManagerAPI _managerAPI = locator<ManagerAPI>();
final Toast _toast = locator<Toast>();
@ -62,8 +63,11 @@ class SettingsViewModel extends BaseViewModel {
try {
final File outFile = File(_managerAPI.storedPatchesFile);
if (outFile.existsSync()) {
final String dateTime =
DateTime.now().toString().replaceAll(' ', '_').split('.').first;
final String dateTime = DateTime.now()
.toString()
.replaceAll(' ', '_')
.split('.')
.first;
await CRFileSaver.saveFileWithDialog(
SaveFileDialogParams(
sourceFilePath: outFile.path,
@ -83,7 +87,8 @@ class SettingsViewModel extends BaseViewModel {
Future<void> importPatches() async {
try {
final FilePickerResult? result = await FilePicker.platform.pickFiles(
final FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['json'],
);
@ -151,7 +156,7 @@ class SettingsViewModel extends BaseViewModel {
Future<int> getSdkVersion() async {
final AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
return info.version.sdkInt ?? -1;
return info.version.sdkInt;
}
Future<void> deleteLogs() async {

View File

@ -16,12 +16,12 @@ class UpdateConfirmationDialog extends StatelessWidget {
expand: false,
snap: true,
snapSizes: const [0.5],
builder: (context, scrollController) => SingleChildScrollView(
builder: (_, scrollController) => SingleChildScrollView(
controller: scrollController,
child: SafeArea(
child: FutureBuilder<Map<String, dynamic>?>(
future: model.getLatestManagerRelease(),
builder: (context, snapshot) {
builder: (_, snapshot) {
if (!snapshot.hasData) {
return const SizedBox(
height: 300,
@ -45,7 +45,8 @@ class UpdateConfirmationDialog extends StatelessWidget {
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
I18nText(
'homeView.updateDialogTitle',
@ -62,12 +63,14 @@ class UpdateConfirmationDialog extends StatelessWidget {
children: [
Icon(
Icons.new_releases_outlined,
color:
Theme.of(context).colorScheme.secondary,
color: Theme.of(context)
.colorScheme
.secondary,
),
const SizedBox(width: 8.0),
Text(
snapshot.data!['tag_name'] ?? 'Unknown',
snapshot.data!['tag_name'] ??
'Unknown',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
@ -93,7 +96,8 @@ class UpdateConfirmationDialog extends StatelessWidget {
),
),
Padding(
padding: const EdgeInsets.only(left: 24.0, bottom: 12.0),
padding:
const EdgeInsets.only(left: 24.0, bottom: 12.0),
child: I18nText(
'homeView.updateChangelogTitle',
child: Text(
@ -109,9 +113,12 @@ class UpdateConfirmationDialog extends StatelessWidget {
),
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 24.0),
margin:
const EdgeInsets.symmetric(horizontal: 24.0),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
color: Theme.of(context)
.colorScheme
.secondaryContainer,
borderRadius: BorderRadius.circular(12.0),
),
child: Markdown(