namespace SettingWiFi
{
- //internal class ConnectPage : RoundedDialogPage
internal class ConnectPage : RoundedDialogPage
{
private AP mAp;
private WiFi mWifi;
private TextField mPasswordField;
- private Button mConnectButton;
private Window mWindow = NUIApplication.GetDefaultWindow();
+ private const int MAX_DEVICE_NAME_LEN = 32;
+ private TextLabel warning;
+ private Button okButton;
+ private bool isLightTheme => ThemeManager.PlatformThemeId == "org.tizen.default-light-theme";
+
internal ConnectPage(WiFi wifi)
{
Debug("ConnectPage");
internal TextField CreatePasswordField()
{
Debug("+");
- var passwordField = new TextField()
+ PropertyMap placeholder = new PropertyMap();
+ placeholder.Add("color", new PropertyValue(isLightTheme ? new Color("#CACACA") : new Color("#666666")));
+ placeholder.Add("fontFamily", new PropertyValue("BreezeSans"));
+ placeholder.Add("pixelSize", new PropertyValue(24.SpToPx()));
+ placeholder.Add("text", new PropertyValue(Resources.IDS_WIFI_HEADER_PASSWORD));
+
+ var passwordField = new TextField
{
- WidthSpecification = 534,
- HeightSpecification = 48,
- BackgroundColor = Color.White,
- PlaceholderText = Resources.IDS_WIFI_HEADER_PASSWORD,
+ FontFamily = "BreezeSans",
+ SizeWidth = 530.SpToPx(),
+ Placeholder = placeholder,
+ BackgroundColor = isLightTheme ? new Color("#FAFAFA") : new Color("#1D1A21"),
+ MaxLength = MAX_DEVICE_NAME_LEN,
+ EnableCursorBlink = true,
+ PixelSize = 24.SpToPx(),
+ Margin = new Extents(0, 26, 0, 0).SpToPx(),
};
InputMethod inputSetting = new InputMethod
var wpsItem = new DefaultLinearItem()
{
- WidthSpecification = LayoutParamPolicies.MatchParent,
+ SizeWidth = 618.SpToPx(),
IsSelectable = true,
Icon = new ImageView(iconStyle),
Text = Resources.IDS_WIFI_OPT_WPS,
+ Margin = new Extents(15, 0, 0, 0).SpToPx(),
};
wpsItem.Icon.HeightSpecification = 20;
{
mAp = ap;
- var connectView = new RecyclerViewItem()
+ var content = new View()
{
+ BackgroundColor = isLightTheme ? new Color("#FAFAFA") : new Color("#16131A"),
+ WidthSpecification = LayoutParamPolicies.WrapContent,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
Layout = new LinearLayout()
{
LinearOrientation = LinearLayout.Orientation.Vertical,
},
- IsSelectable = false,
};
- TextLabel label = new TextLabel(Resources.IDS_WIFI_BODY_TYPE_PASSWORD);
- label.Padding = new Extents(5, 5, 5, 20);
- connectView.Add(label);
+ // main text
+ content.Add(AddSubTitle());
- connectView.Add(CreatePasswordEntryItem());
- connectView.Add(CreateUnderline());
+ //entry view
+ content.Add(CreatePasswordView());
- if(mAp.IsWps)
+ // separator
+ View separatorWrapper = new View()
{
- connectView.Add(CreateWpsItem());
- }
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ },
+ };
- var cancelButton = new Button()
+ View separator = new View
{
- Text = Resources.IDS_WIFI_SK_CANCEL,
- WidthSpecification = 252,
- HeightSpecification = 48,
- BackgroundColor = Color.White,
- TextColor = new Color("#FF6200"),
- BorderlineColor = new Color("#FF6200"),
- BorderlineWidth = 2,
+ Size = new Size(550.SpToPx(), 1),
+ BackgroundColor = new Color("#FF6200"),
+ Margin = new Extents(24, 82, 0, 16).SpToPx(),
};
- cancelButton.Clicked += OnCancelClicked;
+ separatorWrapper.Add(separator);
+ content.Add(separatorWrapper);
- mConnectButton = new Button()
+ // warn label
+ View warningWrapper = new View()
{
- Text = Resources.IDS_WIFI_SK_OK,
- WidthSpecification = 252,
- HeightSpecification = 48,
+ WidthSpecification = LayoutParamPolicies.WrapContent,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ },
};
- mConnectButton.IsEnabled = false;
- mConnectButton.Clicked += OnConnectClicked;
- Content = new AlertDialog()
+ warning = new TextLabel(Resources.IDS_WIFI_BODY_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED)
{
- Title = mAp.Essid,
- Content = connectView,
- Actions = new View[] { cancelButton, mConnectButton},
+ SizeWidth = 618.SpToPx(),
+ PixelSize = 16.SpToPx(),
+ TextColor = new Color("#A40404"),
+ Margin = new Extents(24, 40, 0, 0).SpToPx(),
};
- }
+ warningWrapper.Add(warning);
+ content.Add(warningWrapper);
- 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
+ // wps
+ if (mAp.IsWps)
{
- hiddenInput.Mode = HiddenInputModeType.HideNone;
+ content.Add(CreateWpsItem());
}
- mPasswordField.SetHiddenInput(hiddenInput);
- mPasswordField.Text = mPasswordField.Text;
- }
- private Selector<Color> GetDefaultColorSelector()
- {
- return new Selector<Color>()
+ okButton = new Button()
{
- Normal = new Color("#FFFFFF"),
- Focused = new Color("#17234D"),
- Pressed = new Color("#FF6200"),
- Disabled = new Color("#CACACA"),
+ WidthResizePolicy = ResizePolicyType.FitToChildren,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ Text = Resources.IDS_WIFI_SK_OK,
+ Size = new Size(252, 48).SpToPx(),
+ Margin = new Extents(61, 0, 0, 0).SpToPx(),
};
- }
+ okButton.Clicked += OnOkClicked;
- private Button CreateButton(string iconImagePath)
- {
- int buttonSize = 48;
-
- ButtonStyle style = new ButtonStyle()
+ var cancelButton = new Button("Tizen.NUI.Components.Button.Outlined")
{
- IsSelectable = true,
- CornerRadius = 50,
- BackgroundColor = GetDefaultColorSelector(),
+ WidthResizePolicy = ResizePolicyType.FitToChildren,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ Text = Resources.IDS_WIFI_SK_CANCEL,
+ Size = new Size(252, 48).SpToPx(),
};
+ cancelButton.Clicked += OnCancelClicked;
+
+ CheckNameLength(mPasswordField);
- Button button = new Button(style)
+ Content = new AlertDialog()
{
- WidthSpecification = buttonSize,
- HeightSpecification = buttonSize,
- IconURL = Resources.GetPath() + iconImagePath,
- IsSelectable = false,
+ Title = mAp.Essid,
+ Content = content,
+ Actions = new View[] { cancelButton, okButton },
};
+ }
- return button;
+ private void TextFieldTextChanged(object sender, TextField.TextChangedEventArgs e)
+ {
+ CheckNameLength(e.TextField);
}
- private Button GetCrossButton()
+ private void CheckNameLength(TextField textField)
{
- string crossIconImagePath = "/images/cross_icon.png";
- Button crossButton = CreateButton(crossIconImagePath);
- crossButton.Clicked += OnCrossButtonClicked;
+ if (textField.Text.Length >= MAX_DEVICE_NAME_LEN)
+ {
+ warning.Show();
+ okButton.IsEnabled = false;
+ }
+ else
+ {
+ warning.Hide();
+ try
+ {
+ Debug("Password field changed");
+ okButton.IsEnabled = mPasswordField.Text.Length >= Constants.MIN_PASSWORD_LENGTH ? true : false;
+ }
+ catch (Exception ex)
+ {
+ Debug("Exception: " + ex.Message);
+ }
+ }
- return crossButton;
+ if (textField.Text == string.Empty)
+ {
+ okButton.IsEnabled = false;
+ }
}
- private Button GetEyeButton()
+ private View AddSubTitle()
{
- string eyeIconImagePath = "/images/eye_icon.png";
- Button eyeButton = CreateButton(eyeIconImagePath);
- eyeButton.Clicked += OnEyeButtonClicked;
- eyeButton.IsSelectable = true;
+ var textSubTitle = new TextLabel(Resources.IDS_WIFI_BODY_TYPE_PASSWORD)
+ {
+ FontFamily = "BreezeSans",
+ PixelSize = 24.SpToPx(),
+ SizeWidth = 618.SpToPx(),
+ MultiLine = true,
+ LineWrapMode = LineWrapMode.Word,
+ Margin = new Extents(24, 24, 0, 24).SpToPx(),
+ };
- return eyeButton;
+ return textSubTitle;
}
- private View CreatePasswordEntryItem()
+ private View CreatePasswordView()
{
- View passwordEntryView = new View()
+ View entryView = new View()
{
+ WidthSpecification = LayoutParamPolicies.WrapContent,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
Layout = new LinearLayout()
{
LinearOrientation = LinearLayout.Orientation.Horizontal,
},
- HeightSpecification = 48,
- Padding = new Extents(5, 5, 10,0),
+ Margin = new Extents(35, 30, 0, 0).SpToPx(),
};
mPasswordField = CreatePasswordField();
- mPasswordField.TextChanged += OnTextChanged;
- passwordEntryView.Add(mPasswordField);
- passwordEntryView.Add(GetCrossButton());
- passwordEntryView.Add(GetEyeButton());
+ mPasswordField.TextChanged += TextFieldTextChanged;
+ SettingCore.Views.CancelButton cancelTextButton = new SettingCore.Views.CancelButton();
+ cancelTextButton.Clicked += CancelTextButtonClicked;
- return passwordEntryView;
+ EyeButton eyeButton = new EyeButton();
+ eyeButton.Clicked += OnEyeButtonClicked;
+
+ entryView.Add(mPasswordField);
+ entryView.Add(cancelTextButton);
+ entryView.Add(eyeButton);
+
+ return entryView;
+ }
+
+ private void CancelTextButtonClicked(object sender, ClickedEventArgs e)
+ {
+ mPasswordField.Text = string.Empty;
}
- private View CreateUnderline()
+ public void UpdateHiddenProperty(bool hide)
{
- return new View()
+ Debug("+");
+ var hiddenInput = new Tizen.NUI.Text.HiddenInput();
+ if (hide)
{
- BorderlineColor = new Color("#FF6200"),
- BorderlineWidth = 1,
- WidthSpecification = 530,
- HeightSpecification = 1,
- Padding = new Extents(5, 0, 0, 0),
- };
+ 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 void OnEyeButtonClicked(object sender, ClickedEventArgs e)
{
Debug("+");
- Button button = (Button)sender;
- var hiddenInput = mPasswordField.GetHiddenInput();
+ EyeButton button = (EyeButton)sender;
+ button.OnSelected();
- if (button.IsSelected)
+ if (button.hide==0)
{
Debug("Show Password Selected");
UpdateHiddenProperty(false);
Debug("Show Password UnSelected");
UpdateHiddenProperty(true);
}
-
- }
-
- private void OnCrossButtonClicked(object sender, ClickedEventArgs e)
- {
- Debug("+");
- Button button = (Button)sender;
- mPasswordField.Text = "";
}
private void OnCancelClicked(object source, ClickedEventArgs args)
NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(page);
}
- private void OnConnectClicked(object source, ClickedEventArgs args)
+ private void OnOkClicked(object source, ClickedEventArgs args)
{
Connect();
NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
Error("Error other than wrong password " + e.Message);
}
}
-
- 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 class WrongPasswordEntered : InvalidOperationException
}
}
}
+