Browse Source

集成腾讯短视频SDK 添加ugckit & 封装android端视频拼接& 视频上传 &SDK licence初始化

tencentVideo
zmt 3 years ago
parent
commit
2a6b4af63c
  1. 2
      .idea/compiler.xml
  2. 2
      .idea/gradle.xml
  3. 21
      app/build.gradle
  4. 12
      app/src/main/AndroidManifest.xml
  5. 2
      app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
  6. 2
      app/src/main/assets/apps/__UNI__2B9497D/www/app-view.js
  7. 2
      app/src/main/assets/data/dcloud_control.xml
  8. 31
      beautysettingkit/build.gradle
  9. 21
      beautysettingkit/proguard-rules.pro
  10. 4
      beautysettingkit/src/main/AndroidManifest.xml
  11. 624
      beautysettingkit/src/main/assets/default_beauty_data.json
  12. BIN
      beautysettingkit/src/main/assets/green_1.mp4
  13. 47
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/Beauty.java
  14. 823
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/BeautyImpl.java
  15. 75
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/BeautyParams.java
  16. 140
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/adapter/ItemAdapter.java
  17. 93
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/adapter/TabAdapter.java
  18. 77
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/constant/BeautyConstants.java
  19. 9
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/DownloadListener.java
  20. 142
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/HttpFileHelper.java
  21. 13
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/HttpFileListener.java
  22. 10
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/HttpStatusException.java
  23. 135
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/MaterialDownloader.java
  24. 67
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/model/BeautyInfo.java
  25. 77
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/model/ItemInfo.java
  26. 123
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/model/TabInfo.java
  27. 294
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/utils/BeautyUtils.java
  28. 70
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/utils/ResourceUtils.java
  29. 61
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/utils/SPUtils.java
  30. 314
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/view/BeautyPanel.java
  31. 70
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/view/ProgressDialog.java
  32. 68
      beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/view/TCHorizontalScrollView.java
  33. 13
      beautysettingkit/src/main/res/anim/beauty_load_progress_animation.xml
  34. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_bailan.png
  35. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_baixi.png
  36. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_biaozhun.png
  37. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_chaotuo.png
  38. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_chunzhen.png
  39. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_fennen.png
  40. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_bailan.png
  41. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_baixi.png
  42. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_biaozhun.png
  43. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_chaotuo.png
  44. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_chunzhen.png
  45. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_fennen.png
  46. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_huaijiu.png
  47. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_landiao.png
  48. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_langman.png
  49. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_qingliang.png
  50. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_qingxin.png
  51. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_rixi.png
  52. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_weimei.png
  53. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_white.png
  54. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_xiangfen.png
  55. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_yinghong.png
  56. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_yuanqi.png
  57. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_yunshang.png
  58. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_ziran.png
  59. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_fwhite.png
  60. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_huaijiu.png
  61. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_bigeye.png
  62. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_bottom_bg.png
  63. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_bottom_bg2.png
  64. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_chin.png
  65. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_common_none.png
  66. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_cutout_background_ai.png
  67. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_boom.png
  68. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_call.png
  69. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_constellation.png
  70. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_face_change.png
  71. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_flower_fairy.png
  72. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_headband.png
  73. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_neon_rat.png
  74. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_princess.png
  75. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_purple_cat.png
  76. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_ribbon.png
  77. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_star_ear.png
  78. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eye_angle.png
  79. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eye_bright.png
  80. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eye_distance.png
  81. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eyebig.png
  82. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_face_shape.png
  83. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_face_short.png
  84. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_faceslim.png
  85. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_facev.png
  86. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_forehead.png
  87. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_bottle_cap_challenge.png
  88. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_meteor_shower.png
  89. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_pikachu.png
  90. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_snow_control.png
  91. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_tv_star.png
  92. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_goodluck.png
  93. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_cherry.png
  94. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_costume.png
  95. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_lip.png
  96. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_mixing.png
  97. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_pink.png
  98. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_retro.png
  99. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_seas.png
  100. BIN
      beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_ugly.png

2
.idea/compiler.xml

@ -3,11 +3,13 @@
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.7">
<module name="UniPlugin-Hello-AS.app" target="1.8" />
<module name="UniPlugin-Hello-AS.beautysettingkit" target="1.8" />
<module name="UniPlugin-Hello-AS.face_module" target="1.8" />
<module name="UniPlugin-Hello-AS.face_module_2" target="1.8" />
<module name="UniPlugin-Hello-AS.facelibrary" target="1.8" />
<module name="UniPlugin-Hello-AS.gatelibrary" target="1.8" />
<module name="UniPlugin-Hello-AS.registerlibrary" target="1.8" />
<module name="UniPlugin-Hello-AS.ugckit" target="1.8" />
<module name="UniPlugin-Hello-AS.uniplugin_component" target="1.8" />
<module name="UniPlugin-Hello-AS.uniplugin_module" target="1.8" />
<module name="UniPlugin-Hello-AS.uniplugin_module_ox" target="1.8" />

2
.idea/gradle.xml

@ -12,11 +12,13 @@
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/beautysettingkit" />
<option value="$PROJECT_DIR$/face_module" />
<option value="$PROJECT_DIR$/facelibrary" />
<option value="$PROJECT_DIR$/gatelibrary" />
<option value="$PROJECT_DIR$/ox_module" />
<option value="$PROJECT_DIR$/registerlibrary" />
<option value="$PROJECT_DIR$/ugckit" />
<option value="$PROJECT_DIR$/uniplugin_component" />
<option value="$PROJECT_DIR$/uniplugin_module" />
<option value="$PROJECT_DIR$/uniplugin_module_TXLiveAVSDK" />

21
app/build.gradle

@ -19,6 +19,17 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
renderscriptTargetApi = 19
renderscriptSupportModeEnabled = true
multiDexEnabled = true
ndk {
abiFilters rootProject.ext.ndkAbi
}
}
packagingOptions {
@ -103,6 +114,16 @@ dependencies {
implementation project(path: ':gatelibrary')
implementation project(path: ':uniplugin_module_TXLiveAVSDK')
// compile fileTree(include: ['*.jar'], dir: 'libs')
// compile fileTree(include: ['*.jar'], dir: 'src/main/jniLibs')
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.ctiao:dfm:0.4.4'
compile project(':ugckit')
compile 'com.android.support.constraint:constraint-layout:1.1.3'
}

12
app/src/main/AndroidManifest.xml

@ -20,6 +20,18 @@
<uses-permission android:name="android.permission.FLASHLIGHT" />
<!-- Barcode(二维码) end -->
<!-- TXLive SDK-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.Camera"/>
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:name="io.dcloud.application.DCloudApplication"
android:allowBackup="true"

2
app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
File diff suppressed because it is too large
View File

2
app/src/main/assets/apps/__UNI__2B9497D/www/app-view.js
File diff suppressed because it is too large
View File

2
app/src/main/assets/data/dcloud_control.xml

@ -1,6 +1,6 @@
<hbuilder>
<apps>
<apps debug="true" syncDebug="true">
<app appid="__UNI__2B9497D" appver=""/>
</apps>
</hbuilder>

31
beautysettingkit/build.gradle

@ -0,0 +1,31 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.code.gson:gson:2.3.1'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation rootProject.ext.liteavSdk
}

21
beautysettingkit/proguard-rules.pro

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

4
beautysettingkit/src/main/AndroidManifest.xml

@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tencent.liteav.demo.beauty">
</manifest>

624
beautysettingkit/src/main/assets/default_beauty_data.json

