Skip to content

Commit

Permalink
fixed some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zsh2401 committed Feb 22, 2021
1 parent 5ddf70b commit 1cd5c5d
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ internal class EShizukuActivator : LeafExtensionBase
{
private const string PKG_NAME = "moe.shizuku.privileged.api";
private const string SH_PATH = "/sdcard/Android/data/moe.shizuku.privileged.api/files/start.sh";

[LMain]
#pragma warning disable CA1822 // 将成员标记为 static
public void EntryPoint(ILeafUI ui, IDevice device, ICommandExecutor executor)
#pragma warning restore CA1822 // 将成员标记为 static
{
using (ui)
{
using (executor)
{
executor.OutputReceived += (s, e) => ui.WriteLineToDetails(e.Text);
var text = ClassTextReaderCache.Acquire<EShizukuActivator>();
ui.Show();
ui.AppPropertyCheck(device, PKG_NAME);
ui.ShowMessage(text["launchFirst"]);

var result = executor.AdbShell(device, $"sh {SH_PATH}");
ui.Finish(result.ExitCode == 0 ? StatusMessages.Success : StatusMessages.Failed);
}
Expand Down
6 changes: 3 additions & 3 deletions src/AutumnBox.GUI/AutumnBox.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<AssemblyName>AutumnBox.GUI</AssemblyName>
<RootNamespace>AutumnBox.GUI</RootNamespace>
<ApplicationIcon>Resources\Icons\icon.ico</ApplicationIcon>
<Version>2021.2.20</Version>
<AssemblyVersion>2020.8.19.0</AssemblyVersion>
<Version>2021.2.22</Version>
<AssemblyVersion>2021.2.22.0</AssemblyVersion>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
<Configurations>Debug;Release;Canary</Configurations>
<FileVersion>2020.8.19.0</FileVersion>
<FileVersion>2021.2.22.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
7 changes: 5 additions & 2 deletions src/AutumnBox.GUI/Resources/Languages/en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,12 @@
<s:String x:Key="Version.OpenFx">Open Framework</s:String>
<s:String x:Key="Version.Logging">Logging Framework</s:String>
<s:String x:Key="Version.OS">Operating System</s:String>
<s:String x:Key="Version.Net">.Net Environment</s:String>
<s:String x:Key="Version.Commit">Commit</s:String>
<s:String x:Key="Version.Tag">Tag</s:String>
<s:String x:Key="Version.Net">.Net</s:String>


<s:String x:Key="QQGroup">QQ Group</s:String>
<s:String x:Key="EMail">E-Mail</s:String>
<s:String x:Key="OpenSource">Open source</s:String>
<s:String x:Key="UpdateCheck">Update check</s:String>

Expand Down
8 changes: 6 additions & 2 deletions src/AutumnBox.GUI/Resources/Languages/zh-CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,18 @@
<s:String x:Key="Version.Basic">ADB交互模块</s:String>
<s:String x:Key="Version.OpenFx">SDK</s:String>
<s:String x:Key="Version.ADB">ADB</s:String>

<s:String x:Key="Version.Commit">提交(Commit)</s:String>
<s:String x:Key="Version.Tag">标签(Tag)</s:String>
<s:String x:Key="Version.OS">操作系统</s:String>
<s:String x:Key="Version.Net">.NET Core</s:String>
<s:String x:Key="Version.Net">.Net</s:String>

<!--关于-->
<s:String x:Key="QQGroup">QQ群</s:String>
<s:String x:Key="EMail">电子邮件</s:String>
<s:String x:Key="OpenSource">开放源代码</s:String>



<s:String x:Key="UserLicense.Name">秋之盒使用协议 1.0</s:String>
<s:String x:Key="UserLicense.Content">本协议仍然在编写当中,最终解释权归zsh2401所有
欢迎您使用秋之盒-AutumnBox(下称本软件)。
Expand Down
16 changes: 16 additions & 0 deletions src/AutumnBox.GUI/Services/IBuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutumnBox.GUI.Services
{
internal interface IBuildInfo
{
string LatestCommit { get; }
string DateTime { get; }
string LatestTag { get; }
string Version { get; }
}
}
37 changes: 37 additions & 0 deletions src/AutumnBox.GUI/Services/Impl/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using AutumnBox.Leafx.Container.Support;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace AutumnBox.GUI.Services.Impl
{
[Component(Type = typeof(IBuildInfo))]
class BuildInfo : IBuildInfo
{
private const string FILE_NAME = "./build.ini";

public string LatestCommit => Read("commit") ?? "unknown";

public string DateTime => Read("datetime") ?? "unknown";

public string LatestTag => Read("tag") ?? "unknown";

public string Version => Read("version") ?? "unknown";

[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string def,
StringBuilder retVal, int size, string filePath);

private static string? Read(string key)
{
const int BUFFER_SIZE = 255;
StringBuilder sb = new StringBuilder(BUFFER_SIZE);
_ = GetPrivateProfileString("Build", key, "", sb, BUFFER_SIZE, FILE_NAME);
return sb.ToString();
}

}
}
5 changes: 3 additions & 2 deletions src/AutumnBox.GUI/Util/Loader/GeneralAppLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ private void InitLogSystem(ILoggingManager loggingManager)
}

[Step(1)]
private void PrintInformations()
private void PrintInformations(IBuildInfo buildInfo)
{
Logger.Info("======================");
Logger.Info($"Installed as {Environment.CurrentDirectory}");
Logger.Info($"Run as {(Self.HaveAdminPermission ? "Admin" : "Normal user")}");
Logger.Info($"Run as {(Self.HaveAdminPermission ? "Administrator" : "Normal user")}");
Logger.Info($"AutumnBox version: {Self.Version}");
Logger.Info($"Core library version: {BuildInfo.SDK_VERSION}");
Logger.Info($"Windows version: {Environment.OSVersion.Version}");
Logger.Info($"Clr version: {Environment.Version}");
Logger.Info($"Commit: {buildInfo.LatestCommit}");
Logger.Info("======================");
}

Expand Down
36 changes: 36 additions & 0 deletions src/AutumnBox.GUI/ViewModels/VMAbout.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AutumnBox.GUI.MVVM;
using AutumnBox.GUI.Services;
using AutumnBox.Leafx.Container;
using AutumnBox.Leafx.ObjectManagement;
using System.Windows.Input;

Expand All @@ -9,12 +10,47 @@ class VMAbout : ViewModelBase
{
public ICommand UpdateCheck { get; }

public string VersionName
{
get => _versionName; set
{
_versionName = value;
RaisePropertyChanged();
}
}
private string _versionName;

public string Tag
{
get => _tag; set
{
_tag = value;
RaisePropertyChanged();
}
}
private string _tag;

public string Commit
{
get => _commit;
set
{
_commit = value;
RaisePropertyChanged();
}
}
private string _commit;

[AutoInject]
private IOpenFxManager OpenFxManager { get; set; }

public VMAbout()
{
UpdateCheck = new MVVMCommand((p) => OpenFxManager.RunExtension("EAutumnBoxUpdateChecker"));
var buildInfo = App.Current.Lake.Get<IBuildInfo>();
VersionName = buildInfo.Version;
Commit = buildInfo.LatestCommit.Substring(0, 6);
Tag = buildInfo.LatestTag;
}
}
}
42 changes: 33 additions & 9 deletions src/AutumnBox.GUI/ViewModels/VMStartup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using AutumnBox.GUI.MVVM;
using AutumnBox.GUI.Services;
using AutumnBox.GUI.Util.Loader;
using AutumnBox.Leafx.Container;
using AutumnBox.Leafx.ObjectManagement;
using System;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
Expand All @@ -25,16 +28,23 @@ public string Status
}
private string _status;

