Jelajahi Sumber

2024-05-31提交

zhongzhao 10 bulan lalu
induk
melakukan
762a749771

+ 3 - 3
app/src/main/AndroidManifest.xml

@@ -8,8 +8,6 @@
         android:name="${applicationId}.permission.JPUSH_MESSAGE"
         android:protectionLevel="signature" />
 
-    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
     <!-- Required  一些系统要求的权限,如访问网络等 -->
@@ -20,7 +18,6 @@
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
-    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.hardware.camera" />
@@ -52,7 +49,10 @@
 
     <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
     <uses-permission android:name="action:com.sunmi.scanner.ACTION_BAR_DEVICES_SETTING"/>
+    <!--NFC权限-->
     <uses-permission android:name="android.permission.NFC" />
+    <uses-feature android:name="android.hardware.nfc" android:required="true" />
+    <uses-permission android:name="com.sunmi.perm.CONTACTLESS_CARD" />
 
     <application
         android:allowBackup="true"

+ 0 - 8
app/src/main/java/com/hw/nativeapp/MApplication.java

@@ -4,21 +4,13 @@ import android.app.Application;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.os.StrictMode;
-
 import com.blankj.utilcode.util.Utils;
-import com.hw.nativeapp.config.Contents;
 import com.hw.nativeapp.config.exceptions.CrashHandler;
 import com.hw.nativeapp.httpnet.ApiService;
-import com.hw.nativeapp.httpnet.ErrorConsumer;
 import com.hw.nativeapp.httpnet.FileApiService;
-import com.hw.nativeapp.httpnet.ResponseConsumer;
 import com.hw.nativeapp.httpnet.RetrofitFileManager;
 import com.hw.nativeapp.httpnet.RetrofitManager;
-import com.hw.nativeapp.ui.dialogs.DialogCommon;
-import com.hw.nativeapp.utils.ActivityUtils;
 import com.hw.nativeapp.utils.LogUtils;
-import com.hw.nativeapp.utils.RxUtil;
-import com.hw.nativeapp.utils.ToastUtils;
 import com.liulishuo.filedownloader.FileDownloader;
 
 

+ 6 - 0
app/src/main/java/com/hw/nativeapp/config/Contents.java

@@ -31,4 +31,10 @@ public class Contents {
 
     //广播标识
     public static final String BROADCAST_CODE_TYPE = "bar.code.type";
+
+    /**
+     * 身份证识别参数,从商米partner平台获取
+     */
+    public static final String APP_ID = "29cd0aea97914ae0be88e3c8a9b0800b";
+    public static final String APP_KEY = "00b7ac000db8453da3ad74b2b4a39ebe";
 }

+ 5 - 2
app/src/main/java/com/hw/nativeapp/ui/activity/BaseActivity.java

@@ -1,10 +1,15 @@
 package com.hw.nativeapp.ui.activity;
 
+import android.Manifest;
 import android.app.Activity;
+import android.content.pm.PackageManager;
+import android.os.Build;
 import android.os.Bundle;
 import android.text.TextUtils;
 
 import androidx.annotation.Nullable;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
 
 import butterknife.ButterKnife;
 import butterknife.Unbinder;
@@ -45,6 +50,4 @@ public abstract class BaseActivity extends Activity {
             unbinder.unbind();
         }
     }
-
-
 }

+ 0 - 8
app/src/main/java/com/hw/nativeapp/ui/activity/IssueTicketsActivity.java

@@ -26,17 +26,9 @@ import com.hw.nativeapp.MApplication;
 import com.hw.nativeapp.R;
 import com.hw.nativeapp.httpnet.ErrorConsumer;
 import com.hw.nativeapp.httpnet.ResponseConsumer;
-import com.hw.nativeapp.httpnet.entity.handleBean;
-import com.hw.nativeapp.utils.ActivityUtils;
 import com.hw.nativeapp.utils.RxUtil;
-import com.squareup.picasso.Picasso;
 import com.sunmi.extprinterservice.ExtPrinterService;
 
-import java.sql.Array;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import butterknife.BindView;
 
 

+ 0 - 63
app/src/main/java/com/hw/nativeapp/ui/activity/MainActivity.java

@@ -1,23 +1,15 @@
 package com.hw.nativeapp.ui.activity;
 import android.annotation.SuppressLint;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
 import android.graphics.BitmapFactory;
 import android.os.Bundle;
 import android.os.CountDownTimer;
-import android.os.IBinder;
-import android.os.RemoteException;
 import android.provider.Settings;
 import android.util.Log;
 import android.view.GestureDetector;
 import android.view.KeyEvent;
-import android.view.MotionEvent;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.ImageView;
-import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.Toast;
 import android.widget.ViewFlipper;
@@ -33,19 +25,12 @@ import com.hw.nativeapp.httpnet.ResponseConsumer;
 import com.hw.nativeapp.httpnet.entity.LoginBean;
 import com.hw.nativeapp.httpnet.entity.LoginRequestBean;
 import com.hw.nativeapp.ui.dialogs.DialogInputDevice;
-import com.hw.nativeapp.ui.dialogs.DialogModifyText;
 import com.hw.nativeapp.ui.dialogs.DialogQuantity;
 import com.hw.nativeapp.utils.ActivityUtils;
-import com.hw.nativeapp.utils.DeviceUtils;
-import com.hw.nativeapp.utils.LogUtils;
 import com.hw.nativeapp.utils.RxUtil;
 import com.hw.nativeapp.utils.StringUtils;
 import com.hw.nativeapp.utils.ToastUtils;
 import com.squareup.picasso.Picasso;
-import com.sunmi.extprinterservice.ExtPrinterService;
-
-import java.util.HashMap;
-import java.util.Map;
 
 import butterknife.BindView;
 import butterknife.OnClick;
@@ -80,7 +65,6 @@ public class MainActivity extends BaseActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
-//        bindExtPrinterService();
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
     }
 
@@ -131,25 +115,10 @@ public class MainActivity extends BaseActivity {
     @Override
     protected void onStop() {
         super.onStop();
-//        if (serviceConnection != null) {
-//            try {
-//                unbindService(serviceConnection);
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//            }
-//        }
     }
     @Override
     protected void onDestroy() {
         super.onDestroy();
-//        if (serviceConnection != null) {
-//            try {
-//                unbindService(serviceConnection);
-//            } catch (Exception e) {
-//                e.printStackTrace();
-//            }
-//            serviceConnection = null;
-//        }
     }
     // take_btn 自助取票
     // purchase_btn 自助购票
@@ -259,38 +228,6 @@ public class MainActivity extends BaseActivity {
                     }
                 }, new ErrorConsumer());
     }