@ -0,0 +1,624 @@
{
"beauty_bg": "#ff13233f",
"beauty_tab_name_color_normal": "#ff888888",
"beauty_tab_name_color_select": "#ffffffff",
"beauty_tab_name_width": -2,
"beauty_tab_name_height": -2,
"beauty_tab_name_size": 14,
"beauty_tab_list": [
{
"tab_id": 1,
"tab_type": 10001,
"tab_name": "@beauty_setting_panel_beauty",
"tab_item_name_size": 10,
"tab_item_name_color_normal": "#ff888888",
"tab_item_name_color_select": "#ffffffff",
"tab_item_icon_width": 54,
"tab_item_icon_height": 54,
"tab_item_level_hint_color": "#ffffffff",
"tab_item_level_hint_size": 16,
"tab_item_level_value_color": "#ffffffff",
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list_default_selected_index": 2,
"tab_item_list": [
{
"item_id": 1,
"item_type": 20101,
"item_name": "@beauty_panel_style_smooth",
"item_material_url": "",
"item_level": 4,
"item_icon_normal": "@beauty_ic_smooth",
"item_icon_select": "@beauty_ic_smooth"
},
{
"item_id": 2,
"item_type": 20102,
"item_name": "@beauty_panel_style_natural",
"item_material_url": "",
"item_level": 4,
"item_icon_normal": "@beauty_ic_natural",
"item_icon_select": "@beauty_ic_natural"
},
{
"item_id": 3,
"item_type": 20103,
"item_name": "@beauty_panel_style_pitu",
"item_material_url": "",
"item_level": 4,
"item_icon_normal": "@beauty_ic_pitu",
"item_icon_select": "@beauty_ic_pitu"
},
{
"item_id": 4,
"item_type": 20104,
"item_name": "@beauty_panel_white",
"item_material_url": "",
"item_level": 1,
"item_icon_normal": "@beauty_ic_white",
"item_icon_select": "@beauty_ic_white"
},
{
"item_id": 5,
"item_type": 20105,
"item_name": "@beauty_panel_ruddy",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_ruddy",
"item_icon_select": "@beauty_ic_ruddy"
},
{
"item_id": 6,
"item_type": 20106,
"item_name": "@beauty_panel_bigeye",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_bigeye",
"item_icon_select": "@beauty_ic_bigeye"
},
{
"item_id": 7,
"item_type": 20107,
"item_name": "@beauty_panel_faceslim",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_faceslim",
"item_icon_select": "@beauty_ic_faceslim"
},
{
"item_id": 8,
"item_type": 20108,
"item_name": "@beauty_panel_facev",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_facev",
"item_icon_select": "@beauty_ic_facev"
},
{
"item_id": 9,
"item_type": 20109,
"item_name": "@beauty_panel_chin",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_chin",
"item_icon_select": "@beauty_ic_chin"
},
{
"item_id": 10,
"item_type": 20110,
"item_name": "@beauty_panel_faceshort",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_face_short",
"item_icon_select": "@beauty_ic_face_short"
},
{
"item_id": 11,
"item_type": 20111,
"item_name": "@beauty_panel_noseslim",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_noseslim",
"item_icon_select": "@beauty_ic_noseslim"
},
{
"item_id": 12,
"item_type": 20112,
"item_name": "@beauty_panel_eyelighten",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_eye_bright",
"item_icon_select": "@beauty_ic_eye_bright"
},
{
"item_id": 13,
"item_type": 20113,
"item_name": "@beauty_panel_toothwhite",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_tooth_white",
"item_icon_select": "@beauty_ic_tooth_white"
},
{
"item_id": 14,
"item_type": 20114,
"item_name": "@beauty_panel_wrinkleremove",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_wrinkles",
"item_icon_select": "@beauty_ic_wrinkles"
},
{
"item_id": 15,
"item_type": 20115,
"item_name": "@beauty_panel_pounchremove",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_pouch_remove",
"item_icon_select": "@beauty_ic_pouch_remove"
},
{
"item_id": 16,
"item_type": 20116,
"item_name": "@beauty_panel_smilelinesremove",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_smile_lines",
"item_icon_select": "@beauty_ic_smile_lines"
},
{
"item_id": 17,
"item_type": 20117,
"item_name": "@beauty_panel_forehead",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_forehead",
"item_icon_select": "@beauty_ic_forehead"
},
{
"item_id": 18,
"item_type": 20118,
"item_name": "@beauty_panel_eyedistance",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_eye_distance",
"item_icon_select": "@beauty_ic_eye_distance"
},
{
"item_id": 19,
"item_type": 20119,
"item_name": "@beauty_panel_eyeangle",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_eye_angle",
"item_icon_select": "@beauty_ic_eye_angle"
},
{
"item_id": 20,
"item_type": 20120,
"item_name": "@beauty_panel_mouthshape",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_mouse_shape",
"item_icon_select": "@beauty_ic_mouse_shape"
},
{
"item_id": 21,
"item_type": 20121,
"item_name": "@beauty_panel_nosewing",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_nose_wing",
"item_icon_select": "@beauty_ic_nose_wing"
},
{
"item_id": 22,
"item_type": 20122,
"item_name": "@beauty_panel_noseposition",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_nose_position",
"item_icon_select": "@beauty_ic_nose_position"
},
{
"item_id": 23,
"item_type": 20123,
"item_name": "@beauty_panel_mousewidth",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_mouse_width",
"item_icon_select": "@beauty_ic_mouse_width"
},
{
"item_id": 24,
"item_type": 20124,
"item_name": "@beauty_panel_faceshape",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_face_shape",
"item_icon_select": "@beauty_ic_face_shape"
}
]
},
{
"tab_id": 2,
"tab_type": 10002,
"tab_name": "@beauty_setting_panel_filter",
"tab_item_name_size": 10,
"tab_item_name_color_normal": "#ff888888",
"tab_item_name_color_select": "#ffffffff",
"tab_item_icon_width": 54,
"tab_item_icon_height": 54,
"tab_item_level_hint_color": "#ffffffff",
"tab_item_level_hint_size": 16,
"tab_item_level_value_color": "#ffffffff",
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list_default_selected_index": 1,
"tab_item_list": [
{
"item_id": 1,
"item_type": 20201,
"item_name": "@beauty_common_none",
"item_material_url": "",
"item_level": 0,
"item_icon_normal": "@beauty_ic_common_none",
"item_icon_select": "@beauty_ic_common_none"
},
{
"item_id": 2,
"item_type": 20202,
"item_name": "@beauty_panel_filter_baixi",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_baixi",
"item_icon_select": "@beauty_baixi"
},
{
"item_id": 3,
"item_type": 20203,
"item_name": "@beauty_panel_filter_standard",
"item_material_url": "",
"item_level": 4,
"item_icon_normal": "@beauty_biaozhun",
"item_icon_select": "@beauty_biaozhun"
},
{
"item_id": 4,
"item_type": 20204,
"item_name": "@beauty_panel_filter_ziran",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_ziran",
"item_icon_select": "@beauty_ziran"
},
{
"item_id": 5,
"item_type": 20205,
"item_name": "@beauty_panel_filter_cheery",
"item_material_url": "",
"item_level": 8,
"item_icon_normal": "@beauty_yinghong",
"item_icon_select": "@beauty_yinghong"
},
{
"item_id": 6,
"item_type": 20206,
"item_name": "@beauty_panel_filter_cloud",
"item_material_url": "",
"item_level": 8,
"item_icon_normal": "@beauty_yunshang",
"item_icon_select": "@beauty_yunshang"
},
{
"item_id": 7,
"item_type": 20207,
"item_name": "@beauty_panel_filter_pure",
"item_material_url": "",
"item_level": 8,
"item_icon_normal": "@beauty_chunzhen",
"item_icon_select": "@beauty_chunzhen"
},
{
"item_id": 8,
"item_type": 20208,
"item_name": "@beauty_panel_filter_orchid",
"item_material_url": "",
"item_level": 9,
"item_icon_normal": "@beauty_bailan",
"item_icon_select": "@beauty_bailan"
},
{
"item_id": 9,
"item_type": 20209,
"item_name": "@beauty_panel_filter_vitality",
"item_material_url": "",
"item_level": 8,
"item_icon_normal": "@beauty_yuanqi",
"item_icon_select": "@beauty_yuanqi"
},
{
"item_id": 10,
"item_type": 20210,
"item_name": "@beauty_panel_filter_super",
"item_material_url": "",
"item_level": 9,
"item_icon_normal": "@beauty_chaotuo",
"item_icon_select": "@beauty_chaotuo"
},
{
"item_id": 11,
"item_type": 20211,
"item_name": "@beauty_panel_filter_fragrance",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_xiangfen",
"item_icon_select": "@beauty_xiangfen"
},
{
"item_id": 12,
"item_type": 20212,
"item_name": "@beauty_panel_filter_white",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_fwhite",
"item_icon_select": "@beauty_fwhite"
},
{
"item_id": 13,
"item_type": 20213,
"item_name": "@beauty_panel_filter_romantic",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_langman",
"item_icon_select": "@beauty_langman"
},
{
"item_id": 14,
"item_type": 20214,
"item_name": "@beauty_panel_filter_fresh",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_qingxin",
"item_icon_select": "@beauty_qingxin"
},
{
"item_id": 15,
"item_type": 20215,
"item_name": "@beauty_panel_filter_beautiful",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_weimei",
"item_icon_select": "@beauty_weimei"
},
{
"item_id": 16,
"item_type": 20216,
"item_name": "@beauty_panel_filter_pink",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_fennen",
"item_icon_select": "@beauty_fennen"
},
{
"item_id": 17,
"item_type": 20217,
"item_name": "@beauty_panel_filter_reminiscence",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_huaijiu",
"item_icon_select": "@beauty_huaijiu"
},
{
"item_id": 18,
"item_type": 20218,
"item_name": "@beauty_panel_filter_blues",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_landiao",
"item_icon_select": "@beauty_landiao"
},
{
"item_id": 19,
"item_type": 20219,
"item_name": "@beauty_panel_filter_cool",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_qingliang",
"item_icon_select": "@beauty_qingliang"
},
{
"item_id": 20,
"item_type": 20220,
"item_name": "@beauty_panel_filter_Japanese",
"item_material_url": "",
"item_level": 5,
"item_icon_normal": "@beauty_rixi",
"item_icon_select": "@beauty_rixi"
}
]
},
{
"tab_id": 3,
"tab_type": 10003,
"tab_name": "@beauty_setting_panel_dynamic_effect",
"tab_item_name_size": 10,
"tab_item_name_color_normal": "#ff888888",
"tab_item_name_color_select": "#ffffffff",
"tab_item_icon_width": 54,
"tab_item_icon_height": 54,
"tab_item_level_hint_color": "#ffffffff",
"tab_item_level_hint_size": 16,
"tab_item_level_value_color": "#ffffffff",
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list": [
{
"item_id": 1,
"item_type": 20301,
"item_name": "@beauty_common_none",
"item_material_url": "",
"item_level": -1,
"item_icon_normal": "@beauty_ic_common_none",
"item_icon_select": "@beauty_ic_common_none"
},
{
"item_id": 2,
"item_type": 20302,
"item_name": "@beauty_effect_boom",
"item_material_url": "http://dldir1.qq.com/hudongzhibo/AISpecial/Android/170/video_boomAndroid.zip",
"item_level": -1,
"item_icon_normal": "@beauty_ic_effect_boom",
"item_icon_select": "@beauty_ic_effect_boom"
}
]
},
{
"tab_id": 4,
"tab_type": 10004,
"tab_name": "@beauty_setting_panel_facebeauty",
"tab_item_name_size": 10,
"tab_item_name_color_normal": "#ff888888",
"tab_item_name_color_select": "#ffffffff",
"tab_item_icon_width": 54,
"tab_item_icon_height": 54,
"tab_item_level_hint_color": "#ffffffff",
"tab_item_level_hint_size": 16,
"tab_item_level_value_color": "#ffffffff",
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list": [
{
"item_id": 1,
"item_type": 20401,
"item_name": "@beauty_common_none",
"item_material_url": "",
"item_level": -1,
"item_icon_normal": "@beauty_ic_common_none",
"item_icon_select": "@beauty_ic_common_none"
},
{
"item_id": 2,
"item_type": 20402,
"item_name": "@beauty_makeups_cherry",
"item_material_url": "http://dldir1.qq.com/hudongzhibo/AISpecial/Android/video_cherriesAndroid.zip",
"item_level": -1,
"item_icon_normal": "@beauty_ic_makeups_cherry",
"item_icon_select": "@beauty_ic_makeups_cherry"
}
]
},
{
"tab_id": 5,
"tab_type": 10005,
"tab_name": "@beauty_setting_panel_gesture",
"tab_item_name_size": 10,
"tab_item_name_color_normal": "#ff888888",
"tab_item_name_color_select": "#ffffffff",
"tab_item_icon_width": 54,
"tab_item_icon_height": 54,
"tab_item_level_hint_color": "#ffffffff",
"tab_item_level_hint_size": 16,
"tab_item_level_value_color": "#ffffffff",
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list": [
{
"item_id": 1,
"item_type": 20501,
"item_name": "@beauty_common_none",
"item_material_url": "",
"item_level": -1,
"item_icon_normal": "@beauty_ic_common_none",
"item_icon_select": "@beauty_ic_common_none"
},
{
"item_id": 2,
"item_type": 20502,
"item_name": "@beauty_gesture_pikaqiu",
"item_material_url": "http://dldir1.qq.com/hudongzhibo/AISpecial/Android/181/video_pikachu.zip",
"item_level": -1,
"item_icon_normal": "@beauty_ic_gesture_pikachu",
"item_icon_select": "@beauty_ic_gesture_pikachu"
}
]
},
{
"tab_id": 6,
"tab_type": 10006,
"tab_name": "@beauty_cutout_background_ai",
"tab_item_name_size": 10,
"tab_item_name_color_normal": "#ff888888",
"tab_item_name_color_select": "#ffffffff",
"tab_item_icon_width": 54,
"tab_item_icon_height": 54,
"tab_item_level_hint_color": "#ffffffff",
"tab_item_level_hint_size": 16,
"tab_item_level_value_color": "#ffffffff",
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list": [
{
"item_id": 1,
"item_type": 20601,
"item_name": "@beauty_common_none",
"item_material_url": "",
"item_level": -1,
"item_icon_normal": "@beauty_ic_common_none",
"item_icon_select": "@beauty_ic_common_none"
},
{
"item_id": 2,
"item_type": 20602,
"item_name": "@beauty_cutout_background_ai",
"item_material_url": "http://dldir1.qq.com/hudongzhibo/AISpecial/Android/170/video_xiaofuAndroid.zip",
"item_level": -1,
"item_icon_normal": "@beauty_ic_cutout_background_ai",
"item_icon_select": "@beauty_ic_cutout_background_ai"
}
]
},
{
"tab_id": 7,
"tab_type": 10007,
"tab_name": "@beauty_setting_panel_green_screen",
"tab_item_name_size": 10,
"tab_item_name_color_normal": "#ff888888",
"tab_item_name_color_select": "#ffffffff",
"tab_item_icon_width": 54,
"tab_item_icon_height": 54,
"tab_item_level_hint_color": "#ffffffff",
"tab_item_level_hint_size": 16,
"tab_item_level_value_color": "#ffffffff",
"tab_item_level_value_size": 14,
"tab_item_level_progress_drawable": "@beauty_progress_drawable",
"tab_item_level_progress_thumb": "@beauty_thumb",
"tab_item_list": [
{
"item_id": 1,
"item_type": 20701,
"item_name": "@beauty_common_none",
"item_material_url": "",
"item_level": -1,
"item_icon_normal": "@beauty_ic_common_none",
"item_icon_select": "@beauty_ic_common_none"
},
{
"item_id": 2,
"item_type": 20702,
"item_name": "@beauty_good_luck",
"item_material_url": "",
"item_level": -1,
"item_icon_normal": "@beauty_ic_goodluck",
"item_icon_select": "@beauty_ic_goodluck"
}
]
}
]
}

BIN
beautysettingkit/src/main/assets/green_1.mp4

47
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/Beauty.java

@ -0,0 +1,47 @@
package com.tencent.liteav.demo.beauty;
import android.graphics.Bitmap;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import com.tencent.liteav.beauty.TXBeautyManager;
import com.tencent.liteav.demo.beauty.model.BeautyInfo;
import com.tencent.liteav.demo.beauty.model.ItemInfo;
import com.tencent.liteav.demo.beauty.model.TabInfo;
public interface Beauty {
void setBeautyManager(@NonNull TXBeautyManager beautyManager);
void setBeautySpecialEffects(@NonNull TabInfo tabinfo, @IntRange(from = 0) int tabPosition,
@NonNull ItemInfo itemInfo, @IntRange(from = 0) int itemPosition);
void setBeautyStyleAndLevel(int style, int level);
void setMotionTmplEnable(boolean enable);
void fillingMaterialPath(@NonNull BeautyInfo beautyInfo);
void setCurrentFilterIndex(@NonNull BeautyInfo beautyInfo, @IntRange(from = 0) int index);
void setCurrentBeautyIndex(@NonNull BeautyInfo beautyInfo, @IntRange(from = 0) int index);
void setOnFilterChangeListener(OnFilterChangeListener listener);
void clear();
int getFilterProgress(@NonNull BeautyInfo beautyInfo, @IntRange(from = 0) int index);
int getFilterSize(@NonNull BeautyInfo beautyInfo);
ItemInfo getFilterItemInfo(@NonNull BeautyInfo beautyInfo, @IntRange(from = 0) int index);
Bitmap getFilterResource(@NonNull BeautyInfo beautyInfo, @IntRange(from = 0) int index);
BeautyInfo getDefaultBeauty();
interface OnFilterChangeListener {
void onChanged(Bitmap filterImage, int index);
}
}

823
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/BeautyImpl.java

