Skip to content

Commit

Permalink
fix Android ThirdPartyLoginHelper.StartServer catch & update android …
Browse files Browse the repository at this point in the history
…screenshot & fix NotificationServiceImpl
  • Loading branch information
AigioL committed Apr 2, 2022
1 parent 5179ad8 commit 2f76b78
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
Binary file modified resources/screenshot-android.en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/screenshot-android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/screenshots.en.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/screenshots.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/ST.Client.Android/UI/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Android.Runtime;
using System.Application.UI.Resx;
using System.Application.UI.ViewModels;
using System.Application.Mvvm;
using System.Diagnostics;
using System.Text;
using Xamarin.Essentials;
Expand Down Expand Up @@ -250,7 +251,7 @@ void OnActivityStateChanged(object? sender, ActivityStateChangedEventArgs e)
const AppTheme _DefaultActualTheme = AppTheme.Light;
AppTheme IApplication.DefaultActualTheme => _DefaultActualTheme;

public bool IsRuntimeSwitchXFAppTheme { get; set; } = true;
//public bool IsRuntimeSwitchXFAppTheme { get; set; } = true;

#region AppTheme

Expand Down Expand Up @@ -340,7 +341,7 @@ public AppTheme RealTheme

readonly CompositeDisposable compositeDisposable = new();

CompositeDisposable IApplication.CompositeDisposable => compositeDisposable;
ICollection<IDisposable> IDisposableHolder.CompositeDisposable => compositeDisposable;

#endregion

Expand Down
21 changes: 15 additions & 6 deletions src/ST.Client/Services/Implementation/NotificationServiceImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
using System.Text;
using System.Windows;
using static System.Application.Services.INotificationService;
using System.Runtime.Versioning;

namespace System.Application.Services.Implementation
{
/// <inheritdoc cref="INotificationService"/>
internal sealed class NotificationServiceImpl : INotificationService
{
readonly NotifyIcon notifyIcon;
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("linux")]
static NotifyIcon? NotifyIcon => DI.Get_Nullable<NotifyIcon>();

public NotificationServiceImpl(NotifyIcon notifyIcon)
public NotificationServiceImpl()
{
this.notifyIcon = notifyIcon;
}

bool INotificationService<NotificationType, Entrance, INotificationService>.AreNotificationsEnabled() => true;
Expand All @@ -22,15 +25,19 @@ void INotificationService<NotificationType, Entrance, INotificationService>.Canc
{
if (OperatingSystem2.IsWindows && NotifyIconHelper.IsInitialized)
{
notifyIcon.HideBalloonTip();
#pragma warning disable CA1416 // 验证平台兼容性
NotifyIcon?.HideBalloonTip();
#pragma warning restore CA1416 // 验证平台兼容性
}
}

void INotificationService<NotificationType, Entrance, INotificationService>.CancelAll()
{
if (OperatingSystem2.IsWindows && NotifyIconHelper.IsInitialized)
{
notifyIcon.HideBalloonTip();
#pragma warning disable CA1416 // 验证平台兼容性
NotifyIcon?.HideBalloonTip();
#pragma warning restore CA1416 // 验证平台兼容性
}
}

Expand All @@ -40,7 +47,9 @@ void INotificationService<NotificationType, Entrance, INotificationService>.Noti
{
title ??= ThisAssembly.AssemblyTrademark;
// 调用托盘显示通知
notifyIcon.ShowBalloonTip(title, text, ToolTipIcon.None);
#pragma warning disable CA1416 // 验证平台兼容性
NotifyIcon?.ShowBalloonTip(title, text, ToolTipIcon.None);
#pragma warning restore CA1416 // 验证平台兼容性
}
}

Expand Down
17 changes: 11 additions & 6 deletions src/ST.Client/UI/IApplication.Desktop.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Application.Models;
using System.Application.Mvvm;
using System.Collections.Generic;
Expand Down Expand Up @@ -36,14 +35,20 @@ void SetTopmostOneTime() { }
/// </summary>
IReadOnlyDictionary<string, ICommand> NotifyIconMenus { get; }

new CompositeDisposable CompositeDisposable { get; }

ICollection<IDisposable> IDisposableHolder.CompositeDisposable => CompositeDisposable;

/// <summary>
/// 是否有活动窗口
/// </summary>
/// <returns></returns>
bool HasActiveWindow();
}
}

#if NET6_0_OR_GREATER
// 接口默认实现在 Xamarin.Android 上不可用,将引发 Java.Lang.AbstractMethodError: Exception of type 'Java.Lang.AbstractMethodError' was thrown.
partial interface IApplication
{
new CompositeDisposable CompositeDisposable { get; }

ICollection<IDisposable> IDisposableHolder.CompositeDisposable => CompositeDisposable;
}
#endif
}

0 comments on commit 2f76b78

Please sign in to comment.