pikapika/lib/basic/config/AndroidSecureFlag.dart

54 lines
1.4 KiB
Dart
Raw Normal View History

2021-10-29 03:38:36 +00:00
/// 音量键翻页
import 'dart:io';
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
const propertyName = "androidSecureFlag";
late bool androidSecureFlag;
Future<void> initAndroidSecureFlag() async {
if (Platform.isAndroid) {
androidSecureFlag =
(await method.loadProperty(propertyName, "false")) == "true";
if (androidSecureFlag) {
await method.androidSecureFlag(true);
}
}
}
String androidSecureFlagName() {
return androidSecureFlag ? "" : "";
}
Future<void> chooseAndroidSecureFlag(BuildContext context) async {
String? result =
await chooseListDialog<String>(context, "禁止截图/禁止显示在任务视图", ["", ""]);
if (result != null) {
var target = result == "";
await method.saveProperty(propertyName, "$target");
androidSecureFlag = target;
await method.androidSecureFlag(androidSecureFlag);
}
}
Widget androidSecureFlagSetting() {
if (Platform.isAndroid) {
return StatefulBuilder(builder:
(BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: Text("禁止截图/禁止显示在任务视图(仅安卓)"),
subtitle: Text(androidSecureFlagName()),
onTap: () async {
await chooseAndroidSecureFlag(context);
setState(() {});
});
});
}
return Container();
}