mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 12:47:37 +02:00
feat: download latest patches and integrations.
This commit is contained in:
@ -3,7 +3,7 @@ import 'package:github/github.dart';
|
||||
class GithubAPI {
|
||||
var github = GitHub();
|
||||
|
||||
Future latestRelease(String org, repoName) async {
|
||||
Future<String?> latestRelease(String org, repoName) async {
|
||||
var latestRelease = await github.repositories
|
||||
.getLatestRelease(RepositorySlug(org, repoName));
|
||||
var dlurl = latestRelease.assets
|
||||
@ -12,7 +12,7 @@ class GithubAPI {
|
||||
element.browserDownloadUrl!.contains(".apk"))
|
||||
.browserDownloadUrl;
|
||||
print(dlurl);
|
||||
return latestRelease;
|
||||
return dlurl;
|
||||
}
|
||||
|
||||
Future latestCommitTime(String org, repoName) async {
|
||||
@ -53,7 +53,7 @@ class GithubAPI {
|
||||
|
||||
void main(List<String> args) {
|
||||
GithubAPI githubAPI = GithubAPI();
|
||||
// githubAPI.latestRelease('revanced', 'revanced-patches');
|
||||
githubAPI.latestRelease('revanced', 'revanced-patches');
|
||||
// githubAPI.latestCommitTime("revanced", "revanced-patches");
|
||||
// githubAPI.contributors("revanced", "revanced-manager");
|
||||
}
|
||||
|
@ -1,10 +1,45 @@
|
||||
import 'dart:io';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:path_provider/path_provider.dart' as p;
|
||||
import 'package:revanced_manager_flutter/constants.dart';
|
||||
import 'github_api.dart';
|
||||
|
||||
// use path_provider to get the path of the storage directory
|
||||
Dio dio = Dio();
|
||||
GithubAPI githubAPI = GithubAPI();
|
||||
|
||||
void getPath() async {
|
||||
final path = await p.getExternalStorageDirectory();
|
||||
print(path);
|
||||
Future<String?> getPath() async {
|
||||
final path = await p.getApplicationSupportDirectory();
|
||||
final workDir = Directory('${path.path}/revanced').createSync();
|
||||
final workDirPath = "${path.path}/revanced";
|
||||
return workDirPath;
|
||||
}
|
||||
|
||||
Future<File?> downloadAssets(String repo) async {
|
||||
try {
|
||||
final workDir = await getPath();
|
||||
final dlUrl = await githubAPI.latestRelease(ghOrg, repo);
|
||||
final name =
|
||||
dlUrl?.split('/').lastWhere((element) => element.contains('revanced'));
|
||||
print(name);
|
||||
final assetFile = File('$workDir/$name');
|
||||
final response = await dio.get(
|
||||
dlUrl!,
|
||||
options: Options(
|
||||
responseType: ResponseType.bytes,
|
||||
followRedirects: true,
|
||||
receiveTimeout: 0,
|
||||
),
|
||||
onReceiveProgress: (count, total) {
|
||||
print('$count/$total');
|
||||
},
|
||||
);
|
||||
final raf = assetFile.openSync(mode: FileMode.write);
|
||||
raf.writeFromSync(response.data);
|
||||
raf.closeSync();
|
||||
return assetFile;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -10,3 +10,7 @@ const pink40 = Color(0xFF7D5260);
|
||||
|
||||
final interTextStyle = GoogleFonts.inter();
|
||||
final robotoTextStyle = GoogleFonts.roboto();
|
||||
|
||||
const ghOrg = "revanced";
|
||||
const patchesRepo = "revanced-patches";
|
||||
const integrationsRepo = "revanced-integrations";
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:revanced_manager_flutter/backend/api/manager_api.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/available_updates_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/installed_apps_card.dart';
|
||||
import 'package:revanced_manager_flutter/ui/widgets/latest_commit_card.dart';
|
||||
@ -24,9 +23,7 @@ class HomeScreen extends StatelessWidget {
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
getPath();
|
||||
},
|
||||
onPressed: () {},
|
||||
icon: const Icon(
|
||||
Icons.more_vert,
|
||||
),
|
||||
|
@ -17,10 +17,10 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||
String lastManagerCommit = "Loading...";
|
||||
|
||||
void latestCommit() async {
|
||||
lastPatcherCommit =
|
||||
await githubAPI.latestCommitTime("revanced", "revanced-patcher");
|
||||
lastManagerCommit =
|
||||
await githubAPI.latestCommitTime("revanced", "revanced-manager");
|
||||
// lastPatcherCommit =
|
||||
// await githubAPI.latestCommitTime("revanced", "revanced-patcher");
|
||||
// lastManagerCommit =
|
||||
// await githubAPI.latestCommitTime("revanced", "revanced-manager");
|
||||
}
|
||||
|
||||
@override
|
||||
|
Reference in New Issue
Block a user