Skip to content

Commit

Permalink
Keep up with updates
Browse files Browse the repository at this point in the history
  • Loading branch information
creeper-0910 committed Sep 19, 2022
1 parent 19ed771 commit 1f3fd55
Show file tree
Hide file tree
Showing 30 changed files with 745 additions and 625 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ For suggestions and bug reports, open an issue [here](https://github.com/revance
If you wish to discuss the Manager, a thread has been made under the [#chat](https://discord.com/channels/952946952348270622/1002922226443632761) channel in the Discord server, please note that this thread may be temporary and may be removed in the future.

## ⚠️ Disclaimer
*Please note that even though we're releasing the Manager, it is an ALPHA version. Meaning there's a big chance that the Manager might not work at all for you.*
*Please note that even though we're releasing the Manager, it is an ALPHA version. Meaning there's a big chance that the Manager might not work at all for you.*

## Prerequisites
1. Android 8 or higher.
2. For YouTube and YouTube Music - Vanced MicroG(Only for non-root).
22 changes: 15 additions & 7 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"cancelButton": "キャンセル",
"enabledLabel": "有効",
"disabledLabel": "無効",
"yesLabel": "はい",
"noLabel": "いいえ",
"yesButton": "はい",
"noButton": "いいえ",
"navigationView": {
"dashboardTab": "ダッシュボード",
"patcherTab": "パッチの適用",
Expand Down Expand Up @@ -66,11 +66,13 @@
"widgetSubtitle": "私たちはオンラインです!"
},
"appSelectorView": {
"searchBarHint": "アプリケーションの選択",
"viewTitle": "アプリケーションの選択",
"searchBarHint": "アプリケーションの検索",
"storageButton": "ストレージ",
"errorMessage": "選択したアプリケーションは使用できません。"
},
"patchesSelectorView": {
"viewTitle": "パッチの選択",
"searchBarHint": "パッチの検索",
"doneButton": "完了",
"noPatchesFound": "選択したアプリのパッチは見つかりませんでした。"
Expand All @@ -89,14 +91,19 @@
"notificationTitle": "ReVanced Managerはパッチを適用しています",
"notificationText": "タップするとインストーラーに戻ります",
"shareApkMenuOption": "APKを共有",
"shareLogMenuOption": "logを共有"
"shareLogMenuOption": "logを共有",
"installErrorDialogTitle": "エラー",
"installErrorDialogText1": "現在選択されているパッチでは、ルートインストールはできません。\nアプリを再パッチするか、非ルートインストールを選択してください。",
"installErrorDialogText2": "現在選択されているパッチでは、非ルートインストールはできません。\nアプリを再パッチするか、デバイスをルート化した後、ルートインストールを選択してください。",
"installErrorDialogText3": "ストレージからオリジナルAPKを選択したため、ルートインストールはできません。\nインストールされているアプリを選択するか、非ルートインストールを選択します。"
},
"settingsView": {
"widgetTitle": "設定",
"appearanceSectionTitle": "外観",
"patcherSectionTitle": "Patcher",
"teamSectionTitle": "チーム",
"infoSectionTitle": "情報",
"advancedSectionTitle": "高度な機能",
"darkThemeLabel": "ダークモード",
"darkThemeHint": "ダークサイドへようこそ",
"dynamicThemeLabel": "Material You",
Expand All @@ -113,10 +120,14 @@
"sourcesIntegrationsLabel": "Integrationsのソース",
"sourcesResetDialogTitle": "リセット",
"sourcesResetDialogText": "カスタム ソースをデフォルト値にリセットしてもよろしいですか?",
"apiURLResetDialogText": "APIのURLをデフォルト値にリセットしてもよろしいですか?",
"contributorsLabel": "貢献者",
"contributorsHint": "ReVancedへの貢献者一覧",
"logsLabel": "ログ",
"logsHint": "デバイスのデバッグログを共有",
"apiURLLabel": "API URL",
"apiURLHint": "カスタムAPI URLの設定",
"selectApiURL": "URLを選択",
"aboutLabel": "詳細",
"snackbarMessage": "クリップボードにコピーしました"
},
Expand All @@ -126,9 +137,6 @@
"uninstallButton": "アンインストール",
"patchButton": "適用",
"unpatchButton": "パッチ解除",
"uninstallDialogTitle": "アンインストール",
"uninstallDialogText": "選択したアプリケーションをアンインストールしますか?",
"unpatchDialogTitle": "パッチ解除",
"unpatchDialogText": "選択したアプリケーションに適用されているパッチを解除しますか?",
"rootDialogTitle": "エラー",
"rootDialogText": "アプリは端末がルート化された状態でインストールされましたが、現在はルート化が解除されているようです。\n再度、ルート化してから実行してください。",
Expand Down
5 changes: 3 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Future main() async {
await setupLocator();
WidgetsFlutterBinding.ensureInitialized();
await locator<ManagerAPI>().initialize();
await locator<PatcherAPI>().initialize();
locator<RevancedAPI>().initialize();
String apiUrl = locator<ManagerAPI>().getApiUrl();
await locator<RevancedAPI>().initialize(apiUrl);
locator<GithubAPI>().initialize();
await locator<PatcherAPI>().initialize();
runApp(const MyApp());
}

Expand Down
2 changes: 2 additions & 0 deletions lib/models/patched_application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PatchedApplication {
Uint8List icon;
DateTime patchDate;
bool isRooted;
bool isFromStorage;
bool hasUpdates;
List<String> appliedPatches;
List<String> changelog;
Expand All @@ -29,6 +30,7 @@ class PatchedApplication {
required this.icon,
required this.patchDate,
this.isRooted = false,
this.isFromStorage = false,
this.hasUpdates = false,
this.appliedPatches = const [],
this.changelog = const [],
Expand Down
7 changes: 3 additions & 4 deletions lib/services/github_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import 'package:revanced_manager/models/patch.dart';

@lazySingleton
class GithubAPI {
final String apiUrl = 'https://api.github.com';
final Dio _dio = Dio();
final Dio _dio = Dio(BaseOptions(baseUrl: 'https://api.github.com'));
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions(
const Duration(days: 1),
Expand All @@ -37,7 +36,7 @@ class GithubAPI {
Future<Map<String, dynamic>?> _getLatestRelease(String repoName) async {
try {
var response = await _dio.get(
'$apiUrl/repos/$repoName/releases/latest',
'/repos/$repoName/releases/latest',
options: _cacheOptions,
);
return response.data;
Expand All @@ -55,7 +54,7 @@ class GithubAPI {
'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}';
try {
var response = await _dio.get(
'$apiUrl/repos/$repoName/commits',
'/repos/$repoName/commits',
queryParameters: {
'path': path,
'per_page': 3,
Expand Down
19 changes: 17 additions & 2 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ManagerAPI {
final String patcherRepo = 'revanced-patcher';
final String cliRepo = 'revanced-cli';
late SharedPreferences _prefs;
String defaultApiUrl = 'https://revanced-releases-api.afterst0rm.xyz';
String defaultPatcherRepo = 'revanced/revanced-patcher';
String defaultPatchesRepo = 'revanced/revanced-patches';
String defaultIntegrationsRepo = 'revanced/revanced-integrations';
Expand All @@ -29,6 +30,19 @@ class ManagerAPI {
_prefs = await SharedPreferences.getInstance();
}

String getApiUrl() {
return _prefs.getString('apiUrl') ?? defaultApiUrl;
}

Future<void> setApiUrl(String url) async {
if (url.isEmpty || url == ' ') {
url = defaultApiUrl;
}
await _revancedAPI.initialize(url);
await _revancedAPI.clearAllCache();
await _prefs.setString('apiUrl', url);
}

String getPatchesRepo() {
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
}
Expand Down Expand Up @@ -110,10 +124,11 @@ class ManagerAPI {
}

Future<List<Patch>> getPatches() async {
if (getPatchesRepo() == defaultPatchesRepo) {
String repoName = getPatchesRepo();
if (repoName == defaultPatchesRepo) {
return await _revancedAPI.getPatches();
} else {
return await _githubAPI.getPatches(getPatchesRepo());
return await _githubAPI.getPatches(repoName);
}
}

Expand Down
7 changes: 3 additions & 4 deletions lib/services/patcher_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,9 @@ class PatcherAPI {
String prefix = appName.toLowerCase().replaceAll(' ', '-');
String newName = '$prefix-revanced_v$version.apk';
int lastSeparator = _outFile!.path.lastIndexOf('/');
File share = _outFile!.renameSync(
_outFile!.path.substring(0, lastSeparator + 1) + newName,
);
ShareExtend.share(share.path, 'file');
String newPath = _outFile!.path.substring(0, lastSeparator + 1) + newName;
File shareFile = _outFile!.copySync(newPath);
ShareExtend.share(shareFile.path, 'file');
}
}

Expand Down
25 changes: 13 additions & 12 deletions lib/services/revanced_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import 'package:timeago/timeago.dart';

@lazySingleton
class RevancedAPI {
final String apiUrl = 'https://revanced-releases-api.afterst0rm.xyz';
final Dio _dio = Dio();
late Dio _dio = Dio();
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions(
const Duration(days: 1),
maxStale: const Duration(days: 7),
);

void initialize() {
Future<void> initialize(String apiUrl) async {
_dio = Dio(BaseOptions(baseUrl: apiUrl));
_dio.interceptors.add(_dioCacheManager.interceptor);
}

Expand All @@ -28,10 +28,7 @@ class RevancedAPI {
Future<Map<String, List<dynamic>>> getContributors() async {
Map<String, List<dynamic>> contributors = {};
try {
var response = await _dio.get(
'$apiUrl/contributors',
options: _cacheOptions,
);
var response = await _dio.get('/contributors', options: _cacheOptions);
List<dynamic> repositories = response.data['repositories'];
for (Map<String, dynamic> repo in repositories) {
String name = repo['name'];
Expand All @@ -45,7 +42,7 @@ class RevancedAPI {

Future<List<Patch>> getPatches() async {
try {
var response = await _dio.get('$apiUrl/patches', options: _cacheOptions);
var response = await _dio.get('/patches', options: _cacheOptions);
List<dynamic> patches = response.data;
return patches.map((patch) => Patch.fromJson(patch)).toList();
} on Exception {
Expand All @@ -58,7 +55,7 @@ class RevancedAPI {
String repoName,
) async {
try {
var response = await _dio.get('$apiUrl/tools', options: _cacheOptions);
var response = await _dio.get('/tools', options: _cacheOptions);
List<dynamic> tools = response.data['tools'];
return tools.firstWhereOrNull(
(t) =>
Expand All @@ -71,10 +68,14 @@ class RevancedAPI {
}

Future<String?> getLatestReleaseVersion(
String extension, String repoName) async {
String extension,
String repoName,
) async {
try {
Map<String, dynamic>? release =
await _getLatestRelease(extension, repoName);
Map<String, dynamic>? release = await _getLatestRelease(
extension,
repoName,
);
if (release != null) {
return release['version'];
}
Expand Down
97 changes: 53 additions & 44 deletions lib/ui/views/app_selector/app_selector_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,53 +31,62 @@ class _AppSelectorViewState extends State<AppSelectorView> {
Navigator.of(context).pop();
},
),
body: SafeArea(
child: Padding(
padding:
const EdgeInsets.symmetric(vertical: 4.0, horizontal: 12.0),
child: Column(
children: <Widget>[
SearchBar(
showSelectIcon: false,
hintText: FlutterI18n.translate(
context,
'appSelectorView.searchBarHint',
body: CustomScrollView(
slivers: [
SliverAppBar(
pinned: true,
floating: true,
snap: false,
title: I18nText('appSelectorView.viewTitle'),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(64.0),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0, horizontal: 12.0),
child: SearchBar(
showSelectIcon: false,
hintText: FlutterI18n.translate(
context,
'appSelectorView.searchBarHint',
),
onQueryChanged: (searchQuery) {
setState(() {
_query = searchQuery;
});
},
),
onQueryChanged: (searchQuery) {
setState(() {
_query = searchQuery;
});
},
),
const SizedBox(height: 12),
Expanded(
child: model.noApps
? Center(
child: I18nText('appSelectorCard.noAppsLabel'),
)
: model.apps.isEmpty
? const AppSkeletonLoader()
: ListView(
padding: const EdgeInsets.only(bottom: 80),
children: model
.getFilteredApps(_query)
.map((app) => InkWell(
onTap: () {
model.selectApp(app);
Navigator.of(context).pop();
},
child: InstalledAppItem(
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
),
))
.toList(),
),
),
],
),
),
SliverToBoxAdapter(
child: model.noApps
? Center(
child: I18nText('appSelectorCard.noAppsLabel'),
)
: model.apps.isEmpty
? const AppSkeletonLoader()
: Padding(
padding: const EdgeInsets.only(bottom: 80).add(
const EdgeInsets.symmetric(horizontal: 12.0)),
child: Column(
children: model
.getFilteredApps(_query)
.map((app) => InkWell(
onTap: () {
model.selectApp(app);
Navigator.of(context).pop();
},
child: InstalledAppItem(
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
),
))
.toList(),
),
),
),
),
],
),
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/ui/views/app_selector/app_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class AppSelectorViewModel extends BaseViewModel {
apkFilePath: result.files.single.path!,
icon: application.icon,
patchDate: DateTime.now(),
isFromStorage: true,
);
locator<PatcherViewModel>().selectedPatches.clear();
locator<PatcherViewModel>().notifyListeners();
Expand Down
Loading

0 comments on commit 1f3fd55

Please sign in to comment.