|  |  | 
 |  |  |         exclude group: 'androidx.appcompat'; | 
 |  |  |         exclude group: 'androidx.annotation'; | 
 |  |  |     } | 
 |  |  |     implementation files('libs/ccidcard_20211231.jar') | 
 |  |  |     implementation files('libs/ccimg_20170424.jar') | 
 |  |  | } | 
 
 |  |  | 
 |  |  |     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> | 
 |  |  |     <!--用于申请调用A-GPS模块--> | 
 |  |  |     <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission> | 
 |  |  |  | 
 |  |  |     <uses-permission android:name="android.permission.CAMERA" /> | 
 |  |  |     <uses-feature android:name="android.hardware.camera" /> | 
 |  |  |     <application | 
 |  |  |         android:name=".MyApplication" | 
 |  |  |         android:allowBackup="true" | 
 |  |  | 
 |  |  |         <activity android:name=".activity.IdentifyingActivity" /> | 
 |  |  |         <activity android:name=".activity.ReplacementActivity" /> | 
 |  |  |         <activity android:name=".activity.RechargeDetail" /> | 
 |  |  |         <activity android:name=".activity.CameraActivity"/> | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         <meta-data | 
 
| New file | 
 |  |  | 
 |  |  | package com.dayu.recharge.activity; | 
 |  |  |  | 
 |  |  | import android.app.Activity; | 
 |  |  | import android.content.Context; | 
 |  |  | import android.content.Intent; | 
 |  |  | import android.graphics.Rect; | 
 |  |  | import android.hardware.Camera; | 
 |  |  | import android.os.Bundle; | 
 |  |  | import android.os.Handler; | 
 |  |  | import android.os.Message; | 
 |  |  | import android.util.Log; | 
 |  |  | import android.view.Display; | 
 |  |  | import android.view.SurfaceHolder; | 
 |  |  | import android.view.SurfaceView; | 
 |  |  | import android.view.View; | 
 |  |  | import android.view.View.OnClickListener; | 
 |  |  | import android.view.ViewGroup; | 
 |  |  | import android.view.WindowManager; | 
 |  |  | import android.widget.Button; | 
 |  |  | import android.widget.ImageView; | 
 |  |  | import android.widget.TextView; | 
 |  |  | import android.widget.Toast; | 
 |  |  |  | 
 |  |  | import com.dayu.recharge.R; | 
 |  |  | import com.dayu.recharge.view.ViewfinderView; | 
 |  |  | import com.yunmai.cc.idcard.controler.CameraManager; | 
 |  |  | import com.yunmai.cc.idcard.controler.OcrConstant; | 
 |  |  | import com.yunmai.cc.idcard.controler.OcrManager; | 
 |  |  | import com.yunmai.cc.idcard.vo.IdCardInfoNew; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 视频识别类 | 
 |  |  |  *  | 
 |  |  |  * @author fangcm 2013-03-18 | 
 |  |  |  *  | 
 |  |  |  */ | 
 |  |  |  | 
 |  |  | public class CameraActivity extends BaseActivity implements SurfaceHolder.Callback { | 
 |  |  |  | 
 |  |  |     private final String TAG = "cc_idcard"; | 
 |  |  |  | 
 |  |  |     private TextView tvTips; | 
 |  |  |     private SurfaceView sv_preview; | 
 |  |  |     private SurfaceHolder surfaceHolder; | 
 |  |  |     private CameraManager cameraManager; | 
 |  |  |     private boolean autoFoucs = true; | 
 |  |  |     private ViewfinderView finderView; | 
 |  |  |     private OcrManager ocrManager; | 
 |  |  |     private Rect rect; | 
 |  |  |     private boolean cameraError = false; | 
 |  |  |     // private boolean over = false; | 
 |  |  |  | 
 |  |  |     private Button btnFlash, btnCancel; | 
 |  |  |     private ImageView imgTips; | 
 |  |  |     private ImageView iv, ivHead; | 
 |  |  |     private int typeFront = 1;// 0不区分 ,1正面,2背面 | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     protected void onCreate(Bundle savedInstanceState) { | 
 |  |  |         // TODO Auto-generated method stub | 
 |  |  |         super.onCreate(savedInstanceState); | 
 |  |  |         setContentView(R.layout.camera); | 
 |  |  |  | 
 |  |  |         typeFront = this.getIntent().getIntExtra("typeFront", 0); | 
 |  |  |         initView(); | 
 |  |  |         cameraManager = new CameraManager(getBaseContext(), mHandler); | 
 |  |  |         mCameraOpenThread.start(); | 
 |  |  |         try { | 
 |  |  |             mCameraOpenThread.join(); | 
 |  |  |             mCameraOpenThread = null; | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             // TODO Auto-generated catch block | 
 |  |  |             e.printStackTrace(); | 
 |  |  |             cameraError = true; | 
 |  |  |         } | 
 |  |  |         if (cameraError) { | 
 |  |  |             Toast.makeText(getBaseContext(), "照相机未启动!", Toast.LENGTH_SHORT).show(); | 
 |  |  |             finish(); | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         setParameters(); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private Thread mCameraOpenThread = new Thread(new Runnable() { | 
 |  |  |         @Override | 
 |  |  |         public void run() { | 
 |  |  |             try { | 
 |  |  |                 cameraManager.openCamera(); | 
 |  |  |             } catch (Exception e) { | 
 |  |  |                 // TODO Auto-generated catch block | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |                 cameraError = true; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     }); | 
 |  |  |  | 
 |  |  |     private void setParameters() { | 
 |  |  |  | 
 |  |  |         WindowManager manager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); | 
 |  |  |         Display display = manager.getDefaultDisplay(); | 
 |  |  |         int wWidth = display.getWidth(); | 
 |  |  |         int wHeight = display.getHeight(); | 
 |  |  |  | 
 |  |  |         cameraManager.setCameraFlashModel(Camera.Parameters.FLASH_MODE_OFF); | 
 |  |  |  | 
 |  |  |         float ps = wWidth * 1.0f / wHeight; | 
 |  |  |         cameraManager.setPreviewSize(ps); | 
 |  |  |  | 
 |  |  |         int pWidth = cameraManager.getPreviewWidth(); | 
 |  |  |         int pHeight = cameraManager.getPreviewHeight(); | 
 |  |  |         if (pWidth == 0 || pHeight == 0) { | 
 |  |  |             Toast.makeText(getBaseContext(), "照相机未启动!!", Toast.LENGTH_SHORT).show(); | 
 |  |  |             finish(); | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         Log.i(TAG, pWidth + "<--------W----Preview-----H------->" + pHeight); | 
 |  |  |         Log.i(TAG, wWidth + "<--------W----WindowManager-----H------->" + wHeight); | 
 |  |  |  | 
 |  |  |         int tempWidth = pWidth; | 
 |  |  |         int tempHeidht = pHeight; | 
 |  |  |         float x = 100.0f; | 
 |  |  |         int tempW = pWidth; | 
 |  |  |         int tempH = pHeight; | 
 |  |  |         if (wWidth > pWidth && wHeight > pHeight) { | 
 |  |  |             while (wWidth > tempW && wHeight > tempH) { | 
 |  |  |                 x++; | 
 |  |  |                 Log.d(TAG, "---xx----->" + x / 100.0); | 
 |  |  |                 tempW = (int) (pWidth * x / 100.0); | 
 |  |  |                 tempH = (int) (pHeight * x / 100.0); | 
 |  |  |                 if (wWidth > tempW && wHeight > tempH) { | 
 |  |  |                     tempWidth = tempW; | 
 |  |  |                     tempHeidht = tempH; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             Log.d(TAG, "<------11--wWidth > pWidth && wHeight > pHeight------>"); | 
 |  |  |         } else { | 
 |  |  |             while (tempWidth > wWidth || tempHeidht > wHeight) { | 
 |  |  |                 x--; | 
 |  |  |                 Log.d(TAG, "---xx----->" + x / 100.0); | 
 |  |  |                 tempWidth = (int) (pWidth * x / 100.0); | 
 |  |  |                 tempHeidht = (int) (pHeight * x / 100.0); | 
 |  |  |             } | 
 |  |  |             Log.d(TAG, "<-----22---tempWidth > wWidth || tempHeidht > wHeight------>"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Log.d(TAG, tempWidth + "<--------W----setParameters-----H------->" + tempHeidht); | 
 |  |  |         // tempWidth = 854; | 
 |  |  |         // tempHeidht = 480; | 
 |  |  |         ViewGroup.LayoutParams lp = sv_preview.getLayoutParams(); | 
 |  |  |         lp.width = tempWidth; | 
 |  |  |         lp.height = tempHeidht; | 
 |  |  |         sv_preview.getHolder().setFixedSize(tempWidth, tempHeidht); | 
 |  |  |         sv_preview.setLayoutParams(lp); | 
 |  |  |  | 
 |  |  |         surfaceHolder = sv_preview.getHolder(); | 
 |  |  |         surfaceHolder.addCallback(CameraActivity.this); | 
 |  |  |         surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); | 
 |  |  |  | 
 |  |  |         float[] img = finderView.initFinder(tempWidth, tempHeidht, mHandler, typeFront); | 
 |  |  |  | 
 |  |  |         imgTips.setY(img[0]); | 
 |  |  |         imgTips.setX(img[1]); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void initView() { | 
 |  |  |         sv_preview = (SurfaceView) findViewById(R.id.camera_sv); | 
 |  |  |         finderView = (ViewfinderView) findViewById(R.id.camera_finderView); | 
 |  |  |         tvTips = (TextView) findViewById(R.id.tv_tips); | 
 |  |  |         btnCancel = (Button) findViewById(R.id.bt_cancel); | 
 |  |  |         btnFlash = (Button) findViewById(R.id.bt_flash); | 
 |  |  |         imgTips = (ImageView) findViewById(R.id.iv_tips); | 
 |  |  |         switch (typeFront) { | 
 |  |  |         case 0: | 
 |  |  |             imgTips.setVisibility(View.GONE); | 
 |  |  |             break; | 
 |  |  |         case 1: | 
 |  |  |             imgTips.setBackgroundResource(R.mipmap.people_face); | 
 |  |  |             break; | 
 |  |  |         case 2: | 
 |  |  |             imgTips.setBackgroundResource(R.mipmap.emblem); | 
 |  |  |             break; | 
 |  |  |  | 
 |  |  |         default: | 
 |  |  |             break; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         btnFlash.setOnClickListener(listener); | 
 |  |  |         btnCancel.setOnClickListener(listener); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private boolean isFlashOn = false; | 
 |  |  |  | 
 |  |  |     private OnClickListener listener = new OnClickListener() { | 
 |  |  |  | 
 |  |  |         @Override | 
 |  |  |         public void onClick(View v) { | 
 |  |  |             // TODO Auto-generated method stub | 
 |  |  |             switch (v.getId()) { | 
 |  |  |             case R.id.bt_cancel: | 
 |  |  |                 setResult(998); | 
 |  |  |                 finish(); | 
 |  |  |                 break; | 
 |  |  |             case R.id.bt_flash: | 
 |  |  |                 if (isFlashOn) { | 
 |  |  |                     try { | 
 |  |  |                         if (cameraManager.closeFlashlight()) { | 
 |  |  |                             btnFlash.setBackgroundDrawable(getResources().getDrawable(R.mipmap.flash_on_s)); | 
 |  |  |                             isFlashOn = false; | 
 |  |  |                         } | 
 |  |  |                     } catch (Exception e) { | 
 |  |  |                         // TODO: handle exception | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 } else { | 
 |  |  |                     try { | 
 |  |  |                         if (cameraManager.openFlashlight()) { | 
 |  |  |                             btnFlash.setBackgroundDrawable(getResources().getDrawable(R.mipmap.flash_off_s)); | 
 |  |  |                             isFlashOn = true; | 
 |  |  |                         } | 
 |  |  |                     } catch (Exception e) { | 
 |  |  |                         // TODO: handle exception | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |                 break; | 
 |  |  |  | 
 |  |  |             default: | 
 |  |  |                 break; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     private Handler mHandler = new Handler() { | 
 |  |  |  | 
 |  |  |         @Override | 
 |  |  |         public void handleMessage(Message msg) { | 
 |  |  |             // TODO Auto-generated method stub | 
 |  |  |             super.handleMessage(msg); | 
 |  |  |             switch (msg.what) { | 
 |  |  |             case OcrConstant.TAKE_PREVIEW_DATA_OK: | 
 |  |  |  | 
 |  |  |                 if (ocrManager == null) { | 
 |  |  |                     ocrManager = new OcrManager(mHandler, CameraActivity.this); | 
 |  |  |                     try { | 
 |  |  |                         rect = cameraManager.getViewfinder(finderView.getFinder()); | 
 |  |  |                     } catch (Exception e) { | 
 |  |  |                         // TODO: handle exception | 
 |  |  |                         return; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 byte[] data_p = (byte[]) msg.obj; | 
 |  |  |                 if (data_p != null && data_p.length > 0) { | 
 |  |  |                     // if(over){ | 
 |  |  |                     // return; | 
 |  |  |                     // } | 
 |  |  |                     ocrManager.recognIDCard(data_p, cameraManager.getPreviewWidth(), cameraManager.getPreviewHeight(), | 
 |  |  |                             rect, 0, typeFront); | 
 |  |  |                     mHandler.sendEmptyMessageDelayed(OcrConstant.START_AUTOFOCUS, 100); | 
 |  |  |                 } else { | 
 |  |  |                     finderView.setLineRect(0); | 
 |  |  |                     Toast.makeText(getBaseContext(), "相机出现问题,请重启手机!", Toast.LENGTH_SHORT).show(); | 
 |  |  |                     mHandler.sendEmptyMessageDelayed(OcrConstant.START_AUTOFOCUS, 500); | 
 |  |  |                 } | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.RECOGN_OK: | 
 |  |  |                 mHandler.removeMessages(OcrConstant.TAKE_PREVIEW_DATA_OK); | 
 |  |  |                 mHandler.removeMessages(OcrConstant.START_AUTOFOCUS); | 
 |  |  | //                String imgPath = "/sdcard/aidtest.jpg"; | 
 |  |  | //                String headPath = "/sdcard/aidheadtest.jpg"; | 
 |  |  |  | 
 |  |  |                 byte[] headPath = new byte[2048 * 1024 * 3]; | 
 |  |  |                 byte[] imgPath = new byte[2048 * 1024 * 3]; | 
 |  |  |                 int[] headRect = new int[8]; | 
 |  |  |                 int[] imgRect = new int[8]; | 
 |  |  |  | 
 |  |  |                 IdCardInfoNew idCardInfo = ocrManager.getResultToByte(imgPath, imgRect, headPath, headRect); | 
 |  |  | //                IdCardInfo idCardInfo = ocrManager.getResult(imgPath, headPath); | 
 |  |  |                 Intent data2 = new Intent(); | 
 |  |  |                 data2.putExtra("idcardinfo", idCardInfo); | 
 |  |  |                 setResult(200, data2); | 
 |  |  |  | 
 |  |  |                 finish(); | 
 |  |  |  | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.REPEAT_AUTOFOCUS: | 
 |  |  |                 cameraManager.autoFoucs(); | 
 |  |  |                 mHandler.sendEmptyMessageDelayed(OcrConstant.REPEAT_AUTOFOCUS, 2000); | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.RECOGN_EG_TIME_OUT: | 
 |  |  |                 Toast.makeText(getBaseContext(), "引擎过期,请尽快更新!", Toast.LENGTH_LONG).show(); | 
 |  |  |                 finish(); | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.RECOGN_EG_LICENSE: | 
 |  |  |                 int ret = -1; | 
 |  |  |                 if (msg.obj != null) { | 
 |  |  |                     ret = (Integer) msg.obj; | 
 |  |  |                 } | 
 |  |  |                 Toast.makeText(getBaseContext(), "授权失败-->" + ret, Toast.LENGTH_LONG).show(); | 
 |  |  |                 finish(); | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.RECOGN_EG_INIT_ERROR: | 
 |  |  |                 Toast.makeText(getBaseContext(), "引擎初始化失败!", Toast.LENGTH_LONG).show(); | 
 |  |  |                 finish(); | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.START_AUTOFOCUS: | 
 |  |  |                 if (autoFoucs) { | 
 |  |  |                     cameraManager.autoFoucs(); | 
 |  |  |                     autoFoucs = false; | 
 |  |  |                     mHandler.sendEmptyMessageDelayed(OcrConstant.START_AUTOFOCUS, 500); | 
 |  |  |                     mHandler.sendEmptyMessageDelayed(OcrConstant.REPEAT_AUTOFOCUS, 1500); | 
 |  |  |                 } else { | 
 |  |  |                     cameraManager.autoFocusAndPreviewCallback(); | 
 |  |  |                 } | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.RECOGN_LINE_IN_RECT: | 
 |  |  |                 int restult = (Integer) msg.obj; | 
 |  |  |                 finderView.setLineRect(restult); | 
 |  |  |                 break; | 
 |  |  |             case OcrConstant.RECOGN_TIPS: | 
 |  |  |                 int tips = (Integer) msg.obj; | 
 |  |  |                 switch (tips) { | 
 |  |  |                 case 1000: | 
 |  |  |                     tvTips.setText("请将身份证置于此区域\r\n尝试对齐边缘"); | 
 |  |  |                     break; | 
 |  |  |                 case 1001: | 
 |  |  |                     tvTips.setText("距离稍近,请尝试远点"); | 
 |  |  |                     break; | 
 |  |  |                 case 1002: | 
 |  |  |                     tvTips.setText("距离稍远,请尝试靠近"); | 
 |  |  |                     break; | 
 |  |  |                 case 1003: | 
 |  |  |                     // tvTips.setText("图像模糊,请调整距离"); | 
 |  |  |                     break; | 
 |  |  |                 case 1004: | 
 |  |  |                     tvTips.setText("图像倾斜,请保持水平拍摄"); | 
 |  |  |                     break; | 
 |  |  |                 case 1005: | 
 |  |  |                     tvTips.setText("请将身份证置于此区域\r\n尝试对齐边缘"); | 
 |  |  |                     break; | 
 |  |  |                 case 1006: | 
 |  |  |                     tvTips.setText("请将身份证正面至于此区域"); | 
 |  |  |                     break; | 
 |  |  |                 case 1007: | 
 |  |  |                     tvTips.setText("请将身份证反面至于此区域"); | 
 |  |  |                     break; | 
 |  |  |  | 
 |  |  |                 default: | 
 |  |  |                     break; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 break; | 
 |  |  |             default: | 
 |  |  |                 cameraManager.initDisplay(); | 
 |  |  |                 mHandler.sendEmptyMessageDelayed(OcrConstant.START_AUTOFOCUS, 500); | 
 |  |  |                 Toast.makeText(getBaseContext(), "<>" + msg.what, Toast.LENGTH_SHORT).show(); | 
 |  |  |                 break; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     }; | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void surfaceCreated(SurfaceHolder holder) { | 
 |  |  |         // TODO Auto-generated method stub | 
 |  |  |         Log.d(TAG, "surfaceCreated"); | 
 |  |  |         if (!cameraManager.cameraOpened()) { | 
 |  |  |             cameraManager.openCamera(); | 
 |  |  |             setParameters(); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { | 
 |  |  |         // TODO Auto-generated method stub | 
 |  |  |         if (holder.getSurface() == null) { | 
 |  |  |             Log.d(TAG, "holder.getSurface() == null"); | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         Log.v(TAG, "surfaceChanged. w=" + width + ". h=" + height); | 
 |  |  |         surfaceHolder = holder; | 
 |  |  |         cameraManager.setPreviewDisplay(surfaceHolder); | 
 |  |  |         cameraManager.initDisplay(); | 
 |  |  |         mHandler.sendEmptyMessageDelayed(OcrConstant.START_AUTOFOCUS, 500); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void surfaceDestroyed(SurfaceHolder holder) { | 
 |  |  |         // TODO Auto-generated method stub | 
 |  |  |         Log.d(TAG, "surfaceDestroyed"); | 
 |  |  |         try { | 
 |  |  |             cameraManager.closeCamera(); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             // TODO: handle exception | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         surfaceHolder = null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void finishAll() { | 
 |  |  |         if (cameraManager != null) { | 
 |  |  |             try { | 
 |  |  |                 cameraManager.closeCamera(); | 
 |  |  |             } catch (Exception e) { | 
 |  |  |                 // TODO: handle exception | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     protected void onDestroy() { | 
 |  |  |         // TODO Auto-generated method stub | 
 |  |  |         super.onDestroy(); | 
 |  |  |         mHandler.removeMessages(OcrConstant.TAKE_PREVIEW_DATA_OK); | 
 |  |  |         mHandler.removeMessages(OcrConstant.START_AUTOFOCUS); | 
 |  |  |         finishAll(); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | import android.view.LayoutInflater; | 
 |  |  | import android.view.View; | 
 |  |  |  | 
 |  |  | import com.dayu.recharge.utils.DeviceNumberUtils; | 
 |  |  | import com.dayu.recharge.view.ProgressDialog; | 
 |  |  | import com.msd.ocr.idcard.LibraryInitOCR; | 
 |  |  | import com.dayu.recharge.MyApplication; | 
 |  |  | import com.dayu.recharge.card.UserCard; | 
 |  |  | import com.dayu.recharge.databinding.ActivityNewCardBinding; | 
 |  |  | 
 |  |  | import com.dayu.recharge.tools.HexUtil; | 
 |  |  | import com.dayu.recharge.tools.Utils; | 
 |  |  | import com.dayu.recharge.utils.CRC8; | 
 |  |  | import com.dayu.recharge.utils.DeviceNumberUtils; | 
 |  |  | import com.dayu.recharge.utils.SocketUtil; | 
 |  |  | import com.dayu.recharge.utils.TipUtil; | 
 |  |  | import com.dayu.recharge.view.ProgressDialog; | 
 |  |  | import com.permissionx.guolindev.PermissionX; | 
 |  |  |  | 
 |  |  | import org.json.JSONException; | 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     private void startCamera() { | 
 |  |  |  | 
 |  |  |         Bundle bundle = new Bundle(); | 
 |  |  |         bundle.putBoolean("saveImage", false); | 
 |  |  |         bundle.putInt("requestCode", SCAN_IDCARD_REQUEST); | 
 |  |  |         bundle.putInt("type", 0); //0身份证, 1驾驶证 | 
 |  |  |         LibraryInitOCR.startScan(NewCardActivity.this, bundle); | 
 |  |  |         Intent intent = new Intent(NewCardActivity.this, CameraActivity.class); | 
 |  |  |         intent.putExtra("typeFront", 1); | 
 |  |  |         startActivityForResult(intent, 110); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |             return (c >= 0x4e00 && c <= 0x9fa5); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     protected void onDestroy() { | 
 |  |  |         super.onDestroy(); | 
 |  |  |         newCardActivity=null; | 
 |  |  |         newCardActivity = null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } | 
 
| New file | 
 |  |  | 
 |  |  | package com.dayu.recharge.view; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | import android.content.Context; | 
 |  |  | import android.graphics.Canvas; | 
 |  |  | import android.graphics.Color; | 
 |  |  | import android.graphics.Paint; | 
 |  |  | import android.graphics.Rect; | 
 |  |  | import android.os.Handler; | 
 |  |  | import android.util.AttributeSet; | 
 |  |  | import android.util.Log; | 
 |  |  | import android.view.Display; | 
 |  |  | import android.view.View; | 
 |  |  | import android.view.WindowManager; | 
 |  |  |  | 
 |  |  | import com.dayu.recharge.R; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 视频取景器控件 | 
 |  |  |  * | 
 |  |  |  * @author fangcm 2012-09-06 | 
 |  |  |  */ | 
 |  |  | public class ViewfinderView extends View { | 
 |  |  |  | 
 |  |  |     private int width, height; | 
 |  |  |     private Paint paint; | 
 |  |  |     private Context mContext; | 
 |  |  |     private int mWidth, mHeight; | 
 |  |  |     private float lineLeft, lineRight, lineTop, lineBottom; | 
 |  |  |     private int lineModel = 0; | 
 |  |  |     private float marginW = 0f; | 
 |  |  |     private float marginH = 0f; | 
 |  |  |     private float marginT = 0f; | 
 |  |  |     private int dLineWidth = 12; | 
 |  |  |     private int dLen = 60; | 
 |  |  |     private int m_nImageWidth; | 
 |  |  |     private int m_nImageHeight; | 
 |  |  |  | 
 |  |  |     boolean l = false, r = false, t = false, b = false, L = false; | 
 |  |  |  | 
 |  |  |     public ViewfinderView(Context context, AttributeSet attrs) { | 
 |  |  |         super(context, attrs); | 
 |  |  |         // TODO Auto-generated constructor stub | 
 |  |  |         this.mContext = context; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public ViewfinderView(Context context) { | 
 |  |  |         super(context); | 
 |  |  |         // TODO Auto-generated constructor stub | 
 |  |  |         this.mContext = context; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public ViewfinderView(Context context, AttributeSet attrs, int defStyle) { | 
 |  |  |         super(context, attrs, defStyle); | 
 |  |  |         // TODO Auto-generated constructor stub | 
 |  |  |         this.mContext = context; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 大小  85.6*54 | 
 |  |  |      * 长是宽的1.58倍 | 
 |  |  |      * | 
 |  |  |      * @param pWidth | 
 |  |  |      * @param pHeight | 
 |  |  |      */ | 
 |  |  |     public float[] initFinder(int pWidth, int pHeight, Handler mHandler, int typeFront) { | 
 |  |  |         m_nImageWidth = pWidth; | 
 |  |  |         m_nImageHeight = pHeight; | 
 |  |  |         WindowManager manager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); | 
 |  |  |         Display display = manager.getDefaultDisplay(); | 
 |  |  |         width = display.getWidth(); | 
 |  |  |         height = display.getHeight(); | 
 |  |  |         Log.d("tag", "-1-------->>" + width); | 
 |  |  |  | 
 |  |  |         marginT = mContext.getResources().getDimension(R.dimen.public_46_dp); | 
 |  |  |  | 
 |  |  |         marginW = (float) ((width - pWidth) / 2.0); | 
 |  |  |         marginH = (float) ((height - pHeight) / 2.0); | 
 |  |  |  | 
 |  |  |         mWidth = width / 2; | 
 |  |  |         mHeight = height / 2; | 
 |  |  |  | 
 |  |  |         float g = height - marginT * 2; | 
 |  |  |         float k = g * 1.58f; | 
 |  |  |         float x = 10.0f; | 
 |  |  |         Log.d("ocr", k + "<<--k---高度----g--1---->>" + g); | 
 |  |  |         while (k > pWidth) { | 
 |  |  |             x--; | 
 |  |  |             k = k * (x / 10.0f); | 
 |  |  |             g = g * (x / 10.0f); | 
 |  |  |         } | 
 |  |  |         Log.d("ocr", k + "<<--k---高度----g--2---->>" + g); | 
 |  |  |         lineLeft = (float) (mWidth - k / 2.0); | 
 |  |  |         lineRight = (float) (mWidth + k / 2.0); | 
 |  |  |         lineTop = (float) (mHeight - g / 2.0); | 
 |  |  |         lineBottom = (float) (mHeight + g / 2.0); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         int nDisplayWidth = display.getWidth(); | 
 |  |  |         int nDisplayHeight = display.getHeight(); | 
 |  |  |  | 
 |  |  |         int nImageWidth = m_nImageWidth; | 
 |  |  |         int nImageHeight = m_nImageHeight; | 
 |  |  |         double nFitWidth; | 
 |  |  |         double nFitHeight; | 
 |  |  |         double nUseWidth = 0; | 
 |  |  |         double nUseHeight = 0; | 
 |  |  |         double dRealRegionWidth = 0; | 
 |  |  | //        double dRealRegionHeight = 0; | 
 |  |  |         if (nImageWidth * nDisplayHeight < nDisplayWidth * nImageHeight) { | 
 |  |  |             nFitHeight = nDisplayHeight; | 
 |  |  |             nFitWidth = (nImageWidth / (double) nImageHeight) * nFitHeight; | 
 |  |  |         } else { | 
 |  |  |             nFitWidth = nDisplayWidth; | 
 |  |  |             nFitHeight = nFitWidth * (nImageHeight / (double) nImageWidth); | 
 |  |  |         } | 
 |  |  |         if (nFitWidth / nFitHeight >= 4 / 3) { | 
 |  |  |             nUseHeight = nFitHeight; | 
 |  |  |             nUseWidth = 4 * nUseHeight / 3.0f; | 
 |  |  |         } else { | 
 |  |  |             nUseWidth = nFitWidth; | 
 |  |  |             nUseHeight = 3 * nUseWidth / 4.0f; | 
 |  |  |         } | 
 |  |  |         dRealRegionWidth = nUseWidth / 480.0f * 420.0f; | 
 |  |  | //        dRealRegionHeight = nUseHeight/360.0f*270.0f; | 
 |  |  |  | 
 |  |  | //        lineLeft = (int)((nDisplayWidth - dRealRegionWidth)/2.0f);//- (nDisplayWidth - nFitWidth)/2.0f); | 
 |  |  | //        lineRight = (int)( nDisplayWidth - lineLeft);//- (nDisplayWidth - nFitWidth) ); | 
 |  |  | //        lineTop = (int)(nDisplayHeight - dRealRegionHeight)/2.0f; | 
 |  |  | //        lineBottom = nDisplayHeight - lineTop; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         paint = new Paint(); | 
 |  |  |         dLineWidth = (int) dRealRegionWidth / 28; //30 | 
 |  |  |         dLineWidth = 4; | 
 |  |  |         paint.setStrokeWidth(dLineWidth); | 
 |  |  |         dLen = (int) dRealRegionWidth / 6; //160 | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         float imgX = 10000; | 
 |  |  |         float imgY = 10000; | 
 |  |  |         switch (typeFront) { | 
 |  |  |             case 1: | 
 |  |  |                 imgX = (mWidth - k / 2) + k * 0.56f; | 
 |  |  |                 imgY = lineTop + g * 0.18f; | 
 |  |  |                 break; | 
 |  |  |             case 2: | 
 |  |  |                 imgX = lineLeft + k * 0.1f; | 
 |  |  |                 imgY = lineTop + g * 0.1f; | 
 |  |  |                 break; | 
 |  |  |  | 
 |  |  |             default: | 
 |  |  |                 break; | 
 |  |  |         } | 
 |  |  |         float[] img = {imgY, imgX}; | 
 |  |  |         return img; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public void initFinder(int w, int h, int d) { | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public Rect getFinder() { | 
 |  |  |         return new Rect((int) (lineLeft - marginW), (int) (lineTop - marginH), (int) (lineRight + marginW), (int) (lineBottom + marginH)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public void setLineRect(int model) { | 
 |  |  |         lineModel = model; | 
 |  |  |         invalidate(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void draw(Canvas canvas) { | 
 |  |  |         // TODO Auto-generated method stub | 
 |  |  |         super.draw(canvas); | 
 |  |  |  | 
 |  |  |         paint.setColor(Color.GREEN); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         canvas.drawLine(lineLeft - dLineWidth / 2, lineTop, lineLeft + dLen, lineTop, paint); | 
 |  |  |         canvas.drawLine(lineLeft, lineTop - dLineWidth / 2, lineLeft, lineTop + dLen, paint); | 
 |  |  |  | 
 |  |  |         canvas.drawLine(lineRight, lineTop - dLineWidth / 2, lineRight, lineTop + dLen, paint); | 
 |  |  |         canvas.drawLine(lineRight + dLineWidth / 2, lineTop, lineRight - dLen, lineTop, paint); | 
 |  |  |  | 
 |  |  |         canvas.drawLine(lineLeft, lineBottom + dLineWidth / 2, lineLeft, lineBottom - dLen, paint); | 
 |  |  |         canvas.drawLine(lineLeft - dLineWidth / 2, lineBottom, lineLeft + dLen, lineBottom, paint); | 
 |  |  |  | 
 |  |  |         canvas.drawLine(lineRight + dLineWidth / 2, lineBottom, lineRight - dLen, lineBottom, paint); | 
 |  |  |         canvas.drawLine(lineRight, lineBottom + dLineWidth / 2, lineRight, lineBottom - dLen, paint); | 
 |  |  |  | 
 |  |  |         switch (lineModel) { | 
 |  |  |             case 0: | 
 |  |  |  | 
 |  |  |                 break; | 
 |  |  |             case 1://左边框线 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 2://右边框线 | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 3://左右 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 4://上边框 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 break; | 
 |  |  |             case 5://左上 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 break; | 
 |  |  |             case 6://右上 | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 break; | 
 |  |  |             case 7://左右上 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 break; | 
 |  |  |             case 8://下边框 | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 9://左下 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 10://右下边框 | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 11://左右下 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 12://上下 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 13://上下左 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 14://上下右 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |             case 15://全 | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineLeft, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineRight, lineTop, lineRight, lineBottom, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineTop, lineRight, lineTop, paint); | 
 |  |  |                 canvas.drawLine(lineLeft, lineBottom, lineRight, lineBottom, paint); | 
 |  |  |                 break; | 
 |  |  |  | 
 |  |  |             default: | 
 |  |  |  | 
 |  |  |                 break; | 
 |  |  |         } | 
 |  |  |         paint.setColor(Color.BLACK); | 
 |  |  |         paint.setAlpha(100); | 
 |  |  | //        canvas.drawRect(lineLeft + dLineWidth / 2, lineTop + dLineWidth / 2, lineRight - dLineWidth / 2, lineBottom - dLineWidth / 2, paint); | 
 |  |  |  | 
 |  |  |         //画四周 | 
 |  |  |         canvas.drawRect(0, 0, width, lineTop - dLineWidth / 2, paint); | 
 |  |  |  | 
 |  |  |         canvas.drawRect(0, lineTop - dLineWidth / 2, lineLeft - dLineWidth / 2, lineBottom + dLineWidth / 2, paint); | 
 |  |  |  | 
 |  |  |         canvas.drawRect(0, lineBottom + dLineWidth / 2, width, height, paint); | 
 |  |  |  | 
 |  |  |         canvas.drawRect(lineRight + dLineWidth / 2, lineTop - dLineWidth / 2, width, lineBottom + dLineWidth / 2, paint); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  |                     android:id="@+id/newCard_scanBtn" | 
 |  |  |                     android:layout_width="45dp" | 
 |  |  |                     android:layout_height="45dp" | 
 |  |  |                     android:visibility="gone" | 
 |  |  |  | 
 |  |  |                     android:padding="10dp" | 
 |  |  |                     android:src="@mipmap/icon_scan" /> | 
 |  |  |  | 
 
| New file | 
 |  |  | 
 |  |  | <?xml version="1.0" encoding="utf-8"?> | 
 |  |  | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 
 |  |  |     android:layout_width="fill_parent" | 
 |  |  |     android:layout_height="fill_parent" | 
 |  |  |     android:orientation="vertical"> | 
 |  |  |  | 
 |  |  |     <SurfaceView | 
 |  |  |         android:id="@+id/camera_sv" | 
 |  |  |         android:layout_width="wrap_content" | 
 |  |  |         android:layout_height="wrap_content" | 
 |  |  |         android:layout_centerInParent="true" /> | 
 |  |  |  | 
 |  |  |     <Button | 
 |  |  |         android:id="@+id/bt_cancel" | 
 |  |  |         android:layout_width="wrap_content" | 
 |  |  |         android:layout_height="wrap_content" | 
 |  |  |         android:layout_alignParentRight="true" | 
 |  |  |         android:layout_marginTop="20dip" | 
 |  |  |         android:background="@mipmap/cancel_s" /> | 
 |  |  |  | 
 |  |  |     <Button | 
 |  |  |         android:id="@+id/bt_flash" | 
 |  |  |         android:layout_width="wrap_content" | 
 |  |  |         android:layout_height="wrap_content" | 
 |  |  |         android:layout_marginTop="20dip" | 
 |  |  |         android:background="@mipmap/flash_on_s" /> | 
 |  |  |  | 
 |  |  |     <TextView | 
 |  |  |         android:id="@+id/tv_tips" | 
 |  |  |         android:layout_width="wrap_content" | 
 |  |  |         android:layout_height="wrap_content" | 
 |  |  |         android:layout_centerInParent="true" | 
 |  |  |         android:gravity="center" | 
 |  |  |         android:text="请将身份证置于此区域\n尝试对齐边缘" | 
 |  |  |         android:textColor="@color/white" | 
 |  |  |         android:textSize="20sp" /> | 
 |  |  |  | 
 |  |  |     <com.dayu.recharge.view.ViewfinderView | 
 |  |  |         android:id="@+id/camera_finderView" | 
 |  |  |         android:layout_width="wrap_content" | 
 |  |  |         android:layout_height="wrap_content" /> | 
 |  |  |  | 
 |  |  |     <ImageView | 
 |  |  |         android:id="@+id/iv_tips" | 
 |  |  |         android:layout_width="wrap_content" | 
 |  |  |         android:layout_height="wrap_content" | 
 |  |  |         android:background="@mipmap/people_face" /> | 
 |  |  |  | 
 |  |  |  | 
 |  |  | </RelativeLayout> | 
 
 |  |  | 
 |  |  |     <color name="red">#ff0000</color> | 
 |  |  |  | 
 |  |  |     <color name="text_wite">#ffffff</color> | 
 |  |  |  | 
 |  |  |     <color name="white">#ffffff</color> | 
 |  |  |     <color name="black">#000000</color> | 
 |  |  |     <color name="blue">#0000FF</color> | 
 |  |  |     <color name="gray">#666666</color> | 
 |  |  |     <color name="use">#cccccc</color> <!-- 浅灰 --> | 
 |  |  |     <color name="transparent">#cccccc</color> <!-- 透明 --> | 
 |  |  |     <color name="snow">#444546</color> <!-- 浅白 --> | 
 |  |  |     <color name="azury">#1d8ee4</color> <!-- 浅蓝 --> | 
 |  |  |     <color name="qblue">#335bed</color><!-- 浅蓝 --> | 
 |  |  |     <color name="qgreen">#9dc446</color><!-- 浅绿色 --> | 
 |  |  |     <color name="quse">#9da0ab</color> <!-- 浅灰 --> | 
 |  |  |     <color name="qquse">#9c9c9c</color> <!-- 浅浅灰 --> | 
 |  |  |     <color name="finder_1">#33b5e5</color> <!-- 浅蓝色 --> | 
 |  |  |     <color name="finder_2">#0d80aa</color> <!-- 深一点的浅蓝色 --> | 
 |  |  | </resources> | 
 
 |  |  | 
 |  |  |     <dimen name="dimen_title_text_size">19sp</dimen> | 
 |  |  |     <dimen name="picker_view_height">160dp</dimen> | 
 |  |  |     <dimen name="date_unit_text_size">18sp</dimen> | 
 |  |  |  | 
 |  |  |     <dimen name="public_1_dp">1dip</dimen> | 
 |  |  |     <dimen name="public_4_dp">4dip</dimen> | 
 |  |  |     <dimen name="public_3_dp">3dip</dimen> | 
 |  |  |     <dimen name="public_6_dp">6dip</dimen> | 
 |  |  |     <dimen name="public_8_dp">8dip</dimen> | 
 |  |  |     <dimen name="public_10_dp">10dip</dimen> | 
 |  |  |     <dimen name="public_12_dp">12dip</dimen> | 
 |  |  |     <dimen name="public_14_dp">14dip</dimen> | 
 |  |  |     <dimen name="public_16_dp">16dip</dimen> | 
 |  |  |     <dimen name="public_18_dp">18dip</dimen> | 
 |  |  |     <dimen name="public_20_dp">20dip</dimen> | 
 |  |  |     <dimen name="public_24_dp">24dip</dimen> | 
 |  |  |     <dimen name="public_28_dp">28dip</dimen> | 
 |  |  |     <dimen name="public_30_dp">30dip</dimen> | 
 |  |  |     <dimen name="public_36_dp">36dip</dimen> | 
 |  |  |     <dimen name="public_34_dp">34dip</dimen> | 
 |  |  |     <dimen name="public_40_dp">40dip</dimen> | 
 |  |  |     <dimen name="public_46_dp">46dip</dimen> | 
 |  |  |     <dimen name="public_48_dp">48dip</dimen> | 
 |  |  |     <dimen name="public_60_dp">60dip</dimen> | 
 |  |  |     <dimen name="public_68_dp">68dip</dimen> | 
 |  |  |     <dimen name="public_70_dp">70dip</dimen> | 
 |  |  |     <dimen name="public_80_dp">80dip</dimen> | 
 |  |  |     <dimen name="public_100_dp">100dip</dimen> | 
 |  |  |     <dimen name="public_120_dp">120dip</dimen> | 
 |  |  |     <dimen name="public_160_dp">160dip</dimen> | 
 |  |  |     <dimen name="public_180_dp">180dip</dimen> | 
 |  |  |     <dimen name="public_200_dp">200dip</dimen> | 
 |  |  | </resources> | 
 
 |  |  | 
 |  |  | #!/usr/bin/env sh | 
 |  |  | #!/bin/sh | 
 |  |  |  | 
 |  |  | # | 
 |  |  | # Copyright 2015 the original author or authors. | 
 |  |  | # Copyright © 2015-2021 the original authors. | 
 |  |  | # | 
 |  |  | # Licensed under the Apache License, Version 2.0 (the "License"); | 
 |  |  | # you may not use this file except in compliance with the License. | 
 |  |  | 
 |  |  | # | 
 |  |  |  | 
 |  |  | ############################################################################## | 
 |  |  | ## | 
 |  |  | ##  Gradle start up script for UN*X | 
 |  |  | ## | 
 |  |  | # | 
 |  |  | #   Gradle start up script for POSIX generated by Gradle. | 
 |  |  | # | 
 |  |  | #   Important for running: | 
 |  |  | # | 
 |  |  | #   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is | 
 |  |  | #       noncompliant, but you have some other compliant shell such as ksh or | 
 |  |  | #       bash, then to run this script, type that shell name before the whole | 
 |  |  | #       command line, like: | 
 |  |  | # | 
 |  |  | #           ksh Gradle | 
 |  |  | # | 
 |  |  | #       Busybox and similar reduced shells will NOT work, because this script | 
 |  |  | #       requires all of these POSIX shell features: | 
 |  |  | #         * functions; | 
 |  |  | #         * expansions «$var», «${var}», «${var:-default}», «${var+SET}», | 
 |  |  | #           «${var#prefix}», «${var%suffix}», and «$( cmd )»; | 
 |  |  | #         * compound commands having a testable exit status, especially «case»; | 
 |  |  | #         * various built-in commands including «command», «set», and «ulimit». | 
 |  |  | # | 
 |  |  | #   Important for patching: | 
 |  |  | # | 
 |  |  | #   (2) This script targets any POSIX shell, so it avoids extensions provided | 
 |  |  | #       by Bash, Ksh, etc; in particular arrays are avoided. | 
 |  |  | # | 
 |  |  | #       The "traditional" practice of packing multiple parameters into a | 
 |  |  | #       space-separated string is a well documented source of bugs and security | 
 |  |  | #       problems, so this is (mostly) avoided, by progressively accumulating | 
 |  |  | #       options in "$@", and eventually passing that to Java. | 
 |  |  | # | 
 |  |  | #       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, | 
 |  |  | #       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; | 
 |  |  | #       see the in-line comments for details. | 
 |  |  | # | 
 |  |  | #       There are tweaks for specific operating systems such as AIX, CygWin, | 
 |  |  | #       Darwin, MinGW, and NonStop. | 
 |  |  | # | 
 |  |  | #   (3) This script is generated from the Groovy template | 
 |  |  | #       https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt | 
 |  |  | #       within the Gradle project. | 
 |  |  | # | 
 |  |  | #       You can find Gradle at https://github.com/gradle/gradle/. | 
 |  |  | # | 
 |  |  | ############################################################################## | 
 |  |  |  | 
 |  |  | # Attempt to set APP_HOME | 
 |  |  |  | 
 |  |  | # Resolve links: $0 may be a link | 
 |  |  | PRG="$0" | 
 |  |  | # Need this for relative symlinks. | 
 |  |  | while [ -h "$PRG" ] ; do | 
 |  |  |     ls=`ls -ld "$PRG"` | 
 |  |  |     link=`expr "$ls" : '.*-> \(.*\)$'` | 
 |  |  |     if expr "$link" : '/.*' > /dev/null; then | 
 |  |  |         PRG="$link" | 
 |  |  |     else | 
 |  |  |         PRG=`dirname "$PRG"`"/$link" | 
 |  |  |     fi | 
 |  |  | app_path=$0 | 
 |  |  |  | 
 |  |  | # Need this for daisy-chained symlinks. | 
 |  |  | while | 
 |  |  |     APP_HOME=${app_path%"${app_path##*/}"}  # leaves a trailing /; empty if no leading path | 
 |  |  |     [ -h "$app_path" ] | 
 |  |  | do | 
 |  |  |     ls=$( ls -ld "$app_path" ) | 
 |  |  |     link=${ls#*' -> '} | 
 |  |  |     case $link in             #( | 
 |  |  |       /*)   app_path=$link ;; #( | 
 |  |  |       *)    app_path=$APP_HOME$link ;; | 
 |  |  |     esac | 
 |  |  | done | 
 |  |  | SAVED="`pwd`" | 
 |  |  | cd "`dirname \"$PRG\"`/" >/dev/null | 
 |  |  | APP_HOME="`pwd -P`" | 
 |  |  | cd "$SAVED" >/dev/null | 
 |  |  |  | 
 |  |  | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit | 
 |  |  |  | 
 |  |  | APP_NAME="Gradle" | 
 |  |  | APP_BASE_NAME=`basename "$0"` | 
 |  |  | APP_BASE_NAME=${0##*/} | 
 |  |  |  | 
 |  |  | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | 
 |  |  | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' | 
 |  |  |  | 
 |  |  | # Use the maximum available, or set MAX_FD != -1 to use that value. | 
 |  |  | MAX_FD="maximum" | 
 |  |  | MAX_FD=maximum | 
 |  |  |  | 
 |  |  | warn () { | 
 |  |  |     echo "$*" | 
 |  |  | } | 
 |  |  | } >&2 | 
 |  |  |  | 
 |  |  | die () { | 
 |  |  |     echo | 
 |  |  |     echo "$*" | 
 |  |  |     echo | 
 |  |  |     exit 1 | 
 |  |  | } | 
 |  |  | } >&2 | 
 |  |  |  | 
 |  |  | # OS specific support (must be 'true' or 'false'). | 
 |  |  | cygwin=false | 
 |  |  | msys=false | 
 |  |  | darwin=false | 
 |  |  | nonstop=false | 
 |  |  | case "`uname`" in | 
 |  |  |   CYGWIN* ) | 
 |  |  |     cygwin=true | 
 |  |  |     ;; | 
 |  |  |   Darwin* ) | 
 |  |  |     darwin=true | 
 |  |  |     ;; | 
 |  |  |   MINGW* ) | 
 |  |  |     msys=true | 
 |  |  |     ;; | 
 |  |  |   NONSTOP* ) | 
 |  |  |     nonstop=true | 
 |  |  |     ;; | 
 |  |  | case "$( uname )" in                #( | 
 |  |  |   CYGWIN* )         cygwin=true  ;; #( | 
 |  |  |   Darwin* )         darwin=true  ;; #( | 
 |  |  |   MSYS* | MINGW* )  msys=true    ;; #( | 
 |  |  |   NONSTOP* )        nonstop=true ;; | 
 |  |  | esac | 
 |  |  |  | 
 |  |  | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | 
 |  |  | 
 |  |  | if [ -n "$JAVA_HOME" ] ; then | 
 |  |  |     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | 
 |  |  |         # IBM's JDK on AIX uses strange locations for the executables | 
 |  |  |         JAVACMD="$JAVA_HOME/jre/sh/java" | 
 |  |  |         JAVACMD=$JAVA_HOME/jre/sh/java | 
 |  |  |     else | 
 |  |  |         JAVACMD="$JAVA_HOME/bin/java" | 
 |  |  |         JAVACMD=$JAVA_HOME/bin/java | 
 |  |  |     fi | 
 |  |  |     if [ ! -x "$JAVACMD" ] ; then | 
 |  |  |         die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | 
 |  |  | 
 |  |  | location of your Java installation." | 
 |  |  |     fi | 
 |  |  | else | 
 |  |  |     JAVACMD="java" | 
 |  |  |     JAVACMD=java | 
 |  |  |     which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | 
 |  |  |  | 
 |  |  | Please set the JAVA_HOME variable in your environment to match the | 
 |  |  | 
 |  |  | fi | 
 |  |  |  | 
 |  |  | # Increase the maximum file descriptors if we can. | 
 |  |  | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then | 
 |  |  |     MAX_FD_LIMIT=`ulimit -H -n` | 
 |  |  |     if [ $? -eq 0 ] ; then | 
 |  |  |         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | 
 |  |  |             MAX_FD="$MAX_FD_LIMIT" | 
 |  |  |         fi | 
 |  |  |         ulimit -n $MAX_FD | 
 |  |  |         if [ $? -ne 0 ] ; then | 
 |  |  |             warn "Could not set maximum file descriptor limit: $MAX_FD" | 
 |  |  |         fi | 
 |  |  |     else | 
 |  |  |         warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | 
 |  |  |     fi | 
 |  |  | fi | 
 |  |  |  | 
 |  |  | # For Darwin, add options to specify how the application appears in the dock | 
 |  |  | if $darwin; then | 
 |  |  |     GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | 
 |  |  | fi | 
 |  |  |  | 
 |  |  | # For Cygwin or MSYS, switch paths to Windows format before running java | 
 |  |  | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then | 
 |  |  |     APP_HOME=`cygpath --path --mixed "$APP_HOME"` | 
 |  |  |     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | 
 |  |  |  | 
 |  |  |     JAVACMD=`cygpath --unix "$JAVACMD"` | 
 |  |  |  | 
 |  |  |     # We build the pattern for arguments to be converted via cygpath | 
 |  |  |     ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | 
 |  |  |     SEP="" | 
 |  |  |     for dir in $ROOTDIRSRAW ; do | 
 |  |  |         ROOTDIRS="$ROOTDIRS$SEP$dir" | 
 |  |  |         SEP="|" | 
 |  |  |     done | 
 |  |  |     OURCYGPATTERN="(^($ROOTDIRS))" | 
 |  |  |     # Add a user-defined pattern to the cygpath arguments | 
 |  |  |     if [ "$GRADLE_CYGPATTERN" != "" ] ; then | 
 |  |  |         OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | 
 |  |  |     fi | 
 |  |  |     # Now convert the arguments - kludge to limit ourselves to /bin/sh | 
 |  |  |     i=0 | 
 |  |  |     for arg in "$@" ; do | 
 |  |  |         CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | 
 |  |  |         CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option | 
 |  |  |  | 
 |  |  |         if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition | 
 |  |  |             eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | 
 |  |  |         else | 
 |  |  |             eval `echo args$i`="\"$arg\"" | 
 |  |  |         fi | 
 |  |  |         i=`expr $i + 1` | 
 |  |  |     done | 
 |  |  |     case $i in | 
 |  |  |         0) set -- ;; | 
 |  |  |         1) set -- "$args0" ;; | 
 |  |  |         2) set -- "$args0" "$args1" ;; | 
 |  |  |         3) set -- "$args0" "$args1" "$args2" ;; | 
 |  |  |         4) set -- "$args0" "$args1" "$args2" "$args3" ;; | 
 |  |  |         5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | 
 |  |  |         6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | 
 |  |  |         7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | 
 |  |  |         8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | 
 |  |  |         9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | 
 |  |  | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then | 
 |  |  |     case $MAX_FD in #( | 
 |  |  |       max*) | 
 |  |  |         MAX_FD=$( ulimit -H -n ) || | 
 |  |  |             warn "Could not query maximum file descriptor limit" | 
 |  |  |     esac | 
 |  |  |     case $MAX_FD in  #( | 
 |  |  |       '' | soft) :;; #( | 
 |  |  |       *) | 
 |  |  |         ulimit -n "$MAX_FD" || | 
 |  |  |             warn "Could not set maximum file descriptor limit to $MAX_FD" | 
 |  |  |     esac | 
 |  |  | fi | 
 |  |  |  | 
 |  |  | # Escape application args | 
 |  |  | save () { | 
 |  |  |     for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done | 
 |  |  |     echo " " | 
 |  |  | } | 
 |  |  | APP_ARGS=`save "$@"` | 
 |  |  | # Collect all arguments for the java command, stacking in reverse order: | 
 |  |  | #   * args from the command line | 
 |  |  | #   * the main class name | 
 |  |  | #   * -classpath | 
 |  |  | #   * -D...appname settings | 
 |  |  | #   * --module-path (only if needed) | 
 |  |  | #   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. | 
 |  |  |  | 
 |  |  | # Collect all arguments for the java command, following the shell quoting and substitution rules | 
 |  |  | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" | 
 |  |  | # For Cygwin or MSYS, switch paths to Windows format before running java | 
 |  |  | if "$cygwin" || "$msys" ; then | 
 |  |  |     APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) | 
 |  |  |     CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) | 
 |  |  |  | 
 |  |  |     JAVACMD=$( cygpath --unix "$JAVACMD" ) | 
 |  |  |  | 
 |  |  |     # Now convert the arguments - kludge to limit ourselves to /bin/sh | 
 |  |  |     for arg do | 
 |  |  |         if | 
 |  |  |             case $arg in                                #( | 
 |  |  |               -*)   false ;;                            # don't mess with options #( | 
 |  |  |               /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath | 
 |  |  |                     [ -e "$t" ] ;;                      #( | 
 |  |  |               *)    false ;; | 
 |  |  |             esac | 
 |  |  |         then | 
 |  |  |             arg=$( cygpath --path --ignore --mixed "$arg" ) | 
 |  |  |         fi | 
 |  |  |         # Roll the args list around exactly as many times as the number of | 
 |  |  |         # args, so each arg winds up back in the position where it started, but | 
 |  |  |         # possibly modified. | 
 |  |  |         # | 
 |  |  |         # NB: a `for` loop captures its iteration list before it begins, so | 
 |  |  |         # changing the positional parameters here affects neither the number of | 
 |  |  |         # iterations, nor the values presented in `arg`. | 
 |  |  |         shift                   # remove old arg | 
 |  |  |         set -- "$@" "$arg"      # push replacement arg | 
 |  |  |     done | 
 |  |  | fi | 
 |  |  |  | 
 |  |  | # Collect all arguments for the java command; | 
 |  |  | #   * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of | 
 |  |  | #     shell script including quotes and variable substitutions, so put them in | 
 |  |  | #     double quotes to make sure that they get re-expanded; and | 
 |  |  | #   * put everything else in single quotes, so that it's not re-expanded. | 
 |  |  |  | 
 |  |  | set -- \ | 
 |  |  |         "-Dorg.gradle.appname=$APP_BASE_NAME" \ | 
 |  |  |         -classpath "$CLASSPATH" \ | 
 |  |  |         org.gradle.wrapper.GradleWrapperMain \ | 
 |  |  |         "$@" | 
 |  |  |  | 
 |  |  | # Stop when "xargs" is not available. | 
 |  |  | if ! command -v xargs >/dev/null 2>&1 | 
 |  |  | then | 
 |  |  |     die "xargs is not available" | 
 |  |  | fi | 
 |  |  |  | 
 |  |  | # Use "xargs" to parse quoted args. | 
 |  |  | # | 
 |  |  | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. | 
 |  |  | # | 
 |  |  | # In Bash we could simply go: | 
 |  |  | # | 
 |  |  | #   readarray ARGS < <( xargs -n1 <<<"$var" ) && | 
 |  |  | #   set -- "${ARGS[@]}" "$@" | 
 |  |  | # | 
 |  |  | # but POSIX shell has neither arrays nor command substitution, so instead we | 
 |  |  | # post-process each arg (as a line of input to sed) to backslash-escape any | 
 |  |  | # character that might be a shell metacharacter, then use eval to reverse | 
 |  |  | # that process (while maintaining the separation between arguments), and wrap | 
 |  |  | # the whole thing up as a single "set" statement. | 
 |  |  | # | 
 |  |  | # This will of course break if any of these variables contains a newline or | 
 |  |  | # an unmatched quote. | 
 |  |  | # | 
 |  |  |  | 
 |  |  | eval "set -- $( | 
 |  |  |         printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | | 
 |  |  |         xargs -n1 | | 
 |  |  |         sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | | 
 |  |  |         tr '\n' ' ' | 
 |  |  |     )" '"$@"' | 
 |  |  |  | 
 |  |  | exec "$JAVACMD" "$@" | 
 
 |  |  | 
 |  |  | @rem limitations under the License. | 
 |  |  | @rem | 
 |  |  |  | 
 |  |  | @if "%DEBUG%" == "" @echo off | 
 |  |  | @if "%DEBUG%"=="" @echo off | 
 |  |  | @rem ########################################################################## | 
 |  |  | @rem | 
 |  |  | @rem  Gradle startup script for Windows | 
 |  |  | 
 |  |  | if "%OS%"=="Windows_NT" setlocal | 
 |  |  |  | 
 |  |  | set DIRNAME=%~dp0 | 
 |  |  | if "%DIRNAME%" == "" set DIRNAME=. | 
 |  |  | if "%DIRNAME%"=="" set DIRNAME=. | 
 |  |  | set APP_BASE_NAME=%~n0 | 
 |  |  | set APP_HOME=%DIRNAME% | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  | set JAVA_EXE=java.exe | 
 |  |  | %JAVA_EXE% -version >NUL 2>&1 | 
 |  |  | if "%ERRORLEVEL%" == "0" goto execute | 
 |  |  | if %ERRORLEVEL% equ 0 goto execute | 
 |  |  |  | 
 |  |  | echo. | 
 |  |  | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | 
 |  |  | 
 |  |  |  | 
 |  |  | :end | 
 |  |  | @rem End local scope for the variables with windows NT shell | 
 |  |  | if "%ERRORLEVEL%"=="0" goto mainEnd | 
 |  |  | if %ERRORLEVEL% equ 0 goto mainEnd | 
 |  |  |  | 
 |  |  | :fail | 
 |  |  | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | 
 |  |  | rem the _cmd.exe /c_ return code! | 
 |  |  | if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | 
 |  |  | exit /b 1 | 
 |  |  | set EXIT_CODE=%ERRORLEVEL% | 
 |  |  | if %EXIT_CODE% equ 0 set EXIT_CODE=1 | 
 |  |  | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% | 
 |  |  | exit /b %EXIT_CODE% | 
 |  |  |  | 
 |  |  | :mainEnd | 
 |  |  | if "%OS%"=="Windows_NT" endlocal | 
 
 |  |  | 
 |  |  | # Location of the SDK. This is only used by Gradle. | 
 |  |  | # For customization when using a Version Control System, please read the | 
 |  |  | # header note. | 
 |  |  | #Sat Nov 11 20:12:34 CST 2023 | 
 |  |  | sdk.dir=D\:\\AndroidStudio\\sdk | 
 |  |  | #Thu Nov 30 15:06:34 CST 2023 | 
 |  |  | sdk.dir=D\:\\sdk |