From cdfb09fbfa8e74d84ddcc91565489c3c5b61dfa2 Mon Sep 17 00:00:00 2001 From: Aunali321 Date: Thu, 20 Apr 2023 23:20:30 +0530 Subject: [PATCH] feat: warning for armv7 devices --- assets/i18n/en_US.json | 3 +- lib/ui/views/patcher/patcher_viewmodel.dart | 48 +++++++++++++++++++-- lib/utils/about_info.dart | 2 +- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/assets/i18n/en_US.json b/assets/i18n/en_US.json index b7e9cd53a9..c8037c41de 100644 --- a/assets/i18n/en_US.json +++ b/assets/i18n/en_US.json @@ -48,7 +48,8 @@ "patcherView": { "widgetTitle": "Patcher", "patchButton": "Patch", - "patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?" + "patchDialogText": "You have selected a resource patch and a split APK installation has been detected, so patching errors may occur.\nAre you sure you want to proceed?", + "armv7WarningDialogText": "Patching on ARMv7 devices is not yet supported. Proceed anyways?" }, "appSelectorCard": { "widgetTitle": "Select an application", diff --git a/lib/ui/views/patcher/patcher_viewmodel.dart b/lib/ui/views/patcher/patcher_viewmodel.dart index 4b7bddddc4..ebfa104ee8 100644 --- a/lib/ui/views/patcher/patcher_viewmodel.dart +++ b/lib/ui/views/patcher/patcher_viewmodel.dart @@ -1,3 +1,5 @@ +// ignore_for_file: use_build_context_synchronously + import 'package:flutter/material.dart'; import 'package:flutter_i18n/flutter_i18n.dart'; import 'package:injectable/injectable.dart'; @@ -8,6 +10,7 @@ import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/services/manager_api.dart'; import 'package:revanced_manager/services/patcher_api.dart'; import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart'; +import 'package:revanced_manager/utils/about_info.dart'; import 'package:stacked/stacked.dart'; import 'package:stacked_services/stacked_services.dart'; @@ -54,25 +57,25 @@ class PatcherViewModel extends BaseViewModel { final bool isValid = await isValidPatchConfig(); if (context.mounted) { if (isValid) { - navigateToInstaller(); + showArmv7WarningDialog(context); } else { return showDialog( context: context, builder: (context) => AlertDialog( title: I18nText('warning'), backgroundColor: Theme.of(context).colorScheme.secondaryContainer, - content: I18nText('patcherView.patchDialogText'), + content: I18nText('patcherView.armv7WarningDialogText'), actions: [ CustomMaterialButton( - isFilled: false, label: I18nText('noButton'), onPressed: () => Navigator.of(context).pop(), ), CustomMaterialButton( label: I18nText('yesButton'), + isFilled: false, onPressed: () { Navigator.of(context).pop(); - navigateToInstaller(); + showArmv7WarningDialog(context); }, ) ], @@ -82,6 +85,43 @@ class PatcherViewModel extends BaseViewModel { } } + Future showArmv7WarningDialog(BuildContext context) async { + final bool armv7 = await AboutInfo.getInfo().then( + (info) => + info['arch'] != null && + info['arch']!.contains('armeabi-v7a') && + !info['arch']!.contains('arm64-v8a'), + ); + + if (context.mounted && armv7) { + return showDialog( + context: context, + builder: (context) => AlertDialog( + title: I18nText('warning'), + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, + content: I18nText('patcherView.armv7WarningDialogText'), + actions: [ + CustomMaterialButton( + label: I18nText('noButton'), + onPressed: () => Navigator.of(context).pop(), + ), + CustomMaterialButton( + label: I18nText('yesButton'), + isFilled: false, + onPressed: () { + Navigator.of(context).pop(); + navigateToInstaller(); + }, + ) + ], + ), + ); + } else { + // navigate To Installer + navigateToInstaller(); + } + } + String getAppSelectionString() { String text = '${selectedApp!.name} (${selectedApp!.packageName})'; if (text.length > 32) { diff --git a/lib/utils/about_info.dart b/lib/utils/about_info.dart index bd107ced53..289f78d9e2 100644 --- a/lib/utils/about_info.dart +++ b/lib/utils/about_info.dart @@ -11,7 +11,7 @@ class AboutInfo { 'flavor': kReleaseMode ? 'release' : 'debug', 'model': info.model, 'androidVersion': info.version.release, - 'arch': info.supportedAbis.first + 'arch': info.supportedAbis }; } }