mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
add android translate
This commit is contained in:
@@ -9,7 +9,7 @@ import 'package:path/path.dart' as Path;
|
||||
|
||||
import 'model.dart';
|
||||
|
||||
enum SortBy { name, type, date, size }
|
||||
enum SortBy { Name, Type, Modified, Size }
|
||||
|
||||
// enum FileType {
|
||||
// Dir = 0,
|
||||
@@ -42,7 +42,7 @@ class FileModel extends ChangeNotifier {
|
||||
|
||||
JobState get jobState => _jobProgress.state;
|
||||
|
||||
SortBy _sortStyle = SortBy.name;
|
||||
SortBy _sortStyle = SortBy.Name;
|
||||
|
||||
SortBy get sortStyle => _sortStyle;
|
||||
|
||||
@@ -272,19 +272,19 @@ class FileModel extends ChangeNotifier {
|
||||
var content = "";
|
||||
late final List<Entry> entries;
|
||||
if (item.isFile) {
|
||||
title = "是否永久删除文件";
|
||||
title = translate("Are you sure you want to delete this file?");
|
||||
content = "${item.name}";
|
||||
entries = [item];
|
||||
} else if (item.isDirectory) {
|
||||
title = "这不是一个空文件夹";
|
||||
showLoading("正在读取...");
|
||||
title = translate("Not a Empty Directory");
|
||||
showLoading(translate("Waiting"));
|
||||
final fd = await _fileFetcher.fetchDirectoryRecursive(
|
||||
_jobId, item.path, items.isLocal!, true);
|
||||
fd.format(isWindows);
|
||||
EasyLoading.dismiss();
|
||||
// 空文件夹
|
||||
if (fd.entries.isEmpty) {
|
||||
final confirm = await showRemoveDialog("是否删除空文件夹", item.name, false);
|
||||
final confirm = await showRemoveDialog(translate("Are you sure you want to delete this empty directory?"), item.name, false);
|
||||
if (confirm == true) {
|
||||
sendRemoveEmptyDir(item.path, 0, items.isLocal!);
|
||||
}
|
||||
@@ -296,9 +296,9 @@ class FileModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
final dirShow = item.isDirectory ? "是否删除文件夹下的文件?\n" : "";
|
||||
final dirShow = item.isDirectory ? "${translate("Are you sure you want to delete the file of this directory?")}\n" : "";
|
||||
final count =
|
||||
entries.length > 1 ? "第 ${i + 1}/${entries.length} 项" : "";
|
||||
entries.length > 1 ? "${i + 1}/${entries.length}" : "";
|
||||
content = dirShow + "$count \n${entries[i].path}";
|
||||
final confirm =
|
||||
await showRemoveDialog(title, content, item.isDirectory);
|
||||
@@ -348,7 +348,7 @@ class FileModel extends ChangeNotifier {
|
||||
children: [
|
||||
Text(content),
|
||||
SizedBox(height: 5),
|
||||
Text("此操作不可逆!",
|
||||
Text(translate("This is irreversible!"),
|
||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
showCheckbox
|
||||
? CheckboxListTile(
|
||||
@@ -356,7 +356,7 @@ class FileModel extends ChangeNotifier {
|
||||
dense: true,
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
title: Text(
|
||||
"应用于文件夹下所有文件",
|
||||
translate("Do this for all conflicts"),
|
||||
),
|
||||
value: removeCheckboxRemember,
|
||||
onChanged: (v) {
|
||||
@@ -369,12 +369,12 @@ class FileModel extends ChangeNotifier {
|
||||
actions: [
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () => close(true),
|
||||
child: Text("Yes")),
|
||||
onPressed: () => close(false),
|
||||
child: Text(translate("Cancel"))),
|
||||
TextButton(
|
||||
style: flatButtonStyle,
|
||||
onPressed: () => close(false),
|
||||
child: Text("No"))
|
||||
onPressed: () => close(true),
|
||||
child: Text(translate("OK"))),
|
||||
]));
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ class DirectoryOption {
|
||||
|
||||
// code from file_manager pkg after edit
|
||||
List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
if (sortType == SortBy.name) {
|
||||
if (sortType == SortBy.Name) {
|
||||
// making list of only folders.
|
||||
final dirs = list.where((element) => element.isDirectory).toList();
|
||||
// sorting folder list by name.
|
||||
@@ -688,7 +688,7 @@ List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
|
||||
// first folders will go to list (if available) then files will go to list.
|
||||
return [...dirs, ...files];
|
||||
} else if (sortType == SortBy.date) {
|
||||
} else if (sortType == SortBy.Modified) {
|
||||
// making the list of Path & DateTime
|
||||
List<_PathStat> _pathStat = [];
|
||||
for (Entry e in list) {
|
||||
@@ -703,7 +703,7 @@ List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
.indexWhere((element) => element.path == a.name)
|
||||
.compareTo(_pathStat.indexWhere((element) => element.path == b.name)));
|
||||
return list;
|
||||
} else if (sortType == SortBy.type) {
|
||||
} else if (sortType == SortBy.Type) {
|
||||
// making list of only folders.
|
||||
final dirs = list.where((element) => element.isDirectory).toList();
|
||||
|
||||
@@ -720,7 +720,7 @@ List<Entry> _sortList(List<Entry> list, SortBy sortType) {
|
||||
.last
|
||||
.compareTo(b.name.toLowerCase().split('.').last));
|
||||
return [...dirs, ...files];
|
||||
} else if (sortType == SortBy.size) {
|
||||
} else if (sortType == SortBy.Size) {
|
||||
// create list of path and size
|
||||
Map<String, int> _sizeMap = {};
|
||||
for (Entry e in list) {
|
||||
|
||||
@@ -80,11 +80,11 @@ class ServerModel with ChangeNotifier {
|
||||
toggleService() async {
|
||||
if(_isStart){
|
||||
final res = await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Text("是否关闭"),
|
||||
content: Text("关闭录屏服务将自动关闭所有已连接的控制"),
|
||||
title: Text(translate("Warning")),
|
||||
content: Text(translate("android_stop_service_tip")),
|
||||
actions: [
|
||||
TextButton(onPressed: ()=>close(), child: Text("Cancel")),
|
||||
ElevatedButton(onPressed: ()=>close(true), child: Text("Ok")),
|
||||
TextButton(onPressed: ()=>close(), child: Text(translate("Cancel"))),
|
||||
ElevatedButton(onPressed: ()=>close(true), child: Text(translate("OK"))),
|
||||
],
|
||||
));
|
||||
if(res == true){
|
||||
@@ -92,11 +92,11 @@ class ServerModel with ChangeNotifier {
|
||||
}
|
||||
}else{
|
||||
final res = await DialogManager.show<bool>((setState, close) => CustomAlertDialog(
|
||||
title: Text("是否开启录屏服务"),
|
||||
content: Text("将自动开启监听服务"),
|
||||
title: Text(translate("Warning")),
|
||||
content: Text(translate("android_service_will_start_tip")),
|
||||
actions: [
|
||||
TextButton(onPressed: ()=>close(), child: Text("Cancel")),
|
||||
ElevatedButton(onPressed: ()=>close(true), child: Text("Ok")),
|
||||
TextButton(onPressed: ()=>close(), child: Text(translate("Cancel"))),
|
||||
ElevatedButton(onPressed: ()=>close(true), child: Text(translate("OK"))),
|
||||
],
|
||||
));
|
||||
if(res == true){
|
||||
@@ -169,7 +169,6 @@ class ServerModel with ChangeNotifier {
|
||||
switch (name) {
|
||||
case "media":
|
||||
_mediaOk = value;
|
||||
debugPrint("value $value,_isStart:$_isStart");
|
||||
if(value && !_isStart){
|
||||
startService();
|
||||
}
|
||||
@@ -191,13 +190,11 @@ class ServerModel with ChangeNotifier {
|
||||
|
||||
updateClientState() {
|
||||
var res = FFI.getByName("clients_state");
|
||||
debugPrint("getByName clients_state string:$res");
|
||||
try {
|
||||
final List clientsJson = jsonDecode(res);
|
||||
_clients = clientsJson
|
||||
.map((clientJson) => Client.fromJson(jsonDecode(res)))
|
||||
.toList();
|
||||
debugPrint("updateClientState:${_clients.toString()}");
|
||||
notifyListeners();
|
||||
} catch (e) {}
|
||||
}
|
||||
@@ -217,7 +214,7 @@ class ServerModel with ChangeNotifier {
|
||||
Text(translate("Do you accept?")),
|
||||
SizedBox(height: 20),
|
||||
clientInfo(client),
|
||||
Text(translate("It will be control your device!")),
|
||||
Text(translate("android_new_connection_tip")),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
@@ -321,27 +318,36 @@ showInputWarnAlert() async {
|
||||
await showDialog<bool>(
|
||||
context: globalKey.currentContext!,
|
||||
builder: (alertContext) {
|
||||
// TODO t
|
||||
DialogManager.register(alertContext);
|
||||
return AlertDialog(
|
||||
title: Text("获取输入权限引导"),
|
||||
content: Text.rich(TextSpan(style: TextStyle(), children: [
|
||||
TextSpan(text: "请在接下来的系统设置页\n进入"),
|
||||
TextSpan(text: " [服务] ", style: TextStyle(color: MyTheme.accent)),
|
||||
TextSpan(text: "配置页面\n将"),
|
||||
TextSpan(
|
||||
text: " [RustDesk Input] ",
|
||||
style: TextStyle(color: MyTheme.accent)),
|
||||
TextSpan(text: "服务开启")
|
||||
])),
|
||||
// content: Text.rich(TextSpan(style: TextStyle(), children: [
|
||||
// // [已安装的服务] : [Installed Services]
|
||||
// // 请在接下来的系统设置页面里,找到并进入[Installed Services]页面,将[RustDesk Input]服务开启。
|
||||
// TextSpan(text: "请在接下来的系统设置页\n进入"),
|
||||
// TextSpan(text: " [服务] ", style: TextStyle(color: MyTheme.accent)),
|
||||
// TextSpan(text: "配置页面\n将"),
|
||||
// TextSpan(
|
||||
// text: " [RustDesk Input] ",
|
||||
// style: TextStyle(color: MyTheme.accent)),
|
||||
// TextSpan(text: "服务开启")
|
||||
// ])),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(translate(translate("android_input_permission_tip1"))),
|
||||
SizedBox(height: 10),
|
||||
Text(translate(translate("android_input_permission_tip2"))),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(translate("Do nothing")),
|
||||
child: Text(translate("Cancel")),
|
||||
onPressed: () {
|
||||
DialogManager.reset();
|
||||
}),
|
||||
ElevatedButton(
|
||||
child: Text(translate("Go System Setting")),
|
||||
child: Text(translate("Open System Setting")),
|
||||
onPressed: () {
|
||||
FFI.serverModel.initInput();
|
||||
DialogManager.reset();
|
||||
|
||||
Reference in New Issue
Block a user