1. Device details bizBundle
1.1. Features
- Device information editing (device avatar, room, name)
- Device information query (ID, signal, etc.)
- Alternate network Settings
- Offline reminder function
- Remove device
- Frequently asked questions and feedback (need access to help Center business package)
- Check firmware upgrade (OTA business package is required)
1.2. Biz Bundle integration
1.2.1. Create project
- Create your project in Android Studio, connect to the public SDK and configure Biz Bundle Framework.
- Assets of the main project under the directory,add configList.jsonconfiguration file.If the file already exists,add deviceDetail in configlist.json.The specific configuration is entered below:
{
"deviceDetail": [
{
"type": "header"
},
{
"type": "device_info"
},
{
"type": "device_net_info"
},
{
"type": "off_line_warn"
},
{
"type": "section_other"
},
{
"type":"help_and_feedback"
},
{
"type":"check_device_network"
},
{
"type":"check_firmware_update"
},
{
"type": "empty",
"height": 10
},
{
"type": "footer"
}
]
}
Note that the order of 'deviceDetail type' affects the order in which the deviceDetail page subfunctions are displayed.If the Type is removed, the device detail page subfunction is removed accordingly.
deviceDetail type | function |
---|---|
header | view or modify device icons, names, and locations |
device_info | device information |
device_net_info | device backup network |
off_line_warn | device offline reminder |
section_other | section header,no actual function |
help_and_feedback | frequently asked questions and feedback,you need to integrate the FAQ and feedback business package |
check_firmware_update | check firmware upgrade,you need to integrate firmware upgrade business package |
empty | empty view,no actual function |
footer | remove the device |
1.2.2. Module's build.gradle configuration
dependencies {
implementation 'com.tuya.smart:tuyasmart-bizbundle-panelmore:3.22.0-6'
}
1.3. Function use
Declaration
Parameters | Description |
---|---|
extra_panel_dev_id | Device ID |
extra_panel_name | Device name |
Example
UrlBuilder urlBuilder = new UrlBuilder(PanelMoreActivity.this, "panelMore");
String devId = edt.getText().toString().trim();
DeviceBean deviceBean = TuyaHomeSdk.getDataInstance().getDeviceBean(devId);
Bundle bundle = new Bundle();
bundle.putString("extra_panel_dev_id",devId);
bundle.putString("extra_panel_name",deviceBean.getName());
urlBuilder.putExtras(bundle);
UrlRouter.execute(urlBuilder);
1.4. Custom subfunctions
- The deviceDetail of the configlist. json file inserts the custom type. Note that the type value must start with "C_".
{"deviceDetail": [
{
"type": "header"
},
{
"type": "device_info"
},
{
"type": "device_net_info"
},
{
"type": "off_line_warn"
},
{
"type": "section_other"
},
{
"type":"help_and_feedback"
},
{
"type":"check_device_network"
},
{
"type":"check_firmware_update"
},
{
"type":"c_test_insert"
},
{
"type":"c_test_async_insert"
},
{
"type": "empty",
"height": 10
},
{
"type": "footer"
}
],}
- Implement AbsPanelMoreExpandService.
Implement a click event for a custom type.
Declaration
public abstract void devClickItem(Context context, int action, DeviceBean deviceBean, boolean isAdmin);
Parameters
Parameters | Description |
---|---|
context | android context |
action | Click on the event identifier |
deviceBean | Device information |
isAdmin | Administrator or not |
Example
@Override
public void devClickItem(Context context, int action, TextBean data, DeviceBean deviceBean, boolean isAdmin) {
if(action == R.id.action_test_insert){
// Complementary subfunction
}
}
Synchronously insert subfunction items
Declaration
public abstract IMenuBean insertDevMenuItem(Context context, String type, boolean isAdmin, DeviceBean deviceBean, float order);
Parameters
Parameters | Description |
---|---|
context | android context |
type | Type defined in configList |
isAdmin | Administrator or not |
deviceBean | Device information |
order | Type is in the configList position and is used to generate the ImenuBean |
Example
@Override
public IMenuBean insertDevMenuItem(Context context, String type, boolean isAdmin, DeviceBean deviceBean, float order) {
if(isAdmin && TextUtils.equals(type,"c_test_insert")){
return new IMenuBean("title","subtitle","1",
java.lang.String.valueOf(R.id.action_test_insert),
order,
"test_insert");
}
return null;
}
Asynchronous insertion of subfunction item
Declaration
public abstract void insertDevMenuItemAsync(Context context, String type, boolean isAdmin, DeviceBean deviceBean, float order, IMenuItemCallback callback);
Parameters
Parameters | Description |
---|---|
context | android context |
type | Type defined in configList |
isAdmin | Administrator or not |
deviceBean | Device information |
order | Type is in the configList position and is used to generate the ImenuBean |
IMenuItemCallback | Used to insert a subfunction item |
Example
@Override
@Override
public void insertDevMenuItemAsync(Context context, String type, boolean isAdmin, DeviceBean deviceBean, float order, IMenuItemCallback callback) {
if(isAdmin && TextUtils.equals(type,"c_test_async_insert")){
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
callback.setMenuItem( new IMenuBean("async_title","async_subtitle","0",
java.lang.String.valueOf(R.id.action_test_async_insert),
order));
}
},1000*5);
}
}
IMenuBean,a wrapper class for the Item subfunction
Parameters
Parameters | Description |
---|---|
title | Title |
subTitle | Subtitle |
click | Currently only the string "1" is supported |
target | Click on the event identifier |
order | Type is in the configList position and is used to generate the ImenuBean |
Example
new IMenuBean("title","subtitle","1",java.lang.String.valueOf(R.id.action_test_insert),order);
IMenuItemCallback,asynchronous insert subfunctionality
Declaration
void setMenuItem(IMenuBean item);
Parameters
Parameters | Description |
---|---|
IMenuBean | A wrapper class for the Item subfunction |
Example
callback.setMenuItem(new IMenuBean("async_title","async_subtitle","0",
java.lang.String.valueOf(R.id.action_test_async_insert),
order));
- Register AbsPanelMoreExpandService implementation class,it is suggested that this method is invoked in the application#onCreate
TuyaWrapper.registerService(AbsPanelMoreExpandService.class, new PanelMoreExpandServiceImpl());