Fixing security type button (#50)
authorKamil Stepaniuk/IoT & UI Sample (PLT) /SRPOL/Designer/Samsung Electronics <k.stepaniuk@samsung.com>
Fri, 17 Apr 2020 12:37:10 +0000 (14:37 +0200)
committerLukasz Stanislawski/IoT & UI Sample (PLT) /SRPOL/Engineer/Samsung Electronics <l.stanislaws@samsung.com>
Fri, 17 Apr 2020 12:37:10 +0000 (14:37 +0200)
* Fixing security type button

Signed-off-by: k.stepaniuk <k.stepaniuk@samsung.com>
Oobe/Oobe.Wifi/Controls/Wifi/AddNewNetworkPupup.cs
Oobe/Oobe.Wifi/res/12_back_active.png [new file with mode: 0644]

index 5704dd9fbe42ec134c0c2a362b99c46974b48017..afa2c1fbea2e7e1915e231ed3d55d10988b919cd 100644 (file)
@@ -27,7 +27,8 @@ namespace Oobe.Wifi.Controls.Wifi
         TextField ssidTextField;
         View ssidUnderline;
         TextLabel securityTypeLabel;
-        Button securityTypeButton;
+        TextLabel selectedSecurityTypeLabel;
+        TapGestureDetector securityTypeDetector;
         TextLabel usernameLabel;
         TextField usernameTextField;
         View usernameUnderline;
@@ -40,6 +41,7 @@ namespace Oobe.Wifi.Controls.Wifi
         TextLabel failureLabel;
         WifiUISecurityType currentSecurityType;
         private string backgroundImagePath = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "08_popup_body.png");
+        private string arrowImagePath = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "12_back_active.png");
 
         static Color largeTextColor => new Color(0.0f, 0x14 / 255.0f, 0x47 / 255.0f, 1.0f);
         static Color smallTextColor => new Color(0.0f, 0xC / 255.0f, 0x2B / 255.0f, 1.0f);
@@ -167,21 +169,9 @@ namespace Oobe.Wifi.Controls.Wifi
             this.Add(ssidUnderline);
 
             securityTypeLabel = CreateTextLabel("WIFI_SECURITY_TYPE", new Position2D(104, 144));
-            this.Add(securityTypeLabel);
-
-            securityTypeButton = new Button
-            {
-                Size = new Size(583, 30),
-                Position2D = new Position2D(121, 161),
-                PointSize = 22,
-                Text = currentSecurityType.GetUIName(),
-                BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f),
-                TextAlignment = HorizontalAlignment.Begin,
-                CellHorizontalAlignment = HorizontalAlignmentType.Center,
-                CellVerticalAlignment = VerticalAlignmentType.Center
-            };
-            securityTypeButton.ClickEvent += (s, e) => OpenSecurityTypePopup();
-            this.Add(securityTypeButton);
+            this.Add(securityTypeLabel);\r
+
+            this.Add(CreateSecurityTypeButton());
 
             cancelButton = new Button(ButtonStyles.Cancel)
             {
@@ -211,7 +201,7 @@ namespace Oobe.Wifi.Controls.Wifi
                     return;
                 }
                 bool success = false;
-                if(aps is null || aps.Count() == 0)
+                if (aps is null || aps.Count() == 0)
                 {
                     ShowFailureSsidLabel();
                     return;
@@ -232,7 +222,7 @@ namespace Oobe.Wifi.Controls.Wifi
                         var orginal_task = wifiAp.ConnectAsync();
                         task = orginal_task as Task<bool>;
                     }
-                    catch(Exception connectionException)
+                    catch (Exception connectionException)
                     {
                         Tizen.Log.Error("oobe", $"Failed to connect to WiFI {wifiAp.NetworkInformation.Bssid} ({wifiAp.NetworkInformation.Essid})" +
                             $"Password: {(passwordEntry is null ? "not set" : "XXXXXXXX")}, " +
@@ -254,10 +244,10 @@ namespace Oobe.Wifi.Controls.Wifi
                             break;
                         }
                     }
-                    catch(Exception connectionException)
+                    catch (Exception connectionException)
                     {
                         Tizen.Log.Error("oobe", $"Failed to connect to WiFI {wifiAp.NetworkInformation.Bssid} ({wifiAp.NetworkInformation.Essid})" +
-                            $"Password: {(passwordEntry is null? "not set" : "XXXXXXXX")}, " +
+                            $"Password: {(passwordEntry is null ? "not set" : "XXXXXXXX")}, " +
                             $"Security type: {currentSecurityType.GetUIName()} " +
                             connectionException.Message);
                         continue;
@@ -287,8 +277,39 @@ namespace Oobe.Wifi.Controls.Wifi
             };
             failureLabel.Hide();
             this.Add(failureLabel);
-        }
-
+        }\r
+\r
+        private View CreateSecurityTypeButton()\r
+        {\r
+            var view = new View()\r
+            {\r
+                Size = new Size(583, 30),\r
+                Position2D = new Position2D(121, 161),\r
+                Layout = new AbsoluteLayout(),\r
+            };\r
+            selectedSecurityTypeLabel = new TextLabel()\r
+            {\r
+                Size = new Size(200, 28),\r
+                PixelSize = 22,\r
+                TranslatableText = currentSecurityType.GetUIName(),\r
+                FontStyle = new PropertyMap().AddRegularFontStyle(),\r
+                FontFamily = "BreezeSans",\r
+                TextColor = largeTextColor,\r
+                HorizontalAlignment = HorizontalAlignment.Begin,
+                VerticalAlignment = VerticalAlignment.Center,\r
+            };\r
+            view.Add(selectedSecurityTypeLabel);\r
+            view.Add(new View()\r
+            {\r
+                BackgroundImage = arrowImagePath,\r
+                Position = new Position(568, 2),\r
+            });\r
+            securityTypeDetector = new TapGestureDetector();\r
+            securityTypeDetector.Attach(view);\r
+            securityTypeDetector.Detected += (s, e) => OpenSecurityTypePopup();\r
+            return view;\r
+        }\r
+\r
         void OpenSecurityTypePopup()
         {
             var view = new ChangeSecurityTypePopup(currentSecurityType);
@@ -323,7 +344,7 @@ namespace Oobe.Wifi.Controls.Wifi
                 usernameTextField = null;
             }
 
-            if(!(usernameUnderline is null))
+            if (!(usernameUnderline is null))
             {
                 usernameUnderline.Unparent();
                 usernameUnderline.Dispose();
@@ -442,7 +463,7 @@ namespace Oobe.Wifi.Controls.Wifi
                 this.Add(usernameTextField);
             }
 
-            if(usernameUnderline is null)
+            if (usernameUnderline is null)
             {
                 usernameUnderline = CreateUnderline();
                 this.Add(usernameUnderline);
@@ -460,7 +481,7 @@ namespace Oobe.Wifi.Controls.Wifi
                 this.Add(passwordEntry);
             }
 
-            if(passwordUnderline is null)
+            if (passwordUnderline is null)
             {
                 passwordUnderline = CreateUnderline();
                 this.Add(passwordUnderline);
@@ -488,7 +509,7 @@ namespace Oobe.Wifi.Controls.Wifi
             Tizen.Log.Debug("oobe", $"Reseting view to {securityType.GetUIName()}");
             failureLabel.Hide();
             currentSecurityType = securityType;
-            securityTypeButton.TranslatableText = securityType.GetUIName();
+            selectedSecurityTypeLabel.TranslatableText = securityType.GetUIName();
             switch (securityType)
             {
                 case WifiUISecurityType.None:
diff --git a/Oobe/Oobe.Wifi/res/12_back_active.png b/Oobe/Oobe.Wifi/res/12_back_active.png
new file mode 100644 (file)
index 0000000..62cef3d
Binary files /dev/null and b/Oobe/Oobe.Wifi/res/12_back_active.png differ