Resolve Sort by menu in advanced settings not working issue 97/306397/3
authorSameer Kumar <sameer.kumar@samsung.com>
Wed, 21 Feb 2024 05:21:01 +0000 (10:51 +0530)
committerAnuj Kumar Singh <anujk.singh@samsung.com>
Tue, 27 Feb 2024 07:05:51 +0000 (12:35 +0530)
This patch:
 - Resolve https://jira.sec.samsung.net/browse/TNINE-366

Change-Id: I5cbbd591cbce1db92e4b6937c60ddedd5728ae15
Signed-off-by: Sameer Kumar <sameer.kumar@samsung.com>
SettingWiFi/SettingWiFi/view/APSource.cs
SettingWiFi/SettingWiFi/view/AdvancedPage.cs
SettingWiFi/SettingWiFi/view/MainPage.cs
SettingWiFi/SettingWiFi/view/Resources.cs
SettingWiFi/SettingWiFi/view/SortBy.cs [new file with mode: 0644]
packaging/org.tizen.cssetting-wifi-1.1.5.rpk

index 7696e6269b62ed16f536f8149248402aea1d9826..ab82abbe20a61fbbe65d160281ce92691df8b1eb 100755 (executable)
@@ -9,7 +9,9 @@ using Tizen.NUI.Binding;
 using Tizen.Network.WiFi;\r
 //using SettingWiFi.res.locale;\r
 using static SettingWiFi.Logger;\r
-\r
+using System.Linq;\r
+using System.Collections;\r
+using Interop;\r
 \r
 namespace SettingWiFi\r
 {\r
@@ -37,6 +39,7 @@ namespace SettingWiFi
                 OnPropertyChanged(new PropertyChangedEventArgs("Title"));\r
             }\r
         }\r
+\r
         public float IconOpacity\r
         {\r
             get => iconOpacity;\r
@@ -67,6 +70,49 @@ namespace SettingWiFi
             }\r
         }\r
 \r
+        public void SortScanListByAlphabet(List<AP> apList)\r
+        {\r
+            Debug("SortScanListAlphabet called");\r
+            if (apList == null)\r
+            {\r
+                Debug("apList is null");\r
+                return;\r
+            }\r
+\r
+            while (this.Count > 0)\r
+            {\r
+                this.RemoveAt(this.Count - 1);\r
+            }\r
+\r
+            var sortedApList = apList.OrderBy(ap => ap.Essid).ToList();\r
+\r
+            foreach (var item in sortedApList)\r
+            {\r
+                this.Add(item);\r
+            }\r
+        }\r
+\r
+        public void SortScanListByStrength(List<AP> apList)\r
+        {\r
+            Debug("SortScanListStrength called");\r
+            if (apList == null)\r
+            {\r
+                Debug("apList is null");\r
+                return;\r
+            }\r
+\r
+            while (this.Count > 0)\r
+            {\r
+                this.RemoveAt(this.Count - 1);\r
+            }\r
+            var sortedApList = apList.OrderBy(ap => ap.SignalStrength).ToList();\r
+\r
+            foreach (var item in sortedApList)\r
+            {\r
+                this.Add(item);\r
+            }\r
+        }\r
+\r
         public void RemoveScanList()\r
         {\r
             while (this.Count > 0)\r
@@ -154,10 +200,10 @@ namespace SettingWiFi
                 {\r
                     ap.ProxyPort = port;\r
                 }\r
-            else\r
-            {\r
-                ap.ProxyPort = -1;\r
-            }\r
+                else\r
+                {\r
+                    ap.ProxyPort = -1;\r
+                }\r
             }\r
 \r
             ap.StaticIPConfig = (networkInfo.IPv4Setting.IPConfigType == Tizen.Network.Connection.IPConfigType.Static);\r
@@ -203,6 +249,16 @@ namespace SettingWiFi
             available.UpdateScanList(apList);\r
         }\r
 \r
