Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

一部端末でBluetoothオフの際にBluetooth設定画面が表示できない件の対応 #1123

Merged
3 commits merged into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void NavigateAppSettings()
}
}

public void NavigateBluetoothSettings()
public bool NavigateBluetoothSettings()
{
_loggerService.StartMethod();
try
Expand All @@ -54,11 +54,13 @@ public void NavigateBluetoothSettings()
catch (Exception ex)
{
_loggerService.Exception("Failed navigate to bluetooth settings", ex);
return false;
}
finally
{
_loggerService.EndMethod();
}
return true;
}

public void NavigateLocationSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void NavigateAppSettings()
}
}

public void NavigateBluetoothSettings() => throw new PlatformNotSupportedException();
public bool NavigateBluetoothSettings() => throw new PlatformNotSupportedException();
public void NavigateLocationSettings() => throw new PlatformNotSupportedException();
}
}
18 changes: 18 additions & 0 deletions Covid19Radar/Covid19Radar/Resources/AppResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Covid19Radar/Covid19Radar/Resources/AppResources.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,14 @@
<value>接触記録のため、Bluetooth設定をオンにしてください。</value>
<comment>接触記録のため、Bluetooth設定をオンにしてください。</comment>
</data>
<data name="BluetoothSettingErrorDialogTitle" xml:space="preserve">
<value>設定画面を表示できません</value>
<comment>設定画面を表示できません</comment>
</data>
<data name="BluetoothSettingErrorDialogMessage" xml:space="preserve">
<value>COCOAから設定画面を開けませんでした。端末の設定からBluetoothを有効にしてください。</value>
<comment>COCOAから設定画面を開けませんでした。端末の設定からBluetoothを有効にしてください。</comment>
</data>
<data name="LocationOffWarningDialogMessage" xml:space="preserve">
<value>お使いのOSでは、接触通知を機能させるため、位置情報をオンに設定する必要があります。位置情報設定をオンにするか、Android11以上に更新してください。
なお、本アプリで利用者の位置情報を収集することはありません。</value>
Expand Down
8 changes: 8 additions & 0 deletions Covid19Radar/Covid19Radar/Resources/AppResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,14 @@ You do not have to request it yourself.</value>
<value>Turn on Bluetooth to record contacts with other users.</value>
<comment>接触記録のため、Bluetooth設定をオンにしてください。</comment>
</data>
<data name="BluetoothSettingErrorDialogTitle" xml:space="preserve">
<value>Settings cannot be displayed</value>
<comment>設定画面を表示できません</comment>
</data>
<data name="BluetoothSettingErrorDialogMessage" xml:space="preserve">
<value>COCOA cannot open Bluetooth settings. Please enable Bluetooth in your device's settings.</value>
<comment>COCOAから設定画面を開けませんでした。端末の設定からBluetoothを有効にしてください。</comment>
</data>
<data name="LocationOffWarningDialogMessage" xml:space="preserve">
<value>Your OS needs location services to be on for contact notifications to function. Turn location services on or update your device to Android 11 or later.
Note: this app does not collect users’ location information.</value>
Expand Down
8 changes: 8 additions & 0 deletions Covid19Radar/Covid19Radar/Resources/AppResources.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,14 @@
<value>为记录接触情况,请打开蓝牙。</value>
<comment>接触記録のため、Bluetooth設定をオンにしてください。</comment>
</data>
<data name="BluetoothSettingErrorDialogTitle" xml:space="preserve">
<value>无法显示设置画面</value>
<comment>設定画面を表示できません</comment>
</data>
<data name="BluetoothSettingErrorDialogMessage" xml:space="preserve">
<value>COCOA无法打开设置画面。请从手机设置中启用蓝牙。</value>
<comment>COCOAから設定画面を開けませんでした。端末の設定からBluetoothを有効にしてください。</comment>
</data>
<data name="LocationOffWarningDialogMessage" xml:space="preserve">
<value>您所使用的操作系统,只有打开GPS后才能使用接触通知的功能。请打开GPS,或将操作系统更新到Android 11以上的版本。
此外,本APP不会收集用户的位置信息。</value>
Expand Down
8 changes: 8 additions & 0 deletions Covid19Radar/Covid19Radar/Services/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ await AlertAsync(
AppResources.ButtonCancel);
}

