Resolve issue of adding paired item in device view 76/285776/1 accepted/tizen/unified/20230103.054909
authorAnuj Kumar Singh <anujk.singh@samsung.com>
Tue, 20 Dec 2022 04:13:13 +0000 (09:43 +0530)
committerAnuj Kumar Singh <anujk.singh@samsung.com>
Tue, 20 Dec 2022 04:13:13 +0000 (09:43 +0530)
This patch resolve the following issue:
- Paired item should be added sequentially not rssi descending order like searched item.
- Paired item should come on top of paired devices list when connected.

Change-Id: I5fc0b3a8669fa1e17023e0acdb69e25406de244d
Signed-off-by: Anuj Kumar Singh <anujk.singh@samsung.com>
SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs
packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk

index e88c629a400a392bce92647333fb53370e5dae60..6aaed09e7ab84a571125723415a9b6464fde915d 100644 (file)
@@ -180,7 +180,26 @@ namespace SettingBluetooth
             }
         }
 
-        internal void AddDevice(BtDevice btDevice) // TODO: need to create AddDeviceFront function to add the device in front of the list for paired and unpaired case
+        internal void AddDeviceFront(BtDevice btDevice)
+        {
+            if (this.Count == 0)
+            {
+                this.Add(new Device(btDevice));
+            }
+            else
+            {
+                if (btDevice.DeviceState == BtDeviceState.Connected)
+                {
+                    this.Insert(0, new Device(btDevice));
+                }
+                else
+                {
+                    this.Add(new Device(btDevice));
+                }
+            }
+        }
+
+        internal void AddDevice(BtDevice btDevice)
         {
             if (this.Count == 0)
             {
@@ -252,7 +271,7 @@ namespace SettingBluetooth
             {
                 this.Insert(0, mPaired);
             }
-            mPaired.AddDevice(btDevice); // TODO: need to Add to in front of the list not Insert if paired
+            mPaired.AddDeviceFront(btDevice);
             UpdateState(btDevice); // TODO: don't need to find device item. let's use return value from above function
         }
 
@@ -549,12 +568,16 @@ namespace SettingBluetooth
                 case BtDeviceState.Connected:
                     if (mDeviceSource.FindInPaired(ev.BtDevice) != null)
                     {
+                        mDeviceSource.RemoveFromPaired(ev.BtDevice);
+                        mDeviceSource.AddToPaired(ev.BtDevice);
                         mDeviceSource.UpdateState(ev.BtDevice);
                     }
                     break;
                 case BtDeviceState.Disconnecting:
                     if (mDeviceSource.FindInPaired(ev.BtDevice) != null)
                     {
+                        mDeviceSource.RemoveFromPaired(ev.BtDevice);
+                        mDeviceSource.AddToPaired(ev.BtDevice);
                         mDeviceSource.UpdateState(ev.BtDevice);
                     }
                     break;
index 3db2709ecf038afe234316b46b32df0391de9f9c..94c2a619aaf2731db0eafa867590e6cb75c081a4 100644 (file)
Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk differ