mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: Add ReVanced API and implement cache on it and on Github API
This commit is contained in:
parent
fe13234faa
commit
595ecb7660
@ -1,11 +1,21 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
// ignore: depend_on_referenced_packages
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
|
||||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
import 'package:github/github.dart';
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
import 'package:timeago/timeago.dart';
|
|
||||||
|
|
||||||
class GithubAPI {
|
class GithubAPI {
|
||||||
final GitHub _github = GitHub();
|
final String apiUrl = 'https://api.github.com';
|
||||||
|
final Dio _dio = Dio();
|
||||||
|
final DioCacheManager _dioCacheManager = DioCacheManager(
|
||||||
|
CacheConfig(
|
||||||
|
defaultMaxAge: const Duration(hours: 1),
|
||||||
|
defaultMaxStale: const Duration(days: 7),
|
||||||
|
),
|
||||||
|
);
|
||||||
final Map<String, String> repoAppPath = {
|
final Map<String, String> repoAppPath = {
|
||||||
'com.google.android.youtube': 'youtube',
|
'com.google.android.youtube': 'youtube',
|
||||||
'com.google.android.apps.youtube.music': 'music',
|
'com.google.android.apps.youtube.music': 'music',
|
||||||
@ -16,69 +26,96 @@ class GithubAPI {
|
|||||||
'com.garzotto.pflotsh.ecmwf_a': 'ecmwf',
|
'com.garzotto.pflotsh.ecmwf_a': 'ecmwf',
|
||||||
};
|
};
|
||||||
|
|
||||||
Future<String?> latestReleaseVersion(String repoName) async {
|
void initialize() {
|
||||||
try {
|
_dio.interceptors.add(_dioCacheManager.interceptor);
|
||||||
var latestRelease = await _github.repositories.getLatestRelease(
|
|
||||||
RepositorySlug.full(repoName),
|
|
||||||
);
|
|
||||||
return latestRelease.tagName;
|
|
||||||
} on Exception {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<File?> latestReleaseFile(String extension, String repoName) async {
|
Future<void> clearAllCache() async {
|
||||||
try {
|
await _dioCacheManager.clearAll();
|
||||||
var latestRelease = await _github.repositories.getLatestRelease(
|
|
||||||
RepositorySlug.full(repoName),
|
|
||||||
);
|
|
||||||
String? url = latestRelease.assets
|
|
||||||
?.firstWhere((asset) =>
|
|
||||||
asset.name != null &&
|
|
||||||
asset.name!.endsWith(extension) &&
|
|
||||||
!asset.name!.contains('-sources') &&
|
|
||||||
!asset.name!.contains('-javadoc'))
|
|
||||||
.browserDownloadUrl;
|
|
||||||
if (url != null) {
|
|
||||||
return await DefaultCacheManager().getSingleFile(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>?> _getLatestRelease(String repoName) async {
|
||||||
|
try {
|
||||||
|
var response = await _dio.get(
|
||||||
|
'$apiUrl/repos/$repoName/releases/latest',
|
||||||
|
options: buildCacheOptions(const Duration(hours: 1)),
|
||||||
|
);
|
||||||
|
if (response.headers.value(DIO_CACHE_HEADER_KEY_DATA_SOURCE) != null) {
|
||||||
|
print('1 - From cache');
|
||||||
|
} else {
|
||||||
|
print('1 - From net');
|
||||||
|
}
|
||||||
|
return response.data;
|
||||||
} on Exception {
|
} on Exception {
|
||||||
return null;
|
// ignore
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> latestCommitTime(String repoName) async {
|
Future<List<String>> getCommits(
|
||||||
try {
|
|
||||||
var repo = await _github.repositories.getRepository(
|
|
||||||
RepositorySlug.full(repoName),
|
|
||||||
);
|
|
||||||
return repo.pushedAt != null
|
|
||||||
? format(repo.pushedAt!, locale: 'en_short')
|
|
||||||
: '';
|
|
||||||
} on Exception {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<Contributor>> getContributors(String repoName) async {
|
|
||||||
return await (_github.repositories.listContributors(
|
|
||||||
RepositorySlug.full(repoName),
|
|
||||||
)).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<List<RepositoryCommit>> getCommits(
|
|
||||||
String packageName,
|
String packageName,
|
||||||
String repoName,
|
String repoName,
|
||||||
|
DateTime since,
|
||||||
) async {
|
) async {
|
||||||
String path =
|
String path =
|
||||||
'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}';
|
'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}';
|
||||||
return await (PaginationHelper(_github)
|
try {
|
||||||
.objects<Map<String, dynamic>, RepositoryCommit>(
|
var response = await _dio.get(
|
||||||
'GET',
|
'$apiUrl/repos/$repoName/commits',
|
||||||
'/repos/$repoName/commits',
|
queryParameters: {
|
||||||
(i) => RepositoryCommit.fromJson(i),
|
'path': path,
|
||||||
params: <String, dynamic>{'path': path},
|
'per_page': 3,
|
||||||
)).toList();
|
'since': since.toIso8601String(),
|
||||||
|
},
|
||||||
|
options: buildCacheOptions(const Duration(hours: 1)),
|
||||||
|
);
|
||||||
|
if (response.headers.value(DIO_CACHE_HEADER_KEY_DATA_SOURCE) != null) {
|
||||||
|
print('2 - From cache');
|
||||||
|
} else {
|
||||||
|
print('2 - From net');
|
||||||
|
}
|
||||||
|
List<dynamic> commits = response.data;
|
||||||
|
return commits
|
||||||
|
.map((commit) =>
|
||||||
|
(commit['commit']['message'] as String).split('\n')[0])
|
||||||
|
.toList();
|
||||||
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return List.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File?> getLatestReleaseFile(String extension, String repoName) async {
|
||||||
|
try {
|
||||||
|
Map<String, dynamic>? release = await _getLatestRelease(repoName);
|
||||||
|
if (release != null) {
|
||||||
|
Map<String, dynamic>? asset =
|
||||||
|
(release['assets'] as List<dynamic>).firstWhereOrNull(
|
||||||
|
(asset) => (asset['name'] as String).endsWith(extension),
|
||||||
|
);
|
||||||
|
if (asset != null) {
|
||||||
|
return await DefaultCacheManager().getSingleFile(
|
||||||
|
asset['browser_download_url'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} on Exception {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Patch>> getPatches(String repoName) async {
|
||||||
|
List<Patch> patches = [];
|
||||||
|
try {
|
||||||
|
File? f = await getLatestReleaseFile('.json', repoName);
|
||||||
|
if (f != null) {
|
||||||
|
List<dynamic> list = jsonDecode(f.readAsStringSync());
|
||||||
|
patches = list.map((patch) => Patch.fromJson(patch)).toList();
|
||||||
|
}
|
||||||
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return patches;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:device_apps/device_apps.dart';
|
import 'package:device_apps/device_apps.dart';
|
||||||
import 'package:github/github.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
import 'package:revanced_manager/models/patched_application.dart';
|
import 'package:revanced_manager/models/patched_application.dart';
|
||||||
import 'package:revanced_manager/services/github_api.dart';
|
import 'package:revanced_manager/services/github_api.dart';
|
||||||
|
import 'package:revanced_manager/services/revanced_api.dart';
|
||||||
import 'package:revanced_manager/services/root_api.dart';
|
import 'package:revanced_manager/services/root_api.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
@lazySingleton
|
@lazySingleton
|
||||||
class ManagerAPI {
|
class ManagerAPI {
|
||||||
|
final RevancedAPI _revancedAPI = RevancedAPI();
|
||||||
final GithubAPI _githubAPI = GithubAPI();
|
final GithubAPI _githubAPI = GithubAPI();
|
||||||
final RootAPI _rootAPI = RootAPI();
|
final RootAPI _rootAPI = RootAPI();
|
||||||
final String patcherRepo = 'revanced-patcher';
|
final String patcherRepo = 'revanced-patcher';
|
||||||
@ -26,10 +28,6 @@ class ManagerAPI {
|
|||||||
_prefs = await SharedPreferences.getInstance();
|
_prefs = await SharedPreferences.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getPatcherRepo() {
|
|
||||||
return defaultPatcherRepo;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getPatchesRepo() {
|
String getPatchesRepo() {
|
||||||
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
|
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
|
||||||
}
|
}
|
||||||
@ -52,46 +50,6 @@ class ManagerAPI {
|
|||||||
await _prefs.setString('integrationsRepo', value);
|
await _prefs.setString('integrationsRepo', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getCliRepo() {
|
|
||||||
return defaultCliRepo;
|
|
||||||
}
|
|
||||||
|
|
||||||
String getManagerRepo() {
|
|
||||||
return _prefs.getString('managerRepo') ?? defaultManagerRepo;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> setManagerRepo(String value) async {
|
|
||||||
if (value.isEmpty || value.startsWith('/') || value.endsWith('/')) {
|
|
||||||
value = defaultManagerRepo;
|
|
||||||
}
|
|
||||||
await _prefs.setString('managerRepo', value);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<File?> downloadPatches(String extension) async {
|
|
||||||
return await _githubAPI.latestReleaseFile(extension, getPatchesRepo());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<File?> downloadIntegrations(String extension) async {
|
|
||||||
return await _githubAPI.latestReleaseFile(extension, getIntegrationsRepo());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<File?> downloadManager(String extension) async {
|
|
||||||
return await _githubAPI.latestReleaseFile(extension, getManagerRepo());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String?> getLatestPatchesVersion() async {
|
|
||||||
return await _githubAPI.latestReleaseVersion(getPatchesRepo());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String?> getLatestManagerVersion() async {
|
|
||||||
return await _githubAPI.latestReleaseVersion(getManagerRepo());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String> getCurrentManagerVersion() async {
|
|
||||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
||||||
return packageInfo.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getUseDynamicTheme() {
|
bool getUseDynamicTheme() {
|
||||||
return _prefs.getBool('useDynamicTheme') ?? false;
|
return _prefs.getBool('useDynamicTheme') ?? false;
|
||||||
}
|
}
|
||||||
@ -110,9 +68,7 @@ class ManagerAPI {
|
|||||||
|
|
||||||
List<PatchedApplication> getPatchedApps() {
|
List<PatchedApplication> getPatchedApps() {
|
||||||
List<String> apps = _prefs.getStringList('patchedApps') ?? [];
|
List<String> apps = _prefs.getStringList('patchedApps') ?? [];
|
||||||
return apps
|
return apps.map((a) => PatchedApplication.fromJson(jsonDecode(a))).toList();
|
||||||
.map((a) => PatchedApplication.fromJson(json.decode(a)))
|
|
||||||
.toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setPatchedApps(List<PatchedApplication> patchedApps) async {
|
Future<void> setPatchedApps(List<PatchedApplication> patchedApps) async {
|
||||||
@ -143,6 +99,71 @@ class ManagerAPI {
|
|||||||
await setPatchedApps(patchedApps);
|
await setPatchedApps(patchedApps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearAllData() {
|
||||||
|
_revancedAPI.clearAllCache();
|
||||||
|
_githubAPI.clearAllCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, List<dynamic>>> getContributors() async {
|
||||||
|
return await _revancedAPI.getContributors();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Patch>> getPatches() async {
|
||||||
|
if (getPatchesRepo() == defaultPatchesRepo) {
|
||||||
|
return await _revancedAPI.getPatches();
|
||||||
|
} else {
|
||||||
|
return await _githubAPI.getPatches(getPatchesRepo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File?> downloadPatches() async {
|
||||||
|
String repoName = getPatchesRepo();
|
||||||
|
if (repoName == defaultPatchesRepo) {
|
||||||
|
return await _revancedAPI.getLatestReleaseFile(
|
||||||
|
'.jar',
|
||||||
|
defaultPatchesRepo,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return await _githubAPI.getLatestReleaseFile('.jar', repoName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File?> downloadIntegrations() async {
|
||||||
|
String repoName = getIntegrationsRepo();
|
||||||
|
if (repoName == defaultIntegrationsRepo) {
|
||||||
|
return await _revancedAPI.getLatestReleaseFile(
|
||||||
|
'.apk',
|
||||||
|
defaultIntegrationsRepo,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return await _githubAPI.getLatestReleaseFile('.apk', repoName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File?> downloadManager() async {
|
||||||
|
return await _revancedAPI.getLatestReleaseFile('.apk', defaultManagerRepo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestPatcherReleaseTime() async {
|
||||||
|
return await _revancedAPI.getLatestReleaseTime('.gz', defaultPatcherRepo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestManagerReleaseTime() async {
|
||||||
|
return await _revancedAPI.getLatestReleaseTime('.apk', defaultManagerRepo);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestManagerVersion() async {
|
||||||
|
return await _revancedAPI.getLatestReleaseVersion(
|
||||||
|
'.apk',
|
||||||
|
defaultManagerRepo,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> getCurrentManagerVersion() async {
|
||||||
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||||
|
return packageInfo.version;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> reAssessSavedApps() async {
|
Future<void> reAssessSavedApps() async {
|
||||||
List<PatchedApplication> patchedApps = getPatchedApps();
|
List<PatchedApplication> patchedApps = getPatchedApps();
|
||||||
List<PatchedApplication> toRemove = [];
|
List<PatchedApplication> toRemove = [];
|
||||||
@ -183,40 +204,27 @@ class ManagerAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> hasAppUpdates(String packageName, DateTime patchDate) async {
|
Future<bool> hasAppUpdates(String packageName, DateTime patchDate) async {
|
||||||
List<RepositoryCommit> commits = await _githubAPI.getCommits(
|
List<String> commits = await _githubAPI.getCommits(
|
||||||
packageName,
|
packageName,
|
||||||
getPatchesRepo(),
|
getPatchesRepo(),
|
||||||
|
patchDate,
|
||||||
);
|
);
|
||||||
return commits.any((c) =>
|
return commits.isNotEmpty;
|
||||||
c.commit != null &&
|
|
||||||
c.commit!.author != null &&
|
|
||||||
c.commit!.author!.date != null &&
|
|
||||||
c.commit!.author!.date!.isAfter(patchDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<String>> getAppChangelog(
|
Future<List<String>> getAppChangelog(
|
||||||
String packageName,
|
String packageName, DateTime patchDate) async {
|
||||||
DateTime patchDate,
|
List<String> newCommits = await _githubAPI.getCommits(
|
||||||
) async {
|
|
||||||
List<RepositoryCommit> commits = await _githubAPI.getCommits(
|
|
||||||
packageName,
|
packageName,
|
||||||
getPatchesRepo(),
|
getPatchesRepo(),
|
||||||
|
patchDate,
|
||||||
);
|
);
|
||||||
List<String> newCommits = commits
|
|
||||||
.where((c) =>
|
|
||||||
c.commit != null &&
|
|
||||||
c.commit!.author != null &&
|
|
||||||
c.commit!.author!.date != null &&
|
|
||||||
c.commit!.author!.date!.isAfter(patchDate) &&
|
|
||||||
c.commit!.message != null)
|
|
||||||
.map((c) => c.commit!.message!)
|
|
||||||
.toList();
|
|
||||||
if (newCommits.isEmpty) {
|
if (newCommits.isEmpty) {
|
||||||
newCommits = commits
|
newCommits = await _githubAPI.getCommits(
|
||||||
.where((c) => c.commit != null && c.commit!.message != null)
|
packageName,
|
||||||
.take(3)
|
getPatchesRepo(),
|
||||||
.map((c) => c.commit!.message!)
|
DateTime(2022, 3, 20, 21, 06, 01),
|
||||||
.toList();
|
);
|
||||||
}
|
}
|
||||||
return newCommits;
|
return newCommits;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:app_installer/app_installer.dart';
|
import 'package:app_installer/app_installer.dart';
|
||||||
|
// ignore: depend_on_referenced_packages
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:device_apps/device_apps.dart';
|
import 'package:device_apps/device_apps.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:injectable/injectable.dart';
|
import 'package:injectable/injectable.dart';
|
||||||
@ -39,11 +40,7 @@ class PatcherAPI {
|
|||||||
Future<void> _loadPatches() async {
|
Future<void> _loadPatches() async {
|
||||||
try {
|
try {
|
||||||
if (_patches.isEmpty) {
|
if (_patches.isEmpty) {
|
||||||
File? patchJsonFile = await _managerAPI.downloadPatches('.json');
|
_patches = await _managerAPI.getPatches();
|
||||||
if (patchJsonFile != null) {
|
|
||||||
List<dynamic> list = json.decode(patchJsonFile.readAsStringSync());
|
|
||||||
_patches = list.map((patch) => Patch.fromJson(patch)).toList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} on Exception {
|
} on Exception {
|
||||||
_patches = List.empty();
|
_patches = List.empty();
|
||||||
@ -52,7 +49,6 @@ class PatcherAPI {
|
|||||||
|
|
||||||
Future<List<ApplicationWithIcon>> getFilteredInstalledApps() async {
|
Future<List<ApplicationWithIcon>> getFilteredInstalledApps() async {
|
||||||
List<ApplicationWithIcon> filteredApps = [];
|
List<ApplicationWithIcon> filteredApps = [];
|
||||||
await _loadPatches();
|
|
||||||
for (Patch patch in _patches) {
|
for (Patch patch in _patches) {
|
||||||
for (Package package in patch.compatiblePackages) {
|
for (Package package in patch.compatiblePackages) {
|
||||||
try {
|
try {
|
||||||
@ -73,7 +69,6 @@ class PatcherAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Patch>> getFilteredPatches(String packageName) async {
|
Future<List<Patch>> getFilteredPatches(String packageName) async {
|
||||||
await _loadPatches();
|
|
||||||
return _patches
|
return _patches
|
||||||
.where((patch) =>
|
.where((patch) =>
|
||||||
!patch.name.contains('settings') &&
|
!patch.name.contains('settings') &&
|
||||||
@ -82,7 +77,6 @@ class PatcherAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Patch>> getAppliedPatches(List<String> appliedPatches) async {
|
Future<List<Patch>> getAppliedPatches(List<String> appliedPatches) async {
|
||||||
await _loadPatches();
|
|
||||||
return _patches
|
return _patches
|
||||||
.where((patch) => appliedPatches.contains(patch.name))
|
.where((patch) => appliedPatches.contains(patch.name))
|
||||||
.toList();
|
.toList();
|
||||||
@ -104,20 +98,22 @@ class PatcherAPI {
|
|||||||
);
|
);
|
||||||
if (includeSettings) {
|
if (includeSettings) {
|
||||||
try {
|
try {
|
||||||
Patch settingsPatch = _patches.firstWhere(
|
Patch? settingsPatch = _patches.firstWhereOrNull(
|
||||||
(patch) =>
|
(patch) =>
|
||||||
patch.name.contains('settings') &&
|
patch.name.contains('settings') &&
|
||||||
patch.compatiblePackages.any((pack) => pack.name == packageName),
|
patch.compatiblePackages.any((pack) => pack.name == packageName),
|
||||||
);
|
);
|
||||||
|
if (settingsPatch != null) {
|
||||||
selectedPatches.add(settingsPatch);
|
selectedPatches.add(settingsPatch);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File? patchBundleFile = await _managerAPI.downloadPatches('.jar');
|
File? patchBundleFile = await _managerAPI.downloadPatches();
|
||||||
File? integrationsFile;
|
File? integrationsFile;
|
||||||
if (mergeIntegrations) {
|
if (mergeIntegrations) {
|
||||||
integrationsFile = await _managerAPI.downloadIntegrations('.apk');
|
integrationsFile = await _managerAPI.downloadIntegrations();
|
||||||
}
|
}
|
||||||
if (patchBundleFile != null) {
|
if (patchBundleFile != null) {
|
||||||
_tmpDir.createSync();
|
_tmpDir.createSync();
|
||||||
|
138
lib/services/revanced_api.dart
Normal file
138
lib/services/revanced_api.dart
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
// ignore: depend_on_referenced_packages
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
|
||||||
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||||
|
import 'package:injectable/injectable.dart';
|
||||||
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
|
import 'package:timeago/timeago.dart';
|
||||||
|
|
||||||
|
@lazySingleton
|
||||||
|
class RevancedAPI {
|
||||||
|
final String apiUrl = 'https://revanced-releases-api.afterst0rm.xyz';
|
||||||
|
final Dio _dio = Dio();
|
||||||
|
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
|
||||||
|
final Options _cacheOptions = buildCacheOptions(
|
||||||
|
const Duration(minutes: 10),
|
||||||
|
maxStale: const Duration(days: 7),
|
||||||
|
);
|
||||||
|
|
||||||
|
void initialize() {
|
||||||
|
_dio.interceptors.add(_dioCacheManager.interceptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> clearAllCache() async {
|
||||||
|
await _dioCacheManager.clearAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, List<dynamic>>> getContributors() async {
|
||||||
|
Map<String, List<dynamic>> contributors = {};
|
||||||
|
try {
|
||||||
|
var response = await _dio.get(
|
||||||
|
'$apiUrl/contributors',
|
||||||
|
options: _cacheOptions,
|
||||||
|
);
|
||||||
|
if (response.headers.value(DIO_CACHE_HEADER_KEY_DATA_SOURCE) != null) {
|
||||||
|
print('3 - From cache');
|
||||||
|
} else {
|
||||||
|
print('3 - From net');
|
||||||
|
}
|
||||||
|
List<dynamic> repositories = response.data['repositories'];
|
||||||
|
for (Map<String, dynamic> repo in repositories) {
|
||||||
|
String name = repo['name'];
|
||||||
|
contributors[name] = repo['contributors'];
|
||||||
|
}
|
||||||
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return contributors;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<List<Patch>> getPatches() async {
|
||||||
|
try {
|
||||||
|
var response = await _dio.get('$apiUrl/patches', options: _cacheOptions);
|
||||||
|
if (response.headers.value(DIO_CACHE_HEADER_KEY_DATA_SOURCE) != null) {
|
||||||
|
print('4 - From cache');
|
||||||
|
} else {
|
||||||
|
print('4 - From net');
|
||||||
|
}
|
||||||
|
List<dynamic> patches = response.data;
|
||||||
|
return patches.map((patch) => Patch.fromJson(patch)).toList();
|
||||||
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return List.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>?> _getLatestRelease(
|
||||||
|
String extension,
|
||||||
|
String repoName,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
var response = await _dio.get('$apiUrl/tools', options: _cacheOptions);
|
||||||
|
if (response.headers.value(DIO_CACHE_HEADER_KEY_DATA_SOURCE) != null) {
|
||||||
|
print('5 - From cache');
|
||||||
|
} else {
|
||||||
|
print('5 - From net');
|
||||||
|
}
|
||||||
|
List<dynamic> tools = response.data['tools'];
|
||||||
|
return tools.firstWhereOrNull(
|
||||||
|
(t) =>
|
||||||
|
t['repository'] == repoName &&
|
||||||
|
(t['name'] as String).endsWith(extension),
|
||||||
|
);
|
||||||
|
} on Exception {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestReleaseVersion(
|
||||||
|
String extension, String repoName) async {
|
||||||
|
try {
|
||||||
|
Map<String, dynamic>? release =
|
||||||
|
await _getLatestRelease(extension, repoName);
|
||||||
|
if (release != null) {
|
||||||
|
return release['version'];
|
||||||
|
}
|
||||||
|
} on Exception {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File?> getLatestReleaseFile(String extension, String repoName) async {
|
||||||
|
try {
|
||||||
|
Map<String, dynamic>? release = await _getLatestRelease(
|
||||||
|
extension,
|
||||||
|
repoName,
|
||||||
|
);
|
||||||
|
if (release != null) {
|
||||||
|
String url = release['browser_download_url'];
|
||||||
|
return await DefaultCacheManager().getSingleFile(url);
|
||||||
|
}
|
||||||
|
} on Exception {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestReleaseTime(
|
||||||
|
String extension,
|
||||||
|
String repoName,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
Map<String, dynamic>? release = await _getLatestRelease(
|
||||||
|
extension,
|
||||||
|
repoName,
|
||||||
|
);
|
||||||
|
if (release != null) {
|
||||||
|
DateTime timestamp = DateTime.parse(release['timestamp'] as String);
|
||||||
|
return format(timestamp, locale: 'en_short');
|
||||||
|
}
|
||||||
|
} on Exception {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,34 +1,24 @@
|
|||||||
import 'package:github/github.dart';
|
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/services/github_api.dart';
|
|
||||||
import 'package:revanced_manager/services/manager_api.dart';
|
import 'package:revanced_manager/services/manager_api.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
|
|
||||||
class ContributorsViewModel extends BaseViewModel {
|
class ContributorsViewModel extends BaseViewModel {
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
final GithubAPI _githubAPI = GithubAPI();
|
List<dynamic> patcherContributors = [];
|
||||||
List<Contributor> patcherContributors = [];
|
List<dynamic> patchesContributors = [];
|
||||||
List<Contributor> patchesContributors = [];
|
List<dynamic> integrationsContributors = [];
|
||||||
List<Contributor> integrationsContributors = [];
|
List<dynamic> cliContributors = [];
|
||||||
List<Contributor> cliContributors = [];
|
List<dynamic> managerContributors = [];
|
||||||
List<Contributor> managerContributors = [];
|
|
||||||
|
|
||||||
Future<void> getContributors() async {
|
Future<void> getContributors() async {
|
||||||
patcherContributors = await _githubAPI.getContributors(
|
Map<String, List<dynamic>> contributors =
|
||||||
_managerAPI.getPatcherRepo(),
|
await _managerAPI.getContributors();
|
||||||
);
|
patcherContributors = contributors[_managerAPI.defaultPatcherRepo] ?? [];
|
||||||
patchesContributors = await _githubAPI.getContributors(
|
patchesContributors = contributors[_managerAPI.getPatchesRepo()] ?? [];
|
||||||
_managerAPI.getPatchesRepo(),
|
integrationsContributors =
|
||||||
);
|
contributors[_managerAPI.getIntegrationsRepo()] ?? [];
|
||||||
integrationsContributors = await _githubAPI.getContributors(
|
cliContributors = contributors[_managerAPI.defaultCliRepo] ?? [];
|
||||||
_managerAPI.getIntegrationsRepo(),
|
managerContributors = contributors[_managerAPI.defaultManagerRepo] ?? [];
|
||||||
);
|
|
||||||
cliContributors = await _githubAPI.getContributors(
|
|
||||||
_managerAPI.getCliRepo(),
|
|
||||||
);
|
|
||||||
managerContributors = await _githubAPI.getContributors(
|
|
||||||
_managerAPI.getManagerRepo(),
|
|
||||||
);
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,11 @@ class HomeView extends StatelessWidget {
|
|||||||
onModelReady: (model) => model.initialize(),
|
onModelReady: (model) => model.initialize(),
|
||||||
viewModelBuilder: () => locator<HomeViewModel>(),
|
viewModelBuilder: () => locator<HomeViewModel>(),
|
||||||
builder: (context, model, child) => Scaffold(
|
builder: (context, model, child) => Scaffold(
|
||||||
body: CustomScrollView(
|
body: RefreshIndicator(
|
||||||
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.secondaryContainer,
|
||||||
|
onRefresh: () => model.forceRefresh(),
|
||||||
|
child: CustomScrollView(
|
||||||
slivers: <Widget>[
|
slivers: <Widget>[
|
||||||
CustomSliverAppBar(
|
CustomSliverAppBar(
|
||||||
title: I18nText(
|
title: I18nText(
|
||||||
@ -89,6 +93,7 @@ class HomeView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
final NavigationService _navigationService = locator<NavigationService>();
|
final NavigationService _navigationService = locator<NavigationService>();
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
|
||||||
FlutterLocalNotificationsPlugin();
|
DateTime? _lastUpdate;
|
||||||
bool showUpdatableApps = true;
|
bool showUpdatableApps = true;
|
||||||
List<PatchedApplication> patchedInstalledApps = [];
|
List<PatchedApplication> patchedInstalledApps = [];
|
||||||
List<PatchedApplication> patchedUpdatableApps = [];
|
List<PatchedApplication> patchedUpdatableApps = [];
|
||||||
@ -61,10 +61,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _getPatchedApps() {
|
void _getPatchedApps() {
|
||||||
patchedInstalledApps = _managerAPI
|
patchedInstalledApps = _managerAPI.getPatchedApps().toList();
|
||||||
.getPatchedApps()
|
|
||||||
.where((app) => app.hasUpdates == false)
|
|
||||||
.toList();
|
|
||||||
patchedUpdatableApps = _managerAPI
|
patchedUpdatableApps = _managerAPI
|
||||||
.getPatchedApps()
|
.getPatchedApps()
|
||||||
.where((app) => app.hasUpdates == true)
|
.where((app) => app.hasUpdates == true)
|
||||||
@ -98,7 +95,7 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
toastLength: Toast.LENGTH_LONG,
|
toastLength: Toast.LENGTH_LONG,
|
||||||
gravity: ToastGravity.CENTER,
|
gravity: ToastGravity.CENTER,
|
||||||
);
|
);
|
||||||
File? managerApk = await _managerAPI.downloadManager('.apk');
|
File? managerApk = await _managerAPI.downloadManager();
|
||||||
if (managerApk != null) {
|
if (managerApk != null) {
|
||||||
flutterLocalNotificationsPlugin.show(
|
flutterLocalNotificationsPlugin.show(
|
||||||
0,
|
0,
|
||||||
@ -170,4 +167,21 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestPatcherReleaseTime() async {
|
||||||
|
return _managerAPI.getLatestPatcherReleaseTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestManagerReleaseTime() async {
|
||||||
|
return _managerAPI.getLatestManagerReleaseTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> forceRefresh() async {
|
||||||
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
if (_lastUpdate == null ||
|
||||||
|
_lastUpdate!.difference(DateTime.now()).inSeconds > 60) {
|
||||||
|
_managerAPI.clearAllData();
|
||||||
|
}
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,12 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
await FlutterBackground.enableBackgroundExecution();
|
await FlutterBackground.enableBackgroundExecution();
|
||||||
} finally {
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
await handlePlatformChannelMethods();
|
await handlePlatformChannelMethods();
|
||||||
await runPatcher();
|
await runPatcher();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Future<dynamic> handlePlatformChannelMethods() async {
|
Future<dynamic> handlePlatformChannelMethods() async {
|
||||||
_installerChannel.setMethodCallHandler((call) async {
|
_installerChannel.setMethodCallHandler((call) async {
|
||||||
@ -118,10 +119,13 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
update(1.0, 'Aborting...', 'No app or patches selected! Aborting');
|
update(1.0, 'Aborting...', 'No app or patches selected! Aborting');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (FlutterBackground.isBackgroundExecutionEnabled) {
|
||||||
await FlutterBackground.disableBackgroundExecution();
|
await FlutterBackground.disableBackgroundExecution();
|
||||||
} finally {
|
|
||||||
isPatching = false;
|
|
||||||
}
|
}
|
||||||
|
} on Exception {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
isPatching = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void installResult(bool installAsRoot) async {
|
void installResult(bool installAsRoot) async {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// ignore: depend_on_referenced_packages
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/models/patch.dart';
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
import 'package:revanced_manager/models/patched_application.dart';
|
import 'package:revanced_manager/models/patched_application.dart';
|
||||||
@ -71,9 +73,14 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
List<String> getSupportedVersions(Patch patch) {
|
List<String> getSupportedVersions(Patch patch) {
|
||||||
PatchedApplication app = locator<PatcherViewModel>().selectedApp!;
|
PatchedApplication app = locator<PatcherViewModel>().selectedApp!;
|
||||||
return patch.compatiblePackages
|
Package? package = patch.compatiblePackages.firstWhereOrNull(
|
||||||
.firstWhere((pack) => pack.name == app.packageName)
|
(pack) => pack.name == app.packageName,
|
||||||
.versions;
|
);
|
||||||
|
if (package != null) {
|
||||||
|
return package.versions;
|
||||||
|
} else {
|
||||||
|
return List.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isPatchSupported(Patch patch) {
|
bool isPatchSupported(Patch patch) {
|
||||||
|
@ -7,6 +7,7 @@ import 'package:revanced_manager/models/patched_application.dart';
|
|||||||
import 'package:revanced_manager/services/manager_api.dart';
|
import 'package:revanced_manager/services/manager_api.dart';
|
||||||
import 'package:revanced_manager/services/patcher_api.dart';
|
import 'package:revanced_manager/services/patcher_api.dart';
|
||||||
import 'package:revanced_manager/services/root_api.dart';
|
import 'package:revanced_manager/services/root_api.dart';
|
||||||
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/views/navigation/navigation_viewmodel.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/views/patcher/patcher_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
||||||
@ -73,7 +74,7 @@ class AppInfoViewModel extends BaseViewModel {
|
|||||||
label: I18nText('okButton'),
|
label: I18nText('okButton'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
uninstallApp(app);
|
uninstallApp(app);
|
||||||
locator<NavigationViewModel>().notifyListeners();
|
locator<HomeViewModel>().notifyListeners();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
|
@ -30,7 +30,7 @@ class AppSkeletonLoader extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
height: 25,
|
height: 34,
|
||||||
width: screenWidth * 0.4,
|
width: screenWidth * 0.4,
|
||||||
child: SkeletonParagraph(
|
child: SkeletonParagraph(
|
||||||
style: const SkeletonParagraphStyle(
|
style: const SkeletonParagraphStyle(
|
||||||
@ -42,7 +42,7 @@ class AppSkeletonLoader extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(bottom: 4),
|
margin: const EdgeInsets.only(bottom: 4),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
height: 25,
|
height: 34,
|
||||||
width: screenWidth * 0.6,
|
width: screenWidth * 0.6,
|
||||||
child: SkeletonParagraph(
|
child: SkeletonParagraph(
|
||||||
style: const SkeletonParagraphStyle(
|
style: const SkeletonParagraphStyle(
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:github/github.dart';
|
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class ContributorsCard extends StatefulWidget {
|
class ContributorsCard extends StatefulWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final List<Contributor> contributors;
|
final List<dynamic> contributors;
|
||||||
final double height;
|
final double height;
|
||||||
|
|
||||||
const ContributorsCard({
|
const ContributorsCard({
|
||||||
@ -52,9 +51,9 @@ class _ContributorsCardState extends State<ContributorsCard> {
|
|||||||
borderRadius: BorderRadius.circular(100),
|
borderRadius: BorderRadius.circular(100),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => launchUrl(
|
onTap: () => launchUrl(
|
||||||
Uri.parse(widget.contributors[index].htmlUrl!)),
|
Uri.parse(widget.contributors[index]['html_url'])),
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
widget.contributors[index].avatarUrl!,
|
widget.contributors[index]['avatar_url'],
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 40,
|
width: 40,
|
||||||
),
|
),
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_i18n/flutter_i18n.dart';
|
import 'package:flutter_i18n/flutter_i18n.dart';
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/services/github_api.dart';
|
|
||||||
import 'package:revanced_manager/services/manager_api.dart';
|
|
||||||
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
import 'package:revanced_manager/ui/widgets/installerView/custom_material_button.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_card.dart';
|
||||||
@ -20,8 +18,7 @@ class LatestCommitCard extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LatestCommitCardState extends State<LatestCommitCard> {
|
class _LatestCommitCardState extends State<LatestCommitCard> {
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final HomeViewModel model = locator<HomeViewModel>();
|
||||||
final GithubAPI _githubAPI = GithubAPI();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -35,10 +32,8 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
I18nText('latestCommitCard.patcherLabel'),
|
I18nText('latestCommitCard.patcherLabel'),
|
||||||
FutureBuilder<String>(
|
FutureBuilder<String?>(
|
||||||
future: _githubAPI.latestCommitTime(
|
future: model.getLatestPatcherReleaseTime(),
|
||||||
_managerAPI.getPatcherRepo(),
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) => Text(
|
builder: (context, snapshot) => Text(
|
||||||
snapshot.hasData && snapshot.data!.isNotEmpty
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
||||||
? FlutterI18n.translate(
|
? FlutterI18n.translate(
|
||||||
@ -58,10 +53,8 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
I18nText('latestCommitCard.managerLabel'),
|
I18nText('latestCommitCard.managerLabel'),
|
||||||
FutureBuilder<String>(
|
FutureBuilder<String?>(
|
||||||
future: _githubAPI.latestCommitTime(
|
future: model.getLatestManagerReleaseTime(),
|
||||||
_managerAPI.getManagerRepo(),
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) =>
|
builder: (context, snapshot) =>
|
||||||
snapshot.hasData && snapshot.data!.isNotEmpty
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
||||||
? I18nText(
|
? I18nText(
|
||||||
|
@ -49,7 +49,7 @@ class ApplicationItem extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(format(patchDate, locale: 'en_short')),
|
Text(format(patchDate)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
@ -17,6 +17,8 @@ dependencies:
|
|||||||
url: https://github.com/ponces/flutter_plugin_device_apps
|
url: https://github.com/ponces/flutter_plugin_device_apps
|
||||||
ref: appinfo-from-storage
|
ref: appinfo-from-storage
|
||||||
device_info_plus: ^4.1.2
|
device_info_plus: ^4.1.2
|
||||||
|
dio: ^4.0.6
|
||||||
|
dio_http_cache_lts: ^0.4.1
|
||||||
dynamic_color: ^1.5.4
|
dynamic_color: ^1.5.4
|
||||||
dynamic_themes: ^1.1.0
|
dynamic_themes: ^1.1.0
|
||||||
expandable: ^5.0.1
|
expandable: ^5.0.1
|
||||||
@ -32,7 +34,6 @@ dependencies:
|
|||||||
fluttertoast: ^8.0.9
|
fluttertoast: ^8.0.9
|
||||||
font_awesome_flutter: ^10.1.0
|
font_awesome_flutter: ^10.1.0
|
||||||
get_it: ^7.2.0
|
get_it: ^7.2.0
|
||||||
github: ^9.4.0
|
|
||||||
google_fonts: ^3.0.1
|
google_fonts: ^3.0.1
|
||||||
http: ^0.13.4
|
http: ^0.13.4
|
||||||
injectable: ^1.5.3
|
injectable: ^1.5.3
|
||||||
@ -40,6 +41,7 @@ dependencies:
|
|||||||
json_annotation: ^4.6.0
|
json_annotation: ^4.6.0
|
||||||
package_info_plus: ^1.4.3+1
|
package_info_plus: ^1.4.3+1
|
||||||
path_provider: ^2.0.11
|
path_provider: ^2.0.11
|
||||||
|
pull_to_refresh: ^2.0.0
|
||||||
root: ^2.0.2
|
root: ^2.0.2
|
||||||
share_extend: ^2.0.0
|
share_extend: ^2.0.0
|
||||||
shared_preferences: ^2.0.15
|
shared_preferences: ^2.0.15
|
||||||
|
Loading…
Reference in New Issue
Block a user