public async Task ShowBluetoothSettingErrorAsync()
{
await AlertAsync(
AppResources.BluetoothSettingErrorDialogMessage,
AppResources.BluetoothSettingErrorDialogTitle,
AppResources.ButtonOk);
}

public async Task<bool> ShowLocationOffWarningAsync()
{
if (_essentialsService.IsIos)
Expand Down
1 change: 1 addition & 0 deletions Covid19Radar/Covid19Radar/Services/IDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IDialogService
{
Task<bool> ShowExposureNotificationOffWarningAsync();
Task<bool> ShowBluetoothOffWarningAsync();
Task ShowBluetoothSettingErrorAsync();
Task<bool> ShowLocationOffWarningAsync();
Task ShowTemporarilyUnavailableWarningAsync();
Task ShowHomePageUnknownErrorWaringAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Covid19Radar.Services
public interface IExternalNavigationService
{
void NavigateAppSettings();
void NavigateBluetoothSettings();
bool NavigateBluetoothSettings();
void NavigateLocationSettings();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@ INavigationParameters navigaitonParameters
bool isOK = await dialogService.ShowBluetoothOffWarningAsync();
if (isOK)
{
externalNavigationService.NavigateBluetoothSettings();
bool isSuccess = externalNavigationService.NavigateBluetoothSettings();
if (!isSuccess)
{
await dialogService.ShowBluetoothSettingErrorAsync();
}
}
}
else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ public async Task ShowLocationOffWarningTest_AndroidAsync()
mockUserDialogs.Verify(x => x.AlertAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), null), Times.Never());
}

[Fact]
public async Task ShowBluetoothSettingErrorAsyncTest()
{
var unitUnderTest = CraeteDialogService();
await unitUnderTest.ShowBluetoothSettingErrorAsync();

mockUserDialogs.Verify(x => x.AlertAsync(
AppResources.BluetoothSettingErrorDialogMessage,
AppResources.BluetoothSettingErrorDialogTitle,
AppResources.ButtonOk,
null),
Times.Once());
}

[Fact]
public void ShowLocationOffWarningTest_Ios()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,38 @@ public void OnClickCheckStopReasonCommandTest_StoppedReason_ExposureNotification
}

[Fact]
public void OnClickCheckStopReasonCommandTest_StoppedReason_BluetoothOff_OK()
public void OnClickCheckStopReasonCommandTest_StoppedReason_BluetoothOff_OK_Success()
{
var homePageViewModel = CreateViewModel();

mockExposureNotificationApiService
.Setup(x => x.GetStatusCodesAsync()).Returns(Task.FromResult(new List<int>() { ExposureNotificationStatus.Code_Android.BLUETOOTH_DISABLED } as IList<int>));
mockDialogService.Setup(x => x.ShowBluetoothOffWarningAsync()).ReturnsAsync(true);
mockExternalNavigationService.Setup(x => x.NavigateBluetoothSettings()).Returns(true);

homePageViewModel.OnClickCheckStopReason.Execute(null);

mockDialogService.Verify(x => x.ShowBluetoothOffWarningAsync(), Times.Once());
mockExternalNavigationService.Verify(x => x.NavigateBluetoothSettings(), Times.Once());
}

[Fact]
public void OnClickCheckStopReasonCommandTest_StoppedReason_BluetoothOff_OK_Failure()
{
var homePageViewModel = CreateViewModel();

mockExposureNotificationApiService
.Setup(x => x.GetStatusCodesAsync()).Returns(Task.FromResult(new List<int>() { ExposureNotificationStatus.Code_Android.BLUETOOTH_DISABLED } as IList<int>));
mockDialogService.Setup(x => x.ShowBluetoothOffWarningAsync()).ReturnsAsync(true);
mockExternalNavigationService.Setup(x => x.NavigateBluetoothSettings()).Returns(false);

homePageViewModel.OnClickCheckStopReason.Execute(null);

mockDialogService.Verify(x => x.ShowBluetoothOffWarningAsync(), Times.Once());
mockExternalNavigationService.Verify(x => x.NavigateBluetoothSettings(), Times.Once());
mockDialogService.Verify(x => x.ShowBluetoothSettingErrorAsync(), Times.Once());
}

[Fact]
public void OnClickCheckStopReasonCommandTest_StoppedReason_BluetoothOff_Cancel()
{
Expand Down