+        public void SortScanListByAlphabet(List<AP> apList)\r
+        {\r
+            available.SortScanListByAlphabet(apList);\r
+        }\r
+\r
+        public void SortScanListByStrength(List<AP> apList)\r
+        {\r
+            available.SortScanListByStrength(apList);\r
+        }\r
+\r
         public void RemoveScanList()\r
         {\r
             available.RemoveScanList();\r
index aed6788e009f2c10dd805e94fabc8aeaa0eeb4df..2e10fcbc54f1a294ced24ddd13dabcbb6b9abf72 100755 (executable)
@@ -13,10 +13,15 @@ namespace SettingWiFi
     {
         private WiFi mWifi;
         private APSource mApSource;
+        private List<AP> mApList;
+        private SortBy sortView;
 
-        internal AdvancedPage(WiFi wifi)
+
+        internal AdvancedPage(WiFi wifi, List<AP> apList)
         {
             mWifi = wifi;
+            mApList = apList;
+
         }
 
         internal void CreateComponents(APSource apSource)
@@ -77,12 +82,16 @@ namespace SettingWiFi
             AppBar = CreateAppBar(Resources.IDS_WIFI_BODY_ADVANCED_SETTINGS);
             Content = advacedView;
         }
-
         private void OnSortByClicked(object sender, ClickedEventArgs ev)
         {
-            // TO DO: Need to be completed.
-            // IDS_EMAIL_POP_ALPHABETICAL
-            // IDS_WIFI_MBODY_SIGNAL_STRENGTH_KOR_SKT
+            var sortPage = CreateSortByPage();
+            NUIApplication.GetDefaultWindow().GetDefaultNavigator().Push(sortPage);
+        }
+        internal ContentPage CreateSortByPage()
+        {
+            var page = new SortBy(mApList);
+            page.CreateSortByComponent(mApSource);
+            return page;
         }
 
         private void OnInstallCerticateClicked(object obj, ClickedEventArgs arg)
index c6696385fa4d7d44f881277394f6931af6d1c102..d2d6656d98d3557caa114994169f1753ccabcce0 100755 (executable)
@@ -19,6 +19,7 @@ namespace SettingWiFi
         private CollectionView mScanList;
         private Button mScanButton, mAddNetwork;
         private List<MoreMenuItem> mMenus;
+        private List<AP> mApList;
         private MoreMenuItem mHiddenMenuItem, mWifiDirectMenuItem;
 
         public override string ProvideIconPath() => GetResourcePath("main-menu-wifi-icon.svg");
@@ -366,7 +367,7 @@ namespace SettingWiFi
 
         internal ContentPage CreateAdvancedPage()
         {
-            var page = new AdvancedPage(mWifi);
+            var page = new AdvancedPage(mWifi, mApList);
             page.CreateComponents(mApSource);
             return page;
         }
@@ -504,8 +505,8 @@ namespace SettingWiFi
             {
                 mApSource.SetScanningState(true);
                 await mWifi.Scan();
-                List<AP> apList = mWifi.GetScanResult();
-                mApSource.UpdateScanList(apList);
+                mApList = mWifi.GetScanResult();
+                mApSource.UpdateScanList(mApList);
                 mApSource.SetScanningState(false);
             }
         }
index 4a204a541bbf7fae375ddfd024834d639d308b7c..1c86d46aa2a60ca65ce891288b708b0b48e6f012 100755 (executable)
         static public string IDS_WIFI_BODY_WI_FI = "Wi-Fi";\r
         static public string IDS_WIFI_BODY_UNKNOWN = "Unknown";\r
         static public string IDS_WIFI_BODY_SORT_BY = "Sort by";\r
+        static public string IDS_WIFI_BODY_ALPHABETICAL = "Alphabetical";\r
+        static public string IDS_WIFI_BODY_SIGNAL_STRENGTH = "Signal Strength";\r
         static public string IDS_WIFI_BODY_SCANNING_ING = "Scanning...";\r
         static public string IDS_WIFI_BODY_NAME = "Name";\r
         static public string IDS_WIFI_BODY_CONNECT = "Connect";\r
diff --git a/SettingWiFi/SettingWiFi/view/SortBy.cs b/SettingWiFi/SettingWiFi/view/SortBy.cs
new file mode 100644 (file)
index 0000000..25f2026
--- /dev/null
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI;
+using Tizen.NUI.Components;
+using Tizen.NUI.Binding;
+using SettingCore.Views;
+using Interop;
+using System.Diagnostics;
+
+namespace SettingWiFi
+{
+    public class SortBy : ContentPage
+    {
+        private APSource mApSource;
+        private List<AP> mApList;
+        public SortBy(List<AP> apList)
+        {
+            mApList = apList;
+        }
+        internal void CreateSortByComponent(APSource apSource)
+        {
+            mApSource = apSource;
+            View sortView = new View()
+            {
+                Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Vertical,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                },
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.MatchParent,
+            };
+
+            var sortByAlphabet = new DefaultLinearItem()
+            {
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                Text = Resources.IDS_WIFI_BODY_ALPHABETICAL,
+                IsSelectable = false,
+            };
+            sortByAlphabet.Clicked += OnSortByAlphabetClicked;
+            sortByAlphabet.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
+            sortView.Add(sortByAlphabet);
+
+            var sortByStrength = new DefaultLinearItem()
+            {
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                Text = Resources.IDS_WIFI_BODY_SIGNAL_STRENGTH,
+                IsSelectable = false,
+            };
+            sortByStrength.Clicked += OnSortByStrengthClicked;
+            sortView.Add(sortByAlphabet);
+            sortView.Add(sortByStrength);
+
+            AppBar = CreateAppBar(Resources.IDS_WIFI_BODY_SORT_BY);
+            Content = sortView;
+        }
+        protected virtual AppBar CreateAppBar(string title)
+        {
+            var appBar = new AppBar()
+            {
+                Title = title,
+                AutoNavigationContent = false,
+            };
+            var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
+            var navigationContent = new BackButton();
+            navigationContent.Clicked += (o, e) =>
+            {
+                NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
+            };
+            appBar.NavigationContent = navigationContent;
+            return appBar;
+        }
+        private void OnSortByAlphabetClicked(object obj, ClickedEventArgs arg)
+        {
+
+            mApSource.SortScanListByAlphabet(mApList);
+        }
+        private void OnSortByStrengthClicked(object obj, ClickedEventArgs arg)
+        {
+
+            mApSource.SortScanListByStrength(mApList);
+        }
+
+    }
+}
index a5708afc7c53c47604bde8c5f08a6b6f9dac6d71..592ac140cf7da002110d0a95b4d9e58f6d5c987d 100644 (file)
Binary files a/packaging/org.tizen.cssetting-wifi-1.1.5.rpk and b/packaging/org.tizen.cssetting-wifi-1.1.5.rpk differ