public string VersionName => GetType()?.Assembly?.GetName()?.Version?.ToString(3) +
[AutoInject]
private IBuildInfo build
{
get;
set;
}

#if CANARY
"-canary"
#elif DEBUG
"-debug"
#else
""
#endif
;
public string VersionName
{
get => _versionName;
set
{
_versionName = value;
RaisePropertyChanged();
}
}
private string _versionName;

public double Progress
{
Expand Down Expand Up @@ -100,6 +110,20 @@ private void AppLoader_Succeced(object sender, System.EventArgs e)
private void AppLoader_StepFinished(object sender, StepFinishedEventArgs e)
{
Progress = 100.0 * e.FinishedStep / e.TotalStepCount;

if (VersionName == null)
{
var build = App.Current.Lake.Get<IBuildInfo>();
VersionName = build.Version +
#if CANARY
"-canary"
#elif DEBUG
"-debug"
#else
""
#endif
;
}
}
}
}
28 changes: 23 additions & 5 deletions src/AutumnBox.GUI/Views/Controls/PanelAbout.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
<StackPanel Margin="10" Orientation="Horizontal">
<Image Source="/Resources/Drawable/Icon.ico" Height="30" Margin="5"/>
<StackPanel>
<TextBlock FontSize="20" Text="{DynamicResource App.NameWithVersion}"/>
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="20" Text="{DynamicResource App.Name}"/>
<TextBlock FontSize="20" Text="{Binding VersionName}"/>
</StackPanel>

<TextBlock Text="{DynamicResource App.Slogan}" Foreground="{DynamicResource SecondaryTextBrush}"/>
</StackPanel>
</StackPanel>


<hc:Shield Command="{Binding OpenUrl}" CommandParameter="mailto:[email protected]" Margin="2" HorizontalAlignment="Center" Subject="{DynamicResource EMail}" Status="[email protected]" Color="#d8624c"/>
<hc:Shield Margin="2" HorizontalAlignment="Center" Subject="{DynamicResource QQGroup}" Status="246177486" Color="#1182c3"/>
<TextBlock HorizontalAlignment="Center" Text="www.atmb.top" TextDecorations="Underline">
Expand All @@ -43,17 +48,18 @@
</TextBlock>
</StackPanel>
<StackPanel DockPanel.Dock="Bottom" Margin="0,0,0,10">

</StackPanel>

<StackPanel DockPanel.Dock="Top" Width="200">
<StackPanel DockPanel.Dock="Top">


<DockPanel Margin="30,10,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.GUIString}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.AutumnBox}"/>
</DockPanel>



<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.BasicString}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.Basic}"/>
Expand Down Expand Up @@ -91,6 +97,18 @@
<TextBlock DockPanel.Dock="Right" Text="{x:Static util:VersionInfos.SharpZipLibString}"/>
<TextBlock DockPanel.Dock="Left" Text="SharpZipLib"/>
</DockPanel>

<Grid Height="1" Margin="25,5,25,5" Background="LightGray"/>

<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{Binding Commit}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.Commit}"/>
</DockPanel>

<DockPanel Margin="30,0,30,0">
<TextBlock DockPanel.Dock="Right" Text="{Binding Tag}"/>
<TextBlock DockPanel.Dock="Left" Text="{DynamicResource Version.Tag}"/>
</DockPanel>
</StackPanel>
</DockPanel>
</UserControl>
4 changes: 2 additions & 2 deletions src/AutumnBox.GUI/Views/Windows/AboutWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
WindowStartupLocation="CenterOwner"
Background="{DynamicResource RegionBrush}"
FontFamily="{DynamicResource AutumnBox.Font}"
Width="410"
Height="210"
Width="510"
Height="300"
Title="{DynamicResource App.NameWithVersion}" >
<!--<DockPanel >-->
<panel:PanelAbout Effect="{DynamicResource EffectShadow2}"/>
Expand Down
9 changes: 5 additions & 4 deletions src/AutumnBox.GUI/Views/Windows/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ xmlns:hc="https://handyorg.github.io/handycontrol"
<TextBlock Foreground="{DynamicResource SecondaryTextBrush}" TextWrapping="Wrap" FontSize="12" Text="{DynamicResource Settings.SoundsTip}"/>
</StackPanel>
</DockPanel>
<DockPanel Margin="5">

<!--<DockPanel Margin="5">
<!--<StackPanel Orientation="Vertical" DockPanel.Dock="Left">
<StackPanel Orientation="Vertical" DockPanel.Dock="Left">
<TextBlock Margin="0,0,0,10" Text="{DynamicResource Settings.Theme}"/>
<hc:ButtonGroup>
<RadioButton IsChecked="{Binding ShouldUseLightTheme}" Content="{DynamicResource Settings.ThemeLight}"/>
<RadioButton IsChecked="{Binding ShouldUseAutoTheme}" Content="{DynamicResource Settings.ThemeAuto}"/>
<RadioButton IsChecked="{Binding ShouldUseDarkTheme}" Content="{DynamicResource Settings.ThemeDark}"/>
</hc:ButtonGroup>
</StackPanel>-->
</DockPanel>
</StackPanel>
</DockPanel>-->

</StackPanel>
</TabItem>
Expand Down
2 changes: 2 additions & 0 deletions src/AutumnBox.GUI/create_build_info.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ $FilePath = [System.IO.Path]::Combine($OutDir,"build.ini");

#Content
$Now = [System.DateTime]::Now.ToString("yyyy/MM/dd HH:mm:ss")
$Version= [System.DateTime]::Now.ToString("yyyy.MM")
$Commit = git rev-parse HEAD
$LatestTag = git describe --abbrev=0 --tags
$Content="[Build]
datetime=$Now
commit=$Commit
tag=$LatestTag
version=$Version
"
#Write to file
$fs = [System.IO.FileStream]::new($FilePath,[System.IO.FileMode]::OpenOrCreate);
Expand Down

0 comments on commit 1cd5c5d

Please sign in to comment.