Update Info page as per figma design 30/299030/4 accepted/tizen/unified/20230921.171327
authorAkash Kumar <akash1.kumar@samsung.com>
Mon, 18 Sep 2023 11:05:52 +0000 (16:35 +0530)
committerAkash Kumar <akash1.kumar@samsung.com>
Thu, 21 Sep 2023 04:29:15 +0000 (09:59 +0530)
This patch:
 - Adds textfield to update ap information instead of popups
 - Updates infopage header and item font as per figma
 - Resolves https://code.sec.samsung.net/jira/browse/TEIGHT-5159
 - Resolves https://code.sec.samsung.net/jira/browse/TEIGHT-5158

Change-Id: Iea675aac93183f100f224fbb637b6850c399a719
Signed-off-by: Akash Kumar <akash1.kumar@samsung.com>
SettingWiFi/SettingWiFi/controller/WiFi.cs
SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/rectangle_for_info_page.png [new file with mode: 0644]
SettingWiFi/SettingWiFi/view/InfoItem.cs [new file with mode: 0644]
SettingWiFi/SettingWiFi/view/InfoPage.cs
packaging/org.tizen.cssetting-wifi-1.1.4.rpk

index 9f3e95fd1212d525b25c9f0d79920d6e8766e290..a9106f773da76388544f0d2003f046592cac461c 100755 (executable)
@@ -372,6 +372,37 @@ namespace SettingWiFi
             return wpsPin;\r
         }\r
 \r
