1. Integration
UI BizBundle General Profiles
[NOTE]
We have currently deprecated lasspath 'com.tuya.android.module:tymodule-config:latestVersion' please remove it.
1.1. Summary
Bizbundle support minSdkVersion of 19,targetSdkVersion of 29,only Anroidx builds are supported.
1.2. UI Bizbundle Profiles
Configuration files must be re-downloaded for UI BizBundle updates.
1.2.1. assets profile
module_app.json as a serviced profiles,Copy module_app.json to the assets folder under the app directory.[required]
x_platform_config.json for Mall and Device Control Bizbundle serviced profiles,Copy x_platform_config.json to the assets folder under the app directory。[optional]
1.2.2. res profile
res/values/ty_config.xmlbizbundle profiles and default colors[required]
res/valuesbizbundle profiles [required]
res/ multilingual resource files [optional]
theme color profile
res/values/ty_theme_config.xml主题资源配置[required]
res/values/ty_theme_main_colors.xmltheme color res profiles[required]
assets/tyTheme/ui_theme_config.jsontheme color json profiles[required]
Note: You can change the theme color through ty_theme_main_colors.xml and ui_theme_config.json. The two files need to be modified together. ty_theme_config.xml is not allowed to be changed and can be directly put into the project.
'ty_theme_main_colors.xml' res instructions as follow:
Parameter | Description | Default |
---|---|---|
ty_theme_color_m1 | normal theme color | #FFFF5A28 |
ty_theme_color_m1_1 | disable theme color | #33FF5A28 |
ty_theme_color_m1_2 | pressed theme color | #FFFF6B3E |
ty_theme_color_m1_alpha_5 | theme color with alpha for 5 percent | #0DFF5A28 |
ty_theme_color_m1_alpha_10 | theme color with alpha for 10 percent | #1AFF5A28 |
ty_theme_color_m1_alpha_15 | theme color with alpha for 15 percent | #26FF5A28 |
ty_theme_color_m1_alpha_20 | theme color with alpha for 20 percent | #33FF5A28 |
ty_theme_color_m1_alpha_25 | theme color with alpha for 25 percent | #40FF5A28 |
ty_theme_color_m1_alpha_30 | theme color with alpha for 30 percent | #4DFF5A28 |
ty_theme_color_m1_alpha_35 | theme color with alpha for 35 percent | #59FF5A28 |
ty_theme_color_m1_alpha_40 | theme color with alpha for 40 percent | #66FF5A28 |
ty_theme_color_m1_alpha_45 | theme color with alpha for 45 percent | #73FF5A28 |
ty_theme_color_m1_alpha_50 | theme color with alpha for 50 percent | #80FF5A28 |
ty_theme_color_m1_alpha_55 | theme color with alpha for 55 percent | #8CFF5A28 |
ty_theme_color_m1_alpha_60 | theme color with alpha for 60 percent | #99FF5A28 |
ty_theme_color_m1_alpha_65 | theme color with alpha for 65 percent | #A6FF5A28 |
ty_theme_color_m1_alpha_70 | theme color with alpha for 70 percent | #B3FF5A28 |
ty_theme_color_m1_alpha_75 | theme color with alpha for 75 percent | #BFFF5A28 |
ty_theme_color_m1_alpha_80 | theme color with alpha for 80 percent | #CCFF5A28 |
ty_theme_color_m1_alpha_85 | theme color with alpha for 85 percent | #D9FF5A28 |
ty_theme_color_m1_alpha_90 | theme color with alpha for 90 percent | #E6FF5A28 |
ty_theme_color_m1_alpha_95 | theme color with alpha for 95 percent | #F2FF5A28 |
'ui_theme_config.json' res instructions as follow:
{
"color_alpha":{
"N1":0.9,
"N2":0.7,
"N3":0.5,
"N4":0.3,
"N5":0.7,
"N6":0.2,
"N7":0.1,
"N8":0.4
},
"colors":{
"B1":"#F8F8F8",
"B2":"#FFFFFF",
"B3":"#FFFFFF",
"B4":"#FFFFFF",
"B5":"#FFFFFF",
"M1":"#FF5A28", // can modify the property value for theme color
"M2":"#FF4444",
"M3":"#00CC99",
"M4":"#1989FA",
"M5":"#FF5A28"
},
"corner":{
"alert_corner_type":"angle",
"button_corner_type":"angle",
"card_corner_type":"angle"
},
"font":{
"app_bold_font":"",
"app_font":""
}
}
- Config theme color by change colors's M1 property. Other properties should not be modified.
Parameter | Description | Default |
---|---|---|
M1 | theme color | #FF5A28 |
drawable profile
bg_text_bts.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/mg_2" />
<solid android:color="@color/primary_button_select_color" />
</shape>
</item>
<item android:state_selected="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/mg_2" />
<solid android:color="@color/primary_button_select_color" />
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/mg_2" />
<solid android:color="@color/primary_button_select_color" />
</shape>
</item>
<item android:state_enabled="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/mg_2" />
<solid android:color="@color/primary_button_bg_color" />
</shape>
</item>
<item android:state_enabled="false">
<shape>
<corners android:radius="@dimen/mg_2" />
<solid android:color="@color/gray_99" />
</shape>
</item>
</selector>
1.2.3. style profile
res/values/styles.xmlbizbundle theme [required]
<!-- Base application theme. -->
<style name="Base_BizBundle_Theme" parent="AppTheme">
<item name="status_font_color">@color/status_font_color</item>
<item name="status_bg_color">@color/status_bg_color</item>
<item name="navbar_font_color">@color/navbar_font_color</item>
<item name="navbar_bg_color">@color/navbar_bg_color</item>
<item name="app_bg_color">@color/app_bg_color</item>
<item name="fragment_bg_color">@color/app_bg_color</item>
<item name="list_primary_color">@color/list_primary_color</item>
<item name="list_sub_color">@color/list_sub_color</item>
<item name="list_secondary_color">@color/list_secondary_color</item>
<item name="list_line_color">@color/list_line_color</item>
<item name="list_bg_color">@color/list_bg_color</item>
<item name="primary_button_font_color">@color/primary_button_font_color</item>
<item name="primary_button_bg_color">@color/primary_button_bg_color</item>
<item name="secondary_button_font_color">@color/secondary_button_font_color</item>
<item name="secondary_button_bg_color">@color/secondary_button_bg_color</item>
<item name="notice_font_color">@color/notice_font_color</item>
<item name="notice_bg_color">@color/notice_bg_color</item>
<item name="bg_normal_text_bt">@drawable/bg_text_bts</item>
<item name="app_name">@string/app_name</item>
<item name="is_splash_used">false</item>
<item name="ap_default_ssid">@string/ap_mode_ssid</item>
<item name="ap_connect_description">@string/ty_ap_connect_description</item>
<item name="is_scan_support">@bool/is_scan_support</item>
<item name="is_need_blemesh_support">@bool/is_need_blemesh_support</item>
<item name="status_bg_color_75">@color/status_bg_color_75</item>
<item name="status_bg_color_90">@color/status_bg_color_90</item>
</style>
1.2.4. AndroidManifest.xml profile
<!-- required -->
<application
android:supportsRtl="false"
android:theme="@style/Base_BizBundle_Theme"
tools:replace="android:theme"/>
1.2.5. dependent source configuration
root build.gradle
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}
app build.gradle
android {
packagingOptions {
pickFirst 'lib/*/libc++_shared.so'
pickFirst 'lib/*/libgnustl_shared.so'
}
lintOptions {
abortOnError false
}
defaultConfig {
ndk { abiFilters "armeabi-v7a", "arm64-v8a" }
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
1.2.6. Application init
Bizbundle initialization generic part
// Please do not change the initialization order.
Fresco.initialize(this);
// SDK init
TuyaHomeSdk.init(this);
// bizbundle init
TuyaWrapper.init(this, new RouteEventListener() {
@Override
public void onFaild(int errorCode, UrlBuilder urlBuilder) {
Log.e("router not implement", urlBuilder.target + urlBuilder.params.toString());
}
}, new ServiceEventListener() {
@Override
public void onFaild(String serviceName) {
Log.e("service not implement", serviceName);
}
});
TuyaOptimusSdk.init(this);
// register family service
TuyaWrapper.registerService(AbsBizBundleFamilyService.class, new BizBundleFamilyServiceImpl());
1.2.7. login and logout
After the bizbundle is accessed, the following methods should be invoked at account login and logout, respectively
//login
TuyaWrapper.onLogin();
//logout
TuyaWrapper.onLogout(Context context);
1.2.8. implement family service
Set the current family homeId by inheriting the AbsBizBundleFamilyService abstract class.
sample code
public class BizBundleFamilyServiceImpl extends AbsBizBundleFamilyService {
private long mHomeId;
@Override
public long getCurrentHomeId() {
return mHomeId;
}
@Override
public void setCurrentHomeId(long homeId) {
mHomeId = homeId;
}
}
1.2.9. set family HomeId
After fetching the family list, set the family homeId with a service call
sample code
AbsBizBundleFamilyService service = MicroServiceManager.getInstance().findServiceByInterface(AbsBizBundleFamilyService.class.getName());
//Set the homeId to the current home
service.setCurrentHomeId(homeBean.getHomeId());