From: Anuj Kumar Singh Date: Tue, 20 Dec 2022 04:13:13 +0000 (+0530) Subject: Resolve issue of adding paired item in device view X-Git-Tag: accepted/tizen/unified/20230103.054909^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a12c8ab62a2bcbda5143045543f5459e41332b36;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-bluetooth.git Resolve issue of adding paired item in device view 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 --- diff --git a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs index e88c629..6aaed09 100644 --- a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs +++ b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs @@ -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; diff --git a/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk b/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk index 3db2709..94c2a61 100644 Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.tpk differ