Skip to content

Commit

Permalink
Merge pull request #1676 from MiEcosystem/SDK_10042
Browse files Browse the repository at this point in the history
Sdk 10042
  • Loading branch information
santcool authored Aug 20, 2020
2 parents 3eb0efe + 0a5cc1b commit 26005fc
Show file tree
Hide file tree
Showing 132 changed files with 4,128 additions and 14,261 deletions.
2 changes: 1 addition & 1 deletion bin/config/transformer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/createProject.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion bin/fixbug/Text
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class TouchableText extends React.Component<Props, State> {

render(): React.Node {
let props = this.props;
let ancestorProps = this.props;
if (Platform === 'ios') {
if (props.style) {
if (props.style.color !== undefined && props.style.color !== null && props.style.color !== 'undefined') {
Expand All @@ -156,11 +157,14 @@ class TouchableText extends React.Component<Props, State> {
}
};
}
ancestorProps = props;
} else {
let tcolor = { 'value': '' };
let anceFlag = false;
modifyTextColorIfNeeded(props.style, tcolor);
if (tcolor.value.length === 0) {
tcolor.value = 'blacktext';
anceFlag = true;
}
let styleArray = flatDeep([
props.style,
Expand All @@ -170,6 +174,9 @@ class TouchableText extends React.Component<Props, State> {
...props,
style: styleArray
};
if(!anceFlag){
ancestorProps = props;
}
}
} else {
props = {
Expand All @@ -189,6 +196,10 @@ class TouchableText extends React.Component<Props, State> {
...props,
style: [props.style, { fontFamily: "" }]
};
ancestorProps = {
...ancestorProps,
style: [ancestorProps.style, { fontFamily: "" }]
};
}
} else if (Object.prototype.toString.call(props.style) === '[object Object]') {
if (!props.style.fontFamily) {
Expand All @@ -199,6 +210,13 @@ class TouchableText extends React.Component<Props, State> {
fontFamily: ""
}
};
ancestorProps = {
...ancestorProps,
style: {
...ancestorProps.style,
fontFamily: ""
}
};
}
}
}
Expand All @@ -209,26 +227,40 @@ class TouchableText extends React.Component<Props, State> {
...this.state.responseHandlers,
isHighlighted: this.state.isHighlighted
};
ancestorProps = {
...ancestorProps,
...this.state.responseHandlers,
isHighlighted: this.state.isHighlighted
};
}
if (props.selectionColor != null) {
props = {
...props,
selectionColor: processColor(props.selectionColor)
};
ancestorProps = {
...ancestorProps,
selectionColor: processColor(ancestorProps.selectionColor)
};
}
if (__DEV__) {
if (Touchable.TOUCH_TARGET_DEBUG && props.onPress != null) {
props = {
...props,
style: [props.style, { color: 'magenta' }]
};
ancestorProps = {
...ancestorProps,
style: [ancestorProps.style, { color: 'magenta' }]
};
}
}

