Replace renaming popup to input field as per figma 07/299207/1 accepted/tizen/unified/20230925.091521
authorAkash Kumar <akash1.kumar@samsung.com>
Thu, 21 Sep 2023 10:54:32 +0000 (16:24 +0530)
committerAkash Kumar <akash1.kumar@samsung.com>
Thu, 21 Sep 2023 10:56:54 +0000 (16:26 +0530)
This patch:
 - Resolves https://code.sec.samsung.net/jira/browse/TEIGHT-5173

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

index d13d03e314c7018762c983cfb65fcd18cfc4230a..21caa455d1d811a5986f92d17c02c806bfa6b3d1 100644 (file)
@@ -496,7 +496,10 @@ namespace SettingBluetooth
         {
             try
             {
-                mBluetoothDevice.SetAlias(deviceName);
+                if(mBluetoothDevice.IsPaired || mBluetoothDevice.IsConnected)
+                {
+                    mBluetoothDevice.SetAlias(deviceName);
+                }
             }
             catch (Exception e)
             {
index bfff2710661c272f9f04ba561686204a762e2b76..85e6cdead4f96cd9e15553fb913e363a69a7ae2d 100644 (file)
@@ -12,39 +12,26 @@ namespace SettingBluetooth
     {
         static View mDetailView;
         static ContentPage mDetailPage;
-        static string mBtDeviceName;
         static Device mDevice;
+        private static TextField mDeviceNameField;
+        private static readonly Color underlineColor = new Color("#FF6200");
 
         internal static void CreateDetailView(Device device)
         {
             Window window = NUIApplication.GetDefaultWindow();
             mDevice = device;
 
-            var appBar = new AppBar()
-            {
-                Title = Resources.IDS_BT_BODY_DETAILS,
-            };
-
             mDetailView = new View()
             {
                 Layout = new LinearLayout()
                 {
                     LinearOrientation = LinearLayout.Orientation.Vertical,
-                    HorizontalAlignment = HorizontalAlignment.Center,
                 },
                 WidthSpecification = LayoutParamPolicies.MatchParent,
                 HeightSpecification = LayoutParamPolicies.MatchParent,
             };
 
-            var deviceName = new DefaultLinearItem()
-            {
-                WidthSpecification = LayoutParamPolicies.MatchParent,
-                Text = device.Name,
-                SubText = Resources.IDS_BT_BODY_DEVICENAME,
-            };
-            mBtDeviceName = device.Name;
-            deviceName.Clicked += OnDeviceNameClicked;
-            mDetailView.Add(deviceName);
+            CreateDeviceNameView(device.Name);
 
             var unpairButton = new DefaultLinearItem()
             {
@@ -53,7 +40,6 @@ namespace SettingBluetooth
             };
             unpairButton.Clicked += (obj, ev) =>
             {
-                Log.Info(SettingBluetooth.LogTag, "Unpair to the remote device. Address: " + device.BtDevice.Address + ", Name: " + device.BtDevice.Name);
                 device.BtDevice.Unpair();
                 window.GetDefaultNavigator().Pop();
             };
@@ -94,96 +80,74 @@ namespace SettingBluetooth
 
             mDetailPage = new ContentPage()
             {
-                AppBar = appBar,
+                AppBar = CreateAppBar(),
                 Content = mDetailView,
             };
 
             window.GetDefaultNavigator().Push(mDetailPage);
         }
 
-        private static void OnDeviceNameClicked(object sender, ClickedEventArgs e)
-        {
-            DefaultLinearItem deviceItem = (DefaultLinearItem)sender;
-            var deviceName = deviceItem.BindingContext as string;
-            deviceName = mBtDeviceName;
-            Log.Debug(SettingBluetooth.LogTag, "Name: " + deviceName);
-
-            Window window = NUIApplication.GetDefaultWindow();
-            var connectPage = new RenamePage(deviceName, mDevice);
-            mBtDeviceName =  connectPage.CreateComponents(mBtDeviceName);
-            window.GetDefaultNavigator().Push(connectPage);
-        }
-    }
-
-    internal class RenamePage : DialogPage
-    {
-        TextField mRenameField;
-        static Device mDevice;
-        private static void PopDialog()
-        {
-            Navigator navigator = NUIApplication.GetDefaultWindow().GetDefaultNavigator();
-            navigator?.Pop();
-        }
-
-        internal RenamePage(string deviceName, Device device)
-        {
-            mDevice = device;
-        }
-
-        internal TextField CreateRenameField(string deviceName)
+        private static void CreateDeviceNameView(string deviceName)
         {
-            var mRenameField = new TextField()
+            var label = new TextLabel
             {
-                Text = deviceName,
-                WidthSpecification = 400,
-            };
-            return mRenameField;
-        }
-
-        internal string CreateComponents(string deviceName)
-        {
-            mRenameField = CreateRenameField(deviceName);
-            var cancelButton = new Button()
-            {
-                Text = "Cancel",
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                Text = Resources.IDS_BT_BODY_RENAME,
+                Margin = new Extents(16, 0, 0, 0).SpToPx(),
             };
-            cancelButton.Clicked += OnCancelClicked;
 
-            var renameButton = new Button()
+            mDeviceNameField = new TextField()
             {
-                Text = "Rename",
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = 48,
+                BackgroundColor = Color.White,
+                Text = deviceName,
+                TextColor = Color.Grey,
+                Margin = new Extents(24, 0, 0, 0).SpToPx(),
             };
-            renameButton.Clicked += OnRenameClicked;
 
-            Content = new AlertDialog()
-            {
-                Title = "Rename device",
-                Content = mRenameField,
-                Actions = new View[] { cancelButton, renameButton,},
-            };
-            return mRenameField.Text;
+            mDetailView.Add(label);
+            mDetailView.Add(mDeviceNameField);
+            mDetailView.Add(CreateUnderline());
         }
 
-        private void OnCancelClicked(object source, ClickedEventArgs args)
+        private static View CreateUnderline()
         {
-            Navigator.Pop();
+            return new View()
+            {
+                BorderlineColor = underlineColor,
+                BorderlineWidth = 1,
+                WidthSpecification = LayoutParamPolicies.MatchParent,
+                HeightSpecification = 1,
+                Margin = new Extents(16, 16, 0, 0).SpToPx(),
+            };
         }
 
-        private void OnRenameClicked(object source, ClickedEventArgs args)
+        private static void OnBackClicked(object sender, ClickedEventArgs e)
         {
-            try
+            if (mDeviceNameField.Text == mDevice.Name)
             {
-                mDevice.Name = mRenameField.Text;
-                mDevice.BtDevice.RenameRemoteBtDevice(mDevice.Name);
-                Log.Debug(SettingBluetooth.LogTag, "Updated Device Name: " + mDevice.Name);
+                return;
             }
-            catch(Exception e)
+            if (mDeviceNameField.Text.Length > 0)
             {
-                Log.Debug(SettingBluetooth.LogTag, "Exception : " + e.Message);
+                mDevice.Name = mDeviceNameField.Text;
             }
             NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
-            NUIApplication.GetDefaultWindow().GetDefaultNavigator().Pop();
-            BtDetailView.CreateDetailView(mDevice);
+        }
+
+        private static AppBar CreateAppBar()
+        {
+            var appBar = new AppBar()
+            {
+                Title = Resources.IDS_BT_BODY_DETAILS,
+            };
+            AppBarStyle appBarStyle = (AppBarStyle)ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
+            Button backButton = new Button(((AppBarStyle)appBarStyle).BackButton);
+
+            backButton.Clicked += OnBackClicked;
+            appBar.NavigationContent = backButton;
+            return appBar;
         }
     }
 }
index 56070c65d7ac5d7a708a1ce647f3b21943240a74..53aa6c3aad5a5a066e6ea2436fd29ae26fa976cb 100644 (file)
@@ -86,6 +86,7 @@ namespace SettingBluetooth
             set
             {
                 mName = value;
+                BtDevice.RenameRemoteBtDevice(mName);
                 OnPropertyChanged("Name");
             }
         }
index d2ff9e14efe413200039b7b8d8420e0a6b19a8ee..33ee397b2a6dd2fdf5fec247c57831eab9b309ef 100644 (file)
@@ -42,5 +42,6 @@ namespace SettingBluetooth
             = "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.";
+        static public string IDS_BT_BODY_RENAME = "Rename";
     }
 }
index b6caee700492fea810f488970f3ed39bae69640b..95730eca34af3c445050f376b764644f71c23bcb 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