Skip to content

Commit

Permalink
feat: Add manual connect process reset control
Browse files Browse the repository at this point in the history
  • Loading branch information
4o3F committed Dec 10, 2023
1 parent 8b3e05e commit 1fd42ec
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 1 deletion.
Binary file modified android/app/src/main/jniLibs/arm64-v8a/libnative.so
Binary file not shown.
Binary file modified android/app/src/main/jniLibs/armeabi-v7a/libnative.so
Binary file not shown.
Binary file modified android/app/src/main/jniLibs/x86/libnative.so
Binary file not shown.
Binary file modified android/app/src/main/jniLibs/x86_64/libnative.so
Binary file not shown.
1 change: 1 addition & 0 deletions assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"prepare_guide": "Open game after connect\nYou'll be notified on success",
"connect": "Connect!",
"in_progress": "Waiting...",
"reset": "Reset Process",
"root_connect": "Root Connect!"
},
"notification_title": "Ascent Connect",
Expand Down
1 change: 1 addition & 0 deletions assets/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"prepare_guide": "连接后请直接打开游戏\n成功获得链接后将在通知中提示",
"connect": "开始连接!",
"in_progress": "等待中...",
"reset": "重置状态",
"root_connect": "开始Root连接!"
},
"notification_title": "Ascent连接",
Expand Down
5 changes: 4 additions & 1 deletion lib/components/bottom_navigation_bar/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'package:ascent/routes.dart';
import 'package:bruno/bruno.dart';
import 'package:easy_localization/easy_localization.dart' as easy_localization;
import 'package:flutter/material.dart';
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import 'package:get/get.dart';


class BottomNavigationBarComponent extends StatelessWidget {
BottomNavigationBarComponent({Key? key}) : super(key: key);

Expand All @@ -17,6 +17,9 @@ class BottomNavigationBarComponent extends StatelessWidget {
currentIndex: Routes.route2index(GlobalState.currentRoute.value),
onTap: (index) {
GlobalState.currentRoute.value = Routes.index2route(index);
FlutterForegroundTask.isRunningService.then((value) => {
if (value) {FlutterForegroundTask.stopService()}
});
Get.toNamed(GlobalState.currentRoute.value);
},
fixedColor: Colors.blueAccent,
Expand Down
18 changes: 18 additions & 0 deletions lib/pages/connect/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:ascent/global_state.dart';
import 'package:bruno/bruno.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import 'package:get/get.dart';

import 'logic.dart';
Expand All @@ -26,11 +27,20 @@ class ConnectPage extends StatelessWidget {
await rootConnectForegroundTask.startRootConnectForegroundTask(logic);
}

Future<void> doResetProcess() async {
logic.inProgress.value = false;
logic.link.value = "";
await FlutterForegroundTask.stopService();
}

@override
Widget build(BuildContext context) {
GlobalState.platform.invokeMethod('getDeveloperOptionEnabled').then(
(value) =>
logic.developerOptionEnabled.value = (value.toString() == "true"));
FlutterForegroundTask.isRunningService.then((value) => {
if (!value) {logic.inProgress.value = false, logic.link.value = ""}
});
return Material(
child: Padding(
padding: const EdgeInsets.only(left: 20, right: 20),
Expand All @@ -56,6 +66,14 @@ class ConnectPage extends StatelessWidget {
},
),
const SizedBox(height: 20),
BrnBigMainButton(
title: tr('connect.guide.reset'),
bgColor: Colors.orangeAccent.withOpacity(0.8),
onTap: () {
doResetProcess();
},
),
const SizedBox(height: 20),
Visibility(
visible: GlobalState.rootEnabled.value,
child: BrnBigMainButton(
Expand Down

0 comments on commit 1fd42ec

Please sign in to comment.