From: Akash Kumar Date: Wed, 20 Sep 2023 05:20:00 +0000 (+0530) Subject: Add 'visible to nearby devices' info when bt is on X-Git-Tag: accepted/tizen/unified/20230925.091521~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f8dadfd288f024dc29452227a5b42b727158c68;p=profile%2Fiot%2Fapps%2Fdotnet%2Fsetting-bluetooth.git Add 'visible to nearby devices' info when bt is on 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 --- diff --git a/SettingBluetooth/SettingBluetooth/Model/BtModel.cs b/SettingBluetooth/SettingBluetooth/Model/BtModel.cs index a6b4e64..102d5ec 100644 --- a/SettingBluetooth/SettingBluetooth/Model/BtModel.cs +++ b/SettingBluetooth/SettingBluetooth/Model/BtModel.cs @@ -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(); diff --git a/SettingBluetooth/SettingBluetooth/Model/BtModelImpl.cs b/SettingBluetooth/SettingBluetooth/Model/BtModelImpl.cs index 200f8c1..7e7842c 100644 --- a/SettingBluetooth/SettingBluetooth/Model/BtModelImpl.cs +++ b/SettingBluetooth/SettingBluetooth/Model/BtModelImpl.cs @@ -29,6 +29,18 @@ namespace SettingBluetooth } } + internal string Name + { + get + { + return BluetoothAdapter.Name; + } + set + { + BluetoothAdapter.Name = value; + } + } + internal void Enable() { try diff --git a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs index 7bb9a8d..56070c6 100644 --- a/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs +++ b/SettingBluetooth/SettingBluetooth/View/BtDeviceView.cs @@ -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() diff --git a/SettingBluetooth/SettingBluetooth/View/BtMainView.cs b/SettingBluetooth/SettingBluetooth/View/BtMainView.cs index e22071b..6f0ce55 100644 --- a/SettingBluetooth/SettingBluetooth/View/BtMainView.cs +++ b/SettingBluetooth/SettingBluetooth/View/BtMainView.cs @@ -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; diff --git a/SettingBluetooth/SettingBluetooth/View/Resources.cs b/SettingBluetooth/SettingBluetooth/View/Resources.cs index f2d96f2..d2ff9e1 100644 --- a/SettingBluetooth/SettingBluetooth/View/Resources.cs +++ b/SettingBluetooth/SettingBluetooth/View/Resources.cs @@ -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."; } } diff --git a/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk b/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk index b89c553..b6caee7 100644 Binary files a/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk and b/packaging/org.tizen.cssetting-bluetooth-1.0.0.rpk differ