Resolve enable/disable issue of SSID find button and connect button 08/285408/2 accepted/tizen/unified/20221216.024031
authorAkash <akash1.kumar@samsung.com>
Fri, 9 Dec 2022 04:01:26 +0000 (09:31 +0530)
committerAkash <akash1.kumar@samsung.com>
Mon, 12 Dec 2022 09:43:08 +0000 (15:13 +0530)
This patch adds following functionalities:
- HiddenConnectPage: Find button is disabled until getting Network SSID.
- ConnectPage: Connect button is disabled until password entered is of at least length 8.

Change-Id: I56869739b1118602013bed5918189176498620b4
Signed-off-by: Akash <akash1.kumar@samsung.com>
SettingWiFi/SettingWiFi/Constants.cs [new file with mode: 0644]
SettingWiFi/SettingWiFi/view/ConnectPage.cs
SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs
packaging/org.tizen.cssetting-wifi-1.0.0.tpk

diff --git a/SettingWiFi/SettingWiFi/Constants.cs b/SettingWiFi/SettingWiFi/Constants.cs
new file mode 100644 (file)
index 0000000..41d3c76
--- /dev/null
@@ -0,0 +1,7 @@
+namespace SettingWiFi
+{
+    static class Constants
+    {
+        public const int MIN_PASSWORD_LENGTH = 8;
+    }
+}
index c86a0c1855caa5c62e39f3d9998c9724c136f96f..8de7b11e8659906b7dda1b1d45105077765259a7 100644 (file)
@@ -12,7 +12,8 @@ namespace SettingWiFi
     {
         private AP mAp;
         private WiFi mWifi;
-        private TextField passwordField;
+        private TextField mPasswordField;
+        private Button mConnectButton;
 
         internal ConnectPage(WiFi wifi)
         {
@@ -85,8 +86,9 @@ namespace SettingWiFi
                 HeightSpecification = LayoutParamPolicies.WrapContent,
             };
 
-            passwordField = CreatePasswordField();
-            connectView.Add(passwordField);
+            mPasswordField = CreatePasswordField();
+            mPasswordField.TextChanged += OnTextChanged;
+            connectView.Add(mPasswordField);
 
             if(mAp.IsWps)
             {
@@ -99,17 +101,18 @@ namespace SettingWiFi
             };
             cancelButton.Clicked += OnCancelClicked;
 
-            var connectButton = new Button()
+            mConnectButton = new Button()
             {
                 Text = Resources.IDS_WIFI_BODY_CONNECT,
             };
-            connectButton.Clicked += OnConnectClicked;
+            mConnectButton.IsEnabled = false;
+            mConnectButton.Clicked += OnConnectClicked;
 
             Content = new AlertDialog()
             {
                 Title = mAp.Essid,
                 Content = connectView,
-                Actions = new View[] { cancelButton, connectButton},
+                Actions = new View[] { cancelButton, mConnectButton},
             };
         }
 
@@ -135,12 +138,25 @@ namespace SettingWiFi
         {
             Debug("Connect");
             //mAp.StateInfo = Resources.IDS_WIFI_BODY_CONNECTING_ING;
-            await mWifi.Connect(mAp, passwordField.Text);
+            await mWifi.Connect(mAp, mPasswordField.Text);
 
             if(mWifi.GetConnectedAP().Equals(mAp.Essid))
             {
                 mAp.StateInfo = Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS;
             }
         }
+
+        private void OnTextChanged(object sender, TextField.TextChangedEventArgs e)
+        {
+            try
+            {
+                Debug("Password field changed");
+                mConnectButton.IsEnabled = mPasswordField.Text.Length >= Constants.MIN_PASSWORD_LENGTH? true : false;
+            }
+            catch (Exception ex)
+            {
+                Debug("Exception: " + ex.Message);
+            }
+        }
     }
 }
index 3f69eee7695e43accc1b97f9cb07081ad74f0980..2140b8876e7a17247f1ebbcc0f181acdcef86493 100644 (file)
@@ -1,3 +1,4 @@
+using System;
 using System.Collections.Generic;
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
@@ -11,10 +12,12 @@ namespace SettingWiFi
     {
         private WiFi mWifi;
         private APSource mApSource;
-        private TextField ssidField;
         private AP mAp;
         Window window = NUIApplication.GetDefaultWindow();
 
+        private TextField ssidField;
+        private Button mFindButton;
+
         internal HiddenConnectPage(WiFi wifi)
         {
             mWifi = wifi;
@@ -35,15 +38,14 @@ namespace SettingWiFi
                 PlaceholderText = Resources.IDS_ST_BODY_NETWORK_SSID,
                 WidthSpecification = 400,
             };
-
+            ssidField.TextChanged += OnTextChanged;
             findView.Add(ssidField);
 
-            var item = new DefaultLinearItem();
-            findView.Add(item);
-
             var cancelButton = CreateCancelButton();
-            var findButton = CreateButton(300, 80, Resources.IDS_COM_BODY_FIND);
-            findButton.Clicked += (object source, ClickedEventArgs args) =>
+
+            mFindButton  = CreateButton(300, 80, Resources.IDS_COM_BODY_FIND);
+            mFindButton.IsEnabled = false;
+            mFindButton.Clicked += (object source, ClickedEventArgs args) =>
             {
                 if (mWifi.IsActive())
                 {
@@ -55,7 +57,7 @@ namespace SettingWiFi
             {
                 Title = Resources.IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK,
                 Content = findView,
-                Actions = new View[] { cancelButton, findButton, },
+                Actions = new View[] { cancelButton, mFindButton, },
             };
             return alt;
         }
@@ -181,12 +183,8 @@ namespace SettingWiFi
             }
             else
             {
-                //Debug("More than one ap found with ssid " + essid);
-
-                //foreach (var item in apList)
-                //{
-                //    Debug("More than one ap found with ssid " + essid);
-                //}
+                // Not required as of now because rpi4 doesn't search for more than one AP with same ssid.
+                Debug("More than one ap found with ssid " + apList.Count);
             }
         }
 
@@ -197,5 +195,19 @@ namespace SettingWiFi
             page.CreateComponents(ap);
             return page;
         }
+
+        private void OnTextChanged(object sender, TextField.TextChangedEventArgs arg)
+        {
+            try
+            {
+                Debug("Text Changed Event");
+                mFindButton.IsEnabled = ssidField.Text.Length > 0 ? true : false;
+            }
+            catch(Exception e)
+            {
+                Debug("Exception: " + e.Message);
+            }
+
+        }
     }
 }
index 5e8012a624ed4a7f91706f9724b5ad5c45bde882..66381dd05d68e073ac88598e766f9319e90c93e1 100644 (file)
Binary files a/packaging/org.tizen.cssetting-wifi-1.0.0.tpk and b/packaging/org.tizen.cssetting-wifi-1.0.0.tpk differ