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 20, 2022
1 parent 1f3fd55 commit dc7d984
Show file tree
Hide file tree
Showing 28 changed files with 584 additions and 490 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ If you wish to discuss the Manager, a thread has been made under the [#chat](htt

## Prerequisites
1. Android 8 or higher.
2. For YouTube and YouTube Music - Vanced MicroG(Only for non-root).
2. Does not work on armv7
3. For YouTube and YouTube Music - Vanced MicroG(Only for non-root).
6 changes: 3 additions & 3 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"patchItem": {
"unsupportedWarningButton": "サポートされていないバージョン",
"unsupportedDialogTitle": "警告",
"unsupportedDialogText": "このパッチは、適用時にエラーが発生する場合があります\n\nアプリバージョン: {packageVersion}\n現在サポートされているバージョン:\n{supportedVersions}"
"unsupportedDialogText": "このパッチを選択すると、パッチの適用に失敗することがあります\n\nアプリバージョン: {packageVersion}\n現在サポートされているバージョン:\n{supportedVersions}"
},
"installerView": {
"widgetTitle": "インストーラー",
Expand All @@ -95,12 +95,12 @@
"installErrorDialogTitle": "エラー",
"installErrorDialogText1": "現在選択されているパッチでは、ルートインストールはできません。\nアプリを再パッチするか、非ルートインストールを選択してください。",
"installErrorDialogText2": "現在選択されているパッチでは、非ルートインストールはできません。\nアプリを再パッチするか、デバイスをルート化した後、ルートインストールを選択してください。",
"installErrorDialogText3": "ストレージからオリジナルAPKを選択したため、ルートインストールはできません。\nインストールされているアプリを選択するか、非ルートインストールを選択します。"
"installErrorDialogText3": "ストレージからオリジナルAPKを選択したため、ルートインストールはできません。\nインストールされているアプリを選択するか、非ルートインストールを選択します。",
"noExit": "インストーラーが実行中です..."
},
"settingsView": {
"widgetTitle": "設定",
"appearanceSectionTitle": "外観",
"patcherSectionTitle": "Patcher",
"teamSectionTitle": "チーム",
"infoSectionTitle": "情報",
"advancedSectionTitle": "高度な機能",
Expand Down
2 changes: 2 additions & 0 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/app_selector/app_selector_view.dart';
import 'package:revanced_manager/ui/views/contributors/contributors_view.dart';
import 'package:revanced_manager/ui/views/home/home_viewmodel.dart';
Expand Down Expand Up @@ -36,6 +37,7 @@ import 'package:stacked_services/stacked_services.dart';
LazySingleton(classType: PatcherAPI),
LazySingleton(classType: RevancedAPI),
LazySingleton(classType: GithubAPI),
LazySingleton(classType: Toast),
],
)
class AppSetup {}
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/ui/theme/dynamic_theme_builder.dart';
import 'package:revanced_manager/ui/views/navigation/navigation_view.dart';
import 'package:stacked_themes/stacked_themes.dart';
import 'package:timezone/data/latest.dart' as tz;