@ -0,0 +1,823 @@
package com.tencent.liteav.demo.beauty;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.widget.Toast;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import com.tencent.liteav.beauty.TXBeautyManager;
import com.tencent.liteav.demo.beauty.constant.BeautyConstants;
import com.tencent.liteav.demo.beauty.download.DownloadListener;
import com.tencent.liteav.demo.beauty.download.MaterialDownloader;
import com.tencent.liteav.demo.beauty.model.BeautyInfo;
import com.tencent.liteav.demo.beauty.model.ItemInfo;
import com.tencent.liteav.demo.beauty.model.TabInfo;
import com.tencent.liteav.demo.beauty.utils.BeautyUtils;
import com.tencent.liteav.demo.beauty.utils.ResourceUtils;
import com.tencent.liteav.demo.beauty.utils.SPUtils;
import com.tencent.liteav.demo.beauty.view.ProgressDialog;
import java.util.List;
public class BeautyImpl implements Beauty {
private static final String TAG = "BeautyImpl";
private Context mContext;
private BeautyParams mBeautyParams;
private TXBeautyManager mBeautyManager;
private OnFilterChangeListener mOnFilterChangeListener;
public BeautyImpl(@NonNull Context context) {
mContext = context;
mBeautyParams = new BeautyParams();
}
@Override
public void setBeautyManager(@NonNull TXBeautyManager beautyManager) {
mBeautyManager = beautyManager;
}
@Override
public void setBeautySpecialEffects(@NonNull TabInfo tabinfo, @IntRange(from = 0) int tabPosition,
@NonNull ItemInfo itemInfo, @IntRange(from = 0) int itemPosition) {
dispatchEffects(tabinfo, tabPosition, itemInfo, itemPosition);
}
@Override
public void setBeautyStyleAndLevel(int style, int level) {
if (mBeautyManager != null) {
setBeautyStyle(style);
setBeautyLevel(level);
}
}
/**
* 设置指定素材滤镜特效
*
* @param filterImage 指定素材即颜色查找表图片必须使用 png 格式
* @param index
*/
private void setFilter(Bitmap filterImage, int index) {
mBeautyParams.mFilterBmp = filterImage;
mBeautyParams.mFilterIndex = index;
if (mBeautyManager != null) {
mBeautyManager.setFilter(filterImage);
if (mOnFilterChangeListener != null) {
mOnFilterChangeListener.onChanged(filterImage, index);
}
}
}
/**
* 设置滤镜浓度
*
* @param strength 从0到1越大滤镜效果越明显默认值为0.5
*/
private void setFilterStrength(float strength) {
mBeautyParams.mFilterMixLevel = strength;
if (mBeautyManager != null) {
mBeautyManager.setFilterStrength(strength);
}
}
/**
* 设置绿幕文件
*
* @param path 视频文件路径支持 MP4null 表示关闭特效
*/
private void setGreenScreenFile(String path) {
mBeautyParams.mGreenFile = path;
if (mBeautyManager != null) {
mBeautyManager.setGreenScreenFile(path);
}
}
/**
* 设置美颜类型
*
* @param beautyStyle 美颜风格.三种美颜风格0 光滑 1自然 2朦胧
*/
private void setBeautyStyle(int beautyStyle) {
if (beautyStyle >= 3 || beautyStyle < 0) {
return;
}
mBeautyParams.mBeautyStyle = beautyStyle;
if (mBeautyManager != null) {
mBeautyManager.setBeautyStyle(beautyStyle);
}
}
/**
* 设置美颜级别
*
* @param beautyLevel 美颜级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setBeautyLevel(int beautyLevel) {
mBeautyParams.mBeautyLevel = beautyLevel;
if (mBeautyManager != null) {
mBeautyManager.setBeautyLevel(beautyLevel);
}
}
/**
* 设置美白级别
*
* @param whitenessLevel 美白级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setWhitenessLevel(int whitenessLevel) {
mBeautyParams.mWhiteLevel = whitenessLevel;
if (mBeautyManager != null) {
mBeautyManager.setWhitenessLevel(whitenessLevel);
}
}
/**
* 设置红润级别
*
* @param ruddyLevel 红润级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setRuddyLevel(int ruddyLevel) {
mBeautyParams.mRuddyLevel = ruddyLevel;
if (mBeautyManager != null) {
mBeautyManager.setRuddyLevel(ruddyLevel);
}
}
/**
* 设置大眼级别
*
* @param eyeScaleLevel 大眼级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setEyeScaleLevel(int eyeScaleLevel) {
mBeautyParams.mBigEyeLevel = eyeScaleLevel;
if (mBeautyManager != null) {
mBeautyManager.setEyeScaleLevel(eyeScaleLevel);
}
}
/**
* 设置瘦脸级别
*
* @param faceSlimLevel 瘦脸级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setFaceSlimLevel(int faceSlimLevel) {
mBeautyParams.mFaceSlimLevel = faceSlimLevel;
if (mBeautyManager != null) {
mBeautyManager.setFaceSlimLevel(faceSlimLevel);
}
}
/**
* 设置 V 脸级别
*
* @param faceVLevel V脸级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setFaceVLevel(int faceVLevel) {
mBeautyParams.mFaceVLevel = faceVLevel;
if (mBeautyManager != null) {
mBeautyManager.setFaceVLevel(faceVLevel);
}
}
/**
* 设置下巴拉伸或收缩
*
* @param chinLevel 下巴拉伸或收缩级别取值范围 -9 - 90 表示关闭小于0表示收缩大于0表示拉伸
*/
private void setChinLevel(int chinLevel) {
mBeautyParams.mChinSlimLevel = chinLevel;
if (mBeautyManager != null) {
mBeautyManager.setChinLevel(chinLevel);
}
}
/**
* 设置短脸级别
*
* @param faceShortLevel 短脸级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setFaceShortLevel(int faceShortLevel) {
mBeautyParams.mFaceShortLevel = faceShortLevel;
if (mBeautyManager != null) {
mBeautyManager.setFaceShortLevel(faceShortLevel);
}
}
/**
* 设置瘦鼻级别
*
* @param noseSlimLevel 瘦鼻级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setNoseSlimLevel(int noseSlimLevel) {
mBeautyParams.mNoseSlimLevel = noseSlimLevel;
if (mBeautyManager != null) {
mBeautyManager.setNoseSlimLevel(noseSlimLevel);
}
}
/**
* 设置亮眼
*
* @param eyeLightenLevel 亮眼级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setEyeLightenLevel(int eyeLightenLevel) {
mBeautyParams.mEyeLightenLevel = eyeLightenLevel;
if (mBeautyManager != null) {
mBeautyManager.setEyeLightenLevel(eyeLightenLevel);
}
}
/**
* 设置白牙
*
* @param toothWhitenLevel 亮眼级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setToothWhitenLevel(int toothWhitenLevel) {
mBeautyParams.mToothWhitenLevel = toothWhitenLevel;
if (mBeautyManager != null) {
mBeautyManager.setToothWhitenLevel(toothWhitenLevel);
}
}
/**
* 设置祛皱
*
* @param wrinkleRemoveLevel 祛皱级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setWrinkleRemoveLevel(int wrinkleRemoveLevel) {
mBeautyParams.mWrinkleRemoveLevel = wrinkleRemoveLevel;
if (mBeautyManager != null) {
mBeautyManager.setWrinkleRemoveLevel(wrinkleRemoveLevel);
}
}
/**
* 设置祛眼袋
*
* @param pounchRemoveLevel 祛眼袋级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setPounchRemoveLevel(int pounchRemoveLevel) {
mBeautyParams.mPounchRemoveLevel = pounchRemoveLevel;
if (mBeautyManager != null) {
mBeautyManager.setPounchRemoveLevel(pounchRemoveLevel);
}
}
/**
* 设置祛法令纹
*
* @param smileLinesRemoveLevel 祛法令纹级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setSmileLinesRemoveLevel(int smileLinesRemoveLevel) {
mBeautyParams.mSmileLinesRemoveLevel = smileLinesRemoveLevel;
if (mBeautyManager != null) {
mBeautyManager.setSmileLinesRemoveLevel(smileLinesRemoveLevel);
}
}
/**
* 设置发际线
*
* @param foreheadLevel 发际线级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setForeheadLevel(int foreheadLevel) {
mBeautyParams.mForeheadLevel = foreheadLevel;
if (mBeautyManager != null) {
mBeautyManager.setForeheadLevel(foreheadLevel);
}
}
/**
* 设置眼距
*
* @param eyeDistanceLevel 眼距级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setEyeDistanceLevel(int eyeDistanceLevel) {
mBeautyParams.mEyeDistanceLevel = eyeDistanceLevel;
if (mBeautyManager != null) {
mBeautyManager.setEyeDistanceLevel(eyeDistanceLevel);
}
}
/**
* 设置眼角
*
* @param eyeAngleLevel 眼角级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setEyeAngleLevel(int eyeAngleLevel) {
mBeautyParams.mEyeAngleLevel = eyeAngleLevel;
if (mBeautyManager != null) {
mBeautyManager.setEyeAngleLevel(eyeAngleLevel);
}
}
/**
* 设置嘴型
*
* @param mouthShapeLevel 嘴型级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setMouthShapeLevel(int mouthShapeLevel) {
mBeautyParams.mMouthShapeLevel = mouthShapeLevel;
if (mBeautyManager != null) {
mBeautyManager.setMouthShapeLevel(mouthShapeLevel);
}
}
private void setNoseWingLevel(int noseWingLevel) {
mBeautyParams.mNoseWingLevel = noseWingLevel;
if (mBeautyManager != null) {
mBeautyManager.setNoseWingLevel(noseWingLevel);
}
}
/**
* 设置鼻翼
*
* @param nosePositionLevel 鼻翼级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setNosePositionLevel(int nosePositionLevel) {
mBeautyParams.mNosePositionLevel = nosePositionLevel;
if (mBeautyManager != null) {
mBeautyManager.setNosePositionLevel(nosePositionLevel);
}
}
/**
* 设置嘴唇厚度
*
* @param lipsThicknessLevel 嘴唇厚度级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setLipsThicknessLevel(int lipsThicknessLevel) {
mBeautyParams.mMouthShapeLevel = lipsThicknessLevel;
if (mBeautyManager != null) {
mBeautyManager.setLipsThicknessLevel(lipsThicknessLevel);
}
}
/**
* 设置脸型
*
* @param faceBeautyLevel 脸型级别取值范围0 - 9 0表示关闭1 - 9值越大效果越明显
*/
private void setFaceBeautyLevel(int faceBeautyLevel) {
mBeautyParams.mFaceBeautyLevel = faceBeautyLevel;
if (mBeautyManager != null) {
mBeautyManager.setFaceBeautyLevel(faceBeautyLevel);
}
}
/**
* 选择使用哪一款 AI 动效挂件
*
* @param tmplPath
*/
private void setMotionTmpl(String tmplPath) {
mBeautyParams.mMotionTmplPath = tmplPath;
if (mBeautyManager != null) {
mBeautyManager.setMotionTmpl(tmplPath);
}
}
@Override
public void setMotionTmplEnable(boolean enable) {
if (mBeautyManager != null) {
if (enable) {
mBeautyManager.setMotionTmpl(null);
} else {
mBeautyManager.setMotionTmpl(mBeautyParams.mMotionTmplPath);
}
}
}
@Override
public void fillingMaterialPath(@NonNull BeautyInfo beautyInfo) {
for (TabInfo tabInfo : beautyInfo.getBeautyTabList()) {
List<ItemInfo> tabItemList = tabInfo.getTabItemList();
for (ItemInfo itemInfo : tabItemList) {
itemInfo.setItemMaterialPath(SPUtils.get().getString(getMaterialPathKey(itemInfo)));
}
}
}
@Override
public void setCurrentFilterIndex(BeautyInfo beautyInfo, int index) {
for (TabInfo tabInfo : beautyInfo.getBeautyTabList()) {
if (tabInfo.getTabType() == BeautyConstants.TAB_TYPE_FILTER) {
ItemInfo itemInfo = tabInfo.getTabItemList().get(index);
dispatchFilterEffects(itemInfo, index);
}
}
}
@Override
public void setCurrentBeautyIndex(@NonNull BeautyInfo beautyInfo, int index) {
for (TabInfo tabInfo : beautyInfo.getBeautyTabList()) {
if (tabInfo.getTabType() == BeautyConstants.TAB_TYPE_BEAUTY) {
ItemInfo itemInfo = tabInfo.getTabItemList().get(index);
dispatchBeautyEffects(itemInfo);
}
}
}
@Override
public void setOnFilterChangeListener(OnFilterChangeListener listener) {
mOnFilterChangeListener = listener;
}
/**
* 清空美颜配置如果SDK是新创建的则不需要最后清理如果SDK是单例需要调用此方法清空上次设置的美颜参数<br/>
* 示例TXUGCRecord是单例需要调用TXLivePusher每次创建新的不需要调用
*/
@Override
public void clear() {
mBeautyParams = new BeautyParams();
if (mBeautyManager != null) {
mBeautyManager.setFilter(mBeautyParams.mFilterBmp);
mBeautyManager.setFilterStrength(mBeautyParams.mFilterMixLevel);
mBeautyManager.setGreenScreenFile(mBeautyParams.mGreenFile);
mBeautyManager.setBeautyStyle(mBeautyParams.mBeautyStyle);
mBeautyManager.setBeautyLevel(mBeautyParams.mBeautyLevel);
mBeautyManager.setWhitenessLevel(mBeautyParams.mWhiteLevel);
mBeautyManager.setRuddyLevel(mBeautyParams.mRuddyLevel);
mBeautyManager.setEyeScaleLevel(mBeautyParams.mBigEyeLevel);
mBeautyManager.setFaceSlimLevel(mBeautyParams.mFaceSlimLevel);
mBeautyManager.setFaceVLevel(mBeautyParams.mFaceVLevel);
mBeautyManager.setChinLevel(mBeautyParams.mChinSlimLevel);
mBeautyManager.setFaceShortLevel(mBeautyParams.mFaceShortLevel);
mBeautyManager.setNoseSlimLevel(mBeautyParams.mNoseSlimLevel);
mBeautyManager.setEyeLightenLevel(mBeautyParams.mEyeLightenLevel);
mBeautyManager.setToothWhitenLevel(mBeautyParams.mToothWhitenLevel);
mBeautyManager.setWrinkleRemoveLevel(mBeautyParams.mWrinkleRemoveLevel);
mBeautyManager.setPounchRemoveLevel(mBeautyParams.mPounchRemoveLevel);
mBeautyManager.setSmileLinesRemoveLevel(mBeautyParams.mSmileLinesRemoveLevel);
mBeautyManager.setForeheadLevel(mBeautyParams.mForeheadLevel);
mBeautyManager.setEyeDistanceLevel(mBeautyParams.mEyeDistanceLevel);
mBeautyManager.setEyeAngleLevel(mBeautyParams.mEyeAngleLevel);
mBeautyManager.setMouthShapeLevel(mBeautyParams.mMouthShapeLevel);
mBeautyManager.setNoseWingLevel(mBeautyParams.mNoseWingLevel);
mBeautyManager.setNosePositionLevel(mBeautyParams.mNosePositionLevel);
mBeautyManager.setLipsThicknessLevel(mBeautyParams.mLipsThicknessLevel);
mBeautyManager.setFaceBeautyLevel(mBeautyParams.mFaceBeautyLevel);
mBeautyManager.setMotionTmpl(mBeautyParams.mMotionTmplPath);
}
}
@Override
public int getFilterProgress(@NonNull BeautyInfo beautyInfo, int index) {
if (index < 0) {
return 0;
}
List<TabInfo> beautyTabList = beautyInfo.getBeautyTabList();
for (TabInfo tabInfo : beautyTabList) {
if (tabInfo.getTabType() == BeautyConstants.TAB_TYPE_FILTER) {
List<ItemInfo> tabItemList = tabInfo.getTabItemList();
if (index < tabItemList.size()) {
ItemInfo itemInfo = tabItemList.get(index);
return itemInfo.getItemLevel();
} else {
return 0;
}
}
}
return 0;
}
@Override
public ItemInfo getFilterItemInfo(BeautyInfo beautyInfo, int index) {
for (TabInfo tabInfo : beautyInfo.getBeautyTabList()) {
if (tabInfo.getTabType() == BeautyConstants.TAB_TYPE_FILTER) {
return tabInfo.getTabItemList().get(index);
}
}
return null;
}
@Override
public int getFilterSize(@NonNull BeautyInfo beautyInfo) {
for (TabInfo tabInfo : beautyInfo.getBeautyTabList()) {
if (tabInfo.getTabType() == BeautyConstants.TAB_TYPE_FILTER) {
return tabInfo.getTabItemList().size();
}
}
return 0;
}
@Override
public Bitmap getFilterResource(@NonNull BeautyInfo beautyInfo, int index) {
return decodeFilterResource(getFilterItemInfo(beautyInfo, index));
}
@Override
public BeautyInfo getDefaultBeauty() {
return BeautyUtils.getDefaultBeautyInfo();
}
private void dispatchEffects(@NonNull TabInfo tabInfo, @IntRange(from = 0) int tabPosition,
@NonNull ItemInfo itemInfo, @IntRange(from = 0) int itemPosition) {
int tabType = tabInfo.getTabType();
switch (tabType) {
case BeautyConstants.TAB_TYPE_BEAUTY:
dispatchBeautyEffects(itemInfo);
break;
case BeautyConstants.TAB_TYPE_FILTER:
dispatchFilterEffects(itemInfo, itemPosition);
break;
case BeautyConstants.TAB_TYPE_MOTION:
case BeautyConstants.TAB_TYPE_BEAUTY_FACE:
case BeautyConstants.TAB_TYPE_GESTURE:
case BeautyConstants.TAB_TYPE_CUTOUT_BACKGROUND:
setMaterialEffects(tabInfo, itemInfo);
break;
case BeautyConstants.TAB_TYPE_GREEN:
String file = "";
if (itemInfo.getItemType() == BeautyConstants.ITEM_TYPE_GREEN_GOOD_LUCK) {
file = "green_1.mp4";
}
setGreenScreenFile(file);
break;
default:
break;
}
}
private void dispatchBeautyEffects(@NonNull ItemInfo itemInfo) {
int itemType = itemInfo.getItemType();
int level = itemInfo.getItemLevel();
switch (itemType) {
case BeautyConstants.ITEM_TYPE_BEAUTY_SMOOTH: // 光滑
setBeautyStyleAndLevel(0, level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_NATURAL: // 自然
setBeautyStyleAndLevel(1, level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_PITU: // 天天p图
setBeautyStyleAndLevel(2, level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_WHITE: // 美白
setWhitenessLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_RUDDY: // 红润
setRuddyLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_BIG_EYE: // 大眼
setEyeScaleLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_FACES_LIM: // 瘦脸
setFaceSlimLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_FACEV: // V脸
setFaceVLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_CHIN: // 下巴
setChinLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_FACE_SHORT: // 短脸
setFaceShortLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_NOSES_LIM: // 瘦鼻
setNoseSlimLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_EYE_BRIGHT: // 亮眼
setEyeLightenLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_TOOTH_WHITE: // 白牙
setToothWhitenLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_WRINKLE_REMOVE: // 祛皱
setWrinkleRemoveLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_POUCH_REMOVE: // 祛眼袋
setPounchRemoveLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_SMILE_LINES: // 袪法令纹
setSmileLinesRemoveLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_FOREHEAD: // 发际线
setForeheadLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_EYE_DISTANCE: // 眼距
setEyeDistanceLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_EYE_ANGLE: // 眼角
setEyeAngleLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_MOUTH_SHAPE: // 嘴型
setMouthShapeLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_NOSEWING: // 鼻翼
setNoseWingLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_NOSE_POSITION: // 鼻子位置
setNosePositionLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_MOUSE_WIDTH: // 嘴唇厚度
setLipsThicknessLevel(level);
break;
case BeautyConstants.ITEM_TYPE_BEAUTY_FACE_SHAPE: // 脸型
setFaceBeautyLevel(level);
break;
default :
Log.e(TAG, "wrong itemType : " + itemType);
break;
}
}
private void dispatchFilterEffects(@NonNull ItemInfo itemInfo, int position) {
Bitmap bitmap = decodeFilterResource(itemInfo);
mBeautyParams.mFilterBmp = bitmap;
mBeautyParams.mFilterIndex = position;
setFilter(bitmap, position);
setFilterStrength(itemInfo.getItemLevel() / 10.0f);
}
private void setMaterialEffects(@NonNull final TabInfo tabInfo, @NonNull final ItemInfo itemInfo) {
String itemMaterialPath = itemInfo.getItemMaterialPath();
if (!TextUtils.isEmpty(itemMaterialPath)) {
if (tabInfo.getTabType() == BeautyConstants.TAB_TYPE_GESTURE
&& itemInfo.getItemId() == 2) { // 皮卡丘 item 特殊逻辑
showToast(ResourceUtils.getString(R.string.beauty_palm_out));
}
setMotionTmpl(itemMaterialPath);
return;
}
int itemType = itemInfo.getItemType();
switch (itemType) {
case BeautyConstants.ITEM_TYPE_MOTION_NONE:
case BeautyConstants.ITEM_TYPE_BEAUTY_FACE_NONE:
case BeautyConstants.ITEM_TYPE_GESTURE_NONE:
case BeautyConstants.ITEM_TYPE_CUTOUT_BACKGROUND_NONE:
setMotionTmpl("");
break;
case BeautyConstants.ITEM_TYPE_MOTION_MATERIAL:
case BeautyConstants.ITEM_TYPE_BEAUTY_FACE_MATERIAL:
case BeautyConstants.ITEM_TYPE_GESTURE_MATERIAL:
case BeautyConstants.ITEM_TYPE_CUTOUT_BACKGROUND_MATERIAL:
downloadVideoMaterial(tabInfo, itemInfo);
break;
default :
Log.e(TAG, "wrong itemType : " + itemType);
break;
}
}
private void downloadVideoMaterial(@NonNull final TabInfo tabInfo, @NonNull final ItemInfo itemInfo) {
MaterialDownloader materialDownloader =
new MaterialDownloader(mContext, ResourceUtils.getString(itemInfo.getItemName()),
itemInfo.getItemMaterialUrl());
materialDownloader.start(new DownloadListener() {
private ProgressDialog mProgressDialog;
@Override
public void onDownloadFail(final String errorMsg) {
((Activity) mContext).runOnUiThread(new Runnable() {
@Override
public void run() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
}
Toast.makeText(mContext, errorMsg, Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onDownloadProgress(final int progress) {
((Activity) mContext).runOnUiThread(new Runnable() {
@Override
public void run() {
Log.i(TAG, "onDownloadProgress, progress = " + progress);
if (mProgressDialog == null) {
mProgressDialog = new ProgressDialog();
mProgressDialog.createLoadingDialog(mContext);
mProgressDialog.setCancelable(false); // 设置是否可以通过点击Back键取消
mProgressDialog.setCanceledOnTouchOutside(false); // 设置在点击Dialog外是否取消Dialog进度条
mProgressDialog.show();
}
mProgressDialog.setMsg(progress + "%");
}
});
}
@Override
public void onDownloadSuccess(String filePath) {
itemInfo.setItemMaterialPath(filePath);
SPUtils.get().put(getMaterialPathKey(itemInfo), filePath);
((Activity) mContext).runOnUiThread(new Runnable() {
@Override
public void run() {
if (mProgressDialog != null) {
mProgressDialog.dismiss();
mProgressDialog = null;
}
setMaterialEffects(tabInfo, itemInfo);
}
});
}
});
}
private Bitmap decodeFilterResource(@NonNull ItemInfo itemInfo) {
int itemType = itemInfo.getItemType();
int resId = 0;
switch (itemType) {
case BeautyConstants.ITEM_TYPE_FILTER_FACE_SHAPE:
break;
case BeautyConstants.ITEM_TYPE_FILTER_STANDARD:
resId = R.drawable.beauty_filter_biaozhun;
break;
case BeautyConstants.ITEM_TYPE_FILTER_ZIRAN:
resId = R.drawable.beauty_filter_ziran;
break;
case BeautyConstants.ITEM_TYPE_FILTER_BAIXI:
resId = R.drawable.beauty_filter_baixi;
break;
case BeautyConstants.ITEM_TYPE_FILTER_CHEERY:
resId = R.drawable.beauty_filter_yinghong;
break;
case BeautyConstants.ITEM_TYPE_FILTER_CLOUD:
resId = R.drawable.beauty_filter_yunshang;
break;
case BeautyConstants.ITEM_TYPE_FILTER_PURE:
resId = R.drawable.beauty_filter_chunzhen;
break;
case BeautyConstants.ITEM_TYPE_FILTER_ORCHID:
resId = R.drawable.beauty_filter_bailan;
break;
case BeautyConstants.ITEM_TYPE_FILTER_VITALITY:
resId = R.drawable.beauty_filter_yuanqi;
break;
case BeautyConstants.ITEM_TYPE_FILTER_SUPER:
resId = R.drawable.beauty_filter_chaotuo;
break;
case BeautyConstants.ITEM_TYPE_FILTER_FRAGRANCE:
resId = R.drawable.beauty_filter_xiangfen;
break;
case BeautyConstants.ITEM_TYPE_FILTER_WHITE:
resId = R.drawable.beauty_filter_white;
break;
case BeautyConstants.ITEM_TYPE_FILTER_ROMANTIC:
resId = R.drawable.beauty_filter_langman;
break;
case BeautyConstants.ITEM_TYPE_FILTER_FRESH:
resId = R.drawable.beauty_filter_qingxin;
break;
case BeautyConstants.ITEM_TYPE_FILTER_BEAUTIFUL:
resId = R.drawable.beauty_filter_weimei;
break;
case BeautyConstants.ITEM_TYPE_FILTER_PINK:
resId = R.drawable.beauty_filter_fennen;
break;
case BeautyConstants.ITEM_TYPE_FILTER_REMINISCENCE:
resId = R.drawable.beauty_filter_huaijiu;
break;
case BeautyConstants.ITEM_TYPE_FILTER_BLUES:
resId = R.drawable.beauty_filter_landiao;
break;
case BeautyConstants.ITEM_TYPE_FILTER_COOL:
resId = R.drawable.beauty_filter_qingliang;
break;
case BeautyConstants.ITEM_TYPE_FILTER_JAPANESE:
resId = R.drawable.beauty_filter_rixi;
break;
default :
Log.e(TAG, "wrong itemType : " + itemType);
break;
}
if (resId != 0) {
return decodeResource(resId);
} else {
return null;
}
}
private Bitmap decodeResource(int id) {
TypedValue value = new TypedValue();
ResourceUtils.getResources().openRawResource(id, value);
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inTargetDensity = value.density;
return BitmapFactory.decodeResource(ResourceUtils.getResources(), id, opts);
}
private String getMaterialPathKey(@NonNull ItemInfo itemInfo) {
return itemInfo.getItemId() + "-" + itemInfo.getItemType();
}
private void showToast(@StringRes int resId) {
showToast(ResourceUtils.getString(resId));
}
private void showToast(@NonNull String text) {
Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}
}

75
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/BeautyParams.java

@ -0,0 +1,75 @@
package com.tencent.liteav.demo.beauty;
import android.graphics.Bitmap;
/**
* 美颜参数
*/
public class BeautyParams {
// 美颜类型
public int mBeautyStyle = 0;
// 美颜
public int mBeautyLevel = 4;
// 美白
public int mWhiteLevel = 1;
// 红润
public int mRuddyLevel = 0;
// 滤镜LUT图
public Bitmap mFilterBmp;
// 滑动滤镜索引
public int mFilterIndex;
// 滤镜程度
public float mFilterMixLevel = 0;
// 大眼
public int mBigEyeLevel;
// 瘦脸
public int mFaceSlimLevel;
// 瘦鼻
public int mNoseSlimLevel;
// 缩下巴
public int mChinSlimLevel;
// V脸
public int mFaceVLevel;
// 短脸
public int mFaceShortLevel;
// 亮眼
public int mEyeLightenLevel = 0;
// 白牙
public int mToothWhitenLevel = 0;
// 祛皱
public int mWrinkleRemoveLevel = 0;
// 祛眼袋
public int mPounchRemoveLevel = 0;
// 祛法令纹
public int mSmileLinesRemoveLevel = 0;
// 发际线
public int mForeheadLevel = 0;
// 眼距
public int mEyeDistanceLevel = 0;
// 眼角
public int mEyeAngleLevel = 0;
// 嘴型
public int mMouthShapeLevel = 0;
// 鼻翼
public int mNoseWingLevel = 0;
// 鼻子位置
public int mNosePositionLevel = 0;
// 嘴唇厚度
public int mLipsThicknessLevel = 0;
// 脸型
public int mFaceBeautyLevel = 0;
// 长腿
public int mLongLegLevel = 0;
// 瘦腰
public int mThinWaistLevel = 0;
// 瘦体
public int mThinBodyLevel = 0;
// 瘦肩
public int mThinShoulderLevel = 0;
// 动效文件路径
public String mMotionTmplPath;
// 绿幕
public String mGreenFile;
// 滤镜效果程度
public int mFilterStrength;
}

140
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/adapter/ItemAdapter.java

@ -0,0 +1,140 @@
package com.tencent.liteav.demo.beauty.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.tencent.liteav.demo.beauty.R;
import com.tencent.liteav.demo.beauty.model.ItemInfo;
import com.tencent.liteav.demo.beauty.model.TabInfo;
import com.tencent.liteav.demo.beauty.utils.BeautyUtils;
import com.tencent.liteav.demo.beauty.utils.ResourceUtils;
import java.util.ArrayList;
import java.util.List;
public class ItemAdapter extends BaseAdapter {
private Context mContext;
private TabInfo mTabInfo;
private List<ItemInfo> mItemInfoList;
private OnItemClickListener mItemClickListener;
public interface OnItemClickListener {
void onItemClick(ItemInfo itemInfo, int position);
}
// 当前选中
private int mSelectPos;
public ItemAdapter(Context context) {
mContext = context;
}
public void setData(TabInfo tabInfo) {
setData(tabInfo, 0);
}
public void setData(TabInfo tabInfo, int defaultIndex) {
mTabInfo = tabInfo;
mSelectPos = defaultIndex;
if (mItemInfoList == null) {
mItemInfoList = new ArrayList<>();
}
mItemInfoList.clear();
mItemInfoList.addAll(tabInfo.getTabItemList());
notifyDataSetChanged();
}
@Override
public int getCount() {
return mTabInfo.getTabItemList().size();
}
@Override
public ItemInfo getItem(int position) {
return mItemInfoList.get(position);
}
@Override
public long getItemId(int position) {
return mItemInfoList.get(position).getItemId();
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.beauty_view_item, parent, false);
holder = new ViewHolder(convertView);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) holder.icon.getLayoutParams();
int width;
int height;
if (mTabInfo.getTabItemIconWidth() == LinearLayout.LayoutParams.MATCH_PARENT) {
width = LinearLayout.LayoutParams.MATCH_PARENT;
} else if (mTabInfo.getTabItemIconWidth() == LinearLayout.LayoutParams.WRAP_CONTENT) {
width = LinearLayout.LayoutParams.WRAP_CONTENT;
} else {
width = BeautyUtils.dip2px(mContext, mTabInfo.getTabItemIconWidth());
}
if (mTabInfo.getTabItemIconHeight() == LinearLayout.LayoutParams.MATCH_PARENT) {
height = LinearLayout.LayoutParams.MATCH_PARENT;
} else if (mTabInfo.getTabItemIconHeight() == LinearLayout.LayoutParams.WRAP_CONTENT) {
height = LinearLayout.LayoutParams.WRAP_CONTENT;
} else {
height = BeautyUtils.dip2px(mContext, mTabInfo.getTabItemIconHeight());
}
layoutParams.width = width;
layoutParams.height = height;
holder.icon.setLayoutParams(layoutParams);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final ItemInfo itemInfo = getItem(position);
BeautyUtils.setTextViewText(holder.title, ResourceUtils.getString(itemInfo.getItemName()));
BeautyUtils.setTextViewSize(holder.title, mTabInfo.getTabItemNameSize());
if (mSelectPos == position) {
BeautyUtils.setTextViewColor(holder.title, mTabInfo.getTabItemNameColorSelect());
BeautyUtils.setImageResource(holder.icon, itemInfo.getItemIconSelect());
} else {
BeautyUtils.setTextViewColor(holder.title, mTabInfo.getTabItemNameColorNormal());
BeautyUtils.setImageResource(holder.icon, itemInfo.getItemIconNormal());
}
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mItemClickListener != null) {
mItemClickListener.onItemClick(itemInfo, position);
if (mSelectPos != position) {
mSelectPos = position;
notifyDataSetChanged();
}
}
}
});
return convertView;
}
public void setOnItemClickListener(OnItemClickListener itemClickListener) {
mItemClickListener = itemClickListener;
}
public class ViewHolder extends RecyclerView.ViewHolder {
private ImageView icon;
private TextView title;
public ViewHolder(View itemView) {
super(itemView);
icon = (ImageView) itemView.findViewById(R.id.beauty_iv_icon);
title = (TextView) itemView.findViewById(R.id.beauty_tv_title);
}
}
}

