Compare commits

...

6 Commits

Author SHA1 Message Date
fe629ce77c Merge branch 'flutter' of https://github.com/revanced/revanced-manager into flutter 2022-12-11 18:04:06 +05:30
5c27add2b2 bump:bump version to v0.0.46 2022-12-11 18:04:00 +05:30
ff90dae695 feat: add support for shared patches (#577)
* fix: avoid npe if a patch has empty compatible package.

* feat: support for shared patches

* fix: incorrect bool check and cleanup

Co-authored-by: Aunali321 <aunvakil.aa@gmail.com>
2022-12-11 18:00:44 +05:30
4f8aec6a05 build: bump version to v0.0.45 2022-12-09 17:47:51 +05:30
ba8df57580 Update broken link (#569) 2022-12-09 17:42:09 +05:30
3bab1940c1 Support Gitea repositories (#570) 2022-12-09 17:40:43 +05:30
10 changed files with 78 additions and 23 deletions

View File

@ -28,7 +28,7 @@ If you wish to translate ReVanced Manager, we're accepting translations on [Crow
## 🛠️ Building Manager from source
1. Setup flutter environment for your [platform](https://docs.flutter.dev/get-started/install)
2. Clone the repository locally
3. Add your github token in gradle.properties like [this](https://github.com/revanced/revanced-documentation/wiki/Building-from-source)
3. Add your github token in gradle.properties like [this](https://github.com/revanced/revanced-documentation/blob/main/docs/revanced-development/2_building_from_source.md)
4. Open the project in terminal
5. Run `flutter pub get` in terminal
6. Then `flutter packages pub run build_runner build --delete-conflicting-outputs` (Must be done on each git pull)

View File

@ -174,7 +174,7 @@ class MainActivity : FlutterActivity() {
javaClass.classLoader
)
).loadPatches().filter { patch ->
patch.compatiblePackages!!.any { it.name == patcher.context.packageMetadata.packageName } &&
(patch.compatiblePackages?.any { it.name == patcher.context.packageMetadata.packageName } == true || patch.compatiblePackages.isNullOrEmpty()) &&
selectedPatches.any { it == patch.patchName }
}
} else {

View File

@ -122,6 +122,7 @@
"englishOption": "English",
"sourcesLabel": "Sources",
"sourcesLabelHint": "Configure your custom sources",
"hostRepositoryLabel": "Repository API",
"orgPatchesLabel": "Patches organization",
"sourcesPatchesLabel": "Patches source",
"orgIntegrationsLabel": "Integrations organization",

View File

@ -25,7 +25,8 @@ Future main() async {
await locator<RevancedAPI>().initialize(apiUrl);
await locator<CrowdinAPI>().initialize();
bool isSentryEnabled = locator<ManagerAPI>().isSentryEnabled();
locator<GithubAPI>().initialize();
String repoUrl = locator<ManagerAPI>().getRepoUrl();
locator<GithubAPI>().initialize(repoUrl);
await locator<PatcherAPI>().initialize();
tz.initializeTimeZones();
prefs = await SharedPreferences.getInstance();

View File

@ -28,10 +28,10 @@ class GithubAPI {
'com.spotify.music': 'spotify',
};
void initialize() async {
void initialize(String repoUrl) async {
try {
_dio = Dio(BaseOptions(
baseUrl: 'https://api.github.com',
baseUrl: repoUrl,
));
_dio.interceptors.add(_dioCacheManager.interceptor);
@ -54,10 +54,10 @@ class GithubAPI {
Future<Map<String, dynamic>?> getLatestRelease(String repoName) async {
try {
var response = await _dio.get(
'/repos/$repoName/releases/latest',
'/repos/$repoName/releases',
options: _cacheOptions,
);
return response.data;
return response.data[0];
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return null;

View File

@ -23,6 +23,7 @@ class ManagerAPI {
late String storedPatchesFile = '/selected-patches.json';
late SharedPreferences _prefs;
String defaultApiUrl = 'https://releases.revanced.app/';
String defaultRepoUrl = 'https://api.github.com';
String defaultPatcherRepo = 'revanced/revanced-patcher';
String defaultPatchesRepo = 'revanced/revanced-patches';
String defaultIntegrationsRepo = 'revanced/revanced-integrations';
@ -48,6 +49,17 @@ class ManagerAPI {
await _prefs.setString('apiUrl', url);
}
String getRepoUrl() {
return _prefs.getString('repoUrl') ?? defaultRepoUrl;
}
Future<void> setRepoUrl(String url) async {
if (url.isEmpty || url == ' ') {
url = defaultRepoUrl;
}
await _prefs.setString('repoUrl', url);
}
String getPatchesRepo() {
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
}

View File

@ -54,6 +54,25 @@ class PatcherAPI {
Future<List<ApplicationWithIcon>> getFilteredInstalledApps() async {
List<ApplicationWithIcon> filteredApps = [];
bool? allAppsIncluded =
_patches.any((patch) => patch.compatiblePackages.isEmpty);
if (allAppsIncluded) {
var allPackages = await DeviceApps.getInstalledApplications(
includeAppIcons: true,
onlyAppsWithLaunchIntent: true,
);
allPackages.forEach((pkg) async {
if (!filteredApps.any((app) => app.packageName == pkg.packageName)) {
var appInfo = await DeviceApps.getApp(
pkg.packageName,
true,
) as ApplicationWithIcon?;
if (appInfo != null) {
filteredApps.add(appInfo);
}
}
});
}
for (Patch patch in _patches) {
for (Package package in patch.compatiblePackages) {
try {
@ -76,11 +95,19 @@ class PatcherAPI {
}
Future<List<Patch>> getFilteredPatches(String packageName) async {
return _patches
.where((patch) =>
!patch.name.contains('settings') &&
patch.compatiblePackages.any((pack) => pack.name == packageName))
.toList();
List<Patch> filteredPatches = [];
_patches.forEach((patch) {
if (patch.compatiblePackages.isEmpty) {
filteredPatches.add(patch);
} else {
if (!patch.name.contains('settings') &&
patch.compatiblePackages.any((pack) => pack.name == packageName)
) {
filteredPatches.add(patch);
}
}
});
return filteredPatches;
}
Future<List<Patch>> getAppliedPatches(List<String> appliedPatches) async {
@ -229,7 +256,6 @@ class PatcherAPI {
return false;
}
void exportPatchedFile(String appName, String version) {
try {
if (_outFile != null) {
@ -238,13 +264,12 @@ class PatcherAPI {
// This is temporary workaround to populate initial file name
// ref: https://github.com/Cleveroad/cr_file_saver/issues/7
int lastSeparator = _outFile!.path.lastIndexOf('/');
String newSourcePath = _outFile!.path.substring(0, lastSeparator + 1) + newName;
String newSourcePath =
_outFile!.path.substring(0, lastSeparator + 1) + newName;
_outFile!.copySync(newSourcePath);
CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
sourceFilePath: newSourcePath,
destinationFileName: newName
));
sourceFilePath: newSourcePath, destinationFileName: newName));
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
@ -267,10 +292,9 @@ class PatcherAPI {
}
String _getFileName(String appName, String version) {
String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk';
return newName;
String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk';
return newName;
}
Future<void> sharePatcherLog(String logs) async {

View File

@ -147,7 +147,7 @@ class PatchesSelectorViewModel extends BaseViewModel {
bool isPatchSupported(Patch patch) {
PatchedApplication app = locator<PatcherViewModel>().selectedApp!;
return patch.compatiblePackages.any((pack) =>
return patch.compatiblePackages.isEmpty || patch.compatiblePackages.any((pack) =>
pack.name == app.packageName &&
(pack.versions.isEmpty || pack.versions.contains(app.version)));
}

View File

@ -12,14 +12,17 @@ import 'package:stacked/stacked.dart';
class SManageSources extends BaseViewModel {
final ManagerAPI _managerAPI = locator<ManagerAPI>();
final TextEditingController _hostSourceController = TextEditingController();
final TextEditingController _orgPatSourceController = TextEditingController();
final TextEditingController _patSourceController = TextEditingController();
final TextEditingController _orgIntSourceController = TextEditingController();
final TextEditingController _intSourceController = TextEditingController();
Future<void> showSourcesDialog(BuildContext context) async {
String hostRepository = _managerAPI.getRepoUrl();
String patchesRepo = _managerAPI.getPatchesRepo();
String integrationsRepo = _managerAPI.getIntegrationsRepo();
_hostSourceController.text = hostRepository;
_orgPatSourceController.text = patchesRepo.split('/')[0];
_patSourceController.text = patchesRepo.split('/')[1];
_orgIntSourceController.text = integrationsRepo.split('/')[0];
@ -42,6 +45,17 @@ class SManageSources extends BaseViewModel {
content: SingleChildScrollView(
child: Column(
children: <Widget>[
CustomTextField(
leadingIcon: const Icon(
Icons.extension_outlined,
color: Colors.transparent,
),
inputController: _hostSourceController,
label: I18nText('settingsView.hostRepositoryLabel'),
hint: hostRepository,
onChanged: (value) => notifyListeners(),
),
const SizedBox(height: 20),
CustomTextField(
leadingIcon: Icon(
Icons.extension_outlined,
@ -103,6 +117,7 @@ class SManageSources extends BaseViewModel {
CustomMaterialButton(
label: I18nText('okButton'),
onPressed: () {
_managerAPI.setRepoUrl(_hostSourceController.text);
_managerAPI.setPatchesRepo(
'${_orgPatSourceController.text}/${_patSourceController.text}',
);
@ -133,10 +148,12 @@ class SManageSources extends BaseViewModel {
CustomMaterialButton(
label: I18nText('yesButton'),
onPressed: () {
_managerAPI.setRepoUrl('');
_managerAPI.setPatchesRepo('');
_managerAPI.setIntegrationsRepo('');
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
},
)
],

View File

@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
publish_to: 'none'
version: 0.0.44+44
version: 0.0.46+46
environment:
sdk: ">=2.17.5 <3.0.0"