mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-05-08 17:34:25 +02:00
feat: fix list contributors and add patched apps changelog (wip)
This commit is contained in:
parent
bfbcb510c4
commit
45f4a5b207
@ -56,13 +56,14 @@ class GithubAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Contributor>> getContributors(String org, repoName) async {
|
Future<List<Contributor>> getContributors(String org, repoName) async {
|
||||||
try {
|
return await (_github.repositories.listContributors(
|
||||||
var contributors = _github.repositories.listContributors(
|
|
||||||
RepositorySlug(org, repoName),
|
RepositorySlug(org, repoName),
|
||||||
);
|
)).toList();
|
||||||
return contributors.toList();
|
|
||||||
} on Exception {
|
|
||||||
return List.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<RepositoryCommit>> getCommits(String org, repoName) async {
|
||||||
|
return await (_github.repositories.listCommits(
|
||||||
|
RepositorySlug(org, repoName),
|
||||||
|
)).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ class ManagerAPI {
|
|||||||
Future<void> reAssessSavedApps() async {
|
Future<void> reAssessSavedApps() async {
|
||||||
List<PatchedApplication> patchedApps = getPatchedApps();
|
List<PatchedApplication> patchedApps = getPatchedApps();
|
||||||
bool isRoot = isRooted() ?? false;
|
bool isRoot = isRooted() ?? false;
|
||||||
|
List<PatchedApplication> toRemove = [];
|
||||||
for (PatchedApplication app in patchedApps) {
|
for (PatchedApplication app in patchedApps) {
|
||||||
bool existsRoot = false;
|
bool existsRoot = false;
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
@ -101,23 +102,23 @@ class ManagerAPI {
|
|||||||
}
|
}
|
||||||
bool existsNonRoot = await DeviceApps.isAppInstalled(app.packageName);
|
bool existsNonRoot = await DeviceApps.isAppInstalled(app.packageName);
|
||||||
if (!existsRoot && !existsNonRoot) {
|
if (!existsRoot && !existsNonRoot) {
|
||||||
patchedApps.remove(app);
|
toRemove.add(app);
|
||||||
} else if (existsNonRoot) {
|
} else if (existsNonRoot) {
|
||||||
ApplicationWithIcon? application =
|
ApplicationWithIcon? application =
|
||||||
await DeviceApps.getApp(app.packageName, true)
|
await DeviceApps.getApp(app.packageName, true)
|
||||||
as ApplicationWithIcon?;
|
as ApplicationWithIcon?;
|
||||||
if (application != null) {
|
if (application != null) {
|
||||||
int savedVersionInt =
|
int savedVersionInt =
|
||||||
int.parse(app.version.replaceFirst('v', '').replaceAll('.', ''));
|
int.parse(app.version.replaceAll(RegExp('[^0-9]'), ''));
|
||||||
int currentVersionInt = int.parse(application.versionName!
|
int currentVersionInt = int.parse(
|
||||||
.replaceFirst('v', '')
|
application.versionName!.replaceAll(RegExp('[^0-9]'), ''));
|
||||||
.replaceAll('.', ''));
|
|
||||||
if (savedVersionInt < currentVersionInt) {
|
if (savedVersionInt < currentVersionInt) {
|
||||||
patchedApps.remove(app);
|
toRemove.add(app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
patchedApps.removeWhere((a) => toRemove.contains(a));
|
||||||
setPatchedApps(patchedApps);
|
setPatchedApps(patchedApps);
|
||||||
List<String> apps = await _rootAPI.getInstalledApps();
|
List<String> apps = await _rootAPI.getInstalledApps();
|
||||||
for (String packageName in apps) {
|
for (String packageName in apps) {
|
||||||
@ -136,8 +137,19 @@ class ManagerAPI {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getAppChangelog(String packageName) async {
|
Future<List<String>> getAppChangelog(
|
||||||
// TODO: get changelog based on last commits on the folder of this app?
|
String packageName,
|
||||||
return 'To be implemented';
|
DateTime lastUpdated,
|
||||||
|
) async {
|
||||||
|
return (await _githubAPI.getCommits(ghOrg, patchesRepo))
|
||||||
|
.where((c) =>
|
||||||
|
c.commit != null &&
|
||||||
|
c.commit!.message != null &&
|
||||||
|
!c.commit!.message!.startsWith('chore') &&
|
||||||
|
c.commit!.author != null &&
|
||||||
|
c.commit!.author!.date != null)
|
||||||
|
.map((c) => ' - ${c.commit!.message!}')
|
||||||
|
.toList()
|
||||||
|
.sublist(0, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,15 @@ class RootAPI {
|
|||||||
);
|
);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
List<String> apps = res.split('\n');
|
List<String> apps = res.split('\n');
|
||||||
|
List<String> toRemove = [];
|
||||||
for (String packageName in apps) {
|
for (String packageName in apps) {
|
||||||
bool isInstalled = await isAppInstalled(packageName);
|
bool isInstalled = await isAppInstalled(packageName);
|
||||||
if (!isInstalled) {
|
if (!isInstalled) {
|
||||||
apps.remove(packageName);
|
toRemove.add(packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
apps.removeWhere((a) => toRemove.contains(a));
|
||||||
|
return apps;
|
||||||
}
|
}
|
||||||
} on Exception {
|
} on Exception {
|
||||||
return List.empty();
|
return List.empty();
|
||||||
|
@ -32,5 +32,6 @@ class ContributorsViewModel extends BaseViewModel {
|
|||||||
ghOrg,
|
ghOrg,
|
||||||
managerRepo,
|
managerRepo,
|
||||||
);
|
);
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,9 @@ class HomeViewModel extends BaseViewModel {
|
|||||||
if (latestVersion != null) {
|
if (latestVersion != null) {
|
||||||
try {
|
try {
|
||||||
int latestVersionInt =
|
int latestVersionInt =
|
||||||
int.parse(latestVersion.replaceFirst('v', '').replaceAll('.', ''));
|
int.parse(latestVersion.replaceAll(RegExp('[^0-9]'), ''));
|
||||||
int currentVersionInt =
|
int currentVersionInt =
|
||||||
int.parse(currentVersion.replaceFirst('v', '').replaceAll('.', ''));
|
int.parse(currentVersion.replaceAll(RegExp('[^0-9]'), ''));
|
||||||
return latestVersionInt > currentVersionInt;
|
return latestVersionInt > currentVersionInt;
|
||||||
} on Exception {
|
} on Exception {
|
||||||
return false;
|
return false;
|
||||||
|
@ -20,23 +20,24 @@ class AvailableUpdatesCard extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
FutureBuilder<List<PatchedApplication>>(
|
FutureBuilder<List<PatchedApplication>>(
|
||||||
future: locator<HomeViewModel>().getPatchedApps(true),
|
future: locator<HomeViewModel>().getPatchedApps(true),
|
||||||
builder: (context, snapshot) =>
|
builder: (context, snapshot) => snapshot.hasData &&
|
||||||
snapshot.hasData && snapshot.data!.isNotEmpty
|
snapshot.data!.isNotEmpty
|
||||||
? ListView.builder(
|
? ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
itemCount: snapshot.data!.length,
|
itemCount: snapshot.data!.length,
|
||||||
itemBuilder: (context, index) => FutureBuilder<String>(
|
itemBuilder: (context, index) => FutureBuilder<List<String>>(
|
||||||
future: _managerAPI.getAppChangelog(
|
future: _managerAPI.getAppChangelog(
|
||||||
snapshot.data![index].packageName,
|
snapshot.data![index].packageName,
|
||||||
|
snapshot.data![index].patchDate,
|
||||||
),
|
),
|
||||||
initialData: '',
|
initialData: List.empty(),
|
||||||
builder: (context, snapshot2) => ApplicationItem(
|
builder: (context, snapshot2) => ApplicationItem(
|
||||||
icon: snapshot.data![index].icon,
|
icon: snapshot.data![index].icon,
|
||||||
name: snapshot.data![index].name,
|
name: snapshot.data![index].name,
|
||||||
patchDate: snapshot.data![index].patchDate,
|
patchDate: snapshot.data![index].patchDate,
|
||||||
changelog: snapshot2.data!,
|
changelog: '${snapshot2.data!.join('\n')}\n...',
|
||||||
isUpdatableApp: true,
|
isUpdatableApp: true,
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
locator<HomeViewModel>().navigateToPatcher(
|
locator<HomeViewModel>().navigateToPatcher(
|
||||||
|
@ -21,23 +21,24 @@ class InstalledAppsCard extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
FutureBuilder<List<PatchedApplication>>(
|
FutureBuilder<List<PatchedApplication>>(
|
||||||
future: locator<HomeViewModel>().getPatchedApps(false),
|
future: locator<HomeViewModel>().getPatchedApps(false),
|
||||||
builder: (context, snapshot) =>
|
builder: (context, snapshot) => snapshot.hasData &&
|
||||||
snapshot.hasData && snapshot.data!.isNotEmpty
|
snapshot.data!.isNotEmpty
|
||||||
? ListView.builder(
|
? ListView.builder(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
itemCount: snapshot.data!.length,
|
itemCount: snapshot.data!.length,
|
||||||
itemBuilder: (context, index) => FutureBuilder<String>(
|
itemBuilder: (context, index) => FutureBuilder<List<String>>(
|
||||||
future: _managerAPI.getAppChangelog(
|
future: _managerAPI.getAppChangelog(
|
||||||
snapshot.data![index].packageName,
|
snapshot.data![index].packageName,
|
||||||
|
snapshot.data![index].patchDate,
|
||||||
),
|
),
|
||||||
initialData: '',
|
initialData: const ['Loading'],
|
||||||
builder: (context, snapshot2) => ApplicationItem(
|
builder: (context, snapshot2) => ApplicationItem(
|
||||||
icon: snapshot.data![index].icon,
|
icon: snapshot.data![index].icon,
|
||||||
name: snapshot.data![index].name,
|
name: snapshot.data![index].name,
|
||||||
patchDate: snapshot.data![index].patchDate,
|
patchDate: snapshot.data![index].patchDate,
|
||||||
changelog: snapshot2.data!,
|
changelog: '${snapshot2.data!.join('\n')}\n(...)',
|
||||||
isUpdatableApp: false,
|
isUpdatableApp: false,
|
||||||
onPressed: () => DeviceApps.openApp(
|
onPressed: () => DeviceApps.openApp(
|
||||||
snapshot.data![index].packageName,
|
snapshot.data![index].packageName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user