From: Manika Shrivastava Date: Thu, 2 Nov 2023 11:20:28 +0000 (+0530) Subject: Correct components of type password popup X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_8.0;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-wifi.git Correct components of type password popup This patch resolves jira https://code.sec.samsung.net/jira/browse/TEIGHT-5156 Change-Id: I2b99b347b7a72ca0890ad11656ab9068da362f6e Signed-off-by: Manika Shrivastava --- diff --git a/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/close_eye.svg b/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/close_eye.svg new file mode 100644 index 0000000..92f9464 --- /dev/null +++ b/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/close_eye.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/open_eye.svg b/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/open_eye.svg new file mode 100644 index 0000000..4057f64 --- /dev/null +++ b/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/open_eye.svg @@ -0,0 +1,4 @@ + + + + diff --git a/SettingWiFi/SettingWiFi/view/ConnectPage.cs b/SettingWiFi/SettingWiFi/view/ConnectPage.cs index a270ae7..570c3ea 100755 --- a/SettingWiFi/SettingWiFi/view/ConnectPage.cs +++ b/SettingWiFi/SettingWiFi/view/ConnectPage.cs @@ -9,15 +9,18 @@ using SettingCore; 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"); @@ -27,12 +30,22 @@ namespace SettingWiFi 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 @@ -71,10 +84,11 @@ namespace SettingWiFi 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; @@ -87,168 +101,204 @@ namespace SettingWiFi { 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 GetDefaultColorSelector() - { - return new Selector() + 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); @@ -257,14 +307,6 @@ namespace SettingWiFi 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) @@ -280,7 +322,7 @@ namespace SettingWiFi NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(page); } - private void OnConnectClicked(object source, ClickedEventArgs args) + private void OnOkClicked(object source, ClickedEventArgs args) { Connect(); NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop(); @@ -309,19 +351,6 @@ namespace SettingWiFi 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 @@ -331,3 +360,4 @@ namespace SettingWiFi } } } + diff --git a/SettingWiFi/SettingWiFi/view/EyeButton.cs b/SettingWiFi/SettingWiFi/view/EyeButton.cs new file mode 100644 index 0000000..8df1408 --- /dev/null +++ b/SettingWiFi/SettingWiFi/view/EyeButton.cs @@ -0,0 +1,76 @@ +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +using SettingCore.Views; + + +namespace SettingWiFi +{ + public class EyeButton : BaseComponent + { + private readonly ThemeColor BackgroundColors = new ThemeColor(Color.Transparent, Color.Transparent, Color.Transparent, Color.Transparent); + private readonly ThemeColor IconColors = new ThemeColor(new Color("#17234D"), new Color("#FF8A00"), new Color("#FF6200"), new Color("#FDFDFD")); + + private readonly ImageView icon; + private readonly ImageVisual iconVisual; + + public int hide = 1; + + public EyeButton() : base() + { + BackgroundColor = BackgroundColors.Normal; + CornerRadius = 8f.SpToPx(); + Size = new Size(30, 25).SpToPx(); + Margin = new Extents(10, 0, 0, 0).SpToPx(); + + iconVisual = new ImageVisual + { + MixColor = IconColors.Normal, + URL = System.IO.Path.Combine(Resources.GetPath() + "/images/open_eye.svg"), + FittingMode = FittingModeType.ScaleToFill, + }; + icon = new ImageView + { + Image = iconVisual.OutputVisualMap, + WidthSpecification = LayoutParamPolicies.MatchParent, + HeightSpecification = LayoutParamPolicies.MatchParent, + }; + Add(icon); + + ThemeManager.ThemeChanged += (s, e) => { OnChangeSelected(false); }; + } + + public override void OnChangeSelected(bool selected) + { + if (selected) + { + iconVisual.MixColor = IconColors.Selected; + icon.Image = iconVisual.OutputVisualMap; + + BackgroundColor = BackgroundColors.Selected; + } + else + { + iconVisual.MixColor = IconColors.Normal; + icon.Image = iconVisual.OutputVisualMap; + + BackgroundColor = BackgroundColors.Normal; + } + } + + public void OnSelected() + { + if (iconVisual.URL == System.IO.Path.Combine(Resources.GetPath() + "/images/open_eye.svg")) + { + iconVisual.URL = System.IO.Path.Combine(Resources.GetPath() + "/images/close_eye.svg"); + hide = 0; + } + + else + { + iconVisual.URL = System.IO.Path.Combine(Resources.GetPath() + "/images/open_eye.svg"); + hide = 1; + } + } + } +} diff --git a/SettingWiFi/SettingWiFi/view/Resources.cs b/SettingWiFi/SettingWiFi/view/Resources.cs index 500d58a..4a204a5 100755 --- a/SettingWiFi/SettingWiFi/view/Resources.cs +++ b/SettingWiFi/SettingWiFi/view/Resources.cs @@ -98,6 +98,7 @@ static public string IDS_WIFI_OPT_MOBILEACCESSSERVICEATCIVATION_ON = "On"; static public string IDS_WIFI_OPT_MOBILEACCESSSERVICEATCIVATION_OFF = "Off"; static public string IDS_WIFI_HEADER_PASSWORD = "Password"; + static public string IDS_WIFI_BODY_MAXIMUM_NUMBER_OF_CHARACTERS_REACHED = "Maximum number of characters reached."; static public string IDS_WIFI_BODY_WI_FI = "Wi-Fi"; static public string IDS_WIFI_BODY_UNKNOWN = "Unknown"; static public string IDS_WIFI_BODY_SORT_BY = "Sort by"; @@ -137,6 +138,6 @@ static public string IDS_WIFI_BODY_PROXY = "Proxy"; static public string IDS_WIFI_BODY_DONE = "Done"; static public string IDS_WIFI_BODY_GATEWAY = "Gateway"; - static public string IDS_WIFI_BODY_TYPE_PASSWORD = "Type password."; + static public string IDS_WIFI_BODY_TYPE_PASSWORD = "Type password"; } } diff --git a/packaging/org.tizen.cssetting-wifi-1.1.5.rpk b/packaging/org.tizen.cssetting-wifi-1.1.5.rpk index efd9d1a..5391ede 100644 Binary files a/packaging/org.tizen.cssetting-wifi-1.1.5.rpk and b/packaging/org.tizen.cssetting-wifi-1.1.5.rpk differ