From d688cf8155104a9ca60bedafc8304c259cd766e5 Mon Sep 17 00:00:00 2001 From: chaehee-hong Date: Thu, 13 Oct 2022 17:47:46 +0900 Subject: [PATCH] Modify WiFi methods Change-Id: If34f509de9388e234132409106a51a212bf972a4 --- SettingWiFi/SettingWiFi/controller/WiFi.cs | 57 ++++++------------- .../res/locale/Resources.Designer.cs | 38 +++++++++---- .../SettingWiFi/res/locale/Resources.en.resx | 6 ++ .../res/locale/Resources.ko-KR.resx | 6 ++ .../SettingWiFi/res/locale/Resources.resx | 6 ++ SettingWiFi/SettingWiFi/view/InfoPage.cs | 26 +++------ 6 files changed, 70 insertions(+), 69 deletions(-) diff --git a/SettingWiFi/SettingWiFi/controller/WiFi.cs b/SettingWiFi/SettingWiFi/controller/WiFi.cs index ed30bfa..4d928f2 100755 --- a/SettingWiFi/SettingWiFi/controller/WiFi.cs +++ b/SettingWiFi/SettingWiFi/controller/WiFi.cs @@ -97,27 +97,17 @@ namespace SettingWiFi } } - public Task Disconnect(string essid) - { - Debug("WiFi.Disconnect"); - WiFiAP ap = FindAP(essid); - if (ap == null) - { - return Task.FromException(new ArgumentException("Cannot find " + essid)); - } - return ap.DisconnectAsync(); - } - - public async Task Forget(string essid) + public async Task Forget(AP ap) { Debug("WiFi.Forget"); - WiFiAP ap = FindAP(essid); if (ap == null) { - Debug("Cannot find " + essid); + Debug("Cannot find AP"); return; } - ap.ForgetAP(); + + WiFiAP apHandle = ap.ApHandle; + apHandle.ForgetAP(); } public async Task ScanSpecificAP(string essid) @@ -152,22 +142,22 @@ namespace SettingWiFi public async Task ConnectWps(AP ap, string pin) { Debug("WiFi.ConnectWps"); - WiFiAP wifiAP = FindAP(ap.Essid); - if (wifiAP == null) + if (ap == null) { - Debug("Cannot find " + ap.Essid); + Debug("Cannot find AP"); return; } + WiFiAP apHandle = ap.ApHandle; try { if (pin == null) { - await wifiAP.ConnectWpsAsync(new WpsPbcInfo()); + await apHandle.ConnectWpsAsync(new WpsPbcInfo()); } else { - await wifiAP.ConnectWpsAsync(new WpsPinInfo(pin)); + await apHandle.ConnectWpsAsync(new WpsPinInfo(pin)); } } catch (Exception e) @@ -176,21 +166,6 @@ namespace SettingWiFi } } - private WiFiAP FindAP(string essid) - { - Debug("WiFi.FindAP"); - GetScanResult(); - foreach (var item in mApList) - { - Debug("Found AP\t" + item.NetworkInformation.Essid); - if (item.NetworkInformation.Essid.Equals(essid)) - { - return item; - } - } - return null; - } - public bool IsActive() { Debug("WiFi.IsActive"); @@ -275,12 +250,12 @@ namespace SettingWiFi bool isWpsSupported = item.SecurityInformation.IsWpsSupported; WiFiState state = convertWiFiState(item.NetworkInformation.ConnectionState); - if (item.NetworkInformation.ConnectionState.ToString().Equals(Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS)) - { - apInfoList.Add(new AP(item, item.NetworkInformation.Essid, - state, securityType, isWpsSupported, - item.NetworkInformation.Bssid, item.NetworkInformation.RssiLevel)); - } + var networkInfo = item.NetworkInformation; + var ap = new AP(item, networkInfo.Essid, + state, securityType, isWpsSupported, + networkInfo.Bssid, networkInfo.RssiLevel); + + apInfoList.Add(ap); } return apInfoList; diff --git a/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs b/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs index fbcae5a..1888f51 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs @@ -11,7 +11,7 @@ namespace SettingWiFi.res.locale { using System; - + /// /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. /// @@ -23,15 +23,15 @@ namespace SettingWiFi.res.locale { [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { - + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } - + /// /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. /// @@ -45,7 +45,7 @@ namespace SettingWiFi.res.locale { return resourceMan; } } - + /// /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 /// 재정의합니다. @@ -59,7 +59,7 @@ namespace SettingWiFi.res.locale { resourceCulture = value; } } - + /// /// 과(와) 유사한 지역화된 문자열을 찾습니다. /// @@ -68,7 +68,7 @@ namespace SettingWiFi.res.locale { return ResourceManager.GetString("IDS_ST_HEADER_AVAILABLE_NETWORKS", resourceCulture); } } - + /// /// 과(와) 유사한 지역화된 문자열을 찾습니다. /// @@ -86,7 +86,7 @@ namespace SettingWiFi.res.locale { return ResourceManager.GetString("IDS_WIFI_SBODY_CONNECTED_M_STATUS", resourceCulture); } } - + /// /// 과(와) 유사한 지역화된 문자열을 찾습니다. /// @@ -95,7 +95,7 @@ namespace SettingWiFi.res.locale { return ResourceManager.GetString("IDS_WIFI_HEADER_WI_FI_NETWORK_INFO_ABB", resourceCulture); } } - + /// /// 과(와) 유사한 지역화된 문자열을 찾습니다. /// @@ -266,5 +266,23 @@ namespace SettingWiFi.res.locale { return ResourceManager.GetString("IDS_WIFI_HEADER_PASSWORD", resourceCulture); } } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_OPT_FORGET_NETWORK { + get { + return ResourceManager.GetString("IDS_WIFI_OPT_FORGET_NETWORK", resourceCulture); + } + } + + /// + /// 과(와) 유사한 지역화된 문자열을 찾습니다. + /// + public static string IDS_WIFI_BODY_STATIC_IP { + get { + return ResourceManager.GetString("IDS_WIFI_BODY_STATIC_IP", resourceCulture); + } + } } } diff --git a/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx b/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx index c414f7a..796347f 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.en.resx @@ -186,4 +186,10 @@ Password + + Forget network + + + Static IP + \ 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 dee3005..ec8c093 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.ko-KR.resx +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.ko-KR.resx @@ -186,4 +186,10 @@ 비밀번호 + + 네트워크 지우기 + + + 고정 IP + \ No newline at end of file diff --git a/SettingWiFi/SettingWiFi/res/locale/Resources.resx b/SettingWiFi/SettingWiFi/res/locale/Resources.resx index 0106462..cec224e 100755 --- a/SettingWiFi/SettingWiFi/res/locale/Resources.resx +++ b/SettingWiFi/SettingWiFi/res/locale/Resources.resx @@ -186,4 +186,10 @@ + + + + + + \ No newline at end of file diff --git a/SettingWiFi/SettingWiFi/view/InfoPage.cs b/SettingWiFi/SettingWiFi/view/InfoPage.cs index fc42ad2..7f3905a 100644 --- a/SettingWiFi/SettingWiFi/view/InfoPage.cs +++ b/SettingWiFi/SettingWiFi/view/InfoPage.cs @@ -5,6 +5,7 @@ using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Binding; using Tizen.NUI.Components; +using SettingWiFi.res.locale; using static SettingWiFi.Logger; @@ -29,7 +30,7 @@ namespace SettingWiFi var appBar = new AppBar() { - Title = "Wi-Fi network info", + Title = Resources.IDS_WIFI_HEADER_WI_FI_NETWORK_INFO_ABB, }; AppBarStyle appBarStyle = (AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar"); @@ -68,7 +69,7 @@ namespace SettingWiFi var forgetButton = new Button() { - Text = "Forget", + Text = Resources.IDS_WIFI_SK_FORGET, WidthSpecification = 300, HeightSpecification = 80, }; @@ -114,7 +115,7 @@ namespace SettingWiFi var toggle = new DefaultLinearItem() { WidthSpecification = LayoutParamPolicies.MatchParent, - Text = "Staic IP", + Text = Resources.IDS_WIFI_BODY_STATIC_IP, IsSelectable = false, }; toggle.Label.HorizontalAlignment = HorizontalAlignment.Begin; @@ -147,7 +148,7 @@ namespace SettingWiFi var cancelButton = new Button() { - Text = "Cancel", + Text = Resources.IDS_WIFI_SK_CANCEL, WidthSpecification = 300, HeightSpecification = 80, }; @@ -155,7 +156,7 @@ namespace SettingWiFi var forgetButton = new Button() { - Text = "Forget", + Text = Resources.IDS_WIFI_SK_FORGET, WidthSpecification = 300, HeightSpecification = 80, }; @@ -165,7 +166,7 @@ namespace SettingWiFi { Content = new AlertDialog() { - Title = "Forget network", + Title = Resources.IDS_WIFI_OPT_FORGET_NETWORK, Content = forgetView, Actions = new View[] { cancelButton, forgetButton }, }, @@ -199,18 +200,7 @@ namespace SettingWiFi private async void Forget() { - await mWifi.Forget(mAp.Essid); - if (mWifi.IsActive()) - { - ScanAP(); - } - } - - private async void ScanAP() - { - await mWifi.Scan(); - List apList = mWifi.GetScanResult(); - mApSource.UpdateScanList(apList); + await mWifi.Forget(mAp); } } } \ No newline at end of file -- 2.34.1