Last Updated on : 2024-10-29 06:26:44download
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 files deviceDetail.json
, deviceEditConfigList.json
, and thingarchercell_config.json
to the assets
directory of the main project.
To get the details of the configuration files, download tuya-ui-bizbundle-android-demo on GitHub, go to devicedetail
> assets
, and then check the JSON file. The following sections provide a simple description of these configuration files:
deviceDetail.json
The sequence of the type
parameter values in 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.
The following code block is used only as an example. You can get tuya-ui-bizbundle-android-demo on GitHub.
[
{
"name": "headerSection",
"items": [
{
"cellType": "header"
},
{
"cellType": "device_info"
}
]
},
{
"name": "otherSection",
"header": {
"cellType": "section_other"
},
"items": [
{
"cellType": "device_from"
},
{
"cellType": "bind_multi_control_link"
},
{
"cellType": "sub_device_migrate"
}
]
},
{
"name": "footerSection",
"header": {
"cellType": "device_detail_empty"
},
"items": [
{
"cellType": "footer"
}
],
"margin": {
"top": 16
}
}
]
Parameter | Description |
---|---|
name | The name of the group. |
items | The list of sub-items in the group. The cellType parameter represents the name of a sub-item. |
header | The header content of the group. |
footer | The footer content of the group. |
margin | The pitch between groups. |
deviceEditConfigList.json
The sequence of the type
parameter values in deviceEditConfigList
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.
{
"deviceEdit": [
{
"name": "deviceEdit",
"items": [
{
"cellType": "dev_icon"
},
{
"cellType": "set_icon"
},
{
"cellType": "set_name"
},
{
"cellType": "set_position"
}
]
}
]
}
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. |
thingarchercell_config.json
To add cell
or groupCell
, add the information in the required format in thingarchercell_config
.
The following code block is used only as an example. You can get tuya-ui-bizbundle-android-demo on GitHub.
{
"archerGroup": [
{
"name": "headerSection",
"clazz": "com.thingclips.smart.device_detail.group.HeaderGroup"
}
],
"archerCell": [
{
"name": "check_device_network",
"type": 1,
"clazz": "com.thingclips.smart.device_detail.cell.CheckDeviceNetworkArcherCell"
},
{
"name": "product_instruction",
"type": 1,
"clazz": "com.thingclips.smart.device_detail.cell.ProductInstructionArcherCell"
},
{
"name": "section_off_line_warn",
"type": 2,
"clazz": "com.thingclips.smart.device_detail.cell.OffLineWarnHeaderCell"
},
{
"name": "location_manage",
"type": 1,
"clazz": "com.thingclips.smart.device_detail.cell.LocationManageArcherCell"
},
{
"name": "group_edit_devices",
"type": 1,
"clazz": "com.thingclips.smart.device_detail.cell.GroupEditDeviceArcherCell"
}
]
}
Parameter | Description |
---|---|
name | cellType configured in deviceDetail.json |
type | The type of item . Valid values:
section , if an item is displayed, a header must be displayed. |
clazz | The class of item . |
build.gradle
dependencies {
api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:${biz_bom_version}")
implementation 'com.thingclips.smart:thingsmart-bizbundle-panelmore'
api "com.thingclips.smart:thingsmart:${sdk_version}}"
}
Application
// It is necessary to add @HiltAndroidApp to the project Application, as shown in the following code:
@HiltAndroidApp
public class ThingSmartApp extends Application {
@Override
public void onCreate() {
super.onCreate();
}
}
You need to modify appId
in res
> values
> compat-colors.xml
and replace 1234
in the following code block with the real appId
. You can submit a ticket to request appId
. If you do not configure third-party voice control, page loading might have problems.
<integer name="appId">1234</integer>
Parameters
Parameter | Description |
---|---|
extra_panel_dev_id | The device ID. |
extra_panel_name | The 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 = ThingHomeSdk.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"
}
]
}
]
Implement com.thingclips.smart.archer.api.cell.IArcherCell
or com.thingclips.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 an 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 deviceDetailArcherCellConfig.json
.
{
"name": "c_test_insert",
"type": 1,
"clazz": "com.thingclips.smart.bizubundle.panelmore.demo.CTestInsertCell"
},
{
"name": "c_test_async_insert",
"type": 1,
"clazz": "com.thingclips.smart.bizubundle.panelmore.demo.CTestAsyncInsertCell"
}
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.thingclips.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 listener for changes in the virtual infrared sub-device status.
*
* @param listener
*/
public abstract void registerInfraredSubDevDisplaySettingsListener(OnInfraredSubDevDisplaySettingsListener listener);
/**
* Unregisters a listener for changes in the virtual infrared sub-device status.
*
* @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 the list of devices.
// `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 to implement the new cell . |
PanelMoreMenuService.insertDevMenuItem/insertDevMenuItemAsync/insertDevMenuItem/ | Use the preceding alternative method to implement the new cell . |
PanelMoreInfraredSubDevDisplayService | IPluginInfraredSubDevDisplayService |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback