Browse Source

add OrderVerificationResultActivity

main
MTing 6 days ago
parent
commit
047921f959
  1. 6
      app/src/main/AndroidManifest.xml
  2. 49
      app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java
  3. 180
      app/src/main/java/com/ouxuan/oxface/orderOX/OrderVerificationResultActivity.java
  4. 185
      app/src/main/res/layout/activity_order_verification_result.xml

6
app/src/main/AndroidManifest.xml

@ -120,6 +120,12 @@
android:name=".orderOX.VerificationCodeActivity"
android:exported="false"
android:theme="@style/Theme.Transparent" />
<!-- 订单核销结果Activity -->
<activity
android:name=".orderOX.OrderVerificationResultActivity"
android:exported="false"
android:theme="@style/Theme.Transparent" />
</application>
</manifest>

49
app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java

@ -40,6 +40,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.OrderVerificationResultActivity;
import com.ouxuan.oxface.orderOX.VerificationCodeActivity;
import com.ouxuan.oxface.utils.LogManager;
@ -178,6 +179,9 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
loginDataManager = com.ouxuan.oxface.data.LoginDataManager.getInstance(this);
initView();
// 初始化并注册广播接收器
initCameraControlReceiver();
// 初始化人脸检测状态
lastFaceDetectedTime = System.currentTimeMillis();
isFaceDetected = false;
@ -823,6 +827,14 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
LogManager.logInfo(TAG, "用户点击扫码器开门");
Toast.makeText(this, "扫码器开门功能已触发", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(this, OrderVerificationResultActivity.class);
intent.putExtra("verification_type", 1); // 1-验证码验证, 4-扫码器验证
intent.putExtra("order_no", "订单号");
intent.putExtra("verification_code", "验证码");
intent.putExtra("order_type", "订单类型");
intent.putExtra("card_no", "卡号");
intent.putExtra("status", "核销状态");
startActivity(intent);
// 这里可以添加实际的扫码器开门逻辑
// 例如启动扫码器Activity或显示扫码器界面
@ -863,6 +875,12 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
protected void onDestroy() {
super.onDestroy();
// 注销广播接收器
if (cameraControlReceiver != null) {
unregisterReceiver(cameraControlReceiver);
LogManager.logInfo(TAG, "摄像头控制广播接收器已注销");
}
// 停止摄像头预览
if (CameraPreviewManager.getInstance() != null) {
CameraPreviewManager.getInstance().stopPreview();
@ -1790,4 +1808,35 @@ public class OXFaceOnlineActivity extends BaseActivity implements View.OnClickLi
}
});
}
/**
* 初始化摄像头控制广播接收器
*/
private void initCameraControlReceiver() {
cameraControlReceiver = new CameraControlReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("com.ouxuan.oxface.ACTION_PAUSE_CAMERA");
filter.addAction("com.ouxuan.oxface.ACTION_RESUME_CAMERA");
registerReceiver(cameraControlReceiver, filter);
LogManager.logInfo(TAG, "摄像头控制广播接收器已注册");
}
/**
* 摄像头控制广播接收器
*/
private class CameraControlReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if ("com.ouxuan.oxface.ACTION_PAUSE_CAMERA".equals(action)) {
// 暂停摄像头预览
isNeedCamera = false;
LogManager.logInfo(TAG, "接收到暂停摄像头预览广播 - isNeedCamera设置为false");
} else if ("com.ouxuan.oxface.ACTION_RESUME_CAMERA".equals(action)) {
// 恢复摄像头预览
isNeedCamera = true;
LogManager.logInfo(TAG, "接收到恢复摄像头预览广播 - isNeedCamera设置为true");
}
}
}
}

180
app/src/main/java/com/ouxuan/oxface/orderOX/OrderVerificationResultActivity.java

@ -0,0 +1,180 @@
package com.ouxuan.oxface.orderOX;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.ouxuan.oxface.R;
import com.ouxuan.oxface.utils.LogManager;
/**
* 订单核销结果Activity
* 提供一个覆盖在视频流上的弹窗界面用于显示订单核销结果
*/
public class OrderVerificationResultActivity extends AppCompatActivity {
private static final String TAG = "OrderVerificationResultActivity";
private ImageButton btnClose;
private Button btnConfirm;
private TextView tvTitle, tvOrderNo, tvVerificationCode, tvOrderType, tvCardNo, tvStatus;
private String orderNo, verificationCode, orderType, cardNo, status;
private int verificationType; // 1-验证码验证, 4-扫码器验证
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置无标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 设置背景透明实现弹窗效果
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
setContentView(R.layout.activity_order_verification_result);
// 设置窗口属性
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();
getIntentData();
updateUI();
setupListeners();
// 暂停摄像头预览
pauseCameraPreview();
LogManager.logInfo(TAG, "订单核销结果Activity启动成功");
}
private void initViews() {
// 初始化按钮
btnClose = findViewById(R.id.btn_close_result);
btnConfirm = findViewById(R.id.btn_confirm_result);
// 初始化文本视图
tvTitle = findViewById(R.id.tv_result_title);
tvOrderNo = findViewById(R.id.tv_order_no);
tvVerificationCode = findViewById(R.id.tv_verification_code);
tvOrderType = findViewById(R.id.tv_order_type);
tvCardNo = findViewById(R.id.tv_card_no);
tvStatus = findViewById(R.id.tv_status);
}
private void getIntentData() {
Intent intent = getIntent();
if (intent != null) {
verificationType = intent.getIntExtra("verification_type", 1);
orderNo = intent.getStringExtra("order_no");
verificationCode = intent.getStringExtra("verification_code");
orderType = intent.getStringExtra("order_type");
cardNo = intent.getStringExtra("card_no");
status = intent.getStringExtra("status");
}
// 设置默认值
if (orderNo == null) orderNo = "";
if (verificationCode == null) verificationCode = "";
if (orderType == null) orderType = "";
if (cardNo == null) cardNo = "";
if (status == null) status = "核销成功";
}
private void updateUI() {
// 根据验证类型设置标题
if (verificationType == 1) {
tvTitle.setText("验证码核销结果");
} else if (verificationType == 4) {
tvTitle.setText("扫码器核销结果");
} else {
tvTitle.setText("订单核销结果");
}
// 更新UI内容
tvOrderNo.setText(orderNo);
tvVerificationCode.setText(verificationCode);
tvOrderType.setText(orderType);
tvCardNo.setText(cardNo);
tvStatus.setText(status);
}
private void setupListeners() {
// 确认按钮
btnConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleConfirm();
}
});
// 关闭按钮
btnClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
private void handleConfirm() {
LogManager.logInfo(TAG, "用户确认订单核销结果");
Toast.makeText(this, "订单核销完成", Toast.LENGTH_SHORT).show();
finish();
}
/**
* 暂停摄像头预览
* 通过发送广播通知OXFaceOnlineActivity暂停摄像头预览
*/
private void pauseCameraPreview() {
try {
// 发送广播通知OXFaceOnlineActivity暂停摄像头预览
Intent intent = new Intent("com.ouxuan.oxface.ACTION_PAUSE_CAMERA");
sendBroadcast(intent);
LogManager.logInfo(TAG, "已发送暂停摄像头预览广播");
} catch (Exception e) {
LogManager.logError(TAG, "发送暂停摄像头预览广播失败", e);
}
}
/**
* 恢复摄像头预览
* 通过发送广播通知OXFaceOnlineActivity恢复摄像头预览
*/
private void resumeCameraPreview() {
try {
// 发送广播通知OXFaceOnlineActivity恢复摄像头预览
Intent intent = new Intent("com.ouxuan.oxface.ACTION_RESUME_CAMERA");
sendBroadcast(intent);
LogManager.logInfo(TAG, "已发送恢复摄像头预览广播");
} catch (Exception e) {
LogManager.logError(TAG, "发送恢复摄像头预览广播失败", e);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
// 恢复摄像头预览
resumeCameraPreview();
finish();
}
@Override
protected void onDestroy() {
super.onDestroy();
// 恢复摄像头预览
resumeCameraPreview();
LogManager.logInfo(TAG, "订单核销结果Activity已销毁");
}
}

185
app/src/main/res/layout/activity_order_verification_result.xml

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<!-- 弹窗背景 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:background="@drawable/dialog_background"
android:padding="20dp">
<!-- 标题栏 -->
<RelativeLayout
android:id="@+id/rl_title_bar_result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp">
<!-- 标题 -->
<TextView
android:id="@+id/tv_result_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="订单核销结果"
android:textColor="#333333"
android:textSize="18sp"
android:textStyle="bold" />
<!-- 关闭按钮 -->
<ImageButton
android:id="@+id/btn_close_result"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="关闭"
android:src="@drawable/ic_close" />
</RelativeLayout>
<!-- 订单信息 -->
<LinearLayout
android:id="@+id/ll_order_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/rl_title_bar_result"
android:layout_marginBottom="20dp"
android:orientation="vertical">
<!-- 订单号 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="订单号:"
android:textColor="#666666"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_order_no"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="20230908001"
android:textColor="#333333"
android:textSize="14sp" />
</LinearLayout>
<!-- 验证码 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="验证码:"
android:textColor="#666666"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_verification_code"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="123456"
android:textColor="#333333"
android:textSize="14sp" />
</LinearLayout>
<!-- 订单类型 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="订单类型:"
android:textColor="#666666"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_order_type"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="普通订单"
android:textColor="#333333"
android:textSize="14sp" />
</LinearLayout>
<!-- 卡号 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="卡号:"
android:textColor="#666666"
android:textSize="14sp" />
<TextView
android:id="@+id/tv_card_no"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="CARD001"
android:textColor="#333333"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<!-- 状态信息 -->
<TextView
android:id="@+id/tv_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ll_order_info"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:text="核销成功"
android:textColor="#009874"
android:textSize="16sp"
android:textStyle="bold" />
<!-- 确认按钮 -->
<Button
android:id="@+id/btn_confirm_result"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_below="@id/tv_status"
android:background="@drawable/gradient_button_selector"
android:text="确认"
android:textColor="@android:color/white"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
Loading…
Cancel
Save