mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 04:37:37 +02:00
feat: Disable selection of un-suggested app version by default (#1471)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
@ -28,7 +28,6 @@ class _AppSelectorViewState extends State<AppSelectorView> {
|
||||
icon: const Icon(Icons.sd_storage),
|
||||
onPressed: () {
|
||||
model.selectAppFromStorage(context);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
body: CustomScrollView(
|
||||
|
@ -70,7 +70,26 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> selectApp(ApplicationWithIcon application) async {
|
||||
Future<void> selectApp(
|
||||
BuildContext context,
|
||||
ApplicationWithIcon application, [
|
||||
bool isFromStorage = false,
|
||||
]) async {
|
||||
final String suggestedVersion =
|
||||
getSuggestedVersion(application.packageName);
|
||||
if (application.versionName != suggestedVersion && suggestedVersion.isNotEmpty) {
|
||||
_managerAPI.suggestedAppVersionSelected = false;
|
||||
if (_managerAPI.isRequireSuggestedAppVersionEnabled() &&
|
||||
context.mounted) {
|
||||
return showRequireSuggestedAppVersionDialog(
|
||||
context,
|
||||
application.versionName!,
|
||||
suggestedVersion,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
_managerAPI.suggestedAppVersionSelected = true;
|
||||
}
|
||||
locator<PatcherViewModel>().selectedApp = PatchedApplication(
|
||||
name: application.appName,
|
||||
packageName: application.packageName,
|
||||
@ -78,8 +97,12 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
apkFilePath: application.apkFilePath,
|
||||
icon: application.icon,
|
||||
patchDate: DateTime.now(),
|
||||
isFromStorage: isFromStorage,
|
||||
);
|
||||
await locator<PatcherViewModel>().loadLastSelectedPatches();
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> canSelectInstalled(
|
||||
@ -89,23 +112,60 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
final app =
|
||||
await DeviceApps.getApp(packageName, true) as ApplicationWithIcon?;
|
||||
if (app != null) {
|
||||
if (await checkSplitApk(packageName) && !isRooted) {
|
||||
final bool isSplitApk = await checkSplitApk(packageName);
|
||||
if (isRooted || !isSplitApk) {
|
||||
if (context.mounted) {
|
||||
await selectApp(context, app);
|
||||
}
|
||||
final List<Option> requiredNullOptions = getNullRequiredOptions(
|
||||
locator<PatcherViewModel>().selectedPatches,
|
||||
packageName,
|
||||
);
|
||||
if (requiredNullOptions.isNotEmpty) {
|
||||
locator<PatcherViewModel>().showRequiredOptionDialog();
|
||||
}
|
||||
} else {
|
||||
if (context.mounted) {
|
||||
return showSelectFromStorageDialog(context);
|
||||
}
|
||||
} else if (!await checkSplitApk(packageName) || isRooted) {
|
||||
await selectApp(app);
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
final List<Option> requiredNullOptions = getNullRequiredOptions(locator<PatcherViewModel>().selectedPatches, packageName);
|
||||
if(requiredNullOptions.isNotEmpty){
|
||||
locator<PatcherViewModel>().showRequiredOptionDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future showRequireSuggestedAppVersionDialog(
|
||||
BuildContext context,
|
||||
String selectedVersion,
|
||||
String suggestedVersion,
|
||||
) async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||
title: I18nText('warning'),
|
||||
content: I18nText(
|
||||
'appSelectorView.requireSuggestedAppVersionDialogText',
|
||||
translationParams: {
|
||||
'suggested': suggestedVersion,
|
||||
'selected': selectedVersion,
|
||||
},
|
||||
child: const Text(
|
||||
'',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
CustomMaterialButton(
|
||||
label: I18nText('okButton'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future showSelectFromStorageDialog(BuildContext context) async {
|
||||
return showDialog(
|
||||
context: context,
|
||||
@ -145,12 +205,10 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
CustomMaterialButton(
|
||||
onPressed: () => selectAppFromStorage(context).then(
|
||||
(_) {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
await selectAppFromStorage(context);
|
||||
},
|
||||
label: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@ -203,17 +261,8 @@ class AppSelectorViewModel extends BaseViewModel {
|
||||
apkFile.path,
|
||||
true,
|
||||
) as ApplicationWithIcon?;
|
||||
if (application != null) {
|
||||
locator<PatcherViewModel>().selectedApp = PatchedApplication(
|
||||
name: application.appName,
|
||||
packageName: application.packageName,
|
||||
version: application.versionName!,
|
||||
apkFilePath: result,
|
||||
icon: application.icon,
|
||||
patchDate: DateTime.now(),
|
||||
isFromStorage: true,
|
||||
);
|
||||
locator<PatcherViewModel>().loadLastSelectedPatches();
|
||||
if (application != null && context.mounted) {
|
||||
await selectApp(context, application, true);
|
||||
}
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
|
Reference in New Issue
Block a user