Skip to content

Commit

Permalink
Merge branch 'dev' into feat/disable-install-button
Browse files Browse the repository at this point in the history
  • Loading branch information
erayerdin authored Jan 17, 2024
2 parents 0940d5c + 7911459 commit 07282ce
Show file tree
Hide file tree
Showing 32 changed files with 396 additions and 281 deletions.
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.VIBRATE" />

<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
Expand Down
18 changes: 9 additions & 9 deletions assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

"storageButton": "Storage",
"selectFromStorageButton": "Select from storage",

"errorMessage": "Unable to use selected application",

"downloadToast": "Download function is not available yet",
Expand Down Expand Up @@ -175,7 +175,7 @@
"pressBackAgain": "Press back again to cancel",
"openButton": "Open",
"shareButton": "Share file",

"notificationTitle": "ReVanced Manager is patching",
"notificationText": "Tap to return to the installer",

Expand Down Expand Up @@ -208,29 +208,29 @@
"englishOption": "English",

"sourcesLabel": "Sources",
"sourcesLabelHint": "Configure your sources",
"sourcesLabelHint": "Configure the source of patches and integrations",
"sourcesIntegrationsLabel": "Integrations source",
"sourcesResetDialogTitle": "Reset",
"sourcesResetDialogText": "Are you sure you want to reset your sources to their default values?",
"apiURLResetDialogText": "Are you sure you want to reset your API URL to its default value?",
"sourcesUpdateNote": "Note: Patches will be updated to the latest version automatically.\n\nThis will reveal your IP address to the server.",

"apiURLLabel": "API URL",
"apiURLHint": "Configure your API URL",
"apiURLHint": "Configure the URL of the API to use",
"selectApiURL": "API URL",
"hostRepositoryLabel": "Repository API",
"orgPatchesLabel": "Patches organization",
"sourcesPatchesLabel": "Patches source",
"orgIntegrationsLabel": "Integrations organization",

"contributorsLabel": "Contributors",
"contributorsHint": "A list of contributors of ReVanced",

"logsLabel": "Share logs",
"logsHint": "Share ReVanced Manager logs",

"enablePatchesSelectionLabel": "Allow changing patch selection",
"enablePatchesSelectionHint": "Allow changing the selection of patches",
"enablePatchesSelectionHint": "Do not prevent selecting or deselecting patches",
"enablePatchesSelectionWarningText": "Changing the selection of patches may cause unexpected issues.\n\nEnable anyways?",
"disablePatchesSelectionWarningText": "You are about to disable changing the selection of patches.\nThe default selection of patches will be restored.\n\nDisable anyways?",

Expand All @@ -240,9 +240,9 @@
"universalPatchesHint": "Display all apps and universal patches (may slow down the app list)",

"versionCompatibilityCheckLabel": "Version compatibility check",
"versionCompatibilityCheckHint": "Restricts patches to supported app versions",
"versionCompatibilityCheckHint": "Prevent selecting patches that are not compatible with the selected app version",
"requireSuggestedAppVersionLabel": "Require suggested app version",
"requireSuggestedAppVersionHint": "Enforce selection of suggested app version",
"requireSuggestedAppVersionHint": "Prevent selecting an app with a version that is not the suggested",
"requireSuggestedAppVersionDialogText": "Selecting an app that is not the suggested version may cause unexpected issues.\n\nDo you want to proceed anyways?",

"aboutLabel": "About",
Expand Down Expand Up @@ -320,7 +320,7 @@

"patchedDateHint": "{date} at {time}",
"appliedPatchesHint": "{quantity} applied patches",

