From: Akash Date: Thu, 1 Dec 2022 10:30:09 +0000 (+0530) Subject: Resolve HiddenConnectPage issue of searching and connectiong an AP. X-Git-Tag: accepted/tizen/unified/20221216.024031~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F284948%2F4;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-wifi.git Resolve HiddenConnectPage issue of searching and connectiong an AP. This patches resolves following issues - Hidden AP connect not done. - Scan AP, show loading, if there is no AP, back to previous input field. - Hidden AP found is not located at the bottom of the scan list. Change-Id: I2dd09feb0a452f25cffac134632bbb9a18f5c3f8 Signed-off-by: Akash --- diff --git a/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs b/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs index dcc22c9..3f69eee 100644 --- a/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs +++ b/SettingWiFi/SettingWiFi/view/HiddenConnectPage.cs @@ -7,10 +7,13 @@ using static SettingWiFi.Logger; namespace SettingWiFi { - internal class HiddenConnectPage : ContentPage + internal class HiddenConnectPage : DialogPage { private WiFi mWifi; private APSource mApSource; + private TextField ssidField; + private AP mAp; + Window window = NUIApplication.GetDefaultWindow(); internal HiddenConnectPage(WiFi wifi) { @@ -20,98 +23,176 @@ namespace SettingWiFi internal void CreateComponents(APSource apSource) { mApSource = apSource; + Content = CreateNewPage(); + } - var findView = new View() - { - Layout = new LinearLayout() - { - LinearOrientation = LinearLayout.Orientation.Vertical, - }, - WidthSpecification = 200, - HeightSpecification = 100, - }; + private AlertDialog CreateNewPage() + { + var findView = CreateNewView(200, 100); - var ssidField = new TextField() + ssidField = new TextField() { PlaceholderText = 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() + var cancelButton = CreateCancelButton(); + var findButton = CreateButton(300, 80, Resources.IDS_COM_BODY_FIND); + findButton.Clicked += (object source, ClickedEventArgs args) => + { + if (mWifi.IsActive()) + { + ConnectSpecificAP(); + } + }; + + AlertDialog alt = new AlertDialog() + { + Title = Resources.IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK, + Content = findView, + Actions = new View[] { cancelButton, findButton, }, + }; + return alt; + } + + private View CreateNewView(int width, int height) + { + var view = new View() + { + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Vertical, + }, + WidthSpecification = width, + HeightSpecification = height, + }; + return view; + } + + private Button CreateButton(int width, int height, string name) + { + var button = new Button() { - Text = Resources.IDS_WIFI_SK_CANCEL, - WidthSpecification = 300, - HeightSpecification = 80, + Text = name, + WidthSpecification = width, + HeightSpecification = height, }; + return button; + } + + private Button CreateCancelButton() + { + var cancelButton = CreateButton(300, 80, Resources.IDS_WIFI_SK_CANCEL); cancelButton.Clicked += (object source, ClickedEventArgs args) => { Navigator.Pop(); }; + return cancelButton; + } + + private AlertDialog CreateOpenAPPageView(AP ap) + { + var infoView = CreateNewView(680, 100); - var findButton = new Button() + var info = new DefaultLinearItem() { - Text = Resources.IDS_COM_BODY_FIND, - WidthSpecification = 300, - HeightSpecification = 80, + WidthSpecification = LayoutParamPolicies.MatchParent, + IsSelectable = false, + Text = Resources.IDS_WIFI_BODY_A_WI_FI_NETWORK_HAS_BEEN_DETECTED_YOU_WILL_BE_CONNECTED, }; - findButton.Clicked += (object source, ClickedEventArgs args) => + + infoView.Add(info); + var cancelButton = CreateCancelButton(); + var connectButton = CreateButton(300, 80, Resources.IDS_WIFI_BODY_CONNECT); + + connectButton.Clicked += (object source, ClickedEventArgs args) => { if (mWifi.IsActive()) { - ConnectSpecificAP(input); + OnConnectClicked(ap, ""); } }; - - Content = new AlertDialog() + AlertDialog alt = new AlertDialog() { - Title = Resources.IDS_WIFI_BUTTON_FIND_HIDDEN_NETWORK, - Content = findView, - Actions = new View[] { cancelButton, findButton }, + Title = ap.Essid, + Content = infoView, + Actions = new View[] { cancelButton, connectButton, }, }; + return alt; + } + + private void ConnectOpenAP(AP ap) + { + Debug("Connect open AP"); + Content = CreateOpenAPPageView(ap); + } + + private async void OnConnectClicked(AP ap, string password) + { + Navigator.Pop(); + await mWifi.Connect(ap, password); + if (mWifi.GetConnectedAP().Equals(ap.Essid)) + { + ap.StateInfo = Resources.IDS_WIFI_SBODY_CONNECTED_M_STATUS; + } } - private async void ConnectSpecificAP(string essid) + private async void ConnectSpecificAP() { + mApSource.SetScanningState(true); + string essid = ssidField.Text; + Debug("Searhing Hidden AP named: " + essid); await mWifi.ScanSpecificAP(essid); List apList = mWifi.GetSpecificScanResult(); + mApSource.SetScanningState(false); + if (apList.Count == 0) { - Navigator.Pop(); + Debug("No Hidden ap found with ssid " + essid); + Content = CreateNewPage(); return; } - - // todo: locate on the bottom of the scan list - //if (apList.Count > 1) - //{ - // Navigator.Pop(); - // return; - //} - - foreach (var item in apList) + else if (apList.Count == 1) { - if (item.SecType.Equals(Resources.IDS_WIFI_POP_OPEN)) + mAp = apList[0]; + Debug("A Hidden AP found with ssid " + essid); + if (!mAp.IsConnected()) { - await mWifi.Connect(item, null); + if (mAp.IsAPOpen()) + { + ConnectOpenAP(mAp); + } + else + { + Navigator.Push(CreateConnectPage(mAp)); + } } else { - Navigator.Push(CreateConnectPage(item)); + Navigator.Pop(); } - break; + return; + } + else + { + //Debug("More than one ap found with ssid " + essid); + + //foreach (var item in apList) + //{ + // Debug("More than one ap found with ssid " + essid); + //} } } private DialogPage CreateConnectPage(AP ap) { + window.GetDefaultNavigator().Pop(); var page = new ConnectPage(mWifi); page.CreateComponents(ap); return page; diff --git a/SettingWiFi/SettingWiFi/view/MainPage.cs b/SettingWiFi/SettingWiFi/view/MainPage.cs index c649755..bf8fb09 100644 --- a/SettingWiFi/SettingWiFi/view/MainPage.cs +++ b/SettingWiFi/SettingWiFi/view/MainPage.cs @@ -290,7 +290,7 @@ namespace SettingWiFi return page; } - private ContentPage CreateHiddenConnectPage() + private DialogPage CreateHiddenConnectPage() { var page = new HiddenConnectPage(mWifi); page.CreateComponents(mApSource); diff --git a/packaging/org.tizen.cssetting-wifi-1.0.0.tpk b/packaging/org.tizen.cssetting-wifi-1.0.0.tpk index a9ba650..5e8012a 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