Add 'visible to nearby devices' info when bt is on 16/299116/3
authorAkash Kumar <akash1.kumar@samsung.com>
Wed, 20 Sep 2023 05:20:00 +0000 (10:50 +0530)
committerAkash Kumar <akash1.kumar@samsung.com>
Wed, 20 Sep 2023 05:39:13 +0000 (11:09 +0530)
This patch:
 - Resolves https://code.sec.samsung.net/jira/browse/TEIGHT-5170
 - Refactors code to add message view for both bt on and bt off case

Change-Id: I9fa74ccba284a6238861afcbfaf03101159042ae
Signed-off-by: Akash Kumar <akash1.kumar@samsung.com>
SettingBluetooth/SettingBluetooth/Model/BtModel.cs
SettingBluetooth/SettingBluetooth/Model/BtModelImpl.cs
SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs
SettingBluetooth/SettingBluetooth/View/BtMainView.cs
SettingBluetooth/SettingBluetooth/View/Resources.cs
packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk

index a6b4e645bf8e2b2d10b53398c788947216f0639f..102d5ec5ce33d2b118f44b5a33fe47db633b34f7 100644 (file)
@@ -24,6 +24,18 @@ namespace SettingBluetooth
             }
         }
 
+        internal static string Name
+        {
+            get
+            {
+                return BtModelImpl.Instance.Name;
+            }
+            set
+            {
+                BtModelImpl.Instance.Name = value;
+            }
+        }
+
         internal static void Enable()
         {
             BtModelImpl.Instance.Enable();
index 200f8c1d5c134b9b94db88039a749257331bdb08..7e7842cba0f931d24cfb80a27fe8dc3a33cd9c95 100644 (file)
@@ -29,6 +29,18 @@ namespace SettingBluetooth
             }
         }
 
+        internal string Name
+        {
+            get
+            {
+                return BluetoothAdapter.Name;
+            }
+            set
+            {
+                BluetoothAdapter.Name = value;
+            }
+        }
+
         internal void Enable()
         {
             try
index 7bb9a8d51c24266b508506bcc64945d3a4802789..56070c65d7ac5d7a708a1ce647f3b21943240a74 100644 (file)
@@ -320,7 +320,7 @@ namespace SettingBluetooth
     {
         static CollectionView mDeviceView = null;
         static DeviceSource mDeviceSource = null;
-        static View mBtOffMessage = null;
+        static TextLabel mBtOffMessage = null;
 
         private static CollectionView CreateCollectionView(DeviceSource source, bool isPairedDeviceView = false)
         {
@@ -387,39 +387,47 @@ namespace SettingBluetooth
         {
             Log.Info(SettingBluetooth.LogTag, "Add device view");
 
-            RemoveBTOffMessage(view);
+            ShowBtOnMessage();
             mDeviceSource = new DeviceSource();
             mDeviceView = CreateCollectionView(mDeviceSource);
             view.Add(mDeviceView);
             BtModel.GetBondedDevices();
         }
 
-       public static View CreateBTOffMessage()
+        public static void CreateBtMessageView(View view)
         {
-            TextLabel messageText = new TextLabel()
+            View messageView = new View()
+            {
+                Layout = new LinearLayout()
+                {
+                    HorizontalAlignment = HorizontalAlignment.Begin,
+                },
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = LayoutParamPolicies.WrapContent,
+            };
+
+            mBtOffMessage = new TextLabel()
             {
                 AccessibilityHidden = true,
                 ThemeChangeSensitive = true,
-                Text = Resources.IDS_BT_BODY_TURN_ON_BLUETOOTH_TO_SEE_A_LIST_OF_DEVICES_YOU_CAN_PAIR_WITH_OR_HAVE_ALREADY_PAIRED_WITH,
-                TextColor = new Color("#CACACA"),
+                TextColor = Color.Grey,
                 PixelSize = 22.SpToPx(),
+                HorizontalAlignment = HorizontalAlignment.Begin,
+                Margin = new Extents(16, 0, 0, 0).SpToPx(),
             };
 
-            return messageText;
+            messageView.Add(mBtOffMessage);
+            view.Add(messageView);
         }
 
-        internal static void AddBTOffMessage(View view)
+        internal static void ShowBtOffMessage()
         {
-            mBtOffMessage = CreateBTOffMessage();
-            view.Add(mBtOffMessage);
+            mBtOffMessage.Text = Resources.IDS_BT_BODY_TURN_ON_BLUETOOTH_TO_SEE_A_LIST_OF_DEVICES_YOU_CAN_PAIR_WITH_OR_HAVE_ALREADY_PAIRED_WITH;
         }
-        internal static void RemoveBTOffMessage(View view)
+
+        internal static void ShowBtOnMessage()
         {
-            if (mBtOffMessage != null)
-            {
-                view.Remove(mBtOffMessage);
-                mBtOffMessage = null;
-            }
+            mBtOffMessage.Text = string.Format(Resources.IDS_BT_BODY_YOUR_DEVICE_IS_CURRENTLY_VISIBLE_TO_NEARBY_DEVICES, BtModel.Name);
         }
 
         internal static void RemoveDeviceView(View view)
@@ -431,7 +439,8 @@ namespace SettingBluetooth
                 view.Remove(mDeviceView);
                 mDeviceView = null;
             }
-            AddBTOffMessage(view);
+
+            ShowBtOffMessage();
         }
 
         internal static void RemoveAllSearchedDevices()
index e22071bb49390c5ba83d2a8af5de7cc5a1c5b648..6f0ce556e5a481c0d1eb8ff3dc45f421596dcdc2 100644 (file)
@@ -81,6 +81,7 @@ namespace SettingBluetooth
             onOffSwitch.SelectedChanged += AdapterController.OnOffSwitchSelectedChanged;
             onOffItem.Extra = onOffSwitch;
             mMainView.Add(onOffItem);
+            BtDeviceView.CreateBtMessageView(mMainView);
 
             BtModel.OperationStateChanged += BtModelOperationStateChanged;
             BtModel.DeviceChanged += BtDeviceView.BtModelDeviceChanged;
@@ -95,7 +96,7 @@ namespace SettingBluetooth
             }
             else
             {
-                BtDeviceView.AddBTOffMessage(mMainView);
+                BtDeviceView.ShowBtOffMessage();
             }
 
             return mMainView;
index f2d96f24466e43df0d031150564bc79360c8fe06..d2ff9e14efe413200039b7b8d8420e0a6b19a8ee 100644 (file)
@@ -40,5 +40,7 @@ namespace SettingBluetooth
         static public string IDS_WMGR_POP_THIS_WILL_END_YOUR_CONNECTION_WITH_PS = "This will end your connection with {0}.";
         static public string IDS_BT_BODY_TURN_ON_BLUETOOTH_TO_SEE_A_LIST_OF_DEVICES_YOU_CAN_PAIR_WITH_OR_HAVE_ALREADY_PAIRED_WITH
             = "Turn on Bluetooth to see a list of devices you can pair with or have already paired with.";
+        static public string IDS_BT_BODY_YOUR_DEVICE_IS_CURRENTLY_VISIBLE_TO_NEARBY_DEVICES
+            = "Your device ({0}) is currently visible to nearby devices.";
     }
 }
index b89c5530f9639b2fa3d050722929a845f043e58e..b6caee700492fea810f488970f3ed39bae69640b 100644 (file)
Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk differ