"updateNotImplemented": "This feature has not been implemented yet"
},
"contributorsView": {
Expand Down
26 changes: 20 additions & 6 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/services/root_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_checkbox_list_tile.dart';
import 'package:revanced_manager/utils/check_for_supported_patch.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:timeago/timeago.dart';
Expand All @@ -23,6 +25,7 @@ import 'package:timeago/timeago.dart';
class ManagerAPI {
final RevancedAPI _revancedAPI = locator<RevancedAPI>();
final GithubAPI _githubAPI = locator<GithubAPI>();
final Toast _toast = locator<Toast>();
final RootAPI _rootAPI = RootAPI();
final String patcherRepo = 'revanced-patcher';
final String cliRepo = 'revanced-cli';
Expand Down Expand Up @@ -50,12 +53,12 @@ class ManagerAPI {
String? integrationsVersion = '';

bool isDefaultPatchesRepo() {
return getPatchesRepo().toLowerCase() == 'revanced/revanced-patches';
return getPatchesRepo().toLowerCase() == defaultPatchesRepo;
}

bool isDefaultIntegrationsRepo() {
return getIntegrationsRepo().toLowerCase() ==
'revanced/revanced-integrations';
defaultIntegrationsRepo;
}

Future<void> initialize() async {
Expand All @@ -65,6 +68,16 @@ class ManagerAPI {
(await getSdkVersion()) >= 31; // ANDROID_12_SDK_VERSION = 31
storedPatchesFile =
(await getApplicationDocumentsDirectory()).path + storedPatchesFile;

// Migrate to new API URL if not done yet as the old one is sunset.
final bool hasMigrated = _prefs.getBool('migratedToNewApiUrl') ?? false;
if (!hasMigrated) {
final String apiUrl = getApiUrl().toLowerCase();
if (apiUrl.contains('releases.revanced.app')) {
await setApiUrl(''); // Reset to default.
_prefs.setBool('migratedToNewApiUrl', true);
}
}
}

Future<int> getSdkVersion() async {
Expand All @@ -82,6 +95,7 @@ class ManagerAPI {
}
await _revancedAPI.clearAllCache();
await _prefs.setString('apiUrl', url);
_toast.showBottom('settingsView.restartAppForChanges');
}

String getRepoUrl() {
Expand Down Expand Up @@ -582,8 +596,8 @@ class ManagerAPI {
return showDialog(
barrierDismissible: false,
context: context,
builder: (context) => WillPopScope(
onWillPop: () async => false,
builder: (context) => PopScope(
canPop: false,
child: AlertDialog(
title: I18nText('warning'),
content: ValueListenableBuilder(
Expand All @@ -604,7 +618,7 @@ class ManagerAPI {
),
),
const SizedBox(height: 8),
CheckboxListTile(
HapticCheckboxListTile(
value: value,
contentPadding: EdgeInsets.zero,
title: I18nText(
Expand Down Expand Up @@ -632,7 +646,7 @@ class ManagerAPI {
);
}

Future<void> reAssessSavedApps() async {
Future<void> rePatchedSavedApps() async {
final List<PatchedApplication> patchedApps = getPatchedApps();

// Remove apps that are not installed anymore.
Expand Down
4 changes: 2 additions & 2 deletions lib/services/revanced_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RevancedAPI {
final response = await _dio.get('/contributors');
final List<dynamic> repositories = response.data['repositories'];
for (final Map<String, dynamic> repo in repositories) {
final String name = repo['name'];
final String name = repo['name'].toLowerCase();
contributors[name] = repo['contributors'];
}
} on Exception catch (e) {
Expand All @@ -54,7 +54,7 @@ class RevancedAPI {
final List<dynamic> tools = response.data['tools'];
return tools.firstWhereOrNull(
(t) =>
t['repository'] == repoName &&
(t['repository'] as String).toLowerCase() == repoName.toLowerCase() &&
(t['name'] as String).endsWith(extension),
);
} on Exception catch (e) {
Expand Down
8 changes: 6 additions & 2 deletions lib/services/root_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,12 @@ class RootAPI {
);
final String mountScript = '''
#!/system/bin/sh
MAGISKTMP="\$(magisk --path)" || MAGISKTMP=/sbin
# Mount using Magisk mirror, if available.
MAGISKTMP="\$( magisk --path )" || MAGISKTMP=/sbin
MIRROR="\$MAGISKTMP/.magisk/mirror"
if [ ! -f \$MIRROR ]; then
MIRROR=""
fi
until [ "\$(getprop sys.boot_completed)" = 1 ]; do sleep 3; done
until [ -d "/sdcard/Android" ]; do sleep 1; done
Expand All @@ -171,7 +175,7 @@ class RootAPI {
}

Future<void> installPatchedApk(
String packageName, String patchedFilePath) async {
String packageName, String patchedFilePath,) async {
final String newPatchedFilePath = '$_revancedDirPath/$packageName/base.apk';
await Root.exec(
cmd: '''
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/views/app_selector/app_selector_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:revanced_manager/ui/views/app_selector/app_selector_viewmodel.da
import 'package:revanced_manager/ui/widgets/appSelectorView/app_skeleton_loader.dart';
import 'package:revanced_manager/ui/widgets/appSelectorView/installed_app_item.dart';
import 'package:revanced_manager/ui/widgets/appSelectorView/not_installed_app_item.dart';
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_floating_action_button_extended.dart';
import 'package:revanced_manager/ui/widgets/shared/search_bar.dart';
import 'package:stacked/stacked.dart' hide SkeletonLoader;

Expand All @@ -23,7 +24,7 @@ class _AppSelectorViewState extends State<AppSelectorView> {
onViewModelReady: (model) => model.initialize(),
viewModelBuilder: () => AppSelectorViewModel(),
builder: (context, model, child) => Scaffold(
floatingActionButton: FloatingActionButton.extended(
floatingActionButton: HapticFloatingActionButtonExtended(
label: I18nText('appSelectorView.storageButton'),
icon: const Icon(Icons.sd_storage),
onPressed: () {
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/views/contributors/contributors_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class ContributorsViewModel extends BaseViewModel {
final Map<String, List<dynamic>> contributors =
await _managerAPI.getContributors();
patcherContributors = contributors[_managerAPI.defaultPatcherRepo] ?? [];
patchesContributors = contributors[_managerAPI.getPatchesRepo()] ?? [];
patchesContributors = contributors[_managerAPI.getPatchesRepo().toLowerCase()] ?? [];
integrationsContributors =
contributors[_managerAPI.getIntegrationsRepo()] ?? [];
contributors[_managerAPI.getIntegrationsRepo().toLowerCase()] ?? [];
cliContributors = contributors[_managerAPI.defaultCliRepo] ?? [];
managerContributors = contributors[_managerAPI.defaultManagerRepo] ?? [];
notifyListeners();
Expand Down
11 changes: 8 additions & 3 deletions lib/ui/views/home/home_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/homeView/update_confirmation_dialog.dart';
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_checkbox_list_tile.dart';
import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';

Expand All @@ -38,11 +39,15 @@ class HomeViewModel extends BaseViewModel {
File? downloadedApk;

Future<void> initialize(BuildContext context) async {
_managerAPI.rePatchedSavedApps().then((_) => _getPatchedApps());

_latestManagerVersion = await _managerAPI.getLatestManagerVersion();
if (!_managerAPI.getPatchesConsent()) {
await showPatchesConsent(context);
}

await _patcherAPI.initialize();

await flutterLocalNotificationsPlugin.initialize(
const InitializationSettings(
android: AndroidInitializationSettings('ic_notification'),
Expand All @@ -63,11 +68,13 @@ class HomeViewModel extends BaseViewModel {
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestNotificationsPermission();

final bool isConnected =
await Connectivity().checkConnectivity() != ConnectivityResult.none;
if (!isConnected) {
_toast.showBottom('homeView.noConnection');
}

final NotificationAppLaunchDetails? notificationAppLaunchDetails =
await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails();
if (notificationAppLaunchDetails?.didNotificationLaunchApp ?? false) {
Expand All @@ -79,8 +86,6 @@ class HomeViewModel extends BaseViewModel {
_toast.showBottom('homeView.errorDownloadMessage');
}
}

_managerAPI.reAssessSavedApps().then((_) => _getPatchedApps());
}

void navigateToAppInfo(PatchedApplication app) {
Expand Down Expand Up @@ -203,7 +208,7 @@ class HomeViewModel extends BaseViewModel {
),
),
),
CheckboxListTile(
HapticCheckboxListTile(
value: value,
contentPadding: EdgeInsets.zero,
title: I18nText(
Expand Down
9 changes: 5 additions & 4 deletions lib/ui/views/installer/installer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:revanced_manager/ui/views/installer/installer_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/installerView/gradient_progress_indicator.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_floating_action_button_extended.dart';
import 'package:stacked/stacked.dart';

class InstallerView extends StatelessWidget {
Expand All @@ -15,15 +16,15 @@ class InstallerView extends StatelessWidget {
return ViewModelBuilder<InstallerViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => InstallerViewModel(),
builder: (context, model, child) => WillPopScope(
builder: (context, model, child) => PopScope(
child: SafeArea(
top: false,
bottom: model.isPatching,
child: Scaffold(
floatingActionButton: Visibility(
visible: !model.isPatching && !model.hasErrors,
child: model.isInstalled
? FloatingActionButton.extended(
? HapticFloatingActionButtonExtended(
label: I18nText('installerView.openButton'),
icon: const Icon(Icons.open_in_new),
onPressed: () {
Expand All @@ -34,7 +35,7 @@ class InstallerView extends StatelessWidget {
},
elevation: 0,
)
: FloatingActionButton.extended(
: HapticFloatingActionButtonExtended(
label: I18nText('installerView.installButton'),
icon: const Icon(Icons.file_download_outlined),
onPressed: model.isInstalling
Expand Down Expand Up @@ -113,7 +114,7 @@ class InstallerView extends StatelessWidget {
),
),
),
onWillPop: () => model.onWillPop(context),
onPopInvoked: (bool didPop) => model.onWillPop(context),
),
);
}
Expand Down
12 changes: 4 additions & 8 deletions lib/ui/views/navigation/navigation_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ class NavigationView extends StatelessWidget {
return ViewModelBuilder<NavigationViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<NavigationViewModel>(),
builder: (context, model, child) => WillPopScope(
onWillPop: () async {
if (model.currentIndex == 0) {
return true;
} else {
model.setIndex(0);
return false;
}
builder: (context, model, child) => PopScope(
canPop: model.currentIndex == 0,
onPopInvoked: (bool didPop) => {
if (!didPop) model.setIndex(0),
},
child: Scaffold(
body: PageTransitionSwitcher(
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/views/patch_options/patch_options_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/ui/views/patch_options/patch_options_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/patchesSelectorView/patch_options_fields.dart';
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_floating_action_button_extended.dart';
import 'package:stacked/stacked.dart';

class PatchOptionsView extends StatelessWidget {
Expand All @@ -17,7 +18,7 @@ class PatchOptionsView extends StatelessWidget {
builder: (context, model, child) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Scaffold(
floatingActionButton: FloatingActionButton.extended(
floatingActionButton: HapticFloatingActionButtonExtended(
onPressed: () async {
final bool saved = model.saveOptions(context);
if (saved && context.mounted) {
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/views/patcher/patcher_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:revanced_manager/ui/widgets/patcherView/app_selector_card.dart';
import 'package:revanced_manager/ui/widgets/patcherView/patch_selector_card.dart';
import 'package:revanced_manager/ui/widgets/shared/custom_sliver_app_bar.dart';
import 'package:revanced_manager/ui/widgets/shared/haptics/haptic_floating_action_button_extended.dart';
import 'package:stacked/stacked.dart';

class PatcherView extends StatelessWidget {
Expand All @@ -19,7 +20,7 @@ class PatcherView extends StatelessWidget {
builder: (context, model, child) => Scaffold(
floatingActionButton: Visibility(
visible: model.showPatchButton(),
child: FloatingActionButton.extended(
child: HapticFloatingActionButtonExtended(
label: I18nText('patcherView.patchButton'),
icon: const Icon(Icons.build),
onPressed: () async {
Expand Down
Loading

0 comments on commit 07282ce

Please sign in to comment.