diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index fd36261..64e4e35 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -114,6 +114,12 @@
android:name=".OXFaceOnlineActivity"
android:exported="false"
android:theme="@style/Theme.OxFaceLogin" />
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java b/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java
index 106c50c..24683b1 100644
--- a/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java
+++ b/app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java
@@ -39,6 +39,7 @@ import com.baidu.idl.face.main.finance.utils.TestPopWindow;
import com.baidu.idl.main.facesdk.FaceInfo;
import com.baidu.idl.main.facesdk.model.BDFaceImageInstance;
import com.ouxuan.oxface.data.DeviceSelectDataManager;
+import com.ouxuan.oxface.orderOX.VerificationCodeActivity;
import com.ouxuan.oxface.utils.LogManager;
import java.util.List;
@@ -787,27 +788,10 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
*/
private void handleVerificationCodeClick() {
LogManager.logInfo(TAG, "用户点击验证码开门");
- Toast.makeText(this, "验证码开门功能已触发", Toast.LENGTH_SHORT).show();
-
- // 这里可以添加实际的验证码开门逻辑
- // 例如:弹出输入验证码的对话框
-
- // 显示状态提示
- if (layoutCompareStatus != null) {
- layoutCompareStatus.setVisibility(View.VISIBLE);
- textCompareStatus.setTextColor(Color.parseColor("#009874"));
- textCompareStatus.setText("请输入验证码开门");
-
- // 3秒后隐藏状态提示
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- if (layoutCompareStatus != null) {
- layoutCompareStatus.setVisibility(View.GONE);
- }
- }
- }, 3000);
- }
+
+ // 启动验证码Activity
+ Intent intent = new Intent(this, VerificationCodeActivity.class);
+ startActivityForResult(intent, 1001);
}
/**
@@ -1169,87 +1153,49 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
* 更新小程序码显示
*/
private void updateMiniQrcode() {
- android.util.Log.d(TAG, "updateMiniQrcode方法开始执行");
LogManager.logInfo(TAG, "开始更新小程序码");
- android.util.Log.d(TAG, "开始更新小程序码"); // 添加系统日志
try {
- // 获取DeviceSelectDataManager实例
DeviceSelectDataManager deviceSelectDataManager = DeviceSelectDataManager.getInstance(this);
- LogManager.logInfo(TAG, "DeviceSelectDataManager实例获取成功");
- android.util.Log.d(TAG, "DeviceSelectDataManager实例获取成功");
-
- // 检查是否存在小程序码链接
- LogManager.logInfo(TAG, "检查小程序码链接是否存在");
- android.util.Log.d(TAG, "检查小程序码链接是否存在");
boolean hasQrcode = deviceSelectDataManager.hasMiniQrcodeUrl();
- LogManager.logInfo(TAG, "小程序码链接是否存在: " + hasQrcode);
- android.util.Log.d(TAG, "小程序码链接是否存在: " + hasQrcode);
if (hasQrcode) {
String base64Qrcode = deviceSelectDataManager.getMiniQrcodeUrl();
- LogManager.logInfo(TAG, "获取到小程序码数据,长度: " + (base64Qrcode != null ? base64Qrcode.length() : 0));
- android.util.Log.d(TAG, "获取到小程序码数据,长度: " + (base64Qrcode != null ? base64Qrcode.length() : 0));
-
- // 检查base64数据是否有效
if (base64Qrcode != null && !base64Qrcode.isEmpty()) {
- LogManager.logInfo(TAG, "小程序码数据不为空,准备更新UI");
- android.util.Log.d(TAG, "小程序码数据不为空,准备更新UI");
-
// 在主线程中更新UI
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
- LogManager.logInfo(TAG, "在主线程中更新小程序码UI");
- android.util.Log.d(TAG, "在主线程中更新小程序码UI");
- // 将base64字符串转换为Bitmap并显示在扫码开门按钮区域
- if (imgScanDoorQRCode != null) {
- LogManager.logInfo(TAG, "开始转换base64到Bitmap");
- android.util.Log.d(TAG, "开始转换base64到Bitmap");
- // 先检查base64字符串是否需要解码
- String decodedBase64 = base64Qrcode;
- // 如果是data URL格式,提取base64部分
- if (base64Qrcode.startsWith("data:image")) {
- int commaIndex = base64Qrcode.indexOf(',');
- if (commaIndex > 0) {
- decodedBase64 = base64Qrcode.substring(commaIndex + 1);
- LogManager.logInfo(TAG, "提取到的base64数据长度: " + decodedBase64.length());
- android.util.Log.d(TAG, "提取到的base64数据长度: " + decodedBase64.length());
- }
- }
-
- Bitmap qrcodeBitmap = BitmapUtils.base64ToBitmap(decodedBase64);
- if (qrcodeBitmap != null) {
- imgScanDoorQRCode.setImageBitmap(qrcodeBitmap);
- LogManager.logInfo(TAG, "小程序码更新成功");
- android.util.Log.d(TAG, "小程序码更新成功");
- } else {
- LogManager.logWarning(TAG, "小程序码Bitmap转换失败");
- android.util.Log.w(TAG, "小程序码Bitmap转换失败");
+ // 处理base64数据并显示二维码
+ String decodedBase64 = base64Qrcode;
+ if (base64Qrcode.startsWith("data:image")) {
+ int commaIndex = base64Qrcode.indexOf(',');
+ if (commaIndex > 0) {
+ decodedBase64 = base64Qrcode.substring(commaIndex + 1);
}
+ }
+
+ Bitmap qrcodeBitmap = BitmapUtils.base64ToBitmap(decodedBase64);
+ if (qrcodeBitmap != null && imgScanDoorQRCode != null) {
+ imgScanDoorQRCode.setImageBitmap(qrcodeBitmap);
+ LogManager.logInfo(TAG, "小程序码更新成功");
} else {
- LogManager.logWarning(TAG, "imgScanDoorQRCode为null");
- android.util.Log.w(TAG, "imgScanDoorQRCode为null");
+ LogManager.logWarning(TAG, "小程序码更新失败");
}
} catch (Exception e) {
- LogManager.logError(TAG, "更新小程序码时发生异常: " + e.getMessage(), e);
- android.util.Log.e(TAG, "更新小程序码时发生异常", e);
+ LogManager.logError(TAG, "更新小程序码异常: " + e.getMessage(), e);
}
}
});
} else {
LogManager.logWarning(TAG, "小程序码数据为空");
- android.util.Log.w(TAG, "小程序码数据为空");
}
} else {
- LogManager.logWarning(TAG, "未找到小程序码链接");
- android.util.Log.w(TAG, "未找到小程序码链接");
+ LogManager.logDebug(TAG, "未找到小程序码链接");
}
} catch (Exception e) {
- LogManager.logError(TAG, "获取小程序码时发生异常: " + e.getMessage(), e);
- android.util.Log.e(TAG, "获取小程序码时发生异常", e);
+ LogManager.logError(TAG, "获取小程序码异常: " + e.getMessage(), e);
}
- android.util.Log.d(TAG, "updateMiniQrcode方法执行结束");
}
/**
@@ -1322,4 +1268,60 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
startActivity(intent);
finish();
}
+
+ /**
+ * 处理验证码Activity返回结果
+ */
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ if (requestCode == 1001) {
+ if (resultCode == RESULT_OK && data != null) {
+ String verificationCode = data.getStringExtra("verification_code");
+ if (verificationCode != null && verificationCode.length() == 12) {
+ LogManager.logInfo(TAG, "收到验证码: " + verificationCode);
+ handleVerificationCodeSubmit(verificationCode);
+ }
+ } else {
+ LogManager.logInfo(TAG, "用户取消验证码输入");
+ }
+ }
+ }
+
+ /**
+ * 处理验证码提交
+ */
+ private void handleVerificationCodeSubmit(String verificationCode) {
+ // 显示验证状态
+ if (layoutCompareStatus != null) {
+ layoutCompareStatus.setVisibility(View.VISIBLE);
+ textCompareStatus.setTextColor(Color.parseColor("#009874"));
+ textCompareStatus.setText("正在验证验证码...");
+ }
+
+ // TODO: 这里添加实际的验证码验证逻辑
+ // 例如:发送网络请求验证验证码
+
+ // 模拟验证成功
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (layoutCompareStatus != null) {
+ textCompareStatus.setText("验证码验证成功,正在开门...");
+
+ // 延迟开门
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (layoutCompareStatus != null) {
+ layoutCompareStatus.setVisibility(View.GONE);
+ }
+ Toast.makeText(OXFaceOnlineActivity.this, "门已打开", Toast.LENGTH_SHORT).show();
+ }
+ }, 1000);
+ }
+ }
+ }, 2000);
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/ouxuan/oxface/orderOX/VerificationCodeActivity.java b/app/src/main/java/com/ouxuan/oxface/orderOX/VerificationCodeActivity.java
new file mode 100644
index 0000000..ceeb990
--- /dev/null
+++ b/app/src/main/java/com/ouxuan/oxface/orderOX/VerificationCodeActivity.java
@@ -0,0 +1,205 @@
+package com.ouxuan.oxface.orderOX;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.content.ContextCompat;
+
+import com.ouxuan.oxface.R;
+import com.ouxuan.oxface.utils.LogManager;
+
+/**
+ * 验证码开门Activity
+ * 提供一个覆盖在视频流上的弹窗界面,用于输入12位数字验证码
+ */
+public class VerificationCodeActivity extends AppCompatActivity {
+
+ private static final String TAG = "VerificationCodeActivity";
+
+ private EditText etVerificationCode1, etVerificationCode2, etVerificationCode3, etVerificationCode4;
+ private EditText etVerificationCode5, etVerificationCode6, etVerificationCode7, etVerificationCode8;
+ private EditText etVerificationCode9, etVerificationCode10, etVerificationCode11, etVerificationCode12;
+ private Button btnConfirm, btnCancel;
+ private ImageButton btnClose;
+ private TextView tvTitle, tvSubtitle;
+
+ private EditText[] verificationCodeInputs;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // 设置无标题栏
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+
+ // 设置背景透明,实现弹窗效果
+ getWindow().setBackgroundDrawableResource(android.R.color.transparent);
+
+ setContentView(R.layout.activity_verification_code);
+
+ // 设置窗口属性
+ Window window = getWindow();
+ window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
+ window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
+
+ initViews();
+ setupListeners();
+ setupAutoFocus();
+
+ LogManager.logInfo(TAG, "验证码Activity启动成功");
+ }
+
+ private void initViews() {
+ // 初始化输入框
+ etVerificationCode1 = findViewById(R.id.et_verification_code_1);
+ etVerificationCode2 = findViewById(R.id.et_verification_code_2);
+ etVerificationCode3 = findViewById(R.id.et_verification_code_3);
+ etVerificationCode4 = findViewById(R.id.et_verification_code_4);
+ etVerificationCode5 = findViewById(R.id.et_verification_code_5);
+ etVerificationCode6 = findViewById(R.id.et_verification_code_6);
+ etVerificationCode7 = findViewById(R.id.et_verification_code_7);
+ etVerificationCode8 = findViewById(R.id.et_verification_code_8);
+ etVerificationCode9 = findViewById(R.id.et_verification_code_9);
+ etVerificationCode10 = findViewById(R.id.et_verification_code_10);
+ etVerificationCode11 = findViewById(R.id.et_verification_code_11);
+ etVerificationCode12 = findViewById(R.id.et_verification_code_12);
+
+ // 初始化按钮
+ btnConfirm = findViewById(R.id.btn_confirm);
+ btnCancel = findViewById(R.id.btn_cancel);
+ btnClose = findViewById(R.id.btn_close);
+
+ // 初始化标题
+ tvTitle = findViewById(R.id.tv_title);
+ tvSubtitle = findViewById(R.id.tv_subtitle);
+
+ // 设置输入框数组
+ verificationCodeInputs = new EditText[]{
+ etVerificationCode1, etVerificationCode2, etVerificationCode3, etVerificationCode4,
+ etVerificationCode5, etVerificationCode6, etVerificationCode7, etVerificationCode8,
+ etVerificationCode9, etVerificationCode10, etVerificationCode11, etVerificationCode12
+ };
+
+ // 设置输入限制为数字
+ for (EditText editText : verificationCodeInputs) {
+ editText.setInputType(android.text.InputType.TYPE_CLASS_NUMBER);
+ editText.setFilters(new android.text.InputFilter[]{
+ new android.text.InputFilter.LengthFilter(1)
+ });
+ }
+ }
+
+ private void setupListeners() {
+ // 确认按钮
+ btnConfirm.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ handleConfirm();
+ }
+ });
+
+ // 取消按钮
+ btnCancel.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ handleCancel();
+ }
+ });
+
+ // 关闭按钮
+ btnClose.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+ }
+
+ private void setupAutoFocus() {
+ for (int i = 0; i < verificationCodeInputs.length; i++) {
+ final int index = i;
+ verificationCodeInputs[i].addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ if (s.length() == 1 && index < verificationCodeInputs.length - 1) {
+ verificationCodeInputs[index + 1].requestFocus();
+ }
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {}
+ });
+
+ // 设置删除键监听
+ verificationCodeInputs[i].setOnKeyListener(new View.OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, android.view.KeyEvent event) {
+ if (event.getAction() == android.view.KeyEvent.ACTION_DOWN &&
+ keyCode == android.view.KeyEvent.KEYCODE_DEL) {
+ if (verificationCodeInputs[index].getText().toString().isEmpty() &&
+ index > 0) {
+ verificationCodeInputs[index - 1].requestFocus();
+ verificationCodeInputs[index - 1].setText("");
+ return true;
+ }
+ }
+ return false;
+ }
+ });
+ }
+ }
+
+ private void handleConfirm() {
+ StringBuilder verificationCode = new StringBuilder();
+
+ for (EditText editText : verificationCodeInputs) {
+ String digit = editText.getText().toString().trim();
+ if (digit.isEmpty()) {
+ Toast.makeText(this, "请输入完整的12位验证码", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ verificationCode.append(digit);
+ }
+
+ String code = verificationCode.toString();
+ LogManager.logInfo(TAG, "用户输入验证码: " + code);
+
+ // 验证验证码格式
+ if (code.length() != 12 || !code.matches("\\d{12}")) {
+ Toast.makeText(this, "请输入正确的12位数字验证码", Toast.LENGTH_SHORT).show();
+ return;
+ }
+
+ // 返回验证码结果
+ Intent resultIntent = new Intent();
+ resultIntent.putExtra("verification_code", code);
+ setResult(RESULT_OK, resultIntent);
+ finish();
+ }
+
+ private void handleCancel() {
+ LogManager.logInfo(TAG, "用户取消验证码输入");
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+
+ @Override
+ public void onBackPressed() {
+ super.onBackPressed();
+ setResult(RESULT_CANCELED);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/btn_cancel_bg.xml b/app/src/main/res/drawable/btn_cancel_bg.xml
new file mode 100644
index 0000000..56792d1
--- /dev/null
+++ b/app/src/main/res/drawable/btn_cancel_bg.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/btn_confirm_bg.xml b/app/src/main/res/drawable/btn_confirm_bg.xml
new file mode 100644
index 0000000..a0b84e8
--- /dev/null
+++ b/app/src/main/res/drawable/btn_confirm_bg.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/dialog_background.xml b/app/src/main/res/drawable/dialog_background.xml
index d0ddc3d..cb16ce5 100644
--- a/app/src/main/res/drawable/dialog_background.xml
+++ b/app/src/main/res/drawable/dialog_background.xml
@@ -9,6 +9,6 @@
android:angle="135"
android:type="linear" />
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/primary_color_rounded_background.xml b/app/src/main/res/drawable/primary_color_rounded_background.xml
new file mode 100644
index 0000000..486a980
--- /dev/null
+++ b/app/src/main/res/drawable/primary_color_rounded_background.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/verification_code_bg.xml b/app/src/main/res/drawable/verification_code_bg.xml
new file mode 100644
index 0000000..f20a32b
--- /dev/null
+++ b/app/src/main/res/drawable/verification_code_bg.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_oxface_online.xml b/app/src/main/res/layout/activity_oxface_online.xml
index 6a17277..c8583bd 100644
--- a/app/src/main/res/layout/activity_oxface_online.xml
+++ b/app/src/main/res/layout/activity_oxface_online.xml
@@ -382,7 +382,7 @@
android:text="开门"
android:textSize="14sp"
android:textColor="#FFFFFF"
- android:background="@drawable/rounded_button_background"
+ android:background="@drawable/primary_color_rounded_background"
android:minHeight="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
diff --git a/app/src/main/res/layout/activity_verification_code.xml b/app/src/main/res/layout/activity_verification_code.xml
new file mode 100644
index 0000000..bc5ad2f
--- /dev/null
+++ b/app/src/main/res/layout/activity_verification_code.xml
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..7adda64
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
\ No newline at end of file