using Tizen.NUI.Components;
using Oobe.Common.Styles;
using Tizen.Network.WiFi;
+using Oobe.Common.Utils;
namespace Oobe.Wifi.Controls.Wifi
{
void OpenSecurityTypePopup()
{
- //Temporary solution for no popup stack
- switch (currentSecurityType)
+ var view = new ChangeSecurityTypePopup(currentSecurityType);
+ var popup = new Oobe.Common.Utils.Popup(view);
+ view.OnDismiss += () =>
{
- case WifUISecurityType.None:
- ResetViewTo(WifUISecurityType.EAP);
- break;
- case WifUISecurityType.EAP:
- ResetViewTo(WifUISecurityType.WEP);
- break;
- case WifUISecurityType.WEP:
- ResetViewTo(WifUISecurityType.WPAPSK);
- break;
- case WifUISecurityType.WPAPSK:
- ResetViewTo(WifUISecurityType.WPA2PSK);
- break;
- case WifUISecurityType.WPA2PSK:
- ResetViewTo(WifUISecurityType.None);
- break;
- }
+ ResetViewTo(view.WifiUISecurityType);
+ popup.Dismiss();
+ };
+ popup.Show();
}
void ResetViewToNoPassword()
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using Oobe.Common.Styles;
+using Tizen.Network.WiFi;
+
+namespace Oobe.Wifi.Controls.Wifi
+{
+ class ChangeSecurityTypePopup : View
+ {
+ public event Action OnDismiss;
+
+ public WifUISecurityType WifiUISecurityType { get; private set; }
+ private WifUISecurityType originalWifUISecurityType;
+ private ListView listView;
+ public ObservableCollection<View> choiceViews = new ObservableCollection<View>();
+ private RadioButtonGroup radioButtonGroup = new RadioButtonGroup();
+
+ public ChangeSecurityTypePopup(WifUISecurityType wifUISecurityType)
+ {
+ this.originalWifUISecurityType = wifUISecurityType;
+ this.WifiUISecurityType = wifUISecurityType;
+ this.Size = new Size(808, 440);
+ this.Position = new Position(236, 140);
+ this.BackgroundImage = System.IO.Path.Combine(NUIApplication.Current.DirectoryInfo.Resource, "08_popup_body.png");
+
+ InitializeStaticElements();
+ InitializeRadioButtons();
+ }
+
+ public void InitializeStaticElements()
+ {
+ var titleLabel = new TextLabel()
+ {
+ Position = new Position2D(80, 24),
+ Size = new Size(648, 34),
+ PixelSize = 26,
+ Text = "Choose security type",
+ FontFamily = "BreezeSans",
+ FontStyle = new PropertyMap().AddLightFontStyle(),
+ TextColor = new Color(0.0f, 0x14 / 255.0f, 0x47 / 255.0f, 1.0f),
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center
+ };
+ this.Add(titleLabel);
+
+ var cancelButton = new Button(ButtonStyles.Cancel)
+ {
+ Position = new Position(80, 344),
+ Size = new Size(240, 72)
+ };
+ cancelButton.ClickEvent += (s, e) =>
+ {
+ WifiUISecurityType = originalWifUISecurityType;
+ OnDismiss?.Invoke();
+ };
+ this.Add(cancelButton);
+
+ var addButton = new Button(ButtonStyles.OK)
+ {
+ Position = new Position(488, 344),
+ Size = new Size(240, 72),
+ Text = "OK"
+ };
+
+ addButton.ClickEvent += (s, e) =>
+ {
+ OnDismiss?.Invoke();
+ };
+ this.Add(addButton);
+ }
+
+ private void InitializeRadioButtons()
+ {
+ foreach (WifUISecurityType type in Enum.GetValues(WifiUISecurityType.GetType()))
+ {
+ var view = CreateOption(type);
+ choiceViews.Add(view);
+ }
+ listView = new ListView(768, 238)
+ {
+ Items = choiceViews
+ };
+ listView.View.Position = new Position(0, 82);
+ this.Add(listView.View);
+ }
+
+ private View CreateOption(WifUISecurityType wifiUISecurityType)
+ {
+ var view = new SecurityTypeView(wifiUISecurityType);
+ if (this.WifiUISecurityType == wifiUISecurityType)
+ {
+ view.Button.IsSelected = true;
+ }
+ radioButtonGroup.Add(view.Button);
+ view.Button.ClickEvent += (s, e) => this.WifiUISecurityType = view.WifiUISecurityType;
+ return view;
+ }
+ }
+}
--- /dev/null
+using System;
+using Tizen.Network.WiFi;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Oobe.Common.Styles;
+using Tizen.NUI.Components;
+
+namespace Oobe.Wifi.Controls.Wifi
+{
+ class SecurityTypeView : View
+ {
+ public event Action Tapped;
+ public RadioButton Button;
+ public readonly WifUISecurityType WifiUISecurityType;
+
+ private TextLabel descriptionTextLabel = null;
+ //detectors have to be kept separately because of GC, there is no link by ref between View and Detector
+ private TapGestureDetector detector;
+
+ public SecurityTypeView(WifUISecurityType wifiUISecurityType)
+ {
+ Size = new Size(768, 64);
+ Layout = new AbsoluteLayout();
+ this.WifiUISecurityType = wifiUISecurityType;
+
+ InitializeSubelements();
+ }
+
+ void InitializeSubelements()
+ {
+ Button = new RadioButton()
+ {
+ IsSelected = false,
+ Position = new Position(40, 20),
+ Size = new Size(24, 24)
+ };
+ this.Add(Button);
+
+ descriptionTextLabel = new TextLabel()
+ {
+ Position = new Position(92, 20),
+ Size = new Size(648, 24),
+ Text = WifiUISecurityType.GetUIName()
+ };
+ this.Add(descriptionTextLabel);
+ }
+ }
+}