Last Updated on : 2024-04-28 06:10:09download
Lighting scenarios enable users to customize lighting colors for their homes with a color palette and a scene library.
The Lighting Scenario UI BizBundle supports the following features:
The UI BizBundle relies on Smart Life App SDK. Before the following procedure, you must first finish the steps in Preparation and Fast Integration with Smart Life App SDK for Android.
Create a project.
Smart Life App SDK for Android is integrated into your project with Android Studio. The UI BizBundle is added to your project. For more information, see Integration with UI BizBundle SDK for Android.
Configure the build.gradle
file.
dependencies {
api enforcedPlatform("com.thingclips.smart:thingsmart-BizBundlesBom:${biz_bom_version}")
implementation 'com.thingclips.smart:thingsmart-bizbundle-light_scene'
api "com.thingclips.smart:thingsmart:${sdk_version}}"
}
Obfuscate the code.
#fresco
-keep class com.facebook.drawee.backends.pipeline.Fresco
-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.common.internal.DoNotStrip *;
}
#thingclips
-keep class com.thingclips.**{*;}
-dontwarn com.thingclips.**
(Optional) Configure multilingual options.
Currently, the UI BizBundle supports Chinese and English only. However, in the following fields, you can customize value
.
Settings in English: Copy and paste the following code block to the file res/values/strings.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="thing_light_scene_add">New Lighting Scenario</string>
<string name="thing_light_scene_add_area_tip">Choose space to create a lighting Scenario</string>
<string name="thing_light_lamp_add_area_empty">No Lamps</string>
<string name="thing_light_scene_add_device_tip">Setting lamps to create a lighting Scenario</string>
<string name="thing_light_scene_set_name_icon">Choose an icon and name you like</string>
<string name="thing_light_scene_default_name">New lighting scenario</string>
<string name="thing_light_scene_edit">Edit lighting scenario</string>
<string name="thing_light_scene_manage_nav_title">Scene Management</string>
<string name="thing_light_scene_manage_delete_tips">Are you sure you want to delete?</string>
<string name="thing_light_scene_manage_delete_scene_tips_detail">Relevant schedules in this scenario will also be deleted</string>
<string name="thing_scene_add_lamp_offline_tip">Lamp is offline</string>
<string name="thing_scene_add_lamp_lack_gateway">Lighting not connected to gateway</string>
<string name="thing_scene_add_lamp_group_empty_tip">No device in this group</string>
<string name="thing_light_scene_edit_quit_tip">Are you sure to exit?</string>
<string name="thing_light_scene_edit_quit_tip_detail">The content will not be saved after exiting</string>
<string name="thing_light_scene_icon_select">Select Icon</string>
<string name="thing_light_scene_add_success">Saved</string>
<string name="thing_light_scene_main_light">Functional lighting</string>
<string name="thing_light_scene_secondary_light">Ambience lighting</string>
<string name="thing_light_scene_secondary_light_source">Ambience lighting</string>
</resources>
Settings in Chinese: Copy and paste the following code block to the file res/values-zh/strings.xml
.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="thing_light_scene_add">添加新灯光场景</string>
<string name="thing_light_scene_add_area_tip">选择一个空间区域创建灯光环境</string>
<string name="thing_light_lamp_add_area_empty">暂无灯具</string>
<string name="thing_light_scene_add_device_tip">按照主次调节灯光设置整体效果</string>
<string name="thing_light_scene_set_name_icon">选择一个自己喜欢的图标和名称</string>
<string name="thing_light_scene_default_name">新灯光场景</string>
<string name="thing_light_scene_edit">编辑灯光场景</string>
<string name="thing_light_scene_manage_nav_title">场景管理</string>
<string name="thing_light_scene_manage_delete_tips">确定要删除?</string>
<string name="thing_light_scene_manage_delete_scene_tips_detail">该场景下的相关日程也将会被删除</string>
<string name="thing_scene_add_lamp_offline_tip">灯具已离线</string>
<string name="thing_scene_add_lamp_group_empty_tip">该组灯中无设备</string>
<string name="thing_scene_add_lamp_lack_gateway">灯具未连接网关</string>
<string name="thing_light_scene_edit_quit_tip">确认退出?</string>
<string name="thing_light_scene_edit_quit_tip_detail">退出后所填内容将不会保存</string>
<string name="thing_light_scene_icon_select">选择图标</string>
<string name="thing_light_scene_add_success">添加成功</string>
<string name="thing_light_scene_main_light">功能灯光</string>
<string name="thing_light_scene_secondary_light">氛围灯光</string>
<string name="thing_light_scene_secondary_light_source">氛围灯光</string>
</resources>
Data model of ThingLightSceneBean
Property | Type | Description |
---|---|---|
sceneId | String | The unique identifier for the scenario. |
code | String | The input parameter code to run the scenario. |
parentRegionId | String | The room ID of the scenario. |
icon | String | The scenario icon. |
clickIcon | String | The single-tap icon to implement interactions in the scenario. |
name | String | The name of the scenario. |
The UI BizBundle relies on the implementation of AbsLightScenePlugService
to provide services.
Example
// Returns the services provided by the Lighting Scenario UI BizBundle.
AbsLightScenePlugService sceneLightingService = MicroContext.findServiceByInterface(AbsLightScenePlugService.class.getName());
API description
Create a lighting scenario
void launchLightSceneCreate(Context context, int requestCode);
Parameter description
Parameter | Type | Description |
---|---|---|
context | Context | The Context object. |
requestCode | int | The value of requestCode must be larger than 0. After a scenario is created, you can get the code from onActivityResult() . |
Example
AbsLightScenePlugService sceneLightingService = MicroContext.findServiceByInterface(AbsLightScenePlugService.class.getName());
if(null != sceneLightingService) {
sceneLightingService.launchLightSceneCreate(context, 100);
}
API description
Opens the page to modify a lighting scenario.
launchLightSceneEdit(Context context, LightSceneDetailBean bean, int requestCode);
Parameter description
Parameter | Type | Description |
---|---|---|
context | Context | The Context object. |
bean | LightSceneDetailBean | The Bean data of the lighting scenario. |
requestCode | int | The value of requestCode must be larger than 0. After a scenario is modified, you can get the code from onActivityResult() . |
Example
AbsLightScenePlugService sceneLightingService = MicroContext.findServiceByInterface(AbsLightScenePlugService.class.getName());
if(null != sceneLightingService) {
sceneLightingService.launchLightSceneEdit(context, new LightSceneDetailBean(thingLightSceneBean), 101);
}
Class name | Description |
---|---|
ThingLightSceneSdk | The lighting scenario SDK. |
API description
Returns a list of lighting scenarios.
void getAllLightSceneList(long gid, IThingLightResultCallback<ArrayList<ThingLightSceneBean>> callback);
Parameter description
Parameter | Description |
---|---|
gid | The current home ID. |
callback | The callback. |
Example
ThingLightSceneSdk.getThingLightSceneManagerInstance().getAllLightSceneList(gid, new IThingLightResultCallback<ArrayList<ThingLightSceneBean>>() {
@Override
public void onSuccess(ArrayList<ThingLightSceneBean> thingLightSceneBeans) {
}
@Override
public void onFailure(String code, String detail) {
}
});
API description
Runs a lighting scenario
void executeLightScene(long gid, IThingLightResultCallback<Boolean> callback);
Parameter description
Parameter | Description |
---|---|
code | The input parameter code to run the scenario. |
gid | The current home ID. |
callback | The callback. |
Example
ThingLightSceneSdk.newLightSceneInstance(thingLightSceneBean.getCode()).executeLightScene(gid, new IThingLightResultCallback<Boolean> (){
@Override
public void onSuccess(Boolean aBoolean) {
}
@Override
public void onFailure(String code, String detail) {
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback