fix: disabled android service related (#670)

Fixes #662
This commit is contained in:
lollipopkit🏳️‍⚧️
2025-01-07 20:36:12 +08:00
committed by GitHub
parent 7f58237589
commit e7a5f43cc4
3 changed files with 49 additions and 43 deletions

View File

@@ -1,6 +1,5 @@
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:server_box/data/res/misc.dart'; import 'package:server_box/data/res/misc.dart';
import 'package:server_box/data/res/store.dart';
abstract final class MethodChans { abstract final class MethodChans {
static const _channel = MethodChannel('${Miscs.pkgName}/main_chan'); static const _channel = MethodChannel('${Miscs.pkgName}/main_chan');
@@ -9,14 +8,16 @@ abstract final class MethodChans {
_channel.invokeMethod('sendToBackground'); _channel.invokeMethod('sendToBackground');
} }
/// Issue #662
static void startService() { static void startService() {
if (Stores.setting.fgService.fetch() != true) return; // if (Stores.setting.fgService.fetch() != true) return;
_channel.invokeMethod('startService'); // _channel.invokeMethod('startService');
} }
/// Issue #662
static void stopService() { static void stopService() {
if (Stores.setting.fgService.fetch() != true) return; // if (Stores.setting.fgService.fetch() != true) return;
_channel.invokeMethod('stopService'); // _channel.invokeMethod('stopService');
} }
static void updateHomeWidget() async { static void updateHomeWidget() async {

View File

@@ -80,36 +80,7 @@ class _EditorPageState extends State<EditorPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_init();
/// Higher priority than [path]
if (Stores.setting.editorHighlight.fetch()) {
_langCode =
widget.args?.langCode ?? Highlights.getCode(widget.args?.path);
}
_controller = CodeController(
language: Highlights.all[_langCode],
);
if (_langCode == null) {
_setupCtrl();
} else {
Future.delayed(const Duration(milliseconds: 377)).then(
(value) async => await _setupCtrl(),
);
}
}
Future<void> _setupCtrl() async {
final path = widget.args?.path;
final text = widget.args?.text;
if (path != null) {
final code = await Computer.shared.startNoParam(
() => File(path).readAsString(),
);
_controller.text = code;
} else if (text != null) {
_controller.text = text;
}
} }
@override @override
@@ -206,3 +177,37 @@ class _EditorPageState extends State<EditorPage> {
)); ));
} }
} }
extension on _EditorPageState {
Future<void> _init() async {
/// Higher priority than [path]
if (Stores.setting.editorHighlight.fetch()) {
_langCode =
widget.args?.langCode ?? Highlights.getCode(widget.args?.path);
}
_controller = CodeController(
language: Highlights.all[_langCode],
);
if (_langCode == null) {
_setupCtrl();
} else {
Future.delayed(const Duration(milliseconds: 377)).then(
(value) async => await _setupCtrl(),
);
}
}
Future<void> _setupCtrl() async {
final path = widget.args?.path;
final text = widget.args?.text;
if (path != null) {
final code = await Computer.shared.startNoParam(
() => File(path).readAsString(),
);
_controller.text = code;
} else if (text != null) {
_controller.text = text;
}
}
}

View File

@@ -21,7 +21,7 @@ class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
body: ListView( body: ListView(
padding: const EdgeInsets.symmetric(horizontal: 17), padding: const EdgeInsets.symmetric(horizontal: 17),
children: [ children: [
_buildFgService(), // _buildFgService(),
_buildBgRun(), _buildBgRun(),
_buildAndroidWidgetSharedPreference(), _buildAndroidWidgetSharedPreference(),
if (BioAuth.isPlatformSupported) if (BioAuth.isPlatformSupported)
@@ -31,6 +31,13 @@ class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
); );
} }
// Widget _buildFgService() {
// return ListTile(
// title: TipText(l10n.fgService, l10n.fgServiceTip),
// trailing: StoreSwitch(prop: Stores.setting.fgService),
// );
// }
Widget _buildBgRun() { Widget _buildBgRun() {
return ListTile( return ListTile(
title: TipText(l10n.bgRun, l10n.bgRunTip), title: TipText(l10n.bgRun, l10n.bgRunTip),
@@ -116,11 +123,4 @@ class _AndroidSettingsPageState extends State<AndroidSettingsPage> {
// }, // },
// ); // );
// } // }
Widget _buildFgService() {
return ListTile(
title: TipText(l10n.fgService, l10n.fgServiceTip),
trailing: StoreSwitch(prop: Stores.setting.fgService),
);
}
} }