DialogPage.ShowAlertDialog(Resources.IDS_BT_HEADER_DISCONNECT_DEVICE_ABB, String.Format(Resources.IDS_WMGR_POP_THIS_WILL_END_YOUR_CONNECTION_WITH_PS, btDevice.Name), cancelButton, disconnectButton);
}
- private static void ConnectA2dp(BtDevice device)
+ internal static void ConnectA2dp(BtDevice device)
{
+ Log.Info(Program.LogTag, "Connect to the remote audio device");
device.ConnectAudio();
}
- private static void DisconnectA2dp(BtDevice btDevice)
+ internal static void DisconnectA2dp(BtDevice btDevice)
{
var disconnectButton = new Button()
{
private static void ConnectHid(BtDevice device)
{
+ Log.Info(Program.LogTag, "Connect to the remote hid device");
device.ConnectHid();
}
var device = deviceItem.BindingContext as Device;
Log.Info(Program.LogTag, "DeviceItem clicked. Address: " + device.Address + ", Name: " + device.Name);
- if (device.BtItem.IsPaired)
+ if (device.BtDevice.IsPaired)
{
- if (device.BtItem.IsA2dpSupported)
+ if (device.BtDevice.IsA2dpSupported)
{
- if (device.BtItem.IsA2dpConnected)
+ if (device.BtDevice.IsA2dpConnected)
{
- DisconnectA2dp(device.BtItem);
+ DisconnectA2dp(device.BtDevice);
}
else
{
- Log.Info(Program.LogTag, "Connect to the remote audio device");
- ConnectA2dp(device.BtItem);
+ ConnectA2dp(device.BtDevice);
}
}
- else if (device.BtItem.IsHidSupported)
+ else if (device.BtDevice.IsHidSupported)
{
- if (device.BtItem.IsHidConnected)
+ if (device.BtDevice.IsHidConnected)
{
- DisconnectHid(device.BtItem);
+ DisconnectHid(device.BtDevice);
}
else
{
- Log.Info(Program.LogTag, "Connect to the remote hid device");
- ConnectHid(device.BtItem);
+ ConnectHid(device.BtDevice);
}
}
}
else
{
Log.Info(Program.LogTag, "Pair to the remote device");
- device.BtItem.Pair();
+ device.BtDevice.Pair();
}
}
}
private BluetoothDevice mBluetoothDevice;
private string[] mServiceUuids = null;
private BluetoothServiceClassType mServiceMask = 0;
+ private BtDeviceIcon mDeviceIcon;
private bool mIsA2dpSupported = false;
private BluetoothAudio mBluetoothAudio = null;
mIsHidSupported = true;
}
}
+
+ switch (device.Class.MajorDeviceClassType)
+ {
+ case BluetoothMajorDeviceClassType.Computer:
+ mDeviceIcon = BtDeviceIcon.Computer;
+ break;
+ case BluetoothMajorDeviceClassType.Phone:
+ mDeviceIcon = BtDeviceIcon.Phone;
+ break;
+ case BluetoothMajorDeviceClassType.AudioVideo:
+ if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.AudioVideoHeadphones)
+ {
+ mDeviceIcon = BtDeviceIcon.Headphone;
+ }
+ else if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.AudioVideoLoudspeaker)
+ {
+ mDeviceIcon = BtDeviceIcon.Display;
+ }
+ else
+ {
+ mDeviceIcon = BtDeviceIcon.Headset;
+ }
+ break;
+ case BluetoothMajorDeviceClassType.LanNetworkAccessPoint:
+ mDeviceIcon = BtDeviceIcon.Network;
+ break;
+ case BluetoothMajorDeviceClassType.Imaging:
+ if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.ImagingPrinter)
+ {
+ mDeviceIcon = BtDeviceIcon.Printer;
+ }
+ else if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.ImagingCamera)
+ {
+ mDeviceIcon = BtDeviceIcon.Camera;
+ }
+ else
+ {
+ mDeviceIcon = BtDeviceIcon.Display;
+ }
+ break;
+ case BluetoothMajorDeviceClassType.Peripheral:
+ if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.PeripheralKeyBoard)
+ {
+ mDeviceIcon = BtDeviceIcon.Keyboard;
+ }
+ else if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.PeripheralPointingDevice)
+ {
+ mDeviceIcon = BtDeviceIcon.Mouse;
+ }
+ else if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.PeripheralGamePad)
+ {
+ mDeviceIcon = BtDeviceIcon.Gaming;
+ }
+ else
+ {
+ mDeviceIcon = BtDeviceIcon.Mouse;
+ }
+ break;
+ case BluetoothMajorDeviceClassType.Health:
+ mDeviceIcon = BtDeviceIcon.Health;
+ break;
+ case BluetoothMajorDeviceClassType.Wearable:
+ if (device.Class.MinorDeviceClassType == BluetoothMinorDeviceClassType.WearableWristWatch)
+ {
+ mDeviceIcon = BtDeviceIcon.Watch;
+ }
+ else
+ {
+ mDeviceIcon = BtDeviceIcon.Unknown;
+ }
+ break;
+ default:
+ mDeviceIcon = BtDeviceIcon.Unknown;
+ break;
+ }
}
// for dummy instance (No devices found, Paired device)
}
}
+ internal BtDeviceIcon DeviceIcon
+ {
+ get
+ {
+ return mDeviceIcon;
+ }
+ }
+
internal bool IsA2dpSupported
{
get
Disconnecting,
ServiceSearching,
}
+
+ public enum BtDeviceIcon
+ {
+ Phone,
+ Headset,
+ Headphone,
+ Computer,
+ Keyboard,
+ Mouse,
+ Printer,
+ Health,
+ Network,
+ Gaming,
+ Display,
+ Camera,
+ Watch,
+ Unknown,
+ }
}
-using System;
+using SettingBluetooth.res.locale;
+using System;
using System.Collections.Generic;
using System.Text;
+using Tizen.NUI;
+using Tizen.NUI.Components;
+using Tizen.NUI.BaseComponents;
+using Tizen;
+using SettingBluetooth.Controller;
namespace SettingBluetooth
{
- class BtDetailView
+ internal static class BtDetailView
{
+ static View mDetailView;
+ static ContentPage mDetailPage;
+
+ internal static void CreateDetailView(Device device)
+ {
+ Window window = NUIApplication.GetDefaultWindow();
+
+ 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,
+ };
+ mDetailView.Add(deviceName);
+
+ var unpairButton = new DefaultLinearItem()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = Resources.IDS_BT_OPT_UNPAIR,
+ };
+ unpairButton.Clicked += (obj, ev) =>
+ {
+ Log.Info(Program.LogTag, "Unpair to the remote device. Address: " + device.BtDevice.Address + ", Name: " + device.BtDevice.Name);
+ device.BtDevice.Unpair();
+ window.GetDefaultNavigator().Pop();
+ };
+ mDetailView.Add(unpairButton);
+
+ var connOption = new DefaultLinearItem()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = Resources.IDS_BT_BODY_CONNECTION_OPTIONS,
+ };
+ mDetailView.Add(connOption);
+
+ if (device.BtDevice.IsA2dpSupported)
+ {
+ var mediaAudioItem = new DefaultLinearItem()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = Resources.IDS_BT_BODY_MEDIA_AUDIO,
+ };
+ var mediaAudioSwitch = new Switch()
+ {
+ IsSelected = device.BtDevice.IsA2dpConnected ? true : false,
+ };
+ mediaAudioSwitch.SelectedChanged += (obj, ev) =>
+ {
+ if (ev.IsSelected)
+ {
+ DeviceController.ConnectA2dp(device.BtDevice);
+ }
+ else
+ {
+ DeviceController.DisconnectA2dp(device.BtDevice);
+ }
+ };
+ mediaAudioItem.Extra = mediaAudioSwitch;
+ mDetailView.Add(mediaAudioItem);
+ }
+
+ mDetailPage = new ContentPage()
+ {
+ AppBar = appBar,
+ Content = mDetailView,
+ };
+
+ window.GetDefaultNavigator().Push(mDetailPage);
+ }
}
}
{
public class Device : INotifyPropertyChanged
{
- string mIconDir = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "icon.png";
+ private string mResourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+ private string mIconDir;
private string mAddress;
private string mName;
//private bool connected;
//private bool registered;
public event PropertyChangedEventHandler PropertyChanged;
- BtDevice mBtItem;
+ BtDevice mBtDevice;
private string mState;
private void OnPropertyChanged(string propertyName)
{
mAddress = btDevice.Address;
mName = btDevice.Name;
- mBtItem = btDevice;
+ mBtDevice = btDevice;
+ //string icon;
+ //switch (btDevice.DeviceIcon)
+ //{
+ // case BtDeviceIcon.Phone:
+ // icon = "/images/icon_mobilephone.png"; // TODO: need to replace image file
+ // break;
+ // case BtDeviceIcon.Headset:
+ // icon = "/images/icon_headset.png";
+ // break;
+ // case BtDeviceIcon.Headphone:
+ // icon = "/images/icon_headphone.png";
+ // break;
+ // case BtDeviceIcon.Computer:
+ // icon = "/images/icon_computer.png";
+ // break;
+ // case BtDeviceIcon.Keyboard:
+ // icon = "/images/icon_keyboard.png";
+ // break;
+ // case BtDeviceIcon.Mouse:
+ // icon = "/images/icon_mouse.png";
+ // break;
+ // case BtDeviceIcon.Printer:
+ // icon = "/images/icon_printer.png";
+ // break;
+ // case BtDeviceIcon.Health:
+ // icon = "/images/icon_health.png";
+ // break;
+ // case BtDeviceIcon.Network:
+ // icon = "/images/icon_network_infrastructure.png";
+ // break;
+ // case BtDeviceIcon.Gaming:
+ // icon = "/images/icon_gaming.png";
+ // break;
+ // case BtDeviceIcon.Display:
+ // icon = "/images/icon_display.png";
+ // break;
+ // case BtDeviceIcon.Camera:
+ // icon = "/images/icon_camera.png";
+ // break;
+ // case BtDeviceIcon.Watch:
+ // icon = "/images/icon_wrist.png";
+ // break;
+ // case BtDeviceIcon.Unknown:
+ // default:
+ // icon = "/images/icon_unknown.png";
+ // break;
+ //}
+ //mIconDir = mResourcePath + icon;
+ mIconDir = mResourcePath + "/images/icon.png";
}
- internal BtDevice BtItem
+ internal BtDevice BtDevice
{
get
{
- return mBtItem;
+ return mBtDevice;
}
}
{
return mIconDir;
}
+ set
+ {
+ mIconDir = value;
+ OnPropertyChanged("ImageUrl");
+ }
}
-
- //public bool Connected
- //{
- // get
- // {
- // return connected;
- // }
- // set
- // {
- // connected = value;
- // OnPropertyChanged("Connected");
- // }
- //}
- //public bool Registered
- //{
- // get
- // {
- // return registered;
- // }
- // set
- // {
- // registered = value;
- // OnPropertyChanged("Registered");
- // }
- //}
}
public class DeviceCollection : ObservableCollection<Device>
internal void UpdateState(BtDevice btDevice)
{
var device = FindDevice(btDevice);
- string state = null;
switch (btDevice.DeviceState)
{
case BtDeviceState.Idle:
case BtDeviceState.Unpaired:
- state = "";
+ device.State = "";
break;
case BtDeviceState.Pairing:
case BtDeviceState.Connecting:
- state = Resources.IDS_BT_SBODY_CONNECTING_ING;
+ device.State = Resources.IDS_BT_SBODY_CONNECTING_ING;
break;
case BtDeviceState.Unpairing:
case BtDeviceState.Disconnecting:
- state = Resources.IDS_BT_BODY_DISCONNECTING;
+ device.State = Resources.IDS_BT_BODY_DISCONNECTING;
break;
case BtDeviceState.Paired:
- state = Resources.IDS_BT_BODY_PAIRED;
+ device.State = Resources.IDS_BT_BODY_PAIRED;
break;
case BtDeviceState.Connected:
- state = Resources.IDS_BT_SBODY_CONNECTED_M_STATUS;
+ device.State = Resources.IDS_BT_SBODY_CONNECTED_M_STATUS;
break;
case BtDeviceState.ServiceSearching:
- state = Resources.IDS_BT_POP_SEARCHING_SERVICES_ING;
+ device.State = Resources.IDS_BT_POP_SEARCHING_SERVICES_ING;
break;
}
- //Log.Info(Program.LogTag, "Device(" + btDevice.Address + ") updated. state: " + state);
- device.State = state;
+ //Log.Info(Program.LogTag, "Device(" + btDevice.Address + ") updated. state: " + device.State);
}
}
}
}
// TODO: Need to move device view related functions to BtDeviceView.cs.
- private static CollectionView CreateCollectionView(DeviceSource source, bool fixHeight = true)
+ private static CollectionView CreateCollectionView(DeviceSource source, bool isPairedDeviceView = false)
{
var view = new CollectionView()
{
item.Icon.SetBinding(ImageView.ResourceUrlProperty, "ImageUrl");
item.Icon.WidthSpecification = 40;
item.Icon.HeightSpecification = 40;
- var detailButton = new Button // TODO: need to use other type instead of Button
- {
- Text = "i"
- };
- detailButton.WidthSpecification = 40;
- detailButton.Clicked += (obj, ev) =>
- {
- Button button = (Button)obj;
- var device = button.BindingContext as Device;
- Log.Debug(Program.LogTag, "Button clicked. Name: " + device.Name);
- // TODO: add BtDetailView with device
- };
- item.Extra = detailButton;
item.Clicked += DeviceController.DeviceItemClicked;
item.IsSelectable = false;
+ if (isPairedDeviceView == true)
+ {
+ var detailButton = new Button // TODO: need to use other type instead of Button
+ {
+ Text = "i"
+ };
+ detailButton.WidthSpecification = 40;
+ detailButton.Clicked += (obj, ev) =>
+ {
+ Button button = (Button)obj;
+ var device = button.BindingContext as Device;
+ Log.Debug(Program.LogTag, "Button clicked. Name: " + device.Name);
+ BtDetailView.CreateDetailView(device);
+ };
+ item.Extra = detailButton;
+ }
+
return item;
}),
SelectionMode = ItemSelectionMode.Single,
};
- if (fixHeight) // for searched view
+ if (isPairedDeviceView == false)
{
view.HeightSpecification = LayoutParamPolicies.MatchParent;
}
private static void AddPairedDeviceView()
{
mPairedDevice = new DeviceSource();
- mPairedDeviceView = CreateCollectionView(mPairedDevice, false);
+ mPairedDeviceView = CreateCollectionView(mPairedDevice, true);
mPairedDevice.AddDevice(new BtDevice("dummy paired device")); // temporary device
mPairedDevice.UpdateTitle(Resources.IDS_BT_BODY_PAIRED_DEVICES);
mMainView.Add(mPairedDeviceView);
}
}
- private static void RemoveAllView()
+ private static void RemovePairedDeviceView()
{
- RemoveSearchedDeviceView();
-
if (mPairedDeviceView)
{
mMainView.Remove(mPairedDeviceView);
switch (ev.OperationState)
{
case BtOperationState.Deactivated:
- RemoveAllView();
+ RemoveSearchedDeviceView();
+ RemovePairedDeviceView();
break;
case BtOperationState.Deactivating:
break;
}
}
+ /// <summary>
+ /// 과(와) 유사한 지역화된 문자열을 찾습니다.
+ /// </summary>
+ public static string IDS_BT_BODY_CONNECTION_OPTIONS {
+ get {
+ return ResourceManager.GetString("IDS_BT_BODY_CONNECTION_OPTIONS", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// 과(와) 유사한 지역화된 문자열을 찾습니다.
+ /// </summary>
+ public static string IDS_BT_BODY_DETAILS {
+ get {
+ return ResourceManager.GetString("IDS_BT_BODY_DETAILS", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// 과(와) 유사한 지역화된 문자열을 찾습니다.
+ /// </summary>
+ public static string IDS_BT_BODY_DEVICENAME {
+ get {
+ return ResourceManager.GetString("IDS_BT_BODY_DEVICENAME", resourceCulture);
+ }
+ }
+
/// <summary>
/// 과(와) 유사한 지역화된 문자열을 찾습니다.
/// </summary>
}
}
+ /// <summary>
+ /// 과(와) 유사한 지역화된 문자열을 찾습니다.
+ /// </summary>
+ public static string IDS_BT_BODY_MEDIA_AUDIO {
+ get {
+ return ResourceManager.GetString("IDS_BT_BODY_MEDIA_AUDIO", resourceCulture);
+ }
+ }
+
/// <summary>
/// 과(와) 유사한 지역화된 문자열을 찾습니다.
/// </summary>
}
}
+ /// <summary>
+ /// 과(와) 유사한 지역화된 문자열을 찾습니다.
+ /// </summary>
+ public static string IDS_BT_OPT_UNPAIR {
+ get {
+ return ResourceManager.GetString("IDS_BT_OPT_UNPAIR", resourceCulture);
+ }
+ }
+
/// <summary>
/// 과(와) 유사한 지역화된 문자열을 찾습니다.
/// </summary>
<data name="IDS_BT_BODY_BLUETOOTH" xml:space="preserve">
<value>Bluetooth</value>
</data>
+ <data name="IDS_BT_BODY_CONNECTION_OPTIONS" xml:space="preserve">
+ <value>Connection options</value>
+ </data>
+ <data name="IDS_BT_BODY_DETAILS" xml:space="preserve">
+ <value>Details</value>
+ </data>
+ <data name="IDS_BT_BODY_DEVICENAME" xml:space="preserve">
+ <value>Device name</value>
+ </data>
<data name="IDS_BT_BODY_DISCONNECTING" xml:space="preserve">
<value>Disconnecting...</value>
</data>
+ <data name="IDS_BT_BODY_MEDIA_AUDIO" xml:space="preserve">
+ <value>Media audio</value>
+ </data>
<data name="IDS_BT_BODY_PAIRED" xml:space="preserve">
<value>Paired</value>
</data>
<data name="IDS_BT_HEADER_DISCONNECT_DEVICE_ABB" xml:space="preserve">
<value>Disconnect device</value>
</data>
+ <data name="IDS_BT_OPT_UNPAIR" xml:space="preserve">
+ <value>Unpair</value>
+ </data>
<data name="IDS_BT_POP_SEARCHING_SERVICES_ING" xml:space="preserve">
<value>Searching services...</value>
</data>
<data name="IDS_BT_BODY_BLUETOOTH" xml:space="preserve">
<value>블루투스</value>
</data>
+ <data name="IDS_BT_BODY_CONNECTION_OPTIONS" xml:space="preserve">
+ <value>연결 옵션</value>
+ </data>
+ <data name="IDS_BT_BODY_DETAILS" xml:space="preserve">
+ <value>상세정보</value>
+ </data>
+ <data name="IDS_BT_BODY_DEVICENAME" xml:space="preserve">
+ <value>디바이스 이름</value>
+ </data>
<data name="IDS_BT_BODY_DISCONNECTING" xml:space="preserve">
<value>연결을 해제하는 중...</value>
</data>
+ <data name="IDS_BT_BODY_MEDIA_AUDIO" xml:space="preserve">
+ <value>미디어 오디오</value>
+ </data>
<data name="IDS_BT_BODY_PAIRED" xml:space="preserve">
<value>등록됨</value>
</data>
<data name="IDS_BT_HEADER_DISCONNECT_DEVICE_ABB" xml:space="preserve">
<value>디바이스 연결 해제</value>
</data>
+ <data name="IDS_BT_OPT_UNPAIR" xml:space="preserve">
+ <value>등록 해제</value>
+ </data>
<data name="IDS_BT_POP_SEARCHING_SERVICES_ING" xml:space="preserve">
<value>서비스 검색 중...</value>
</data>
<data name="IDS_BT_BODY_BLUETOOTH" xml:space="preserve">
<value />
</data>
+ <data name="IDS_BT_BODY_CONNECTION_OPTIONS" xml:space="preserve">
+ <value />
+ </data>
+ <data name="IDS_BT_BODY_DETAILS" xml:space="preserve">
+ <value />
+ </data>
+ <data name="IDS_BT_BODY_DEVICENAME" xml:space="preserve">
+ <value />
+ </data>
<data name="IDS_BT_BODY_DISCONNECTING" xml:space="preserve">
<value />
</data>
+ <data name="IDS_BT_BODY_MEDIA_AUDIO" xml:space="preserve">
+ <value />
+ </data>
<data name="IDS_BT_BODY_PAIRED" xml:space="preserve">
<value />
</data>
<data name="IDS_BT_HEADER_DISCONNECT_DEVICE_ABB" xml:space="preserve">
<value />
</data>
+ <data name="IDS_BT_OPT_UNPAIR" xml:space="preserve">
+ <value />
+ </data>
<data name="IDS_BT_POP_SEARCHING_SERVICES_ING" xml:space="preserve">
<value />
</data>