Skip to content

Commit

Permalink
完善拓展模块元信息及其显示内容
Browse files Browse the repository at this point in the history
  • Loading branch information
zsh2401 committed Aug 20, 2020
1 parent bd4d373 commit 9f92abc
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
using AutumnBox.OpenFramework.Extension;
using AutumnBox.OpenFramework.Extension.Leaf;
using AutumnBox.OpenFramework.Management;
using System;
using System.Collections.Generic;
using System.Text;

namespace AutumnBox.Extensions.Essentials.Extensions
{
[ExtName("Launch ADB-CMD(PS)", "zh-cn:ADB-Powershell命令行")]
[ExtName("Launch ADB-CMD(PS)", "zh-cn:ADB-PS命令行")]
[ExtRequiredDeviceStates(AutumnBoxExtension.NoMatter)]
[ExtIcon("Resources.Icons.ps.png")]
class EPSLauncher : LeafExtensionBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@

namespace AutumnBox.CoreModules.Extensions.Fastboot
{
[ExtName("刷入Boot.img", "en-us:Flash boot.img")]
[ExtName("Flash Boot Partion", "zh-cn:刷入Boot分区")]
[ExtDesc("Support A/B Slot now!", "zh-cn:现已支持A/B槽位切换!")]
[ExtRequiredDeviceStates(DeviceState.Fastboot)]
[ExtIcon("Icons.cd.png")]
[ExtVersion(2, 0, 0)]
[ExtAuth("zsh2401")]
[ClassText("EFlashBootSelectingTitle", "Select a image file", "zh-cn:选择一个文件")]
[ClassText("EFlashBootSelectingFilter", "Image file(*.img)|*.img|Any file(*.*)|*.*", "zh-cn:镜像文件(*.img)|*.img|全部文件(*.*)|*.*")]
internal class EFlashBoot : LeafExtensionBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace AutumnBox.CoreModules.Extensions.Fastboot
[ExtName("加上BL锁", "en-us:Lock oem")]
[ExtDesc("觉得解BL后不安全?想养老了?", "en-us:Do you want to relock oem for your device?")]
[ExtIcon("Icons.lock.png")]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Fastboot)]
[ClassText("warn", "This will erase all the data on your device, OK?", "zh-cn:此操作将可能清空你设备上的所有数据,确定吗?")]
[ClassText("warn2", "Once again, this will erase all the data on your device, OK?", "zh-cn:再问一次,此操作将 可 能 清空你设备上的所有数据,确定吗?")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@
* ==============================================================================
*/
using AutumnBox.Basic.Calling;
using AutumnBox.Basic.Data;
using AutumnBox.Basic.Device;
using AutumnBox.Leafx.Enhancement.ClassTextKit;
using AutumnBox.Logging;
using AutumnBox.OpenFramework.Extension;
using AutumnBox.OpenFramework.Extension.Leaf;
using AutumnBox.OpenFramework.Open.LKit;
using System;
using System.Text.RegularExpressions;

namespace AutumnBox.Extensions.Standard.Extensions.Fastboot
{
[ExtName("Switch A/B slot", "zh-cn:切换AB槽位")]
[ExtRequiredDeviceStates(DeviceState.Fastboot)]
[ExtAuth("zsh2401")]
[ExtIcon("Icons.a_b.png")]
/// <summary>
/// https://github.com/zsh2401/AutumnBox/issues/19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace AutumnBox.CoreModules.Extensions.Mix
[ExtName("Remove device owner", "zh-cn:清除设备管理员")]
[ExtDesc("If you want to replace the DPM software, or if you perform the wrong operation during uninstallation, resulting in \"Device Owner Remains\", then use this feature to save your device!", "zh-cn:如果你想要更换DPM软件了,或者是卸载时进行了错误的操作,导致了“Device Owner残留”,那么快用这个功能拯救你的设备吧!")]
[ExtIcon("Icons.nuclear.png")]
[ExtAuth("zsh2401")]
[ExtRegions("zh-CN")]
[ExtRequiredDeviceStates(DeviceState.Poweron | DeviceState.Recovery)]
internal class EDeviceOwnerRemover : LeafExtensionBase
Expand All @@ -26,12 +27,12 @@ public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
using (executor)
{
ui.Show();
ui.EAgree("本模块将玉石俱焚,并且效果不一定完美,你真的需要这么做吗?如果你只是想要移除某个冻结软件,请前往该软件设置进行卸载");
ui.EAgree("本模块将玉石俱焚,并且效果不一定完美,你真的需要这么做吗?\n如果你只是想要移除某个冻结软件,请前往该软件设置进行卸载");
executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
executor.AdbShell(device, "su -c rm - rf / data / system / device_policies.xml");
executor.AdbShell(device, "su -c rm - rf /data/system/device_policies.xml");
executor.AdbShell(device, "su -c rm -rf /data/system/device_owner_2.xml");
device.Reboot2System();
ui.Finish(StatusMessages.Success);
ui.Finish(StatusMessages.PossibleSuccess);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace AutumnBox.CoreModules.Extensions.Mix
{
[ExtName("推送文件到手机主目录", "en-us:Push file to device")]
[ExtIcon("Icons.filepush.png")]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Poweron | DeviceState.Recovery)]
[ClassText("title", "Select a file", "zh-cn:选择一个文件")]
[ClassText("filter", "Any file", "zh-cn:任意文件(*.*)|*.*")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
[ExtName("激活黑阈", "en-us:Activate brevent by one key")]
[ExtDesc("一键激活黑阈,但值得注意的是,这样的激活方式,在重启后将失效", "Activate the brevent service by one key")]
[ExtPriority(ExtPriority.LOW)]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ExtIcon("Icons.brevent.png")]
[ClassText("first_msg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
[ExtName("Clear all accounts", "zh-CN:暴力清空所有账号")]
[ExtDesc("Use the tech by web1n", "zh-CN:使用web1n提供的黑科技暴力清空账号")]
[ExtIcon("Icons.nuclear.png")]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ClassText("warn", "Read it in detail, otherwise the consequences will be at your own risk!!\nThere is only one thing you need to do manually: clear the screen lock and fingerprint lock, do it now, make sure there is no screen lock and fingerprint lock, click agree", "zh-cn:详细阅读,否则后果自负!!!\n你需要手动做的只有一件事:清除屏幕锁和指纹锁,现在立刻去做,确保没有屏幕锁和指纹锁后,请点击同意将开始执行操作")]
[ClassText("pushing", "pushing DpmPro to device", "zh-cn:推送DPMPRO")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
[ExtName("Clear all users", "zh-CN:暴力清空所有用户")]
[ExtDesc("Use the tech by web1n", "zh-CN:使用web1n提供的黑科技暴力清空用户,这将会导致你的应用双开失效,以及其他可能的负面效果")]
[ExtIcon("Icons.nuclear.png")]
[ExtAuth("zsh2401")]
[ClassText("warn", "Read it in detail, otherwise the consequences will be at your own risk!!\nThere is only one thing you need to do manually: clear the screen lock and fingerprint lock, do it now, make sure there is no screen lock and fingerprint lock, click agree", "zh-cn:详细阅读,否则后果自负!!!\n你需要手动做的只有一件事:清除屏幕锁和指纹锁,现在立刻去做,确保没有屏幕锁和指纹锁后,请点击同意将开始执行操作")]
[ClassText("pushing", "pushing DpmPro to device", "zh-cn:推送DPMPRO")]
[ClassText("extracting", "extracting DpmPro", "zh-cn:提取DPMPRO")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
{
[ExtName("Modify dpi without root", "zh-cn:修改DPI")]
[ExtIcon("Icons.dpi.png")]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ClassText("msg", "Which is your want?", "zh-cn:您要做哪一个操作")]
[ClassText("modify", "Modify DPI", "zh-cn:修改DPI")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
[ExtRegions("zh-CN")]
[ExtName("激活极客内存清理")]
[ExtIcon("Icons.gcm.png")]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ClassText("isNet", "The target is already net device", "zh-cn:已经是网络设备,无需再次激活")]
[ClassText("notsupport", "Do not support this type of device", "zh-cn:不支持当前设备")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
{
[ExtName("Greenify Aggressive Doze", "zh-CN:绿色守护免ROOT模式")]
[ExtVersion(2019, 1, 3)]
[ExtAuth("zsh2401")]
[ExtIcon("Icons.Greenify.png")]
[ClassText("notice", "This activator activates most of its ROOT-free functions with reference to the green daemon file. Activation may not be successful due to problems with the Android platform.", "zh-cn:本激活器参照绿色守护文档对其大部分免ROOT功能进行激活,由于安卓平台的问题,激活不一定可以成功")]
[ClassText("tip", "MaybeSuccess", "zh-cn:可能成功")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace AutumnBox.Extensions.Standard.Extensions.Poweron
[ExtName("Permission Dog Activator", "zh-cn:权限狗ADB模式")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ExtIcon("Icons.permissiondog")]
[ExtAuth("zsh2401")]
class EPermissionDogActivator : LeafExtensionBase
{
[LMain]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace AutumnBox.CoreModules.Extensions
{
[ExtName("Screen capture", "zh-cn:截图")]
[ExtIcon("Icons.screenshotv2.png")]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ClassText("error", "Can not get screenshot.Plz unlock device at least once or replug it.", "zh-cn:截图失败,请至少解锁一次手机或重新拔插设备")]
internal class EScreenShoter : LeafExtensionBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
{
[ExtName("Activate ShizukuManager", "zh-cn:激活ShizukuManager")]
[ExtIcon("Icons.ShizukuManager.png")]
[ExtAuth("zsh2401")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ClassText("launchFirst", "Click OK after ShizukuManager has been launched", "zh-cn:启动Shizuku Manager后点击确认")]
internal class EShizukuActivator : LeafExtensionBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
[ExtName("StopApp MaxWell Mode", "zh-cn:激活小黑屋麦克斯韦妖模式")]
[ExtAuth("zsh2401")]
[ExtPriority(ExtPriority.HIGH - 1)]
[ExtAuth("zsh2401")]
[ExtIcon("Icons.stopapp.png")]
[ExtRequiredDeviceStates(DeviceState.Poweron)]
class EStopAppMaxWellActivator : LeafExtensionBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ namespace AutumnBox.CoreModules.Extensions.Poweron
[ExtRequiredDeviceStates(DeviceState.Poweron)]
[ExtRequireRoot(true)]
[ExtIcon("Icons.unlock.png")]
[ExtAuth("zsh2401")]
[ClassText("reboot", "Reboot device?", "zh-cn:似乎成功了.\n重启设备生效,是否重启?")]
[ClassText("warn", "This function is not making your device's boot loader partion unlocked.", "zh-cn:这个模块不是用于解锁手机BL的!")]
internal class EUnlockSystemParation : LeafExtensionBase
{
[LMain]
Expand All @@ -29,6 +31,7 @@ public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
{
var text = ClassTextReaderCache.Acquire<EUnlockSystemParation>();
ui.Show();
ui.EAgree(text.RxGet("warn"));
executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
executor.Adb(device, "root");
var result = executor.Adb(device, "disable-verity");
Expand Down
4 changes: 3 additions & 1 deletion src/AutumnBox.GUI/Models/ExtensionDock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public string ToolTip
{
get
{
return $"{ExtensionInfo.Name()}{Environment.NewLine}v{ExtensionInfo.Version()} by {ExtensionInfo.Author()}";
string? desc = ExtensionInfo.Description();
desc = desc == String.Empty ? App.Current.Resources["ExtensionsFinder.DefaultDescription"]?.ToString() : desc;
return $"{ExtensionInfo.Name()}{Environment.NewLine}v{ExtensionInfo.Version()}(BY {ExtensionInfo.Author()}){Environment.NewLine}{desc ?? "--"}";
}
}

Expand Down
1 change: 1 addition & 0 deletions src/AutumnBox.GUI/Resources/Languages/zh-CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
<s:String x:Key="Settings.DisplayCmdWindowTip">或许你可以通过这个来排查某些疑难杂症,仅在部分情况下支持</s:String>

<s:String x:Key="ExtensionsFinder.StateNotCorrectWarning">设备状态不正确</s:String>
<s:String x:Key="ExtensionsFinder.DefaultDescription">无说明</s:String>

<s:String x:Key="DeviceState.Poweron">开机</s:String>
<s:String x:Key="DeviceState.Recovery">恢复模式</s:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public static class StatusMessages
/// </summary>
public static string Fatal => carrier.RxGetClassText(KEY_FATAL);

/// <summary>
/// 可能成功
/// </summary>
public static string PossibleSuccess => carrier.RxGetClassText(KEY_MAY_SUCCESS);

/// <summary>
/// 文本载体
/// </summary>
Expand All @@ -53,14 +58,17 @@ static StatusMessages()
ClassTextReaderCache.Acquire(typeof(TextCarrier));
}
private const string KEY_SUCCESS = "success";
private const string KEY_MAY_SUCCESS = "may_success";
private const string KEY_FAILED = "failed";
private const string KEY_FATAL = "fatal";
private const string KEY_CANCELLED_BY_USER = "cancelled_by_user";


/// <summary>
/// 载体
/// </summary>
[ClassText(KEY_SUCCESS, "Success", "zh-cn:成功")]
[ClassText(KEY_MAY_SUCCESS, "Possible success ", "zh-cn:可能成功")]
[ClassText(KEY_FAILED, "Failed", "zh-cn:失败")]
[ClassText(KEY_CANCELLED_BY_USER, "Cancelled by user", "zh-cn:被用户取消")]
[ClassText(KEY_FATAL, "Fatal Error", "zh-cn:致命问题")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,29 @@ public static string Name(this IExtensionInfo extensionInfo)
}
}

/// <summary>
/// 获取解释信息
/// </summary>
/// <param name="extensionInfo"></param>
/// <returns></returns>
public static string Description(this IExtensionInfo extensionInfo)
{
string DEFAULT_VALUE = String.Empty;
try
{
return extensionInfo.Metadata[ExtensionMetadataKeys.DESCRIPTION]?.Invoke() as string ?? DEFAULT_VALUE;
}
catch (Exception)
{
return DEFAULT_VALUE;
}
}

/// <summary>
/// 获取版本号
/// </summary>
/// <param name="extensionInfo"></param>
/// <returns></returns>
public static Version Version(this IExtensionInfo extensionInfo)
{
var DEFAULT_VALUE = new Version(1, 0, 0);
Expand Down

0 comments on commit 9f92abc

Please sign in to comment.