Future main() async {
await ThemeManager.initialise();
Expand All @@ -19,6 +20,7 @@ Future main() async {
await locator<RevancedAPI>().initialize(apiUrl);
locator<GithubAPI>().initialize();
await locator<PatcherAPI>().initialize();
tz.initializeTimeZones();
runApp(const MyApp());
}

Expand Down
20 changes: 12 additions & 8 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ class ManagerAPI {
Future<void> savePatchedApp(PatchedApplication app) async {
List<PatchedApplication> patchedApps = getPatchedApps();
patchedApps.removeWhere((a) => a.packageName == app.packageName);
ApplicationWithIcon? installed =
await DeviceApps.getApp(app.packageName, true) as ApplicationWithIcon?;
ApplicationWithIcon? installed = await DeviceApps.getApp(
app.packageName,
true,
) as ApplicationWithIcon?;
if (installed != null) {
app.name = installed.appName;
app.version = installed.versionName!;
Expand Down Expand Up @@ -202,9 +204,10 @@ class ManagerAPI {
List<String> installedApps = await _rootAPI.getInstalledApps();
for (String packageName in installedApps) {
if (!patchedApps.any((app) => app.packageName == packageName)) {
ApplicationWithIcon? application =
await DeviceApps.getApp(packageName, true)
as ApplicationWithIcon?;
ApplicationWithIcon? application = await DeviceApps.getApp(
packageName,
true,
) as ApplicationWithIcon?;
if (application != null) {
unsavedApps.add(
PatchedApplication(
Expand All @@ -229,9 +232,10 @@ class ManagerAPI {
if (app.packageName.startsWith('app.revanced') &&
!app.packageName.startsWith('app.revanced.manager.') &&
!patchedApps.any((uapp) => uapp.packageName == app.packageName)) {
ApplicationWithIcon? application =
await DeviceApps.getApp(app.packageName, true)
as ApplicationWithIcon?;
ApplicationWithIcon? application = await DeviceApps.getApp(
app.packageName,
true,
) as ApplicationWithIcon?;
if (application != null) {
unsavedApps.add(
PatchedApplication(
Expand Down
7 changes: 4 additions & 3 deletions lib/services/patcher_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ class PatcherAPI {
for (Package package in patch.compatiblePackages) {
try {
if (!filteredApps.any((app) => app.packageName == package.name)) {
ApplicationWithIcon? app =
await DeviceApps.getApp(package.name, true)
as ApplicationWithIcon?;
ApplicationWithIcon? app = await DeviceApps.getApp(
package.name,
true,
) as ApplicationWithIcon?;
if (app != null) {
filteredApps.add(app);
}
Expand Down
23 changes: 23 additions & 0 deletions lib/services/toast.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:fluttertoast/fluttertoast.dart' as t;

class Toast {
final t.FToast _fToast = t.FToast();
late BuildContext buildContext;

void initialize(BuildContext context) {
_fToast.init(context);
}

void show(String text) {
t.Fluttertoast.showToast(
msg: FlutterI18n.translate(
_fToast.context!,
text,
),
toastLength: t.Toast.LENGTH_LONG,
gravity: t.ToastGravity.CENTER,
);
}
}
35 changes: 25 additions & 10 deletions lib/ui/views/app_selector/app_selector_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,29 @@ class _AppSelectorViewState extends State<AppSelectorView> {
pinned: true,
floating: true,
snap: false,
title: I18nText('appSelectorView.viewTitle'),
title: I18nText(
'appSelectorView.viewTitle',
child: Text(
'',
style: TextStyle(
color: Theme.of(context).textTheme.headline6!.color,
),
),
),
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: Theme.of(context).textTheme.headline6!.color,
),
onPressed: () => Navigator.of(context).pop(),
),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(64.0),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0, horizontal: 12.0),
vertical: 8.0,
horizontal: 12.0,
),
child: SearchBar(
showSelectIcon: false,
hintText: FlutterI18n.translate(
Expand All @@ -66,21 +83,19 @@ class _AppSelectorViewState extends State<AppSelectorView> {
: model.apps.isEmpty
? const AppSkeletonLoader()
: Padding(
padding: const EdgeInsets.only(bottom: 80).add(
const EdgeInsets.symmetric(horizontal: 12.0)),
padding: const EdgeInsets.symmetric(horizontal: 12.0)
.copyWith(bottom: 80),
child: Column(
children: model
.getFilteredApps(_query)
.map((app) => InkWell(
.map((app) => InstalledAppItem(
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
onTap: () {
model.selectApp(app);
Navigator.of(context).pop();
},
child: InstalledAppItem(
name: app.appName,
pkgName: app.packageName,
icon: app.icon,
),
))
.toList(),
),
Expand Down
20 changes: 7 additions & 13 deletions lib/ui/views/app_selector/app_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import 'dart:io';
import 'package:device_apps/device_apps.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:revanced_manager/app/app.locator.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/patcher_api.dart';
import 'package:revanced_manager/services/toast.dart';
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
import 'package:stacked/stacked.dart';

class AppSelectorViewModel extends BaseViewModel {
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
final Toast _toast = locator<Toast>();
final List<ApplicationWithIcon> apps = [];
bool noApps = false;

Expand Down Expand Up @@ -43,9 +43,10 @@ class AppSelectorViewModel extends BaseViewModel {
);
if (result != null && result.files.single.path != null) {
File apkFile = File(result.files.single.path!);
ApplicationWithIcon? application =
await DeviceApps.getAppFromStorage(apkFile.path, true)
as ApplicationWithIcon?;
ApplicationWithIcon? application = await DeviceApps.getAppFromStorage(
apkFile.path,
true,
) as ApplicationWithIcon?;
if (application != null) {
locator<PatcherViewModel>().selectedApp = PatchedApplication(
name: application.appName,
Expand All @@ -61,14 +62,7 @@ class AppSelectorViewModel extends BaseViewModel {
}
}
} on Exception {
Fluttertoast.showToast(
msg: FlutterI18n.translate(
context,
'appSelectorView.errorMessage',
),
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.CENTER,
);
_toast.show('appSelectorView.errorMessage');
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/ui/views/home/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class HomeView extends StatelessWidget {
child: CustomScrollView(
slivers: <Widget>[
CustomSliverAppBar(
isMainView: true,
title: I18nText(
'homeView.widgetTitle',
child: Text(
Expand Down
Loading

0 comments on commit dc7d984

Please sign in to comment.