Skip to content

Commit

Permalink
feat: change default repository
Browse files Browse the repository at this point in the history
  • Loading branch information
inotia00 committed Oct 20, 2023
1 parent 3aee2eb commit 04074e3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 59 deletions.
92 changes: 34 additions & 58 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,13 @@ class ManagerAPI {
String defaultApiUrl = 'https://api.revanced.app/';
String defaultRepoUrl = 'https://api.github.com';
String defaultPatcherRepo = 'revanced/revanced-patcher';
String defaultPatchesRepo = 'revanced/revanced-patches';
String defaultIntegrationsRepo = 'revanced/revanced-integrations';
String defaultPatchesRepo = 'inotia00/revanced-patches';
String defaultIntegrationsRepo = 'inotia00/revanced-integrations';
String defaultCliRepo = 'revanced/revanced-cli';
String defaultManagerRepo = 'revanced/revanced-manager';
String defaultManagerRepo = 'inotia00/revanced-manager';
String? patchesVersion = '';
String? integrationsVersion = '';

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

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

Future<void> initialize() async {
_prefs = await SharedPreferences.getInstance();
isRooted = await _rootAPI.isRooted();
Expand Down Expand Up @@ -404,75 +395,60 @@ class ManagerAPI {
}

Future<File?> downloadManager() async {
return await _revancedAPI.getLatestReleaseFile(
return await _githubAPI.getLatestReleaseFile(
'.apk',
defaultManagerRepo,
);
}

Future<String?> getLatestPatchesReleaseTime() async {
if (isDefaultPatchesRepo()) {
return await _revancedAPI.getLatestReleaseTime(
'.json',
defaultPatchesRepo,
);
final release =
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
if (release != null) {
final DateTime timestamp =
DateTime.parse(release['created_at'] as String);
return format(timestamp, locale: 'en_short');
} else {
final release =
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
if (release != null) {
final DateTime timestamp =
DateTime.parse(release['created_at'] as String);
return format(timestamp, locale: 'en_short');
} else {
return null;
}
return null;
}
}

Future<String?> getLatestManagerReleaseTime() async {
return await _revancedAPI.getLatestReleaseTime(
'.apk',
defaultManagerRepo,
);
final release =
await _githubAPI.getLatestManagerRelease(defaultManagerRepo);
if (release != null) {
final DateTime timestamp =
DateTime.parse(release['created_at'] as String);
return format(timestamp, locale: 'en_short');
} else {
return null;
}
}

Future<String?> getLatestManagerVersion() async {
return await _revancedAPI.getLatestReleaseVersion(
'.apk',
defaultManagerRepo,
);
final release = await _githubAPI.getLatestRelease(defaultManagerRepo);
if (release != null) {
return release['tag_name'];
} else {
return null;
}
}

Future<String?> getLatestIntegrationsVersion() async {
if (isDefaultIntegrationsRepo()) {
return await _revancedAPI.getLatestReleaseVersion(
'.apk',
defaultIntegrationsRepo,
);
final release = await _githubAPI.getLatestRelease(getIntegrationsRepo());
if (release != null) {
return release['tag_name'];
} else {
final release = await _githubAPI.getLatestRelease(getIntegrationsRepo());
if (release != null) {
return release['tag_name'];
} else {
return null;
}
return null;
}
}

Future<String?> getLatestPatchesVersion() async {
if (isDefaultPatchesRepo()) {
return await _revancedAPI.getLatestReleaseVersion(
'.json',
defaultPatchesRepo,
);
final release = await _githubAPI.getLatestRelease(getPatchesRepo());
if (release != null) {
return release['tag_name'];
} else {
final release =
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
if (release != null) {
return release['tag_name'];
} else {
return null;
}
return null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/home/home_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class HomeViewModel extends BaseViewModel {

Future<File?> downloadManager() async {
try {
final response = await _revancedAPI.downloadManager();
final response = await _managerAPI.downloadManager();
final bytes = await response!.readAsBytes();
final tempDir = await getTemporaryDirectory();
final tempFile = File('${tempDir.path}/revanced-manager.apk');
Expand Down

0 comments on commit 04074e3

Please sign in to comment.