mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
commit
768ad0c9bc
@ -1,12 +1,12 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:app_installer/app_installer.dart';
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:cr_file_saver/file_saver.dart';
|
import 'package:cr_file_saver/file_saver.dart';
|
||||||
import 'package:device_apps/device_apps.dart';
|
import 'package:device_apps/device_apps.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
|
import 'package:install_plugin/install_plugin.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';
|
||||||
import 'package:revanced_manager/models/patch.dart';
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
@ -232,10 +232,8 @@ class PatcherAPI {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await AppInstaller.installApk(_outFile!.path);
|
final install = await InstallPlugin.installApk(_outFile!.path);
|
||||||
return await DeviceApps.isAppInstalled(
|
return install['isSuccess'];
|
||||||
patchedApp.packageName,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
|
@ -73,7 +73,7 @@ class RootAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<String>> getInstalledApps() async {
|
Future<List<String>> getInstalledApps() async {
|
||||||
final List<String> apps = List.empty();
|
final List<String> apps = List.empty(growable: true);
|
||||||
try {
|
try {
|
||||||
String? res = await Root.exec(
|
String? res = await Root.exec(
|
||||||
cmd: 'ls "$_revancedDirPath"',
|
cmd: 'ls "$_revancedDirPath"',
|
||||||
|
@ -88,7 +88,7 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: model.apps.isEmpty
|
: model.allApps.isEmpty
|
||||||
? const AppSkeletonLoader()
|
? const AppSkeletonLoader()
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12.0)
|
padding: const EdgeInsets.symmetric(horizontal: 12.0)
|
||||||
|
@ -45,9 +45,7 @@ class AppSelectorViewModel extends BaseViewModel {
|
|||||||
.length
|
.length
|
||||||
.compareTo(_patcherAPI.getFilteredPatches(a.packageName).length),
|
.compareTo(_patcherAPI.getFilteredPatches(a.packageName).length),
|
||||||
);
|
);
|
||||||
noApps = apps.isEmpty;
|
|
||||||
getAllApps();
|
getAllApps();
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ class AppSelectorViewModel extends BaseViewModel {
|
|||||||
.toSet()
|
.toSet()
|
||||||
.where((name) => !apps.any((app) => app.packageName == name))
|
.where((name) => !apps.any((app) => app.packageName == name))
|
||||||
.toList();
|
.toList();
|
||||||
|
noApps = allApps.isEmpty;
|
||||||
return allApps;
|
return allApps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class HomeView extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
child: model.showUpdatableApps
|
child: model.showUpdatableApps
|
||||||
? AvailableUpdatesCard()
|
? AvailableUpdatesCard()
|
||||||
: InstalledAppsCard(),
|
: const InstalledAppsCard(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// ignore_for_file: use_build_context_synchronously
|
// ignore_for_file: use_build_context_synchronously
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:app_installer/app_installer.dart';
|
|
||||||
import 'package:cross_connectivity/cross_connectivity.dart';
|
import 'package:cross_connectivity/cross_connectivity.dart';
|
||||||
import 'package:flutter/foundation.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';
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
|
import 'package:install_plugin/install_plugin.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';
|
||||||
import 'package:revanced_manager/app/app.router.dart';
|
import 'package:revanced_manager/app/app.router.dart';
|
||||||
@ -51,7 +51,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
_toast.showBottom('homeView.installingMessage');
|
_toast.showBottom('homeView.installingMessage');
|
||||||
final File? managerApk = await _managerAPI.downloadManager();
|
final File? managerApk = await _managerAPI.downloadManager();
|
||||||
if (managerApk != null) {
|
if (managerApk != null) {
|
||||||
await AppInstaller.installApk(managerApk.path);
|
await InstallPlugin.installApk(managerApk.path);
|
||||||
} else {
|
} else {
|
||||||
_toast.showBottom('homeView.errorDownloadMessage');
|
_toast.showBottom('homeView.errorDownloadMessage');
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
_toast.showBottom('homeView.installingMessage');
|
_toast.showBottom('homeView.installingMessage');
|
||||||
final File? managerApk = await _managerAPI.downloadManager();
|
final File? managerApk = await _managerAPI.downloadManager();
|
||||||
if (managerApk != null) {
|
if (managerApk != null) {
|
||||||
await AppInstaller.installApk(managerApk.path);
|
await InstallPlugin.installApk(managerApk.path);
|
||||||
} else {
|
} else {
|
||||||
_toast.showBottom('homeView.errorDownloadMessage');
|
_toast.showBottom('homeView.errorDownloadMessage');
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
child: CustomMaterialButton(
|
child: CustomMaterialButton(
|
||||||
label: I18nText('updateButton'),
|
label: I18nText('updateButton'),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await AppInstaller.installApk(
|
await InstallPlugin.installApk(
|
||||||
downloadedApk!.path,
|
downloadedApk!.path,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -318,7 +318,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
// UILocalNotificationDateInterpretation.absoluteTime,
|
// UILocalNotificationDateInterpretation.absoluteTime,
|
||||||
// );
|
// );
|
||||||
_toast.showBottom('homeView.installingMessage');
|
_toast.showBottom('homeView.installingMessage');
|
||||||
await AppInstaller.installApk(managerApk.path);
|
await InstallPlugin.installApk(managerApk.path);
|
||||||
} else {
|
} else {
|
||||||
_toast.showBottom('homeView.errorDownloadMessage');
|
_toast.showBottom('homeView.errorDownloadMessage');
|
||||||
}
|
}
|
||||||
|
@ -13,58 +13,68 @@ class NavigationView extends StatelessWidget {
|
|||||||
return ViewModelBuilder<NavigationViewModel>.reactive(
|
return ViewModelBuilder<NavigationViewModel>.reactive(
|
||||||
onViewModelReady: (model) => model.initialize(context),
|
onViewModelReady: (model) => model.initialize(context),
|
||||||
viewModelBuilder: () => locator<NavigationViewModel>(),
|
viewModelBuilder: () => locator<NavigationViewModel>(),
|
||||||
builder: (context, model, child) => Scaffold(
|
builder: (context, model, child) => WillPopScope(
|
||||||
body: PageTransitionSwitcher(
|
onWillPop: () async {
|
||||||
duration: const Duration(milliseconds: 400),
|
if (model.currentIndex == 0) {
|
||||||
transitionBuilder: (
|
return true;
|
||||||
Widget child,
|
} else {
|
||||||
Animation<double> animation,
|
model.setIndex(0);
|
||||||
Animation<double> secondaryAnimation,
|
return false;
|
||||||
) {
|
}
|
||||||
return FadeThroughTransition(
|
},
|
||||||
animation: animation,
|
child: Scaffold(
|
||||||
secondaryAnimation: secondaryAnimation,
|
body: PageTransitionSwitcher(
|
||||||
fillColor: Theme.of(context).colorScheme.surface,
|
duration: const Duration(milliseconds: 400),
|
||||||
child: child,
|
transitionBuilder: (
|
||||||
);
|
Widget child,
|
||||||
},
|
Animation<double> animation,
|
||||||
child: model.getViewForIndex(model.currentIndex),
|
Animation<double> secondaryAnimation,
|
||||||
),
|
) {
|
||||||
bottomNavigationBar: NavigationBar(
|
return FadeThroughTransition(
|
||||||
onDestinationSelected: model.setIndex,
|
animation: animation,
|
||||||
selectedIndex: model.currentIndex,
|
secondaryAnimation: secondaryAnimation,
|
||||||
destinations: <Widget>[
|
fillColor: Theme.of(context).colorScheme.surface,
|
||||||
NavigationDestination(
|
child: child,
|
||||||
icon: model.isIndexSelected(0)
|
);
|
||||||
? const Icon(Icons.dashboard)
|
},
|
||||||
: const Icon(Icons.dashboard_outlined),
|
child: model.getViewForIndex(model.currentIndex),
|
||||||
label: FlutterI18n.translate(
|
),
|
||||||
context,
|
bottomNavigationBar: NavigationBar(
|
||||||
'navigationView.dashboardTab',
|
onDestinationSelected: model.setIndex,
|
||||||
|
selectedIndex: model.currentIndex,
|
||||||
|
destinations: <Widget>[
|
||||||
|
NavigationDestination(
|
||||||
|
icon: model.isIndexSelected(0)
|
||||||
|
? const Icon(Icons.dashboard)
|
||||||
|
: const Icon(Icons.dashboard_outlined),
|
||||||
|
label: FlutterI18n.translate(
|
||||||
|
context,
|
||||||
|
'navigationView.dashboardTab',
|
||||||
|
),
|
||||||
|
tooltip: '',
|
||||||
),
|
),
|
||||||
tooltip: '',
|
NavigationDestination(
|
||||||
),
|
icon: model.isIndexSelected(1)
|
||||||
NavigationDestination(
|
? const Icon(Icons.build)
|
||||||
icon: model.isIndexSelected(1)
|
: const Icon(Icons.build_outlined),
|
||||||
? const Icon(Icons.build)
|
label: FlutterI18n.translate(
|
||||||
: const Icon(Icons.build_outlined),
|
context,
|
||||||
label: FlutterI18n.translate(
|
'navigationView.patcherTab',
|
||||||
context,
|
),
|
||||||
'navigationView.patcherTab',
|
tooltip: '',
|
||||||
),
|
),
|
||||||
tooltip: '',
|
NavigationDestination(
|
||||||
),
|
icon: model.isIndexSelected(2)
|
||||||
NavigationDestination(
|
? const Icon(Icons.settings)
|
||||||
icon: model.isIndexSelected(2)
|
: const Icon(Icons.settings_outlined),
|
||||||
? const Icon(Icons.settings)
|
label: FlutterI18n.translate(
|
||||||
: const Icon(Icons.settings_outlined),
|
context,
|
||||||
label: FlutterI18n.translate(
|
'navigationView.settingsTab',
|
||||||
context,
|
),
|
||||||
'navigationView.settingsTab',
|
tooltip: '',
|
||||||
),
|
),
|
||||||
tooltip: '',
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -84,12 +84,16 @@ class _InstalledAppItemState extends State<InstalledAppItem> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Flexible(
|
||||||
widget.patchesCount == 1
|
child: Text(
|
||||||
? '• ${widget.patchesCount} patch'
|
widget.patchesCount == 1
|
||||||
: '• ${widget.patchesCount} patches',
|
? '• ${widget.patchesCount} patch'
|
||||||
style: TextStyle(
|
: '• ${widget.patchesCount} patches',
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -78,12 +78,16 @@ class _NotInstalledAppItem extends State<NotInstalledAppItem> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text(
|
Flexible(
|
||||||
widget.patchesCount == 1
|
child: Text(
|
||||||
? '• ${widget.patchesCount} patch'
|
widget.patchesCount == 1
|
||||||
: '• ${widget.patchesCount} patches',
|
? '• ${widget.patchesCount} patch'
|
||||||
style: TextStyle(
|
: '• ${widget.patchesCount} patches',
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -1,16 +1,49 @@
|
|||||||
|
import 'package:device_apps/device_apps.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: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';
|
||||||
|
import 'package:revanced_manager/services/manager_api.dart';
|
||||||
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/application_item.dart';
|
import 'package:revanced_manager/ui/widgets/shared/application_item.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
||||||
|
|
||||||
class InstalledAppsCard extends StatelessWidget {
|
class InstalledAppsCard extends StatefulWidget {
|
||||||
InstalledAppsCard({Key? key}) : super(key: key);
|
const InstalledAppsCard({Key? key}) : super(key: key);
|
||||||
|
|
||||||
final List<PatchedApplication> apps =
|
@override
|
||||||
locator<HomeViewModel>().patchedInstalledApps;
|
State<InstalledAppsCard> createState() => _InstalledAppsCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _InstalledAppsCardState extends State<InstalledAppsCard> {
|
||||||
|
List<PatchedApplication> apps = locator<HomeViewModel>().patchedInstalledApps;
|
||||||
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
|
List<PatchedApplication> patchedApps = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_getApps();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _getApps() async {
|
||||||
|
if (apps.isNotEmpty) {
|
||||||
|
patchedApps = [...apps];
|
||||||
|
for (final element in apps) {
|
||||||
|
await DeviceApps.getApp(element.packageName).then((value) {
|
||||||
|
if (element.version != value?.versionName) {
|
||||||
|
patchedApps.remove(element);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (apps.length != patchedApps.length) {
|
||||||
|
await _managerAPI.setPatchedApps(patchedApps);
|
||||||
|
apps.clear();
|
||||||
|
apps = [...patchedApps];
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -4,14 +4,13 @@ homepage: https://github.com/revanced/revanced-manager
|
|||||||
|
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 1.4.0+100400000
|
version: 1.4.1+100400001
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.0.0 <4.0.0'
|
sdk: '>=3.0.0 <4.0.0'
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
animations: ^2.0.7
|
animations: ^2.0.7
|
||||||
app_installer: ^1.1.0
|
|
||||||
collection: ^1.17.0
|
collection: ^1.17.0
|
||||||
cross_connectivity: ^3.0.5
|
cross_connectivity: ^3.0.5
|
||||||
cr_file_saver:
|
cr_file_saver:
|
||||||
@ -59,8 +58,8 @@ dependencies:
|
|||||||
pull_to_refresh: ^2.0.0
|
pull_to_refresh: ^2.0.0
|
||||||
root:
|
root:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/gokul1630/root
|
url: https://github.com/EvadeMaster/root
|
||||||
ref: main
|
ref: 9bcf0dc06b8e2e3ccd5fbd16bc849938e817b36b
|
||||||
share_extend: ^2.0.0
|
share_extend: ^2.0.0
|
||||||
shared_preferences: ^2.1.0
|
shared_preferences: ^2.1.0
|
||||||
skeletons: ^0.0.3
|
skeletons: ^0.0.3
|
||||||
@ -75,6 +74,7 @@ dependencies:
|
|||||||
flutter_dotenv: ^5.0.2
|
flutter_dotenv: ^5.0.2
|
||||||
flutter_markdown: ^0.6.14
|
flutter_markdown: ^0.6.14
|
||||||
dio_cache_interceptor: ^3.4.0
|
dio_cache_interceptor: ^3.4.0
|
||||||
|
install_plugin: ^2.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
json_serializable: ^6.6.1
|
json_serializable: ^6.6.1
|
||||||
|
Loading…
Reference in New Issue
Block a user