diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index dc1a78f..0000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -/.nyc_output -/coverage -/node_modules -/tests/fixtures -/sign -/dist -/build \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3d1760d..c61557c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,10 @@ -node_modules -build -dist - -.DS_Store -Thumbs.db - -*.log -*.iml +.gradle/ +build/ +local.properties .idea/ -.vscode/ - -.nyc_output -/coverage - -/logs +*.iml +.DS_Store +*.log +captures/ +.externalNativeBuild/ +.cxx/ diff --git a/README.md b/README.md index f859aa2..f734b54 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,26 @@ -## 快速上手 +# DSHWatchPhone(手机端 / 原生 Android) -您可通过运行 `npm run start` 后,使用快应用引擎扫描二维码快速开发。 +DSHWatch 手机客户端空壳。后续接入: -## 了解更多 +- DSHWatch_Server(或 dsh-watch 插件直连)WebSocket。 +- 小米穿戴 SDK(Wearable / MessageApi)作为手表 BLE 互联对端。 +- 作为手表网关,把服务器状态/事件转发给 DSHWatch,并把手表指令转发回服务器。 -你可以通过我们的[官方文档](https://doc.quickapp.cn/)熟悉和了解快应用。 +## 当前为 UI 空壳 -可以通过我们[快应用官方示例项目](https://github.com/quickappcn/sample),快速掌握 -api 和组件的用法 +- MainActivity:状态页(刷新 / 设置入口)。 +- SettingsActivity:服务器地址 / userId / token 表单。 +- WatchBridge.java / ServerClient.java:占位接口,未接入 SDK。 -对我们有什么意见,建议或者 bug,可以在这里反馈 -https://github.com/quickappcn/issues +## 构建 + +用 Android Studio 打开本目录(Gradle 会拉取 AGP + AndroidX)。 + +- compileSdk 34 / minSdk 26 / targetSdk 34 +- Java 17 + +## 后续接入小米穿戴 SDK + +- 从官方 demo(open-vela packages_apps / interconnect_image_demo 的 android_program)拿 libs/。 +- 包名与签名需与 DSHWatch(手表 rpk)一致:com.dshwatch.app。 +- 在 ServerClient 里接 WebSocket,在 WatchBridge 里接 MessageApi。 diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..313b7e4 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,29 @@ +plugins { + id 'com.android.application' +} +android { + namespace 'com.dshwatch.app' + compileSdk 34 + defaultConfig { + applicationId "com.dshwatch.app" + minSdk 26 + targetSdk 34 + versionCode 1 + versionName "0.1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } +} +dependencies { + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.9.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..fb164d6 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1 @@ +# Add project specific ProGuard rules here. diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..22e969d --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/dshwatch/app/MainActivity.java b/app/src/main/java/com/dshwatch/app/MainActivity.java new file mode 100644 index 0000000..b617f26 --- /dev/null +++ b/app/src/main/java/com/dshwatch/app/MainActivity.java @@ -0,0 +1,38 @@ +package com.dshwatch.app; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +import androidx.appcompat.app.AppCompatActivity; + +public class MainActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + TextView status = findViewById(R.id.status_text); + status.setText(getString(R.string.status_disconnected)); + + Button settings = findViewById(R.id.btn_settings); + settings.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(MainActivity.this, SettingsActivity.class)); + } + }); + + Button refresh = findViewById(R.id.btn_refresh); + refresh.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // 空壳:后续调用 ServerClient 拉取 Harness 状态 + status.setText(R.string.status_disconnected); + } + }); + } +} diff --git a/app/src/main/java/com/dshwatch/app/ServerClient.java b/app/src/main/java/com/dshwatch/app/ServerClient.java new file mode 100644 index 0000000..f6fd63e --- /dev/null +++ b/app/src/main/java/com/dshwatch/app/ServerClient.java @@ -0,0 +1,31 @@ +package com.dshwatch.app; + +/** + * Harness 服务器客户端(空壳)。 + * 后续接入 WebSocket(OkHttp ws),通过 DSHWatch_Server 或直连 dsh-watch 插件, + * 实现 harness.status / session.prompt / session.list 等 RPC。 + */ +public class ServerClient { + private String serverUrl; + private String userId; + private String token; + + public ServerClient(String serverUrl, String userId, String token) { + this.serverUrl = serverUrl; + this.userId = userId; + this.token = token; + } + + public void connect() { + // 空壳:TODO 实现 WebSocket 握手 + 请求/响应 + 事件回调 + } + + public void sendRequest(String method, String paramsJson, Callback cb) { + // 空壳:TODO + } + + public interface Callback { + void onResult(String json); + void onError(String message); + } +} diff --git a/app/src/main/java/com/dshwatch/app/SettingsActivity.java b/app/src/main/java/com/dshwatch/app/SettingsActivity.java new file mode 100644 index 0000000..d0303d2 --- /dev/null +++ b/app/src/main/java/com/dshwatch/app/SettingsActivity.java @@ -0,0 +1,35 @@ +package com.dshwatch.app; + +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +public class SettingsActivity extends AppCompatActivity { + + private EditText serverUrl; + private EditText userId; + private EditText token; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_settings); + + serverUrl = findViewById(R.id.input_server); + userId = findViewById(R.id.input_user); + token = findViewById(R.id.input_token); + + Button save = findViewById(R.id.btn_save); + save.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // 空壳:后续持久化到 SharedPreferences / 安全存储 + Toast.makeText(SettingsActivity.this, "保存(空壳): " + serverUrl.getText(), Toast.LENGTH_SHORT).show(); + } + }); + } +} diff --git a/app/src/main/java/com/dshwatch/app/WatchBridge.java b/app/src/main/java/com/dshwatch/app/WatchBridge.java new file mode 100644 index 0000000..11ec0b8 --- /dev/null +++ b/app/src/main/java/com/dshwatch/app/WatchBridge.java @@ -0,0 +1,15 @@ +package com.dshwatch.app; + +/** + * 手表 BLE 互联桥(空壳)。 + * 后续接入小米穿戴 SDK:Wearable / MessageApi / sendMessage / addListener, + * 用于把手表(DSHWatch) 与手机端双向转发。 + */ +public interface WatchBridge { + /** 连接手表(小米穿戴服务) */ + void connect(); + /** 发送消息给手表 */ + void sendToWatch(String json); + /** 接收来自手表的消息 */ + String onWatchMessage(String json); +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..bb73b9f --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,48 @@ + + + + + + + +