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:
Alberto Ponces 2022-08-16 12:12:10 +01:00
parent ce09a5264a
commit cd1610d847
19 changed files with 365 additions and 180 deletions

View file

@ -19,8 +19,6 @@ jobs:
channel: 'stable'
- name: Set up Flutter
run: flutter pub get
- name: Generate files with Builder
run: flutter packages pub run build_runner build --delete-conflicting-outputs
- name: Build with Flutter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View file

@ -42,8 +42,6 @@ version
# Flutter/Dart/Pub related
**/doc/api/
**/*.g.dart
**/*.locator.dart
**/*.router.dart
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies

8
.vscode/tasks.json vendored
View file

@ -2,7 +2,7 @@
"version": "2.0.0",
"tasks": [
{
"label": "Generate (Builder)",
"label": "Build (Serializer)",
"type": "shell",
"command": "flutter packages pub run build_runner build --delete-conflicting-outputs",
"problemMatcher": []
@ -30,7 +30,7 @@
"problemMatcher": []
},
{
"label": "Clean (Builder)",
"label": "Clean (Serializer)",
"type": "shell",
"command": "flutter packages pub run build_runner clean",
"problemMatcher": []
@ -39,7 +39,7 @@
"label": "Build all (Android)",
"dependsOrder": "sequence",
"dependsOn": [
"Generate (Builder)",
"Build (Serializer)",
"Build (Android)"
],
"problemMatcher": []
@ -49,7 +49,7 @@
"dependsOrder": "sequence",
"dependsOn": [
"Clean (Flutter)",
"Clean (Builder)"
"Clean (Serializer)"
],
"problemMatcher": []
},

View file

@ -179,41 +179,10 @@ class MainActivity : FlutterActivity() {
return true
}
fun createPatcher(
inputFilePath: String,
cacheDirPath: String,
resourcePatching: Boolean
): Boolean {
fun createPatcher(inputFilePath: String, cacheDirPath: String, resourcePatching: Boolean): Boolean {
val inputFile = File(inputFilePath)
val aaptPath = Aapt.binary(applicationContext).absolutePath
patcher =
Patcher(
PatcherOptions(
inputFile,
cacheDirPath,
resourcePatching,
aaptPath,
cacheDirPath,
logger =
object : app.revanced.patcher.logging.Logger {
override fun error(msg: String) {
methodChannel.invokeMethod("updateInstallerLog", msg)
}
override fun warn(msg: String) {
methodChannel.invokeMethod("updateInstallerLog", msg)
}
override fun info(msg: String) {
methodChannel.invokeMethod("updateInstallerLog", msg)
}
override fun trace(msg: String) {
methodChannel.invokeMethod("updateInstallerLog", msg)
}
}
)
)
patcher = Patcher(PatcherOptions(inputFile, cacheDirPath, resourcePatching, aaptPath, cacheDirPath))
return true
}

BIN
assets/images/reddit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -0,0 +1,6 @@
<svg width="20" height="17" viewBox="0 0 20 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5714 10.9953C20.4762 9.88627 20.4762 7.11373 18.5714 6.00471L8.92857 0.39032C7.02381 -0.718696 4.64286 0.667579 4.64286 2.88561V4.46595L2.14286 3.01037C1.19048 2.45586 3.61997e-07 3.149 3.61997e-07 4.25801L0 12.742C-3.33951e-08 13.851 1.19048 14.5441 2.14286 13.9896L4.64286 12.534V14.1144C4.64286 16.3324 7.02381 17.7187 8.92857 16.6097L18.5714 10.9953ZM4.64286 4.46595L4.64286 12.534L9.42857 9.74764C10.381 9.19313 10.381 7.80687 9.42857 7.25236L4.64286 4.46595Z" fill="#FF6B78"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5714 10.9953C20.4762 9.88627 20.4762 7.11373 18.5714 6.00471L8.92857 0.39032C7.02381 -0.718696 4.64286 0.667579 4.64286 2.88561V4.46595L2.14286 3.01037C1.19048 2.45586 3.61997e-07 3.149 3.61997e-07 4.25801L0 12.742C-3.33951e-08 13.851 1.19048 14.5441 2.14286 13.9896L4.64286 12.534V14.1144C4.64286 16.3324 7.02381 17.7187 8.92857 16.6097L18.5714 10.9953ZM4.64286 4.46595L4.64286 12.534L9.42857 9.74764C10.381 9.19313 10.381 7.80687 9.42857 7.25236L4.64286 4.46595Z" fill="#FF4151"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5714 6.00471C20.4762 7.11373 20.4762 9.88627 18.5714 10.9953L8.92857 16.6097C7.02381 17.7187 4.64286 16.3324 4.64286 14.1144V12.534L9.42857 9.74764C10.381 9.19313 10.381 7.80687 9.42857 7.25236L4.64286 4.46595V2.88561C4.64286 0.667579 7.02381 -0.718696 8.92857 0.39032L18.5714 6.00471Z" fill="#FF6B78"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.5714 6.00471C20.4762 7.11373 20.4762 9.88627 18.5714 10.9953L8.92857 16.6097C7.02381 17.7187 4.64286 16.3324 4.64286 14.1144V12.534L9.42857 9.74764C10.381 9.19313 10.381 7.80687 9.42857 7.25236L4.64286 4.46595V2.88561C4.64286 0.667579 7.02381 -0.718696 8.92857 0.39032L18.5714 6.00471Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -5,7 +5,6 @@ import 'package:revanced_manager/services/root_api.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.dart';
import 'package:revanced_manager/ui/views/contributors/contributors_view.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
import 'package:revanced_manager/ui/views/installer/installer_view.dart';
import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
@ -32,7 +31,6 @@ import 'package:stacked_themes/stacked_themes.dart';
LazySingleton(classType: PatcherAPI),
LazySingleton(classType: ManagerAPI),
LazySingleton(classType: RootAPI),
LazySingleton(classType: HomeViewModel),
LazySingleton(classType: PatcherViewModel),
LazySingleton(classType: AppSelectorViewModel),
LazySingleton(classType: PatchesSelectorViewModel),

39
lib/app/app.locator.dart Normal file
View file

@ -0,0 +1,39 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// StackedLocatorGenerator
// **************************************************************************
// ignore_for_file: public_member_api_docs, depend_on_referenced_packages
import 'package:stacked_core/stacked_core.dart';
import 'package:stacked_services/stacked_services.dart';
import 'package:stacked_themes/stacked_themes.dart';
import '../services/manager_api.dart';
import '../services/patcher_api.dart';
import '../services/root_api.dart';
import '../ui/views/app_selector/app_selector_viewmodel.dart';
import '../ui/views/installer/installer_viewmodel.dart';
import '../ui/views/patcher/patcher_viewmodel.dart';
import '../ui/views/patches_selector/patches_selector_viewmodel.dart';
final locator = StackedLocator.instance;
Future<void> setupLocator(
{String? environment, EnvironmentFilter? environmentFilter}) async {
// Register environments
locator.registerEnvironment(
environment: environment, environmentFilter: environmentFilter);
// Register dependencies
locator.registerLazySingleton(() => NavigationService());
locator.registerLazySingleton(() => PatcherAPI());
locator.registerLazySingleton(() => ManagerAPI());
locator.registerLazySingleton(() => RootAPI());
locator.registerLazySingleton(() => PatcherViewModel());
locator.registerLazySingleton(() => AppSelectorViewModel());
locator.registerLazySingleton(() => PatchesSelectorViewModel());
locator.registerLazySingleton(() => InstallerViewModel());
locator.registerLazySingleton(() => ThemeService.getInstance());
}

231
lib/app/app.router.dart Normal file
View file

@ -0,0 +1,231 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// StackedRouterGenerator
// **************************************************************************
// ignore_for_file: public_member_api_docs, unused_import, non_constant_identifier_names
import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
import '../main.dart';
import '../ui/views/app_selector/app_selector_view.dart';
import '../ui/views/contributors/contributors_view.dart';
import '../ui/views/installer/installer_view.dart';
import '../ui/views/patches_selector/patches_selector_view.dart';
import '../ui/views/root_checker/root_checker_view.dart';
import '../ui/views/settings/settings_view.dart';
class Routes {
static const String navigation = '/Navigation';
static const String appSelectorView = '/app-selector-view';
static const String patchesSelectorView = '/patches-selector-view';
static const String installerView = '/installer-view';
static const String settingsView = '/settings-view';
static const String contributorsView = '/contributors-view';
static const String rootCheckerView = '/root-checker-view';
static const all = <String>{
navigation,
appSelectorView,
patchesSelectorView,
installerView,
settingsView,
contributorsView,
rootCheckerView,
};
}
class StackedRouter extends RouterBase {
@override
List<RouteDef> get routes => _routes;
final _routes = <RouteDef>[
RouteDef(Routes.navigation, page: Navigation),
RouteDef(Routes.appSelectorView, page: AppSelectorView),
RouteDef(Routes.patchesSelectorView, page: PatchesSelectorView),
RouteDef(Routes.installerView, page: InstallerView),
RouteDef(Routes.settingsView, page: SettingsView),
RouteDef(Routes.contributorsView, page: ContributorsView),
RouteDef(Routes.rootCheckerView, page: RootCheckerView),
];
@override
Map<Type, StackedRouteFactory> get pagesMap => _pagesMap;
final _pagesMap = <Type, StackedRouteFactory>{
Navigation: (data) {
return MaterialPageRoute<dynamic>(
builder: (context) => const Navigation(),
settings: data,
);
},
AppSelectorView: (data) {
return MaterialPageRoute<dynamic>(
builder: (context) => const AppSelectorView(),
settings: data,
);
},
PatchesSelectorView: (data) {
return MaterialPageRoute<dynamic>(
builder: (context) => const PatchesSelectorView(),
settings: data,
);
},
InstallerView: (data) {
var args = data.getArgs<InstallerViewArguments>(
orElse: () => InstallerViewArguments(),
);
return MaterialPageRoute<dynamic>(
builder: (context) => InstallerView(key: args.key),
settings: data,
);
},
SettingsView: (data) {
return MaterialPageRoute<dynamic>(
builder: (context) => const SettingsView(),
settings: data,
);
},
ContributorsView: (data) {
return MaterialPageRoute<dynamic>(
builder: (context) => const ContributorsView(),
settings: data,
);
},
RootCheckerView: (data) {
return MaterialPageRoute<dynamic>(
builder: (context) => const RootCheckerView(),
settings: data,
);
},
};
}
/// ************************************************************************
/// Arguments holder classes
/// *************************************************************************
/// InstallerView arguments holder class
class InstallerViewArguments {
final Key? key;
InstallerViewArguments({this.key});
}
/// ************************************************************************
/// Extension for strongly typed navigation
/// *************************************************************************
extension NavigatorStateExtension on NavigationService {
Future<dynamic> navigateToNavigation({
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
}) async {
return navigateTo(
Routes.navigation,
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition,
);
}
Future<dynamic> navigateToAppSelectorView({
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
}) async {
return navigateTo(
Routes.appSelectorView,
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition,
);
}
Future<dynamic> navigateToPatchesSelectorView({
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
}) async {
return navigateTo(
Routes.patchesSelectorView,
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition,
);
}
Future<dynamic> navigateToInstallerView({
Key? key,
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
}) async {
return navigateTo(
Routes.installerView,
arguments: InstallerViewArguments(key: key),
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition,
);
}
Future<dynamic> navigateToSettingsView({
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
}) async {
return navigateTo(
Routes.settingsView,
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition,
);
}
Future<dynamic> navigateToContributorsView({
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
}) async {
return navigateTo(
Routes.contributorsView,
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition,
);
}
Future<dynamic> navigateToRootCheckerView({
int? routerId,
bool preventDuplicates = true,
Map<String, String>? parameters,
Widget Function(BuildContext, Animation<double>, Animation<double>, Widget)?
transition,
}) async {
return navigateTo(
Routes.rootCheckerView,
id: routerId,
preventDuplicates: preventDuplicates,
parameters: parameters,
transition: transition,
);
}
}

View file

@ -1,43 +1,21 @@
import 'dart:typed_data';
import 'package:json_annotation/json_annotation.dart';
import 'package:revanced_manager/models/patch.dart';
part 'patched_application.g.dart';
@JsonSerializable()
class PatchedApplication {
final String name;
final String packageName;
final String version;
final String apkFilePath;
@JsonKey(
fromJson: bytesFromString,
toJson: bytesToString,
)
final Uint8List icon;
final DateTime patchDate;
final bool isRooted;
final bool isFromStorage;
final List<String> appliedPatches;
final List<Patch> appliedPatches;
PatchedApplication({
required this.name,
required this.packageName,
required this.version,
required this.apkFilePath,
required this.icon,
required this.patchDate,
required this.isRooted,
required this.isFromStorage,
this.appliedPatches = const <String>[],
this.appliedPatches = const <Patch>[],
});
factory PatchedApplication.fromJson(Map<String, dynamic> json) =>
_$PatchedApplicationFromJson(json);
Map toJson() => _$PatchedApplicationToJson(this);
static Uint8List bytesFromString(String pictureUrl) =>
Uint8List.fromList(pictureUrl.codeUnits);
static String bytesToString(Uint8List bytes) => String.fromCharCodes(bytes);
}

View file

@ -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(

View file

@ -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(

View file

@ -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();
}
}

View file

@ -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,
),
),

View file

@ -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);
}
}
}

View file

@ -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(

View file

@ -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(

View file

@ -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',

View file

@ -12,10 +12,7 @@ environment:
dependencies:
app_installer: ^1.1.0
cupertino_icons: ^1.0.2
device_apps:
git:
url: https://github.com/ponces/flutter_plugin_device_apps
ref: appinfo-from-storage
device_apps: ^2.2.0
dio: ^4.0.6
file_picker: ^5.0.1
flutter:
@ -31,6 +28,7 @@ dependencies:
http: ^0.13.4
injectable: ^1.5.3
json_annotation: ^4.6.0
package_archive_info: ^0.1.0
path_provider: ^2.0.11
root: ^2.0.2
share_extend: ^2.0.0