1.修改架构将河南版本提取成library
2.修复密码修改的bug
3.添加登录页选择模块功能
3 文件已复制
61个文件已修改
3个文件已删除
8 文件已重命名
7个文件已添加
| | |
| | | |
| | | implementation project(':henanlibrary') |
| | | implementation project(':baselibrary') |
| | | implementation project(':qihealonelibrary') |
| | | |
| | | implementation 'com.tencent.bugly:crashreport:4.1.9.3' |
| | | // 处理图片 |
| | |
| | | implementation 'androidx.recyclerview:recyclerview:1.2.0'//经典刷新头 |
| | | |
| | | implementation 'io.reactivex.rxjava3:rxandroid:3.0.0' |
| | | |
| | | |
| | | } |
| | |
| | | package com.dayu.recharge; |
| | | |
| | | import android.app.Application; |
| | | import android.text.TextUtils; |
| | | |
| | | import com.dayu.baselibrary.BaseApplication; |
| | | import com.dayu.baselibrary.utils.AidlUtil; |
| | | import com.dayu.baselibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.baselibrary.dbbean.LibraryBean; |
| | | import com.dayu.baselibrary.utils.BaseCommon; |
| | | import com.dayu.henanlibrary.HeNanApplication; |
| | | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dbBean.AdminDataBean; |
| | | import com.dayu.qihealonelibrary.QHAloneApplication; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | public class MyApplication extends Application { |
| | | public static String TAG = "MyApplication"; |
| | | |
| | | //当前加载的library模块 //0:河南版本,1齐河单机版 |
| | | public int libraryType = BaseCommon.NoLibrary; |
| | | public static MyApplication myApplication; |
| | | |
| | | @Override |
| | | public void onCreate() { |
| | | super.onCreate(); |
| | | myApplication = this; |
| | | initApplication(); |
| | | BaseApplication.getInstance().onCreat(this); |
| | | HeNanApplication.getInstance().application = this; |
| | | CrashReport.initCrashReport(getApplicationContext(), "45551598b8", true); |
| | | } |
| | | |
| | | |
| | | public void initApplication() { |
| | | //兼容老版的,认为有addressCode并且LibraryBean为null的为河南版本的 |
| | | AdminDataBean adminDataBean = HNBaseDaoSingleton.getInstance(this).adminDao().findFirst(); |
| | | LibraryBean libraryBean = BaseDaoSingleton.getInstance(this).libraryDao().findFirst(); |
| | | if (adminDataBean != null && libraryBean == null && !TextUtils.isEmpty(adminDataBean.addressCode)) { |
| | | libraryType = BaseCommon.HeNanLibrary; |
| | | HeNanApplication.getInstance().application = this; |
| | | } else if (libraryBean != null) { |
| | | libraryType = libraryBean.getType(); |
| | | switch (libraryType) { |
| | | case BaseCommon.HeNanLibrary: |
| | | HeNanApplication.getInstance().application = this; |
| | | break; |
| | | case BaseCommon.QHAloneLibrary: |
| | | QHAloneApplication.getInstance().application = this; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.dayu.baselibrary.activity.BaseActivity; |
| | | import com.dayu.baselibrary.utils.BaseCommon; |
| | | import com.dayu.baselibrary.utils.TipUtil; |
| | | import com.dayu.baselibrary.utils.WSMD5; |
| | | import com.dayu.baselibrary.view.LibraryDialog; |
| | | import com.dayu.henanlibrary.HeNanApplication; |
| | | import com.dayu.henanlibrary.activity.HomeActivity; |
| | | import com.dayu.henanlibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; |
| | | |
| | | import com.dayu.henanlibrary.dbBean.PassWordBean; |
| | | |
| | | import com.dayu.recharge.MyApplication; |
| | | import com.dayu.recharge.databinding.ActivityLoginBinding; |
| | | import com.hjq.permissions.OnPermissionCallback; |
| | | import com.hjq.permissions.Permission; |
| | |
| | | super.onCreate(savedInstanceState); |
| | | binding = ActivityLoginBinding.inflate(LayoutInflater.from(this)); |
| | | setContentView(binding.getRoot()); |
| | | getPermission(); |
| | | |
| | | initView(); |
| | | } |
| | | |
| | | private void initView() { |
| | | binding.loginBtn.setOnClickListener(v -> { |
| | | String psStr = binding.loginPw.getText().toString(); |
| | | if (MyApplication.myApplication.libraryType == BaseCommon.NoLibrary) { |
| | | LibraryDialog dialog = new LibraryDialog(this, type -> { |
| | | if (type == BaseCommon.HeNanLibrary) { |
| | | getHNPermission(); |
| | | } else if (type == BaseCommon.QHAloneLibrary) { |
| | | getQHAlonePermission(); |
| | | } |
| | | MyApplication.myApplication.initApplication(); |
| | | }); |
| | | dialog.show(); |
| | | //没有选择版本先选择版本 |
| | | return; |
| | | } |
| | | if (TextUtils.isEmpty(psStr)) { |
| | | TipUtil.show("请输入密码"); |
| | | return; |
| | | } |
| | | if ((passWordBean == null && psStr.equals("123456")) |
| | | || passWordBean != null && passWordBean.getPassWord().equalsIgnoreCase(WSMD5.getMD5Str(psStr))) { |
| | | startActivity(new Intent(LoginActivity.this, HomeActivity.class)); |
| | | if (MyApplication.myApplication.libraryType == 0) { |
| | | startActivity(new Intent(LoginActivity.this, com.dayu.henanlibrary.activity.HomeActivity.class)); |
| | | } else if (MyApplication.myApplication.libraryType == 1) { |
| | | startActivity(new Intent(LoginActivity.this, com.dayu.qihealonelibrary.activity.HomeActivity.class)); |
| | | } |
| | | LoginActivity.this.finish(); |
| | | } else { |
| | | Toast.makeText(LoginActivity.this, "密码错误", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | }); |
| | | try { |
| | | PackageInfo packageInfo=getPackageManager().getPackageInfo(getPackageName(), 0); |
| | | binding.versionName.setText("当前版本:V"+packageInfo.versionName); |
| | | PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); |
| | | binding.versionName.setText("当前版本:V" + packageInfo.versionName); |
| | | } catch (PackageManager.NameNotFoundException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | private void getPermission() { |
| | | /** |
| | | * 河南版的获取权限 |
| | | */ |
| | | private void getHNPermission() { |
| | | try { |
| | | |
| | | |
| | |
| | | |
| | | HeNanApplication.getInstance().initEasySocket(false, null); |
| | | try { |
| | | File file = new File(BaseDaoSingleton.SqlitePath); |
| | | File file = new File(HNBaseDaoSingleton.SqlitePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | passWordBean = BaseDaoSingleton.getInstance(LoginActivity.this).loginPsDao().findFirst(); |
| | | passWordBean = HNBaseDaoSingleton.getInstance(LoginActivity.this).loginPsDao().findFirst(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private void getQHAlonePermission() { |
| | | try { |
| | | XXPermissions.with(this) |
| | | .permission( |
| | | Permission.WRITE_EXTERNAL_STORAGE) |
| | | .request(new OnPermissionCallback() { |
| | | |
| | | @Override |
| | | public void onGranted(@NonNull List<String> permissions, boolean allGranted) { |
| | | if (allGranted) { |
| | | if (allGranted) {//所有申请的权限都已通过 |
| | | |
| | | try { |
| | | File file = new File(HNBaseDaoSingleton.SqlitePath); |
| | | if (!file.exists()) { |
| | | file.mkdirs(); |
| | | } |
| | | passWordBean = HNBaseDaoSingleton.getInstance(LoginActivity.this).loginPsDao().findFirst(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onDenied(@NonNull List<String> permissions, boolean doNotAskAgain) { |
| | | if (doNotAskAgain) { |
| | | // 如果是被永久拒绝就跳转到应用权限系统设置页面 |
| | | } else { |
| | | // toast("获取录音和日历权限失败"); |
| | | } |
| | | } |
| | | }); |
| | | } catch ( |
| | | Throwable e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | implementation "androidx.room:room-ktx:2.3.0" |
| | | runtimeOnly("androidx.room:room-common:2.3.0") |
| | | annotationProcessor "androidx.room:room-compiler:2.3.0" |
| | | |
| | | //权限申请 |
| | | compileOnly 'com.github.getActivity:XXPermissions:18.5' |
| | | } |
| | |
| | | package com.dayu.baselibrary; |
| | | |
| | | import android.app.Application; |
| | | import android.content.Context; |
| | | |
| | | import com.dayu.baselibrary.utils.AidlUtil; |
| | | |
| | |
| | | |
| | | |
| | | //初始化打印相关服务 |
| | | public void onCreat(Context context) { |
| | | public void onCreat(Application context) { |
| | | application = context; |
| | | AidlUtil.getInstance().connectPrinterService(context); |
| | | } |
| | | |
New file |
| | |
| | | package com.dayu.baselibrary.dao; |
| | | |
| | | import androidx.room.Database; |
| | | import androidx.room.RoomDatabase; |
| | | |
| | | import com.dayu.baselibrary.dbbean.LibraryBean; |
| | | |
| | | |
| | | /** |
| | | * Copyright (C), 2023, |
| | | * Author: zuo |
| | | * Date: 2023-11-05 16:23 |
| | | * Description: |
| | | */ |
| | | @Database(entities = {LibraryBean.class}, version = AppDatabase.version, exportSchema = false) |
| | | public abstract class AppDatabase extends RoomDatabase { |
| | | |
| | | public final static int version = 3; |
| | | |
| | | |
| | | public abstract LibraryDao libraryDao(); |
| | | |
| | | |
| | | } |
File was renamed from henanlibrary/src/main/java/com/dayu/henanlibrary/dao/BaseDaoSingleton.java |
| | |
| | | package com.dayu.henanlibrary.dao; |
| | | package com.dayu.baselibrary.dao; |
| | | |
| | | import android.content.Context; |
| | | import android.os.Environment; |
| | |
| | | baseDao = Room.databaseBuilder( |
| | | context, |
| | | AppDatabase.class, |
| | | SqlitePath + "ConfigurationData" |
| | | ).allowMainThreadQueries().build(); |
| | | SqlitePath + "BaseData" |
| | | ).allowMainThreadQueries().fallbackToDestructiveMigration().build(); |
| | | } |
| | | return baseDao; |
| | | } |
| | |
| | | AsynchBaseDao = Room.databaseBuilder( |
| | | context, |
| | | AppDatabase.class, |
| | | SqlitePath + "ConfigurationData" |
| | | SqlitePath + "BaseData" |
| | | ).build(); |
| | | } |
| | | return AsynchBaseDao; |
| | |
| | | //0:河南版本,1齐河单机版 |
| | | private int type; |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | } |
New file |
| | |
| | | package com.dayu.baselibrary.utils; |
| | | |
| | | /** |
| | | * author: zuo |
| | | * Date: 2024-04-29 |
| | | * Time: 15:09 |
| | | * 备注:公共参数 |
| | | */ |
| | | public class BaseCommon { |
| | | |
| | | /** |
| | | * 没有选择模块 |
| | | */ |
| | | public final static int NoLibrary = -1; |
| | | public final static int HeNanLibrary = 0; |
| | | public final static int QHAloneLibrary = 1; |
| | | |
| | | |
| | | } |
File was renamed from henanlibrary/src/main/java/com/dayu/henanlibrary/view/ConfirmDialog.java |
| | |
| | | package com.dayu.henanlibrary.view; |
| | | package com.dayu.baselibrary.view; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.widget.Button; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.dayu.henanlibrary.R; |
| | | import com.dayu.baselibrary.R; |
| | | |
| | | |
| | | /** |
| | | * author: zuo |
| | |
| | | getWindow().setGravity(Gravity.CENTER); |
| | | setContentView(R.layout.confirm_dialog); |
| | | setCanceledOnTouchOutside(false); |
| | | Button cannel = (Button) this.findViewById(R.id.confirm_cancel); |
| | | Button ok = (Button) this.findViewById(R.id.confirm_ok); |
| | | TextView cannel = (TextView) this.findViewById(R.id.confirm_cancel); |
| | | TextView ok = (TextView) this.findViewById(R.id.confirm_ok); |
| | | cannel.setOnClickListener(v -> ConfirmDialog.this.dismiss()); |
| | | if (mListner == null) { |
| | | ok.setOnClickListener((View v) -> { |
New file |
| | |
| | | package com.dayu.baselibrary.view; |
| | | |
| | | import android.app.Activity; |
| | | import android.app.Dialog; |
| | | import android.content.Intent; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.WindowManager; |
| | | import android.widget.RadioGroup; |
| | | import android.widget.TextView; |
| | | |
| | | import com.dayu.baselibrary.R; |
| | | import com.dayu.baselibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.baselibrary.dao.LibraryDao; |
| | | import com.dayu.baselibrary.dbbean.LibraryBean; |
| | | |
| | | /** |
| | | * author: zuo |
| | | * Date: 2024-04-26 |
| | | * Time: 16:18 |
| | | * 备注:选择模块 |
| | | */ |
| | | public class LibraryDialog extends Dialog { |
| | | |
| | | Intent intent; |
| | | Activity mContext; |
| | | LibraryBean libraryBean; |
| | | LibraryDao libraryDao; |
| | | boolean ischose = false; |
| | | |
| | | libraryBack mLibraryBack; |
| | | int type; |
| | | |
| | | public LibraryDialog(Activity context, libraryBack libraryBack) { |
| | | super(context, com.dayu.baselibrary.R.style.ws_pay_showSelfDialog); |
| | | this.intent = intent; |
| | | mContext = context; |
| | | mLibraryBack = libraryBack; |
| | | initView(); |
| | | } |
| | | |
| | | private void initView() { |
| | | getWindow().setGravity(Gravity.CENTER); |
| | | setContentView(R.layout.library_dialog); |
| | | setCanceledOnTouchOutside(false); |
| | | RadioGroup radioGroup = findViewById(R.id.radioLibrary); |
| | | libraryDao = BaseDaoSingleton.getInstance(mContext).libraryDao(); |
| | | libraryBean = libraryDao.findFirst(); |
| | | if (libraryBean == null) { |
| | | libraryBean = new LibraryBean(); |
| | | } |
| | | |
| | | radioGroup.setOnCheckedChangeListener((group, checkedId) -> { |
| | | ischose = true; |
| | | // 当选中的RadioButton发生变化时调用 |
| | | if (checkedId == R.id.henanLibrary) { |
| | | type = 0; |
| | | libraryBean.setType(type); |
| | | } else if (checkedId == R.id.qhAloneLibrary) {// 处理选中Option 2的逻辑 |
| | | type = 1; |
| | | libraryBean.setType(type); |
| | | } |
| | | }); |
| | | TextView okBtn = findViewById(R.id.ok); |
| | | okBtn.setOnClickListener(v -> { |
| | | if (ischose) { |
| | | libraryDao.insert(libraryBean); |
| | | mLibraryBack.listener(type); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void show() { |
| | | |
| | | super.show(); |
| | | /** |
| | | * 设置宽度全屏,要设置在show的后面 |
| | | */ |
| | | WindowManager.LayoutParams layoutParams = getWindow().getAttributes(); |
| | | layoutParams.gravity = Gravity.CENTER; |
| | | layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; |
| | | layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; |
| | | getWindow().getDecorView().setPadding(0, 0, 0, 0); |
| | | getWindow().setAttributes(layoutParams); |
| | | } |
| | | |
| | | |
| | | public interface libraryBack { |
| | | void listener(int type); |
| | | } |
| | | } |
| | |
| | | import android.app.Dialog; |
| | | import android.content.Intent; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.WindowManager; |
| | | import android.widget.EditText; |
| | |
| | | setCanceledOnTouchOutside(false); |
| | | TextView textView = (TextView) this.findViewById(R.id.pw_ok); |
| | | final EditText editText = (EditText) this.findViewById(R.id.pw_et); |
| | | textView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | try { |
| | | //密码为dyjsczgl@2024 |
| | | if (WSMD5.getMD5Str(editText.getText().toString()).equalsIgnoreCase("c42da502706e47c7962cb539cbc87321")) { |
| | | mContext.startActivity(intent); |
| | | PassWordDialog.this.dismiss(); |
| | | } else { |
| | | TipUtil.show(mContext, "密码错误"); |
| | | } |
| | | } catch (Exception e) { |
| | | CrashReport.postCatchedException(e); |
| | | e.printStackTrace(); |
| | | textView.setOnClickListener(v -> { |
| | | try { |
| | | //密码为dyjsczgl@2024 |
| | | if (WSMD5.getMD5Str(editText.getText().toString()).equalsIgnoreCase("c42da502706e47c7962cb539cbc87321")) { |
| | | mContext.startActivity(intent); |
| | | PassWordDialog.this.dismiss(); |
| | | } else { |
| | | TipUtil.show(mContext, "密码错误"); |
| | | } |
| | | } catch (Exception e) { |
| | | CrashReport.postCatchedException(e); |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | android:startColor="#ffffff" /> |
| | | <!-- 设置四个角的角度 --> |
| | | <corners |
| | | android:bottomLeftRadius="15dp" |
| | | android:bottomRightRadius="15dp" |
| | | android:topLeftRadius="15dp" |
| | | android:topRightRadius="15dp" /> |
| | | android:bottomLeftRadius="5dp" |
| | | android:bottomRightRadius="5dp" |
| | | android:topLeftRadius="5dp" |
| | | android:topRightRadius="5dp" /> |
| | | <!-- 设置padding --> |
| | | |
| | | </shape> |
copy from henanlibrary/src/main/res/drawable/ws_pay_bg_dialog_top_stroke.xml
copy to baselibrary/src/main/res/drawable/editbg_dialog.xml
File was copied from henanlibrary/src/main/res/drawable/ws_pay_bg_dialog_top_stroke.xml |
| | |
| | | <!-- 边缘线的宽度和颜色 --> |
| | | <stroke |
| | | android:width="0px" |
| | | android:color="#ffffff" /> |
| | | android:color="@color/edite_bg" /> |
| | | <!-- |
| | | 中间渐变,角度0从左往右,正值为逆时针,270度为从上到下 |
| | | <gradient |
| | |
| | | <!-- 中间渐变,角度0从左往右,正值为逆时针,270度为从上到下 --> |
| | | <gradient |
| | | android:angle="270" |
| | | android:centerColor="#ffffff" |
| | | android:endColor="#ffffff" |
| | | android:startColor="#ffffff" /> |
| | | android:centerColor="@color/edite_bg" |
| | | android:endColor="@color/edite_bg" |
| | | android:startColor="@color/edite_bg" /> |
| | | <!-- 设置四个角的角度 --> |
| | | <corners |
| | | android:bottomLeftRadius="15dp" |
| | | android:bottomRightRadius="15dp" |
| | | android:topLeftRadius="15dp" |
| | | android:topRightRadius="15dp" /> |
| | | android:bottomLeftRadius="15px" |
| | | android:bottomRightRadius="15px" |
| | | android:topLeftRadius="15px" |
| | | android:topRightRadius="15px" /> |
| | | <!-- 设置padding --> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <item android:drawable="@drawable/radio_select_off" android:state_checked="false" /> |
| | | <item android:drawable="@drawable/radio_select_on" android:state_checked="true" /> |
| | | </selector> |
File was renamed from henanlibrary/src/main/res/drawable/ws_pay_bg_dialog_top_stroke.xml |
| | |
| | | |
| | | <!-- 边缘线的宽度和颜色 --> |
| | | <stroke |
| | | android:width="0px" |
| | | android:color="#ffffff" /> |
| | | android:width="2px" |
| | | android:color="@color/line_bg" /> |
| | | <!-- |
| | | 中间渐变,角度0从左往右,正值为逆时针,270度为从上到下 |
| | | <gradient |
| | |
| | | android:startColor="#ffffff" /> |
| | | <!-- 设置四个角的角度 --> |
| | | <corners |
| | | android:bottomLeftRadius="15dp" |
| | | android:bottomRightRadius="15dp" |
| | | android:topLeftRadius="15dp" |
| | | android:topRightRadius="15dp" /> |
| | | android:bottomLeftRadius="15px" |
| | | android:bottomRightRadius="15px" |
| | | android:topLeftRadius="15px" |
| | | android:topRightRadius="15px" /> |
| | | <!-- 设置padding --> |
| | | |
| | | </shape> |
copy from henanlibrary/src/main/res/drawable/ws_pay_bg_dialog_top_stroke.xml
copy to baselibrary/src/main/res/drawable/radio_select_on.xml
File was copied from henanlibrary/src/main/res/drawable/ws_pay_bg_dialog_top_stroke.xml |
| | |
| | | |
| | | <!-- 边缘线的宽度和颜色 --> |
| | | <stroke |
| | | android:width="0px" |
| | | android:color="#ffffff" /> |
| | | android:width="2px" |
| | | android:color="@color/title_bg" /> |
| | | <!-- |
| | | 中间渐变,角度0从左往右,正值为逆时针,270度为从上到下 |
| | | <gradient |
| | |
| | | --> |
| | | <!-- 中间渐变,角度0从左往右,正值为逆时针,270度为从上到下 --> |
| | | <gradient |
| | | |
| | | android:angle="270" |
| | | android:centerColor="#ffffff" |
| | | android:endColor="#ffffff" |
| | | android:startColor="#ffffff" /> |
| | | android:centerColor="@color/title_bg" |
| | | android:endColor="@color/title_bg" |
| | | android:startColor="@color/title_bg" /> |
| | | <!-- 设置四个角的角度 --> |
| | | <corners |
| | | android:bottomLeftRadius="15dp" |
| | | android:bottomRightRadius="15dp" |
| | | android:topLeftRadius="15dp" |
| | | android:topRightRadius="15dp" /> |
| | | android:bottomLeftRadius="15px" |
| | | android:bottomRightRadius="15px" |
| | | android:topLeftRadius="15px" |
| | | android:topRightRadius="15px" /> |
| | | <!-- 设置padding --> |
| | | |
| | | </shape> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <selector xmlns:android="http://schemas.android.com/apk/res/android"> |
| | | <item android:color="@color/text_color" |
| | | android:state_checked="false" /> |
| | | <item android:color="#ffffff" |
| | | android:state_checked="true" /> |
| | | </selector> |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="#00ffffff" |
| | | android:gravity="center" |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="@dimen/dialog_bg_margin" |
| | | android:background="@drawable/base_bg_dialog_top_stroke" |
| | | android:gravity="center" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:id="@+id/confirm_data" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center" |
| | | android:text="还未写卡!!!\n您确认退出吗?" |
| | | android:textColor="@color/text_color" |
| | | android:textSize="22sp" /> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="2px" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="horizontal"> |
| | | |
| | | <TextView |
| | | android:id="@+id/confirm_cancel" |
| | | android:layout_width="0dp" |
| | | android:layout_height="@dimen/dialog_btn_height" |
| | | android:layout_weight="1" |
| | | android:gravity="center" |
| | | android:text="取 消" |
| | | android:textColor="@color/text_color" |
| | | android:textSize="20sp" /> |
| | | |
| | | <View |
| | | android:layout_width="2px" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/confirm_ok" |
| | | android:layout_width="0dp" |
| | | android:layout_height="@dimen/dialog_btn_height" |
| | | android:layout_weight="1" |
| | | android:gravity="center" |
| | | android:text="确 认" |
| | | android:textColor="@color/dialog_btn" |
| | | android:textSize="20sp" /> |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | </LinearLayout> |
| | | |
| | |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="wrap_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="@dimen/dialog_bg_margin" |
| | | android:background="@drawable/base_bg_dialog_top_stroke" |
| | | android:gravity="center" |
| | | android:orientation="vertical" |
| | | android:padding="20dp"> |
| | | android:orientation="vertical"> |
| | | |
| | | |
| | | <EditText |
| | | android:id="@+id/pw_et" |
| | | android:layout_width="300dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginTop="20dp" |
| | | android:layout_marginRight="20dp" |
| | | android:background="@drawable/editbg_dialog" |
| | | android:hint="请输入信息" |
| | | android:paddingLeft="10dp" |
| | | android:textColor="#000000" /> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="2px" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | |
| | | |
| | | <TextView |
| | | android:id="@+id/pw_cannel" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | |
| | | android:layout_marginTop="20dp" |
| | | android:background="@drawable/base_login_btn" |
| | | android:paddingLeft="15dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="15dp" |
| | | android:paddingBottom="5dp" |
| | | android:text="取消" |
| | | android:layout_width="0dp" |
| | | android:layout_height="@dimen/dialog_btn_height" |
| | | android:layout_weight="1" |
| | | android:gravity="center" |
| | | android:text="取 消" |
| | | android:textColor="@color/text_color" |
| | | android:textSize="20sp" /> |
| | | |
| | | <View |
| | | android:layout_width="2px" |
| | | android:layout_height="match_parent" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/pw_ok" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@drawable/base_login_btn" |
| | | android:paddingLeft="15dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="15dp" |
| | | android:paddingBottom="5dp" |
| | | android:text="确认" |
| | | android:layout_width="0dp" |
| | | android:layout_height="@dimen/dialog_btn_height" |
| | | android:layout_weight="1" |
| | | android:gravity="center" |
| | | android:text="确 认" |
| | | android:textColor="@color/dialog_btn" |
| | | android:textSize="20sp" /> |
| | | |
| | | |
New file |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:background="#00ffffff" |
| | | android:gravity="center" |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="@dimen/dialog_bg_margin" |
| | | android:background="@drawable/base_bg_dialog_top_stroke" |
| | | android:gravity="center" |
| | | android:orientation="vertical"> |
| | | |
| | | <TextView |
| | | android:layout_width="300dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="20dp" |
| | | android:gravity="center" |
| | | android:text="选择版本" |
| | | android:textColor="@color/dialog_btn" |
| | | android:textSize="23sp" |
| | | android:textStyle="bold" /> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="2px" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <RadioGroup |
| | | android:id="@+id/radioLibrary" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content"> |
| | | |
| | | |
| | | <RadioButton |
| | | android:id="@+id/henanLibrary" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="50dp" |
| | | android:layout_marginTop="25dp" |
| | | android:layout_marginRight="50dp" |
| | | android:background="@drawable/radio_select" |
| | | android:button="@null" |
| | | android:gravity="center" |
| | | android:text="河南版本" |
| | | android:textColor="@drawable/radio_text_select" |
| | | android:textSize="20sp" /> |
| | | |
| | | <RadioButton |
| | | android:id="@+id/qhAloneLibrary" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="50dp" |
| | | android:layout_marginTop="25dp" |
| | | android:layout_marginRight="50dp" |
| | | android:background="@drawable/radio_select" |
| | | android:button="@null" |
| | | android:gravity="center" |
| | | android:text="齐河单机版" |
| | | android:textColor="@drawable/radio_text_select" |
| | | android:textSize="20sp" /> |
| | | </RadioGroup> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="2px" |
| | | android:layout_marginTop="35dp" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:gravity="center_horizontal" |
| | | android:orientation="horizontal"> |
| | | |
| | | <TextView |
| | | android:id="@+id/ok" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/dialog_btn_height" |
| | | android:gravity="center" |
| | | android:paddingLeft="15dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="15dp" |
| | | android:paddingBottom="5dp" |
| | | android:text="确 认" |
| | | android:textColor="@color/dialog_btn" |
| | | android:textSize="20sp" /> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | |
| | | </LinearLayout> |
| | | |
| | | </LinearLayout> |
| | | |
| | |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="wrap_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="@dimen/dialog_bg_margin" |
| | | android:background="@drawable/base_bg_dialog_top_stroke" |
| | | android:gravity="center" |
| | | android:orientation="vertical" |
| | | android:padding="20dp"> |
| | | android:orientation="vertical"> |
| | | |
| | | |
| | | <EditText |
| | | android:id="@+id/pw_et" |
| | | android:layout_width="300dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="50dp" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginTop="20dp" |
| | | android:layout_marginRight="20dp" |
| | | android:background="@drawable/editbg_dialog" |
| | | android:hint="请输入管理密码" |
| | | android:textColor="#000000" |
| | | android:inputType="textPassword" /> |
| | | android:inputType="textPassword" |
| | | android:paddingLeft="15dp" |
| | | android:textColor="#000000" /> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="2px" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/pw_ok" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@drawable/base_login_btn" |
| | | android:paddingBottom="5dp" |
| | | android:paddingLeft="15dp" |
| | | android:paddingRight="15dp" |
| | | android:paddingTop="5dp" |
| | | android:text="确认" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/dialog_btn_height" |
| | | android:gravity="center" |
| | | android:text="确 认" |
| | | android:textColor="@color/dialog_btn" |
| | | android:textSize="@dimen/text_size" /> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:orientation="vertical"> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="wrap_content" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="@dimen/dialog_bg_margin" |
| | | android:background="@drawable/base_bg_dialog_top_stroke" |
| | | android:gravity="center" |
| | | android:orientation="vertical" |
| | | android:padding="20dp"> |
| | | android:orientation="vertical"> |
| | | |
| | | |
| | | <TextView |
| | | android:id="@+id/textData" |
| | | android:layout_width="300dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginLeft="20dp" |
| | | android:layout_marginTop="20dp" |
| | | android:layout_marginRight="20dp" |
| | | android:gravity="center" |
| | | android:textColor="#000000" |
| | | android:textColor="@color/text_color" |
| | | android:textSize="20sp" /> |
| | | |
| | | <View |
| | | android:layout_width="match_parent" |
| | | android:layout_height="2px" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@color/line_bg" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | |
| | | |
| | | <TextView |
| | | android:id="@+id/cannel" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="20dp" |
| | | android:background="@drawable/base_login_btn" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/dialog_btn_height" |
| | | android:gravity="center" |
| | | android:paddingLeft="15dp" |
| | | android:paddingTop="5dp" |
| | | android:paddingRight="15dp" |
| | | android:paddingBottom="5dp" |
| | | android:textColor="#000000" |
| | | android:text="确认" |
| | | android:text="确 认" |
| | | android:textColor="@color/dialog_btn" |
| | | android:textSize="20sp" /> |
| | | |
| | | |
| | |
| | | <color name="choose_grey">#cdcdcd</color> |
| | | |
| | | <color name="title_bar_bg">#ffffff</color> |
| | | <color name="line_bg">#DADADA</color> |
| | | <color name="dialog_btn">#1FA9EC</color> |
| | | <color name="edite_bg">#F5F5F5</color> |
| | | <color name="text_color">#696969</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="dialog_btn_height">45dp</dimen> |
| | | <dimen name="dialog_bg_margin">30dp</dimen> |
| | | </resources> |
| | |
| | | # Gradle automatically packages shared libraries with your APK. |
| | | |
| | | add_library( # Sets the name of the library. |
| | | native-lib |
| | | henan-native-lib |
| | | |
| | | # Sets the library as a shared library. |
| | | SHARED |
| | | |
| | | # Provides a relative path to your source file(s). |
| | | src/main/cpp/native-lib.cpp ) |
| | | src/main/cpp/henan-native-lib.cpp ) |
| | | |
| | | # Searches for a specified prebuilt library and stores the path as a |
| | | # variable. Because CMake includes system libraries in the search path by |
| | |
| | | # build script, prebuilt third-party libraries, or system libraries. |
| | | |
| | | target_link_libraries( # Specifies the target library. |
| | | native-lib |
| | | henan-native-lib |
| | | |
| | | # Links the target library to the log library |
| | | # included in the NDK. |
| | |
| | | import com.dayu.baselibrary.utils.CRC8; |
| | | import com.dayu.henanlibrary.utils.DeviceNumberUtils; |
| | | import com.dayu.baselibrary.utils.ToastUtil; |
| | | import com.dayu.henanlibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dbBean.IpBean; |
| | | import com.dayu.henanlibrary.net.CallbackIDFactoryImpl; |
| | | import com.dayu.henanlibrary.net.ScoketMessageProtocol; |
| | |
| | | try { |
| | | // this.createBack = createBack; |
| | | try { |
| | | ipBean = BaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).ipDao().findFirst(); |
| | | ipBean = HNBaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).ipDao().findFirst(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | import com.dayu.baselibrary.view.TitleBar; |
| | | import com.dayu.henanlibrary.R; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; |
| | | |
| | | /** |
| | | * Created by zuoxiao on 2018/12/20. |
| | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | baseDao = BaseDaoSingleton.getInstance(this); |
| | | asynchBaseDao = BaseDaoSingleton.getAsynchInstance(this); |
| | | baseDao = HNBaseDaoSingleton.getInstance(this); |
| | | asynchBaseDao = HNBaseDaoSingleton.getAsynchInstance(this); |
| | | } |
| | | |
| | | |
| | |
| | | import com.dayu.baselibrary.view.ChooseView; |
| | | import com.dayu.henanlibrary.databinding.ActivityIdentyfyingBinding; |
| | | import com.dayu.henanlibrary.dbBean.CardData; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | |
| | | |
| | | switch (data) { |
| | | case "管理卡": |
| | | cardType = MyCommon.MANAGE_CRAD; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.MANAGE_CRAD); |
| | | cardType = CardCommon.MANAGE_CRAD; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.MANAGE_CRAD); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | | binding.electricOldNumber.setText(MyCommon.getDefaultCardData(cardType)); |
| | | binding.electricOldNumber.setText(CardCommon.getDefaultCardData(cardType)); |
| | | } |
| | | break; |
| | | case "清零卡": |
| | | cardType = MyCommon.CLEAN_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CLEAN_CARD_TYPE); |
| | | cardType = CardCommon.CLEAN_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CLEAN_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | | binding.electricOldNumber.setText(MyCommon.getDefaultCardData(cardType)); |
| | | binding.electricOldNumber.setText(CardCommon.getDefaultCardData(cardType)); |
| | | } |
| | | break; |
| | | case "重新注册设备卡": |
| | | cardType = MyCommon.REGISTERED_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.REGISTERED_CARD_TYPE); |
| | | cardType = CardCommon.REGISTERED_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.REGISTERED_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | | binding.electricOldNumber.setText(MyCommon.getDefaultCardData(cardType)); |
| | | binding.electricOldNumber.setText(CardCommon.getDefaultCardData(cardType)); |
| | | } |
| | | break; |
| | | case "删除全部用户卡": |
| | | cardType = MyCommon.CLEAN_ALL_USER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CLEAN_ALL_USER_CARD_TYPE); |
| | | cardType = CardCommon.CLEAN_ALL_USER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CLEAN_ALL_USER_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | | binding.electricOldNumber.setText(MyCommon.getDefaultCardData(cardType)); |
| | | binding.electricOldNumber.setText(CardCommon.getDefaultCardData(cardType)); |
| | | } |
| | | break; |
| | | case "测试卡": |
| | | cardType = MyCommon.TEST_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.TEST_CARD_TYPE); |
| | | cardType = CardCommon.TEST_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.TEST_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | | binding.electricOldNumber.setText(MyCommon.getDefaultCardData(cardType)); |
| | | binding.electricOldNumber.setText(CardCommon.getDefaultCardData(cardType)); |
| | | } |
| | | break; |
| | | case "设备信息卡": |
| | | cardType = MyCommon.CONFIGURATION_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CONFIGURATION_CARD_TYPE); |
| | | cardType = CardCommon.CONFIGURATION_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CONFIGURATION_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | | binding.electricOldNumber.setText(MyCommon.getDefaultCardData(cardType)); |
| | | binding.electricOldNumber.setText(CardCommon.getDefaultCardData(cardType)); |
| | | } |
| | | break; |
| | | case "水泵功率卡": |
| | | cardType = MyCommon.CONFIGURATION_POWER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CONFIGURATION_POWER_CARD_TYPE); |
| | | cardType = CardCommon.CONFIGURATION_POWER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CONFIGURATION_POWER_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | | binding.electricOldNumber.setText(MyCommon.getDefaultCardData(cardType)); |
| | | binding.electricOldNumber.setText(CardCommon.getDefaultCardData(cardType)); |
| | | } |
| | | break; |
| | | } |
| | |
| | | import com.dayu.baselibrary.utils.AidlUtil; |
| | | import com.dayu.baselibrary.utils.CRC8; |
| | | import com.dayu.baselibrary.utils.DateUtil; |
| | | import com.dayu.baselibrary.view.TitleBar; |
| | | import com.dayu.henanlibrary.utils.DeviceNumberUtils; |
| | | import com.dayu.baselibrary.utils.MornyUtil; |
| | | import com.dayu.baselibrary.utils.TipUtil; |
| | | import com.dayu.henanlibrary.HeNanApplication; |
| | | import com.dayu.baselibrary.view.TitleBar; |
| | | import com.dayu.henanlibrary.card.CleanCard; |
| | | import com.dayu.henanlibrary.card.CleanUserCard; |
| | | import com.dayu.henanlibrary.card.ConfigurationPowerCard; |
| | |
| | | import com.dayu.henanlibrary.tools.NFCWriteHelper; |
| | | import com.dayu.henanlibrary.tools.NfcReadHelper; |
| | | import com.dayu.henanlibrary.tools.WriteCardUtils; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.DeviceNumberUtils; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | import com.dayu.henanlibrary.utils.SocketUtil; |
| | | import com.dayu.henanlibrary.view.ConfirmDialog; |
| | | import com.dayu.baselibrary.view.ConfirmDialog; |
| | | import com.dayu.henanlibrary.view.ProgressDialog; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | |
| | | |
| | | String cardType = NfcReadHelper.getInstence(intent, this).getCradType(); |
| | | Log.i("NFCWreatActivity", "cardType=" + cardType); |
| | | if (cardType.equals(MyCommon.USER_CARD_TYPE_1) || |
| | | cardType.equals(MyCommon.USER_CARD_TYPE_2) || |
| | | cardType.equals(MyCommon.USER_CARD_TYPE_3) |
| | | if (cardType.equals(CardCommon.USER_CARD_TYPE_1) || |
| | | cardType.equals(CardCommon.USER_CARD_TYPE_2) || |
| | | cardType.equals(CardCommon.USER_CARD_TYPE_3) |
| | | ) { |
| | | binding.textView.setText("该卡已经写入用户信息,请更换卡片"); |
| | | binding.textView.setTextColor(getResources().getColor(com.dayu.baselibrary.R.color.red)); |
| | |
| | | import com.dayu.henanlibrary.socketBean.BalanceSelecteRequestBean; |
| | | import com.dayu.henanlibrary.tools.NfcReadHelper; |
| | | import com.dayu.henanlibrary.tools.WriteCardUtils; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | import com.dayu.henanlibrary.utils.SocketUtil; |
| | | import com.dayu.henanlibrary.view.ProgressDialog; |
| | | |
| | |
| | | byte cardType = data.get(0)[0]; |
| | | String cardTypeStr = HexUtil.byteToHex(cardType); |
| | | switch (cardTypeStr) { |
| | | case MyCommon.USER_CARD_TYPE_1: |
| | | case MyCommon.USER_CARD_TYPE_2: |
| | | case MyCommon.USER_CARD_TYPE_3: |
| | | case CardCommon.USER_CARD_TYPE_1: |
| | | case CardCommon.USER_CARD_TYPE_2: |
| | | case CardCommon.USER_CARD_TYPE_3: |
| | | userCard = UserCard.getBean(data); |
| | | selectBalance(userCard.getInitPeasantCode()); |
| | | break; |
| | | case MyCommon.MANAGE_CRAD: |
| | | case CardCommon.MANAGE_CRAD: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为管理卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.CLEAN_CARD_TYPE: |
| | | case CardCommon.CLEAN_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为清零卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.REGISTERED_CARD_TYPE: |
| | | case CardCommon.REGISTERED_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为重新注册设备卡"); |
| | | stopAnim(); |
| | | |
| | | break; |
| | | case MyCommon.CLEAN_ALL_USER_CARD_TYPE: |
| | | case CardCommon.CLEAN_ALL_USER_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为删除全部用户卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.DOMAIN_CARD_TYPE: |
| | | case CardCommon.DOMAIN_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为设置域名卡"); |
| | | DomainCard domainCard = DomainCard.toBean(data); |
| | | redCardBinding.readCardDataTV.setText("序号:" + domainCard.getDomainNumber() + "\n" + "域名:" + domainCard.getDomainName() + "\n" + "端口号:" + domainCard.getPort()); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.TEST_CARD_TYPE: |
| | | case CardCommon.TEST_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为测试卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.CONFIGURATION_CARD_TYPE: |
| | | case CardCommon.CONFIGURATION_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为配置设备注册信息卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.CONFIGURATION_POWER_CARD_TYPE: |
| | | case CardCommon.CONFIGURATION_POWER_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前配置水泵功率卡"); |
| | | ConfigurationPowerCard powerCard = ConfigurationPowerCard.toBean(data.get(0)); |
| | |
| | | @Override |
| | | public void error(int code) { |
| | | switch (code) { |
| | | case MyCommon.ERROR_MOVE: |
| | | case CardCommon.ERROR_MOVE: |
| | | stopAnim(); |
| | | TipUtil.show("连接中断,请重新贴合卡片"); |
| | | break; |
| | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.dbBean.CardData; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | if (cardDataBean != null) { |
| | | cardData = cardDataBean.getCardIdentifying(); |
| | | } else { |
| | | cardData= MyCommon.getDefaultCardData(cardType); |
| | | cardData= CardCommon.getDefaultCardData(cardType); |
| | | } |
| | | } catch (Exception e) { |
| | | CrashReport.postCatchedException(e); |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description:清零卡 |
| | | */ |
| | | public class CleanCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.CLEAN_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CLEAN_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description:删除全部用户卡 |
| | | */ |
| | | public class CleanUserCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.CLEAN_ALL_USER_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CLEAN_ALL_USER_CARD_TYPE;//卡类型 |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | public class ConfigurationPowerCard extends BaseCard implements Serializable { |
| | | |
| | | |
| | | public String cardType = MyCommon.CONFIGURATION_POWER_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CONFIGURATION_POWER_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * 为方便现场更换设备时重新注册的问题,配置设备信息卡,首先刷卡,把原设备的注册号和ID号读到卡内,同时卡状态则00修改为FF,再新设备上刷此卡时,注册号和ID号自动写到控制器内,可以直接刷卡使用 |
| | | */ |
| | | public class ConfigureDeviceRegistrationCrad extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.CONFIGURATION_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CONFIGURATION_CARD_TYPE;//卡类型 |
| | | public String cardData = "A0B1C289";//标识码 |
| | | |
| | | public String getCardData() { |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.BcdUtil; |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | public class DomainCard implements Serializable { |
| | | |
| | | |
| | | public String cardType = MyCommon.DOMAIN_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.DOMAIN_CARD_TYPE;//卡类型 |
| | | public String domainNumber;//域名序号 (BCD格式) |
| | | public int domainLength;//域名长度 |
| | | |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description: 管理卡 第1扇区 0块 |
| | | */ |
| | | public class ManageCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.MANAGE_CRAD;//卡类型 |
| | | public String cardType = CardCommon.MANAGE_CRAD;//卡类型 |
| | | // public String cardData = "3668F7A30119";//标识码 |
| | | |
| | | public String getCardData() { |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description:密码卡 |
| | | */ |
| | | public class PassWordCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.PASS_WORD_CRAD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.PASS_WORD_CRAD_TYPE;//卡类型 |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description:重新注册设备卡:用于写用户注册号 |
| | | */ |
| | | public class RegisteredCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.REGISTERED_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.REGISTERED_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.AppDatabase; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description: 测试卡 |
| | | */ |
| | | public class TestCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.TEST_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.TEST_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.BcdUtil; |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Calendar; |
| | |
| | | * Description: 用户卡结构 |
| | | */ |
| | | public class UserCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.USER_CARD_TYPE_1;//写卡标志 A1刷卡开泵前 A8刷卡开泵后 A2叠加充值 |
| | | public String cardType = CardCommon.USER_CARD_TYPE_1;//写卡标志 A1刷卡开泵前 A8刷卡开泵后 A2叠加充值 |
| | | |
| | | public int rechargeTimes;//充值次数 |
| | | |
| | |
| | | * Date: 2023-11-05 16:23 |
| | | * Description: |
| | | */ |
| | | @Database(entities = {CardData.class, DeviceNumber.class, IdentityBean.class, DomainBean.class, ElectricPriceBean.class, IpBean.class, AdminDataBean.class, PassWordBean.class, UserCardBean.class, RechargeBean.class, PowerBean.class}, version = 2, exportSchema = false) |
| | | @Database(entities = {CardData.class, DeviceNumber.class, IdentityBean.class, DomainBean.class, ElectricPriceBean.class, IpBean.class, AdminDataBean.class, PassWordBean.class, UserCardBean.class, RechargeBean.class, PowerBean.class}, version = com.dayu.baselibrary.dao.AppDatabase.version, exportSchema = false) |
| | | public abstract class AppDatabase extends RoomDatabase { |
| | | |
| | | |
copy from henanlibrary/src/main/java/com/dayu/henanlibrary/dao/BaseDaoSingleton.java
copy to henanlibrary/src/main/java/com/dayu/henanlibrary/dao/HNBaseDaoSingleton.java
File was copied from henanlibrary/src/main/java/com/dayu/henanlibrary/dao/BaseDaoSingleton.java |
| | |
| | | import android.content.Context; |
| | | import android.os.Environment; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.room.Room; |
| | | import androidx.room.migration.Migration; |
| | | import androidx.sqlite.db.SupportSQLiteDatabase; |
| | | |
| | | import java.io.File; |
| | | |
| | |
| | | * Date: 2023-11-06 16:58 |
| | | * Description: 创建数据库实例 |
| | | */ |
| | | public class BaseDaoSingleton { |
| | | public class HNBaseDaoSingleton { |
| | | public static AppDatabase baseDao; |
| | | public static AppDatabase AsynchBaseDao; |
| | | public static String SqlitePath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + ".dayu" + File.separator + "data" + File.separator; |
| | |
| | | context, |
| | | AppDatabase.class, |
| | | SqlitePath + "ConfigurationData" |
| | | ).allowMainThreadQueries().build(); |
| | | ).allowMainThreadQueries().addMigrations(migration_2_3).build(); |
| | | } |
| | | return baseDao; |
| | | } |
| | | static Migration migration_2_3 = new Migration(2, 3) { |
| | | @Override |
| | | public void migrate(@NonNull SupportSQLiteDatabase database) { |
| | | // 在此处编写从版本 2 到版本 3 的迁移逻辑 |
| | | // 例如,你可以执行 SQL 命令来修改表结构,迁移数据等操作 |
| | | |
| | | // 如果需要,你还可以执行其他的 SQL 命令来迁移数据等操作 |
| | | } |
| | | }; |
| | | public static AppDatabase getAsynchInstance(Context context) { |
| | | |
| | | if (AsynchBaseDao == null) { |
| | |
| | | |
| | | import com.dayu.henanlibrary.HeNanApplication; |
| | | import com.dayu.henanlibrary.activity.HomeActivity; |
| | | import com.dayu.henanlibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dbBean.AdminDataBean; |
| | | import com.easysocket.EasySocket; |
| | | import com.easysocket.callback.SimpleCallBack; |
| | |
| | | Log.i("SocketActionListener1111", "连接成功"); |
| | | HeNanApplication.myApplication.isConncet = true; |
| | | try { |
| | | AdminDataBean adminData = BaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).adminDao().findFirst(); |
| | | AdminDataBean adminData = HNBaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).adminDao().findFirst(); |
| | | Log.i("SocketActionListener1111", "isDoInitMachine==" + HeNanApplication.myApplication.isDoInitMachine + ""); |
| | | //每次连接成功注册一次设备 |
| | | if (!HeNanApplication.myApplication.isDoInitMachine) { |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.card.UserCard; |
| | | import com.dayu.henanlibrary.utils.MyCommon; |
| | | import com.dayu.henanlibrary.utils.CardCommon; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | |
| | | if (flag) { |
| | | callback.callBack(map); |
| | | } else { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } |
| | | } catch (IOException e) { |
| | | callback.error(MyCommon.ERROR_MOVE); |
| | | callback.error(CardCommon.ERROR_MOVE); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | |
| | | if (flag) { |
| | | callback.callBack(list); |
| | | } else { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } |
| | | } catch (IOException e) { |
| | | callback.error(MyCommon.ERROR_MOVE); |
| | | callback.error(CardCommon.ERROR_MOVE); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | |
| | |
| | | mfc.connect(); |
| | | int count = mfc.getSectorCount(); |
| | | if (a < 0 || a > count - 1) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | return; |
| | | } |
| | | int bCount = mfc.getBlockCountInSector(a); |
| | | if (b < 0 || b > bCount - 1) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | return; |
| | | } |
| | | |
| | |
| | | byte[] data = mfc.readBlock(bIndex + b); |
| | | callback.callBack(data); |
| | | } else { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } |
| | | } catch (IOException e) { |
| | | callback.error(MyCommon.ERROR_MOVE); |
| | | callback.error(CardCommon.ERROR_MOVE); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } finally { |
| | | try { |
| | | mfc.close(); |
File was renamed from henanlibrary/src/main/java/com/dayu/henanlibrary/utils/MyCommon.java |
| | |
| | | * Copyright (C), 2023, |
| | | * Author: zuo |
| | | * Date: 2023-11-06 20:22 |
| | | * Description: |
| | | * Description: 卡类型 |
| | | */ |
| | | public class MyCommon { |
| | | public class CardCommon { |
| | | |
| | | public static final int ERROR = -1; |
| | | //连接中断 提示用户重新连接或提示用户重新靠近卡片 |
| | |
| | | package com.dayu.henanlibrary.utils; |
| | | |
| | | import com.dayu.henanlibrary.HeNanApplication; |
| | | import com.dayu.henanlibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dbBean.DeviceNumber; |
| | | |
| | | /** |
| | |
| | | |
| | | // 获取充值机设备序列号 |
| | | public static String getDeviceNumber() { |
| | | DeviceNumber deviceNumber = BaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).deviceNumberDao().findFirst(); |
| | | DeviceNumber deviceNumber = HNBaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).deviceNumberDao().findFirst(); |
| | | if (deviceNumber != null) { |
| | | return deviceNumber.getDeviceRegistrationNumber(); |
| | | } else { |
| | |
| | | |
| | | // 设置充值机设备序列号 |
| | | public static void setDeviceNumber(String deviceRegistrationNumber) { |
| | | DeviceNumber deviceNumber = BaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).deviceNumberDao().findFirst(); |
| | | DeviceNumber deviceNumber = HNBaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).deviceNumberDao().findFirst(); |
| | | if (deviceNumber != null) { |
| | | deviceNumber.setDeviceRegistrationNumber(deviceRegistrationNumber); |
| | | } else { |
| | | deviceNumber = new DeviceNumber(); |
| | | deviceNumber.setDeviceRegistrationNumber(deviceRegistrationNumber); |
| | | } |
| | | BaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).deviceNumberDao().insert(deviceNumber); |
| | | HNBaseDaoSingleton.getInstance(HeNanApplication.myApplication.application).deviceNumberDao().insert(deviceNumber); |
| | | } |
| | | } |
| | |
| | | import android.os.Message; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.henanlibrary.dao.BaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dao.HNBaseDaoSingleton; |
| | | import com.dayu.henanlibrary.dbBean.AdminDataBean; |
| | | |
| | | import java.io.UnsupportedEncodingException; |
| | |
| | | |
| | | String xuLie = ""; |
| | | try { |
| | | AdminDataBean villageNo = BaseDaoSingleton.getInstance(context).adminDao().findFirst(); |
| | | AdminDataBean villageNo = HNBaseDaoSingleton.getInstance(context).adminDao().findFirst(); |
| | | if (villageNo != null) { |
| | | xuLie = SocketUtil.get10to16LowHigh(Integer.valueOf(villageNo.getSerial()), 6); |
| | | } |
| | |
| | | public static String getOrderId(Context context) { |
| | | String orderId = "000000000001"; |
| | | try { |
| | | AdminDataBean villageNo = BaseDaoSingleton.getInstance(context).adminDao().findFirst(); |
| | | AdminDataBean villageNo = HNBaseDaoSingleton.getInstance(context).adminDao().findFirst(); |
| | | // String orderNo = WSHelper.getInstance(context).get(OrderNo, 1) + ""; |
| | | String orderNo = generateNumber8(); |
| | | if (villageNo != null) { |
| | |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/dimen_title_height" |
| | | android:background="@color/title_bar_bg" |
| | | app:centerText="首页" /> |
| | | app:centerText="河南版首页" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | |
| | | # Gradle automatically packages shared libraries with your APK. |
| | | |
| | | add_library( # Sets the name of the library. |
| | | native-lib |
| | | qihealone-native-lib |
| | | |
| | | # Sets the library as a shared library. |
| | | SHARED |
| | | |
| | | # Provides a relative path to your source file(s). |
| | | src/main/cpp/native-lib.cpp ) |
| | | src/main/cpp/qihealone-native-lib.cpp ) |
| | | |
| | | # Searches for a specified prebuilt library and stores the path as a |
| | | # variable. Because CMake includes system libraries in the search path by |
| | |
| | | # build script, prebuilt third-party libraries, or system libraries. |
| | | |
| | | target_link_libraries( # Specifies the target library. |
| | | native-lib |
| | | qihealone-native-lib |
| | | |
| | | # Links the target library to the log library |
| | | # included in the NDK. |
| | |
| | | package com.dayu.qihealonelibrary; |
| | | |
| | | import android.content.Context; |
| | | |
| | | import androidx.test.platform.app.InstrumentationRegistry; |
| | | import androidx.test.ext.junit.runners.AndroidJUnit4; |
| | | |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | |
| | | import static org.junit.Assert.*; |
| | | |
| | | /** |
| | | * Instrumented test, which will execute on an Android device. |
| | | * |
| | | * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
| | | */ |
| | | @RunWith(AndroidJUnit4.class) |
| | | //@RunWith(AndroidJUnit4.class) |
| | | public class ExampleInstrumentedTest { |
| | | @Test |
| | | public void useAppContext() { |
| | | // Context of the app under test. |
| | | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); |
| | | assertEquals("com.dayu.qihealonelibrary", appContext.getPackageName()); |
| | | } |
| | | // @Test |
| | | // public void useAppContext() { |
| | | // // Context of the app under test. |
| | | // Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); |
| | | // assertEquals("com.dayu.qihealonelibrary", appContext.getPackageName()); |
| | | // } |
| | | } |
| | |
| | | |
| | | <application |
| | | android:allowBackup="true" |
| | | android:icon="@mipmap/ic_launcher" |
| | | android:label="@string/app_name" |
| | | android:roundIcon="@mipmap/ic_launcher_round" |
| | | android:supportsRtl="true" |
| | | /> |
| | | android:supportsRtl="true"> |
| | | |
| | | |
| | | <activity |
| | | android:name="com.dayu.qihealonelibrary.activity.AdminSetupActivity" |
| | | android:exported="true"> |
| | | |
| | | </activity> |
| | | |
| | | <activity |
| | | android:name="com.dayu.qihealonelibrary.activity.HomeActivity" |
| | | android:exported="true"> |
| | | |
| | | </activity> |
| | | <activity |
| | | android:name="com.dayu.qihealonelibrary.activity.NewCardActivity" |
| | | android:exported="true" |
| | | android:launchMode="singleTop" |
| | | android:screenOrientation="portrait"> |
| | | <intent-filter> |
| | | <action android:name="android.nfc.action.TAG_DISCOVERED" /> |
| | | <data android:mimeType="text/plain" /> |
| | | </intent-filter> |
| | | </activity> |
| | | <activity |
| | | android:name="com.dayu.qihealonelibrary.activity.SysActivity" |
| | | android:exported="true"> |
| | | |
| | | </activity> |
| | | |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.PassWordActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.MyActivity" /> |
| | | <activity |
| | | android:name="com.dayu.qihealonelibrary.activity.RechargeActivity" |
| | | android:exported="true" |
| | | android:launchMode="singleTop"> |
| | | <intent-filter> |
| | | <action android:name="android.nfc.action.TAG_DISCOVERED" /> |
| | | <data android:mimeType="text/plain" /> |
| | | </intent-filter> |
| | | </activity> |
| | | |
| | | <activity |
| | | android:name="com.dayu.qihealonelibrary.activity.ReadCardAcitivy" |
| | | android:exported="true" |
| | | android:launchMode="singleTop"> |
| | | <intent-filter> |
| | | <action android:name="android.nfc.action.ACTION_NDEF_DISCOVERED" /> |
| | | <category android:name="android.intent.category.DEFAULT" /> |
| | | <data android:mimeType="text/plain" /> |
| | | </intent-filter> |
| | | </activity> |
| | | <activity |
| | | android:name="com.dayu.qihealonelibrary.activity.NFCWreatActivity" |
| | | android:exported="true" |
| | | android:launchMode="singleTop"> |
| | | <intent-filter> |
| | | <action android:name="android.nfc.action.TAG_DISCOVERED" /> |
| | | <data android:mimeType="text/plain" /> |
| | | </intent-filter> |
| | | </activity> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.RechargeListActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.NewCardListActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.ParameterActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.PowerActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.DomainActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.ElectricPriceActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.IdentifyingActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.ReplacementActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.RechargeDetail" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.PasswordCardActivity" /> |
| | | <activity android:name="com.dayu.qihealonelibrary.activity.RegionActivity" /> |
| | | |
| | | </application> |
| | | |
| | | </manifest> |
| | |
| | | import com.dayu.qihealonelibrary.dbBean.CardData; |
| | | import com.dayu.qihealonelibrary.dbBean.IdentityBean; |
| | | |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | |
| | | |
| | | switch (data) { |
| | | case "管理卡": |
| | | cardType = MyCommon.MANAGE_CRAD; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.MANAGE_CRAD); |
| | | cardType = CardCommon.MANAGE_CRAD; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.MANAGE_CRAD); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | |
| | | } |
| | | break; |
| | | case "清零卡": |
| | | cardType = MyCommon.CLEAN_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CLEAN_CARD_TYPE); |
| | | cardType = CardCommon.CLEAN_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CLEAN_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | |
| | | } |
| | | break; |
| | | case "重新注册设备卡": |
| | | cardType = MyCommon.REGISTERED_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.REGISTERED_CARD_TYPE); |
| | | cardType = CardCommon.REGISTERED_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.REGISTERED_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | |
| | | } |
| | | break; |
| | | case "删除全部用户卡": |
| | | cardType = MyCommon.CLEAN_ALL_USER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CLEAN_ALL_USER_CARD_TYPE); |
| | | cardType = CardCommon.CLEAN_ALL_USER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CLEAN_ALL_USER_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | |
| | | } |
| | | break; |
| | | case "测试卡": |
| | | cardType = MyCommon.TEST_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.TEST_CARD_TYPE); |
| | | cardType = CardCommon.TEST_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.TEST_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | |
| | | } |
| | | break; |
| | | case "设备信息卡": |
| | | cardType = MyCommon.CONFIGURATION_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CONFIGURATION_CARD_TYPE); |
| | | cardType = CardCommon.CONFIGURATION_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CONFIGURATION_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | |
| | | } |
| | | break; |
| | | case "水泵功率卡": |
| | | cardType = MyCommon.CONFIGURATION_POWER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(MyCommon.CONFIGURATION_POWER_CARD_TYPE); |
| | | cardType = CardCommon.CONFIGURATION_POWER_CARD_TYPE; |
| | | cardData = baseDao.cardDataDao().findFirst(CardCommon.CONFIGURATION_POWER_CARD_TYPE); |
| | | if (cardData != null) { |
| | | setData(cardData); |
| | | } else { |
| | |
| | | import com.dayu.baselibrary.utils.TipUtil; |
| | | |
| | | import com.dayu.qihealonelibrary.QHAloneApplication; |
| | | import com.dayu.qihealonelibrary.R; |
| | | import com.dayu.qihealonelibrary.card.CleanCard; |
| | | import com.dayu.qihealonelibrary.card.CleanUserCard; |
| | | import com.dayu.qihealonelibrary.card.ConfigurationPowerCard; |
| | |
| | | import com.dayu.qihealonelibrary.tools.NFCWriteHelper; |
| | | import com.dayu.qihealonelibrary.tools.NfcReadHelper; |
| | | import com.dayu.qihealonelibrary.tools.WriteCardUtils; |
| | | import com.dayu.qihealonelibrary.utils.DeviceNumberUtils; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * Copyright (C), 2023, |
| | |
| | | |
| | | String cardType = NfcReadHelper.getInstence(intent, this).getCradType(); |
| | | Log.i("NFCWreatActivity", "cardType=" + cardType); |
| | | if (cardType.equals(MyCommon.USER_CARD_TYPE_1) || |
| | | cardType.equals(MyCommon.USER_CARD_TYPE_2) || |
| | | cardType.equals(MyCommon.USER_CARD_TYPE_3) |
| | | if (cardType.equals(CardCommon.USER_CARD_TYPE_1) || |
| | | cardType.equals(CardCommon.USER_CARD_TYPE_2) || |
| | | cardType.equals(CardCommon.USER_CARD_TYPE_3) |
| | | ) { |
| | | binding.textView.setText("该卡已经写入用户信息,请更换卡片"); |
| | | binding.textView.setTextColor(getResources().getColor(com.dayu.baselibrary.R.color.red)); |
| | |
| | | import com.dayu.baselibrary.activity.BaseActivity; |
| | | import com.dayu.baselibrary.view.TitleBar; |
| | | import com.dayu.qihealonelibrary.R; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.dao.BaseDaoSingleton; |
| | | |
| | | |
| | |
| | | |
| | | public TitleBar titleBar = null; |
| | | //z主线程查询 |
| | | public AppDatabase baseDao; |
| | | public QHAloneAppDatabase baseDao; |
| | | //异步线程查询 |
| | | public AppDatabase asynchBaseDao; |
| | | public QHAloneAppDatabase asynchBaseDao; |
| | | public final String SIGN = "308202b8308201a0020101300d06092a864886f70d01010b05003022310f300d06035504030c06e5a4a7e7a6b9310f300d06035504070c06e5a4a9e6b4a5301e170d3233313132303035333131325a170d3438313131333035333131325a3022310f300d06035504030c06e5a4a7e7a6b9310f300d06035504070c06e5a4a9e6b4a530820122300d06092a864886f70d01010105000382010f003082010a0282010100a0924f3d618e4a622def691e16e54ce5bdfd035bd73e7cb947d2bf3bd0c00afa26e52963e0299fc06d76d153be696c5285d630577e1dcb2b740a72b6d904482217de308fb91c8435441ed05e844ced1e5c3446d82cb8f38751049df26a42adcfc33f1f12c2ce03f676e5d148aad800ace89670b87835e2c02a8570a0b6740d9c0669d4cb3c597d0b2dd49fc0904e885773b6d3a87d9f1e73eb526e0d1a9e9e3c48d986938286cd824151b5a6214faf89d3e699524511b23c86d3b110a7f0bb56a6d2436f69816538a62a38cb1fee6eb685d267cc200df8af51b936bd280beaa2023f75678d77a11ac6de734b30af63d394c8b63bccf2115a47ea15c9212c740d0203010001300d06092a864886f70d01010b05000382010100307cafa9b14be91ba6424cfcc6aed75b069a1c4d6eb646eab0de93f372f236f5f0a6097499df99391075d6ced18d419a2b15adb041890e2b56a3bfbd6be40efee99c5c713ba8ea1d45da09b67916106116e96eb735271c4d53e0739f753145cbc42e149ad3d9507d422ec1c6f1a7f792a4542f9a64f0de3d4f4af69f0fb3390ef3577dcf8844cf744426d173b0934d879148062c5ca64022dc99af370dbfeaf2b5d4a279b20c54a361bca12c25bf185c2885519bbbc36e46ddb083080f0cc5b1f2eafe964ebce5071b0ae7d92a34a9193861b996d2c0299b1993f41063a27038199365a6e3cb27a02ffa9facdc48a63713eb5fbf90e9fd73056aba16b28e5fee"; |
| | | |
| | | @Override |
| | |
| | | |
| | | import com.dayu.qihealonelibrary.tools.NfcReadHelper; |
| | | |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | import com.dayu.qihealonelibrary.view.ProgressDialog; |
| | | |
| | | import java.util.Calendar; |
| | |
| | | byte cardType = data.get(0)[0]; |
| | | String cardTypeStr = HexUtil.byteToHex(cardType); |
| | | switch (cardTypeStr) { |
| | | case MyCommon.USER_CARD_TYPE_1: |
| | | case MyCommon.USER_CARD_TYPE_2: |
| | | case MyCommon.USER_CARD_TYPE_3: |
| | | case CardCommon.USER_CARD_TYPE_1: |
| | | case CardCommon.USER_CARD_TYPE_2: |
| | | case CardCommon.USER_CARD_TYPE_3: |
| | | userCard = UserCard.getBean(data); |
| | | break; |
| | | case MyCommon.MANAGE_CRAD: |
| | | case CardCommon.MANAGE_CRAD: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为管理卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.CLEAN_CARD_TYPE: |
| | | case CardCommon.CLEAN_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为清零卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.REGISTERED_CARD_TYPE: |
| | | case CardCommon.REGISTERED_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为重新注册设备卡"); |
| | | stopAnim(); |
| | | |
| | | break; |
| | | case MyCommon.CLEAN_ALL_USER_CARD_TYPE: |
| | | case CardCommon.CLEAN_ALL_USER_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为删除全部用户卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.DOMAIN_CARD_TYPE: |
| | | case CardCommon.DOMAIN_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为设置域名卡"); |
| | | DomainCard domainCard = DomainCard.toBean(data); |
| | |
| | | redCardBinding.readCardDataTV.setText("序号:" + domainCard.getDomainNumber() + "\n" + "域名:" + domainCard.getDomainName() + "\n" + "端口号:" + domainCard.getPort()); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.TEST_CARD_TYPE: |
| | | case CardCommon.TEST_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为测试卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.CONFIGURATION_CARD_TYPE: |
| | | case CardCommon.CONFIGURATION_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为配置设备注册信息卡"); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.CONFIGURATION_POWER_CARD_TYPE: |
| | | case CardCommon.CONFIGURATION_POWER_CARD_TYPE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前配置水泵功率卡"); |
| | | ConfigurationPowerCard powerCard = ConfigurationPowerCard.toBean(data.get(0)); |
| | | redCardBinding.readCardDataTV.setText(powerCard.getPower()); |
| | | stopAnim(); |
| | | break; |
| | | case MyCommon.BLACK: |
| | | case CardCommon.BLACK: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为黑卡"); |
| | | BlackCard blackCard = BlackCard.getBean(data); |
| | | redCardBinding.readCardDataTV.setText("当前黑卡用户号为:" + blackCard.getBlackCard()); |
| | | break; |
| | | case MyCommon.REGION: |
| | | case CardCommon.REGION: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为区域表号卡"); |
| | | RegionCard regionCard = RegionCard.getBean(data); |
| | |
| | | stringBuilder.append("控制器编号:").append(regionCard.getControllerCodel()).append("\n"); |
| | | redCardBinding.readCardDataTV.setText(stringBuilder.toString()); |
| | | break; |
| | | case MyCommon.ELECTRIC_PRICE: |
| | | case CardCommon.ELECTRIC_PRICE: |
| | | viweGone(false); |
| | | redCardBinding.readCardTypeTV.setText("当前为电量单价卡"); |
| | | ElectricPriceCard electricPriceCard = ElectricPriceCard.getBean(data); |
| | |
| | | @Override |
| | | public void error(int code) { |
| | | switch (code) { |
| | | case MyCommon.ERROR_MOVE: |
| | | case CardCommon.ERROR_MOVE: |
| | | stopAnim(); |
| | | TipUtil.show("连接中断,请重新贴合卡片"); |
| | | break; |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.dbBean.CardData; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | public class BaseCard implements Serializable { |
| | | public String cardData;//标识码 |
| | | |
| | | public void setCardData(AppDatabase baseDao, String cardType) { |
| | | public void setCardData(QHAloneAppDatabase baseDao, String cardType) { |
| | | try { |
| | | CardData cardDataBean = baseDao.cardDataDao().findFirst(cardType); |
| | | if (cardDataBean != null) { |
| | | cardData = cardDataBean.getCardIdentifying(); |
| | | } else { |
| | | cardData=MyCommon.getDefaultCardData(cardType); |
| | | cardData= CardCommon.getDefaultCardData(cardType); |
| | | } |
| | | } catch (Exception e) { |
| | | CrashReport.postCatchedException(e); |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | |
| | | */ |
| | | public class BlackCard extends BaseCard implements Serializable { |
| | | |
| | | public String cardType = MyCommon.BLACK; |
| | | public String cardType = CardCommon.BLACK; |
| | | |
| | | public String blackCard;//黑户卡号 |
| | | |
| | |
| | | this.blackCard = blackCard; |
| | | } |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description:清零卡 |
| | | */ |
| | | public class CleanCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.CLEAN_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CLEAN_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | | } |
| | | |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description:删除全部用户卡 |
| | | */ |
| | | public class CleanUserCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.CLEAN_ALL_USER_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CLEAN_ALL_USER_CARD_TYPE;//卡类型 |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | public class ConfigurationPowerCard extends BaseCard implements Serializable { |
| | | |
| | | |
| | | public String cardType = MyCommon.CONFIGURATION_POWER_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CONFIGURATION_POWER_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | |
| | | } |
| | | } |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase,cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase,cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * 为方便现场更换设备时重新注册的问题,配置设备信息卡,首先刷卡,把原设备的注册号和ID号读到卡内,同时卡状态则00修改为FF,再新设备上刷此卡时,注册号和ID号自动写到控制器内,可以直接刷卡使用 |
| | | */ |
| | | public class ConfigureDeviceRegistrationCrad extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.CONFIGURATION_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.CONFIGURATION_CARD_TYPE;//卡类型 |
| | | public String cardData = "A0B1C289";//标识码 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | | } |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.BcdUtil; |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | public class DomainCard implements Serializable { |
| | | |
| | | |
| | | public String cardType = MyCommon.DOMAIN_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.DOMAIN_CARD_TYPE;//卡类型 |
| | | public String domainNumber;//域名序号 (BCD格式) |
| | | public int domainLength;//域名长度 |
| | | |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | |
| | | * 备注:电量单价卡 |
| | | */ |
| | | public class ElectricPriceCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.ELECTRIC_PRICE; |
| | | public String cardType = CardCommon.ELECTRIC_PRICE; |
| | | public Float electricPrice;// 电量单价(低)单位是元,3位小数点 |
| | | |
| | | public Float getElectricPrice() { |
| | |
| | | this.electricPrice = electricPrice; |
| | | } |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description: 管理卡 第1扇区 0块 |
| | | */ |
| | | public class ManageCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.MANAGE_CRAD;//卡类型 |
| | | public String cardType = CardCommon.MANAGE_CRAD;//卡类型 |
| | | // public String cardData = "A0B1C289";//标识码 |
| | | |
| | | |
| | |
| | | return cardData; |
| | | } |
| | | |
| | | public byte[] toZeroByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toZeroByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | |
| | | * Description:密码卡 |
| | | */ |
| | | public class PassWordCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.PASS_WORD_CRAD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.PASS_WORD_CRAD_TYPE;//卡类型 |
| | | |
| | | public String passWord;//六位的密码 |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | |
| | | */ |
| | | public class RegionCard extends BaseCard implements Serializable { |
| | | |
| | | public String cardType = MyCommon.REGION;//卡命令 |
| | | public String cardType = CardCommon.REGION;//卡命令 |
| | | |
| | | public short region;//区域地址(低前高后) 可以识别某县镇村 |
| | | |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description:重新注册设备卡:用于写用户注册号 |
| | | */ |
| | | public class RegisteredCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.REGISTERED_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.REGISTERED_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | | } |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.dao.AppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.dao.QHAloneAppDatabase; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | |
| | | * Description: 测试卡 |
| | | */ |
| | | public class TestCard extends BaseCard implements Serializable { |
| | | public String cardType = MyCommon.TEST_CARD_TYPE;//卡类型 |
| | | public String cardType = CardCommon.TEST_CARD_TYPE;//卡类型 |
| | | |
| | | public String getCardData() { |
| | | return cardData; |
| | | } |
| | | |
| | | public byte[] toByte(AppDatabase appDatabase) { |
| | | setCardData(appDatabase, cardType); |
| | | public byte[] toByte(QHAloneAppDatabase QHAloneAppDatabase) { |
| | | setCardData(QHAloneAppDatabase, cardType); |
| | | Zero zero = new Zero(); |
| | | return zero.toByte(); |
| | | } |
| | |
| | | package com.dayu.qihealonelibrary.card; |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | |
| | | * Description: 齐河项目用户卡结构 |
| | | */ |
| | | public class UserCard implements Serializable { |
| | | public String cardType = MyCommon.USER_CARD_TYPE_1;//写卡标志 A1刷卡开泵前 A8刷卡开泵后 A2叠加充值 |
| | | public String cardType = CardCommon.USER_CARD_TYPE_1;//写卡标志 A1刷卡开泵前 A8刷卡开泵后 A2叠加充值 |
| | | |
| | | public short arerNumber;//区域号(底位在前高位在后) |
| | | |
| | |
| | | * Description: 创建数据库实例 |
| | | */ |
| | | public class BaseDaoSingleton { |
| | | public static AppDatabase baseDao; |
| | | public static AppDatabase AsynchBaseDao; |
| | | public static String SqlitePath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + ".dayu" + File.separator + "data_qh" + File.separator; |
| | | public static QHAloneAppDatabase baseDao; |
| | | public static QHAloneAppDatabase AsynchBaseDao; |
| | | public static String SqlitePath = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + ".dayu" + File.separator + "data" + File.separator; |
| | | |
| | | //MyFileUtil.SqlitePath + |
| | | public static AppDatabase getInstance(Context context) { |
| | | public static QHAloneAppDatabase getInstance(Context context) { |
| | | if (baseDao == null) { |
| | | baseDao = Room.databaseBuilder( |
| | | context, |
| | | AppDatabase.class, |
| | | SqlitePath + "ConfigurationData" |
| | | ).allowMainThreadQueries().addMigrations(AppDatabase.MIGRATION_3_4).build(); |
| | | QHAloneAppDatabase.class, |
| | | SqlitePath + "ConfigurationData_qiheAlone" |
| | | ).allowMainThreadQueries().addMigrations(QHAloneAppDatabase.MIGRATION_3_4).build(); |
| | | } |
| | | return baseDao; |
| | | } |
| | | |
| | | public static AppDatabase getAsynchInstance(Context context) { |
| | | public static QHAloneAppDatabase getAsynchInstance(Context context) { |
| | | |
| | | if (AsynchBaseDao == null) { |
| | | AsynchBaseDao = Room.databaseBuilder( |
| | | context, |
| | | AppDatabase.class, |
| | | SqlitePath + "ConfigurationData" |
| | | ).addMigrations(AppDatabase.MIGRATION_3_4).build(); |
| | | QHAloneAppDatabase.class, |
| | | SqlitePath + "ConfigurationData_qiheAlone" |
| | | ).addMigrations(QHAloneAppDatabase.MIGRATION_3_4).build(); |
| | | } |
| | | return AsynchBaseDao; |
| | | |
File was renamed from qihealonelibrary/src/main/java/com/dayu/qihealonelibrary/dao/AppDatabase.java |
| | |
| | | * Date: 2023-11-05 16:23 |
| | | * Description: |
| | | */ |
| | | @Database(entities = {RegionBean.class, PassWordCardBean.class, CardData.class, DeviceNumber.class, IdentityBean.class, DomainBean.class, ElectricPriceBean.class, IpBean.class, AdminDataBean.class, PassWordBean.class, UserCardBean.class, RechargeBean.class, PowerBean.class}, version = 4, exportSchema = false) |
| | | public abstract class AppDatabase extends RoomDatabase { |
| | | @Database(entities = {RegionBean.class, PassWordCardBean.class, CardData.class, DeviceNumber.class, IdentityBean.class, DomainBean.class, ElectricPriceBean.class, IpBean.class, AdminDataBean.class, PassWordBean.class, UserCardBean.class, RechargeBean.class, PowerBean.class}, version = com.dayu.baselibrary.dao.AppDatabase.version, exportSchema = false) |
| | | public abstract class QHAloneAppDatabase extends RoomDatabase { |
| | | |
| | | |
| | | public abstract AdminDataDao adminDao(); |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | import com.dayu.qihealonelibrary.card.UserCard; |
| | | import com.dayu.qihealonelibrary.utils.MyCommon; |
| | | import com.dayu.qihealonelibrary.utils.CardCommon; |
| | | |
| | | |
| | | import java.io.IOException; |
| | |
| | | if (flag) { |
| | | callback.callBack(map); |
| | | } else { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } |
| | | } catch (IOException e) { |
| | | callback.error(MyCommon.ERROR_MOVE); |
| | | callback.error(CardCommon.ERROR_MOVE); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | |
| | | if (flag) { |
| | | callback.callBack(list); |
| | | } else { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } |
| | | } catch (IOException e) { |
| | | callback.error(MyCommon.ERROR_MOVE); |
| | | callback.error(CardCommon.ERROR_MOVE); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | |
| | |
| | | mfc.connect(); |
| | | int count = mfc.getSectorCount(); |
| | | if (a < 0 || a > count - 1) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | return; |
| | | } |
| | | int bCount = mfc.getBlockCountInSector(a); |
| | | if (b < 0 || b > bCount - 1) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | return; |
| | | } |
| | | |
| | |
| | | byte[] data = mfc.readBlock(bIndex + b); |
| | | callback.callBack(data); |
| | | } else { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } |
| | | } catch (IOException e) { |
| | | callback.error(MyCommon.ERROR_MOVE); |
| | | callback.error(CardCommon.ERROR_MOVE); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | callback.error(MyCommon.ERROR); |
| | | callback.error(CardCommon.ERROR); |
| | | } finally { |
| | | try { |
| | | mfc.close(); |
File was renamed from qihealonelibrary/src/main/java/com/dayu/qihealonelibrary/utils/MyCommon.java |
| | |
| | | * Copyright (C), 2023, |
| | | * Author: zuo |
| | | * Date: 2023-11-06 20:22 |
| | | * Description: |
| | | * Description:卡类型 |
| | | */ |
| | | public class MyCommon { |
| | | public class CardCommon { |
| | | |
| | | public static final int ERROR = -1; |
| | | //连接中断 提示用户重新连接或提示用户重新靠近卡片 |
| | |
| | | android:layout_width="match_parent" |
| | | android:layout_height="@dimen/dimen_title_height" |
| | | android:background="@color/title_bar_bg" |
| | | app:centerText="首页" /> |
| | | app:centerText="齐河单机版首页" /> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | |
| | | android:textSize="@dimen/home_text_size" /> |
| | | </LinearLayout> |
| | | |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:gravity="bottom|center_horizontal"> |
| | | |
| | | <TextView |
| | | android:id="@+id/socketState" |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginBottom="20dp" |
| | | android:text="已连接数据中心" /> |
| | | </LinearLayout> |
| | | |
| | | </LinearLayout> |
| | |
| | | package com.dayu.qihealonelibrary; |
| | | |
| | | import org.junit.Test; |
| | | |
| | | import static org.junit.Assert.*; |
| | | |
| | | /** |
| | | * Example local unit test, which will execute on the development machine (host). |
| | |
| | | * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> |
| | | */ |
| | | public class ExampleUnitTest { |
| | | @Test |
| | | public void addition_isCorrect() { |
| | | assertEquals(4, 2 + 2); |
| | | } |
| | | // @Test |
| | | // public void addition_isCorrect() { |
| | | // assertEquals(4, 2 + 2); |
| | | // } |
| | | } |