Last Updated on : 2023-05-22 06:38:28download
Device Details UI BizBundle supports the following features:
Integrate Smart Life App SDK for Android into your project with Android Studio and add the framework of the UI BizBundle to your project. For more information, see Integrate with Framework.
Add the configuration file deviceDetail.json
and [deviceEditConfigList.json
] to the assets
directory of the main project. Example:
[
{
"name": "headerSection",
"items": [
{
"cellType": "header"
},
{
"cellType": "device_info"
},
{
"cellType": "net_setting"
},
{
"cellType": "group_edit_devices"
}
]
},
{
"name": "offLineWarnSection",
"header": {
"cellType": "section_off_line_warn"
},
"items": [
{
"cellType": "off_line_warn"
}
]
},
{
"name": "otherSection",
"header": {
"cellType": "section_other"
},
"items": [
{
"cellType": "bind_multi_control_link"
},
{
"cellType": "group_create"
},
{
"cellType": "help_and_feedback"
},
{
"cellType": "add_icon_to_home_screen"
},
{
"cellType": "show_infrared_gateway_sub_device"
},
{
"cellType": "check_device_network"
},
{
"cellType": "check_firmware_update"
},
{
"cellType": "c_test_insert"
},
{
"cellType": "c_test_async_insert"
}
]
},
{
"name": "footerSection",
"header": {
"cellType": "device_detail_empty"
},
"items": [
{
"cellType": "footer"
}
],
"margin": {
"top": 16
}
}
]
deviceEditConfigList.json
{
"deviceEdit": [
{
"name": "deviceEdit",
"items": [
{
"cellType": "dev_icon"
},
{
"cellType": "set_icon"
},
{
"cellType": "set_name"
},
{
"cellType": "set_position"
}
]
}
]
}
type
parameter of deviceDetail
determines the sequence in which sub-items of device details are displayed. If type
is removed from a sub-item, this sub-item will also be removed.type
parameter of devBaseInfo
determines the sequence in which sub-items of basic device information are displayed. If type
is removed from a sub-item, this sub-item will also be removed.type of deviceDetail |
Device feature |
---|---|
header | View and modify the device icon, device name, and location. |
device_info | Display device information. |
net_setting | Display backup Wi-Fi networks. |
group_edit_devices | Manage group devices. Group Management UI BizBundle must be additionally integrated. |
off_line_warn | Notify users of devices getting offline. |
section_other | This is a section header and serves no purpose. |
bind_multi_control_link | Multi-Control Association UI BizBundle |
group_create | Create device groups. Group Management UI BizBundle must be additionally integrated. |
help_and_feedback | Provide FAQ and feedback. FAQ UI BizBundle must be additionally integrated. |
check_firmware_update | Check for firmware updates. OTA UI BizBundle must be additionally integrated. |
show_infrared_gateway_sub_device | Show remote controls. |
device_detail_empty | This is an empty view and serves no purpose. |
footer | Remove devices. |
type of deviceEdit |
Device feature |
---|---|
dev_icon | The device icon. |
set_icon | The item of the icon. |
set_name | The item of the name. |
set_position | The item of the location. |
build.gradle
dependencies {
implementation 'com.tuya.smart:tuyasmart-bizbundle-panelmore:1.0.0-cube'
}
Parameters
Parameter | Description |
---|---|
extra_panel_dev_id | The device ID. |
extra_panel_name | Device Name |
extra_panel_group_id | The group ID. |
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());
bundle.putLong("extra_panel_group_id",groupId);
urlBuilder.putExtras(bundle);
UrlRouter.execute(urlBuilder);
You can add the custom parameter type
to deviceDetail
in configList.json
.
The value of type
must start with c_
, for example, c_test_insert
.
[
{
"name": "headerSection",
"items": [
{
"cellType": "header"
},
{
"cellType": "device_info"
},
{
"cellType": "net_setting"
},
{
"cellType": "group_edit_devices"
}
]
},
{
"name": "offLineWarnSection",
"header": {
"cellType": "section_off_line_warn"
},
"items": [
{
"cellType": "off_line_warn"
}
]
},
{
"name": "otherSection",
"header": {
"cellType": "section_other"
},
"items": [
{
"cellType": "bind_multi_control_link"
},
{
"cellType": "group_create"
},
{
"cellType": "help_and_feedback"
},
{
"cellType": "add_icon_to_home_screen"
},
{
"cellType": "show_infrared_gateway_sub_device"
},
{
"cellType": "check_device_network"
},
{
"cellType": "check_firmware_update"
},
{
"cellType": "c_test_insert"
},
{
"cellType": "c_test_async_insert"
}
]
},
{
"name": "footerSection",
"header": {
"cellType": "device_detail_empty"
},
"items": [
{
"cellType": "footer"
}
],
"margin": {
"top": 16
}
}
]
Implement com.tuya.smart.archer.api.cell.IArcherCell
or com.tuya.smart.archer.api.AbsBaseArcherCell
.
API description
override fun onCreate(context: Context?) {}
Parameters
Parameter | Description |
---|---|
context | The context for Android. |
To implement AbsBaseArcherCell
, getContainerControl().updateCell(this)
must be triggered for update. Otherwise, show() will not be called.
To implement IArcherCell
, getContainerControl().updateCall(this)
cannot be called, but show()
is called automatically.
override suspend fun show(): Boolean {}
The click event can be implemented in onBindView
.
override fun onCreateView(parent: ViewGroup): View? {}
override fun onBindView(view: View): ITYBaseData?{}
Configure the current class
in tyarchercell_config
.
{
"name": "c_test_insert",
"type": 1,
"clazz": "com.tuya.smart.bizubundle.panelmore.demo.CTestInsertCell"
},
{
"name": "c_test_async_insert",
"type": 1,
"clazz": "com.tuya.smart.bizubundle.panelmore.demo.CTestAsyncInsertCell"
}
Parameter | Description |
---|---|
name | cellType configured in deviceDetail.json |
type | The type of item . Valid values: 1 indicates an item and 2 indicates a header . In the current section , if an item is displayed, a header must be displayed. |
clazz | The class of item . |
val service:IPluginDeviceDetailInfoService? = MicroServiceManager.getInstance()
.findServiceByInterface(IPluginDeviceDetailInfoService::class.java.name)
val deviceId = service?.getCurrentDevId();
val groupId = service?.getCurrentGroupId();
val absDevBaseInfoService: AbsDevBaseInfoService? by lazy {
MicroServiceManager.getInstance()
.findServiceByInterface(AbsDevBaseInfoService::class.java.name)
}
val isAdmin = absDevBaseInfoService.getIsAdmin()
You need to develop a navigation method that allows shortcuts to be added to the home screen. Meanwhile, your app must be granted permissions to create shortcuts. Perform the following steps:
Define activity-alias
and set the entry activity startup mode to singleTask
.
<activity-alias
android:name="com.tuya.smart.hometab.activity.shortcut"
android:exported="true"
android:targetActivity=".MainActivity"> // This is the entry to implement navigation to `activity`.
Implement route parsing with RouterPresenter
of the app module.
if (PINNED_SHORTCUT_ALIAS.equals(intent.getComponent().getClassName())) {
String url = null;
try {
url = intent.getStringExtra("url");
} catch (Throwable t) {
LogUtil.e(TAG, "get url error", t);
}
L.d(TAG, "schemeJump: " + url);
if (TextUtils.isEmpty(url)) {
return null;
}
if (isInnerRouter(url)) {
return new RouterPresenter(url, intent.getExtras());
}
return null;
}
return null;
...
Rewrite the method onNewIntent
and call Router
to parse the route.
Implement route-based navigation in onResume
.
API description
/**
* Indicates whether infrared sub-devices are displayed on the homepage.
*
* @param homeId
* @param devId
* @return
*/
public abstract boolean getInfraredSubDevDisplaySettings(long homeId, String devId);
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
devId | The device ID. |
API description
/**
* Get the logic that indicates whether to display infrared sub-devices.
* @param homeId
* @param devId
* @return
*/
public abstract boolean getInfraredDevDisplaySettings(long homeId, String devId);
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
devId | The infrared device ID. |
API description
/**
* Registers a sub-device status listener.
*
* @param listener
*/
public abstract void registerInfraredSubDevDisplaySettingsListener(OnInfraredSubDevDisplaySettingsListener listener);
/**
* Unregisters a sub-device status listener.
*
* @param listener
*/
public abstract void unregisterInfraredSubDevDisplaySettingsListener(OnInfraredSubDevDisplaySettingsListener listener);
Parameters
Parameter | Description |
---|---|
homeId | The home ID. |
devId | The infrared device ID. |
Example
IPluginInfraredSubDevDisplayService service = MicroServiceManager.getInstance().findServiceByInterface(IPluginInfraredSubDevDisplayService.class.getName());
service.registerInfraredSubDevDisplaySettingsListener(new OnInfraredSubDevDisplaySettingsListener() {
@Override
public void onDisplaySettingsChanged(Long homeId, String gwId, Boolean shown) {
// Updates and returns the device list.
// `gwId`: the infrared device ID.
// `devId`: the infrared sub-device ID.
// service.getInfraredSubDevDisplaySettings(homeId,devId) Returns the setting of whether to display infrared sub-devices on the homepage.
Log.e(TAG, " changed " + "homeId: " + homeId + " devId" + gwId + " show" + shown);
Toast.makeText(DeviceDetailActivity.this, "infrared Changed", Toast.LENGTH_LONG).show();
}
@Override
public void onDisplaySettingsRemoved(Long homeId, String gwId) {
Log.e(TAG, " removed " + "homeId: " + homeId + " devId" + gwId);
Toast.makeText(DeviceDetailActivity.this, "infrared removed", Toast.LENGTH_LONG).show();
}
});
Deprecated API | Alternative method |
---|---|
PanelMoreItemClickService.devClickItem | Implement IArcherCell or AbsArcherCell . |
PanelMoreItemClickService.devClickItem | Implement IArcherCell or AbsArcherCell . |
PanelMoreMenuService.insertDevMenuItemAsync | Use the preceding alternative method. |
PanelMoreMenuService.insertDevMenuItem/insertDevMenuItemAsync/insertDevMenuItem/ | Use the preceding alternative method. |
PanelMoreInfraredSubDevDisplayService | IPluginInfraredSubDevDisplayService |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback