From: chaehee-hong Date: Wed, 12 Oct 2022 08:33:46 +0000 (+0900) Subject: Add hidden connect and WPS connect X-Git-Tag: accepted/tizen/unified/20221216.024031~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d833f4aef478f85b26d01fe26e72f037127a27b1;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-wifi.git Add hidden connect and WPS connect Change-Id: I7695505e38460b0508722e6ffb3b865d72c800a4 --- diff --git a/SettingWiFi/SettingWiFi/controller/WiFi.cs b/SettingWiFi/SettingWiFi/controller/WiFi.cs index 9e60a8a..09c14a1 100755 --- a/SettingWiFi/SettingWiFi/controller/WiFi.cs +++ b/SettingWiFi/SettingWiFi/controller/WiFi.cs @@ -19,6 +19,7 @@ namespace SettingWiFi public class WiFi { IEnumerable apList = new List(); + IEnumerable specificAPList = new List(); private event EventHandler wifiStateChanged = null; @@ -94,7 +95,6 @@ namespace SettingWiFi { Debug("Fail to connect" + e.ToString()); } - } public Task Disconnect(string essid) @@ -120,6 +120,62 @@ namespace SettingWiFi ap.ForgetAP(); } + public async Task ScanSpecificAP(string essid) + { + Debug("WiFi.ScanSpecificAP"); + try + { + await WiFiManager.ScanSpecificAPAsync(essid); + } + catch (Exception e) + { + Debug("Fail to scan specific AP " + e.ToString()); + } + } + + public List GetSpecificScanResult() + { + Debug("WiFi.GetSpecificScanResult"); + try + { + specificAPList = WiFiManager.GetFoundSpecificAPs(); + return GetSpecificAPList(); + } + catch (Exception e) + { + Debug("Fail to get scan result " + e.ToString()); + } + + return null; + } + + public async Task ConnectWps(AP ap, string pin) + { + Debug("WiFi.ConnectWps"); + WiFiAP wifiAP = FindAP(ap.Essid); + if (wifiAP == null) + { + Debug("Cannot find " + ap.Essid); + return; + } + + try + { + if (pin == null) + { + await wifiAP.ConnectWpsAsync(new WpsPbcInfo()); + } + else + { + await wifiAP.ConnectWpsAsync(new WpsPinInfo(pin)); + } + } + catch (Exception e) + { + Debug("Fail to connect" + e.ToString()); + } + } + private WiFiAP FindAP(string essid) { Debug("WiFi.FindAP"); @@ -132,7 +188,6 @@ namespace SettingWiFi return item; } } - return null; } @@ -153,6 +208,12 @@ namespace SettingWiFi return WiFiManager.GetConnectedAP().NetworkInformation.Essid; } + public string GetConnectionState() + { + Debug("WiFi.GetConnectionState"); + return WiFiManager.ConnectionState.ToString(); + } + public List GetAPList() { Debug("WiFi.GetAPList"); @@ -242,5 +303,48 @@ namespace SettingWiFi get; set; } + + public List GetSpecificAPList() + { + Debug("WiFi.GetSpecificAPList"); + List apInfoList = new List(); + foreach (var item in specificAPList) + { + Debug("AP name: " + item.NetworkInformation.Essid); + Debug("AP connection state: " + item.NetworkInformation.ConnectionState.ToString()); + + string securityType = item.SecurityInformation.SecurityType.ToString(); + bool isWpsSupported = item.SecurityInformation.IsWpsSupported; + + if (item.NetworkInformation.ConnectionState.ToString().Equals(Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS)) + { + apInfoList.Add(new AP(item.NetworkInformation.Essid, Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS, securityType, isWpsSupported)); + continue; + } + + string text = ""; + + if (securityType.Equals(Resources.IDS_ST_BODY_NONE)) + { + text = Resources.IDS_WIFI_POP_OPEN; + } + else if (securityType.Equals(Resources.IDS_WIFI_BODY_EAP)) + { + text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY + " (Eap)"; + } + else if (isWpsSupported) + { + text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY + " (WPS available)"; + } + else + { + text = Resources.IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY; + } + + apInfoList.Add(new AP(item.NetworkInformation.Essid, text, securityType, isWpsSupported)); + } + + return apInfoList; + } } } diff --git a/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs b/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs index 329eea9..fbcae5a 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs @@ -140,5 +140,131 @@ namespace SettingWiFi.res.locale { return ResourceManager.GetString("IDS_ST_BODY_SECURED_ABB_M_WIFI_AP_SUMMARY", resourceCulture); } } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK { + get { + return ResourceManager.GetString("IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_ST_BODY_NETWORK_SSID { + get { + return ResourceManager.GetString("IDS_ST_BODY_NETWORK_SSID", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_SK_CANCEL { + get { + return ResourceManager.GetString("IDS_WIFI_SK_CANCEL", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_COM_BODY_FIND { + get { + return ResourceManager.GetString("IDS_COM_BODY_FIND", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_POP_PRESS_WPS_ON_YOUR_WI_FI_ACCESS_POINT_WITHIN_PD_MINUTES { + get { + return ResourceManager.GetString("IDS_WIFI_POP_PRESS_WPS_ON_YOUR_WI_FI_ACCESS_POINT_WITHIN_PD_MINUTES", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_BUTTON_WPS_BUTTON { + get { + return ResourceManager.GetString("IDS_WIFI_BUTTON_WPS_BUTTON", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_SK_WPS_PIN { + get { + return ResourceManager.GetString("IDS_WIFI_SK_WPS_PIN", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_HEADER_SELECT_WPS_METHOD_ABB { + get { + return ResourceManager.GetString("IDS_WIFI_HEADER_SELECT_WPS_METHOD_ABB", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_BODY_CONNECT { + get { + return ResourceManager.GetString("IDS_WIFI_BODY_CONNECT", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_OPT_WPS { + get { + return ResourceManager.GetString("IDS_WIFI_OPT_WPS", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_BODY_WI_FI { + get { + return ResourceManager.GetString("IDS_WIFI_BODY_WI_FI", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_BUTTON_SCAN { + get { + return ResourceManager.GetString("IDS_WIFI_BUTTON_SCAN", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_ST_BODY_ENTER_THE_P1SS_PIN_ON_YOUR_WI_FI_ROUTER_THE_SETUP_CAN_TAKE_UP_TO_P2SD_MINUTES_TO_COMPLETE { + get { + return ResourceManager.GetString("IDS_ST_BODY_ENTER_THE_P1SS_PIN_ON_YOUR_WI_FI_ROUTER_THE_SETUP_CAN_TAKE_UP_TO_P2SD_MINUTES_TO_COMPLETE", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_HEADER_PASSWORD { + get { + return ResourceManager.GetString("IDS_WIFI_HEADER_PASSWORD", resourceCulture); + } + } } } diff --git a/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx b/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx index dfac5ec..c414f7a 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx @@ -123,9 +123,6 @@ Connecting... - - Connected - Wi-Fi network info @@ -147,4 +144,46 @@ Secured + + Find hidden network + + + Network SSID + + + Cancel + + + Find + + + Press WPS on your Wi-Fi access point within {0} minutes. + + + WPS button + + + WPS PIN + + + Select WPS method + + + Connect + + + WPS + + + Wi-Fi + + + Scan + + + Enter the {0} PIN on your Wi-Fi router. The setup can take up to {1} minutes to complete. + + + Password + \ No newline at end of file diff --git a/SettingWiFi/SettingWiFi/res/locale/Resources.ko-KR.resx b/SettingWiFi/SettingWiFi/res/locale/Resources.ko-KR.resx index 63405a2..dee3005 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.ko-KR.resx +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.ko-KR.resx @@ -144,4 +144,46 @@ 보안 + + 숨겨진 네트워크 찾기 + + + 네트워크 이름 + + + 취소 + + + 찾기 + + + Wi-Fi 액세스 포인트에서 %d분 안에 WPS 버튼을 누르세요. + + + WPS 버튼 + + + WPS PIN + + + WPS 방식 선택 + + + 연결 + + + WPS + + + Wi-Fi + + + 찾기 + + + Wi-Fi 공유기에 PIN{0}을 입력하세요. 설정을 완료하기까지 최대 {1}분이 소요됩니다. + + + 비밀번호 + \ No newline at end of file diff --git a/SettingWiFi/SettingWiFi/res/locale/Resources.resx b/SettingWiFi/SettingWiFi/res/locale/Resources.resx index afb697d..0106462 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.resx +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.resx @@ -144,4 +144,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SettingWiFi/SettingWiFi/view/ConnectPage.cs b/SettingWiFi/SettingWiFi/view/ConnectPage.cs index e27158f..bb8a8d8 100644 --- a/SettingWiFi/SettingWiFi/view/ConnectPage.cs +++ b/SettingWiFi/SettingWiFi/view/ConnectPage.cs @@ -1,3 +1,4 @@ +using System; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -32,9 +33,14 @@ namespace SettingWiFi HeightSpecification = 100, }; + var passwordItem = new DefaultLinearItem(); + var wpsButtonItem = new DefaultLinearItem(); + var passwordField = new TextField() { WidthSpecification = 400, + BackgroundColor = Color.Grey, + PlaceholderText = Resources.IDS_WIFI_HEADER_PASSWORD, }; var hiddenInput = new Tizen.NUI.Text.HiddenInput(); @@ -44,24 +50,27 @@ namespace SettingWiFi hiddenInput.ShowLastCharacterDuration = 1000; passwordField.SetHiddenInput(hiddenInput); - connectView.Add(passwordField); + var wpsButton = new Button() + { + Text = Resources.IDS_WIFI_OPT_WPS, + }; + wpsButton.Clicked += OnWpsClicked; + + passwordItem.Add(passwordField); + wpsButtonItem.Add(wpsButton); - var item = new DefaultLinearItem(); - connectView.Add(item); + connectView.Add(passwordItem); + connectView.Add(wpsButtonItem); var cancelButton = new Button() { - Text = "Cancel", - WidthSpecification = 300, - HeightSpecification = 80, + Text = Resources.IDS_WIFI_SK_CANCEL, }; cancelButton.Clicked += OnCancelClicked; var connectButton = new Button() { - Text = "Connect", - WidthSpecification = 300, - HeightSpecification = 80, + Text = Resources.IDS_WIFI_BODY_CONNECT, }; connectButton.Clicked += OnConnectClicked; @@ -78,6 +87,13 @@ namespace SettingWiFi Navigator.Pop(); } + private void OnWpsClicked(object source, ClickedEventArgs args) + { + var page = new WpsConnectPage(mWifi); + page.CreateComponents(mAp); + Navigator.Push(page); + } + private void OnConnectClicked(object source, ClickedEventArgs args) { Connect(); diff --git a/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs b/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs new file mode 100644 index 0000000..faadd4a --- /dev/null +++ b/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs @@ -0,0 +1,120 @@ +using System.Collections.Generic; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using SettingWiFi.res.locale; +using static SettingWiFi.Logger; + +namespace SettingWiFi +{ + internal class HiddenConnectPage : ContentPage + { + private WiFi mWifi; + private APSource mApSource; + + internal HiddenConnectPage(WiFi wifi) + { + mWifi = wifi; + } + + internal void CreateComponents(APSource apSource) + { + mApSource = apSource; + + var findView = new View() + { + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + WidthSpecification = 200, + HeightSpecification = 100, + }; + + var ssidField = new TextField() + { + Text = Resources.IDS_ST_BODY_NETWORK_SSID, + WidthSpecification = 400, + }; + + // todo: add text input + var input = "dnet_sn"; + + findView.Add(ssidField); + + var item = new DefaultLinearItem(); + findView.Add(item); + + var cancelButton = new Button() + { + Text = Resources.IDS_WIFI_SK_CANCEL, + WidthSpecification = 300, + HeightSpecification = 80, + }; + cancelButton.Clicked += (object source, ClickedEventArgs args) => + { + Navigator.Pop(); + }; + + var findButton = new Button() + { + Text = Resources.IDS_COM_BODY_FIND, + WidthSpecification = 300, + HeightSpecification = 80, + }; + findButton.Clicked += (object source, ClickedEventArgs args) => + { + if (mWifi.IsActive()) + { + ConnectSpecificAP(input); + } + }; + + Content = new AlertDialog() + { + Title = Resources.IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK, + Content = findView, + Actions = new View[] { cancelButton, findButton }, + }; + } + + private async void ConnectSpecificAP(string essid) + { + await mWifi.ScanSpecificAP(essid); + + List apList = mWifi.GetSpecificScanResult(); + if (apList.Count == 0) + { + Navigator.Pop(); + return; + } + + // todo: locate on the bottom of the scan list + //if (apList.Count > 1) + //{ + // Navigator.Pop(); + // return; + //} + + foreach (var item in apList) + { + if (item.SecType.Equals(Resources.IDS_WIFI_POP_OPEN)) + { + await mWifi.Connect(item.Essid, null); + } + else + { + Navigator.Push(CreateConnectPage(item)); + } + break; + } + } + + private DialogPage CreateConnectPage(AP ap) + { + var page = new ConnectPage(mWifi); + page.CreateComponents(ap); + return page; + } + } +} \ No newline at end of file diff --git a/SettingWiFi/SettingWiFi/view/MainPage.cs b/SettingWiFi/SettingWiFi/view/MainPage.cs index 5d9209b..130413f 100644 --- a/SettingWiFi/SettingWiFi/view/MainPage.cs +++ b/SettingWiFi/SettingWiFi/view/MainPage.cs @@ -15,7 +15,6 @@ namespace SettingWiFi CollectionView mScanList; ContentPage mInfoPage; - ContentPage mMorePage; DialogPage mConnectPage; WiFi mWifi; @@ -39,12 +38,11 @@ namespace SettingWiFi }; MenuItem[] menuItems = new MenuItem[itemCount]; - menuItems[0] = new MenuItem() { Text = "Add WiFi network" }; + menuItems[0] = new MenuItem() { Text = Resources.IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK }; menuItems[0].SelectedChanged += (object sender, SelectedChangedEventArgs args) => { + Navigator.Push(CreateHiddenConnectPage()); var menuItem = sender as MenuItem; - mMorePage = CreateMorePage(); - Navigator.Push(mMorePage); }; moreButton.Clicked += (object sender, ClickedEventArgs args) => @@ -61,7 +59,7 @@ namespace SettingWiFi var appBar = new AppBar() { - Title = "Wi-Fi", + Title = Resources.IDS_WIFI_BODY_WI_FI, Actions = new View[] { moreButton, }, }; @@ -113,7 +111,7 @@ namespace SettingWiFi var header = GetHeader(); var scanButton = new Button() { - Text = "Scan", + Text = Resources.IDS_WIFI_BUTTON_SCAN, WidthSpecification = 300, HeightSpecification = 80, }; @@ -197,7 +195,7 @@ namespace SettingWiFi var toggle = new DefaultLinearItem() { WidthSpecification = LayoutParamPolicies.MatchParent, - Text = "Wi-Fi", + Text = Resources.IDS_WIFI_BODY_WI_FI, IsSelectable = false, }; toggle.Label.HorizontalAlignment = HorizontalAlignment.Begin; @@ -221,10 +219,10 @@ namespace SettingWiFi return page; } - private ContentPage CreateMorePage() + private ContentPage CreateHiddenConnectPage() { - var page = new MorePage(mWifi); - page.CreateComponents(); + var page = new HiddenConnectPage(mWifi); + page.CreateComponents(mApSource); return page; } diff --git a/SettingWiFi/SettingWiFi/view/WPSConnectPage.cs b/SettingWiFi/SettingWiFi/view/WPSConnectPage.cs new file mode 100644 index 0000000..283ac90 --- /dev/null +++ b/SettingWiFi/SettingWiFi/view/WPSConnectPage.cs @@ -0,0 +1,294 @@ +using System; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; +using SettingWiFi.res.locale; +using static SettingWiFi.Logger; + + +namespace SettingWiFi +{ + internal class WpsButtonWaitPage : DialogPage + { + private WiFi mWifi; + private AP mAp; + private bool isConnected = false; + + internal WpsButtonWaitPage(WiFi wifi) + { + mWifi = wifi; + } + + internal void CreateComponents(AP ap) + { + mAp = ap; + + var view = new View() + { + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + }; + + var messageItem = new DefaultLinearItem(); + var progressItem = new DefaultLinearItem(); + + string timeout = "2"; + TextLabel text = new TextLabel(String.Format(Resources.IDS_WIFI_POP_PRESS_WPS_ON_YOUR_WI_FI_ACCESS_POINT_WITHIN_PD_MINUTES, timeout)) + { + Size = new Size(1000, 700), + HorizontalAlignment = HorizontalAlignment.Begin, + PointSize = 15.0f, + }; + + var progress = new Progress() + { + MinValue = 0, + MaxValue = 120, + CurrentValue = 0, + TrackColor = Color.White, + ProgressColor = Color.Navy, + Size = new Size(400, 50), + WidthSpecification = 400, + }; + + messageItem.Add(text); + progressItem.Add(progress); + + view.Add(messageItem); + view.Add(progressItem); + + int timeCnt = 60 * 2; + var timer = new Timer(1000); + timer.Tick += (o, e) => + { + timeCnt--; + progress.CurrentValue++; + if (timeCnt == 0) + { + Navigator.Pop(); + return false; + } + + checkConnection(); + if (isConnected) + { + Navigator.Pop(); + return false; + } + + return true; + }; + timer.Start(); + + var cancelButton = new Button() + { + Text = Resources.IDS_WIFI_SK_CANCEL, + WidthSpecification = 100, + HeightSpecification = 60, + }; + cancelButton.Clicked += (object s, ClickedEventArgs e) => + { + timer.Stop(); + Navigator.Pop(); + }; + + Content = new AlertDialog() + { + Title = Resources.IDS_WIFI_BUTTON_WPS_BUTTON, + Content = view, + Actions = new View[] { cancelButton }, + }; + } + + private async void checkConnection() + { + if (mWifi.GetConnectionState().Equals(Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS)) + { + isConnected = true; + } + } + } + + internal class WpsPinWaitPage : DialogPage + { + private WiFi mWifi; + private AP mAp; + private bool isConnected = false; + + internal WpsPinWaitPage(WiFi wifi) + { + mWifi = wifi; + } + + internal void CreateComponents(AP ap, string pin) + { + mAp = ap; + + var view = new View() + { + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + }; + + var messageItem = new DefaultLinearItem(); + var progressItem = new DefaultLinearItem(); + + string timeout = "2"; + TextLabel text = new TextLabel(String.Format(Resources.IDS_ST_BODY_ENTER_THE_P1SS_PIN_ON_YOUR_WI_FI_ROUTER_THE_SETUP_CAN_TAKE_UP_TO_P2SD_MINUTES_TO_COMPLETE, pin, timeout)) + { + Size = new Size(1000, 700), + }; + text.HorizontalAlignment = HorizontalAlignment.Begin; + text.PointSize = 15.0f; + + var progress = new Progress() + { + MinValue = 0, + MaxValue = 120, + CurrentValue = 0, + TrackColor = Color.White, + ProgressColor = Color.Navy, + Size = new Size(400, 50), + WidthSpecification = 400, + }; + + messageItem.Add(text); + progressItem.Add(progress); + + view.Add(messageItem); + view.Add(progressItem); + + int timeCnt = 60 * 2; + var timer = new Timer(1000); + timer.Tick += (o, e) => + { + timeCnt--; + progress.CurrentValue++; + if (timeCnt == 0) + { + Navigator.Pop(); + return false; + } + + checkConnection(); + if (isConnected) + { + Debug(Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS); + Navigator.Pop(); + return false; + } + + return true; + }; + timer.Start(); + + var cancelButton = new Button() + { + Text = Resources.IDS_WIFI_SK_CANCEL, + WidthSpecification = 100, + HeightSpecification = 60, + }; + cancelButton.Clicked += (object s, ClickedEventArgs e) => + { + timer.Stop(); + Navigator.Pop(); + }; + + Content = new AlertDialog() + { + Title = Resources.IDS_WIFI_SK_WPS_PIN, + Content = view, + Actions = new View[] { cancelButton }, + }; + } + + private async void checkConnection() + { + if (mWifi.GetConnectionState().Equals(Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS)) + { + isConnected = true; + } + } + } + + internal class WpsConnectPage : DialogPage + { + private WiFi mWifi; + private AP mAp; + + internal WpsConnectPage(WiFi wifi) + { + mWifi = wifi; + } + + internal void CreateComponents(AP ap) + { + mAp = ap; + + var view = new View() + { + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + WidthSpecification = 200, + HeightSpecification = 100, + }; + + var pbsButton = new Button() + { + Text = Resources.IDS_WIFI_BUTTON_WPS_BUTTON, + }; + pbsButton.Clicked += OnButtonMethodClicked; + + var pinButton = new Button() + { + Text = Resources.IDS_WIFI_SK_WPS_PIN, + }; + pinButton.Clicked += OnPinMethodClicked; + + Content = new AlertDialog() + { + Title = Resources.IDS_WIFI_HEADER_SELECT_WPS_METHOD_ABB, + Content = view, + Actions = new View[] { pbsButton, pinButton }, + }; + } + + private void OnButtonMethodClicked(object source, ClickedEventArgs args) + { + var page = new WpsButtonWaitPage(mWifi); + page.CreateComponents(mAp); + + ConnectWpsPbs(); + + Navigator.Push(page); + } + + private void OnPinMethodClicked(object source, ClickedEventArgs args) + { + //GeneratePinNumber(); // todo + string pin = "1234"; + ConnectWpsPin(pin); + + var page = new WpsPinWaitPage(mWifi); + page.CreateComponents(mAp, pin); + + Navigator.Push(page); + } + + private async void ConnectWpsPbs() + { + await mWifi.ConnectWps(mAp, null); + } + + private async void ConnectWpsPin(string pin) + { + await mWifi.ConnectWps(mAp, pin); + } + } +} \ No newline at end of file