From 57a934b9bcbce189421442baff14a201964a47af Mon Sep 17 00:00:00 2001 From: mujianwu Date: Mon, 22 Jul 2024 20:26:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UotanToolbox/Assets/Resources.Designer.cs | 11 +++++- UotanToolbox/Assets/Resources.resx | 5 ++- UotanToolbox/Assets/Resources.zh-CN.resx | 5 ++- UotanToolbox/Features/Home/HomeViewModel.cs | 40 +++++++++++++++------ 4 files changed, 48 insertions(+), 13 deletions(-) diff --git a/UotanToolbox/Assets/Resources.Designer.cs b/UotanToolbox/Assets/Resources.Designer.cs index dd5ec692..3c3a6677 100644 --- a/UotanToolbox/Assets/Resources.Designer.cs +++ b/UotanToolbox/Assets/Resources.Designer.cs @@ -960,6 +960,15 @@ public static string Common_EnterFastboot { } } + /// + /// 查找类似 Please enter Recovery mode or enable USB debugging! 的本地化字符串。 + /// + public static string Common_EnterRecOrOpenADB { + get { + return ResourceManager.GetString("Common_EnterRecOrOpenADB", resourceCulture); + } + } + /// /// 查找类似 Please enter Recovery mode! 的本地化字符串。 /// @@ -1042,7 +1051,7 @@ public static string Common_NotSupportSystem { } /// - /// 查找类似 Please enter Recovery mode or enable USB debugging! 的本地化字符串。 + /// 查找类似 Please enable USB debugging! 的本地化字符串。 /// public static string Common_OpenADB { get { diff --git a/UotanToolbox/Assets/Resources.resx b/UotanToolbox/Assets/Resources.resx index 9c2d158d..b3c5682a 100644 --- a/UotanToolbox/Assets/Resources.resx +++ b/UotanToolbox/Assets/Resources.resx @@ -267,7 +267,7 @@ The device has been disconnected - + Please enter Recovery mode or enable USB debugging! @@ -1173,4 +1173,7 @@ Please select the flashing file! + + Please enable USB debugging! + \ No newline at end of file diff --git a/UotanToolbox/Assets/Resources.zh-CN.resx b/UotanToolbox/Assets/Resources.zh-CN.resx index fa08193f..915f0aa0 100644 --- a/UotanToolbox/Assets/Resources.zh-CN.resx +++ b/UotanToolbox/Assets/Resources.zh-CN.resx @@ -267,7 +267,7 @@ 设备已断开连接 - + 请进入Recovery模式或开启USB调试! @@ -1170,4 +1170,7 @@ 请选择刷机文件! + + 请开启USB调试! + \ No newline at end of file diff --git a/UotanToolbox/Features/Home/HomeViewModel.cs b/UotanToolbox/Features/Home/HomeViewModel.cs index 7d16f296..71aafd72 100644 --- a/UotanToolbox/Features/Home/HomeViewModel.cs +++ b/UotanToolbox/Features/Home/HomeViewModel.cs @@ -200,6 +200,26 @@ public async Task FreshDeviceList() } } + private async Task SystemControl(string shell) + { + if (await GetDevicesInfo.SetDevicesInfoLittle()) + { + MainViewModel sukiViewModel = GlobalData.MainViewModelInstance; + if (sukiViewModel.Status == GetTranslation("Home_System")) + { + await CallExternalProgram.ADB($"-s {Global.thisdevice} {shell}"); + } + else + { + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_OpenADB")), allowBackgroundClose: true); + } + } + else + { + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_NotConnected")), allowBackgroundClose: true); + } + } + private async Task ADBControl(string shell) { if (await GetDevicesInfo.SetDevicesInfoLittle()) @@ -211,7 +231,7 @@ private async Task ADBControl(string shell) } else { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_OpenADB")), allowBackgroundClose: true); + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecOrOpenADB")), allowBackgroundClose: true); } } else @@ -242,31 +262,31 @@ private async Task FastbootControl(string shell) [RelayCommand] - public async Task Back() => await ADBControl("shell input keyevent 4"); + public async Task Back() => await SystemControl("shell input keyevent 4"); [RelayCommand] - public async Task Home() => await ADBControl("shell input keyevent 3"); + public async Task Home() => await SystemControl("shell input keyevent 3"); [RelayCommand] - public async Task Mul() => await ADBControl("shell input keyevent 187"); + public async Task Mul() => await SystemControl("shell input keyevent 187"); [RelayCommand] - public async Task Lock() => await ADBControl("shell input keyevent 26"); + public async Task Lock() => await SystemControl("shell input keyevent 26"); [RelayCommand] - public async Task VolU() => await ADBControl("shell input keyevent 24"); + public async Task VolU() => await SystemControl("shell input keyevent 24"); [RelayCommand] - public async Task VolD() => await ADBControl("shell input keyevent 25"); + public async Task VolD() => await SystemControl("shell input keyevent 25"); [RelayCommand] - public async Task Mute() => await ADBControl("shell input keyevent 164"); + public async Task Mute() => await SystemControl("shell input keyevent 164"); [RelayCommand] public async Task SC() { string pngname = String.Format($"{DateAndTime.Now:yyyy-MM-dd_HH-mm-ss}"); - await ADBControl($"shell /system/bin/screencap -p /sdcard/{pngname}.png"); + await SystemControl($"shell /system/bin/screencap -p /sdcard/{pngname}.png"); await SukiHost.ShowToast(GetTranslation("Home_Succeeded"), $"{GetTranslation("Home_Saved")} {pngname}.png {GetTranslation("Home_ToStorage")}", NotificationType.Success); } @@ -292,7 +312,7 @@ public async Task ARSide() } else { - SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_OpenADB")), allowBackgroundClose: true); + SukiHost.ShowDialog(new PureDialog(GetTranslation("Common_EnterRecOrOpenADB")), allowBackgroundClose: true); } } else