feat: Save last patched app (#1414)

Co-authored-by: aAbed <39409020+TheAabedKhan@users.noreply.github.com>
Co-authored-by: Ushie <ushiekane@gmail.com>
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
Co-authored-by: Mr. X <79870712+n30mrx@users.noreply.github.com>
Co-authored-by: festry0 <153519925+festry0@users.noreply.github.com>
This commit is contained in:
Benjamin 2024-06-29 05:38:00 -07:00 committed by GitHub
parent b26760b216
commit 77204087bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 448 additions and 46 deletions

View file

@ -217,7 +217,7 @@ class PatcherAPI {
BuildContext context,
PatchedApplication patchedApp,
) async {
if (outFile != null) {
if (patchedApp.patchedFilePath != '') {
_managerAPI.ctx = context;
try {
if (patchedApp.isRooted) {
@ -232,7 +232,7 @@ class PatcherAPI {
return await _rootAPI.install(
patchedApp.packageName,
patchedApp.apkFilePath,
outFile!.path,
patchedApp.patchedFilePath,
)
? 0
: 1;
@ -246,7 +246,7 @@ class PatcherAPI {
if (context.mounted) {
return await installApk(
context,
outFile!.path,
patchedApp.patchedFilePath,
);
}
}
@ -368,13 +368,13 @@ class PatcherAPI {
return cleanInstall ? 10 : 1;
}
void exportPatchedFile(String appName, String version) {
void exportPatchedFile(PatchedApplication app) {
try {
if (outFile != null) {
final String newName = _getFileName(appName, version);
final String newName = _getFileName(app.name, app.version);
FlutterFileDialog.saveFile(
params: SaveFileDialogParams(
sourceFilePath: outFile!.path,
sourceFilePath: app.patchedFilePath,
fileName: newName,
mimeTypesFilter: ['application/vnd.android.package-archive'],
),
@ -387,14 +387,14 @@ class PatcherAPI {
}
}
void sharePatchedFile(String appName, String version) {
void sharePatchedFile(PatchedApplication app) {
try {
if (outFile != null) {
final String newName = _getFileName(appName, version);
final int lastSeparator = outFile!.path.lastIndexOf('/');
final String newName = _getFileName(app.name, app.version);
final int lastSeparator = app.patchedFilePath.lastIndexOf('/');
final String newPath =
outFile!.path.substring(0, lastSeparator + 1) + newName;
final File shareFile = outFile!.copySync(newPath);
app.patchedFilePath.substring(0, lastSeparator + 1) + newName;
final File shareFile = File(app.patchedFilePath).copySync(newPath);
Share.shareXFiles([XFile(shareFile.path)]);
}
} on Exception catch (e) {