mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 04:37:37 +02:00
Revert "fix: save patched and installed apps on prefs, improve installer log, improve dashboard with real data (wip)"
This reverts commit ce09a5264a
.
This commit is contained in:
@ -4,6 +4,7 @@ import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:package_archive_info/package_archive_info.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/services/patcher_api.dart';
|
||||
@ -38,8 +39,6 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
packageName: application.packageName,
|
||||
version: application.versionName!,
|
||||
apkFilePath: application.apkFilePath,
|
||||
icon: application.icon,
|
||||
patchDate: DateTime.now(),
|
||||
isRooted: isRooted,
|
||||
isFromStorage: isFromStorage,
|
||||
);
|
||||
@ -58,25 +57,20 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
);
|
||||
if (result != null && result.files.single.path != null) {
|
||||
File apkFile = File(result.files.single.path!);
|
||||
ApplicationWithIcon? application =
|
||||
await DeviceApps.getAppFromStorage(apkFile.path, true)
|
||||
as ApplicationWithIcon?;
|
||||
if (application != null) {
|
||||
PatchedApplication app = PatchedApplication(
|
||||
name: application.appName,
|
||||
packageName: application.packageName,
|
||||
version: application.versionName!,
|
||||
apkFilePath: result.files.single.path!,
|
||||
icon: application.icon,
|
||||
patchDate: DateTime.now(),
|
||||
isRooted: isRooted,
|
||||
isFromStorage: isFromStorage,
|
||||
);
|
||||
locator<AppSelectorViewModel>().selectedApp = app;
|
||||
locator<PatchesSelectorViewModel>().selectedPatches.clear();
|
||||
locator<PatcherViewModel>().dimPatchCard = false;
|
||||
locator<PatcherViewModel>().notifyListeners();
|
||||
}
|
||||
PackageArchiveInfo? packageArchiveInfo =
|
||||
await PackageArchiveInfo.fromPath(apkFile.path);
|
||||
PatchedApplication app = PatchedApplication(
|
||||
name: packageArchiveInfo.appName,
|
||||
packageName: packageArchiveInfo.packageName,
|
||||
version: packageArchiveInfo.version,
|
||||
apkFilePath: result.files.single.path!,
|
||||
isRooted: isRooted,
|
||||
isFromStorage: isFromStorage,
|
||||
);
|
||||
locator<AppSelectorViewModel>().selectedApp = app;
|
||||
locator<PatchesSelectorViewModel>().selectedPatches.clear();
|
||||
locator<PatcherViewModel>().dimPatchCard = false;
|
||||
locator<PatcherViewModel>().notifyListeners();
|
||||
}
|
||||
} on Exception {
|
||||
Fluttertoast.showToast(
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/theme.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/available_updates_card.dart';
|
||||
@ -15,8 +14,7 @@ class HomeView extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ViewModelBuilder.reactive(
|
||||
disposeViewModel: false,
|
||||
viewModelBuilder: () => locator<HomeViewModel>(),
|
||||
viewModelBuilder: () => HomeViewModel(),
|
||||
builder: (context, model, child) => Scaffold(
|
||||
body: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
|
@ -1,22 +1,8 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
@lazySingleton
|
||||
class HomeViewModel extends BaseViewModel {
|
||||
Future downloadPatches() => locator<ManagerAPI>().downloadPatches();
|
||||
Future downloadIntegrations() => locator<ManagerAPI>().downloadIntegrations();
|
||||
|
||||
Future<List<PatchedApplication>> getPatchedApps() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
List<String> patchedApps = prefs.getStringList('patchedApps') ?? [];
|
||||
return patchedApps
|
||||
.map((app) => PatchedApplication.fromJson(json.decode(app)))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
@ -82,8 +81,9 @@ class InstallerView extends StatelessWidget {
|
||||
),
|
||||
child: SelectableText(
|
||||
model.logs,
|
||||
style: GoogleFonts.jetBrainsMono(
|
||||
fontSize: 12,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
fontSize: 15,
|
||||
height: 1.5,
|
||||
),
|
||||
),
|
||||
|
@ -7,7 +7,6 @@ import 'package:revanced_manager/services/patcher_api.dart';
|
||||
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
class InstallerViewModel extends BaseViewModel {
|
||||
@ -62,25 +61,29 @@ class InstallerViewModel extends BaseViewModel {
|
||||
List<Patch> selectedPatches =
|
||||
locator<PatchesSelectorViewModel>().selectedPatches;
|
||||
if (selectedPatches.isNotEmpty) {
|
||||
addLog('Initializing installer');
|
||||
addLog('Initializing installer...');
|
||||
if (selectedApp.isRooted && !selectedApp.isFromStorage) {
|
||||
addLog('Checking if an old patched version exists');
|
||||
addLog('Checking if an old patched version exists...');
|
||||
bool oldExists =
|
||||
await locator<PatcherAPI>().checkOldPatch(selectedApp);
|
||||
addLog('Done');
|
||||
if (oldExists) {
|
||||
addLog('Deleting old patched version');
|
||||
addLog('Deleting old patched version...');
|
||||
await locator<PatcherAPI>().deleteOldPatch(selectedApp);
|
||||
addLog('Done');
|
||||
}
|
||||
}
|
||||
addLog('Creating working directory');
|
||||
addLog('Creating working directory...');
|
||||
bool? isSuccess = await locator<PatcherAPI>().initPatcher();
|
||||
if (isSuccess != null && isSuccess) {
|
||||
addLog('Done');
|
||||
updateProgress(0.1);
|
||||
addLog('Copying original apk');
|
||||
addLog('Copying original apk...');
|
||||
isSuccess = await locator<PatcherAPI>().copyInputFile(apkFilePath);
|
||||
if (isSuccess != null && isSuccess) {
|
||||
addLog('Done');
|
||||
updateProgress(0.2);
|
||||
addLog('Creating patcher');
|
||||
addLog('Creating patcher...');
|
||||
bool resourcePatching = false;
|
||||
if (selectedApp.packageName == 'com.google.android.youtube' ||
|
||||
selectedApp.packageName ==
|
||||
@ -92,23 +95,29 @@ class InstallerViewModel extends BaseViewModel {
|
||||
);
|
||||
if (isSuccess != null && isSuccess) {
|
||||
if (selectedApp.packageName == 'com.google.android.youtube') {
|
||||
addLog('Done');
|
||||
updateProgress(0.3);
|
||||
addLog('Merging integrations');
|
||||
addLog('Merging integrations...');
|
||||
isSuccess = await locator<PatcherAPI>().mergeIntegrations();
|
||||
}
|
||||
if (isSuccess != null && isSuccess) {
|
||||
addLog('Done');
|
||||
updateProgress(0.5);
|
||||
addLog('Applying patches...');
|
||||
isSuccess =
|
||||
await locator<PatcherAPI>().applyPatches(selectedPatches);
|
||||
if (isSuccess != null && isSuccess) {
|
||||
addLog('Done');
|
||||
updateProgress(0.7);
|
||||
addLog('Repacking patched apk');
|
||||
addLog('Repacking patched apk...');
|
||||
isSuccess = await locator<PatcherAPI>().repackPatchedFile();
|
||||
if (isSuccess != null && isSuccess) {
|
||||
addLog('Done');
|
||||
updateProgress(0.9);
|
||||
addLog('Signing patched apk');
|
||||
addLog('Signing patched apk...');
|
||||
isSuccess = await locator<PatcherAPI>().signPatchedFile();
|
||||
if (isSuccess != null && isSuccess) {
|
||||
addLog('Done');
|
||||
showButtons = true;
|
||||
updateProgress(1.0);
|
||||
}
|
||||
@ -119,13 +128,13 @@ class InstallerViewModel extends BaseViewModel {
|
||||
}
|
||||
}
|
||||
if (isSuccess == null || !isSuccess) {
|
||||
addLog('An error occurred! Aborting');
|
||||
addLog('An error occurred! Aborting...');
|
||||
}
|
||||
} else {
|
||||
addLog('No patches selected! Aborting');
|
||||
addLog('No patches selected! Aborting...');
|
||||
}
|
||||
} else {
|
||||
addLog('No app selected! Aborting');
|
||||
addLog('No app selected! Aborting...');
|
||||
}
|
||||
await FlutterBackground.disableBackgroundExecution();
|
||||
isPatching = false;
|
||||
@ -136,14 +145,13 @@ class InstallerViewModel extends BaseViewModel {
|
||||
locator<AppSelectorViewModel>().selectedApp;
|
||||
if (selectedApp != null) {
|
||||
addLog(selectedApp.isRooted
|
||||
? 'Installing patched file using root method'
|
||||
: 'Installing patched file using nonroot method');
|
||||
? 'Installing patched file using root method...'
|
||||
: 'Installing patched file using nonroot method...');
|
||||
isInstalled = await locator<PatcherAPI>().installPatchedFile(selectedApp);
|
||||
if (isInstalled) {
|
||||
addLog('Done');
|
||||
await saveApp(selectedApp);
|
||||
} else {
|
||||
addLog('An error occurred! Aborting');
|
||||
addLog('An error occurred! Aborting...');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,14 +181,4 @@ class InstallerViewModel extends BaseViewModel {
|
||||
DeviceApps.openApp(selectedApp.packageName);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> saveApp(PatchedApplication selectedApp) async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
List<String> patchedApps = prefs.getStringList('patchedApps') ?? [];
|
||||
String app = selectedApp.toJson().toString();
|
||||
if (!patchedApps.contains(app)) {
|
||||
patchedApps.add(app);
|
||||
prefs.setStringList('patchedApps', patchedApps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +1,40 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/constants.dart';
|
||||
import 'package:revanced_manager/ui/widgets/patch_text_button.dart';
|
||||
import 'package:timeago/timeago.dart';
|
||||
|
||||
class ApplicationItem extends StatelessWidget {
|
||||
final Uint8List icon;
|
||||
final String asset;
|
||||
final String name;
|
||||
final DateTime patchDate;
|
||||
final String releaseDate;
|
||||
final Function()? onPressed;
|
||||
|
||||
const ApplicationItem({
|
||||
Key? key,
|
||||
required this.icon,
|
||||
required this.asset,
|
||||
required this.name,
|
||||
required this.patchDate,
|
||||
required this.releaseDate,
|
||||
required this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isSVG = asset.endsWith('.svg');
|
||||
return ListTile(
|
||||
horizontalTitleGap: 12.0,
|
||||
leading: Image.memory(icon),
|
||||
leading: isSVG
|
||||
? SvgPicture.asset(
|
||||
asset,
|
||||
height: 26,
|
||||
width: 26,
|
||||
)
|
||||
: Image.asset(
|
||||
asset,
|
||||
height: 39,
|
||||
width: 39,
|
||||
),
|
||||
title: Text(
|
||||
name,
|
||||
style: GoogleFonts.roboto(
|
||||
@ -33,7 +43,7 @@ class ApplicationItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
format(patchDate),
|
||||
releaseDate,
|
||||
style: robotoTextStyle,
|
||||
),
|
||||
trailing: PatchTextButton(
|
||||
|
@ -1,9 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/application_item.dart';
|
||||
import 'package:revanced_manager/ui/widgets/patch_text_button.dart';
|
||||
|
||||
@ -53,19 +50,17 @@ class AvailableUpdatesCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
FutureBuilder<List<PatchedApplication>>(
|
||||
future: locator<HomeViewModel>().getPatchedApps(),
|
||||
builder: (context, snapshot) =>
|
||||
snapshot.hasData && snapshot.data!.length > 1
|
||||
? ListView.builder(
|
||||
itemBuilder: (context, index) => ApplicationItem(
|
||||
icon: snapshot.data![index].icon,
|
||||
name: snapshot.data![index].name,
|
||||
patchDate: snapshot.data![index].patchDate,
|
||||
onPressed: () => {},
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
ApplicationItem(
|
||||
asset: 'assets/images/revanced.svg',
|
||||
name: 'ReVanced',
|
||||
releaseDate: '2 days ago',
|
||||
onPressed: () => {},
|
||||
),
|
||||
ApplicationItem(
|
||||
asset: 'assets/images/reddit.png',
|
||||
name: 'ReReddit',
|
||||
releaseDate: 'Released 1 month ago',
|
||||
onPressed: () => {},
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
I18nText(
|
||||
|
@ -1,9 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||
import 'package:revanced_manager/ui/widgets/application_item.dart';
|
||||
|
||||
class InstalledAppsCard extends StatelessWidget {
|
||||
@ -36,19 +33,11 @@ class InstalledAppsCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
FutureBuilder<List<PatchedApplication>>(
|
||||
future: locator<HomeViewModel>().getPatchedApps(),
|
||||
builder: (context, snapshot) =>
|
||||
snapshot.hasData && snapshot.data!.length > 1
|
||||
? ListView.builder(
|
||||
itemBuilder: (context, index) => ApplicationItem(
|
||||
icon: snapshot.data![index].icon,
|
||||
name: snapshot.data![index].name,
|
||||
patchDate: snapshot.data![index].patchDate,
|
||||
onPressed: () => {},
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
ApplicationItem(
|
||||
asset: 'assets/images/revanced.svg',
|
||||
name: 'ReVanced',
|
||||
releaseDate: '2 days ago',
|
||||
onPressed: () => {},
|
||||
),
|
||||
I18nText(
|
||||
'installedAppsCard.changelogLabel',
|
||||
|
Reference in New Issue
Block a user