Modify WiFi methods 26/282926/1
authorchaehee-hong <chaehee.hong@samsung.com>
Thu, 13 Oct 2022 08:47:46 +0000 (17:47 +0900)
committerchaehee-hong <chaehee.hong@samsung.com>
Thu, 13 Oct 2022 08:47:46 +0000 (17:47 +0900)
Change-Id: If34f509de9388e234132409106a51a212bf972a4

SettingWiFi/SettingWiFi/controller/WiFi.cs
SettingWiFi/SettingWiFi/res/locale/Resources.Designer.cs
SettingWiFi/SettingWiFi/res/locale/Resources.en.resx
SettingWiFi/SettingWiFi/res/locale/Resources.ko-KR.resx
SettingWiFi/SettingWiFi/res/locale/Resources.resx
SettingWiFi/SettingWiFi/view/InfoPage.cs

index ed30bfad2b5e031761b93c3af250e588023df0af..4d928f2fb5d5f4348c728bca51b30091540dec5a 100755 (executable)
@@ -97,27 +97,17 @@ namespace SettingWiFi
             }\r
         }\r
 \r
-        public Task Disconnect(string essid)\r
-        {\r
-            Debug("WiFi.Disconnect");\r
-            WiFiAP ap = FindAP(essid);\r
-            if (ap == null)\r
-            {\r
-                return Task.FromException(new ArgumentException("Cannot find " + essid));\r
-            }\r
-            return ap.DisconnectAsync();\r
-        }\r
-\r
-        public async Task Forget(string essid)\r
+        public async Task Forget(AP ap)\r
         {\r
             Debug("WiFi.Forget");\r
-            WiFiAP ap = FindAP(essid);\r
             if (ap == null)\r
             {\r
-                Debug("Cannot find " + essid);\r
+                Debug("Cannot find AP");\r
                 return;\r
             }\r
-            ap.ForgetAP();\r
+\r
+            WiFiAP apHandle = ap.ApHandle;\r
+            apHandle.ForgetAP();\r
         }\r
 \r
         public async Task ScanSpecificAP(string essid)\r
@@ -152,22 +142,22 @@ namespace SettingWiFi
         public async Task ConnectWps(AP ap, string pin)\r
         {\r
             Debug("WiFi.ConnectWps");\r
-            WiFiAP wifiAP = FindAP(ap.Essid);\r
-            if (wifiAP == null)\r
+            if (ap == null)\r
             {\r
-                Debug("Cannot find " + ap.Essid);\r
+                Debug("Cannot find AP");\r
                 return;\r
             }\r
 \r
+            WiFiAP apHandle = ap.ApHandle;\r
             try\r
             {\r
                 if (pin == null)\r
                 {\r
-                    await wifiAP.ConnectWpsAsync(new WpsPbcInfo());\r
+                    await apHandle.ConnectWpsAsync(new WpsPbcInfo());\r
                 }\r
                 else\r
                 {\r
-                    await wifiAP.ConnectWpsAsync(new WpsPinInfo(pin));\r
+                    await apHandle.ConnectWpsAsync(new WpsPinInfo(pin));\r
                 }\r
             }\r
             catch (Exception e)\r
@@ -176,21 +166,6 @@ namespace SettingWiFi
             }\r
         }\r
 \r
-        private WiFiAP FindAP(string essid)\r
-        {\r
-            Debug("WiFi.FindAP");\r
-            GetScanResult();\r
-            foreach (var item in mApList)\r
-            {\r
-                Debug("Found AP\t" + item.NetworkInformation.Essid);\r
-                if (item.NetworkInformation.Essid.Equals(essid))\r
-                {\r
-                    return item;\r
-                }\r
-            }\r
-            return null;\r
-        }\r
-\r
         public bool IsActive()\r
         {\r
             Debug("WiFi.IsActive");\r
@@ -275,12 +250,12 @@ namespace SettingWiFi
                 bool isWpsSupported = item.SecurityInformation.IsWpsSupported;\r
                 WiFiState state = convertWiFiState(item.NetworkInformation.ConnectionState);\r
 \r
-                if (item.NetworkInformation.ConnectionState.ToString().Equals(Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS))\r
-                {\r
-                    apInfoList.Add(new AP(item, item.NetworkInformation.Essid,\r
-                        state, securityType, isWpsSupported,\r
-                        item.NetworkInformation.Bssid, item.NetworkInformation.RssiLevel));\r
-                }\r
+                var networkInfo = item.NetworkInformation;\r
+                var ap = new AP(item, networkInfo.Essid,\r
+                    state, securityType, isWpsSupported,\r
+                    networkInfo.Bssid, networkInfo.RssiLevel);\r
+\r
+                apInfoList.Add(ap);\r
             }\r
 \r
             return apInfoList;\r
index fbcae5ac666f1603ab9250c896a8cd5dc2502fcd..1888f51a30af72416282e7ddbb20bbea8c2273ff 100755 (executable)
@@ -11,7 +11,7 @@
 namespace SettingWiFi.res.locale {
     using System;
     
-    
+
     /// <summary>
     ///   지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
     /// </summary>
@@ -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() {
         }
-        
+
         /// <summary>
         ///   이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
         /// </summary>
@@ -45,7 +45,7 @@ namespace SettingWiFi.res.locale {
                 return resourceMan;
             }
         }
-        
+
         /// <summary>
         ///   이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
         ///   재정의합니다.
@@ -59,7 +59,7 @@ namespace SettingWiFi.res.locale {
                 resourceCulture = value;
             }
         }
-        
+
         /// <summary>
         ///   과(와) 유사한 지역화된 문자열을 찾습니다.
         /// </summary>
@@ -68,7 +68,7 @@ namespace SettingWiFi.res.locale {
                 return ResourceManager.GetString("IDS_ST_HEADER_AVAILABLE_NETWORKS", resourceCulture);
             }
         }
-        
+
         /// <summary>
         ///   과(와) 유사한 지역화된 문자열을 찾습니다.
         /// </summary>
@@ -86,7 +86,7 @@ namespace SettingWiFi.res.locale {
                 return ResourceManager.GetString("IDS_WIFI_SBODY_CONNECTED_M_STATUS", resourceCulture);
             }
         }
-        
+
         /// <summary>
         ///   과(와) 유사한 지역화된 문자열을 찾습니다.
         /// </summary>
@@ -95,7 +95,7 @@ namespace SettingWiFi.res.locale {
                 return ResourceManager.GetString("IDS_WIFI_HEADER_WI_FI_NETWORK_INFO_ABB", resourceCulture);
             }
         }
-        
+
         /// <summary>
         ///   과(와) 유사한 지역화된 문자열을 찾습니다.
         /// </summary>
@@ -266,5 +266,23 @@ namespace SettingWiFi.res.locale {
                 return ResourceManager.GetString("IDS_WIFI_HEADER_PASSWORD", resourceCulture);
             }
         }
+
+        /// <summary>
+        ///   과(와) 유사한 지역화된 문자열을 찾습니다.
+        /// </summary>
+        public static string IDS_WIFI_OPT_FORGET_NETWORK {
+            get {
+                return ResourceManager.GetString("IDS_WIFI_OPT_FORGET_NETWORK", resourceCulture);
+            }
+        }
+
+        /// <summary>
+        ///   과(와) 유사한 지역화된 문자열을 찾습니다.
+        /// </summary>
+        public static string IDS_WIFI_BODY_STATIC_IP {
+            get {
+                return ResourceManager.GetString("IDS_WIFI_BODY_STATIC_IP", resourceCulture);
+            }
+        }
     }
 }
index c414f7a03436b47a441baa6aaf5aaa773702dcdf..796347fd38c8c414beb29945bf976603585f010e 100755 (executable)
   <data name="IDS_WIFI_HEADER_PASSWORD" xml:space="preserve">\r
     <value>Password</value>\r
   </data>\r
+  <data name="IDS_WIFI_OPT_FORGET_NETWORK" xml:space="preserve">\r
+    <value>Forget network</value>\r
+  </data>\r
+  <data name="IDS_WIFI_BODY_STATIC_IP" xml:space="preserve">\r
+    <value>Static IP</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index dee30053f840f81384248a761da60e25e53286c2..ec8c093d90d9464ce30e20430251d8263ab4f10f 100755 (executable)
   <data name="IDS_WIFI_HEADER_PASSWORD" xml:space="preserve">\r
     <value>비밀번호</value>\r
   </data>\r
+  <data name="IDS_WIFI_OPT_FORGET_NETWORK" xml:space="preserve">\r
+    <value>네트워크 지우기</value>\r
+  </data>\r
+  <data name="IDS_WIFI_BODY_STATIC_IP" xml:space="preserve">\r
+    <value>고정 IP</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index 0106462985a16e0a7e4098e9273f2e4c54cc7634..cec224e757f6e358f0528ed9ffab12ee7287fc40 100755 (executable)
   <data name="IDS_WIFI_HEADER_PASSWORD" xml:space="preserve">\r
     <value />\r
   </data>\r
+  <data name="IDS_WIFI_OPT_FORGET_NETWORK" xml:space="preserve">\r
+    <value />\r
+  </data>\r
+  <data name="IDS_WIFI_BODY_STATIC_IP" xml:space="preserve">\r
+    <value />\r
+  </data>\r
 </root>
\ No newline at end of file
index fc42ad2b5dae7b49dc60ad1018cb83f92b0ee702..7f3905ad70f9af1fcc83592043c10b68f4f53ed6 100644 (file)
@@ -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<AP> apList = mWifi.GetScanResult();
-            mApSource.UpdateScanList(apList);
+            await mWifi.Forget(mAp);
         }
     }
 }
\ No newline at end of file