-
Notifications
You must be signed in to change notification settings - Fork 113
DebugPage の実装 #178
DebugPage の実装 #178
Changes from 27 commits
92fb986
c22df7f
47f32e3
baa112f
516d974
adc6bfe
77209c1
e9bd943
239f33c
39e03a3
3857b4a
b8f90a3
9273bcb
80128f5
7d64bc3
4f594a2
8fbbc10
2185ec7
857bc1c
da3f2c1
051ab33
243a3d3
de97c2e
0bda3cf
489700c
24be80f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,6 +29,16 @@ public MainMenuModel SelectedMenuItem | |||||
public MenuPageViewModel(INavigationService navigationService) : base(navigationService) | ||||||
{ | ||||||
MenuItems = new ObservableCollection<MainMenuModel>(); | ||||||
#if DEBUG | ||||||
MenuItems.Add(new MainMenuModel() | ||||||
{ | ||||||
Icon = "\uf013", | ||||||
PageName = nameof(DebugPage), | ||||||
Title = "debug", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
IconColor = "#019AE8", | ||||||
TextColor = "#000" | ||||||
}); | ||||||
#endif | ||||||
Comment on lines
+32
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. デバッグ画面のカラムは一番下に置きましょう(あまり主張したくないので)。 |
||||||
MenuItems.Add(new MainMenuModel() | ||||||
{ | ||||||
Icon = "\uf965", | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,160 @@ | ||||||||||||||||||||||||||||||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||||||||||||||||||||||||||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||||||||||||||||||||||||||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
using System; | ||||||||||||||||||||||||||||||
using Acr.UserDialogs; | ||||||||||||||||||||||||||||||
using Covid19Radar.Services; | ||||||||||||||||||||||||||||||
using Prism.Navigation; | ||||||||||||||||||||||||||||||
using Xamarin.Forms; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
namespace Covid19Radar.ViewModels | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
public class DebugPageViewModel : ViewModelBase | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
private readonly IUserDataService userDataService; | ||||||||||||||||||||||||||||||
private readonly ITermsUpdateService termsUpdateService; | ||||||||||||||||||||||||||||||
private readonly IExposureNotificationService exposureNotificationService; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
private string _debugInfo; | ||||||||||||||||||||||||||||||
public string DebugInfo | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
get { return _debugInfo; } | ||||||||||||||||||||||||||||||
set { SetProperty(ref _debugInfo, value); } | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
public async void Info(string ex = "") | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. メソッド名は動詞から始めてください。また、 今回の場合、表示する情報を更新する役割のメソッドなので There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 引数名 |
||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
string os; | ||||||||||||||||||||||||||||||
switch (Device.RuntimePlatform) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
case Device.Android: | ||||||||||||||||||||||||||||||
os = "Android"; | ||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||
case Device.iOS: | ||||||||||||||||||||||||||||||
os = "iOS"; | ||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||
default: | ||||||||||||||||||||||||||||||
os = "unknown"; | ||||||||||||||||||||||||||||||
break; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Comment on lines
+27
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
#if DEBUG | ||||||||||||||||||||||||||||||
os += ",DEBUG"; | ||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||
#if USE_MOCK | ||||||||||||||||||||||||||||||
os += ",USE_MOCK"; | ||||||||||||||||||||||||||||||
#endif | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
// debug info for ./SplashPageViewModel.cs | ||||||||||||||||||||||||||||||
string agree; | ||||||||||||||||||||||||||||||
if (termsUpdateService.IsAllAgreed()) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
agree = "exists";// (mainly) navigate from SplashPage to HomePage | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||
var termsUpdateInfo = await termsUpdateService.GetTermsUpdateInfo(); | ||||||||||||||||||||||||||||||
if (termsUpdateService.IsReAgree(TermsType.TermsOfService, termsUpdateInfo)) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
agree += "-TermsOfService"; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
else if (termsUpdateService.IsReAgree(TermsType.PrivacyPolicy, termsUpdateInfo)) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
agree += "-PrivacyPolicy"; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Comment on lines
+52
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここは ここは「利用許諾」と「プライバシーポリシー」が更新されている経路だと理解しています。 一般的にデバッグ画面に到達したときにはすでプライバシーポリシーの再同意が行われている状態になるので、 |
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
agree = "not exists"; // navigate from SplashPage to TutorialPage1 | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. デバッグ画面に到達するには初期設定が必要と理解しているので、ここの経路に到達することはないかと思いますが、仮にこの経路があるとすれば、
Suggested change
|
||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
var ticks = exposureNotificationService.GetLastProcessTekTimestamp(AppSettings.Instance.SupportedRegions[0]); | ||||||||||||||||||||||||||||||
var dt = DateTimeOffset.FromUnixTimeMilliseconds(ticks).ToOffset(new TimeSpan(9, 0, 0)); | ||||||||||||||||||||||||||||||
//please check : offset is correct or not | ||||||||||||||||||||||||||||||
//cf: ../../../Covid19Radar.Android/Services/Logs/LogPeriodicDeleteServiceAndroid.cs | ||||||||||||||||||||||||||||||
var lastProcessTekTimestamp = dt.ToLocalTime().ToString("F"); | ||||||||||||||||||||||||||||||
Comment on lines
+67
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
また、取得した日時に対して
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
var exposureNotificationStatus = await Xamarin.ExposureNotifications.ExposureNotification.IsEnabledAsync(); | ||||||||||||||||||||||||||||||
var exposureNotificationMessage = await exposureNotificationService.UpdateStatusMessageAsync(); | ||||||||||||||||||||||||||||||
// ../../settings.json | ||||||||||||||||||||||||||||||
var str = new[] { "Build: " + os, "Ver: " + AppSettings.Instance.AppVersion, | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setting.json から設定される AppSettings.Instance.AppVersion,Write は、意味のない情報のようで、ログや、バージョンチェックで使われるのは, EssentialsService.AppVersion のようですね。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 表示するのは There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 文字列連結は + ではなく、 あと、 |
||||||||||||||||||||||||||||||
"Region: " + string.Join(",", AppSettings.Instance.SupportedRegions), "CdnUrl: " + AppSettings.Instance.CdnUrlBase, | ||||||||||||||||||||||||||||||
"ApiUrl: " + AppSettings.Instance.ApiUrlBase, "Agree: " + agree, "StartDate: " + userDataService.GetStartDate().ToLocalTime().ToString("F"), | ||||||||||||||||||||||||||||||
"DaysOfUse: " + userDataService.GetDaysOfUse(), "ExposureCount: " + exposureNotificationService.GetExposureCountToDisplay(), | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v1.2.4 に対応するため、GetExposureCountToDisplayにしました。 |
||||||||||||||||||||||||||||||
"LastProcessTek: " + lastProcessTekTimestamp, " (long): " + ticks, "ENstatus: " + exposureNotificationStatus, | ||||||||||||||||||||||||||||||
"ENmessage: " + exposureNotificationMessage, "Now: " + DateTime.Now.ToLocalTime().ToString("F"), ex}; | ||||||||||||||||||||||||||||||
DebugInfo = string.Join(Environment.NewLine, str); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
public DebugPageViewModel(INavigationService navigationService, IUserDataService userDataService, ITermsUpdateService termsUpdateService, IExposureNotificationService exposureNotificationService) : base(navigationService) | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 横に長くなっているので適切に改行+インデントをお願いします。 |
||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
Title = "Title:DebugPage"; | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Debug Pageでも良いかと思いましたが、開発者しか使わないことを考えると、よりシンプルに |
||||||||||||||||||||||||||||||
this.userDataService = userDataService; | ||||||||||||||||||||||||||||||
this.termsUpdateService = termsUpdateService; | ||||||||||||||||||||||||||||||
this.exposureNotificationService = exposureNotificationService; | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
public override void Initialize(INavigationParameters parameters) | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
base.Initialize(parameters); | ||||||||||||||||||||||||||||||
Info("Initialize"); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
public Command OnClickReload => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
Info("Reload"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
public Command OnClickStartExposureNotification => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
UserDialogs.Instance.ShowLoading("Starting ExposureNotification..."); | ||||||||||||||||||||||||||||||
var result = await exposureNotificationService.StartExposureNotification(); | ||||||||||||||||||||||||||||||
var str = $"StartExposureNotification: {result}"; | ||||||||||||||||||||||||||||||
UserDialogs.Instance.HideLoading(); | ||||||||||||||||||||||||||||||
await UserDialogs.Instance.AlertAsync(str, str, Resources.AppResources.ButtonOk); | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. アラートダイアログのタイトルと内容に同じ文字列を表示する意味はないと思います。 そうれば、ローカル変数strに値を取る必要もないと思います。 |
||||||||||||||||||||||||||||||
Info("StartExposureNotification"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
public Command OnClickFetchExposureKeyAsync => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
var exLog = "FetchExposureKeyAsync"; | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
また、Logもログを取ることに使っていないので付ける必要はなく、この変数名はシンプルに |
||||||||||||||||||||||||||||||
try { await exposureNotificationService.FetchExposureKeyAsync(); } | ||||||||||||||||||||||||||||||
catch (Exception ex) { exLog += $":Exception: {ex}"; } | ||||||||||||||||||||||||||||||
Info(exLog); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
// see ../Settings/SettingsPageViewModel.cs | ||||||||||||||||||||||||||||||
public Command OnClickStopExposureNotification => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
UserDialogs.Instance.ShowLoading("Stopping ExposureNotification..."); | ||||||||||||||||||||||||||||||
var result = await exposureNotificationService.StopExposureNotification(); | ||||||||||||||||||||||||||||||
string str = "StopExposureNotification: " + result.ToString(); | ||||||||||||||||||||||||||||||
UserDialogs.Instance.HideLoading(); | ||||||||||||||||||||||||||||||
await UserDialogs.Instance.AlertAsync(str, str, Resources.AppResources.ButtonOk); | ||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここも |
||||||||||||||||||||||||||||||
Info("StopExposureNotification"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
public Command OnClickRemoveStartDate => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
userDataService.RemoveStartDate(); | ||||||||||||||||||||||||||||||
Info("RemoveStartDate"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
public Command OnClickRemoveExposureInformation => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
exposureNotificationService.RemoveExposureInformation(); | ||||||||||||||||||||||||||||||
Info("RemoveExposureInformation"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
public Command OnClickRemoveConfiguration => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
exposureNotificationService.RemoveConfiguration(); | ||||||||||||||||||||||||||||||
Info("RemoveConfiguration"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
public Command OnClickRemoveLastProcessTekTimestamp => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
exposureNotificationService.RemoveLastProcessTekTimestamp(); | ||||||||||||||||||||||||||||||
Info("RemoveLastProcessTekTimestamp"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
public Command OnClickRemoveAllUpdateDate => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
termsUpdateService.RemoveAllUpdateDate(); | ||||||||||||||||||||||||||||||
Info("RemoveAllUpdateDate"); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
public Command OnClickQuit => new Command(async () => | ||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||
Application.Current.Quit(); | ||||||||||||||||||||||||||||||
DependencyService.Get<ICloseApplication>().closeApplication(); | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
本質的ではないのですが、虫Icon があるようですね。そちらにしたくなってきました。