From: Akash Date: Fri, 9 Dec 2022 04:01:26 +0000 (+0530) Subject: Resolve enable/disable issue of SSID find button and connect button X-Git-Tag: accepted/tizen/unified/20221216.024031^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98c883d60375eb35a680e818ffbb8465c750e058;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-wifi.git Resolve enable/disable issue of SSID find button and connect button 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 --- diff --git a/SettingWiFi/SettingWiFi/Constants.cs b/SettingWiFi/SettingWiFi/Constants.cs new file mode 100644 index 0000000..41d3c76 --- /dev/null +++ b/SettingWiFi/SettingWiFi/Constants.cs @@ -0,0 +1,7 @@ +namespace SettingWiFi +{ + static class Constants + { + public const int MIN_PASSWORD_LENGTH = 8; + } +} diff --git a/SettingWiFi/SettingWiFi/view/ConnectPage.cs b/SettingWiFi/SettingWiFi/view/ConnectPage.cs index c86a0c1..8de7b11 100644 --- a/SettingWiFi/SettingWiFi/view/ConnectPage.cs +++ b/SettingWiFi/SettingWiFi/view/ConnectPage.cs @@ -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); + } + } } } diff --git a/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs b/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs index 3f69eee..2140b88 100644 --- a/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs +++ b/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs @@ -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); + } + + } } } diff --git a/packaging/org.tizen.cssetting-wifi-1.0.0.tpk b/packaging/org.tizen.cssetting-wifi-1.0.0.tpk index 5e8012a..66381dd 100644 Binary files a/packaging/org.tizen.cssetting-wifi-1.0.0.tpk and b/packaging/org.tizen.cssetting-wifi-1.0.0.tpk differ