+        public void SyncAPObjectState(AP ap)\r
+        {\r
+            if (ap.IsConnected())\r
+            {\r
+                ap.ApHandle.Refresh();\r
+            }\r
+            var networkInfo = ap.ApHandle.NetworkInformation;\r
+            ap.IPv4 = networkInfo.IPv4Setting.IP.ToString();\r
+            var proxy = networkInfo.ProxyAddress;\r
+            if (proxy.Contains(':'))\r
+            {\r
+                var result = proxy.Split(":");\r
+                ap.ProxyAddress = result[0];\r
+                int port = 0;\r
+                if (Int32.TryParse(result[1], out port))\r
+                {\r
+                    ap.ProxyPort = port;\r
+                }\r
+                else\r
+                {\r
+                    ap.ProxyPort = 0;\r
+                }\r
+            }\r
+\r
+            ap.Dns1 = networkInfo.IPv4Setting.Dns1.ToString();\r
+            ap.Dns2 = networkInfo.IPv4Setting.Dns2.ToString();\r
+            ap.SubnetMask = networkInfo.IPv4Setting.SubnetMask.ToString();\r
+            ap.GatewayAddress = networkInfo.IPv4Setting.Gateway.ToString();\r
+            ap.NetworkPrefixLength = networkInfo.IPv4Setting.PrefixLength.ToString();\r
+        }\r
+\r
         public void UpdateIpConfigMethod(AP ap, bool isStaticIpConfig)\r
         {\r
             if (isStaticIpConfig)\r
diff --git a/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/rectangle_for_info_page.png b/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/rectangle_for_info_page.png
new file mode 100644 (file)
index 0000000..458ebe4
Binary files /dev/null and b/SettingWiFi/SettingWiFi/res/allowed/SettingWiFi/images/rectangle_for_info_page.png differ
diff --git a/SettingWiFi/SettingWiFi/view/InfoItem.cs b/SettingWiFi/SettingWiFi/view/InfoItem.cs
new file mode 100644 (file)
index 0000000..7d54696
--- /dev/null
@@ -0,0 +1,109 @@
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using SettingCore;
+using SettingCore.Views;
+
+namespace SettingWiFi
+{
+    public class InfoItem : BaseComponent
+    {
+        private TextField textField;
+        private TextLabel primary = null;
+        private TextLabel secondaryLabel = null;
+
+        private readonly Color underlineColor = new Color("#FF6200");
+        private readonly Color disabledItemColor = new Color("#CACACA");
+        public string Value
+        {
+            get
+            {
+                return textField.Text;
+            }
+            set
+            {
+                textField.Text = value;
+            }
+        }
+
+        private TextLabel GetLabel(string titleText, bool isEnabled)
+        {
+            var label = new TextLabel
+            {
+                AccessibilityHidden = true,
+                ThemeChangeSensitive = true,
+                Text = titleText,
+                Margin = new Extents(16, 0, 0, 0).SpToPx(),
+                PixelSize = 24.SpToPx(),
+            };
+            if (!isEnabled)
+            {
+                label.TextColor = disabledItemColor;
+            }
+
+            return label;
+        }
+        public InfoItem(string primaryText, bool isEnabled , string curvalue, bool fillValue, bool drawUnderline = true)
+            : base()
+        {
+            Layout = new LinearLayout()
+            {
+                LinearOrientation = LinearLayout.Orientation.Vertical,
+            };
+            Padding = new Extents(0, 0, 8, 8).SpToPx();
+
+            primary = GetLabel(primaryText, isEnabled);
+            Add(primary);
+
+            if (!isEnabled)
+            {
+                secondaryLabel = GetLabel(curvalue, false);
+                Add(secondaryLabel);
+            }
+            else
+            {
+                var textFieldView = new View
+                {
+                    WidthSpecification = LayoutParamPolicies.MatchParent,
+                    Margin = new Extents(16, 16, 0, 0).SpToPx(),
+                    Layout = new LinearLayout()
+                    {
+                        LinearOrientation = LinearLayout.Orientation.Vertical,
+                    },
+                };
+                textField = new TextField()
+                {
+                    WidthSpecification = LayoutParamPolicies.MatchParent,
+                    HeightSpecification = 48,
+                    BackgroundColor = Color.White,
+                    PlaceholderText = curvalue,
+                    Padding = new Extents(16, 16, 0, 0).SpToPx(),
+                };
+
+                textFieldView.Add(textField);
+                if (fillValue)
+                {
+                    textField.Text = curvalue;
+                }
+                if (drawUnderline)
+                {
+                    textFieldView.Add(CreateUnderline());
+                }
+
+                Add(textFieldView);
+            }
+        }
+
+        private View CreateUnderline()
+        {
+            return new View()
+            {
+                BorderlineColor = underlineColor,
+                BorderlineWidth = 1,
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = 1,
+            };
+        }
+    }
+}
index 1bc1efe6a353995b7f708c6e102de96d486cb36d..a992e6efa3bc78098f67b1c7f2f646eb087f6e7d 100755 (executable)
@@ -1,4 +1,5 @@
 using SettingCore;
+using SettingCore.Views;
 using System;
 using System.Collections.Generic;
 using Tizen;
@@ -6,22 +7,21 @@ using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Binding;
 using Tizen.NUI.Components;
-//using SettingWiFi.res.locale;
 using static SettingWiFi.Logger;
 
 namespace SettingWiFi
 {
     internal class InfoPage : ContentPage
     {
-        Switch mOnOffSwitch;
-        CollectionView mApInfoListView;
-
         private AP mAp;
         private WiFi mWifi;
 
-        ApInfoSource mApInfoSource;
-
-        bool mIsOriginOnOffSwitchSelected;
+        private View mInfoView;
+        private ScrollableBase mScrollableInfo;
+        private Switch mOnOffSwitch;
+        private InfoItem[] staticItems = new InfoItem[9];
+        private InfoItem[] dynamicItems = new InfoItem[4];
+        private bool mIsOriginOnOffSwitchSelected;
 
         internal InfoPage(WiFi wifi)
         {
@@ -31,19 +31,7 @@ namespace SettingWiFi
         internal void CreateComponents(AP ap)
         {
             mAp = ap;
-
-            var appBar = new AppBar()
-            {
-                Title = Resources.IDS_WIFI_HEADER_WI_FI_NETWORK_INFO_ABB,
-            };
-
-            AppBarStyle appBarStyle = (AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
-            Button backButton = new Button(((AppBarStyle)appBarStyle).BackButton);
-
-            backButton.Clicked += OnBackClicked;
-            appBar.NavigationContent = backButton;
-
-            View infoView = new View()
+            mInfoView = new View()
             {
                 Layout = new LinearLayout()
                 {
@@ -54,20 +42,21 @@ namespace SettingWiFi
                 HeightSpecification = LayoutParamPolicies.MatchParent,
             };
 
-            mApInfoSource = new ApInfoSource(mWifi, mAp);
-
-            mApInfoListView = new CollectionView()
+            mScrollableInfo = new ScrollableBase()
             {
-                ItemsSource = mApInfoSource,
-                ItemsLayouter = new LinearLayouter(),
-                ItemTemplate = CreateItemTemplate(),
-                IsGrouped = false,
-                ScrollingDirection = ScrollableBase.Direction.Vertical,
                 WidthSpecification = LayoutParamPolicies.MatchParent,
                 HeightSpecification = LayoutParamPolicies.MatchParent,
-            };
+                ScrollingDirection = ScrollableBase.Direction.Vertical,
+                HideScrollbar = false,
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Vertical,
+                },
 
-            var header = GetHeader();
+            };
+            mIsOriginOnOffSwitchSelected = ap.StaticIPConfig;
+            AddHeader();
+            AddInfo();
 
             var forgetButton = new Button()
             {
@@ -77,92 +66,30 @@ namespace SettingWiFi
             };
 
             forgetButton.Clicked += OnForgetClicked;
+            mInfoView.Add(forgetButton);
 
-            infoView.Add(header);
-            infoView.Add(mApInfoListView);
-            infoView.Add(forgetButton);
-
-            AppBar = appBar;
-            Content = infoView;
-
-            mApInfoSource.ShowInfo(mOnOffSwitch.IsSelected, false);
-        }
-
-        private void OnInfoItemClicked(object sender, ClickedEventArgs e)
-        {
-            Debug("OnInfoItemClicked");
-            DefaultLinearItem infoItem = (DefaultLinearItem)sender;
-            var info = infoItem.BindingContext as ApInfoText;
-            if (info == null)
-            {
-                Error("Info null");
-            }
-            else
-            {
-                Debug("Ok info");
-                if(IsFieldEditable(info.InfoTitle))
-                {
-                    RoundedDialogPage.ShowDialog(CreateInfoInputPage(info.InfoTitle, info.InfoValue));
-                    //NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(CreateInfoInputPage(info.InfoTitle, info.InfoValue));
-                }
-            }
+            AppBar = CreateAppBar();
+            Content = mInfoView;
         }
 
-        private bool IsFieldEditable(string fieldName)
+        private AppBar CreateAppBar()
         {
-            // Checks if particular field on info page is editable or not.
-            if (fieldName == Resources.IDS_WIFI_BODY_MAC_ADDRESS)
-            {
-                return false;
-            }
-            else
+            var appBar = new AppBar()
             {
-                if (mOnOffSwitch.IsSelected)
-                {
-                    return true;
-                }
-                else
-                {
-                    if(fieldName == Resources.IDS_ST_SBODY_PROXY_ADDRESS || fieldName == Resources.IDS_ST_SBODY_PROXY_PORT)
-                    {
-                        return true;
-                    }
-                    else
-                    {
-                        return false;
-                    }
-                }
-            }
-        }
-
-        private Page CreateInfoInputPage(string title, string value)
-        {
-            var page = new InfoInputPage(mAp, mApInfoSource, mOnOffSwitch.IsSelected);
-            page.CreateComponents(title, value);
-            return page;
-        }
+                Title = Resources.IDS_WIFI_HEADER_WI_FI_NETWORK_INFO_ABB,
+            };
+            AppBarStyle appBarStyle = (AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
+            Button backButton = new Button(((AppBarStyle)appBarStyle).BackButton);
 
-        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;
-            });
+            backButton.Clicked += OnBackClicked;
+            appBar.NavigationContent = backButton;
+            return appBar;
         }
 
-        private RecyclerViewItem GetHeader()
+        private void AddHeader()
         {
-            var header = new RecyclerViewItem()
+            Debug("");
+            View headerView = new View()
             {
                 Layout = new LinearLayout()
                 {
@@ -188,16 +115,148 @@ namespace SettingWiFi
             mOnOffSwitch.SelectedChanged += OnSwitchClicked;
 
             toggle.Extra = mOnOffSwitch;
-            header.Add(toggle);
 
-            return header;
+            headerView.Add(CreateAPTitleView());
+            headerView.Add(toggle);
+
+            mInfoView.Add(headerView);
+        }
+
+        private View CreateAPTitleView()
+        {
+            var textFieldView = new View
+            {
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                Margin = new Extents(16, 16, 16, 16).SpToPx(),
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Horizontal,
+                    VerticalAlignment = VerticalAlignment.Center,
+                },
+            };
+
+            string iconpath = Resources.GetPath() + "/images/rectangle_for_info_page.png";
+            var icon = new ImageView(iconpath)
+            {
+                Size2D = new Size2D(32, 32).SpToPx(),
+                Margin = new Extents(0, 5, 0, 0).SpToPx(),
+            };
+
+            TextLabel title = new TextLabel()
+            {
+                Text = mAp.Essid,
+                HorizontalAlignment = HorizontalAlignment.Begin,
+                Margin = new Extents(16, 0, 0, 0),
+            };
+
+            textFieldView.Add(icon);
+            textFieldView.Add(title);
+            return textFieldView;
+        }
+
+        private void AddInfo()
+        {
+            mScrollableInfo.RemoveAllChildren();
+            mWifi.SyncAPObjectState(mAp);
+
+            if (mOnOffSwitch.IsSelected)
+            {
+                // Static Info to show
+                ShowStaticInfo();
+            }
+            else
+            {
+                ShowDynamicInfo();
+            }
+        }
+        private void ShowStaticInfo()
+        {
+            GetStaticInfo();
+            mInfoView.Add(mScrollableInfo);
+        }
+
+        private void ShowDynamicInfo()
+        {
+            Debug("+");
+            GetDynamicInfo();
+            mInfoView.Add(mScrollableInfo);
+        }
+
+        private void GetStaticInfo()
+        {
+            Debug("+");
+            staticItems[0] = new InfoItem(Resources.IDS_WIFI_BODY_IP_ADDRESS, true, mAp.IPv4, true);
+            staticItems[1] = new InfoItem(Resources.IDS_WIFI_BODY_SUBNET_MASK, true, mAp.SubnetMask, true);
+            staticItems[2] = new InfoItem(Resources.IDS_WIFI_BODY_GATEWAY, true, mAp.GatewayAddress, true);
+            staticItems[3] = new InfoItem(Resources.IDS_ST_BODY_NETWORK_PREFIX_LENGTH, true, mAp.NetworkPrefixLength, true);
+            staticItems[4] = new InfoItem(Resources.IDS_WIFI_BODY_DNS_1, true, mAp.Dns1, true);
+            staticItems[5] = new InfoItem(Resources.IDS_WIFI_BODY_DNS_2, true, mAp.Dns2, true);
+            staticItems[6] = new InfoItem(Resources.IDS_WIFI_BODY_MAC_ADDRESS, false, mAp.Bssid, true);
+            if(mAp.ProxyAddress?.Length > 0)
+            {
+                staticItems[7] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, mAp.ProxyAddress, true, false);
+            }
+            else
+            {
+                staticItems[7] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, "proxy.example.com", false, false);
+            }
+            if(mAp.ProxyPort > 0)
+            {
+                string port = "" + mAp.ProxyPort;
+                staticItems[8] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, port, true, false);
+            }
+            else
+            {
+                staticItems[8] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, "8080", false, false);
+            }
+
+
+            foreach (var item in staticItems)
+            {
+                mScrollableInfo.Add(item);
+            }
+        }
+
+        private void GetDynamicInfo()
+        {
+            Debug("+");
+            dynamicItems[0] = new InfoItem(Resources.IDS_WIFI_BODY_IP_ADDRESS, false, mAp.IPv4, true);
+            dynamicItems[1] = new InfoItem(Resources.IDS_WIFI_BODY_MAC_ADDRESS, false, mAp.Bssid, true);
+
+            if (mAp.ProxyAddress?.Length > 0)
+            {
+                dynamicItems[2] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, mAp.ProxyAddress, true, false);
+            }
+            else
+            {
+                dynamicItems[2] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_ADDRESS, true, "proxy.example.com", false,  false);
+            }
+            if (mAp.ProxyPort > 0)
+            {
+                string port = "" + mAp.ProxyPort;
+                new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, port,true,  false);
+            }
+            else
+            {
+                dynamicItems[3] = new InfoItem(Resources.IDS_ST_SBODY_PROXY_PORT, true, "8080", false, false);
+            }
+            foreach (var item in dynamicItems)
+            {
+                mScrollableInfo.Add(item);
+            }
         }
 
         private void OnSwitchClicked(object sender, SelectedChangedEventArgs e)
         {
-            mAp.StaticIPConfig = mOnOffSwitch.IsSelected;
-            mApInfoSource.Clear();
-            mApInfoSource.ShowInfo(e.IsSelected, true);
+            Debug("");
+            if (mAp.IsConnected())
+            {
+                mAp.StaticIPConfig = mOnOffSwitch.IsSelected;
+                mWifi.UpdateIpConfigMethod(mAp, mOnOffSwitch.IsSelected);
+                mWifi.UpdateApInfo(mAp);
+            }
+
+            AddInfo();
         }
 
         private ContentPage CreateForgetPage()
