android secure flag
This commit is contained in:
parent
7cebc1d90c
commit
6bf01d7a7b
|
@ -11,6 +11,7 @@ import android.provider.MediaStore
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Display
|
import android.view.Display
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
import android.view.WindowManager
|
||||||
import androidx.annotation.NonNull
|
import androidx.annotation.NonNull
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
@ -98,6 +99,7 @@ class MainActivity : FlutterActivity() {
|
||||||
"migrate" -> androidMigrate(call.argument("path")!!)
|
"migrate" -> androidMigrate(call.argument("path")!!)
|
||||||
// 获取可以迁移数据地址
|
// 获取可以迁移数据地址
|
||||||
"androidGetExtendDirs" -> androidGetExtendDirs()
|
"androidGetExtendDirs" -> androidGetExtendDirs()
|
||||||
|
"androidSecureFlag" -> androidSecureFlag(call.argument("flag")!!)
|
||||||
else -> {
|
else -> {
|
||||||
notImplementedToken
|
notImplementedToken
|
||||||
}
|
}
|
||||||
|
@ -338,4 +340,14 @@ class MainActivity : FlutterActivity() {
|
||||||
return super.onKeyDown(keyCode, event)
|
return super.onKeyDown(keyCode, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun androidSecureFlag(flag: Boolean) {
|
||||||
|
uiThreadHandler.post {
|
||||||
|
if (flag) {
|
||||||
|
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
|
||||||
|
} else {
|
||||||
|
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Fri Jun 23 08:50:38 CEST 2017
|
#Fri Oct 29 09:53:43 CST 2021
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
@ -581,4 +581,11 @@ class Method {
|
||||||
Future saveDownloadAndExportPath(String folder) {
|
Future saveDownloadAndExportPath(String folder) {
|
||||||
return _flatInvoke("saveDownloadAndExportPath", folder);
|
return _flatInvoke("saveDownloadAndExportPath", folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 切换安全策略 (安卓禁止截图, 录屏, 不显示在任务视图)
|
||||||
|
Future androidSecureFlag(bool flag) {
|
||||||
|
return _channel.invokeMethod("androidSecureFlag", {
|
||||||
|
"flag": flag,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/// 音量键翻页
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pikapi/basic/config/Address.dart';
|
import 'package:pikapi/basic/config/Address.dart';
|
||||||
import 'package:pikapi/basic/config/AndroidDisplayMode.dart';
|
import 'package:pikapi/basic/config/AndroidDisplayMode.dart';
|
||||||
|
import 'package:pikapi/basic/config/AndroidSecureFlag.dart';
|
||||||
import 'package:pikapi/basic/config/AutoClean.dart';
|
import 'package:pikapi/basic/config/AutoClean.dart';
|
||||||
import 'package:pikapi/basic/config/AutoFullScreen.dart';
|
import 'package:pikapi/basic/config/AutoFullScreen.dart';
|
||||||
import 'package:pikapi/basic/config/ChooserRoot.dart';
|
import 'package:pikapi/basic/config/ChooserRoot.dart';
|
||||||
|
@ -63,6 +64,7 @@ class _InitScreenState extends State<InitScreen> {
|
||||||
await initChooserRoot();
|
await initChooserRoot();
|
||||||
await initTimeZone();
|
await initTimeZone();
|
||||||
await initDownloadAndExportPath();
|
await initDownloadAndExportPath();
|
||||||
|
await initAndroidSecureFlag();
|
||||||
// 登录, 如果token失效重新登录, 网络不好的时候可能需要1分钟
|
// 登录, 如果token失效重新登录, 网络不好的时候可能需要1分钟
|
||||||
if (await method.preLogin()) {
|
if (await method.preLogin()) {
|
||||||
// 如果token或username+password有效则直接进入登录好的界面
|
// 如果token或username+password有效则直接进入登录好的界面
|
||||||
|
|
|
@ -4,6 +4,7 @@ import 'dart:io';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pikapi/basic/Common.dart';
|
import 'package:pikapi/basic/Common.dart';
|
||||||
import 'package:pikapi/basic/config/AndroidDisplayMode.dart';
|
import 'package:pikapi/basic/config/AndroidDisplayMode.dart';
|
||||||
|
import 'package:pikapi/basic/config/AndroidSecureFlag.dart';
|
||||||
import 'package:pikapi/basic/config/AutoClean.dart';
|
import 'package:pikapi/basic/config/AutoClean.dart';
|
||||||
import 'package:pikapi/basic/config/AutoFullScreen.dart';
|
import 'package:pikapi/basic/config/AutoFullScreen.dart';
|
||||||
import 'package:pikapi/basic/config/ChooserRoot.dart';
|
import 'package:pikapi/basic/config/ChooserRoot.dart';
|
||||||
|
@ -121,6 +122,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||||
),
|
),
|
||||||
Divider(),
|
Divider(),
|
||||||
androidDisplayModeSetting(),
|
androidDisplayModeSetting(),
|
||||||
|
androidSecureFlagSetting(),
|
||||||
Divider(),
|
Divider(),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("文件夹选择器默认路径"),
|
title: Text("文件夹选择器默认路径"),
|
||||||
|
|
Loading…
Reference in New Issue