-    // 打印注册
-    private void bindExtPrinterService() {
-        Intent intent = new Intent();
-        intent.setPackage("com.sunmi.extprinterservice");
-        intent.setAction("com.sunmi.extprinterservice.PrinterService");
-        bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
-    }
-
-    ServiceConnection serviceConnection = new ServiceConnection() {
-        @Override public void onServiceConnected(ComponentName name, IBinder
-                service) {
-            ExtPrinterService ext = ExtPrinterService.Stub.asInterface(service);
-            int printerStatus = 0;
-            try {
-                printerStatus = ext.getPrinterStatus();
-            } catch (RemoteException e) {
-                e.printStackTrace();
-            }
-            if(printerStatus == 2) {
-                paper_text.setText("打印纸已用尽");
-            }
-        }
-        @Override public void onServiceDisconnected(ComponentName name) {
-            Log.e("onServiceDisconnected","---------------onServiceDisconnected--------------");
-        }
-        @Override public void onBindingDied(ComponentName name) {
-            Log.e("onBindingDied","---------------onBindingDied--------------");
-        }
-        @Override public void onNullBinding(ComponentName name) {
-            Log.e("onNullBinding","---------------onNullBinding--------------");
-        }
-    };
 
     private void stopCountDownTimer(){
         if (timer != null){

+ 9 - 0
app/src/main/java/com/hw/nativeapp/ui/activity/SelectInfoActivity.java

@@ -17,6 +17,7 @@ import androidx.annotation.RequiresApi;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.blankj.utilcode.util.ToastUtils;
 import com.hjq.bar.OnTitleBarListener;
 import com.hjq.bar.TitleBar;
 import com.hw.nativeapp.MApplication;
@@ -115,6 +116,14 @@ public class SelectInfoActivity extends BaseActivity  {
             case R.id.select_btn:
                 if(btnStatus){
                     Bundle bundle = new Bundle();
+                    if(performId.isEmpty()||auditoriumId.isEmpty()||performTimeId.isEmpty()||seatTypeId.isEmpty()||goodsId.isEmpty()||salePeice.isEmpty()){
+                        ToastUtils Toast1 = new ToastUtils();
+                        Toast1.setGravity(Gravity.TOP, 0, 200);
+                        Toast1.setTextSize(32);
+                        Toast1.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
+                        Toast1.show("提交数据不完整,请重新进入!");
+                        return;
+                    }
                     bundle.putString("performId", performId);
                     bundle.putString("auditoriumId", auditoriumId);
                     bundle.putString("performTimeId", performTimeId);

+ 15 - 35
app/src/main/java/com/hw/nativeapp/ui/activity/TakeActivity.java

@@ -10,13 +10,14 @@ import android.content.ServiceConnection;
 import android.content.pm.PackageManager;
 import android.os.Bundle;
 import android.os.CountDownTimer;
+import android.os.Handler;
 import android.os.IBinder;
+import android.os.Parcel;
 import android.os.RemoteException;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.View;
 import android.view.WindowManager;
-import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -51,9 +52,6 @@ public class TakeActivity extends BaseActivity  {
 //    @BindView(R.id.img_code_btn)
 //    ImageView img_code_btn;
 
-    private IDCardServiceAidl mService;
-    private Context context;
-
     @Override
     void initView() {
         titleBar = findViewById(R.id.tb_main_bar);
@@ -81,6 +79,9 @@ public class TakeActivity extends BaseActivity  {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_take);
         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+
+//        registerReceiver();
+        bindIDCardService();
     }
     @Override
     protected void onStart() {
@@ -89,9 +90,10 @@ public class TakeActivity extends BaseActivity  {
         if (!hasPermission) {
             ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 101);
         }
-
+        if (mService != null) {
+            readCardAutoFu();
+        }
         registerReceiver();
-//        bindIDCardService();
     }
     @Override
     protected void onStop() {
@@ -290,13 +292,14 @@ public class TakeActivity extends BaseActivity  {
         intent.setAction("com.sunmi.idcard");
         bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
     }
+    private IDCardServiceAidl mService;
     private ServiceConnection mConnection = new ServiceConnection() {
         @Override
         public void onServiceConnected(ComponentName name, IBinder service) {
             mService = IDCardServiceAidl.Stub.asInterface(service);
             Log.e("id_card", " 服务已连接");
             Toast.makeText(TakeActivity.this, "请将身份证放置到指示位置!", Toast.LENGTH_SHORT).show();
-            auto();
+            readCardAutoFu();
         }
 
         @Override
@@ -305,12 +308,14 @@ public class TakeActivity extends BaseActivity  {
             Log.e("id_card", "服务已断开");
         }
     };
-    public void auto() {
+
+    private void readCardAutoFu() {
         try {
             mService.readCardAuto(new CardCallback.Stub() {
                 @Override
                 public void getCardData(final IDCardInfo info, int code) {
                     Log.i(TAG, "getCardData: code=" + code + ", id info:" + info);
+                    Toast.makeText(TakeActivity.this, "身份证读取状态code=" + code, Toast.LENGTH_SHORT).show();
                     if (code == 10) {
                         //读取成功
                         Log.i(TAG, "getCardData: " + info.toString());
@@ -321,11 +326,11 @@ public class TakeActivity extends BaseActivity  {
                         bundle.putString("idcard", info.getIdCard());
                         ActivityUtils.launchActivity(TakeActivity.this, TicketCollectionActivity.class, bundle);
                     } else if (code == -10) {
-//                        Toast.makeText(TakeActivity.this, "身份证读取失败!" + code, Toast.LENGTH_SHORT).show();
+                        Toast.makeText(TakeActivity.this, "身份证读取失败!" + code, Toast.LENGTH_SHORT).show();
                         //读取失败
                         Log.i(TAG, "auto read card did not get data");
                     } else {
-//                        Toast.makeText(TakeActivity.this, "身份证读取失败!" + code, Toast.LENGTH_SHORT).show();
+                        Toast.makeText(TakeActivity.this, "身份证读取失败!" + code, Toast.LENGTH_SHORT).show();
                         Log.i(TAG, "what is wrong");
                     }
                 }
@@ -335,29 +340,4 @@ public class TakeActivity extends BaseActivity  {
             e.printStackTrace();
         }
     }
-    public void read(View view) {
-        try {
-            if (mService != null) {
-                IDCardInfo cardInfo = mService.readCard();
-                if (cardInfo != null) {
-                    //显示图片
-                    Log.i(TAG, "read: " + cardInfo.toString());
-                } else {
-                    Log.i(TAG, "card info is null ");
-                }
-            } else {
-                Log.i(TAG, "service is null");
-            }
-        } catch (Exception e) {
-            Log.i(TAG, "got error: " + e.getMessage());
-            e.printStackTrace();
-        }
-    }
-    public void cancelAuto(View v) {
-        try {
-            mService.cancelAutoReading();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
 }

+ 62 - 0
app/src/main/res/layout/activity_id_main.xml

@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        tools:context=".IdMainActivity">
+
+
+        <TextView
+            android:id="@+id/status"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:onClick="onOcrIDCard"
+            android:visibility="gone"
+            android:text="证件OCR识读" />
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:onClick="onMifare"
+            android:text="非接卡" />
+
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:onClick="read"
+            android:text="读卡" />
+
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:onClick="auto"
+            android:text="自动读卡" />
+
+        <Button
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:onClick="cancelAuto"
+            android:text="取消自动读卡" />
+
+        <ImageView
+            android:id="@+id/image"
+            android:layout_width="100dp"
+            android:layout_height="100dp" />
+
+        <TextView
+            android:id="@+id/text"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+
+    </LinearLayout>
+</layout>

TEMPAT SAMPAH
app/src/main/res/mipmap-hdpi/main_top.png