93
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/adapter/TabAdapter.java

@ -0,0 +1,93 @@
package com.tencent.liteav.demo.beauty.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.tencent.liteav.demo.beauty.model.BeautyInfo;
import com.tencent.liteav.demo.beauty.model.TabInfo;
import com.tencent.liteav.demo.beauty.utils.BeautyUtils;
public class TabAdapter extends BaseAdapter implements View.OnClickListener {
private Context mContext;
private BeautyInfo mBeautyInfo;
private TextView mTextSelected;
private OnTabChangeListener mTabClickListener;
public interface OnTabChangeListener {
void onTabChange(TabInfo tabInfo, int position);
}
public TabAdapter(Context context, BeautyInfo beautyInfo) {
mContext = context;
mBeautyInfo = beautyInfo;
}
@Override
public int getCount() {
return mBeautyInfo.getBeautyTabList().size();
}
@Override
public TabInfo getItem(int position) {
return mBeautyInfo.getBeautyTabList().get(position);
}
@Override
public long getItemId(int position) {
return mBeautyInfo.getBeautyTabList().get(position).getTabId();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView tabView;
if (convertView == null) {
tabView = new TextView(mContext);
BeautyUtils.setTextViewColor(tabView, mBeautyInfo.getBeautyTabNameColorNormal());
BeautyUtils.setTextViewSize(tabView, mBeautyInfo.getBeautyTabNameSize());
ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(mBeautyInfo.getBeautyTabNameWidth(),
mBeautyInfo.getBeautyTabNameHeight());
tabView.setLayoutParams(layoutParams);
} else {
tabView = (TextView) convertView;
}
if (position == 0) {
tabView.setPadding(BeautyUtils.dip2px(mContext, 20), 0, BeautyUtils.dip2px(mContext, 11),
BeautyUtils.dip2px(mContext, 30));
} else {
tabView.setPadding(BeautyUtils.dip2px(mContext, 12), 0, BeautyUtils.dip2px(mContext, 11),
BeautyUtils.dip2px(mContext, 30));
}
BeautyUtils.setTextViewText(tabView, getItem(position).getTabName());
tabView.setTag(position);
tabView.setOnClickListener(this);
if (position == 0) {
setCurrentPosition(0, tabView);
}
return tabView;
}
@Override
public void onClick(View view) {
int index = (int) view.getTag();
setCurrentPosition(index, view);
}
private void setCurrentPosition(int position, View view) {
if (mTextSelected != null) {
BeautyUtils.setTextViewColor(mTextSelected, mBeautyInfo.getBeautyTabNameColorNormal());
}
mTextSelected = (TextView) view;
BeautyUtils.setTextViewColor(mTextSelected, mBeautyInfo.getBeautyTabNameColorSelect());
if (mTabClickListener != null) {
mTabClickListener.onTabChange(getItem(position), position);
}
}
public void setOnTabClickListener(OnTabChangeListener tabClickListener) {
mTabClickListener = tabClickListener;
}
}

77
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/constant/BeautyConstants.java

@ -0,0 +1,77 @@
package com.tencent.liteav.demo.beauty.constant;
public class BeautyConstants {
public static final int TAB_TYPE_BEAUTY = 10001; // 美颜
public static final int TAB_TYPE_FILTER = 10002; // 滤镜
public static final int TAB_TYPE_MOTION = 10003; // 动效
public static final int TAB_TYPE_BEAUTY_FACE = 10004; // 美妆
public static final int TAB_TYPE_GESTURE = 10005; // 手势
public static final int TAB_TYPE_CUTOUT_BACKGROUND = 10006; // 抠背
public static final int TAB_TYPE_GREEN = 10007; // 绿幕
public static final int ITEM_TYPE_BEAUTY_SMOOTH = 20101; // 光滑
public static final int ITEM_TYPE_BEAUTY_NATURAL = 20102; // 自然
public static final int ITEM_TYPE_BEAUTY_PITU = 20103; // 天天P图
public static final int ITEM_TYPE_BEAUTY_WHITE = 20104; // 美白
public static final int ITEM_TYPE_BEAUTY_RUDDY = 20105; // 红润
public static final int ITEM_TYPE_BEAUTY_BIG_EYE = 20106; // 大眼
public static final int ITEM_TYPE_BEAUTY_FACES_LIM = 20107; // 瘦脸
public static final int ITEM_TYPE_BEAUTY_FACEV = 20108; // V脸
public static final int ITEM_TYPE_BEAUTY_CHIN = 20109; // 下巴
public static final int ITEM_TYPE_BEAUTY_FACE_SHORT = 20110; // 短脸
public static final int ITEM_TYPE_BEAUTY_NOSES_LIM = 20111; // 瘦鼻
public static final int ITEM_TYPE_BEAUTY_EYE_BRIGHT = 20112; // 亮眼
public static final int ITEM_TYPE_BEAUTY_TOOTH_WHITE = 20113; // 白牙
public static final int ITEM_TYPE_BEAUTY_WRINKLE_REMOVE = 20114; // 祛皱
public static final int ITEM_TYPE_BEAUTY_POUCH_REMOVE = 20115; // 祛眼袋
public static final int ITEM_TYPE_BEAUTY_SMILE_LINES = 20116; // 袪法令纹
public static final int ITEM_TYPE_BEAUTY_FOREHEAD = 20117; // 发际线
public static final int ITEM_TYPE_BEAUTY_EYE_DISTANCE = 20118; // 眼距
public static final int ITEM_TYPE_BEAUTY_EYE_ANGLE = 20119; // 眼角
public static final int ITEM_TYPE_BEAUTY_MOUTH_SHAPE = 20120; // 嘴型
public static final int ITEM_TYPE_BEAUTY_NOSEWING = 20121; // 鼻翼
public static final int ITEM_TYPE_BEAUTY_NOSE_POSITION = 20122; // 鼻子位置
public static final int ITEM_TYPE_BEAUTY_MOUSE_WIDTH = 20123; // 嘴唇厚度
public static final int ITEM_TYPE_BEAUTY_FACE_SHAPE = 20124; // 脸型
public static final int ITEM_TYPE_FILTER_FACE_SHAPE = 20201; // 无特效
public static final int ITEM_TYPE_FILTER_BAIXI = 20202; // 白皙
public static final int ITEM_TYPE_FILTER_STANDARD = 20203; // 标准
public static final int ITEM_TYPE_FILTER_ZIRAN = 20204; // 自然
public static final int ITEM_TYPE_FILTER_CHEERY = 20205; // 樱红
public static final int ITEM_TYPE_FILTER_CLOUD = 20206; // 云裳
public static final int ITEM_TYPE_FILTER_PURE = 20207; // 纯真
public static final int ITEM_TYPE_FILTER_ORCHID = 20208; // 白兰
public static final int ITEM_TYPE_FILTER_VITALITY = 20209; // 元气
public static final int ITEM_TYPE_FILTER_SUPER = 20210; // 超脱
public static final int ITEM_TYPE_FILTER_FRAGRANCE = 20211; // 香氛
public static final int ITEM_TYPE_FILTER_WHITE = 20212; // 美白
public static final int ITEM_TYPE_FILTER_ROMANTIC = 20213; // 浪漫
public static final int ITEM_TYPE_FILTER_FRESH = 20214; // 清新
public static final int ITEM_TYPE_FILTER_BEAUTIFUL = 20215; // 唯美
public static final int ITEM_TYPE_FILTER_PINK = 20216; // 粉嫩
public static final int ITEM_TYPE_FILTER_REMINISCENCE = 20217; // 怀旧
public static final int ITEM_TYPE_FILTER_BLUES = 20218; // 蓝调
public static final int ITEM_TYPE_FILTER_COOL = 20219; // 清凉
public static final int ITEM_TYPE_FILTER_JAPANESE = 20220; // 日系
public static final int ITEM_TYPE_MOTION_NONE = 20301; // 动效无特效
public static final int ITEM_TYPE_MOTION_MATERIAL = 20302; // 动效素材
public static final int ITEM_TYPE_BEAUTY_FACE_NONE = 20401; // 美妆无特效
public static final int ITEM_TYPE_BEAUTY_FACE_MATERIAL = 20402; // 美妆素材
public static final int ITEM_TYPE_GESTURE_NONE = 20501; // 手势无特效
public static final int ITEM_TYPE_GESTURE_MATERIAL = 20502; // 手势素材
public static final int ITEM_TYPE_CUTOUT_BACKGROUND_NONE = 20601; // 抠背无特效
public static final int ITEM_TYPE_CUTOUT_BACKGROUND_MATERIAL = 20602; // 抠背AI
public static final int ITEM_TYPE_GREEN_NONE = 20701; // 绿幕无特效
public static final int ITEM_TYPE_GREEN_GOOD_LUCK = 20702; // 绿幕good luck
public static final String BEAUTY_BG_GRAY = "#CC000000";// 灰色背景
}

9
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/DownloadListener.java

@ -0,0 +1,9 @@
package com.tencent.liteav.demo.beauty.download;
public interface DownloadListener {
void onDownloadFail(String errorMsg);
void onDownloadProgress(final int progress);
void onDownloadSuccess(String filePath);
}

142
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/HttpFileHelper.java

@ -0,0 +1,142 @@
package com.tencent.liteav.demo.beauty.download;
import android.content.Context;
import android.text.TextUtils;
import com.tencent.liteav.demo.beauty.utils.BeautyUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpFileHelper implements Runnable {
private static final int BUFFERED_READER_SIZE = 8192;
private static final int TIMEOUT = 30000;
private Context mContext;
private HttpFileListener mListener;
private String mURL;
private String mFolder;
private String mFilename;
private long mContentLength;
private long mDownloadingSize;
private boolean mNeedProgress;
public HttpFileHelper(Context context, String url, String folder, String filename, HttpFileListener listener,
boolean needProgress) {
mContext = context;
mURL = url;
mFolder = folder;
mFilename = filename;
mListener = listener;
mNeedProgress = needProgress;
}
@Override
public void run() {
if (!BeautyUtils.isNetworkAvailable(mContext) || TextUtils.isEmpty(mURL) || TextUtils.isEmpty(mFolder)
|| TextUtils.isEmpty(mFilename) || !mURL.startsWith("http")) {
fail(null);
return;
}
File dstFolder = new File(mFolder);
if (!dstFolder.exists()) {
dstFolder.mkdirs();
} else {
if (dstFolder.isFile()) {
if (mListener != null) {
mListener.onSaveFailed(dstFolder, null);
return;
}
}
}
File dstFile = new File(mFolder + File.separator + mFilename);
HttpURLConnection client = null;
InputStream responseIs = null;
FileOutputStream fos = null;
int statusCode = -1;
boolean success = false;
Exception failException = null;
try {
if (dstFile.exists()) {
dstFile.delete();
}
dstFile.createNewFile();
client = (HttpURLConnection) new URL(mURL).openConnection();
// 设置网络超时参数
client.setConnectTimeout(TIMEOUT);
client.setReadTimeout(TIMEOUT);
client.setDoInput(true);
client.setRequestMethod("GET");
statusCode = client.getResponseCode();
success = client.getResponseCode() == HttpURLConnection.HTTP_OK;
if (success) {
if (mNeedProgress) {
mContentLength = client.getContentLength();
}
responseIs = client.getInputStream();
fos = new FileOutputStream(dstFile);
mDownloadingSize = 0;
mListener.onProgressUpdate(0);
int length = -1;
byte[] buffer = new byte[BUFFERED_READER_SIZE];
while ((length = responseIs.read(buffer)) != -1) {
fos.write(buffer, 0, length);
if (mNeedProgress) {
int pre = (int) (mDownloadingSize * 100 / mContentLength);
mDownloadingSize += length;
int now = (int) (mDownloadingSize * 100 / mContentLength);
if (pre != now && mListener != null) {
mListener.onProgressUpdate(now);
}
}
}
fos.flush();
if (mListener != null) {
mListener.onProgressUpdate(100);
mListener.onSaveSuccess(dstFile);
}
} else {
failException = new HttpStatusException("http status got exception. code = " + statusCode);
}
} catch (Exception e) {
failException = e;
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
}
if (responseIs != null) {
responseIs.close();
}
if (client != null) {
client.disconnect();
}
mListener.onProcessEnd();
} catch (IOException e) {
e.printStackTrace();
}
}
if (!success || null != failException) {
mListener.onSaveFailed(dstFile, failException);
}
}
private void fail(Exception e) {
if (mListener != null) {
mListener.onSaveFailed(null, e);
}
mListener = null;
}
}

13
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/HttpFileListener.java

@ -0,0 +1,13 @@
package com.tencent.liteav.demo.beauty.download;
import java.io.File;
public interface HttpFileListener {
void onProgressUpdate(int progress);
void onSaveSuccess(File file);
void onSaveFailed(File file, Exception e);
void onProcessEnd();
}

10
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/HttpStatusException.java

@ -0,0 +1,10 @@
package com.tencent.liteav.demo.beauty.download;
/**
* Http状态异常[自定义抛出的异常]
*/
public class HttpStatusException extends Exception {
public HttpStatusException(String detailMessage) {
super(detailMessage);
}
}

135
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/download/MaterialDownloader.java

@ -0,0 +1,135 @@
package com.tencent.liteav.demo.beauty.download;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.tencent.liteav.demo.beauty.R;
import com.tencent.liteav.demo.beauty.utils.BeautyUtils;
import java.io.File;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 美颜模块素材下载
*/
public class MaterialDownloader {
public static final String DOWNLOAD_FILE_POSTFIX = ".zip";
public static final String ONLINE_MATERIAL_FOLDER = "cameraVideoAnimal";
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
private static final int CORE_POOL_SIZE = CPU_COUNT + 1;
private Context mContext;
private boolean mProcessing;
private String mURL;
private String mMaterialId;
private DownloadListener mListener;
private DownloadThreadPool mDownloadThreadPool;
public MaterialDownloader(Context context, String materialId, String url) {
mContext = context;
mMaterialId = materialId;
mURL = url;
mProcessing = false;
}
/**
* Start download material.
*
* @param listener
*/
public void start(@Nullable DownloadListener listener) {
if (listener == null || TextUtils.isEmpty(mURL) || mProcessing) {
return;
}
mProcessing = true;
mListener = listener;
mListener.onDownloadProgress(0);
HttpFileListener fileListener = new HttpFileListener() {
@Override
public void onSaveSuccess(@NonNull File file) {
//删除该素材目录下的旧文件
File path = new File(file.toString().substring(0, file.toString().indexOf(DOWNLOAD_FILE_POSTFIX)));
if (path.exists() && path.isDirectory()) {
File[] oldFiles = path.listFiles();
if (oldFiles != null) {
for (File f : oldFiles) {
f.delete();
}
}
}
String dataDir = BeautyUtils.unZip(file.getPath(), file.getParentFile().getPath());
if (TextUtils.isEmpty(dataDir)) {
mListener.onDownloadFail(
mContext.getString(R.string.beauty_video_material_download_progress_material_unzip_failed));
stop();
return;
}
file.delete();
mListener.onDownloadSuccess(dataDir);
stop();
}
@Override
public void onSaveFailed(File file, Exception e) {
mListener.onDownloadFail(
mContext.getString(R.string.beauty_video_material_download_progress_download_failed));
stop();
}
@Override
public void onProgressUpdate(int progress) {
mListener.onDownloadProgress(progress);
}
@Override
public void onProcessEnd() {
mProcessing = false;
}
};
File onlineMaterialDir = BeautyUtils.getExternalFilesDir(mContext, ONLINE_MATERIAL_FOLDER);
if (onlineMaterialDir == null || onlineMaterialDir.getName().startsWith("null")) {
mListener.onDownloadFail(
mContext.getString(R.string.beauty_video_material_download_progress_no_enough_storage_space));
stop();
return;
}
if (!onlineMaterialDir.exists()) {
onlineMaterialDir.mkdirs();
}
ThreadPoolExecutor threadPool = getThreadExecutor();
threadPool.execute(
new HttpFileHelper(mContext, mURL, onlineMaterialDir.getPath(), mMaterialId + DOWNLOAD_FILE_POSTFIX,
fileListener, true));
}
public void stop() {
mListener = null;
}
public synchronized ThreadPoolExecutor getThreadExecutor() {
if (mDownloadThreadPool == null || mDownloadThreadPool.isShutdown()) {
mDownloadThreadPool = new DownloadThreadPool(CORE_POOL_SIZE);
}
return mDownloadThreadPool;
}
public static class DownloadThreadPool extends ThreadPoolExecutor {
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public DownloadThreadPool(int poolSize) {
super(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<Runnable>(),
Executors.defaultThreadFactory(), new DiscardOldestPolicy());
}
}
}

67
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/model/BeautyInfo.java

@ -0,0 +1,67 @@
package com.tencent.liteav.demo.beauty.model;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* 美颜面板相关属性
* 成员变量名和 assets/default_beauty_data.json key 相对应便于 json 解析
*/
public class BeautyInfo {
@SerializedName("beauty_tab_name_size")
private int mBeautyTabNameSize; // int, tab文字大小
@SerializedName("beauty_tab_name_width")
private int mBeautyTabNameWidth; // int, tab 宽度
@SerializedName("beauty_tab_name_height")
private int mBeautyTabNameHeight; // int, tab 高度
@SerializedName("beauty_bg")
private String mBeautyBg; // color/drawable, beauty布局的背景色值
@SerializedName("beauty_tab_name_color_normal")
private String mBeautyTabNameColorNormal; // color, tab文字常规颜色
@SerializedName("beauty_tab_name_color_select")
private String mBeautyTabNameColorSelect; // color, tab文字选中颜色
@SerializedName("beauty_tab_list")
private List<TabInfo> mBeautyTabList;
public String getBeautyBg() {
return mBeautyBg;
}
public void setBeautyBg(String beautyBg) {
this.mBeautyBg = beautyBg;
}
public int getBeautyTabNameWidth() {
return mBeautyTabNameWidth;
}
public int getBeautyTabNameHeight() {
return mBeautyTabNameHeight;
}
public String getBeautyTabNameColorNormal() {
return mBeautyTabNameColorNormal;
}
public String getBeautyTabNameColorSelect() {
return mBeautyTabNameColorSelect;
}
public int getBeautyTabNameSize() {
return mBeautyTabNameSize;
}
public List<TabInfo> getBeautyTabList() {
return mBeautyTabList;
}
@Override
public String toString() {
return "BeautyInfo{" + ", mBeautyBg='" + mBeautyBg + '\'' + ", mBeautyTabNameWidth=" + mBeautyTabNameWidth
+ ", mBeautyTabNameHeight=" + mBeautyTabNameHeight + ", mBeautyTabNameColorNormal='"
+ mBeautyTabNameColorNormal + '\'' + ", mBeautyTabNameColorSelect='" + mBeautyTabNameColorSelect + '\''
+ ", mBeautyTabNameSize=" + mBeautyTabNameSize + ", mBeautyTabList=" + mBeautyTabList + '}';
}
}

77
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/model/ItemInfo.java

@ -0,0 +1,77 @@
package com.tencent.liteav.demo.beauty.model;
import com.google.gson.annotations.SerializedName;
/**
* 美颜面板 item 相关属性
* 成员变量名和 assets/default_beauty_data.json key 相对应便于 json 解析
*/
public class ItemInfo {
@SerializedName("item_id")
private long mItemId; // long, item iditem 唯一标识
@SerializedName("item_type")
private int mItemType; // int, item 类型item 的功能
@SerializedName("item_level")
private int mItemLevel; // int, 特效级别-1代表无特效级别即不显示SeekBar
@SerializedName("item_name")
private String mItemName; // string, item 名称
@SerializedName("item_material_url")
private String mItemMaterialUrl; // string, 素材 url
@SerializedName("item_material_path")
private String mItemMaterialPath; // string, 素材本地路径
@SerializedName("item_icon_normal")
private String mItemIconNormal; // drawable, item 常规 icon
@SerializedName("item_icon_select")
private String mItemIconSelect; // drawable, item 选中 icon
public long getItemId() {
return mItemId;
}
public int getItemType() {
return mItemType;
}
public String getItemName() {
return mItemName;
}
public String getItemIconNormal() {
return mItemIconNormal;
}
public String getItemIconSelect() {
return mItemIconSelect;
}
public void setItemLevel(int itemLevel) {
this.mItemLevel = itemLevel;
}
public int getItemLevel() {
return mItemLevel;
}
public String getItemMaterialUrl() {
return mItemMaterialUrl;
}
public String getItemMaterialPath() {
return mItemMaterialPath;
}
public void setItemMaterialPath(String itemMaterialPath) {
this.mItemMaterialPath = itemMaterialPath;
}
@Override
public String toString() {
return "ItemInfo{" + "mItemId=" + mItemId + ", mItemType=" + mItemType + ", mItemName='" + mItemName + '\''
+ ", mItemMaterialUrl='" + mItemMaterialUrl + '\'' + ", mItemLevel=" + mItemLevel
+ ", mItemIconNormal='" + mItemIconNormal + '\'' + ", mItemIconSelect='" + mItemIconSelect + '\''
+ ", mItemMaterialPath='" + mItemMaterialPath + '\'' + '}';
}
}

123
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/model/TabInfo.java

@ -0,0 +1,123 @@
package com.tencent.liteav.demo.beauty.model;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* 美颜面板 tab 相关属性
* 成员变量名和 assets/default_beauty_data.json key 相对应便于 json 解析
*/
public class TabInfo {
@SerializedName("tab_id")
private long mTabId; // long, tab idtab 唯一标识
@SerializedName("tab_type")
private int mTabType; // int, tab类型
@SerializedName("tab_item_name_size")
private int mTabItemNameSize; // int, item文字大小
@SerializedName("tab_item_icon_width")
private int mTabItemIconWidth; // int, item icon 宽度
@SerializedName("tab_item_icon_height")
private int mTabItemIconHeight; // int, item icon 高度
@SerializedName("tab_item_level_hint_size")
private int mTabItemLevelHintSize; // int, 进度条提示文字大小
@SerializedName("tab_item_level_value_size")
private int mTabItemLevelValueSize; // int, 进度条值文字大小
@SerializedName("tab_name")
private String mTabName; // string, tab 名称
@SerializedName("tab_item_name_color_normal")
private String mTabItemNameColorNormal; // string, item 文件常规颜色
@SerializedName("tab_item_name_color_select")
private String mTabItemNameColorSelect; // string, item 文件选中颜色
@SerializedName("tab_item_level_hint_color")
private String mTabItemLevelHintColor; // string, 进度条提示文字颜色
@SerializedName("tab_item_level_value_color")
private String mTabItemLevelValueColor; // string, 进度条值文字颜色
@SerializedName("tab_item_level_progress_drawable")
private String mTabItemLevelProgressDrawable;// string, 进度条背景颜色
@SerializedName("tab_item_level_progress_thumb")
private String mTabItemLevelProgressThumb; // string, 进度条 bar 颜色
@SerializedName("tab_item_list_default_selected_index")
private int mTabItemListDefaultSelectedIndex; // int, 默认选中的item
@SerializedName("tab_item_list")
private List<ItemInfo> mTabItemList;
public long getTabId() {
return mTabId;
}
public int getTabType() {
return mTabType;
}
public String getTabName() {
return mTabName;
}
public int getTabItemNameSize() {
return mTabItemNameSize;
}
public String getTabItemNameColorNormal() {
return mTabItemNameColorNormal;
}
public String getTabItemNameColorSelect() {
return mTabItemNameColorSelect;
}
public int getTabItemIconWidth() {
return mTabItemIconWidth;
}
public int getTabItemIconHeight() {
return mTabItemIconHeight;
}
public String getTabItemLevelHintColor() {
return mTabItemLevelHintColor;
}
public int getTabItemLevelHintSize() {
return mTabItemLevelHintSize;
}
public String getTabItemLevelValueColor() {
return mTabItemLevelValueColor;
}
public int getTabItemLevelValueSize() {
return mTabItemLevelValueSize;
}
public String getTabItemLevelProgressDrawable() {
return mTabItemLevelProgressDrawable;
}
public String getTabItemLevelProgressThumb() {
return mTabItemLevelProgressThumb;
}
public int getTabItemListDefaultSelectedIndex() {
return mTabItemListDefaultSelectedIndex;
}
public List<ItemInfo> getTabItemList() {
return mTabItemList;
}
@Override
public String toString() {
return "TabInfo{" + "mTabId=" + mTabId + ", mTabName='" + mTabName + '\'' + ", mTabItemNameSize="
+ mTabItemNameSize + ", mTabItemNameColorNormal='" + mTabItemNameColorNormal + '\''
+ ", mTabItemNameColorSelect='" + mTabItemNameColorSelect + '\'' + ", mTabItemIconWidth="
+ mTabItemIconWidth + ", mTabItemIconHeight=" + mTabItemIconHeight + ", mTabItemLevelHintColor='"
+ mTabItemLevelHintColor + '\'' + ", mTabItemLevelHintSize=" + mTabItemLevelHintSize
+ ", mTabItemLevelValueColor='" + mTabItemLevelValueColor + '\'' + ", mTabItemLevelValueSize="
+ mTabItemLevelValueSize + ", mTabItemLevelProgressDrawable='" + mTabItemLevelProgressDrawable + '\''
+ ", mTabItemLevelProgressThumb='" + mTabItemLevelProgressThumb + '\''
+ ", mTabItemListDefaultSelectedIndex='" + mTabItemListDefaultSelectedIndex + '\'' + ", mTabItemList="
+ mTabItemList + '}';
}
}

294
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/utils/BeautyUtils.java

@ -0,0 +1,294 @@
package com.tencent.liteav.demo.beauty.utils;
import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.gson.Gson;
import com.tencent.liteav.demo.beauty.model.BeautyInfo;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class BeautyUtils {
private static final String TAG = "BeautyUtils";
private static final String DEFAULT_BEAUTY_DATA = "default_beauty_data.json";
@SuppressLint("StaticFieldLeak")
private static Application sApplication;
public static BeautyInfo getDefaultBeautyInfo() {
return createBeautyInfo(readAssetsFile(DEFAULT_BEAUTY_DATA));
}
public static BeautyInfo createBeautyInfo(String json) {
Gson gson = new Gson();
return gson.fromJson(json, BeautyInfo.class);
}
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
public static void setTextViewText(TextView textView, String resName) {
textView.setText(ResourceUtils.getString(resName));
}
public static void setTextViewColor(TextView textView, String resName) {
textView.setTextColor(ResourceUtils.getColor(resName));
}
public static void setTextViewSize(TextView textView, int size) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size);
}
public static void setImageResource(ImageView imageView, String res) {
imageView.setImageResource(ResourceUtils.getDrawableId(res));
}
/**
* Read file from assets.
*
* @param fileName
* @return
*/
public static String readAssetsFile(String fileName) {
StringBuilder sb = new StringBuilder();
InputStream is = null;
BufferedReader br = null;
try {
is = getApplication().getAssets().open(fileName);
br = new BufferedReader(new InputStreamReader(is, "utf-8"));
String readLine;
while ((readLine = br.readLine()) != null) {
sb.append(readLine);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is != null) {
is.close();
}
if (br != null) {
br.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
public static Application getApplication() {
if (sApplication != null) {
return sApplication;
}
Application app = getApplicationByReflect();
init(app);
return app;
}
public static String getPackageName() {
return getApplication().getPackageName();
}
private static void init(final Application app) {
if (sApplication == null) {
if (app == null) {
sApplication = getApplicationByReflect();
} else {
sApplication = app;
}
} else {
if (app != null && app.getClass() != sApplication.getClass()) {
sApplication = app;
}
}
}
private static Application getApplicationByReflect() {
try {
@SuppressLint("PrivateApi") Class<?> activityThread = Class.forName("android.app.ActivityThread");
Object thread = activityThread.getMethod("currentActivityThread").invoke(null);
Object app = activityThread.getMethod("getApplication").invoke(thread);
if (app == null) {
throw new NullPointerException("You should init first.");
}
return (Application) app;
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
throw new NullPointerException("You should init first.");
}
/**
* Unzip file to target directory.
*
* @param zipFile
* @param targetDir
* @return
*/
public static synchronized String unZip(@NonNull String zipFile, @NonNull String targetDir) {
if (TextUtils.isEmpty(zipFile)) {
return null;
} else {
File file = new File(zipFile);
if (!file.exists()) {
return null;
} else {
File targetFolder = new File(targetDir);
if (!targetFolder.exists()) {
targetFolder.mkdirs();
}
String dataDir = null;
short buffer = 4096;
FileInputStream fis = null;
ZipInputStream zis = null;
FileOutputStream fos = null;
BufferedOutputStream dest = null;
try {
fis = new FileInputStream(file);
zis = new ZipInputStream(new BufferedInputStream(fis));
while (true) {
String strEntry;
ZipEntry entry;
do {
if ((entry = zis.getNextEntry()) == null) {
return dataDir;
}
strEntry = entry.getName();
} while (strEntry.contains("../"));
if (entry.isDirectory()) {
String count1 = targetDir + File.separator + strEntry;
File data1 = new File(count1);
if (!data1.exists()) {
data1.mkdirs();
}
if (TextUtils.isEmpty(dataDir)) {
dataDir = data1.getPath();
}
} else {
byte[] data = new byte[buffer];
String targetFileDir = targetDir + File.separator + strEntry;
File targetFile = new File(targetFileDir);
try {
fos = new FileOutputStream(targetFile);
dest = new BufferedOutputStream(fos, buffer);
int count;
while ((count = zis.read(data)) != -1) {
dest.write(data, 0, count);
}
dest.flush();
} catch (IOException var41) {
var41.printStackTrace();
} finally {
try {
if (dest != null) {
dest.close();
}
if (fos != null) {
fos.close();
}
} catch (IOException var40) {
var40.printStackTrace();
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (zis != null) {
zis.close();
}
if (fis != null) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return dataDir;
}
}
}
public static boolean isEmpty(@Nullable Collection object) {
return null == object || object.isEmpty();
}
public static boolean isNetworkAvailable(@NonNull Context context) {
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo networkInfo = connectivity.getActiveNetworkInfo();
return networkInfo != null && networkInfo.isConnectedOrConnecting();
}
}
/**
* Get external file path.
*
* @param context
* @param folder
* @return
*/
@Nullable
public static File getExternalFilesDir(@NonNull Context context, String folder) {
if (context == null) {
Log.e(TAG, "getExternalFilesDir context is null");
return null;
}
File sdcardDir = context.getApplicationContext().getExternalFilesDir(null);
if (sdcardDir == null) {
Log.e(TAG, "sdcardDir is null");
return null;
}
String path = sdcardDir.getPath();
File file = new File(path + File.separator + folder);
try {
if (file.exists() && file.isFile()) {
file.delete();
}
if (!file.exists()) {
file.mkdirs();
}
} catch (Exception var5) {
var5.printStackTrace();
}
return file;
}
}

70
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/utils/ResourceUtils.java

@ -0,0 +1,70 @@
package com.tencent.liteav.demo.beauty.utils;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import androidx.annotation.StringRes;
public class ResourceUtils {
private static final String TYPE_QUOTE_PREFIX = "@";
private static final String TYPE_COLOR_PREFIX = "#";
private static final String TYPE_STRING = "string";
private static final String TYPE_COLOR = "color";
private static final String TYPE_DRAWABLE = "drawable";
public static int getDrawableId(String resName) {
if (resName.startsWith(TYPE_QUOTE_PREFIX)) {
return getResources().getIdentifier(resName, TYPE_DRAWABLE, BeautyUtils.getPackageName());
}
throw new IllegalArgumentException("\"" + resName + "\" is illegal, must start with \"@\".");
}
public static int getStringId(String resName) {
return getResources().getIdentifier(resName, TYPE_STRING, BeautyUtils.getPackageName());
}
public static String getString(String resName) {
if (resName.startsWith(TYPE_QUOTE_PREFIX)) {
return getResources().getString(getStringId(resName.substring(1)));
}
return resName;
}
public static String getString(@StringRes int resId) {
return getResources().getString(resId);
}
public static int getColor(String resName) {
if (resName.startsWith(TYPE_COLOR_PREFIX)) {
return Color.parseColor(resName);
}
if (resName.startsWith(TYPE_QUOTE_PREFIX)) {
return getResources().getColor(getColorId(resName));
}
throw new IllegalArgumentException("\"" + resName + "\" is unknown color.");
}
public static int getColorId(String resName) {
return getResources().getIdentifier(resName, TYPE_COLOR, BeautyUtils.getPackageName());
}
public static Resources getResources() {
return BeautyUtils.getApplication().getResources();
}
public static Drawable getLinearDrawable(int color) {
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(color);
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setCornerRadii(new float[]{
BeautyUtils.dip2px(BeautyUtils.getApplication(), 10),
BeautyUtils.dip2px(BeautyUtils.getApplication(), 10),
BeautyUtils.dip2px(BeautyUtils.getApplication(), 10),
BeautyUtils.dip2px(BeautyUtils.getApplication(), 10), 0, 0, 0, 0});
return drawable;
}
}

61
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/utils/SPUtils.java

@ -0,0 +1,61 @@
package com.tencent.liteav.demo.beauty.utils;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
public class SPUtils {
private static final String SP_NAME_DEFAULT = "beauty_default";
private static SPUtils sInstance;
private SharedPreferences mSharedPreferences;
public static SPUtils get() {
return get(SP_NAME_DEFAULT, Context.MODE_PRIVATE);
}
public static SPUtils get(final int mode) {
return get(SP_NAME_DEFAULT, mode);
}
public static SPUtils get(String spName) {
return get(spName, Context.MODE_PRIVATE);
}
public static SPUtils get(String spName, final int mode) {
if (sInstance == null) {
synchronized (SPUtils.class) {
if (sInstance == null) {
sInstance = new SPUtils(spName, mode);
}
}
}
return sInstance;
}
private SPUtils(final String spName, final int mode) {
mSharedPreferences = BeautyUtils.getApplication().getSharedPreferences(spName, mode);
}
public void put(@NonNull final String key, final String value) {
put(key, value, false);
}
public void put(@NonNull final String key, final String value, final boolean isCommit) {
if (isCommit) {
mSharedPreferences.edit().putString(key, value).commit();
} else {
mSharedPreferences.edit().putString(key, value).apply();
}
}
public String getString(@NonNull final String key) {
return getString(key, "");
}
public String getString(@NonNull final String key, final String defaultValue) {
return mSharedPreferences.getString(key, defaultValue);
}
}

314
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/view/BeautyPanel.java

@ -0,0 +1,314 @@
package com.tencent.liteav.demo.beauty.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.tencent.liteav.beauty.TXBeautyManager;
import com.tencent.liteav.demo.beauty.Beauty;
import com.tencent.liteav.demo.beauty.BeautyImpl;
import com.tencent.liteav.demo.beauty.R;
import com.tencent.liteav.demo.beauty.adapter.ItemAdapter;
import com.tencent.liteav.demo.beauty.adapter.TabAdapter;
import com.tencent.liteav.demo.beauty.model.BeautyInfo;
import com.tencent.liteav.demo.beauty.model.ItemInfo;
import com.tencent.liteav.demo.beauty.model.TabInfo;
import com.tencent.liteav.demo.beauty.utils.BeautyUtils;
import com.tencent.liteav.demo.beauty.utils.ResourceUtils;
/**
* 美颜面板控件 View
* -引用 xml 中引用该布局设置其大小
* -外部可通过 getDefaultBeautyInfo 获取默认美颜面板的属性
* -外部可通过 setBeautyInfo 设置美颜面板内部属性
* -外部可通过 setOnBeautyListener 监听美颜面板的行为动作
*/
public class BeautyPanel extends FrameLayout implements SeekBar.OnSeekBarChangeListener, View.OnClickListener {
private static final String TAG = "BeautyPanel";
private Context mContext;
private TCHorizontalScrollView mScrollTabView;
private TCHorizontalScrollView mScrollItemView;
private RelativeLayout mRelativeSeekBarLayout;
private SeekBar mSeekBarLevel;
private TextView mTextLevelHint;
private TextView mTextLevelValue;
private TextView mTextTitle;
private TextView mTextClose;
private BeautyInfo mBeautyInfo;
private OnBeautyListener mOnBeautyListener;
private Beauty mBeauty;
private TabInfo mCurrentTabInfo;
private ItemInfo[] mCurrentItemInfo;
private int mCurrentTabPosition = 0;
private int[] mCurrentItemPosition;
public abstract static class OnBeautyListener {
public void onTabChange(TabInfo tabInfo, int position) {
}
public boolean onClose() {
return true;
}
public boolean onClick(TabInfo tabInfo, int tabPosition, ItemInfo itemInfo, int itemPosition) {
return false;
}
public boolean onLevelChanged(TabInfo tabInfo, int tabPosition, ItemInfo itemInfo, int itemPosition,
int beautyLevel) {
return false;
}
}
public BeautyPanel(@NonNull Context context) {
super(context);
initialize(context);
}
public BeautyPanel(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initialize(context);
}
public BeautyPanel(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context);
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mCurrentItemInfo[mCurrentTabPosition].setItemLevel(progress);
mTextLevelValue.setText(String.valueOf(progress));
if (mOnBeautyListener == null || !mOnBeautyListener
.onLevelChanged(mCurrentTabInfo, mCurrentTabPosition, mCurrentItemInfo[mCurrentTabPosition],
mCurrentItemPosition[mCurrentTabPosition], progress)) {
mBeauty.setBeautySpecialEffects(mCurrentTabInfo, mCurrentTabPosition, mCurrentItemInfo[mCurrentTabPosition],
mCurrentItemPosition[mCurrentTabPosition]);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
@Override
public void onClick(View v) {
int id = v.getId();
if (id == mTextClose.getId()) {
if (mOnBeautyListener == null || !mOnBeautyListener.onClose()) {
setVisibility(View.GONE);
}
}
}
@Override
public void setVisibility(int visibility) {
super.setVisibility(visibility);
if (visibility == View.VISIBLE) {
bringToFront();
}
}
/**
* 设置 BeautyPanel 绘制所要使用的数据
*
* @param beautyInfo
*/
public void setBeautyInfo(@NonNull BeautyInfo beautyInfo) {
mBeautyInfo = beautyInfo;
//根据配置文件选择默认选中项
setCurrentBeautyInfo(beautyInfo);
mBeauty.fillingMaterialPath(beautyInfo);
setBackground(ResourceUtils.getLinearDrawable(ResourceUtils.getColor(beautyInfo.getBeautyBg())));
refresh();
}
/**
* 设置 特效点击回调
*
* @param onBeautyListener
*/
public void setOnBeautyListener(@NonNull OnBeautyListener onBeautyListener) {
mOnBeautyListener = onBeautyListener;
}
public void setOnFilterChangeListener(Beauty.OnFilterChangeListener listener) {
mBeauty.setOnFilterChangeListener(listener);
}
public int getFilterProgress(int index) {
return mBeauty.getFilterProgress(mBeautyInfo, index);
}
public BeautyInfo getDefaultBeautyInfo() {
return mBeauty.getDefaultBeauty();
}
public void setBeautyManager(TXBeautyManager beautyManager) {
mBeauty.setBeautyManager(beautyManager);
clear();
if (mBeautyInfo != null) {
//根据配置文件选择默认选中项
setCurrentBeautyInfo(mBeautyInfo);
}
}
public void setMotionTmplEnable(boolean enable) {
mBeauty.setMotionTmplEnable(enable);
}
public ItemInfo getItemInfo(int tabIndex, int itemIndex) {
return mBeautyInfo.getBeautyTabList().get(tabIndex).getTabItemList().get(itemIndex);
}
public void setCurrentFilterIndex(int index) {
mCurrentItemPosition[1] = index;
mBeauty.setCurrentFilterIndex(mBeautyInfo, index);
}
public void setCurrentBeautyIndex(int index) {
mCurrentItemPosition[0] = index;
mBeauty.setCurrentBeautyIndex(mBeautyInfo, index);
}
public ItemInfo getFilterItemInfo(int index) {
return mBeauty.getFilterItemInfo(mBeautyInfo, index);
}
public int getFilterSize() {
return mBeauty.getFilterSize(mBeautyInfo);
}
public Bitmap getFilterResource(int index) {
return mBeauty.getFilterResource(mBeautyInfo, index);
}
public void clear() {
mBeauty.clear();
}
private void initialize(Context context) {
mContext = context;
LayoutInflater.from(context).inflate(R.layout.beauty_view_layout, this);
mBeauty = new BeautyImpl(mContext);
initView();
initData();
}
private void initView() {
mRelativeSeekBarLayout = (RelativeLayout) findViewById(R.id.beauty_rl_seek_bar);
mSeekBarLevel = (SeekBar) findViewById(R.id.beauty_seek_bar_third);
mTextLevelHint = (TextView) findViewById(R.id.beauty_tv_seek_bar_hint);
mTextLevelValue = (TextView) findViewById(R.id.beauty_tv_seek_bar_value);
mTextTitle = (TextView) findViewById(R.id.beauty_tv_title);
mTextClose = (TextView) findViewById(R.id.beauty_tv_close);
mTextClose.setOnClickListener(this);
mSeekBarLevel.setOnSeekBarChangeListener(this);
mScrollTabView = (TCHorizontalScrollView) findViewById(R.id.beauty_horizontal_picker_view_first);
mScrollItemView = (TCHorizontalScrollView) findViewById(R.id.beauty_horizontal_picker_second);
}
private void initData() {
setBeautyInfo(getDefaultBeautyInfo());
}
private void setCurrentBeautyInfo(@NonNull BeautyInfo beautyInfo) {
int tabSize = beautyInfo.getBeautyTabList().size();
mCurrentItemPosition = new int[tabSize];
mCurrentItemInfo = new ItemInfo[tabSize];
for (int i = 0; i < tabSize; i++) {
TabInfo tabInfo = beautyInfo.getBeautyTabList().get(i);
mCurrentItemPosition[i] = tabInfo.getTabItemListDefaultSelectedIndex();
mCurrentItemInfo[i] = tabInfo.getTabItemList().get(tabInfo.getTabItemListDefaultSelectedIndex());
mBeauty.setBeautySpecialEffects(tabInfo, i, mCurrentItemInfo[i], mCurrentItemPosition[i]);
}
}
private void refresh() {
createTabList();
}
private void createTabList() {
TabAdapter tabAdapter = new TabAdapter(mContext, mBeautyInfo);
mScrollTabView.setAdapter(tabAdapter);
tabAdapter.setOnTabClickListener(new TabAdapter.OnTabChangeListener() {
@Override
public void onTabChange(TabInfo tabInfo, int position) {
mCurrentTabInfo = tabInfo;
mCurrentTabPosition = position;
createItemList(tabInfo, position);
if (mOnBeautyListener != null) {
mOnBeautyListener.onTabChange(tabInfo, position);
}
}
});
TabInfo tabInfo = mBeautyInfo.getBeautyTabList().get(0);
mCurrentTabInfo = tabInfo;
mCurrentTabPosition = 0;
createItemList(tabInfo, 0);
}
private void createItemList(@NonNull final TabInfo tabInfo, @NonNull final int tabPosition) {
setBeautyTitle(tabInfo.getTabName());
ItemAdapter itemAdapter = new ItemAdapter(mContext);
itemAdapter.setData(tabInfo, mCurrentItemPosition[tabPosition]);
mScrollItemView.setAdapter(itemAdapter);
mScrollItemView.setClicked(mCurrentItemPosition[tabPosition]);
itemAdapter.setOnItemClickListener(new ItemAdapter.OnItemClickListener() {
@Override
public void onItemClick(ItemInfo itemInfo, int position) {
mCurrentItemPosition[tabPosition] = position;
mCurrentItemInfo[tabPosition] = itemInfo;
createSeekBar(tabInfo, itemInfo);
if (mOnBeautyListener == null || !mOnBeautyListener.onClick(tabInfo, tabPosition, itemInfo, position)) {
mBeauty.setBeautySpecialEffects(tabInfo, tabPosition, itemInfo, position);
}
}
});
ItemInfo itemInfo = tabInfo.getTabItemList().get(mCurrentItemPosition[tabPosition]);
mCurrentItemInfo[tabPosition] = itemInfo;
createSeekBar(tabInfo, itemInfo);
}
private void createSeekBar(@NonNull TabInfo tabInfo, @NonNull ItemInfo itemInfo) {
int visibility;
if (itemInfo.getItemLevel() == -1) {
visibility = View.GONE;
} else {
visibility = View.VISIBLE;
mTextLevelValue.setText(String.valueOf(itemInfo.getItemLevel()));
mSeekBarLevel.setProgress(itemInfo.getItemLevel());
BeautyUtils.setTextViewSize(mTextLevelHint, tabInfo.getTabItemLevelHintSize());
BeautyUtils.setTextViewColor(mTextLevelHint, tabInfo.getTabItemLevelHintColor());
BeautyUtils.setTextViewSize(mTextLevelValue, tabInfo.getTabItemLevelValueSize());
BeautyUtils.setTextViewColor(mTextLevelValue, tabInfo.getTabItemLevelValueColor());
}
mRelativeSeekBarLayout.setVisibility(visibility);
}
private void setBeautyTitle(String title) {
mTextTitle.setText(ResourceUtils.getString(title) + ResourceUtils.getString(R.string.beauty_setup));
}
}

70
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/view/ProgressDialog.java

@ -0,0 +1,70 @@
package com.tencent.liteav.demo.beauty.view;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.tencent.liteav.demo.beauty.R;
public class ProgressDialog {
private Dialog mDialog;
private TextView mTextMsg;
public void createLoadingDialog(Context context) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(R.layout.beauty_layout_loading_progress, null);
ImageView spaceshipImage = (ImageView) v.findViewById(R.id.beauty_iv_progress_img);
mTextMsg = (TextView) v.findViewById(R.id.beauty_tv_msg);
Animation hyperspaceJumpAnimation =
AnimationUtils.loadAnimation(context, R.anim.beauty_load_progress_animation);
spaceshipImage.startAnimation(hyperspaceJumpAnimation);
mDialog = new Dialog(context, R.style.BeautyLoadingDialog);
mDialog.setCancelable(false);
LinearLayout layout = (LinearLayout) v.findViewById(R.id.beauty_ll_progress);
mDialog.setContentView(layout, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT));
}
public void setCancelable(boolean cancelable) {
if (mDialog != null) {
mDialog.setCancelable(cancelable);
}
}
public void setCanceledOnTouchOutside(boolean canceledOnTouchOutside) {
if (mDialog != null) {
mDialog.setCanceledOnTouchOutside(canceledOnTouchOutside);
}
}
public void show() {
if (mDialog != null) {
mDialog.show();
}
}
public void dismiss() {
if (mDialog != null) {
mDialog.dismiss();
}
}
public void setMsg(String msg) {
if (mTextMsg == null) {
return;
}
if (mTextMsg.getVisibility() == View.GONE) {
mTextMsg.setVisibility(View.VISIBLE);
}
mTextMsg.setText(msg);
}
}

68
beautysettingkit/src/main/java/com/tencent/liteav/demo/beauty/view/TCHorizontalScrollView.java

@ -0,0 +1,68 @@
package com.tencent.liteav.demo.beauty.view;
import android.content.Context;
import android.database.DataSetObserver;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.HorizontalScrollView;
public class TCHorizontalScrollView extends HorizontalScrollView {
private DataSetObserver mObserver;
private Adapter mAdapter;
public TCHorizontalScrollView(Context context) {
super(context);
initialize();
}
public TCHorizontalScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize();
}
public TCHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize();
}
public void setAdapter(Adapter adapter) {
if (mAdapter != null) {
mAdapter.unregisterDataSetObserver(mObserver);
}
mAdapter = adapter;
mAdapter.registerDataSetObserver(mObserver);
updateAdapter();
}
private void updateAdapter() {
ViewGroup group = (ViewGroup) getChildAt(0);
group.removeAllViews();
for (int i = 0; i < mAdapter.getCount(); i++) {
View view = mAdapter.getView(i, null, group);
group.addView(view);
}
}
void initialize() {
mObserver = new DataSetObserver() {
@Override
public void onChanged() {
super.onChanged();
updateAdapter();
}
@Override
public void onInvalidated() {
super.onInvalidated();
((ViewGroup) getChildAt(0)).removeAllViews();
}
};
}
public void setClicked(int position) {
((ViewGroup) getChildAt(0)).getChildAt(position).performClick();
}
}

13
beautysettingkit/src/main/res/anim/beauty_load_progress_animation.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="1500"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="-1"
android:repeatMode="restart"
android:startOffset="-1"
android:toDegrees="+360" />
</set>

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_bailan.png

After

Width: 163  |  Height: 163  |  Size: 51 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_baixi.png

After

Width: 163  |  Height: 163  |  Size: 45 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_biaozhun.png

After

Width: 163  |  Height: 163  |  Size: 50 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_chaotuo.png

After

Width: 163  |  Height: 163  |  Size: 50 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_chunzhen.png

After

Width: 163  |  Height: 163  |  Size: 50 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_fennen.png

After

Width: 163  |  Height: 163  |  Size: 47 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_bailan.png

After

Width: 512  |  Height: 512  |  Size: 240 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_baixi.png

After

Width: 512  |  Height: 512  |  Size: 237 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_biaozhun.png

After

Width: 512  |  Height: 512  |  Size: 121 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_chaotuo.png

After

Width: 512  |  Height: 512  |  Size: 168 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_chunzhen.png

After

Width: 512  |  Height: 512  |  Size: 303 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_fennen.png

After

Width: 512  |  Height: 512  |  Size: 3.0 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_huaijiu.png

After

Width: 512  |  Height: 512  |  Size: 3.2 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_landiao.png

After

Width: 512  |  Height: 512  |  Size: 3.1 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_langman.png

After

Width: 512  |  Height: 512  |  Size: 3.1 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_qingliang.png

After

Width: 512  |  Height: 512  |  Size: 2.9 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_qingxin.png

After

Width: 512  |  Height: 512  |  Size: 3.0 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_rixi.png

After

Width: 512  |  Height: 512  |  Size: 3.1 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_weimei.png

After

Width: 512  |  Height: 512  |  Size: 2.8 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_white.png

After

Width: 512  |  Height: 512  |  Size: 3.0 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_xiangfen.png

After

Width: 512  |  Height: 512  |  Size: 202 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_yinghong.png

After

Width: 512  |  Height: 512  |  Size: 165 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_yuanqi.png

After

Width: 512  |  Height: 512  |  Size: 236 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_yunshang.png

After

Width: 512  |  Height: 512  |  Size: 195 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_filter_ziran.png

After

Width: 512  |  Height: 512  |  Size: 274 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_fwhite.png

After

Width: 163  |  Height: 163  |  Size: 45 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_huaijiu.png

After

Width: 163  |  Height: 163  |  Size: 46 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_bigeye.png

After

Width: 135  |  Height: 135  |  Size: 9.8 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_bottom_bg.png

After

Width: 1125  |  Height: 438  |  Size: 9.4 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_bottom_bg2.png

After

Width: 1125  |  Height: 150  |  Size: 3.3 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_chin.png

After

Width: 135  |  Height: 135  |  Size: 10 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_common_none.png

After

Width: 135  |  Height: 135  |  Size: 12 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_cutout_background_ai.png

After

Width: 135  |  Height: 135  |  Size: 13 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_boom.png

After

Width: 110  |  Height: 110  |  Size: 8.1 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_call.png

After

Width: 110  |  Height: 110  |  Size: 18 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_constellation.png

After

Width: 110  |  Height: 110  |  Size: 22 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_face_change.png

After

Width: 110  |  Height: 110  |  Size: 17 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_flower_fairy.png

After

Width: 110  |  Height: 110  |  Size: 24 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_headband.png

After

Width: 110  |  Height: 110  |  Size: 21 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_neon_rat.png

After

Width: 110  |  Height: 110  |  Size: 5.4 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_princess.png

After

Width: 110  |  Height: 110  |  Size: 1.5 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_purple_cat.png

After

Width: 110  |  Height: 110  |  Size: 3.5 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_ribbon.png

After

Width: 110  |  Height: 110  |  Size: 14 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_effect_star_ear.png

After

Width: 110  |  Height: 110  |  Size: 19 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eye_angle.png

After

Width: 135  |  Height: 135  |  Size: 9.2 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eye_bright.png

After

Width: 135  |  Height: 135  |  Size: 9.1 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eye_distance.png

After

Width: 135  |  Height: 135  |  Size: 10 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_eyebig.png

After

Width: 135  |  Height: 135  |  Size: 9.8 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_face_shape.png

After

Width: 135  |  Height: 135  |  Size: 9.8 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_face_short.png

After

Width: 135  |  Height: 135  |  Size: 9.3 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_faceslim.png

After

Width: 135  |  Height: 138  |  Size: 11 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_facev.png

After

Width: 135  |  Height: 138  |  Size: 9.5 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_forehead.png

After

Width: 135  |  Height: 135  |  Size: 9.3 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_bottle_cap_challenge.png

After

Width: 110  |  Height: 110  |  Size: 4.5 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_meteor_shower.png

After

Width: 110  |  Height: 110  |  Size: 5.9 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_pikachu.png

After

Width: 110  |  Height: 110  |  Size: 5.5 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_snow_control.png

After

Width: 110  |  Height: 110  |  Size: 16 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_gesture_tv_star.png

After

Width: 110  |  Height: 110  |  Size: 6.6 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_goodluck.png

After

Width: 135  |  Height: 135  |  Size: 10 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_cherry.png

After

Width: 110  |  Height: 110  |  Size: 17 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_costume.png

After

Width: 110  |  Height: 110  |  Size: 17 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_lip.png

After

Width: 110  |  Height: 110  |  Size: 14 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_mixing.png

After

Width: 110  |  Height: 110  |  Size: 18 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_pink.png

After

Width: 110  |  Height: 110  |  Size: 15 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_retro.png

After

Width: 110  |  Height: 110  |  Size: 34 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_seas.png

After

Width: 110  |  Height: 110  |  Size: 17 KiB

BIN
beautysettingkit/src/main/res/drawable-xxhdpi/beauty_ic_makeups_ugly.png

After

Width: 110  |  Height: 110  |  Size: 16 KiB

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save