Skip to content

Commit a503243

Browse files
authored
Merge pull request #980 from BeyondDimension/develop
v2.6.5 RC4
2 parents 8a6ecf9 + 405352f commit a503243

File tree

8 files changed

+110
-142
lines changed

8 files changed

+110
-142
lines changed

src/AboutAppInfoPopup.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,18 @@ static string GetJavaSystemGetProperty(string propertyKey)
414414
// b.Append(DeviceSecurityCheckUtil.IsEmulator.ToLowerString());
415415
// b.AppendLine();
416416
//}
417-
b.Append("[device.gl.renderer] ");
418-
b.Append(GLES20.GlGetString(GLES20.GlRenderer) ?? "");
419-
b.AppendLine();
420-
b.Append("[device.gl.vendor] ");
421-
b.Append(GLES20.GlGetString(GLES20.GlVendor) ?? "");
422-
b.AppendLine();
423-
b.Append("[device.gl.version] ");
424-
b.Append(GLES20.GlGetString(GLES20.GlVersion) ?? "");
425-
b.AppendLine();
426-
b.Append("[device.gl.extensions] ");
427-
b.Append(GLES20.GlGetString(GLES20.GlExtensions) ?? "");
428-
b.AppendLine();
417+
//b.Append("[device.gl.renderer] ");
418+
//b.Append(GLES20.GlGetString(GLES20.GlRenderer) ?? "");
419+
//b.AppendLine();
420+
//b.Append("[device.gl.vendor] ");
421+
//b.Append(GLES20.GlGetString(GLES20.GlVendor) ?? "");
422+
//b.AppendLine();
423+
//b.Append("[device.gl.version] ");
424+
//b.Append(GLES20.GlGetString(GLES20.GlVersion) ?? "");
425+
//b.AppendLine();
426+
//b.Append("[device.gl.extensions] ");
427+
//b.Append(GLES20.GlGetString(GLES20.GlExtensions) ?? "");
428+
//b.AppendLine();
429429
b.Append("[device.biometric] ");
430430
b.Append(IBiometricService.Instance.IsSupportedAsync().Result.ToLowerString());
431431
b.AppendLine();

src/Common.ClientLib.Droid/Application/Security/DeviceSecurityCheckUtil.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,28 @@
267267
// newRating++;
268268
// }
269269

270-
// try
271-
// {
272-
// var opengl = Android.Opengl.GLES20.GlGetString(Android.Opengl.GLES20.GlRenderer);
273-
// if (!string.IsNullOrWhiteSpace(opengl))
274-
// {
275-
//#pragma warning disable CS8604 // 可能的 null 引用参数。
276-
// if (contains(opengl, "Bluestacks") ||
277-
// contains(opengl, "Translator") ||
278-
// contains(opengl, "youwave")
279-
// )
280-
//#pragma warning restore CS8604 // 可能的 null 引用参数。
281-
// newRating += 10;
282-
// }
283-
// }
284-
// catch
285-
// {
286-
// }
270+
/* signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdd0
271+
* Cause: null pointer dereference
272+
* backtrace:
273+
* #00 pc 0000000000005ff4 /system/lib64/libGLESv1_CM.so (glGetString+52)
274+
*/
275+
//// try
276+
//// {
277+
//// var opengl = Android.Opengl.GLES20.GlGetString(Android.Opengl.GLES20.GlRenderer);
278+
//// if (!string.IsNullOrWhiteSpace(opengl))
279+
//// {
280+
////#pragma warning disable CS8604 // 可能的 null 引用参数。
281+
//// if (contains(opengl, "Bluestacks") ||
282+
//// contains(opengl, "Translator") ||
283+
//// contains(opengl, "youwave")
284+
//// )
285+
////#pragma warning restore CS8604 // 可能的 null 引用参数。
286+
//// newRating += 10;
287+
//// }
288+
//// }
289+
//// catch
290+
//// {
291+
//// }
287292

288293
// try
289294
// {

src/Common.ClientLib/Application/Services/Implementation/PreferencesPlatformServiceImpl.cs

Lines changed: 16 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
using System.Application.Entities;
33
using System.Application.Repositories;
44
using System.Diagnostics;
5-
using System.Diagnostics.CodeAnalysis;
65
using System.Globalization;
7-
using NotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
86
using SQLiteNotNull = SQLite.NotNullAttribute;
97
using SQLiteTable = SQLite.TableAttribute;
108

@@ -26,93 +24,33 @@ static string GetId(string key, string? sharedName)
2624
if (sharedName == null) return GetId(key);
2725
return $"{key}_{sharedName}_S";
2826
}
29-
3027
public void PlatformClear(string? sharedName)
3128
{
32-
if (sharedName == null)
33-
{
34-
conn.Execute(Sql_Delete_All);
35-
}
36-
else
37-
{
38-
conn.Execute(Sql_Delete_Where_SharedName_Equals, sharedName);
39-
}
29+
conn.Execute(Sql_Delete_Where_SharedName_Equals, sharedName ?? string.Empty);
4030
}
4131

42-
//public void PlatformClear(string? sharedName)
43-
//{
44-
// if (sharedName == null)
45-
// {
46-
// conn.DeleteAll<Entity>();
47-
// }
48-
// else
49-
// {
50-
// var items = conn.Table<Entity>().Where(x => x.SharedName == sharedName).ToArray();
51-
// foreach (var item in items)
52-
// {
53-
// conn.Delete(item);
54-
// }
55-
// }
56-
//}
57-
58-
//public bool PlatformContainsKey(string key, string? sharedName)
59-
//{
60-
// int r;
61-
// if (sharedName == null)
62-
// {
63-
// r = conn.Execute(Sql_Select_SharedName_Where_Key_Equals_And_SharedName_IsNull, GetId(key));
64-
// }
65-
// else
66-
// {
67-
// r = conn.Execute(Sql_Select_SharedName_Where_Key_Equals_And_SharedName_Equals, GetId(key, sharedName), sharedName);
68-
// }
69-
// return r > 0;
70-
//}
71-
7232
public bool PlatformContainsKey(string key, string? sharedName)
7333
{
7434
var id = GetId(key, sharedName);
75-
var item = conn.Table<Entity>().Where(x => x.Id == id && x.SharedName == sharedName).FirstOrDefault();
35+
sharedName ??= string.Empty;
36+
var item = conn.Table<Entity>()
37+
.Where(x => x.Id == id && x.SharedName == sharedName)
38+
.FirstOrDefault();
7639
return item != null;
7740
}
7841

79-
//public T? PlatformGet<T>(string key, T? defaultValue, string? sharedName) where T : notnull, IConvertible
80-
//{
81-
// string? r;
82-
// if (sharedName == null)
83-
// {
84-
// r = conn.ExecuteScalar<string?>(Sql_Select_Value_Where_Key_Equals_And_SharedName_IsNull, GetId(key));
85-
// }
86-
// else
87-
// {
88-
// r = conn.ExecuteScalar<string?>(Sql_Select_Value_Where_Key_Equals_And_SharedName_Equals, GetId(key, sharedName), sharedName);
89-
// }
90-
// if (r == null) return defaultValue;
91-
// var r2 = ConvertibleHelper.Convert<T>(r);
92-
// return r2;
93-
//}
94-
9542
public T? PlatformGet<T>(string key, T? defaultValue, string? sharedName) where T : notnull, IConvertible
9643
{
9744
var id = GetId(key, sharedName);
98-
var item = conn.Table<Entity>().Where(x => x.Id == id && x.SharedName == sharedName).FirstOrDefault();
45+
sharedName ??= string.Empty;
46+
var item = conn.Table<Entity>()
47+
.Where(x => x.Id == id && x.SharedName == sharedName)
48+
.FirstOrDefault();
9949
if (item == null) return defaultValue;
10050
var value = ConvertibleHelper.Convert<T>(item.Value);
10151
return value;
10252
}
10353

104-
//public void PlatformRemove(string key, string? sharedName)
105-
//{
106-
// if (sharedName == null)
107-
// {
108-
// conn.Execute(Sql_Delete_Where_Id_Equals_And_SharedName_IsNull, GetId(key));
109-
// }
110-
// else
111-
// {
112-
// conn.Execute(Sql_Delete_Where_Id_Equals_And_SharedName_Equals, GetId(key, sharedName), sharedName);
113-
// }
114-
//}
115-
11654
public void PlatformRemove(string key, string? sharedName)
11755
{
11856
var id = GetId(key, sharedName);
@@ -132,19 +70,16 @@ public void PlatformSet<T>(string key, T? value, string? sharedName) where T : n
13270
{
13371
Id = id,
13472
Value = value.ToString(CultureInfo.InvariantCulture),
135-
SharedName = sharedName,
73+
SharedName = sharedName ?? string.Empty,
13674
});
13775
}
13876
}
13977

140-
const string TableName = "0984415E";
78+
const string TableName = "1984415E";
14179
const string ColumnName_Id = "0F5E4BAA";
14280
const string ColumnName_Value = "4FC331D7";
14381
const string ColumnName_SharedName = "F6A739AA";
14482

145-
const string Sql_Delete_All =
146-
$"DELETE FROM \"{TableName}\"";
147-
14883
const string Sql_Delete_Where_SharedName_Equals =
14984
$"DELETE FROM \"{TableName}\" WHERE \"{ColumnName_SharedName}\" = ?";
15085

@@ -174,19 +109,18 @@ public sealed class Entity : IEntity<string>
174109
[Column(ColumnName_Id)]
175110
[PrimaryKey]
176111
[SQLiteNotNull]
177-
[NotNull, DisallowNull] // C# 8 not null
178-
public string? Id { get; set; }
112+
public string Id { get; set; } = string.Empty;
179113

180114
[Column(ColumnName_Value)]
181115
[SQLiteNotNull]
182-
[NotNull, DisallowNull] // C# 8 not null
183-
public string? Value { get; set; }
116+
public string Value { get; set; } = string.Empty;
184117
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
185118

186119
[Column(ColumnName_SharedName)]
187-
public string? SharedName { get; set; }
120+
[SQLiteNotNull]
121+
public string SharedName { get; set; } = string.Empty;
188122

189-
string DebuggerDisplay() => SharedName == null ? $"{Id}, {Value}" : $"{Id}, {Value}, {SharedName}";
123+
string DebuggerDisplay() => SharedName == string.Empty ? $"{Id}, {Value}" : $"{Id}, {Value}, {SharedName}";
190124
}
191125
}
192126
}

src/ST.Client.Android/Services/Implementation/AndroidDeviceInfoPlatformServiceImpl.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,28 @@ static bool _()
114114
newRating++;
115115
}
116116

117-
try
118-
{
119-
var opengl = Android.Opengl.GLES20.GlGetString(Android.Opengl.GLES20.GlRenderer);
120-
if (!string.IsNullOrWhiteSpace(opengl))
121-
{
122-
#pragma warning disable CS8604 // 可能的 null 引用参数。
123-
if (contains(opengl, "Bluestacks") ||
124-
contains(opengl, "Translator") ||
125-
contains(opengl, "youwave")
126-
)
127-
#pragma warning restore CS8604 // 可能的 null 引用参数。
128-
newRating += 10;
129-
}
130-
}
131-
catch
132-
{
133-
}
117+
/* signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdd0
118+
* Cause: null pointer dereference
119+
* backtrace:
120+
* #00 pc 0000000000005ff4 /system/lib64/libGLESv1_CM.so (glGetString+52)
121+
*/
122+
// try
123+
// {
124+
// var opengl = Android.Opengl.GLES20.GlGetString(Android.Opengl.GLES20.GlRenderer);
125+
// if (!string.IsNullOrWhiteSpace(opengl))
126+
// {
127+
//#pragma warning disable CS8604 // 可能的 null 引用参数。
128+
// if (contains(opengl, "Bluestacks") ||
129+
// contains(opengl, "Translator") ||
130+
// contains(opengl, "youwave")
131+
// )
132+
//#pragma warning restore CS8604 // 可能的 null 引用参数。
133+
// newRating += 10;
134+
// }
135+
// }
136+
// catch
137+
// {
138+
// }
134139

135140
try
136141
{

src/ST.Client/UI/ViewModels/MainWindowViewModel.TabItems.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,24 @@ partial class MainWindowViewModel
99
readonly Dictionary<Type, Lazy<TabItemViewModel>> mTabItems = new();
1010
public IEnumerable<TabItemViewModel> TabItems => mTabItems.Values.Select(x => x.Value);
1111

12-
public IReadOnlyList<TabItemViewModel>? FooterTabItems { get; private set; }
12+
IReadOnlyList<TabItemViewModel>? _FooterTabItems;
13+
public IReadOnlyList<TabItemViewModel>? FooterTabItems
14+
{
15+
get
16+
{
17+
if (_FooterTabItems == null)
18+
{
19+
var settingsPageVM = SettingsPageViewModel.Instance;
20+
var aboutPageVM = AboutPageViewModel.Instance;
21+
_FooterTabItems = new List<TabItemViewModel>
22+
{
23+
settingsPageVM,
24+
aboutPageVM,
25+
};
26+
}
27+
return _FooterTabItems;
28+
}
29+
}
1330

1431
public IEnumerable<TabItemViewModel> AllTabItems
1532
{
@@ -20,6 +37,18 @@ public IEnumerable<TabItemViewModel> AllTabItems
2037
}
2138
}
2239

40+
/// <summary>
41+
/// 当前 <see cref="AllTabItems"/>,延时加载 <see cref="FooterTabItems"/>
42+
/// </summary>
43+
public IEnumerable<TabItemViewModel> CurrentAllTabItems
44+
{
45+
get
46+
{
47+
if (_FooterTabItems == null) return TabItems;
48+
else return TabItems.Concat(_FooterTabItems);
49+
}
50+
}
51+
2352
void AddTabItem<TabItemVM>() where TabItemVM : TabItemViewModel, new()
2453
{
2554
Lazy<TabItemViewModel> value = new(() => new TabItemVM()

src/ST.Client/UI/ViewModels/MainWindowViewModel.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,14 @@ public MainWindowViewModel()
8888
});
8989
}
9090

91-
FooterTabItems = new List<TabItemViewModel>
92-
{
93-
SettingsPageViewModel.Instance,
94-
AboutPageViewModel.Instance,
95-
};
96-
9791
#region InitTabItems
9892

9993

10094
//AddTabItem<StartPageViewModel>();
10195
AddTabItem<CommunityProxyPageViewModel>();
102-
AddTabItem<ProxyScriptManagePageViewModel>();
10396
if (IApplication.IsDesktopPlatform)
10497
{
98+
AddTabItem<ProxyScriptManagePageViewModel>();
10599
AddTabItem<SteamAccountPageViewModel>();
106100
AddTabItem<GameListPageViewModel>();
107101
}
@@ -134,7 +128,7 @@ public MainWindowViewModel()
134128

135129
R.Subscribe(() =>
136130
{
137-
foreach (var item in AllTabItems)
131+
foreach (var item in CurrentAllTabItems)
138132
{
139133
item.RaisePropertyChanged(nameof(TabItemViewModelBase.Name));
140134
}

src/ST.Client/UI/ViewModels/Pages/CommunityProxyPageViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace System.Application.UI.ViewModels
1919
{
2020
public partial class CommunityProxyPageViewModel
2121
{
22-
readonly IHostsFileService hostsFileService = IHostsFileService.Instance;
22+
readonly IHostsFileService? hostsFileService;
2323
readonly IPlatformService platformService = IPlatformService.Instance;
2424

2525
public ReactiveCommand<Unit, Unit>? SetupCertificateCommand { get; }
@@ -58,6 +58,7 @@ public CommunityProxyPageViewModel()
5858

5959
if (IApplication.IsDesktopPlatform)
6060
{
61+
hostsFileService = IHostsFileService.Instance;
6162
SetupCertificateCommand = ReactiveCommand.Create(SetupCertificate_OnClick);
6263
DeleteCertificateCommand = ReactiveCommand.Create(DeleteCertificate_OnClick);
6364
EditHostsFileCommand = ReactiveCommand.Create(hostsFileService.OpenFile);

src/ST.Client/UI/ViewModels/Pages/Settings/SettingsPageViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public SettingsPageViewModel()
2828

2929
UpdateChannels = Enum2.GetAll<UpdateChannelType>();
3030

31-
SelectFont = R.Fonts.FirstOrDefault(x => x.Value == UISettings.FontName.Value);
32-
this.WhenValueChanged(x => x.SelectFont, false)
33-
.Subscribe(x => UISettings.FontName.Value = x.Value);
34-
3531
if (IApplication.IsDesktopPlatform)
3632
{
33+
SelectFont = R.Fonts.FirstOrDefault(x => x.Value == UISettings.FontName.Value);
34+
this.WhenValueChanged(x => x.SelectFont, false)
35+
.Subscribe(x => UISettings.FontName.Value = x.Value);
36+
3737
SelectImage_Click = ReactiveCommand.CreateFromTask(async () =>
3838
{
3939
FilePickerFileType fileTypes = new ValueTuple<string, string[]>[] {

0 commit comments

Comments
 (0)