--- /dev/null
+using SettingWiFi.res.locale;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using static SettingWiFi.Logger;
+
+namespace SettingWiFi
+{
+ internal class EapInfoInputPage : DialogPage
+ {
+ private EapItem mAddItem;
+ EapInfoSource mInfoSource;
+
+ private TextField mValueField;
+ private RadioButton[] mRadioButtons;
+ private RadioButtonGroup mGroup;
+ private string mTitle;
+ private int mCount;
+ private string mImagesPath;
+ private string[] mOptionNames;
+ private int mSelectedIndex;
+
+ internal EapInfoInputPage(EapItem item, EapInfoSource infoSource)
+ {
+ Debug("EapInfoInputPage");
+ mAddItem = item;
+ mInfoSource = infoSource;
+ mGroup = new RadioButtonGroup();
+ mImagesPath = Resources.GetPath() + "/images/";
+ }
+
+ internal void CreateComponents(string title, string value)
+ {
+ mTitle = title;
+ var infoView = new RecyclerViewItem()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ },
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
+ };
+ mValueField = new TextField()
+ {
+ WidthSpecification = 600,
+ PlaceholderText = value,
+ };
+
+ infoView.Add(mValueField);
+
+ var okButton = new Button()
+ {
+ Text = Resources.IDS_WIFI_SK2_OK,
+ };
+ okButton.Clicked += OnOkClicked;
+
+ Content = new AlertDialog()
+ {
+ Title = title,
+ Content = infoView,
+ Actions = new View[] { okButton },
+ };
+ }
+
+ internal void CreateRadioComponents(string title, string[] options)
+ {
+ Debug("CreateRadioComponents" + title);
+ mTitle = title;
+ mOptionNames = options;
+ mCount = options.Length;
+ mRadioButtons = new RadioButton[mCount];
+ getSelectedIndex();
+
+ var optionView = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ },
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
+ };
+
+ var okButton = new Button()
+ {
+ Text = Resources.IDS_WIFI_SK2_OK,
+ };
+ okButton.Clicked += OnRadioOkClicked;
+
+ CreateRadioOptions(optionView);
+ mRadioButtons[mSelectedIndex].IsSelected = true;
+ Content = new AlertDialog()
+ {
+ Title = mTitle,
+ Content = optionView,
+ Actions = new View[] { okButton },
+ };
+ }
+
+ private void getSelectedIndex()
+ {
+ Debug("");
+ mSelectedIndex = 0;
+ if (mTitle == Resources.IDS_ST_BUTTON_EAP_METHOD)
+ {
+ switch (mAddItem.Eapmethod)
+ {
+ case "PEAP":
+ mSelectedIndex = 0;
+ break;
+ case "TLS":
+ mSelectedIndex = 1;
+ break;
+ case "TTLS":
+ mSelectedIndex = 2;
+ break;
+ case "SIM":
+ mSelectedIndex = 3;
+ break;
+ case "AKA":
+ mSelectedIndex = 4;
+ break;
+ }
+ }
+ else if (mTitle == Resources.IDS_ST_BUTTON_PHASE_AUTHENTICATION)
+ {
+ switch (mAddItem.Phaseauthentication)
+ {
+ case "None ":
+ mSelectedIndex = 0;
+ break;
+ case "MSCHAPV2":
+ mSelectedIndex = 1;
+ break;
+ case "GTC":
+ mSelectedIndex = 2;
+ break;
+ }
+ }
+ else if (mTitle == Resources.IDS_ST_BUTTON_USER_CERTIFICATE)
+ {
+ switch (mAddItem.Usercertificate)
+ {
+ case "None":
+ mSelectedIndex = 0;
+ break;
+ case "Wifiserver":
+ mSelectedIndex = 1;
+ break;
+ case "Wificonv":
+ mSelectedIndex = 2;
+ break;
+ case "WL3-server":
+ mSelectedIndex = 3;
+ break;
+ }
+ }
+ }
+ private void CreateRadioOptions(View optionView)
+ {
+ for (int i = 0; i < mCount; i++)
+ {
+ int index = i;
+ var childView = new View()
+ {
+ Layout = new GridLayout()
+ {
+ GridOrientation = GridLayout.Orientation.Horizontal,
+ Columns = 2,
+ Rows = 1,
+ ColumnSpacing = 10,
+ },
+ };
+ mRadioButtons[i] = new RadioButton();
+ var buttonStyle = mRadioButtons[i].Style;
+ CreateRadioButtonStyle(buttonStyle);
+ mRadioButtons[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
+ {
+ OnSelectionChanged(sender, args, index);
+ };
+ mRadioButtons[i].ApplyStyle(buttonStyle);
+ mRadioButtons[i].Size = new Size(48, 48);
+ mRadioButtons[i].Icon.Size = new Size(48, 48);
+ mGroup.Add(mRadioButtons[i]);
+ var nameLabel = new TextLabel(mOptionNames[i]);
+ nameLabel.WidthSpecification = 150;
+ childView.Add(nameLabel);
+ childView.Add(mRadioButtons[i]);
+ optionView.Add(childView);
+ }
+ }
+ void CreateRadioButtonStyle(ButtonStyle buttonStyle)
+ {
+ Debug("");
+ buttonStyle.Icon.Opacity = new Selector<float?>
+ {
+ Normal = 1.0f,
+ Selected = 1.0f,
+ Disabled = 0.4f,
+ DisabledSelected = 0.4f
+ };
+ buttonStyle.Icon.BackgroundImage = "";
+
+ buttonStyle.Icon.ResourceUrl = new Selector<string>
+ {
+ Normal = mImagesPath + "controller_btn_radio_off.png",
+ Selected = mImagesPath + "controller_btn_radio_on.png",
+ Disabled = mImagesPath + "controller_btn_radio_off.png",
+ DisabledSelected = mImagesPath + "controller_btn_radio_on.png",
+ };
+ }
+
+ void OnSelectionChanged(object sender, SelectedChangedEventArgs e, int i)
+ {
+ Debug($"{i}th RadioButton's IsSelected is changed to {e.IsSelected}.");
+ if (e.IsSelected)
+ {
+ mSelectedIndex = i;
+ Debug("Selected index: " + mSelectedIndex);
+ }
+ }
+
+ private void OnRadioOkClicked(object source, ClickedEventArgs args)
+ {
+ Debug("OnRadioOkClicked");
+ mInfoSource.Clear();
+ UpdateInfo(mTitle, mOptionNames[mSelectedIndex]);
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+ }
+ private void OnOkClicked(object sender, ClickedEventArgs e)
+ {
+ Debug("OnOkClicked " + mValueField.Text + " : " + mTitle);
+ mInfoSource.Clear();
+ UpdateInfo(mTitle, mValueField.Text);
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+ }
+
+ private void UpdateInfo(string fieldName, string value)
+ {
+ Debug("UpdateInfo");
+
+ if (fieldName == Resources.IDS_ST_BUTTON_EAP_METHOD)
+ {
+ Debug("Eap method: Updating value to " + value + " from " + mAddItem.Eapmethod);
+ mAddItem.Eapmethod = value;
+ mInfoSource.ShowEapInfo();
+ }
+ else if (fieldName == Resources.IDS_ST_BUTTON_PHASE_AUTHENTICATION)
+ {
+ Debug("Phase 2 authentication: Updating value to " + value + " from " + mAddItem.Phaseauthentication);
+ mAddItem.Phaseauthentication = value;
+ mInfoSource.ShowEapInfo();
+ }
+ else if (fieldName == Resources.IDS_ST_BUTTON_USER_CERTIFICATE)
+ {
+ Debug("User Certificate: Updating value to " + value + " from " + mAddItem.Usercertificate);
+ mAddItem.Usercertificate = value;
+ mInfoSource.ShowEapInfo();
+ }
+ }
+ }
+}
+
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Components;
+using static SettingWiFi.Logger;
+
+namespace SettingWiFi
+{
+ internal class EapPage : ContentPage
+ {
+ private AP mAp;
+ private WiFi mWifi;
+ private EapItem mEapItem;
+ private TextField mPasswordField;
+ private TextField mIdentityField;
+ private Button mConnectButton;
+
+ EapInfoSource mEapDetailsInfoSource;
+ CollectionView mEapDetailsCollection;
+
+ internal EapPage(WiFi wifi)
+ {
+ Debug("EapPage");
+ mWifi = wifi;
+ mEapItem = new EapItem("PEAP", Resources.IDS_ST_BODY_NONE, Resources.IDS_ST_BODY_NONE);
+ }
+
+ internal void CreateComponents(AP ap)
+ {
+ mEapDetailsInfoSource = new EapInfoSource(mWifi, mEapItem);
+ mAp = ap;
+
+ var appBar = new AppBar()
+ {
+ Title = mAp.Essid,
+ };
+
+ AppBarStyle appBarStyle = (AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
+ Button backButton = new Button(((AppBarStyle)appBarStyle).BackButton);
+
+ backButton.Clicked += OnBackClicked;
+ appBar.NavigationContent = backButton;
+
+ View eapView = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ View mDetailsView = new ScrollableBase()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ ScrollingDirection = ScrollableBase.Direction.Vertical,
+ HideScrollbar = false,
+ };
+
+ mEapDetailsCollection = new CollectionView()
+ {
+ ItemsSource = mEapDetailsInfoSource,
+ ItemsLayouter = new LinearLayouter(),
+ ItemTemplate = CreateItemTemplate(),
+ IsGrouped = false,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ mEapDetailsInfoSource.ShowEapInfo();
+
+ View infoCollection = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ Padding = new Extents(16, 0, 0, 0),
+ };
+
+ TextLabel identity = new TextLabel(Resources.IDS_WIFI_BODY_IDENTITY);
+ Margin = new Extents(0, 0, 10, 20);
+ infoCollection.Add(identity);
+
+ infoCollection.Add(CreateIdentityEntryItem());
+ infoCollection.Add(CreateUnderline());
+
+ TextLabel label = new TextLabel(Resources.IDS_WIFI_HEADER_PASSWORD);
+ Margin = new Extents(0, 0, 30, 20);
+ infoCollection.Add(label);
+
+ infoCollection.Add(CreatePasswordEntryItem());
+ infoCollection.Add(CreateUnderline());
+
+ View childView = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ Padding = new Extents(110, 0, 10, 8),
+ };
+
+ var cancelButton = new Button()
+ {
+ Text = Resources.IDS_WIFI_SK_CANCEL,
+ WidthSpecification = 252,
+ HeightSpecification = 48,
+ BackgroundColor = Color.White,
+ TextColor = new Color("#FF6200"),
+ BorderlineColor = new Color("#FF6200"),
+ BorderlineWidth = 2,
+ };
+ cancelButton.Clicked += OnCancelClicked;
+
+ mConnectButton = new Button()
+ {
+ Text = Resources.IDS_WIFI_SK_OK,
+ WidthSpecification = 252,
+ HeightSpecification = 48,
+ Margin = new Extents(160, 0, 0, 0).SpToPx(),
+ };
+ mConnectButton.IsEnabled = false;
+ mConnectButton.Clicked += OnConnectClicked;
+
+ childView.Add(cancelButton);
+ childView.Add(mConnectButton);
+
+ mDetailsView.Add(mEapDetailsCollection);
+ mDetailsView.Add(infoCollection);
+ eapView.Add(mDetailsView);
+ eapView.Add(childView);
+
+ AppBar = appBar;
+ Content = eapView;
+ }
+
+ private void OnBackClicked(object source, ClickedEventArgs args)
+ {
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+ }
+
+ private DataTemplate CreateItemTemplate()
+ {
+ return new DataTemplate(() =>
+ {
+ DefaultLinearItem item = new DefaultLinearItem()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+ item.Label.SetBinding(TextLabel.TextProperty, "InfoTitle");
+ item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
+ item.SubLabel.SetBinding(TextLabel.TextProperty, "InfoValue");
+ item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
+ item.IsSelectable = false;
+ item.Clicked += OnInfoItemClicked;
+ return item;
+ });
+ }
+
+ private void OnCancelClicked(object source, ClickedEventArgs args)
+ {
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+ }
+
+ private void OnConnectClicked(object source, ClickedEventArgs args)
+ {
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+ }
+
+ private void OnInfoItemClicked(object sender, ClickedEventArgs e)
+ {
+ Debug("OnInfoItemClicked");
+ DefaultLinearItem infoItem = (DefaultLinearItem)sender;
+ var info = infoItem.BindingContext as EapInfoText;
+ if (info == null)
+ {
+ Error("Info null");
+ }
+ else
+ {
+ Debug("Item Clicked: " + info.InfoTitle);
+ if (info.InfoTitle == Resources.IDS_ST_BUTTON_EAP_METHOD)
+ {
+ OnEapMethodClicked(sender, e);
+ }
+ else if (info.InfoTitle == Resources.IDS_ST_BUTTON_PHASE_AUTHENTICATION)
+ {
+ OnPhase2AuthenticationClicked(sender, e);
+ }
+ else if (info.InfoTitle == Resources.IDS_ST_BUTTON_USER_CERTIFICATE)
+ {
+ OnUserCertificateClicked(sender, e);
+ }
+ else
+ {
+ Debug("Not a valid field");
+ }
+ }
+ }
+
+ public void OnEapMethodClicked(object source, ClickedEventArgs e)
+ {
+ Debug("OnEapMethodClicked");
+
+ string[] options = new string[]
+ {
+ "PEAP",
+ "TLS",
+ "TTLS",
+ "SIM",
+ "AKA"
+ };
+
+ var page = new EapInfoInputPage(mEapItem, mEapDetailsInfoSource);
+ page.CreateRadioComponents(Resources.IDS_ST_BUTTON_EAP_METHOD, options);
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(page);
+ }
+
+ public void OnPhase2AuthenticationClicked(object source, ClickedEventArgs e)
+ {
+ Debug("OnPhase2AuthenticationClicked");
+
+ string[] options = new string[]
+ {
+ "None",
+ "MSCHAPV2",
+ "GTC"
+ };
+
+ var page = new EapInfoInputPage(mEapItem, mEapDetailsInfoSource);
+ page.CreateRadioComponents(Resources.IDS_ST_BUTTON_PHASE_AUTHENTICATION, options);
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(page);
+ }
+
+ public void OnUserCertificateClicked(object source, ClickedEventArgs e)
+ {
+ Debug("OnUserCertificateClicked");
+
+ string[] options = new string[]
+ {
+ "None",
+ "Wifiserver",
+ "Wificonv",
+ "WL3-server"
+ };
+
+ var page = new EapInfoInputPage(mEapItem, mEapDetailsInfoSource);
+ page.CreateRadioComponents(Resources.IDS_ST_BUTTON_USER_CERTIFICATE, options);
+ NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(page);
+ }
+
+ private View CreatePasswordEntryItem()
+ {
+ View passwordEntryView = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ HeightSpecification = 35,
+ };
+
+ mPasswordField = CreatePasswordField();
+ mPasswordField.TextChanged += OnTextChanged;
+
+ passwordEntryView.Add(mPasswordField);
+ passwordEntryView.Add(GetCrossButton());
+ passwordEntryView.Add(GetEyeButton());
+
+ return passwordEntryView;
+ }
+
+ private View CreateIdentityEntryItem()
+ {
+ View identityEntryView = new View()
+ {
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ HeightSpecification = 35,
+ };
+
+ mIdentityField = CreateIdentityField();
+
+ identityEntryView.Add(mIdentityField);
+
+ return identityEntryView;
+ }
+
+ private View CreateUnderline()
+ {
+ return new View()
+ {
+ BorderlineColor = new Color("#FF6200"),
+ BorderlineWidth = 1,
+ WidthSpecification = 530,
+ HeightSpecification = 1,
+ };
+ }
+
+ 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);
+ }
+ }
+
+ internal TextField CreatePasswordField()
+ {
+ Debug("+");
+ var passwordField = new TextField()
+ {
+ WidthSpecification = 534,
+ HeightSpecification = 35,
+ BackgroundColor = Color.White,
+ PlaceholderText = Resources.IDS_WIFI_HEADER_PASSWORD,
+ };
+
+ InputMethod inputSetting = new InputMethod
+ {
+ PanelLayout = InputMethod.PanelLayoutType.Password,
+ };
+ PropertyMap p1 = inputSetting.OutputMap;
+ passwordField.InputMethodSettings = p1;
+
+ mPasswordField = passwordField;
+ UpdateHiddenProperty(true);
+
+ return passwordField;
+ }
+
+ internal TextField CreateIdentityField()
+ {
+ Debug("+");
+ var identityField = new TextField()
+ {
+ WidthSpecification = 534,
+ HeightSpecification = 35,
+ BackgroundColor = Color.White,
+ PlaceholderText = Resources.IDS_WIFI_BODY_IDENTITY,
+ };
+
+ InputMethod inputSetting = new InputMethod
+ {
+ PanelLayout = InputMethod.PanelLayoutType.Password,
+ };
+ PropertyMap p1 = inputSetting.OutputMap;
+ identityField.InputMethodSettings = p1;
+
+ mIdentityField = identityField;
+
+ return identityField;
+ }
+
+ private Button GetCrossButton()
+ {
+ string crossIconImagePath = "/images/cross_icon.png";
+ Button crossButton = CreateButton(crossIconImagePath);
+ crossButton.Clicked += OnCrossButtonClicked;
+
+ return crossButton;
+ }
+
+ private Button GetEyeButton()
+ {
+ string eyeIconImagePath = "/images/eye_icon.png";
+ Button eyeButton = CreateButton(eyeIconImagePath);
+ eyeButton.Clicked += OnEyeButtonClicked;
+ eyeButton.IsSelectable = true;
+
+ return eyeButton;
+ }
+
+ private void OnEyeButtonClicked(object sender, ClickedEventArgs e)
+ {
+ Debug("+");
+ Button button = (Button)sender;
+ var hiddenInput = mPasswordField.GetHiddenInput();
+
+ if (button.IsSelected)
+ {
+ Debug("Show Password Selected");
+ UpdateHiddenProperty(false);
+ }
+ else
+ {
+ Debug("Show Password UnSelected");
+ UpdateHiddenProperty(true);
+ }
+
+ }
+
+ private void OnCrossButtonClicked(object sender, ClickedEventArgs e)
+ {
+ Debug("+");
+ Button button = (Button)sender;
+ mPasswordField.Text = "";
+ }
+
+ private Button CreateButton(string iconImagePath)
+ {
+ int buttonSize = 48;
+
+ ButtonStyle style = new ButtonStyle()
+ {
+ IsSelectable = true,
+ CornerRadius = 50,
+ BackgroundColor = GetDefaultColorSelector(),
+ };
+
+ Button button = new Button(style)
+ {
+ WidthSpecification = buttonSize,
+ HeightSpecification = buttonSize,
+ IconURL = Resources.GetPath() + iconImagePath,
+ IsSelectable = false,
+ };
+
+ return button;
+ }
+
+ private void UpdateHiddenProperty(bool hide)
+ {
+ Debug("+");
+ var hiddenInput = new Tizen.NUI.Text.HiddenInput();
+ if (hide)
+ {
+ hiddenInput.Mode = HiddenInputModeType.ShowLastCharacter;
+ hiddenInput.SubstituteCharacter = '*';
+ hiddenInput.SubstituteCount = 0;
+ hiddenInput.ShowLastCharacterDuration = 1000;
+ }
+ else
+ {
+ hiddenInput.Mode = HiddenInputModeType.HideNone;
+ }
+ mPasswordField.SetHiddenInput(hiddenInput);
+ mPasswordField.Text = mPasswordField.Text;
+ }
+
+ private Selector<Color> GetDefaultColorSelector()
+ {
+ return new Selector<Color>()
+ {
+ Normal = new Color("#FFFFFF"),
+ Focused = new Color("#17234D"),
+ Pressed = new Color("#FF6200"),
+ Disabled = new Color("#CACACA"),
+ };
+ }
+ }
+}
+