Skip to content

Commit

Permalink
AddMobile
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Oct 16, 2021
1 parent 303873f commit 2f5dcab
Show file tree
Hide file tree
Showing 33 changed files with 1,055 additions and 155 deletions.
62 changes: 62 additions & 0 deletions SteamToolsV2+.sln
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UI Framework", "UI Framewor
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Web API", "Web API", "{4E7DF449-F136-4B90-82CE-D1418CD5123C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ST.Client.Android", "src\ST.Client.Android\ST.Client.Android.csproj", "{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ST.Client.iOS", "src\ST.Client.iOS\ST.Client.iOS.csproj", "{7EE23547-B2AC-409D-991C-1FDAE122657C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1207,6 +1211,62 @@ Global
{D30203AC-97AB-4A51-BFA5-826251C9A28E}.Release|x64.Build.0 = Release|Any CPU
{D30203AC-97AB-4A51-BFA5-826251C9A28E}.Release|x86.ActiveCfg = Release|Any CPU
{D30203AC-97AB-4A51-BFA5-826251C9A28E}.Release|x86.Build.0 = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|ARM.Build.0 = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|ARM64.Build.0 = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|iPhone.Build.0 = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|x64.ActiveCfg = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|x64.Build.0 = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|x86.ActiveCfg = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Debug|x86.Build.0 = Debug|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|Any CPU.Build.0 = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|ARM.ActiveCfg = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|ARM.Build.0 = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|ARM64.ActiveCfg = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|ARM64.Build.0 = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|iPhone.ActiveCfg = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|iPhone.Build.0 = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|x64.ActiveCfg = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|x64.Build.0 = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|x86.ActiveCfg = Release|Any CPU
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B}.Release|x86.Build.0 = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|ARM.Build.0 = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|ARM64.Build.0 = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|iPhone.Build.0 = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|x64.ActiveCfg = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|x64.Build.0 = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|x86.ActiveCfg = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Debug|x86.Build.0 = Debug|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|Any CPU.Build.0 = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|ARM.ActiveCfg = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|ARM.Build.0 = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|ARM64.ActiveCfg = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|ARM64.Build.0 = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|iPhone.ActiveCfg = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|iPhone.Build.0 = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|x64.ActiveCfg = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|x64.Build.0 = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|x86.ActiveCfg = Release|Any CPU
{7EE23547-B2AC-409D-991C-1FDAE122657C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1252,6 +1312,8 @@ Global
{E50441E8-75F3-406E-9921-30BFC211B5CE} = {327FDEE7-C4C8-4AA4-A7B0-8BCE3D75346F}
{8E38AAF2-8C7D-4B0D-AB25-AB37EECB4029} = {327FDEE7-C4C8-4AA4-A7B0-8BCE3D75346F}
{4E7DF449-F136-4B90-82CE-D1418CD5123C} = {327FDEE7-C4C8-4AA4-A7B0-8BCE3D75346F}
{DEF239E4-AC40-4BD8-8D36-5AA6B36AB86B} = {E50441E8-75F3-406E-9921-30BFC211B5CE}
{7EE23547-B2AC-409D-991C-1FDAE122657C} = {E50441E8-75F3-406E-9921-30BFC211B5CE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9313F2B4-10DA-43AA-A481-CAA7571C740C}
Expand Down
16 changes: 2 additions & 14 deletions src/AboutAppInfoPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,20 +358,8 @@ static string GetJavaSystemGetProperty(string propertyKey)
b.AppendLine();
#endif

b.Append("[xamarin.essentials.supported] ");
static bool? GetXamarinEssentialsIsSupported()
{
try
{
if (typeof(MainThread2).Assembly.GetType("System.Application.XamarinEssentials").GetProperty("IsSupported", BindingFlags.Public | BindingFlags.Static).GetValue(null) is bool b)
return b;
}
catch
{
}
return null;
}
b.Append(GetXamarinEssentialsIsSupported().ToLowerString());
b.Append("[essentials] ");
b.Append(Essentials.IsSupported.ToLowerString());
b.AppendLine();

var b_str = b.ToString();
Expand Down
6 changes: 3 additions & 3 deletions src/Common.ClientLib/Application/Essentials/Clipboard2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class Clipboard2
{
public static async Task SetTextAsync(string? text)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
await Clipboard.SetTextAsync(text);
}
Expand All @@ -27,7 +27,7 @@ public static async Task SetTextAsync(string? text)

public static async Task<string> GetTextAsync()
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return await Clipboard.GetTextAsync();
}
Expand All @@ -41,7 +41,7 @@ public static bool HasText
{
get
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return Clipboard.HasText;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common.ClientLib/Application/Essentials/Email2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static Task ComposeAsync(string subject, string body, params string[] to)

public static async Task ComposeAsync(EmailMessage? message)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
await Email.ComposeAsync(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace System.Application
{
internal static class XamarinEssentials
public static class Essentials
{
static readonly Lazy<bool> _IsSupported = new(() =>
{
Expand Down
8 changes: 4 additions & 4 deletions src/Common.ClientLib/Application/Essentials/FilePicker2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class FilePicker2
{
static readonly Lazy<bool> mIsSupportedFileExtensionFilter = new(() =>
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return OperatingSystem2.IsWindows;
}
Expand Down Expand Up @@ -48,7 +48,7 @@ public static class FilePicker2

public static async Task<FileResult?> PickAsync(PickOptions? options = null)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return await FilePicker.PickAsync(options);
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public static async Task PickAsync(Func<string, Task> func, FilePickerFileType?

public static async Task<IEnumerable<FileResult>> PickMultipleAsync(PickOptions? options = null)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return await FilePicker.PickMultipleAsync(options);
}
Expand Down Expand Up @@ -286,7 +286,7 @@ public static class Images
{
static readonly Lazy<FilePickerFileType> _FileTypes = new(() =>
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return FilePickerFileType.Images;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Common.ClientLib/Application/Essentials/MainThread2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static bool IsMainThread
{
get
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return MainThread.IsMainThread;
}
Expand All @@ -29,7 +29,7 @@ public static bool IsMainThread

public static void BeginInvokeOnMainThread(Action action, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
MainThread.BeginInvokeOnMainThread(action);
}
Expand All @@ -48,7 +48,7 @@ public static void BeginInvokeOnMainThread(Action action, DispatcherPriorityComp

public static Task InvokeOnMainThreadAsync(Action action, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return MainThread.InvokeOnMainThreadAsync(action);
}
Expand Down Expand Up @@ -85,7 +85,7 @@ public static Task InvokeOnMainThreadAsync(Action action, DispatcherPriorityComp

public static Task<T> InvokeOnMainThreadAsync<T>(Func<T> func, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return MainThread.InvokeOnMainThreadAsync(func);
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public static Task<T> InvokeOnMainThreadAsync<T>(Func<T> func, DispatcherPriorit

public static Task InvokeOnMainThreadAsync(Func<Task> funcTask, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return MainThread.InvokeOnMainThreadAsync(funcTask);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ public static Task InvokeOnMainThreadAsync(Func<Task> funcTask, DispatcherPriori

public static Task<T> InvokeOnMainThreadAsync<T>(Func<Task<T>> funcTask, DispatcherPriorityCompat priority = DispatcherPriorityCompat.Normal)
{
if (XamarinEssentials.IsSupported)
if (Essentials.IsSupported)
{
return MainThread.InvokeOnMainThreadAsync(funcTask);
}
Expand Down
32 changes: 32 additions & 0 deletions src/ST.Client.Android/ST.Client.Android.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>net6.0-android;MonoAndroid11.0</TargetFrameworks>
<RootNamespace>System.Application</RootNamespace>
<AssemblyName>System.Application.SteamTools.Client.Android</AssemblyName>
<DefineConstants>__HAVE_ANDROIDX__;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<!--当前包是否为应用商店渠道包(IS_STORE_PACKAGE)-->
<!--<PropertyGroup>
<DefineConstants>IS_STORE_PACKAGE;$(DefineConstants)</DefineConstants>
</PropertyGroup>-->

<ItemGroup>
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
</Compile>
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.Version.cs">
<Link>Properties\AssemblyInfo.Version.cs</Link>
</Compile>
<Compile Include="..\ST\Properties\InternalsVisibleTo.cs">
<Link>Properties\InternalsVisibleTo.cs</Link>
</Compile>
<!--<Compile Include="..\ST.Client.Desktop\ServiceCollectionExtensions.AddGeneralLogging.cs" />-->
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\ST.Client\ST.Client.csproj" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/ST.Client.Desktop.Avalonia.App/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,5 +529,7 @@ void IDisposable.Dispose()
#endregion

string IAvaloniaApplication.RenderingSubsystemName => Program.RenderingSubsystemName;

object IApplication.CurrentPlatformUIHost => MainWindow;
}
}
8 changes: 1 addition & 7 deletions src/ST.Client.Desktop.Linux/ST.Client.Linux.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
<DefineConstants>LINUX;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Internals\**" />
<EmbeddedResource Remove="Internals\**" />
<None Remove="Internals\**" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Common.CoreLib\Properties\AssemblyInfo.cs">
<Link>Properties\AssemblyInfo.cs</Link>
Expand All @@ -24,7 +18,7 @@
<Link>Properties\InternalsVisibleTo.cs</Link>
</Compile>
<Compile Include="..\ST.Client.Desktop\ServiceCollectionExtensions.AddGeneralLogging.cs" />
<Compile Include="..\ST.Client.Desktop.Mac\Internals\UnixHelper.cs">
<Compile Include="..\ST.Client.Desktop.Mac\Internals\UnixHelper.RunShellAsync.cs">
<LinkBase>Internals</LinkBase>
</Compile>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Application.Internals;
using System.Application.Models;
using System.Diagnostics;
using System.IO;
Expand Down
75 changes: 75 additions & 0 deletions src/ST.Client.Desktop.Mac/Internals/UnixHelper.RunShellAsync.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Application.UI.Resx;
using System.Application.UI.ViewModels;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Application.Services;

static partial class UnixHelper
{
static readonly Lazy<string> _bin_bash = new(() => string.Format("{0}bin{0}bash", Path.DirectorySeparatorChar));

/// <summary>
/// /bin/bash
/// </summary>
public static string BinBash => _bin_bash.Value;

/// <inheritdoc cref="IPlatformService.RunShellAsync(string, bool)"/>
public static ValueTask RunShellAsync(string script, bool admin)
=> RunShellAsync(script, admin, 3);

/// <inheritdoc cref="IPlatformService.RunShellAsync(string, bool)"/>
static async ValueTask RunShellAsync(string script, bool admin, sbyte retry_count)
{
if (retry_count <= 0) return;

var file = new FileInfo(Path.Combine(IOPath.AppDataDirectory, $@"{(admin ? "sudo" : "")}shell.sh"));

if (file.Exists)
file.Delete();
var scriptContent = new StringBuilder();
if (admin)
{
TextBoxWindowViewModel vm = new()
{
Title = AppResources.MacSudoPasswordTips,
InputType = TextBoxWindowViewModel.TextBoxInputType.Password,
Description = $"sudo {script}",
};
await TextBoxWindowViewModel.ShowDialogAsync(vm);
if (string.IsNullOrWhiteSpace(vm.Value))
return;
scriptContent.AppendLine($"echo \"{vm.Value}\" | sudo -S {script}");
}
else
{
scriptContent.AppendLine(script);
}
using (var stream = file.CreateText())
{
stream.Write(scriptContent);
stream.Flush();
}
using var p = new Process();
p.StartInfo.FileName = BinBash;
p.StartInfo.Arguments = $"\"{file.FullName}\"";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Exited += async (_, _) =>
{
if (file.Exists)
file.Delete();
if (p.ExitCode != 0)
{
await RunShellAsync(script, admin, --retry_count);
}
};
p.Start();
var ret = p.StandardOutput.ReadToEnd();
p.Kill();
if (file.Exists)
file.Delete();
}
}
Loading

0 comments on commit 2f5dcab

Please sign in to comment.