@@ -246,39 +305,60 @@ namespace SettingWiFi
 
         private void OnBackClicked(object source, ClickedEventArgs args)
         {
-            if (mIsOriginOnOffSwitchSelected != mOnOffSwitch.IsSelected)
-            {
-                UpdateApInfo(mOnOffSwitch.IsSelected);
-            }
-            mAp.StaticIPConfig = mOnOffSwitch.IsSelected;
-            NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
-        }
-
-        private void UpdateApInfo(bool isStaticIpConfig)
-        {
-            Debug("");
+            Debug("+");
             if (mAp.IsConnected())
             {
-                mWifi.UpdateIpConfigMethod(mAp, isStaticIpConfig);
-                if (isStaticIpConfig)
+                if (mOnOffSwitch.IsSelected)
                 {
-                    GetStaticIpInfo();
+                    UpdateStaticIpInfo();
                 }
+                else
+                {
+                    UpdateDynamicIpInfo();
+                }
+
                 mWifi.UpdateApInfo(mAp);
             }
+
+            NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+        }
+
+        private void UpdateStaticIpInfo()
+        {
+            Debug("+");
+
+            mWifi.UpdateIPAddress(mAp, staticItems[0].Value);
+            mWifi.UpdateSubnetMask(mAp, staticItems[1].Value);
+            mWifi.UpdateGatewayAddress(mAp, staticItems[2].Value);
+            mWifi.UpdateDns1(mAp, staticItems[4].Value);
+            mWifi.UpdateDns2(mAp, staticItems[5].Value);
+            UpdateProxy(staticItems[7].Value, staticItems[8].Value);
         }
 
-        private void GetStaticIpInfo()
+        private void UpdateDynamicIpInfo()
         {
-            Debug("GetStaticIpInfo from mApInfoSource");
-            var list = mApInfoSource.GetItemList();
-            foreach (var info in list)
+            Debug("+");
+            UpdateProxy(dynamicItems[2].Value, dynamicItems[3].Value);
+        }
+
+        public void UpdateProxy(string proxy, string port)
+        {
+            if(proxy?.Length > 0)
             {
-                if (info.mUpdater != null)
-                    info.mUpdater(info.InfoValue);
+                int portNum;
+                if (Int32.TryParse(port, out portNum) == false)
+                {
+                    Error("port parsing error");
+                    return;
+                }
+                else
+                {
+                    proxy = proxy + ":" + portNum;
+                }
+                Debug("Proxy: " + proxy);
+                mWifi.UpdateProxy(mAp, proxy);
             }
         }
-
         private void OnForgetClicked(object source, ClickedEventArgs args)
         {
             Debug("Forget " + mAp.Essid);
index 7651cea5895f970dc41561b7f0122d4e81c33927..4a7dc8b2c216713fe62cb87cbdbb07473ed49b64 100644 (file)
Binary files a/packaging/org.tizen.cssetting-wifi-1.1.4.rpk and b/packaging/org.tizen.cssetting-wifi-1.1.4.rpk differ