forked from zsh2401/AutumnBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
256 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
*.dll | ||
*.psd | ||
*.txt | ||
fast | ||
#fast | ||
gfast.exe | ||
makezip | ||
##dirs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using AutumnBox.OpenFramework.ExtLibrary; | ||
using AutumnBox.OpenFramework.Management; | ||
using AutumnBox.OpenFramework.Wrapper; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace AutumnBox.OpenFramework.Fast | ||
{ | ||
/// <summary> | ||
/// 关于ILibsManager的拓展函数 | ||
/// </summary> | ||
public static class Lib | ||
{ | ||
/// <summary> | ||
/// 获取加载的Wrappers | ||
/// </summary> | ||
/// <param name="libsManager"></param> | ||
/// <returns></returns> | ||
public static IEnumerable<IExtensionWrapper> Wrappers(this ILibsManager libsManager) | ||
{ | ||
List<IExtensionWrapper> result = new List<IExtensionWrapper>(); | ||
IEnumerable<ILibrarian> libs = libsManager.Librarians; | ||
foreach (var lib in libs) | ||
{ | ||
try | ||
{ | ||
result.AddRange(lib.GetWrappers()); | ||
} | ||
catch (Exception ex) | ||
{ | ||
OpenFx.BaseApi.Log("LibExtension", "Warn", $"获取拓展模块封装类失败({lib.Name}){ex}"); | ||
} | ||
} | ||
return result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using AutumnBox.Basic.Device; | ||
using AutumnBox.OpenFramework.Extension; | ||
using AutumnBox.OpenFramework.Wrapper; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace AutumnBox.OpenFramework.Fast | ||
{ | ||
/// <summary> | ||
/// 一些过滤器 | ||
/// </summary> | ||
public static class WrapperFilter | ||
{ | ||
/// <summary> | ||
/// 根据所需状态过滤 | ||
/// </summary> | ||
/// <param name="wrappers"></param> | ||
/// <param name="state"></param> | ||
/// <returns></returns> | ||
public static IEnumerable<IExtensionWrapper> State(this IEnumerable<IExtensionWrapper> wrappers, DeviceState state) | ||
{ | ||
return from wrapper in wrappers | ||
where wrapper.Info.RequiredDeviceStates.HasFlag(state) || wrapper.Info.RequiredDeviceStates == state | ||
select wrapper; | ||
} | ||
|
||
/// <summary> | ||
/// 根据当前地区进行过滤 | ||
/// </summary> | ||
/// <param name="wrappers"></param> | ||
/// <param name="region"></param> | ||
/// <returns></returns> | ||
public static IEnumerable<IExtensionWrapper> Region(this IEnumerable<IExtensionWrapper> wrappers, string region) | ||
{ | ||
return from wrapper in wrappers | ||
where wrapper.RegionOK(region) | ||
select wrapper; | ||
} | ||
private static bool RegionOK(this IExtensionWrapper wrapper, string region) | ||
{ | ||
if (wrapper.Info.Regions == null) | ||
{ | ||
return true; | ||
} | ||
return wrapper.Info.Regions.Where((str) => | ||
{ | ||
return str.ToLower() == region; | ||
}).Count() > 0; | ||
} | ||
|
||
/// <summary> | ||
/// 根据开发者状态进行过滤 | ||
/// </summary> | ||
/// <param name="wrappers"></param> | ||
/// <param name="nowIsDevMode"></param> | ||
/// <param name="region"></param> | ||
/// <returns></returns> | ||
public static IEnumerable<IExtensionWrapper> Dev(this IEnumerable<IExtensionWrapper> wrappers, bool nowIsDevMode) | ||
{ | ||
return from wrapper in wrappers | ||
where wrapper.IsPassedDevCheck(nowIsDevMode) | ||
select wrapper; | ||
} | ||
private static bool IsPassedDevCheck(this IExtensionWrapper wrapper, bool nowIsDevMode) | ||
{ | ||
if (wrapper.Info.TryGetValueType(ExtensionInformationKeys.IS_DEVELOPING, out bool isDevExt)) | ||
{ | ||
if (isDevExt) | ||
{ | ||
return nowIsDevMode; | ||
} | ||
else | ||
{ | ||
return true; | ||
} | ||
} | ||
else | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// 过滤掉隐藏的 | ||
/// </summary> | ||
/// <param name="wrappers"></param> | ||
/// <returns></returns> | ||
public static IEnumerable<IExtensionWrapper> Hide(this IEnumerable<IExtensionWrapper> wrappers) | ||
{ | ||
return from wrapper in wrappers | ||
where wrapper.IsHide() | ||
select wrapper; | ||
} | ||
private static bool IsHide(this IExtensionWrapper wrapper) | ||
{ | ||
if (wrapper.Info.TryGetValueType(ExtensionInformationKeys.IS_HIDE, out bool result)) | ||
{ | ||
|
||
return !result; | ||
} | ||
else | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
AutumnBox.OpenFramework.Shared/LeafExtension/Fast/LeafUIHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using AutumnBox.Basic.Device; | ||
using AutumnBox.OpenFramework.LeafExtension.Kit; | ||
|
||
namespace AutumnBox.OpenFramework.LeafExtension.Fast | ||
{ | ||
/// <summary> | ||
/// LeafUI相关拓展函数 | ||
/// </summary> | ||
public static class LeafUIHelper | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <exception cref="LeafTerminatedException"></exception> | ||
/// <param name="ui"></param> | ||
/// <param name="exitCode"></param> | ||
public static void EFinish(this ILeafUI ui, int exitCode = 0) | ||
{ | ||
ui.Finish(exitCode); | ||
LeafExtensionHelper.EndCurrentLeafThread(null, exitCode); | ||
} | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <exception cref="LeafTerminatedException"></exception> | ||
/// <param name="ui"></param> | ||
/// <param name="tip"></param> | ||
public static void EFinish(this ILeafUI ui, string tip) | ||
{ | ||
ui.Finish(tip); | ||
LeafExtensionHelper.EndCurrentLeafThread(null); | ||
} | ||
/// <summary> | ||
/// Shutdown | ||
/// </summary> | ||
/// <param name="ui"></param> | ||
public static void EShutdown(this ILeafUI ui) | ||
{ | ||
ui.Shutdown(); | ||
LeafExtensionHelper.EndCurrentLeafThread(null); | ||
} | ||
/// <summary> | ||
/// 检查是否安装APP并询问用户,如果处于不恰当情况,将停止LeafExtension执行流程 | ||
/// </summary> | ||
/// <param name="ui"></param> | ||
/// <param name="device"></param> | ||
/// <param name="packageName"></param> | ||
public static void ECheckApp(this ILeafUI ui, IDevice device, string packageName) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
/// <summary> | ||
/// 检查设备安卓版本 | ||
/// </summary> | ||
/// <param name="ui"></param> | ||
/// <param name="device"></param> | ||
/// <param name="minAndroidVersion"></param> | ||
/// <param name="maxAndroidVersion"></param> | ||
/// <param name="targetAndroidVersion"></param> | ||
public static void ECheckAndroidVersion(this ILeafUI ui, IDevice device, | ||
string minAndroidVersion = null, string maxAndroidVersion = null, string targetAndroidVersion = null) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
/// <summary> | ||
/// 进行警告 | ||
/// </summary> | ||
/// <param name="ui"></param> | ||
/// <param name="warn"></param> | ||
public static void EWarn(this ILeafUI ui, string warn) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
/// <summary> | ||
/// 进行是否抉择 | ||
/// </summary> | ||
/// <param name="ui"></param> | ||
/// <param name="msg"></param> | ||
/// <param name="btnYes"></param> | ||
/// <param name="btnNo"></param> | ||
/// <returns></returns> | ||
public static bool EYN(this ILeafUI ui, string msg, string btnYes = null, string btnNo = null) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
/// <summary> | ||
/// 进行可取消的是否抉择 | ||
/// </summary> | ||
/// <param name="ui"></param> | ||
/// <param name="msg"></param> | ||
/// <param name="btnYes"></param> | ||
/// <param name="btnNo"></param> | ||
/// <param name="btnCancel"></param> | ||
/// <returns></returns> | ||
public static bool? EChoice(this ILeafUI ui, string msg, string btnYes = null, string btnNo = null, string btnCancel = null) | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
AutumnBox.OpenFramework.Shared/LeafExtension/LeafUIHelper.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters