diff --git a/app/build.gradle b/app/build.gradle
index 76019ec..09cb51b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,7 +1,8 @@
plugins {
//alias(libs.plugins.android.application)
alias(libs.plugins.android.library)
- id 'org.jetbrains.kotlin.android'
+ alias(libs.plugins.kotlin.android)
+ //id 'org.jetbrains.kotlin.android'
}
ext.vvl_version='1.4.321.0'
@@ -43,13 +44,13 @@ android {
}
// 添加 Kotlin 编译选项
- kotlinOptions {
- jvmTarget = '17' // 与 Java 版本保持一致
- }
+// kotlinOptions {
+// jvmTarget = '17' // 与 Java 版本保持一致
+// }
- kotlin {
- jvmToolchain(17)
- }
+// kotlin {
+// jvmToolchain(17)
+// }
buildFeatures {
prefab true
@@ -83,6 +84,9 @@ android {
packagingOptions {
pickFirst '**/*.jar'
}
+ kotlinOptions {
+ jvmTarget = '17'
+ }
}
dependencies {
@@ -90,6 +94,7 @@ dependencies {
implementation libs.appcompat
implementation libs.material
implementation libs.games.activity
+ implementation libs.androidx.core.core.ktx
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
diff --git a/build.gradle b/build.gradle
index 60094ff..3f2f157 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ google()
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:8.3.2'
+ }
+}
+
plugins {
alias(libs.plugins.android.application) apply false
- alias(libs.plugins.android.library) apply false // 添加这行
- id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
+ alias(libs.plugins.android.library) apply false
+ alias(libs.plugins.kotlin.android) apply false // 添加这行
+ //alias(libs.plugins.kotlin.android) apply false
+ //id 'org.jetbrains.kotlin.android' version '2.2.0' apply false
}
\ No newline at end of file
diff --git a/example/build.gradle b/example/build.gradle
index 28dbfaa..ed25e85 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -1,13 +1,15 @@
plugins {
alias(libs.plugins.android.application)
+ alias(libs.plugins.kotlin.android)
+ //alias(libs.plugins.kotlin.android)
}
android {
- namespace 'com.hmwl.example'
+ namespace 'com.inewme.uvmirror'
compileSdk 36
defaultConfig {
- applicationId "com.hmwl.f20251110"
+ applicationId "com.inewme.uvmirror.f20251112"
minSdk 30
targetSdk 36
versionCode 1
@@ -26,6 +28,20 @@ android {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
+
+ buildFeatures {
+ compose true
+ }
+
+ composeOptions {
+ kotlinCompilerExtensionVersion '1.5.1'
+ }
+ kotlinOptions {
+ jvmTarget = '17'
+ }
+// kotlinOptions {
+// jvmTarget = '17'
+// }
}
dependencies {
@@ -33,11 +49,21 @@ dependencies {
implementation libs.appcompat
implementation libs.material
implementation libs.games.activity
+ implementation libs.core.ktx
+ implementation libs.androidx.core.ktx
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
implementation project(':app')
+ // Jetpack Compose
+ implementation "androidx.compose.ui:ui:1.5.0"
+ implementation "androidx.compose.material3:material3:1.0.0"
+ implementation "androidx.compose.foundation:foundation:1.5.0"
+ implementation "androidx.compose.runtime:runtime:1.5.0"
+ implementation "androidx.activity:activity-compose:1.7.2" // �ؼ����ṩ setContent
+
+ debugImplementation("androidx.compose.ui:ui-tooling:1.5.4")
def camerax_version = '1.4.2'
implementation "androidx.camera:camera-core:$camerax_version"
diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml
index 2f6f785..70485aa 100644
--- a/example/src/main/AndroidManifest.xml
+++ b/example/src/main/AndroidManifest.xml
@@ -20,6 +20,10 @@
android:name="android.app.lib_name"
android:value="face_sdk" />
+
+
\ No newline at end of file
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/区域示意图/pic0.png b/example/src/main/assets/底妆/基础上妆/2按压/区域示意图/pic0.png
deleted file mode 100644
index add9422..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/区域示意图/pic0.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/区域示意图/pic0_thick.png b/example/src/main/assets/底妆/基础上妆/2按压/区域示意图/pic0_thick.png
deleted file mode 100644
index 1a55a07..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/区域示意图/pic0_thick.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/demo0.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/demo0.png
deleted file mode 100644
index c9e5244..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/demo0.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/demo0_thick.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/demo0_thick.png
deleted file mode 100644
index 4cbe056..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/demo0_thick.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic0.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic0.png
deleted file mode 100644
index 5e96f81..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic0.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic0_thick.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic0_thick.png
deleted file mode 100644
index 3a076eb..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic0_thick.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic1.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic1.png
deleted file mode 100644
index 3af6c63..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic1.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic1_thick.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic1_thick.png
deleted file mode 100644
index 66d4024..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic1_thick.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic2.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic2.png
deleted file mode 100644
index 85b1564..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic2.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic2_thick.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic2_thick.png
deleted file mode 100644
index fea7c4f..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/pic2_thick.png and /dev/null differ
diff --git a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/test0.png b/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/test0.png
deleted file mode 100644
index acbb2d2..0000000
Binary files a/example/src/main/assets/底妆/基础上妆/2按压/方向示意图/test0.png and /dev/null differ
diff --git a/example/src/main/java/com/hmwl/example/MainActivity.java b/example/src/main/java/com/hmwl/example/MainActivity.java
deleted file mode 100644
index 2e1e537..0000000
--- a/example/src/main/java/com/hmwl/example/MainActivity.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package com.hmwl.example;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.MotionEvent;
-import android.widget.Toast;
-
-import com.hmwl.face_sdk.InitArg;
-import com.hmwl.face_sdk.Motion;
-
-
-import com.hmwl.face_sdk.FaceActivity;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public class MainActivity extends FaceActivity
-{
-
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- Motion motion = new Motion();
- motion.type = "4";
- motion.png_names.add("4.png");
- InitArg initArg = new InitArg();
- initArg.action_fps = 29;
- initArg.zoom = 1.5f;
- initArg.motion = motion;
- SetInitArg(initArg.toJson());
-
-
- super.onCreate(savedInstanceState);
- FaceInit(this);
- Toast.makeText(this, "4.png", Toast.LENGTH_LONG).show();
- }
-
- String GetCurMotionState(int index)
- {
- Motion motion = new Motion();
- motion.type = pngFilesByFolder.get(index).folderName;
- motion.png_names = pngFilesByFolder.get(index).getFileList();
- return motion.toJson();
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- // 获取触控动作
- int action = event.getAction();
-
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- // 手指按下
- Log.d("TouchEvent", "手指按下 - X: " + event.getX() + ", Y: " + event.getY());
- break;
-
- case MotionEvent.ACTION_MOVE:
- // 手指移动
- Log.d("TouchEvent", "手指移动 - X: " + event.getX() + ", Y: " + event.getY());
- break;
-
- case MotionEvent.ACTION_UP:
- // 手指抬起
- Log.d("TouchEvent", "手指抬起");
- curIndex++;
- if(curIndex > pngFilesByFolder.size()-1)
- {
- curIndex = 0;
- }
- ChangeState(GetCurMotionState(curIndex));
- Toast.makeText(this, pngFilesByFolder.get(curIndex).folderName, Toast.LENGTH_LONG).show();
- break;
- }
-
- return true; // 表示已处理该事件
- }
-
- private class FolderInfo {
- private String folderName;
- private List fileList;
-
- public FolderInfo(String folderName, List fileList) {
- this.folderName = folderName;
- this.fileList = fileList;
- }
-
- public String getFolderName() {
- return folderName;
- }
-
- public List getFileList() {
- return fileList;
- }
- }
-
- private List readPngFilenamesFromAssets(Context context, String filename) {
- List folderList = new ArrayList<>();
-
- try {
- InputStream is = context.getAssets().open(filename);
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- StringBuilder stringBuilder = new StringBuilder();
- String line;
- while ((line = reader.readLine()) != null) {
- stringBuilder.append(line);
- }
-
- JSONObject jsonObject = new JSONObject(stringBuilder.toString());
-
- // 遍历所有文件夹
- Iterator folderIterator = jsonObject.keys();
- while (folderIterator.hasNext()) {
- String folderName = folderIterator.next();
- JSONArray fileArray = jsonObject.getJSONArray(folderName);
-
- List filesInFolder = new ArrayList<>();
- for (int i = 0; i < fileArray.length(); i++) {
- filesInFolder.add(fileArray.getString(i));
- }
-
- folderList.add(new FolderInfo(folderName, filesInFolder));
- }
-
- reader.close();
- is.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return folderList;
- }
- int curIndex = 0;
- List pngFilesByFolder = null;
- private void FaceInit(Context context){
- pngFilesByFolder = readPngFilenamesFromAssets(context, "pic/motion_data.json");
- }
-
-}
diff --git a/example/src/main/java/com/inewme/uvmirror/MainActivity.kt b/example/src/main/java/com/inewme/uvmirror/MainActivity.kt
new file mode 100644
index 0000000..41077d4
--- /dev/null
+++ b/example/src/main/java/com/inewme/uvmirror/MainActivity.kt
@@ -0,0 +1,64 @@
+package com.inewme.uvmirror
+
+import android.content.Intent
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material3.Button
+import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Surface
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.tooling.preview.Preview
+
+class MainActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ MyApp()
+ }
+ }
+}
+
+@Composable
+fun MyApp(modifier: Modifier = Modifier) {
+ MaterialTheme {
+ Surface(modifier = modifier) {
+ Greeting("Android")
+ }
+ }
+}
+
+@Composable
+fun Greeting(name: String, modifier: Modifier = Modifier) {
+ val context = LocalContext.current // 获取上下文用于启动 Activity
+
+ Column(
+ modifier = modifier.padding(16.dp)
+ ) {
+ Text(text = "Hello $name!")
+
+ Button(
+ onClick = {
+ // 跳转到 MakeupActivity
+ val intent = Intent(context, MakeupActivity::class.java)
+ context.startActivity(intent)
+ }
+ ) {
+ Text("Go to Makeup")
+ }
+ }
+}
+
+@Preview(showBackground = true)
+@Composable
+fun GreetingPreview() {
+ MaterialTheme {
+ Greeting("Android")
+ }
+}
\ No newline at end of file
diff --git a/example/src/main/java/com/inewme/uvmirror/MakeupActivity.kt b/example/src/main/java/com/inewme/uvmirror/MakeupActivity.kt
new file mode 100644
index 0000000..70650d8
--- /dev/null
+++ b/example/src/main/java/com/inewme/uvmirror/MakeupActivity.kt
@@ -0,0 +1,123 @@
+
+package com.inewme.uvmirror
+
+import android.content.Context
+import android.os.Bundle
+import android.util.Log
+import android.view.MotionEvent
+import android.widget.Toast
+import com.hmwl.face_sdk.FaceActivity
+import com.hmwl.face_sdk.InitArg
+import com.hmwl.face_sdk.Motion
+import org.json.JSONArray
+import org.json.JSONObject
+import java.io.BufferedReader
+import java.io.InputStreamReader
+
+
+class MakeupActivity : FaceActivity() {
+
+ private var curIndex = 0
+ private var pngFilesByFolder: List? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ val motion = Motion().apply {
+ type = "4"
+ png_names.add("4.png")
+ }
+
+ val initArg = InitArg().apply {
+ action_fps = 29
+ zoom = 1.5f
+ this.motion = motion
+ }
+
+ SetInitArg(initArg.toJson())
+
+ super.onCreate(savedInstanceState)
+ FaceInit(this)
+ Toast.makeText(this, "4.png", Toast.LENGTH_LONG).show()
+ }
+
+ private fun getCurMotionState(index: Int): String {
+ pngFilesByFolder?.let { folders ->
+ val motion = Motion().apply {
+ type = folders[index].folderName
+ png_names = folders[index].fileList
+ }
+ return motion.toJson()
+ }
+ return ""
+ }
+
+ override fun onTouchEvent(event: MotionEvent): Boolean {
+ when (event.action) {
+ MotionEvent.ACTION_DOWN -> {
+ Log.d("TouchEvent", "手指按下 - X: ${event.x}, Y: ${event.y}")
+ if(curIndex == 1)
+ {
+ finish();
+ }
+ }
+ MotionEvent.ACTION_MOVE -> {
+ Log.d("TouchEvent", "手指移动 - X: ${event.x}, Y: ${event.y}")
+ }
+ MotionEvent.ACTION_UP -> {
+ Log.d("TouchEvent", "手指抬起")
+ curIndex++
+ pngFilesByFolder?.let { folders ->
+ if (curIndex > folders.size - 1) {
+ curIndex = 0
+ }
+ ChangeState(getCurMotionState(curIndex))
+ Toast.makeText(this, folders[curIndex].folderName, Toast.LENGTH_LONG).show()
+ }
+ }
+ }
+ return true
+ }
+
+ private inner class FolderInfo(
+ val folderName: String,
+ val fileList: List
+ )
+
+ private fun readPngFilenamesFromAssets(context: Context, filename: String): List {
+ val folderList = mutableListOf()
+
+ try {
+ context.assets.open(filename).use { inputStream ->
+ BufferedReader(InputStreamReader(inputStream)).use { reader ->
+ val stringBuilder = StringBuilder()
+ var line: String?
+ while (reader.readLine().also { line = it } != null) {
+ stringBuilder.append(line)
+ }
+
+ val jsonObject = JSONObject(stringBuilder.toString())
+ val folderIterator = jsonObject.keys()
+
+ while (folderIterator.hasNext()) {
+ val folderName = folderIterator.next()
+ val fileArray = jsonObject.getJSONArray(folderName)
+ val filesInFolder = mutableListOf()
+
+ for (i in 0 until fileArray.length()) {
+ filesInFolder.add(fileArray.getString(i))
+ }
+
+ folderList.add(FolderInfo(folderName, filesInFolder))
+ }
+ }
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+
+ return folderList
+ }
+
+ private fun FaceInit(context: Context) {
+ pngFilesByFolder = readPngFilenamesFromAssets(context, "pic/motion_data.json")
+ }
+}
\ No newline at end of file
diff --git a/example/src/main/res/values/strings.xml b/example/src/main/res/values/strings.xml
index 6d4f3ef..468f9ea 100644
--- a/example/src/main/res/values/strings.xml
+++ b/example/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
- f20251110
+ f20251112
\ No newline at end of file
diff --git a/example/src/test/java/com/hmwl/example/ExampleUnitTest.java b/example/src/test/java/com/hmwl/example/ExampleUnitTest.java
deleted file mode 100644
index 63c26a9..0000000
--- a/example/src/test/java/com/hmwl/example/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.hmwl.example;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index e383a1f..9f1a1dc 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -6,6 +6,11 @@ espressoCore = "3.7.0"
appcompat = "1.7.1"
material = "1.13.0"
gamesActivity = "2.0.2"
+kotlin = "1.9.0"
+coreKtx = "1.12.0"
+kotlinVersion = "1.9.0"
+coreKtxVersion = "1.12.0"
+androidxCoreKtx = "1.12.0"
[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
@@ -14,7 +19,11 @@ espresso-core = { group = "androidx.test.espresso", name = "espresso-core", vers
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
games-activity = { group = "androidx.games", name = "games-activity", version.ref = "gamesActivity" }
+core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
+androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtxVersion" }
+androidx-core-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCoreKtx" }
[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
+kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }