Skip to content

Commit

Permalink
Fix bluetooth and autostart issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePBone committed Jul 4, 2020
1 parent 987933b commit 63076ac
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
66 changes: 47 additions & 19 deletions Galaxy Buds Client/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,6 @@ public MainWindow()

InitializeComponent();

BluetoothWin32Events.GetInstance().InRange +=
delegate (object sender, BluetoothWin32RadioInRangeEventArgs args)
{
if (GetRegisteredDevice() != null && GetRegisteredDevice() == args.Device.DeviceAddress)
{
if (!BluetoothService.Instance.IsConnected && _connectionLostPage != null)
ConnectionLostPageOnRetryRequested(this, new EventArgs());
}
};

_tbi = new TaskbarIcon();
Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/icon_white.ico"))?.Stream;
_tbi.Icon = new Icon(iconStream);
Expand Down Expand Up @@ -140,6 +130,16 @@ public MainWindow()
});
_address = savedAddress;
}

BluetoothWin32Events.GetInstance().InRange +=
delegate (object sender, BluetoothWin32RadioInRangeEventArgs args)
{
if (GetRegisteredDevice() != null && GetRegisteredDevice() == args.Device.DeviceAddress)
{
if (!BluetoothService.Instance.IsConnected && _connectionLostPage != null)
ConnectionLostPageOnRetryRequested(this, new EventArgs());
}
};
}

private void OnClosing(object sender, CancelEventArgs e)
Expand Down Expand Up @@ -261,6 +261,14 @@ private void InstanceOnStatusUpdate(object sender, StatusUpdateParser e)
}
private void InstanceOnSocketException(object sender, SocketException e)
{
if (PageControl == null)
return;
if (_connectionLostPage == null)
return;
if (PageControl.CurrentPage != null && (PageControl.CurrentPage.GetType() == typeof(WelcomePage)
|| PageControl.CurrentPage.GetType() == typeof(DeviceSelectPage)))
return;

if (e != null)
try
{
Expand All @@ -274,30 +282,50 @@ private void InstanceOnSocketException(object sender, SocketException e)
GenerateTrayContext();

_connectionLostPage.Reset();
if (PageControl.CurrentPage.GetType() != typeof(ConnectionLostPage)
&& PageControl.CurrentPage.GetType() != typeof(WelcomePage)
&& PageControl.CurrentPage.GetType() != typeof(DeviceSelectPage))
if (PageControl.CurrentPage == null)
{
Dispatcher.Invoke(() =>
{
PageControl.TransitionType = PageTransitionType.Fade;
PageControl.ShowPage(_connectionLostPage);
});
{
PageControl.TransitionType = PageTransitionType.Fade;
PageControl.ShowPage(_connectionLostPage);
});
}
else
{
if (PageControl.CurrentPage.GetType() != typeof(ConnectionLostPage)
&& PageControl.CurrentPage.GetType() != typeof(WelcomePage)
&& PageControl.CurrentPage.GetType() != typeof(DeviceSelectPage))
{
Dispatcher.Invoke(() =>
{
PageControl.TransitionType = PageTransitionType.Fade;
PageControl.ShowPage(_connectionLostPage);
});
}
}
}
private void InstanceOnPlatformNotSupportedException(object sender, PlatformNotSupportedException e)
{
Dispatcher.Invoke(() =>
{
MessageBox.Show("No bluetooth adapter found.\nPlease enable bluetooth and try again.",
var m = MessageBox.Show("No bluetooth adapter found.\nPlease enable bluetooth and try again.",
"Galaxy Buds Manager", MessageBoxButton.OK, MessageBoxImage.Error);
Close();
Environment.Exit(0);
});
}
private void InstanceOnInvalidDataException(object sender, InvalidDataException e)
{
Dispatcher.Invoke(() =>
{
if (_mainPage == null)
{
Task.Delay(500).ContinueWith(delegate
{
BluetoothService.Instance.Connect(GetRegisteredDevice(), GetRegisteredDeviceModel());
});
return;
}
GenerateTrayContext();
BluetoothService.Instance.Disconnect();
_mainPage.SetWarning(true, $"Received corrupted data. Reconnecting... ({e.Message})");
Expand Down
4 changes: 2 additions & 2 deletions Galaxy Buds Client/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyVersion("2.0.2.0")]
[assembly: AssemblyFileVersion("2.0.2.0")]
2 changes: 1 addition & 1 deletion InstallerDefinition.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Galaxy Buds Manager (Unofficial)"
!define PRODUCT_VERSION "2.0.0"
!define PRODUCT_VERSION "2.0.1"
!define PRODUCT_PUBLISHER "ThePBone"
!define PRODUCT_WEB_SITE "https://github.com/ThePBone/GalaxyBudsClient"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Galaxy Buds Client.exe"
Expand Down
Binary file added Setup_GalaxyBudsManager_2.0.1.exe
Binary file not shown.

0 comments on commit 63076ac

Please sign in to comment.