From 39055940c7109268b24ca146173ef210b7fb8fd6 Mon Sep 17 00:00:00 2001 From: "k.stepaniuk" Date: Tue, 24 Mar 2020 12:15:05 +0100 Subject: [PATCH] Handling exceptions & turn on/off button Signed-off-by: k.stepaniuk --- Oobe/OobeCommon/Styles/ButtonStyles.cs | 11 +++++++++ Oobe/OobeWifi/Controls/Wifi/ApView.cs | 16 +++++++++--- Oobe/OobeWifi/Controls/Wifi/WifiState.cs | 33 +++++++++++++++---------- Oobe/OobeWifi/Controls/Wifi/WifiView.cs | 18 ++++++++------ Oobe/OobeWifi/res/12_icon_wifioff_disabled.png | Bin 0 -> 1417 bytes Oobe/OobeWifi/res/12_icon_wifion_disabled.png | Bin 0 -> 1527 bytes 6 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 Oobe/OobeWifi/res/12_icon_wifioff_disabled.png create mode 100644 Oobe/OobeWifi/res/12_icon_wifion_disabled.png diff --git a/Oobe/OobeCommon/Styles/ButtonStyles.cs b/Oobe/OobeCommon/Styles/ButtonStyles.cs index ec2b11d..e57345c 100644 --- a/Oobe/OobeCommon/Styles/ButtonStyles.cs +++ b/Oobe/OobeCommon/Styles/ButtonStyles.cs @@ -37,6 +37,17 @@ namespace Oobe.Common.Styles }, Size2D = new Size2D(72, 32), }; + public static ButtonStyle TurnOnOff = new ButtonStyle + { + BackgroundImage = new Selector + { + Normal = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifioff.png", + Disabled = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifioff_disabled.png", + Selected = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifion.png", + DisabledSelected = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifion_disabled.png", + }, + Size2D = new Size2D(72, 32), + }; public static ButtonStyle AddNetwork = new ButtonStyle { BackgroundImage = new Selector diff --git a/Oobe/OobeWifi/Controls/Wifi/ApView.cs b/Oobe/OobeWifi/Controls/Wifi/ApView.cs index 523461e..a43b7f4 100644 --- a/Oobe/OobeWifi/Controls/Wifi/ApView.cs +++ b/Oobe/OobeWifi/Controls/Wifi/ApView.cs @@ -65,18 +65,28 @@ namespace Oobe.Wifi.Controls.Wifi private static string GetDetailInfo(WiFiAP wifiAp) { + //state if (wifiAp.NetworkInformation.ConnectionState == WiFiConnectionState.Connected) { return "Connected"; } - else if (wifiAp.SecurityInformation.IsPassphraseRequired) + if (wifiAp.NetworkInformation.ConnectionState == WiFiConnectionState.Association) { - return "Secured"; + return "Connecting..."; } - else + //security + else if (wifiAp.SecurityInformation.SecurityType == Tizen.Network.Connection.WiFiSecurityType.None) { return "Open"; } + else if(wifiAp.SecurityInformation.IsPassphraseRequired == false) + { + return "Saved"; + } + else + { + return "Secured"; + } } private static string GetRangeImage(WiFiAP wifiAp) diff --git a/Oobe/OobeWifi/Controls/Wifi/WifiState.cs b/Oobe/OobeWifi/Controls/Wifi/WifiState.cs index 7e6640b..6de399d 100644 --- a/Oobe/OobeWifi/Controls/Wifi/WifiState.cs +++ b/Oobe/OobeWifi/Controls/Wifi/WifiState.cs @@ -16,26 +16,33 @@ namespace Oobe.Wifi.Controls.Wifi public async Task TurnWifi() { - if (IsTurnedOn) + try { - await Tizen.Network.WiFi.WiFiManager.DeactivateAsync(); - if (IsTurnedOn == false) + if (IsTurnedOn) { - OnTurnedOff?.Invoke(); - } - } - else - { - await Tizen.Network.WiFi.WiFiManager.ActivateAsync(); - if (IsTurnedOn == false) - { - OnTurningOnFailed?.Invoke(); + await Tizen.Network.WiFi.WiFiManager.DeactivateAsync(); + if (IsTurnedOn == false) + { + OnTurnedOff?.Invoke(); + } } else { - OnTurnedOn?.Invoke(); + await Tizen.Network.WiFi.WiFiManager.ActivateAsync(); + if (IsTurnedOn == false) + { + OnTurningOnFailed?.Invoke(); + } + else + { + OnTurnedOn?.Invoke(); + } } } + catch (Exception ex) + { + Tizen.Log.Error("oobe", $"{ex.ToString()}"); + } } public async Task> Scan() diff --git a/Oobe/OobeWifi/Controls/Wifi/WifiView.cs b/Oobe/OobeWifi/Controls/Wifi/WifiView.cs index 7777e71..c5ca0ad 100644 --- a/Oobe/OobeWifi/Controls/Wifi/WifiView.cs +++ b/Oobe/OobeWifi/Controls/Wifi/WifiView.cs @@ -123,20 +123,22 @@ namespace Oobe.Wifi.Controls.Wifi private Button CreateTurnOnButton() { - var button = new Button(new ButtonStyle()) + var button = new Button(ButtonStyles.TurnOnOff) { Size = new Size(72, 32), Position = new Position(369, 39), }; - button.Style.BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + - (State.IsTurnedOn ? "12_icon_wifion.png" : "12_icon_wifioff.png"); + button.IsSelected = State.IsTurnedOn; - State.OnTurnedOff += () => - button.Style.BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifioff.png"; - State.OnTurnedOn += () => - button.Style.BackgroundImage = NUIApplication.Current.DirectoryInfo.Resource + "12_icon_wifion.png"; + State.OnTurnedOff += () => button.IsSelected = State.IsTurnedOn; + State.OnTurnedOn += () => button.IsSelected = State.IsTurnedOn; - button.ClickEvent += async (s, e) => await State.TurnWifi(); + button.ClickEvent += async (s, e) => + { + button.IsEnabled = false; + await State.TurnWifi(); + button.IsEnabled = true; + }; return button; } diff --git a/Oobe/OobeWifi/res/12_icon_wifioff_disabled.png b/Oobe/OobeWifi/res/12_icon_wifioff_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..26a807be9e1307c94cf795714add1eda800c6952 GIT binary patch literal 1417 zcmV;41$O$0P)NR%;;lcsGxO)p8

ESH_Di#<3;C3y|0{Xe%g`Rben>WO0+fg8a4=UULeqZRyXc z)Uc0pNBVxxd7g*!zUMvP`3O;r&Y$}m*O|@(tOY28m@`0>7zM-*gz^$VQw*L0=r;mi z)t@f8DNBSR1sbi^R9@i^z;uxa$&uof@H>O&0DMUa^s!#2vxnmx(jc47rkPn-dk4TJ z5K@&OJZg>%I|Co3C&zuE)oPu=o)2nJ=ip$<`kdoB5uJ^CQUyN1j26{?&Fj_2kIx6v z-(rx_+*bfn-2hOiK&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ifion_disabled.png b/Oobe/OobeWifi/res/12_icon_wifion_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..4a775a064855e9153b40268796d5071489b70245 GIT binary patch literal 1527 zcmV%TWl0n826fLy&mfYcz8czMtl zX)0{DBn@63CNX#+A$4gQAjYII`XFE|twD{&O95N7Mj{GQ0gFf}?LxOjN_V$&jyVIf z+3n7DXSTxHa*}=MIsf_R`@jCTGiL}UhQr}l3t&Bf2Z(4i0P!1cLd6{y<(zi|a1)W6 zbAHldvFt4?E2}XIgrW%+78crVHruP5^NmC_BAWalS?>h!p4aPrbJwn29sOaBNRTYc zR*%Q?GUxntBC-z>!%e~DoC|W^u-okwvMl@bHtP~pT3R~N=krwoSZ3;pgID-~)oOiy z`}XbE`kD|%P)SKihN39dL^N~o+G`#;=lpj71umECbnxyFf{KcY(h?F9>WOHE`9}I+E?F>YmPyt2lq|51jw=jA0$Yf}Ha`E|+T~ZQ8VHlq5;*0IacSnmjE7Svh&I z+H5K@ilV4$1W{s~Z90YHjrAd_A7As7x_-H}MVADzF2XJ&{n69hF7 z(OfedHCfFQY7bWF<`N;d~L!%yKh9JM+hw6PFnle))>f27xgE_fs7zJ0ez65A8S}rq6&>aXd?|?!~RIo&= z4F~pq5b-}FdY<%g_l8s}Jp#nsu;EGg;pjKWo^vxLMhmgqoumP%Ar^Cz){GC%FMXL> zv+h|~Bq@YMJ%Y4~*K0K7S(5hP@ccu_0~TIg1j^gznIW)xEtG&a=X(!~oQ{Ad-d zZyOLPgtUY%ltfGZ+Ji)+nE%L%h`o>?=li-^(~aUSg7yr!QPg^&-rinZaks&9)vY#% zscB=>Zuv@k8@~POvk>C?%Q0H(V3Z(Du?V-xQ)h%6HJZgy!({Ih43sgpQax%|ES9!d zE16IzD%F(fGXuv9F((LXYi-eOAp0Xo99gnixJ-6Q^!!>aaNQL@v= zPr$VI9|7mQhcPxW@VY}lDlRU5S8x@7c=1QT zIe*9Ha%~kz0&f(>O@`O&Jwim;@rM{c1f27R&d$!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