return (
<TextAncestor.Consumer>
{(hasTextAncestor) =>
hasTextAncestor ? (
<RCTVirtualText {...props} ref={props.forwardedRef} />
<RCTVirtualText {...ancestorProps} ref={ancestorProps.forwardedRef} />
) : (
<TextAncestor.Provider value={true}>
<RCTText {...props} ref={props.forwardedRef} />
Expand Down
31 changes: 22 additions & 9 deletions doc-md/03-设备管理/02-基础插件设备模块.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ reject:{code: xxx, message: xxx}
查询设备的房间信息
**Kind**: instance method of [<code>BasicDevice</code>](#module_miot/device--module.exports.BasicDevice)
**Returns**: <code>[ &#x27;Promise&#x27; ].&lt;Object&gt;</code> - {code: 0, data: {roomId, homeId, roomName} }
**Returns**: <code>[ &#x27;Promise&#x27; ].&lt;Object&gt;</code> - {code: 0, data: {roomId, homeId, roomName, homeName} }
**Since**: 10039
| Param | Type | Default | Description |
Expand Down Expand Up @@ -813,7 +813,7 @@ DeviceEvent 当前设备事件:可以理解为iOS中的通知,或者Android
<a name="module_miot/device--module.exports..DeviceEvent.BLESpecNotifyActionEvent"></a>
##### DeviceEvent.BLESpecNotifyActionEvent
ble直连spec消息通知
订阅ble spec 消息推送;除了订阅之外,插件需要与设备建立蓝牙连接,并主动扫描设备的特征值,设备才会给插件推送消息。
**Kind**: static property of [<code>DeviceEvent</code>](#module_miot/device--module.exports..DeviceEvent)
Expand All @@ -825,18 +825,29 @@ ble直连spec消息通知
**Example**
```js
let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) => {

if(data.has('prop.2.1')){
console.log(`receive prop(event) changed notification,prop.2.1:`, data.get('prop.2.1'));
//详细使用示例可以参考com.xiaomi.bledemo/Main/BleSpec.js
let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) => {
console.log('receive prop(event) changed notification:' + JSON.stringify(data))
data.forEach((key, value) => {
console.log(`receive prop(event) changed notification,prop:${ key }`, JSON.stringify(value));
});
if(data.has('event.2.1')){
console.log(`receive prop(event) changed notification,event.2.1:`, data.get('event.2.1'));
}
});

this._s1 = BluetoothEvent.bluetoothSeviceDiscovered.addListener((blut, services) => {
if (services.length <= 0) {
return;
}
console.log('bluetoothSeviceDiscovered', blut.mac, services.map(s => s.UUID), bt.isConnected);

const s = services.map(s => ({ uuid: s.UUID, char: [] }));
services.forEach(s => {
s.startDiscoverCharacteristics();
});
}

bt = Device.getBluetoothLE();
if(bt.isConnected){
bt.startDiscoverServices();
bt.subscribeMessages('prop.2.1','event.2.1').then(res => {
console.log('subscribe exception success,res:',JSON.stringify(res));
}).catch(err => console.log('subscribe exception fail'))
Expand All @@ -845,6 +856,7 @@ let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) =
console.log('bluetoothConnectionStatusChanged', blut, isConnect);
if (bt.mac === blut.mac) {
if(isConnect){
bt.startDiscoverServices();
bt.subscribeMessages('prop.2.1','event.2.1').then(res => {
console.log('subscribe exception success,res:',JSON.stringify(res));
}).catch(err => console.log('subscribe exception fail'))
Expand All @@ -855,6 +867,7 @@ let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) =
}
}else{
bt.connect(scType,{ did: Device.deviceID }).then(res=>{
bt.startDiscoverServices();
bt.subscribeMessages('prop.2.1','event.2.1').then(res => {
console.log('subscribe exception success,res:',JSON.stringify(res));
}).catch(err => console.log('subscribe exception fail'))
Expand Down
20 changes: 18 additions & 2 deletions doc-md/04-蓝牙设备/02-蓝牙模块.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Device.getBluetoothLE().getVersion(true, true).then(version => {
<a name="module_miot/device/bluetooh.IBluetooth+subscribeMessages"></a>

#### iBluetooth.subscribeMessages(...propertyOrEventNames)
订阅ble spec 消息推送;如果手机没有连接ble设备(可以调用Device.getBluetoothLE().connect(...)建立连接),收不到推送
订阅ble spec 消息推送;除了订阅之外,插件需要与设备建立蓝牙连接,并主动扫描设备的特征值,设备才会给插件推送消息。

**Kind**: instance method of [<code>IBluetooth</code>](#module_miot/device/bluetooh.IBluetooth)
**Since**: 10040
Expand All @@ -324,15 +324,29 @@ Device.getBluetoothLE().getVersion(true, true).then(version => {

**Example**
```js
let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) => {
//详细使用示例可以参考com.xiaomi.bledemo/Main/BleSpec.js
let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) => {
console.log('receive prop(event) changed notification:' + JSON.stringify(data))
data.forEach((key, value) => {
console.log(`receive prop(event) changed notification,prop:${ key }`, JSON.stringify(value));
});
});

this._s1 = BluetoothEvent.bluetoothSeviceDiscovered.addListener((blut, services) => {
if (services.length <= 0) {
return;
}
console.log('bluetoothSeviceDiscovered', blut.mac, services.map(s => s.UUID), bt.isConnected);

const s = services.map(s => ({ uuid: s.UUID, char: [] }));
services.forEach(s => {
s.startDiscoverCharacteristics();
});
}

bt = Device.getBluetoothLE();
if(bt.isConnected){
bt.startDiscoverServices();
bt.subscribeMessages('prop.2.1','event.2.1').then(res => {
console.log('subscribe exception success,res:',JSON.stringify(res));
}).catch(err => console.log('subscribe exception fail'))
Expand All @@ -341,6 +355,7 @@ let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) =
console.log('bluetoothConnectionStatusChanged', blut, isConnect);
if (bt.mac === blut.mac) {
if(isConnect){
bt.startDiscoverServices();
bt.subscribeMessages('prop.2.1','event.2.1').then(res => {
console.log('subscribe exception success,res:',JSON.stringify(res));
}).catch(err => console.log('subscribe exception fail'))
Expand All @@ -351,6 +366,7 @@ let listener0= DeviceEvent.BLESpecNotifyActionEvent.addListener((device, data) =
}
}else{
bt.connect(scType,{ did: Device.deviceID }).then(res=>{
bt.startDiscoverServices();
bt.subscribeMessages('prop.2.1','event.2.1').then(res => {
console.log('subscribe exception success,res:',JSON.stringify(res));
}).catch(err => console.log('subscribe exception fail'))
Expand Down
6 changes: 3 additions & 3 deletions doc-md/04-蓝牙设备/06-ble直连spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<a name="module_miot/device/bluetooth/blespec..BleSpec+setPropertiesValue"></a>

#### bleSpec.setPropertiesValue(mac, json)
ble直连spec:设置property,调用前确保已连接蓝牙连接
ble直连spec:设置property,调用前确保已建立蓝牙连接

**Kind**: instance method of [<code>BleSpec</code>](#module_miot/device/bluetooth/blespec..BleSpec)
**Since**: 10040
Expand All @@ -50,7 +50,7 @@ Bluetooth.spec.setPropertiesValue(mac,data)
<a name="module_miot/device/bluetooth/blespec..BleSpec+getPropertiesValue"></a>
#### bleSpec.getPropertiesValue(mac, json)
ble直连spec:读property,调用前确保已连接蓝牙连接
ble直连spec:读property,调用前确保已建立蓝牙连接
**Kind**: instance method of [<code>BleSpec</code>](#module_miot/device/bluetooth/blespec..BleSpec)
**Since**: 10040
Expand All @@ -74,7 +74,7 @@ Bluetooth.spec.getPropertiesValue(mac,data)
<a name="module_miot/device/bluetooth/blespec..BleSpec+doAction"></a>
#### bleSpec.doAction(mac, json)
ble直连spec:doAction,调用前确保已连接蓝牙连接
ble直连spec:doAction,调用前确保已建立蓝牙连接
**Kind**: instance method of [<code>BleSpec</code>](#module_miot/device/bluetooth/blespec..BleSpec)
**Since**: 10040
Expand Down
9 changes: 9 additions & 0 deletions doc-md/05-功能接口/01-原生模块.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {Host} from 'miot'

* [miot/Host](#module_miot/Host)
* _static_
* [.displayCutoutTop](#module_miot/Host.displayCutoutTop) : <code>int</code>
* [.type](#module_miot/Host.type) : <code>string</code>
* [.systemInfo](#module_miot/Host.systemInfo) : <code>object</code>
* [.isAndroid](#module_miot/Host.isAndroid) : <code>boolean</code>
Expand Down Expand Up @@ -83,6 +84,14 @@ import {Host} from 'miot'
* ["cellPhoneNetworkStateChanged"](#module_miot/Host..HostEvent.event_cellPhoneNetworkStateChanged)
* [~IExecutor](#module_miot/Host..IExecutor)

<a name="module_miot/Host.displayCutoutTop"></a>

### miot/Host.displayCutoutTop : <code>int</code>
获取Android 官方提供的打孔屏api提供的打孔屏高度。 ios手机一律返回0.

**Kind**: static property of [<code>miot/Host</code>](#module_miot/Host)
**Read only**: true
**Since**: 10042
<a name="module_miot/Host.type"></a>

### miot/Host.type : <code>string</code>
Expand Down
Loading

0 comments on commit 26005fc

Please sign in to comment.