diff --git a/androidpdfviewer/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties b/androidpdfviewer/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties index 42f9046..ac475a5 100644 --- a/androidpdfviewer/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +++ b/androidpdfviewer/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties @@ -1,4 +1,4 @@ -#Thu Feb 13 15:46:01 CST 2025 +#Fri Feb 14 17:09:23 CST 2025 com.github.barteksc.pdfviewer.androidpdfviewer-main-6\:/drawable/default_scroll_handle_bottom.xml=/home/admin/AndroidStudioProjects/ZHDCOA/androidpdfviewer/build/intermediates/packaged_res/debug/packageDebugResources/drawable/default_scroll_handle_bottom.xml com.github.barteksc.pdfviewer.androidpdfviewer-main-6\:/drawable/default_scroll_handle_left.xml=/home/admin/AndroidStudioProjects/ZHDCOA/androidpdfviewer/build/intermediates/packaged_res/debug/packageDebugResources/drawable/default_scroll_handle_left.xml com.github.barteksc.pdfviewer.androidpdfviewer-main-6\:/drawable/default_scroll_handle_right.xml=/home/admin/AndroidStudioProjects/ZHDCOA/androidpdfviewer/build/intermediates/packaged_res/debug/packageDebugResources/drawable/default_scroll_handle_right.xml diff --git a/androidslantedtextview/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties b/androidslantedtextview/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties index 9a71320..677d37d 100644 --- a/androidslantedtextview/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +++ b/androidslantedtextview/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties @@ -1 +1 @@ -#Thu Feb 13 15:46:06 CST 2025 +#Fri Feb 14 17:09:23 CST 2025 diff --git a/app/build.gradle b/app/build.gradle index dcfe26a..013a818 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { applicationId "com.rehome.zhdcoa" minSdk 24 targetSdk 35 - versionCode 18 - versionName "2.3.4" + versionCode 19 + versionName "2.3.5" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" //每个应用拥有不同的authorities,防止相同的在同一个手机上无法同时安装 @@ -73,11 +73,8 @@ dependencies { implementation files('libs/pdf.aar') implementation files('libs/ZSDK_API.jar') implementation files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar') -// implementation files('libs/MiPush_SDK_Client_3_4_3.jar') implementation files('libs/badgeview.jar') implementation files('libs/TbsFileSdk_base_arm64_release_1.0.5.6000030.20231109143447.aar') -// implementation 'androidx.appcompat:appcompat:1.6.1' -// implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation libs.androidx.core.ktx @@ -119,83 +116,55 @@ dependencies { implementation project(':videocompressor') //实时录音wav转mp3 implementation project(':recorderlib') - //下拉刷新 -// implementation project(':refreshheader') -// implementation project(':refreshlayout') - - - - - //网络请求 - implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0' - implementation 'com.squareup.retrofit2:retrofit:2.9.0' - implementation 'com.squareup.retrofit2:converter-gson:2.9.0' - implementation 'com.squareup.okhttp3:okhttp:3.12.12' - implementation 'cn.hutool:hutool-all:5.8.5' - - //implementation 'com.hjq:http:9.0' - //implementation 'com.hjq.gson:factory:2.2' - //implementation 'com.hjq:toast:8.8' - -// ---------------------------------------------------------------- - - implementation 'com.orhanobut:logger:2.2.0' -// implementation 'com.yanzhenjie:permission:2.0.3' - implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' - implementation 'de.hdodenhof:circleimageview:3.1.0' - implementation 'com.github.chrisbanes.photoview:library:1.2.4' - implementation 'me.leolin:ShortcutBadger:1.1.22@aar' - implementation 'cn.jzvd:jiaozivideoplayer:7.2.3' - - //implementation 'com.google.zxing:core:3.4.1' - //implementation 'com.king.zxing:zxing-lite:1.1.6-androidx' - - implementation 'com.github.chrisbanes:PhotoView:2.1.3' - implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0' - implementation 'com.github.huangyanbin:SmartTable:2.2.0' -// implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'com.github.xuexiangjys:XUI:1.1.5' - implementation 'com.github.baoyachi:StepView:1.9' - implementation 'io.github.azhon:appupdate:4.2.6' - implementation 'com.tencent.bugly:crashreport:3.2.1' + implementation libs.logging.interceptor + implementation libs.com.squareup.retrofit2.retrofit3 + implementation libs.com.squareup.retrofit2.converter.gson + implementation libs.okhttp + implementation libs.cn.hutool.hutool.all + + + implementation libs.com.github.philjay.mpandroidchart6 + implementation libs.circleimageview + implementation libs.com.github.chrisbanes.photoview.library6 + implementation libs.me.leolin.shortcutbadger + implementation libs.cn.jzvd.jiaozivideoplayer6 + implementation libs.com.github.chrisbanes.photoview6 + implementation libs.com.davemorrissey.labs.subsampling.scale.image.view6 + implementation libs.com.github.huangyanbin.smarttable6 + implementation libs.androidx.multidex + implementation libs.recyclerview.v140 + implementation libs.xuexiangjys.xui + implementation libs.baoyachi.stepview + implementation libs.appupdate + implementation libs.com.tencent.bugly.crashreport // implementation 'com.github.xuexiangjys.SmartRefreshLayout:refresh-header:1.1.5' // implementation 'com.github.xuexiangjys.SmartRefreshLayout:refresh-layout:1.1.5' //implementation 'com.just.agentweb:agentweb:4.1.4' //第三方浏览器 - implementation 'io.github.justson:agentweb-core:v5.1.1-androidx' - //implementation 'com.lcodecorex:tkrefreshlayout:1.0.7' - implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.30' -// implementation files('../libs/poi-3.9-20121203.jar') -// implementation files('../libs/poi-scratchpad-3.9-20121203.jar') -// implementation 'androidx.activity:activity:1.8.0' -// testImplementation 'junit:junit:4.13.1' -// androidTestImplementation 'androidx.test.ext:junit:1.1.2' -// androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation libs.io.github.justson.agentweb.core3 + implementation libs.cymchad.baserecyclerviewadapterhelper //第三方库图片选择器 // PictureSelector basic (Necessary) - implementation 'io.github.lucksiege:pictureselector:v3.10.7' + implementation libs.github.pictureselector // image compress library (Not necessary) - implementation 'io.github.lucksiege:compress:v3.10.7' + implementation libs.github.compress // uCrop library (Not necessary) - implementation 'io.github.lucksiege:ucrop:v3.10.7' + implementation libs.github.ucrop // simple camerax library (Not necessary) - implementation 'io.github.lucksiege:camerax:v3.10.7' + implementation libs.github.camerax //第三方库图片异步加载 - implementation 'com.github.bumptech.glide:glide:4.11.0' - annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' + implementation libs.com.github.bumptech.glide.glide + annotationProcessor libs.compiler //mqtt - implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.4' - implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1' - implementation 'org.bouncycastle:bcpkix-jdk15on:1.47' - implementation 'commons-codec:commons-codec:1.15' - //implementation 'com.google.android.play:app-update:2.0.1' + implementation libs.eclipse.org.eclipse.paho.client.mqttv3 + implementation libs.eclipse.org.eclipse.paho.android.service + implementation libs.org.bouncycastle.bcpkix.jdk15on + implementation libs.commons.codec //emoji表情符号 - implementation 'androidx.emoji:emoji-bundled:1.0.0' + implementation libs.androidx.emoji.bundled //二维码扫描 - implementation 'com.google.mlkit:barcode-scanning:16.1.1' + implementation libs.barcode.scanning } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ab00387..8e0926d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -440,9 +440,9 @@ - + + + diff --git a/app/src/main/java/com/rehome/zhdcoa/service/BackUploadService.java b/app/src/main/java/com/rehome/zhdcoa/service/BackUploadService.java index cefbae8..8663b1b 100755 --- a/app/src/main/java/com/rehome/zhdcoa/service/BackUploadService.java +++ b/app/src/main/java/com/rehome/zhdcoa/service/BackUploadService.java @@ -8,12 +8,10 @@ import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.Binder; -import android.os.Build; import android.os.IBinder; +import android.util.Log; import androidx.localbroadcastmanager.content.LocalBroadcastManager; - -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; /** @@ -46,11 +44,11 @@ public class BackUploadService extends Service { // @Override // public void run() { // try { -// Logger.v("network" + "查询数据库数据"); +// showLog("network" + "查询数据库数据"); // Thread.sleep(2000); -// Logger.v("network" + "上传数据"); +// showLog("network" + "上传数据"); // Thread.sleep(2000); -// Logger.v("network" + "上传成功"); +// showLog("network" + "上传成功"); // } catch (InterruptedException e) { // e.printStackTrace(); // } @@ -140,7 +138,7 @@ public class BackUploadService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { WIFI = isWifiConnected(this); - Logger.v("开启服务..." + WIFI); + Log.i("app","开启服务..." + WIFI); return super.onStartCommand(intent, flags, startId); } } diff --git a/app/src/main/java/com/rehome/zhdcoa/service/UploadDataService.java b/app/src/main/java/com/rehome/zhdcoa/service/UploadDataService.java index e689fb4..48a6c2d 100755 --- a/app/src/main/java/com/rehome/zhdcoa/service/UploadDataService.java +++ b/app/src/main/java/com/rehome/zhdcoa/service/UploadDataService.java @@ -2,8 +2,6 @@ package com.rehome.zhdcoa.service; import android.app.IntentService; import android.content.Intent; - -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.Djjh; @@ -270,7 +268,7 @@ public class UploadDataService extends IntentService { requestCount++; Request request1 = NoHttp.createStringRequest(Contans.IP + Contans.DJJHQXGD, RequestMethod.POST); String qxgdjson = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(qxgdjson); + //Logger.json(qxgdjson); System.out.println(qxgdjson); request1.setDefineRequestBodyForJson(qxgdjson); NohttpUtils.getInstance().add(null, 1, request1, callback, false, false, ""); @@ -316,7 +314,7 @@ public class UploadDataService extends IntentService { if (infos.size() != 0) { requestCount++; String json1 = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(json1); + //Logger.json(json1); request2.setDefineRequestBodyForJson(json1); NohttpUtils.getInstance().add(null, 2, request2, callback, false, false, "上传中..."); } @@ -379,7 +377,7 @@ public class UploadDataService extends IntentService { if (!xf.toString().isEmpty()) { requestCount++; - Logger.v(xf.toString()); + //showLog(xf.toString()); Request request = NoHttp.createStringRequest(Contans.IP + Contans.XFDJJHSC + "?cjscr=" + UiUtlis.encoder(App.getInstance().getUserInfo().getManid()), RequestMethod.POST); request.setDefineRequestBodyForJson(UiUtlis.encoder(xfjson)); queue.add(0, request, new HttpResponseListener<>(null, request, callback, false, false, "")); @@ -397,7 +395,7 @@ public class UploadDataService extends IntentService { } if (!ba.toString().isEmpty()) { requestCount++; - Logger.v(ba.toString()); + //showLog(ba.toString()); Request baxc = NoHttp.createStringRequest(Contans.IP + Contans.BAXCJHSC + "?cjscr=" + UiUtlis.encoder(App.getInstance().getUserInfo().getManid()), RequestMethod.POST); baxc.setDefineRequestBodyForJson(UiUtlis.encoder(bajson)); queue.add(2, baxc, new HttpResponseListener<>(null, baxc, callback, false, false, "")); @@ -405,7 +403,7 @@ public class UploadDataService extends IntentService { } if (!ly.toString().isEmpty()) { - Logger.v(ly.toString()); + //showLog(ly.toString()); //上传隐患排查单 List info = DataSupport.findAll(LyYhpcInfo.class); if (info.size() != 0) { @@ -443,7 +441,7 @@ public class UploadDataService extends IntentService { @Override public void onSucceed(int what, Response response) { try { - Logger.v(response.get()); + //showLog(response.get()); StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class); if (info != null) { if (info.getTotal() != 0) { @@ -524,7 +522,7 @@ public class UploadDataService extends IntentService { scs.add(info); } String json = "{\"Rows\":" + GsonUtils.GsonString(scs) + ",\"Total\": " + scs.size() + "}"; - Logger.json(json); + //Logger.json(json); return json; } @@ -546,7 +544,7 @@ public class UploadDataService extends IntentService { infos.add(info); } String json = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(json); + //Logger.json(json); return json; } } diff --git a/app/src/main/java/com/rehome/zhdcoa/service/UploadService.java b/app/src/main/java/com/rehome/zhdcoa/service/UploadService.java index f7f88fd..a164f56 100755 --- a/app/src/main/java/com/rehome/zhdcoa/service/UploadService.java +++ b/app/src/main/java/com/rehome/zhdcoa/service/UploadService.java @@ -3,8 +3,6 @@ package com.rehome.zhdcoa.service; import android.app.IntentService; import android.content.Intent; import android.database.Cursor; - -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.DBModel.Djjh; import com.rehome.zhdcoa.Contans; @@ -175,7 +173,7 @@ public class UploadService extends IntentService { ++requestCount; Request request1 = NoHttp.createStringRequest(Contans.IP+Contans.DJJHQXGD, RequestMethod.POST); String qxgdjson = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(qxgdjson); +// Logger.json(qxgdjson); request1.setDefineRequestBodyForJson(qxgdjson); NohttpUtils.getInstance().add(null, 1, request1, callback, false, false, ""); } diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/ActivitySHYK.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/ActivitySHYK.java index 9789c3b..f0b7957 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/ActivitySHYK.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/ActivitySHYK.java @@ -30,9 +30,7 @@ import com.rehome.zhdcoa.utils.FileUtils; import com.rehome.zhdcoa.utils.GsonUtils; import com.rehome.zhdcoa.utils.HttpUtils; import com.rehome.zhdcoa.utils.UriUtils; -import com.rehome.zhdcoa.zxing.decoding.Intents; import com.xuexiang.xui.widget.dialog.materialdialog.MaterialDialog; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -72,7 +70,7 @@ public class ActivitySHYK extends BaseActivity { public static final String KEY_IS_CONTINUOUS = "key_continuous_scan"; // public static final int REQUEST_CODE_SCAN = 0X01; - private static final int CAMERA_REQUEST_CAMERA_SCAN = 7;//请求码 + private ActivityResultLauncher launcherResultQRCode; private String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "com.rehome.zhdcoa/images"; @@ -103,28 +101,8 @@ public class ActivitySHYK extends BaseActivity { .items(R.array.menu_values) .itemsCallback((dialog, itemView, position, text) -> { if (position == 0) { - -// ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeCustomAnimation(ActivitySHYK.this,R.anim.in,R.anim.out); -// Intent intent = new Intent(ActivitySHYK.this, CaptureActivity.class); -// intent.putExtra(KEY_TITLE,"扫码"); -// intent.putExtra(KEY_IS_CONTINUOUS,false); -// ActivityCompat.startActivityForResult(ActivitySHYK.this,intent,REQUEST_CODE_SCAN,optionsCompat.toBundle()); - -// - - //检测摄像头权限 - if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) { - Toast.makeText(context, "权限拒绝,请手动设置开启APP访问摄像头权限", Toast.LENGTH_LONG).show(); - return; - } - //动态权限申请 - if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { - //权限请求 - ActivityCompat.requestPermissions(ActivitySHYK.this, new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CAMERA_SCAN); - } else { - //已授权,打开摄像头扫描 - intentTOQRCode(); - } + //打开摄像头扫描 + intentTOQRCode(); } else if (position == 1) { startPhotoCode(); } else if (position == 2) { @@ -420,19 +398,4 @@ public class ActivitySHYK extends BaseActivity { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); launcherResultQRCode.launch(intent); } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (CAMERA_REQUEST_CAMERA_SCAN == requestCode) { - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - //已授权,打开摄像头扫描 - intentTOQRCode(); - } else { - //权限拒绝 - Toast.makeText(ActivitySHYK.this, "权限拒绝,请手动设置开启APP访问摄像头权限", Toast.LENGTH_SHORT).show(); - } - } - } - } diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/Activity_YJYAJX.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/Activity_YJYAJX.java index b624570..aeef0d0 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/Activity_YJYAJX.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/Activity_YJYAJX.java @@ -8,8 +8,8 @@ import android.widget.TextView; import com.rehome.zhdcoa.R; import com.rehome.zhdcoa.adapter.FragmentAdapter; import com.rehome.zhdcoa.base.BaseActivity; -import com.rehome.zhdcoa.ui.fragment.YjyaCFragment; -import com.rehome.zhdcoa.ui.fragment.YjyaDFragment; +import com.rehome.zhdcoa.ui.fragment.YjyacFragment; +import com.rehome.zhdcoa.ui.fragment.YjyadFragment; import com.rehome.zhdcoa.weiget.DateTimePickDialog; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -26,8 +26,8 @@ public class Activity_YJYAJX extends BaseActivity { private TabLayout mTabLayout; private final List fragments = new ArrayList<>(); - private YjyaCFragment yjyaCFragment; - private YjyaDFragment yjyaDFragment; + private YjyacFragment yjyacFragment; + private YjyadFragment yjyadFragment; private int page; @@ -63,20 +63,20 @@ public class Activity_YJYAJX extends BaseActivity { tvSt.setOnClickListener(view -> { DateTimePickDialog dialog = new DateTimePickDialog(context, (outPutDate, outPutDate1, outPutDate2) -> { tvSt.setText(outPutDate1); - yjyaCFragment.stime = tvSt.getText().toString().trim(); - yjyaDFragment.stime = tvSt.getText().toString().trim(); - yjyaCFragment.reloadData(); - yjyaDFragment.reloadData(); + yjyacFragment.resetStime(tvSt.getText().toString().trim()); + yjyadFragment.resetStime(tvSt.getText().toString().trim()); + yjyacFragment.reloadData(); + yjyadFragment.reloadData(); }); dialog.show(); }); tvEt.setOnClickListener(view -> { DateTimePickDialog dialog = new DateTimePickDialog(context, (outPutDate, outPutDate1, outPutDate2) ->{ tvEt.setText(outPutDate1); - yjyaCFragment.etime = tvEt.getText().toString().trim(); - yjyaDFragment.etime = tvEt.getText().toString().trim(); - yjyaCFragment.reloadData(); - yjyaDFragment.reloadData(); + yjyacFragment.resetEtime(tvEt.getText().toString().trim()); + yjyadFragment.resetEtime(tvEt.getText().toString().trim()); + yjyacFragment.reloadData(); + yjyadFragment.reloadData(); }); dialog.show(); }); @@ -92,15 +92,15 @@ public class Activity_YJYAJX extends BaseActivity { for (int i = 0; i < titles.size(); i++) { mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(i))); } - yjyaCFragment = YjyaCFragment.newInstance(); - yjyaCFragment.stime = tvSt.getText().toString().trim(); - yjyaCFragment.etime = tvEt.getText().toString().trim(); - yjyaDFragment = YjyaDFragment.newInstance(); - yjyaDFragment.stime = tvSt.getText().toString().trim(); - yjyaDFragment.etime = tvEt.getText().toString().trim(); + yjyacFragment = new YjyacFragment(); + yjyacFragment.resetStime(tvSt.getText().toString().trim()); + yjyacFragment.resetEtime(tvEt.getText().toString().trim()); + yjyadFragment = new YjyadFragment(); + yjyadFragment.resetStime(tvSt.getText().toString().trim()); + yjyadFragment.resetEtime(tvEt.getText().toString().trim()); - fragments.add(yjyaCFragment); - fragments.add(yjyaDFragment); + fragments.add(yjyacFragment); + fragments.add(yjyadFragment); FragmentAdapter mFragmentAdapter = new FragmentAdapter(getSupportFragmentManager(), fragments, titles); mViewPager.setAdapter(mFragmentAdapter); mTabLayout.setupWithViewPager(mViewPager); diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/ApplyLeaveAuditActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/ApplyLeaveAuditActivity.java index 1c0f17a..06225f0 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/ApplyLeaveAuditActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/ApplyLeaveAuditActivity.java @@ -5,8 +5,6 @@ import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.Toast; - -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.QxgdInfo; import com.rehome.zhdcoa.R; diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AscFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AscFragment.java index 7bbe3a2..caa33df 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AscFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AscFragment.java @@ -8,7 +8,6 @@ import android.widget.Button; import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.AjhScInfo; import com.rehome.zhdcoa.DBModel.Ajhjh; @@ -341,7 +340,7 @@ public class AscFragment extends BaseFragment { if (infos.size() != 0) { selectCount++; String json1 = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(json1); + showLog(json1); json1 = new String(json1.getBytes(), StandardCharsets.UTF_8); request2.setDefineRequestBodyForJson(UiUtlis.encoder(json1)); if(App.getInstance().getUserInfo()!=null&&App.getInstance().getUserInfo().getToken()!=null){ @@ -390,7 +389,7 @@ public class AscFragment extends BaseFragment { infos.add(info); } String json = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(json); + showLog(json); json = new String(json.getBytes(), StandardCharsets.UTF_8); return json; } @@ -399,7 +398,7 @@ public class AscFragment extends BaseFragment { @Override public void onSucceed(int what, Response response) { - Logger.v(response.get()); + showLog(response.get()); try { StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class); diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglActivity.java index 5c4f2a6..df421bd 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglActivity.java @@ -19,8 +19,6 @@ import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; - -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.XwaqgcJh; import com.rehome.zhdcoa.DBModel.XwaqgcJs; @@ -250,7 +248,7 @@ public class AxwaqgcglActivity extends BaseActivity2 { @Override public void onSucceed(int what, Response response) { - Logger.d(response.get()); + showLog(response.get()); System.out.println(response.get()); diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglHmActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglHmActivity.java index fde7410..8ece921 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglHmActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/AxwaqgcglHmActivity.java @@ -15,7 +15,6 @@ import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; import com.google.gson.Gson; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.XwaqgcJh; import com.rehome.zhdcoa.DBModel.XwaqgcJs; @@ -318,7 +317,7 @@ public class AxwaqgcglHmActivity extends BaseActivity2 { @Override public void onSucceed(int what, Response response) { - Logger.d(response.get()); + showLog(response.get()); System.out.println(response.get()); diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/CaptureActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/CaptureActivity.java deleted file mode 100644 index 25a68d3..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/CaptureActivity.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.rehome.zhdcoa.ui.activity; - -import android.os.Bundle; -import android.view.MotionEvent; -import android.view.SurfaceView; -import android.view.View; - -import com.king.zxing.CaptureHelper; -import com.king.zxing.Intents; -import com.king.zxing.OnCaptureCallback; -import com.king.zxing.ViewfinderView; -import com.king.zxing.camera.CameraManager; - -import androidx.annotation.LayoutRes; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - -public class CaptureActivity extends AppCompatActivity implements OnCaptureCallback { - - public static final String KEY_RESULT = Intents.Scan.RESULT; - - private SurfaceView surfaceView; - private ViewfinderView viewfinderView; - private View ivTorch; - - private CaptureHelper mCaptureHelper; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - int layoutId = getLayoutId(); - if(isContentView(layoutId)){ - setContentView(layoutId); - } - initUI(); - mCaptureHelper.onCreate(); - } - - /** - * 初始化 - */ - public void initUI(){ - surfaceView = findViewById(getSurfaceViewId()); - int viewfinderViewId = getViewfinderViewId(); - if(viewfinderViewId != 0){ - viewfinderView = findViewById(viewfinderViewId); - } - int ivTorchId = getIvTorchId(); - if(ivTorchId != 0){ - ivTorch = findViewById(ivTorchId); - ivTorch.setVisibility(View.INVISIBLE); - } - initCaptureHelper(); - } - - public void initCaptureHelper(){ - mCaptureHelper = new CaptureHelper(this,surfaceView,viewfinderView,ivTorch); - mCaptureHelper.setOnCaptureCallback(this); - } - - /** - * 返回true时会自动初始化{@link #setContentView(int)},返回为false是需自己去初始化{@link #setContentView(int)} - * @param layoutId - * @return 默认返回true - */ - public boolean isContentView(@LayoutRes int layoutId){ - return true; - } - - /** - * 布局id - * @return - */ - public int getLayoutId(){ - return com.king.zxing.R.layout.zxl_capture; - } - - /** - * {@link #viewfinderView} 的 ID - * @return 默认返回{@code R.id.viewfinderView}, 如果不需要扫码框可以返回0 - */ - public int getViewfinderViewId(){ - return com.king.zxing.R.id.viewfinderView; - } - - - /** - * 预览界面{@link #surfaceView} 的ID - * @return - */ - public int getSurfaceViewId(){ - return com.king.zxing.R.id.surfaceView; - } - - /** - * 获取 {@link #ivTorch} 的ID - * @return 默认返回{@code R.id.ivTorch}, 如果不需要手电筒按钮可以返回0 - */ - public int getIvTorchId(){ - return com.king.zxing.R.id.ivTorch; - } - - /** - * Get {@link CaptureHelper} - * @return {@link #mCaptureHelper} - */ - public CaptureHelper getCaptureHelper(){ - return mCaptureHelper; - } - - /** - * Get {@link CameraManager} use {@link #getCaptureHelper()#getCameraManager()} - * @return {@link #mCaptureHelper#getCameraManager()} - */ - @Deprecated - public CameraManager getCameraManager(){ - return mCaptureHelper.getCameraManager(); - } - - @Override - public void onResume() { - super.onResume(); - mCaptureHelper.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - mCaptureHelper.onPause(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - mCaptureHelper.onDestroy(); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - mCaptureHelper.onTouchEvent(event); - return super.onTouchEvent(event); - } - - /** - * 接收扫码结果回调 - * @param result 扫码结果 - * @return 返回true表示拦截,将不自动执行后续逻辑,为false表示不拦截,默认不拦截 - */ - @Override - public boolean onResultCallback(String result) { - return false; - } -} diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/DjdscFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/DjdscFragment.java index a151a69..b855a23 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/DjdscFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/DjdscFragment.java @@ -9,7 +9,6 @@ import android.widget.Button; import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.Djjh; import com.rehome.zhdcoa.DBModel.DjjhRwQy; @@ -305,7 +304,7 @@ public class DjdscFragment extends BaseFragment { sCData(toJson()); checkedCount = 0; // Logger.json(toJson()); -// Logger.v(toJson()); +// showLog(toJson()); } else { //showToast("你还有未检查的项目"); @@ -323,7 +322,7 @@ public class DjdscFragment extends BaseFragment { public void onClick(DialogInterface dialog, int which) { sCData(toJson()); // Logger.json(toJson()); - Logger.v(toJson()); + showLog(toJson()); } }); builder.show(); @@ -404,7 +403,7 @@ public class DjdscFragment extends BaseFragment { ++requestCount; Request request1 = NoHttp.createStringRequest(Contans.IP + Contans.DJJHQXGD, RequestMethod.POST); String qxgdjson = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(qxgdjson); + showLog(qxgdjson); System.out.println(qxgdjson); qxgdjson = new String(qxgdjson.getBytes(), StandardCharsets.UTF_8); request1.setDefineRequestBodyForJson(UiUtlis.encoder(qxgdjson)); @@ -446,7 +445,7 @@ public class DjdscFragment extends BaseFragment { @Override public void onSucceed(int what, Response response) { - Logger.v(response.get()); + showLog(response.get()); System.out.println(response.get()); StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class); if (info != null) { @@ -529,7 +528,7 @@ public class DjdscFragment extends BaseFragment { } String json = "{\"Rows\":" + GsonUtils.GsonString(scs) + ",\"Total\": " + scs.size() + "}"; System.out.println("点检记录" + json); - Logger.json(json); + showLog(json); json = new String(json.getBytes(), StandardCharsets.UTF_8); return json; } diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjbqdyActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjbqdyActivity.java index 3a82bb2..e8f12b5 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjbqdyActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjbqdyActivity.java @@ -10,7 +10,6 @@ import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.R; import com.rehome.zhdcoa.base.BaseActivity2; @@ -107,7 +106,7 @@ public class HjbqdyActivity extends BaseActivity2 { "^CF0,89^FO380,250^FD" + UiUtlis.getText(etHjh) + "^FS" + "^PQ" + UiUtlis.getText(etDysl) + ",,,^XZ"; - Logger.v("打印:" + getprints()); + showLog("打印:" + getprints()); showToast("你没有输入货架号"); } @@ -239,7 +238,7 @@ public class HjbqdyActivity extends BaseActivity2 { } // String str1 = "^XA" + "^FO160,300BY3" + "^BCN,100,N,N,N" + "^FD" + UiUtlis.getText(etHjh) + "^FS" + "^PQ" + (UiUtlis.getText(etDysl).equals("") ? "1" : UiUtlis.getText(etDysl)) + ",,,^XZ"; -// Logger.v("打印数据" + str); +// showLog("打印数据" + str); configLabel = str.getBytes(); } else if (printerLanguage == PrinterLanguage.CPCL) { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjpdActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjpdActivity.kt index 3c999dd..dcc45e2 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjpdActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/HjpdActivity.kt @@ -1,14 +1,19 @@ package com.rehome.zhdcoa.ui.activity +import android.Manifest import android.content.Intent +import android.content.pm.PackageManager import android.media.RingtoneManager import android.text.TextUtils import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.CheckBox +import android.widget.Toast import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.contract.ActivityResultContracts +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat import com.rehome.zhdcoa.App import com.rehome.zhdcoa.Contans import com.rehome.zhdcoa.R @@ -47,6 +52,10 @@ class HjpdActivity : BaseActivityOaToolbarViewBinding(), private lateinit var launcherResultMHJ: ActivityResultLauncher private lateinit var launcherResultZHJ: ActivityResultLauncher + + private val CAMERA_REQUEST_CAMERA_SCAN: Int = 7 //请求码 + private val CAMERA_REQUEST_CAMERA_SCAN_ONE: Int = 8 //请求码 + override fun getViewBinding() = ActivityHjpdBinding.inflate(layoutInflater) override fun getToolbar() = binding.toolbarView.toolbar @@ -86,12 +95,10 @@ class HjpdActivity : BaseActivityOaToolbarViewBinding(), } }) binding.tvSys.setOnClickListener(View.OnClickListener { - val intentMHJ = Intent(this, MipcaActivityCapture::class.java) - launcherResultMHJ.launch(intentMHJ) + intentTOQRCode() }) binding.tvSyswz.setOnClickListener(View.OnClickListener { - val intentZHJ = Intent(this, MipcaActivityCapture::class.java) - launcherResultZHJ.launch(intentZHJ) + intentTOQRCodeOne() }) binding.btnItqz.setOnClickListener(View.OnClickListener { binding.etXmh.setText("IT") @@ -112,6 +119,18 @@ class HjpdActivity : BaseActivityOaToolbarViewBinding(), } + private fun intentTOQRCode() { + val intentMHJ = Intent(this, QrCodeActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) + launcherResultMHJ.launch(intentMHJ) + } + + private fun intentTOQRCodeOne() { + val intentZHJ = Intent(this, QrCodeActivity::class.java) + intentZHJ.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) + launcherResultZHJ.launch(intentZHJ) + } + //创建一个ActivityResultLauncher private fun createActivityResultLauncherMHJ(): ActivityResultLauncher { //kotlin写法 @@ -119,9 +138,11 @@ class HjpdActivity : BaseActivityOaToolbarViewBinding(), val resultIntent = it.data val resultCode = it.resultCode if (resultCode == RESULT_OK) { - val resultText = resultIntent?.getStringExtra("result") ?: "" + val resultText = resultIntent?.getStringExtra("code") ?: "" binding.etHgtm.setText(resultText) if (!TextUtils.isEmpty(resultText)) { + showLog("-------") + showLog(resultText) getSpinnerParentData(resultText) } } @@ -135,7 +156,7 @@ class HjpdActivity : BaseActivityOaToolbarViewBinding(), val resultIntent = it.data val resultCode = it.resultCode if (resultCode == RESULT_OK) { - val resultText = resultIntent?.getStringExtra("result") ?: "" + val resultText = resultIntent?.getStringExtra("code") ?: "" binding.etXmh.setText(resultText) } } diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/KcpdActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/KcpdActivity.java index 1f742a0..bfe5f2f 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/KcpdActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/KcpdActivity.java @@ -6,6 +6,11 @@ import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.os.Bundle; + +import androidx.activity.result.ActivityResult; +import androidx.activity.result.ActivityResultCallback; +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; import androidx.appcompat.app.AlertDialog; import android.text.TextUtils; import android.view.View; @@ -61,6 +66,9 @@ public class KcpdActivity extends BaseActivity2 implements KcpdAdapter.Callback TextView tvSyswz; Spinner spBz; + private ActivityResultLauncher launcherResultQRCode; + private ActivityResultLauncher launcherResultQRCodeOne; + private void findView() { et_hgtm = findViewById(R.id.et_hgtm); tv_sys = findViewById(R.id.tv_sys); @@ -163,15 +171,13 @@ public class KcpdActivity extends BaseActivity2 implements KcpdAdapter.Callback tv_sys.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(KcpdActivity.this, MipcaActivityCapture.class); - startActivityForResult(intent, 1); + intentTOQRCode(); } }); tvSyswz.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent1 = new Intent(KcpdActivity.this, MipcaActivityCapture.class); - startActivityForResult(intent1, 2); + intentTOQRCodeOne(); } }); btn_itqz.setOnClickListener(new View.OnClickListener() { @@ -186,7 +192,6 @@ public class KcpdActivity extends BaseActivity2 implements KcpdAdapter.Callback private KcpdAdapter adapter; private List infos; private View headView; - private String pdid; private int selectItem = -1; @@ -199,6 +204,8 @@ public class KcpdActivity extends BaseActivity2 implements KcpdAdapter.Callback @Override protected void initView() { findView(); + launcherResultQRCode = createQRCodeActivityResultLauncher(); + launcherResultQRCodeOne = createQRCodeActivityResultLauncher1(); } public void initData() { @@ -214,25 +221,72 @@ public class KcpdActivity extends BaseActivity2 implements KcpdAdapter.Callback headView.findViewById(R.id.head).setVisibility(View.VISIBLE); } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - switch (requestCode) { - case 1: - if (resultCode == RESULT_OK) { - Bundle bundle = data.getExtras(); - String resultText = bundle.getString("result"); - et_hgtm.setText(resultText); - } - break; - case 2: - if (resultCode == RESULT_OK) { - Bundle bundle = data.getExtras(); - String resultText = bundle.getString("result"); - etXmh.setText(resultText); - } - break; - } + private void intentTOQRCode(){ + Intent intent = new Intent(context, QrCodeActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + //startActivity(intent); + launcherResultQRCode.launch(intent); + } + + private void intentTOQRCodeOne(){ + Intent intent = new Intent(context, QrCodeActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + //startActivity(intent); + launcherResultQRCodeOne.launch(intent); + } + +// @Override +// protected void onActivityResult(int requestCode, int resultCode, Intent data) { +// super.onActivityResult(requestCode, resultCode, data); +// switch (requestCode) { +// case 1: +// if (resultCode == RESULT_OK) { +// Bundle bundle = data.getExtras(); +// String resultText = bundle.getString("result"); +// et_hgtm.setText(resultText); +// } +// break; +// case 2: +// if (resultCode == RESULT_OK) { +// Bundle bundle = data.getExtras(); +// String resultText = bundle.getString("result"); +// etXmh.setText(resultText); +// } +// break; +// } +// } + + private ActivityResultLauncher createQRCodeActivityResultLauncher() { + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), + new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + int resultCode = result.getResultCode(); + Intent data = result.getData(); + if (resultCode == RESULT_OK) { + if(data!=null){ + String code = data.getStringExtra("code"); + et_hgtm.setText(code); + } + } + } + }); + } + private ActivityResultLauncher createQRCodeActivityResultLauncher1() { + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), + new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + int resultCode = result.getResultCode(); + Intent data = result.getData(); + if (resultCode == RESULT_OK) { + if(data!=null){ + String code = data.getStringExtra("code"); + etXmh.setText(code); + } + } + } + }); } //CheckBox点击事件 diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/LoginActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/LoginActivity.kt index d7832e8..83bc806 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/LoginActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/LoginActivity.kt @@ -33,7 +33,11 @@ import com.yolanda.nohttp.NoHttp import com.yolanda.nohttp.RequestMethod import com.yolanda.nohttp.rest.Response - +/** + * Create By HuangWenFei + * 创建日期:2023-07-15 10:23 + * 描述:代码改成kotlin,按厂里要求,接口上下行加密,防止数据传输入过程密码泄密 + */ class LoginActivity : BaseActivityOaToolbarViewBinding() { private lateinit var networkCheckType: String @@ -169,8 +173,8 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { if (isApkInDebug(context)) { // 管理员 - binding.etUsername.setText("ZHPS_Admin") - binding.etPassword.setText("Rehome.zhps@996") +// binding.etUsername.setText("ZHPS_Admin") +// binding.etPassword.setText("Rehome.zhps@996") //公司内网215管理员 // binding.etUsername.setText("ZHPS_Admin") diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/MateLablePrintFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/MateLablePrintFragment.java index 8b324cb..34d74a8 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/MateLablePrintFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/MateLablePrintFragment.java @@ -12,9 +12,7 @@ import android.widget.CheckBox; import android.widget.EditText; import android.widget.ListView; import android.widget.TextView; - import com.google.gson.Gson; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.R; import com.rehome.zhdcoa.adapter.PoInfoadapter; @@ -329,7 +327,7 @@ public class MateLablePrintFragment extends BaseFragment implements PoInfoadapte // "^FO50,50^XGR:imgName.GRF,1,1^FS" + // "^PQ" + 1 + ",,,^XZ"; //// -// Logger.v("打印数据" + str); +// showLog("打印数据" + str); if (strs.size() == prints.size()) { @@ -351,7 +349,7 @@ public class MateLablePrintFragment extends BaseFragment implements PoInfoadapte } }).start(); } -// Logger.v("打印数据" + response.get()); +// showLog("打印数据" + response.get()); // showToast(response.get()); break; } @@ -481,7 +479,7 @@ public class MateLablePrintFragment extends BaseFragment implements PoInfoadapte "^PQ" + page + ",,,^XZ"; } - Logger.v("打印数据" + str); + showLog("打印数据" + str); configLabel = str.getBytes(); @@ -576,7 +574,7 @@ public class MateLablePrintFragment extends BaseFragment implements PoInfoadapte // "^XA" + // "^F050,50^XGR:AA.GRF,3,3^FS" + // "^XZ"; -// Logger.v(cc); +// showLog(cc); // // String cesi = BitmapString.convertStringToIcon("广东省粤电集团有限公司珠海发电厂", "DC") + // "^XA" + diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/MaterialIssue.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/MaterialIssue.java index 9c9d7ef..e520620 100755 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/MaterialIssue.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/MaterialIssue.java @@ -13,7 +13,6 @@ import android.widget.LinearLayout; import android.widget.ListView; import android.widget.Spinner; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.R; @@ -342,7 +341,7 @@ public class MaterialIssue extends BaseActivity2 implements WlffAdapter.CallBack private void sendNoHttpRequestPost() { Request request = NoHttp.createStringRequest(Contans.IP + Contans.WLFFSC, RequestMethod.POST); request.setDefineRequestBodyForJson(toJson()); - Logger.v(toJson()); + showLog(toJson()); NohttpUtils.getInstance().add(this, SC_FLAG, request, listener, true, true, "上传中..."); } @@ -360,7 +359,7 @@ public class MaterialIssue extends BaseActivity2 implements WlffAdapter.CallBack public void onSucceed(int what, Response response) { System.out.println("json" + response.get()); - Logger.json(response.get()); + showLog(response.get()); switch (what) { case CX_FLAG: info = GsonUtils.GsonToBean(response.get(), WlffInfo.class); @@ -535,7 +534,7 @@ public class MaterialIssue extends BaseActivity2 implements WlffAdapter.CallBack //如果没有选中。 if (cb.isChecked() == false) { lists.get(index).setPrint(false); - Logger.v("执行到这里..click" + index); + showLog("执行到这里..click" + index); clearView(); seletcitem = -1; } else { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/MipcaActivityCapture.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/MipcaActivityCapture.java deleted file mode 100644 index 2cc72db..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/MipcaActivityCapture.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.rehome.zhdcoa.ui.activity; - -import android.Manifest; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.res.AssetFileDescriptor; -import android.graphics.Bitmap; -import android.media.AudioManager; -import android.media.MediaPlayer; -import android.os.Bundle; -import android.os.Handler; -import android.os.Vibrator; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.widget.Toast; -import androidx.annotation.NonNull; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import com.rehome.zhdcoa.R; -import com.rehome.zhdcoa.base.BaseActivity2; -import com.rehome.zhdcoa.zxing.camera.CameraManager; -import com.rehome.zhdcoa.zxing.decoding.CaptureActivityHandler; -import com.rehome.zhdcoa.zxing.decoding.InactivityTimer; -import com.rehome.zhdcoa.zxing.view.ViewfinderView; -import java.io.IOException; -import java.util.Vector; - -/** - * Created by ruihong on 2017/10/28. - */ - -public class MipcaActivityCapture extends BaseActivity2 implements SurfaceHolder.Callback { - - private static final int CAMERA_REQUEST_CODE = 3;//请求码 - - private SurfaceHolder mSurfaceHolder; - - private CaptureActivityHandler handler; - private ViewfinderView viewfinderView; - private boolean hasSurface; - private Vector decodeFormats; - private String characterSet; - private InactivityTimer inactivityTimer; - private MediaPlayer mediaPlayer; - private boolean playBeep; - private static final float BEEP_VOLUME = 0.10f; - private boolean vibrate; - - @Override - public int getContentViewID() { - return R.layout.activity_capture; - } - - @Override - protected void initView() { - CameraManager.init(getApplication()); - viewfinderView = findViewById(R.id.viewfinder_view); - hasSurface = false; - inactivityTimer = new InactivityTimer(this); - setTitle("二维码/条码扫描"); - setBack(); - } - - @Override - protected void onResume() { - super.onResume(); - SurfaceView surfaceView = findViewById(R.id.preview_view); - SurfaceHolder surfaceHolder = surfaceView.getHolder(); - if (hasSurface) { - initCamera(surfaceHolder); - } else { - surfaceHolder.addCallback(this); - surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - } - decodeFormats = null; - characterSet = null; - - playBeep = true; - AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE); - if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) { - playBeep = false; - } - initBeepSound(); - vibrate = true; - - } - - @Override - protected void onPause() { - super.onPause(); - if (handler != null) { - handler.quitSynchronously(); - handler = null; - } - - CameraManager.get().closeDriver(); - } - - @Override - protected void onDestroy() { - inactivityTimer.shutdown(); - super.onDestroy(); - } - - - public void handleDecode(Result result, Bitmap barcode) { - - - inactivityTimer.onActivity(); - - - playBeepSoundAndVibrate(); - - String[] b = result.getText().split("\\t"); - - String Result = b[0]; - - if (Result.equals("")) { - - showToast("Scan failed!"); - - } else { - - Intent resultIntent = new Intent(); - - Bundle bundle = new Bundle(); - - bundle.putString("result", Result); - - resultIntent.putExtras(bundle); - - setResult(RESULT_OK, resultIntent); - } - finish(); - } - - private void initCamera(SurfaceHolder surfaceHolder) { - try { - CameraManager.get().openDriver(surfaceHolder); - } catch (IOException | RuntimeException ioe) { - return; - } - if (handler == null) { - handler = new CaptureActivityHandler(this, decodeFormats, - characterSet); - } - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - - } - - @Override - public void surfaceCreated(SurfaceHolder holder) { - if (!hasSurface) { - hasSurface = true; - checkPermission(holder); - } - } - - - @Override - public void surfaceDestroyed(SurfaceHolder holder) { - hasSurface = false; - - } - - - private void checkPermission(SurfaceHolder surfaceHolder) { - /** - * 检测 设备是否支持闪光灯 - */ - if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { - showToast("设备没有闪光灯,无法开启手电筒"); - return; - } - - this.mSurfaceHolder = surfaceHolder; - - //动态权限申请 - if (ContextCompat.checkSelfPermission(MipcaActivityCapture.this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { - //权限请求 - ActivityCompat.requestPermissions(MipcaActivityCapture.this, new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CODE); - } else { - initCamera(surfaceHolder); - } - } - - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (CAMERA_REQUEST_CODE==requestCode){ - if (grantResults.length>0&&grantResults[0]==PackageManager.PERMISSION_GRANTED) { - checkPermission(this.mSurfaceHolder); - }else { - //权限拒绝 - Toast.makeText(MipcaActivityCapture.this, "没有权限,请到设置-权限管理中开启", Toast.LENGTH_SHORT).show(); - finish(); - } - } - } - - - public ViewfinderView getViewfinderView() { - return viewfinderView; - } - - public Handler getHandler() { - return handler; - } - - public void drawViewfinder() { - viewfinderView.drawViewfinder(); - - } - - private void initBeepSound() { - if (playBeep && mediaPlayer == null) { - setVolumeControlStream(AudioManager.STREAM_MUSIC); - mediaPlayer = new MediaPlayer(); - mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); - mediaPlayer.setOnCompletionListener(beepListener); - - AssetFileDescriptor file = getResources().openRawResourceFd( - R.raw.beep); - try { - mediaPlayer.setDataSource(file.getFileDescriptor(), - file.getStartOffset(), file.getLength()); - file.close(); - mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME); - mediaPlayer.prepare(); - } catch (IOException e) { - mediaPlayer = null; - } - } - } - - private static final long VIBRATE_DURATION = 200L; - - private void playBeepSoundAndVibrate() { - if (playBeep && mediaPlayer != null) { - mediaPlayer.start(); - } - if (vibrate) { - Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); - vibrator.vibrate(VIBRATE_DURATION); - } - } - - /** - * When the beep has finished playing, rewind to queue up another one. - */ - private final MediaPlayer.OnCompletionListener beepListener = mediaPlayer -> mediaPlayer.seekTo(0); - - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/QrCodeActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/QrCodeActivity.kt index 6c16f3b..2389b8d 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/QrCodeActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/QrCodeActivity.kt @@ -1,14 +1,19 @@ package com.rehome.zhdcoa.ui.activity +import android.Manifest import android.annotation.SuppressLint import android.content.Intent +import android.content.pm.PackageManager import android.graphics.Rect import android.graphics.RectF import android.os.Bundle -import android.util.Log +import android.view.View +import android.widget.Toast import androidx.camera.core.ImageCapture import androidx.camera.view.LifecycleCameraController +import androidx.core.app.ActivityCompat +import androidx.core.content.ContextCompat import com.rehome.zhdcoa.databinding.ActivityQrCodeBinding import com.rehome.zhdcoa.Listener.QRCodeAnalyser import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding @@ -16,14 +21,15 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.Executors /** - * date:2021/6/18 - * author:zhangteng + * date:2025/02/13 10:05:28 + * author:HuangWenfei * description:二维码扫描 */ class QrCodeActivity : BaseActivityOaToolbarViewBinding() { - //private lateinit var binding: ActivityQrCodeBinding + private lateinit var lifecycleCameraController: LifecycleCameraController private lateinit var cameraExecutor: ExecutorService + private val CAMERA_REQUEST_CAMERA_SCAN: Int = 88 //请求码 // override fun onCreate(savedInstanceState: Bundle?) { // super.onCreate(savedInstanceState) @@ -39,13 +45,68 @@ class QrCodeActivity : BaseActivityOaToolbarViewBinding() override fun initView() { initToolbar("二维码/条码扫描") setLeftOnClickListener { finish() } - initController() + checkPermission() + //initController() } override fun initData() { } + private fun checkPermission(){ + //检测摄像头权限 + if (!context.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) { + binding.frCamera.visibility=View.GONE + Toast.makeText( + context, + "权限拒绝,请手动设置开启APP访问摄像头权限", + Toast.LENGTH_LONG + ).show() + return + } + + //动态权限申请 + if (ContextCompat.checkSelfPermission( + context, + Manifest.permission.CAMERA + ) != PackageManager.PERMISSION_GRANTED + ) { + binding.frCamera.visibility=View.GONE + //权限请求 + ActivityCompat.requestPermissions( + this, + arrayOf(Manifest.permission.CAMERA), + CAMERA_REQUEST_CAMERA_SCAN + ) + } else { + //已授权,打开摄像头扫描 + initController() + } + } + + override fun onRequestPermissionsResult( + requestCode: Int, + permissions: Array, + grantResults: IntArray + ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) + if (CAMERA_REQUEST_CAMERA_SCAN == requestCode) { + if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) { + binding.frCamera.visibility=View.VISIBLE + //已授权,打开摄像头扫描 + initController() + } else { + binding.frCamera.visibility=View.GONE + //权限拒绝 + Toast.makeText( + this, + "权限拒绝,请手动设置开启APP访问摄像头权限", + Toast.LENGTH_SHORT + ).show() + } + } + } + @SuppressLint("ClickableViewAccessibility", "UnsafeOptInUsageError") private fun initController() { cameraExecutor = Executors.newSingleThreadExecutor() @@ -66,12 +127,12 @@ class QrCodeActivity : BaseActivityOaToolbarViewBinding() barcode.boundingBox?.let { rect -> val translateRect = translateRect(rect) list.add(translateRect) - Log.e( - "ztzt", "left:${translateRect.left} +" + - " top:${translateRect.top} + right:${translateRect.right}" + - " + bottom:${translateRect.bottom}" - ) - Log.e("ztzt", "barcode.rawValue:${barcode.rawValue}") +// Log.e( +// "ztzt", "left:${translateRect.left} +" + +// " top:${translateRect.top} + right:${translateRect.right}" + +// " + bottom:${translateRect.bottom}" +// ) +// Log.e("ztzt", "barcode.rawValue:${barcode.rawValue}") strList.add(barcode.rawValue ?: "No Value") } } @@ -86,16 +147,12 @@ class QrCodeActivity : BaseActivityOaToolbarViewBinding() val sb = StringBuilder() list.forEach { sb.append(it) - sb.append("\n") + //sb.append("\n") } intentToResult(sb.toString()) } private fun intentToResult(result: String) { -// val intent = Intent(this, QRCodeResultActivity::class.java) -// intent.putExtra(QRCodeResultActivity.RESULT_KEY, result) -// startActivity(intent) -// finish() val resultIntent = Intent() val bundle = Bundle() bundle.putString("code", result) @@ -120,31 +177,9 @@ class QrCodeActivity : BaseActivityOaToolbarViewBinding() //初始化缩放比例 private fun initScale(imageWidth: Int, imageHeight: Int) { - Log.e("ztzt", "imageWidth:${imageWidth} + imageHeight:${imageHeight}") + //Log.e("ztzt", "imageWidth:${imageWidth} + imageHeight:${imageHeight}") scaleY = binding.scanView.height.toFloat() / imageWidth.toFloat() scaleX = binding.scanView.width.toFloat() / imageHeight.toFloat() - Log.e("ztzt", "scaleX:${scaleX} + scaleY:${scaleY}") + //Log.e("ztzt", "scaleX:${scaleX} + scaleY:${scaleY}") } -} - - -// -//import android.os.Bundle -//import androidx.activity.enableEdgeToEdge -//import androidx.appcompat.app.AppCompatActivity -//import androidx.core.view.ViewCompat -//import androidx.core.view.WindowInsetsCompat -//import com.rehome.zhdcoa.R -// -//class QrCodeActivity : AppCompatActivity() { -// override fun onCreate(savedInstanceState: Bundle?) { -// super.onCreate(savedInstanceState) -// enableEdgeToEdge() -// setContentView(R.layout.activity_qr_code) -// ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> -// val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) -// v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) -// insets -// } -// } -//} \ No newline at end of file +} \ No newline at end of file diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/RealTimeKcpdHistoryActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/RealTimeKcpdHistoryActivity.kt index 8fba853..0083d13 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/RealTimeKcpdHistoryActivity.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/RealTimeKcpdHistoryActivity.kt @@ -69,12 +69,10 @@ class RealTimeKcpdHistoryActivity : BaseActivityOaToolbarViewBinding { //kotlin写法 @@ -128,7 +138,7 @@ class RealTimeKcpdHistoryActivity : BaseActivityOaToolbarViewBinding request1 = NoHttp.createStringRequest(Contans.IP + Contans.DJJHQXGD, RequestMethod.POST); String qxgdjson = "{\"Rows\":" + GsonUtils.GsonString(infos) + ",\"Total\": " + infos.size() + "}"; - Logger.json(qxgdjson); + showLog(qxgdjson); System.out.println(qxgdjson); qxgdjson = new String(qxgdjson.getBytes(), StandardCharsets.UTF_8); request1.setDefineRequestBodyForJson(UiUtlis.encoder(qxgdjson)); diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/TlrkActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/TlrkActivity.java index 661eef4..b0f6b0c 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/TlrkActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/TlrkActivity.java @@ -12,7 +12,6 @@ import android.widget.LinearLayout; import android.widget.ListView; import android.widget.Spinner; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.R; @@ -280,7 +279,7 @@ public class TlrkActivity extends BaseActivity2 implements TlrkAdapter.CallBack private void sendRequestNohttpPost() { Request request = NoHttp.createStringRequest(Contans.IP + Contans.TLRKSC, RequestMethod.POST); request.setDefineRequestBodyForJson(toJson()); - Logger.v(toJson()); + showLog(toJson()); NohttpUtils.getInstance().add(TlrkActivity.this, 1, request, callback, true, true, "上传中..."); } @@ -404,7 +403,7 @@ public class TlrkActivity extends BaseActivity2 implements TlrkAdapter.CallBack // if (position != 0) { // if (lists.get(position - 1).isPrint() == true) { // lists.get(position - 1).setPrint(false); -// Logger.v("执行到这里..item"); +// showLog("执行到这里..item"); // clearView(); // } else { // lists.get(position - 1).setPrint(true); @@ -486,7 +485,7 @@ public class TlrkActivity extends BaseActivity2 implements TlrkAdapter.CallBack //如果没有选中。 if (cb.isChecked() == false) { lists.get(index).setPrint(false); - Logger.v("执行到这里..click" + index); + showLog("执行到这里..click" + index); clearView(); seletcitem = -1; } else { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/TmdyActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/TmdyActivity.java index 75e6e2d..f82c723 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/TmdyActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/TmdyActivity.java @@ -28,8 +28,6 @@ import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; - -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.R; @@ -472,7 +470,7 @@ public class TmdyActivity extends BaseActivity2 implements TmdyAdapter.CallBack e.printStackTrace(); } - Logger.v("打印数据" + response.get()); + showLog("打印数据" + response.get()); // showToast(response.get()); break; } @@ -625,7 +623,7 @@ public class TmdyActivity extends BaseActivity2 implements TmdyAdapter.CallBack "^PQ" + count + ",,,^XZ"; } - Logger.v("打印数据" + str); + showLog("打印数据" + str); configLabel = str.getBytes(); } else if (printerLanguage == PrinterLanguage.CPCL) { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscFragment.java index 2cfe89f..95a91ec 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscFragment.java @@ -11,8 +11,6 @@ import android.widget.Button; import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; - -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.LyXcjsInfo; import com.rehome.zhdcoa.DBModel.LyYhpcInfo; @@ -461,7 +459,7 @@ public class XscFragment extends BaseFragment { bajson = new String(ba.toString().getBytes(), StandardCharsets.UTF_8); xfjson = new String(xf.toString().getBytes(), StandardCharsets.UTF_8); lyjson = new String(ly.toString().getBytes(), StandardCharsets.UTF_8); - Logger.v(bajson); + showLog(bajson); sCData(xfjson, bajson, lyjson); } } @@ -595,7 +593,7 @@ public class XscFragment extends BaseFragment { if (!xf.isEmpty()) { requestCount++; - Logger.v(xf); + showLog(xf); Request request = NoHttp.createStringRequest(Contans.IP + Contans.XFDJJHSC + "?cjscr=" + UiUtlis.encoder(App.getInstance().getUserInfo().getManid()), RequestMethod.POST); request.setDefineRequestBodyForJson(UiUtlis.encoder(xf)); if (App.getInstance().getUserInfo() != null && App.getInstance().getUserInfo().getToken() != null) { @@ -634,7 +632,7 @@ public class XscFragment extends BaseFragment { } if (!ba.isEmpty()) { requestCount++; - Logger.v(ba); + showLog(ba); Request baxc = NoHttp.createStringRequest(Contans.IP + Contans.BAXCJHSC + "?cjscr=" + UiUtlis.encoder(App.getInstance().getUserInfo().getManid()), RequestMethod.POST); baxc.setDefineRequestBodyForJson(UiUtlis.encoder(ba)); if(App.getInstance().getUserInfo()!=null&&App.getInstance().getUserInfo().getToken()!=null){ @@ -650,7 +648,7 @@ public class XscFragment extends BaseFragment { } if (!ly.isEmpty()) { - Logger.v(ly); + showLog(ly); // //上传隐患排查单 List info = DataSupport.findAll(LyYhpcInfo.class); if (info.size() != 0) { @@ -709,7 +707,7 @@ public class XscFragment extends BaseFragment { private final HttpListener callback = new HttpListener() { @Override public void onSucceed(int what, Response response) { - Logger.v(response.get()); + showLog(response.get()); System.out.println("消防" + response.get()); StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class); if (info != null && info.getTotal() != 0) { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscbqyActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscbqyActivity.java index 05ae50f..929905b 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscbqyActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XscbqyActivity.java @@ -6,6 +6,12 @@ import android.text.TextUtils; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; + +import androidx.activity.result.ActivityResult; +import androidx.activity.result.ActivityResultCallback; +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; + import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.R; import com.rehome.zhdcoa.adapter.XsjhqyAdapter; @@ -43,6 +49,9 @@ public class XscbqyActivity extends BaseActivity2 { private boolean isSHOW; + private static final int CAMERA_REQUEST_CAMERA_SCAN = 7;//请求码 + private ActivityResultLauncher launcherResultQRCode; + @Override public int getContentViewID() { return R.layout.activity_xscbqy; @@ -55,6 +64,8 @@ public class XscbqyActivity extends BaseActivity2 { xscbjh = mIntent.getParcelableExtra(Contans.KEY_XSCBJH); isHistory = mIntent.getBooleanExtra(Contans.KEY_XS_HISTORY, false); + launcherResultQRCode = createQRCodeActivityResultLauncher(); + if (QX != null) { QX = getIntent().getExtras().getString("QX");//如果权限为1 可以修改历史记录 isSHOW = "0".equals(QX); @@ -175,8 +186,7 @@ public class XscbqyActivity extends BaseActivity2 { } } else { - Intent intent = new Intent(XscbqyActivity.this, MipcaActivityCapture.class); - startActivityForResult(intent, 1); + intentTOQRCode(); } } } @@ -187,42 +197,84 @@ public class XscbqyActivity extends BaseActivity2 { } } - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - switch (requestCode) { - case 1: - if (resultCode == RESULT_OK) { - Bundle bundle = data.getExtras(); - String ewm = bundle.getString("result"); - for (XsjhQyBean.DataBeanX qy : qys) { - if (ewm.equals(qy.getTxm())) { + private void intentTOQRCode(){ + Intent intent = new Intent(context, QrCodeActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + launcherResultQRCode.launch(intent); + } - if (xscbjh.getJhlx().equals(XscbqyWorkActivity.JHLX_XS)) { - Intent intent = new Intent(XscbqyActivity.this, XscbqyWorkXsActivity.class); - intent.putExtra(Contans.KEY_QY, qy); - intent.putExtra(Contans.KEY_EWM_OR_NFC, "扫描条码"); - intent.putExtra(Contans.KEY_JHLX, xscbjh.getJhlx()); -// intent.putExtra(Contans.KEY_IS_HIS, qy.getSczt().equals("1") ? true : false); - intent.putExtra(Contans.KEY_IS_HIS, false); - startActivity(intent); - } else { - Intent intent = new Intent(XscbqyActivity.this, XscbqyWorkActivity.class); - intent.putExtra(Contans.KEY_QY, qy); - intent.putExtra(Contans.KEY_EWM_OR_NFC, "扫描条码"); - intent.putExtra(Contans.KEY_JHLX, xscbjh.getJhlx()); -// intent.putExtra(Contans.KEY_IS_HIS, qy.getSczt().equals("1") ? true : false); - intent.putExtra(Contans.KEY_IS_HIS, false); - startActivity(intent); + private ActivityResultLauncher createQRCodeActivityResultLauncher() { + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), + new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + int resultCode = result.getResultCode(); + Intent data = result.getData(); + if (resultCode == RESULT_OK) { + if(data!=null){ + String ewm = data.getStringExtra("code"); + for (XsjhQyBean.DataBeanX qy : qys) { + if (ewm!=null&&ewm.equals(qy.getTxm())) { + if (xscbjh.getJhlx().equals(XscbqyWorkActivity.JHLX_XS)) { + Intent intent = new Intent(XscbqyActivity.this, XscbqyWorkXsActivity.class); + intent.putExtra(Contans.KEY_QY, qy); + intent.putExtra(Contans.KEY_EWM_OR_NFC, "扫描条码"); + intent.putExtra(Contans.KEY_JHLX, xscbjh.getJhlx()); + intent.putExtra(Contans.KEY_IS_HIS, false); + startActivity(intent); + } else { + Intent intent = new Intent(XscbqyActivity.this, XscbqyWorkActivity.class); + intent.putExtra(Contans.KEY_QY, qy); + intent.putExtra(Contans.KEY_EWM_OR_NFC, "扫描条码"); + intent.putExtra(Contans.KEY_JHLX, xscbjh.getJhlx()); + intent.putExtra(Contans.KEY_IS_HIS, false); + startActivity(intent); + } + return; + } + } } - return; } } - } - break; - } + }); } +// @Override +// protected void onActivityResult(int requestCode, int resultCode, Intent data) { +// super.onActivityResult(requestCode, resultCode, data); +// switch (requestCode) { +// case 1: +// if (resultCode == RESULT_OK) { +// Bundle bundle = data.getExtras(); +// String ewm = bundle.getString("result"); +// for (XsjhQyBean.DataBeanX qy : qys) { +// if (ewm.equals(qy.getTxm())) { +// +// if (xscbjh.getJhlx().equals(XscbqyWorkActivity.JHLX_XS)) { +// Intent intent = new Intent(XscbqyActivity.this, XscbqyWorkXsActivity.class); +// intent.putExtra(Contans.KEY_QY, qy); +// intent.putExtra(Contans.KEY_EWM_OR_NFC, "扫描条码"); +// intent.putExtra(Contans.KEY_JHLX, xscbjh.getJhlx()); +//// intent.putExtra(Contans.KEY_IS_HIS, qy.getSczt().equals("1") ? true : false); +// intent.putExtra(Contans.KEY_IS_HIS, false); +// startActivity(intent); +// } else { +// Intent intent = new Intent(XscbqyActivity.this, XscbqyWorkActivity.class); +// intent.putExtra(Contans.KEY_QY, qy); +// intent.putExtra(Contans.KEY_EWM_OR_NFC, "扫描条码"); +// intent.putExtra(Contans.KEY_JHLX, xscbjh.getJhlx()); +//// intent.putExtra(Contans.KEY_IS_HIS, qy.getSczt().equals("1") ? true : false); +// intent.putExtra(Contans.KEY_IS_HIS, false); +// startActivity(intent); +// } +// return; +// } +// } +// } +// break; +// } +// } + private String createJson() { XsRequestInfo info = new XsRequestInfo(); info.setAction("XSCB_ZXJHD_GET"); diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxfxcActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxfxcActivity.java index 80af3fc..457f716 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxfxcActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxfxcActivity.java @@ -117,7 +117,6 @@ public class XxfxcActivity extends BaseActivity2 { private void intentTOQRCode(){ Intent intent = new Intent(XxfxcActivity.this, QrCodeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); - //startActivity(intent); launcherResultQRCode.launch(intent); } diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxzjhFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxzjhFragment.java index eda86c4..ef0fa86 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxzjhFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/XxzjhFragment.java @@ -2,13 +2,13 @@ package com.rehome.zhdcoa.ui.activity; import android.content.ContentValues; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.CheckBox; import android.widget.ListView; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.LyxcXmList; @@ -373,7 +373,7 @@ public class XxzjhFragment extends BaseFragment { break; case 4: - Logger.v(response.get()); + showLog(response.get()); XfBaxcRwqyList xfbas = GsonUtils.GsonToBean(response.get(), XfBaxcRwqyList.class); if (xfbas != null) { successCount++; diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpcFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpcFragment.java index dbc01b0..5cf74ea 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpcFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpcFragment.java @@ -20,7 +20,6 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.Ajhxzrwqy; @@ -317,7 +316,7 @@ public class YhpcFragment extends BaseFragment { @Override public void onSucceed(int what, Response response) { System.out.println("json" + response.get()); - Logger.json(response.get()); + showLog(response.get()); try { StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class); if (info != null) { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrActivity.java index 75bd1e6..0dc08ae 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrActivity.java @@ -13,6 +13,11 @@ import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; + +import androidx.activity.result.ActivityResult; +import androidx.activity.result.ActivityResultCallback; +import androidx.activity.result.ActivityResultLauncher; +import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; @@ -24,7 +29,6 @@ import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.Qy; import com.rehome.zhdcoa.DBModel.YhpcInfo; @@ -35,7 +39,6 @@ import com.rehome.zhdcoa.entity.StatusInfo; import com.rehome.zhdcoa.utils.GsonUtils; import com.rehome.zhdcoa.utils.HttpListener; import com.rehome.zhdcoa.utils.NohttpUtils; -import com.rehome.zhdcoa.utils.SPUtils; import com.rehome.zhdcoa.utils.UiUtlis; import com.rehome.zhdcoa.weiget.WaitDialog; import com.yolanda.nohttp.FileBinary; @@ -111,8 +114,7 @@ public class YhpclrActivity extends BaseActivity2 { btnSm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(context, MipcaActivityCapture.class); - startActivityForResult(intent, 1); + intentTOQRCode(); } }); btnPz.setOnClickListener(new View.OnClickListener() { @@ -189,6 +191,9 @@ public class YhpclrActivity extends BaseActivity2 { private static final int STPZ = 101; private Uri uriTakePic; + private static final int CAMERA_REQUEST_CAMERA_SCAN = 7;//请求码 + private ActivityResultLauncher launcherResultQRCode; + @Override public int getContentViewID() { return R.layout.activity_yhpclr; @@ -201,6 +206,7 @@ public class YhpclrActivity extends BaseActivity2 { setTitle("隐患排查录入"); initNFC(); + launcherResultQRCode = createQRCodeActivityResultLauncher(); isUpdate = getIntent().getExtras().getBoolean("isUpdate"); id = getIntent().getStringExtra("guid"); @@ -235,6 +241,37 @@ public class YhpclrActivity extends BaseActivity2 { dialog = new WaitDialog(context, "上传中..."); } + private void intentTOQRCode(){ + Intent intent = new Intent(context, QrCodeActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + launcherResultQRCode.launch(intent); + } + + private ActivityResultLauncher createQRCodeActivityResultLauncher() { + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), + new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + int resultCode = result.getResultCode(); + Intent data = result.getData(); + if (resultCode == RESULT_OK) { + if(data!=null){ + String code = data.getStringExtra("code"); + List qys = DataSupport.where("txm = ?", code).find(Qy.class); + if (!qys.isEmpty()) { + qycode = qys.get(0).getAREACODE(); + tvQy.setText(qys.get(0).getAREANAME()); + } else { + qycode = ""; + tvQy.setText(""); + } + } + } + } + }); + } + + /** * 申请权限回调 * @@ -244,16 +281,15 @@ public class YhpclrActivity extends BaseActivity2 { */ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (requestCode == STPZ) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { cropFromTake(); } else { //"权限拒绝"); - // TODO: 2018/12/4 这里可以给用户一个提示,请求权限被拒绝了 showToast("拍照请求权限被拒绝,请手动打开后重试"); } } - super.onRequestPermissionsResult(requestCode, permissions, grantResults); } //修改数据 @@ -408,18 +444,18 @@ public class YhpclrActivity extends BaseActivity2 { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { - case 1: - Bundle bundle = data.getExtras(); - List qys = DataSupport.where("txm = ?", (String) bundle.get("result")).find(Qy.class); -// List qys = DataSupport.where("txm = ?", "HX0001").find(Qy.class); - if (qys.size() != 0) { - qycode = qys.get(0).getAREACODE(); - tvQy.setText(qys.get(0).getAREANAME()); - } else { - qycode = ""; - tvQy.setText(""); - } - break; +// case 1: +// Bundle bundle = data.getExtras(); +// List qys = DataSupport.where("txm = ?", (String) bundle.get("result")).find(Qy.class); +//// List qys = DataSupport.where("txm = ?", "HX0001").find(Qy.class); +// if (qys.size() != 0) { +// qycode = qys.get(0).getAREACODE(); +// tvQy.setText(qys.get(0).getAREANAME()); +// } else { +// qycode = ""; +// tvQy.setText(""); +// } +// break; case 9: carpImageUri(uriTakePic); break; @@ -468,7 +504,7 @@ public class YhpclrActivity extends BaseActivity2 { @Override public void onSucceed(int what, Response response) { System.out.println("json" + response.get()); - Logger.json(response.get()); + showLog(response.get()); try { StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class); if (info != null) { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrListActivity.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrListActivity.java index 5e8f89c..39e1f70 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrListActivity.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YhpclrListActivity.java @@ -6,7 +6,6 @@ import android.widget.AdapterView; import android.widget.Button; import android.widget.ListView; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.DBModel.Qy; import com.rehome.zhdcoa.DBModel.YhpcInfo; @@ -185,7 +184,7 @@ public class YhpclrListActivity extends BaseActivity2 { @Override public void onSucceed(int what, Response response) { System.out.println("json" + response.get()); - Logger.json(response.get()); + showLog(response.get()); try { StatusInfo info = GsonUtils.GsonToBean(response.get(), StatusInfo.class); if (info != null) { diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YsAndPzFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YsAndPzFragment.java index 0954188..06e1b92 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/activity/YsAndPzFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/YsAndPzFragment.java @@ -25,7 +25,6 @@ import android.widget.LinearLayout; import android.widget.ListView; import android.widget.ScrollView; import android.widget.TextView; -import com.orhanobut.logger.Logger; import com.rehome.zhdcoa.App; import com.rehome.zhdcoa.Contans; import com.rehome.zhdcoa.R; @@ -390,7 +389,7 @@ public class YsAndPzFragment extends BaseFragment implements YsPzAdapter.CallBac yspz.setTotal(list.size()); String json = GsonUtils.GsonString(yspz); sendNohttpRequestPost(json); - Logger.v("json" + json); + showLog("json" + json); } } } @@ -481,7 +480,7 @@ public class YsAndPzFragment extends BaseFragment implements YsPzAdapter.CallBac public void sendNohttpRequestPost(String json) { Request request = NoHttp.createStringRequest(Contans.IP + Contans.YSPZJSSC, RequestMethod.POST); request.setDefineRequestBodyForJson(json); - Logger.json(json); + showLog(json); NohttpUtils.getInstance().add(getActivity(), SC_FLAG, request, mListener, true, true, "上传中..."); } diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/ContactFragment.kt b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/ContactFragment.kt index 650616d..e991e41 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/ContactFragment.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/ContactFragment.kt @@ -29,7 +29,11 @@ import com.yolanda.nohttp.NoHttp import com.yolanda.nohttp.RequestMethod import com.yolanda.nohttp.rest.Response - +/** + * Create By HuangWenFei + * 创建日期:2025-01-03 11:03 + * 描述:代码改成kotlin,按厂里要求,接口上下行加密,以防数据传输入过程泄密 + */ class ContactFragment : BaseViewBindingKotlinFragment(){ diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/HomeFragment.kt b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/HomeFragment.kt index 893291d..96920ad 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/HomeFragment.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/HomeFragment.kt @@ -88,6 +88,12 @@ import retrofit2.Response import java.text.SimpleDateFormat import java.util.Calendar +/** + * Create By HuangWenFei + * 创建日期:2024-09-15 10:13 + * 描述:代码改成kotlin,首页 + */ + class HomeFragment : BaseViewBindingFragment() { private var AboutMeListdatas: MutableList = mutableListOf() diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/MineFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/MineFragment.java index 36f876b..6d2ae92 100755 --- a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/MineFragment.java +++ b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/MineFragment.java @@ -57,6 +57,7 @@ import com.rehome.zhdcoa.bean.ApkUpdateBean; import com.rehome.zhdcoa.bean.HeadPhotoResultBean; import com.rehome.zhdcoa.bean.QtdbBean; import com.rehome.zhdcoa.ui.activity.AboutMeActivity; +import com.rehome.zhdcoa.ui.activity.ActivityCreatQRCode; import com.rehome.zhdcoa.ui.activity.ApplyAboutMeActivity; import com.rehome.zhdcoa.ui.activity.ChangeMyPhoneActivity; import com.rehome.zhdcoa.ui.activity.EmojiActivity; @@ -137,7 +138,6 @@ public class MineFragment extends BaseLazyFragment { private static final int PICTURE_BOOK_CODE = 4;//请求码 private static final int CAMERA_REQUEST_CODE_END = 5;//请求码 private static final int PICTURE_BOOK_CODE_END = 6;//请求码 - private static final int CAMERA_REQUEST_CAMERA_SCAN = 7;//请求码 private Uri uriTakePicOutput; @@ -387,20 +387,10 @@ public class MineFragment extends BaseLazyFragment { tvSq.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + //进入授权页面 SQApp(); - //检测摄像头权限 -// if (!requireActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) { -// Toast.makeText(getActivity(), "权限拒绝,请手动设置开启APP访问摄像头权限", Toast.LENGTH_LONG).show(); -// return; -// } -// //动态权限申请 -// if (ContextCompat.checkSelfPermission(requireActivity(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { -// //权限请求 -// ActivityCompat.requestPermissions(requireActivity(), new String[]{Manifest.permission.CAMERA}, CAMERA_REQUEST_CAMERA_SCAN); -// } else { -// //已授权,打开摄像头扫描 -// intentTOQRCode(); -// } + //打开摄像头扫描 + //intentTOQRCode(); } }); } @@ -408,7 +398,6 @@ public class MineFragment extends BaseLazyFragment { private void intentTOQRCode(){ Intent intent = new Intent(getActivity(), QrCodeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); - //startActivity(intent); launcherResultQRCode.launch(intent); } @@ -452,15 +441,6 @@ public class MineFragment extends BaseLazyFragment { Toast.makeText(getActivity(), "权限拒绝,请手动设置开启APP访问像册权限", Toast.LENGTH_SHORT).show(); } } - if (CAMERA_REQUEST_CAMERA_SCAN == requestCode) { - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - //已授权,打开摄像头扫描 - intentTOQRCode(); - } else { - //权限拒绝 - Toast.makeText(getActivity(), "权限拒绝,请手动设置开启APP访问摄像头权限", Toast.LENGTH_SHORT).show(); - } - } } @Override diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyaCFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyaCFragment.java deleted file mode 100644 index 539f09b..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyaCFragment.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.rehome.zhdcoa.ui.fragment; - - -import android.content.Intent; -import android.os.Bundle; -import android.text.TextUtils; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.TextView; - -import com.rehome.zhdcoa.App; -import com.rehome.zhdcoa.Contans; -import com.rehome.zhdcoa.R; -import com.rehome.zhdcoa.adapter.YjyaBaseAdapter; -import com.rehome.zhdcoa.base.BaseCallBack; -import com.rehome.zhdcoa.base.BaseFragment; -import com.rehome.zhdcoa.bean.YjyaBaseBean; -import com.rehome.zhdcoa.bean.YjyaItemBean; -import com.rehome.zhdcoa.ui.activity.Activity_Yjyajx_Action; -import com.rehome.zhdcoa.utils.AuthenticationLoginUtils; -import com.rehome.zhdcoa.utils.GsonUtils; -import com.rehome.zhdcoa.utils.HttpUtils; -import com.rehome.zhdcoa.utils.OnAuthenticationLoginListener; -import com.rehome.zhdcoa.utils.RSAUtils; -import com.rehome.zhdcoa.utils.SPUtils; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import retrofit2.Call; -import retrofit2.Response; - -/** - * Created by ruihong on 2018/11/13. - */ - -public class YjyaCFragment extends BaseFragment { - - ListView lv; - TextView tv_nodata; - - private List rowsBeanList = new ArrayList();; - public YjyaBaseAdapter adapter; - public String stime = ""; - public String etime = ""; - - private String userName = ""; - private String password = ""; - - public static YjyaCFragment newInstance() { - YjyaCFragment fragment = new YjyaCFragment(); - return fragment; - } - - - @Override - protected void initView() { - lv = view.findViewById(R.id.lv); - tv_nodata = view.findViewById(R.id.tv_nodata); - tv_nodata.setVisibility(View.VISIBLE); - lv.setVisibility(View.GONE); - - //人员组织结构模块 用户验证接口 - userName = App.getInstance().getUserInfo().getManid(); - String passwordTemp = (String) SPUtils.get(context, Contans.SP.AF_PASS_WORD, String.valueOf("")); - if (!TextUtils.isEmpty(passwordTemp)) { - password = RSAUtils.decryptBASE64StrLocal(passwordTemp); - showLog("Contans.SP.AF_PASS_WORD"); - showLog(password); - } - - adapter = new YjyaBaseAdapter(context, rowsBeanList); - lv.setAdapter(adapter); - lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - YjyaItemBean bean = rowsBeanList.get(position); - Log.i("bean", GsonUtils.GsonString(bean)); - Intent intent = new Intent(getActivity(), Activity_Yjyajx_Action.class); - intent.putExtra("jlid", bean.getID()); - intent.putExtra("zstype", "1"); - intent.putExtra("state", "0"); - intent.putExtra("title", "应急处理执行"); - startActivity(intent); - } - }); - - } - - public void reloadData() { - checkToken(); - } - - public void checkToken() { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - long expires = (Long) SPUtils.get(getActivity(), Contans.AUTHENTICATIONLOGINNEXTDATE, Long.valueOf(0)); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(expires); - showLog("expires" + format.format(calendar.getTime())); - - if (expires != 0) { - String time = format.format(calendar.getTime()); - showLog("完整的时间和日期: " + time); - Calendar calendarNow = Calendar.getInstance(); - String timeNow = format.format(calendarNow.getTime()); - showLog("完整的时间和日期now: " + timeNow); - //a比c早,返回-1, - //a与c相同,返回0 - //a比c晚,返回1 - if (calendar.compareTo(calendarNow) > 0) { - //token有效 - showLog("完整的时间和日期: " + "token有效"); - String token = (String) SPUtils.get(context, Contans.AUTHENTICATIONLOGINTOKEN, ""); - getListDatas(token); - } else { - //token已过期 - showLog("完整的时间和日期: " + "token已过期"); - if (userName.equals("") == false && password.equals("") == false) { - AuthenticationLoginUtils.authenticationLogin(mActivity, userName, password, new OnAuthenticationLoginListener() { - @Override - public void onAuthenticationSuccess(boolean result, String token) { - if (result) { - getListDatas(token); - } - } - }); - } - } - } else { - if (userName.equals("") == false && password.equals("") == false) { - AuthenticationLoginUtils.authenticationLogin(mActivity, userName, password, new OnAuthenticationLoginListener() { - @Override - public void onAuthenticationSuccess(boolean result, String token) { - if (result) { - getListDatas(token); - } - } - }); - } - } - } - - - @Override - public void initData() { - checkToken(); - } - - - private void getListDatas(String token) { - HttpUtils.getCompanyServerApi(token).GetyjyaListData(this.stime, this.etime, "1", "1").enqueue(new BaseCallBack(context) { - @Override - public void onSuccess(Call call, Response response) { - YjyaBaseBean bean = response.body(); - - if (bean != null) { - if (bean.getTotal().equals("0")) { - tv_nodata.setVisibility(View.VISIBLE); - lv.setVisibility(View.GONE); - adapter.notifyDataSetChanged(); - } else { - tv_nodata.setVisibility(View.GONE); - lv.setVisibility(View.VISIBLE); - rowsBeanList = bean.getData(); - adapter.notifyDataSetChanged(); - } - }else{ - tv_nodata.setVisibility(View.VISIBLE); - lv.setVisibility(View.GONE); - adapter.notifyDataSetChanged(); - } - } - - @Override - public void onError(Call call, Throwable t) { - } - }); - } - -// private void setAdapter() { -// -// if (adapter == null) { -// -// } else { -// adapter.setNewData(rowsBeanList); -// } -// } - - @Override - public int getLayoutId() { - return R.layout.fragment_yjyac; - } - - - @Override - public void onResume() { - super.onResume(); - checkToken(); - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyaDFragment.java b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyaDFragment.java deleted file mode 100644 index 0f5863e..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyaDFragment.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.rehome.zhdcoa.ui.fragment; - - -import android.content.Intent; -import android.os.Bundle; -import android.text.TextUtils; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ListView; - -import com.rehome.zhdcoa.App; -import com.rehome.zhdcoa.Contans; -import com.rehome.zhdcoa.R; -import com.rehome.zhdcoa.adapter.YjyaBaseAdapter; -import com.rehome.zhdcoa.base.BaseCallBack; -import com.rehome.zhdcoa.base.BaseFragment; -import com.rehome.zhdcoa.bean.YjyaBaseBean; -import com.rehome.zhdcoa.bean.YjyaItemBean; -import com.rehome.zhdcoa.ui.activity.Activity_Yjyajx_Action; -import com.rehome.zhdcoa.utils.AuthenticationLoginUtils; -import com.rehome.zhdcoa.utils.GsonUtils; -import com.rehome.zhdcoa.utils.HttpUtils; -import com.rehome.zhdcoa.utils.OnAuthenticationLoginListener; -import com.rehome.zhdcoa.utils.RSAUtils; -import com.rehome.zhdcoa.utils.SPUtils; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; -import retrofit2.Call; -import retrofit2.Response; - -/** - * Created by ruihong on 2018/11/13. - */ - -public class YjyaDFragment extends BaseFragment { - - ListView lv; - private List rowsBeanList; - public YjyaBaseAdapter adapter; - public String stime = ""; - public String etime = ""; - - private String userName = ""; - private String password = ""; - - public static YjyaDFragment newInstance() { - YjyaDFragment fragment = new YjyaDFragment(); - return fragment; - } - - @Override - public int getLayoutId() { - return R.layout.fragment_yjyac; - } - - - @Override - protected void initView() { - lv = view.findViewById(R.id.lv); - - //人员组织结构模块 用户验证接口 - userName = App.getInstance().getUserInfo().getManid(); - String passwordTemp = (String) SPUtils.get(context, Contans.SP.AF_PASS_WORD, String.valueOf("")); - if (!TextUtils.isEmpty(passwordTemp)) { - password = RSAUtils.decryptBASE64StrLocal(passwordTemp); - } - } - - public void reloadData(){ - checkToken(); - } - - public void checkToken() { - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - long expires = (Long) SPUtils.get(getActivity(), Contans.AUTHENTICATIONLOGINNEXTDATE, Long.valueOf(0)); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(expires); - showLog("expires:"+format.format(calendar.getTime())); - - if (expires != 0) { - String time = format.format(calendar.getTime()); - Log.i("完整的时间和日期: ", time); - Calendar calendarNow = Calendar.getInstance(); - String timeNow = format.format(calendarNow.getTime()); - Log.i("完整的时间和日期now: ", timeNow); - //a比c早,返回-1, - //a与c相同,返回0 - //a比c晚,返回1 - if (calendar.compareTo(calendarNow) > 0) { - //token有效 - String token = (String) SPUtils.get(context, Contans.AUTHENTICATIONLOGINTOKEN, ""); - showLog("完整的时间和日期: "+"token有效"); - showLog(token); - getListDatas(token); - } else { - //token已过期 - showLog("完整的时间和日期: "+"token已过期"); - if (userName.equals("") == false && password.equals("") == false) { - AuthenticationLoginUtils.authenticationLogin(mActivity, userName, password, new OnAuthenticationLoginListener() { - @Override - public void onAuthenticationSuccess(boolean result, String token) { - if (result) { - getListDatas(token); - } - } - }); - } - } - } else { - if (userName.equals("") == false && password.equals("") == false) { - AuthenticationLoginUtils.authenticationLogin(mActivity, userName, password, new OnAuthenticationLoginListener() { - @Override - public void onAuthenticationSuccess(boolean result, String token) { - if (result) { - getListDatas(token); - } - } - }); - } - } - } - - - @Override - public void initData() { - checkToken(); - } - - - private void getListDatas(String token) { - showLog("getListDatas"); - showLog("YJYAJX/GetList"); - HttpUtils.getCompanyServerApi(token).GetyjyaListData(this.stime, this.etime,"1","2").enqueue(new BaseCallBack(context) { - @Override - public void onSuccess(Call call, Response response) { - YjyaBaseBean bean = response.body(); - - if (bean != null) { - if (bean.getTotal().equals("0")){ - //showToast("暂无数据"); - rowsBeanList= new ArrayList(); - setAdapter(); - }else { - rowsBeanList = bean.getData(); - setAdapter(); - } - }else{ - rowsBeanList= new ArrayList(); - setAdapter(); - } - } - - @Override - public void onError(Call call, Throwable t) { - } - }); - } - - private void setAdapter() { - - if (adapter == null) { - adapter = new YjyaBaseAdapter(context, rowsBeanList); - lv.setAdapter(adapter); - lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - YjyaItemBean bean = rowsBeanList.get(position); - Log.i("bean", GsonUtils.GsonString(bean)); - Intent intent = new Intent(getActivity(), Activity_Yjyajx_Action.class); - intent.putExtra("jlid", bean.getID()); - intent.putExtra("zstype","2"); - intent.putExtra("state","0"); - intent.putExtra("title","应急演练执行"); - startActivity(intent); - } - }); - } else { - adapter.setNewData(rowsBeanList); - } - } - - @Override - public void onResume() { - super.onResume(); - checkToken(); - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyacFragment.kt b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyacFragment.kt new file mode 100644 index 0000000..74458a2 --- /dev/null +++ b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyacFragment.kt @@ -0,0 +1,180 @@ +package com.rehome.zhdcoa.ui.fragment + +import android.annotation.SuppressLint +import android.content.Intent +import android.text.TextUtils +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.AdapterView +import com.rehome.zhdcoa.App +import com.rehome.zhdcoa.Contans +import com.rehome.zhdcoa.adapter.YjyaBaseAdapter +import com.rehome.zhdcoa.base.BaseCallBack +import com.rehome.zhdcoa.base.BaseViewBindingKotlinFragment +import com.rehome.zhdcoa.bean.YjyaBaseBean +import com.rehome.zhdcoa.bean.YjyaItemBean +import com.rehome.zhdcoa.databinding.FragmentYjyacBinding +import com.rehome.zhdcoa.ui.activity.Activity_Yjyajx_Action +import com.rehome.zhdcoa.utils.AuthenticationLoginUtils +import com.rehome.zhdcoa.utils.GsonUtils +import com.rehome.zhdcoa.utils.HttpUtils +import com.rehome.zhdcoa.utils.RSAUtils +import com.rehome.zhdcoa.utils.SPUtils +import retrofit2.Call +import retrofit2.Response +import java.text.SimpleDateFormat +import java.util.Calendar + +/** + * Create By HuangWenFei + * 创建日期:2024-09-15 10:13 + * 描述:代码改成kotlin,应急预案 + */ +class YjyacFragment : BaseViewBindingKotlinFragment() { + + private lateinit var adapter: YjyaBaseAdapter + private var rowsBeanList: MutableList = mutableListOf() + + private var stime: String = "" + private var etime: String = "" + + private var userName = "" + private var password = "" + + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?) = FragmentYjyacBinding.inflate(inflater) + + override fun initView() { + binding?.tvNodata?.visibility = View.VISIBLE + binding?.lv?.visibility = View.GONE + + + //人员组织结构模块 用户验证接口 + userName = App.getInstance().userInfo.manid + val passwordTemp = SPUtils.get(context, Contans.SP.AF_PASS_WORD, "".toString()) as String + if (!TextUtils.isEmpty(passwordTemp)) { + password = RSAUtils.decryptBASE64StrLocal(passwordTemp) + showLog("Contans.SP.AF_PASS_WORD") + showLog(password) + } + + adapter = YjyaBaseAdapter(context, rowsBeanList) + binding?.lv?.setAdapter(adapter) + binding?.lv?.onItemClickListener = + AdapterView.OnItemClickListener { parent, view, position, id -> + val bean = rowsBeanList[position] + Log.i("bean", GsonUtils.GsonString(bean)) + val intent = Intent(activity, Activity_Yjyajx_Action::class.java) + intent.putExtra("jlid", bean.id) + intent.putExtra("zstype", "1") + intent.putExtra("state", "0") + intent.putExtra("title", "应急处理执行") + startActivity(intent) + } + + } + + override fun initData() { + checkToken() + } + + override fun onResume() { + super.onResume() + checkToken() + } + + fun reloadData() { + checkToken() + } + + fun resetStime(stime: String) { + this.stime = stime + } + + fun resetEtime(etime: String) { + this.etime = etime + } + + @SuppressLint("SimpleDateFormat") + private fun checkToken() { + val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + val expires = SPUtils.get(requireActivity(), Contans.AUTHENTICATIONLOGINNEXTDATE, 0L) as Long + val calendar = Calendar.getInstance() + calendar.timeInMillis = expires + showLog("expires" + format.format(calendar.time)) + + if (expires != 0L) { + val time = format.format(calendar.time) + showLog("完整的时间和日期: $time") + val calendarNow = Calendar.getInstance() + val timeNow = format.format(calendarNow.time) + showLog("完整的时间和日期now: $timeNow") + //a比c早,返回-1, + //a与c相同,返回0 + //a比c晚,返回1 + if (calendar.compareTo(calendarNow) > 0) { + //token有效 + showLog("完整的时间和日期: " + "token有效") + val token = SPUtils.get(context, Contans.AUTHENTICATIONLOGINTOKEN, "") as String + getListDatas(token) + } else { + //token已过期 + showLog("完整的时间和日期: " + "token已过期") + if (userName == "" == false && password == "" == false) { + AuthenticationLoginUtils.authenticationLogin( + requireActivity(), userName, password + ) { result, token -> + if (result) { + getListDatas(token) + } + } + } + } + } else { + if (userName == "" == false && password == "" == false) { + AuthenticationLoginUtils.authenticationLogin( + requireActivity(), userName, password + ) { result, token -> + if (result) { + getListDatas(token) + } + } + } + } + } + + private fun getListDatas(token: String) { + HttpUtils.getCompanyServerApi(token).GetyjyaListData( + this.stime, + this.etime, "1", "1" + ).enqueue(object : BaseCallBack(context) { + + override fun onSuccess(call: Call?, response: Response?) { + val bean = response?.body() + showLog(GsonUtils.GsonString(bean)) + if (bean != null) { + if (bean.total == "0") { + binding?.tvNodata?.visibility = View.VISIBLE + binding?.lv?.visibility = View.GONE + adapter.notifyDataSetChanged() + } else { + binding?.tvNodata?.visibility = View.GONE + binding?.lv?.visibility = View.VISIBLE + rowsBeanList = bean.data + adapter.notifyDataSetChanged() + } + } else { + binding?.tvNodata?.visibility = View.VISIBLE + binding?.lv?.visibility = View.GONE + adapter.notifyDataSetChanged() + } + } + + override fun onError(call: Call?, t: Throwable?) { + + } + }) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyadFragment.kt b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyadFragment.kt new file mode 100644 index 0000000..eaf2c0f --- /dev/null +++ b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YjyadFragment.kt @@ -0,0 +1,184 @@ +package com.rehome.zhdcoa.ui.fragment + + +import android.content.Intent +import android.text.TextUtils +import android.util.Log +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.AdapterView +import com.rehome.zhdcoa.App +import com.rehome.zhdcoa.Contans +import com.rehome.zhdcoa.adapter.YjyaBaseAdapter +import com.rehome.zhdcoa.base.BaseCallBack +import com.rehome.zhdcoa.base.BaseViewBindingKotlinFragment +import com.rehome.zhdcoa.bean.YjyaBaseBean +import com.rehome.zhdcoa.bean.YjyaItemBean +import com.rehome.zhdcoa.databinding.FragmentYjyadBinding +import com.rehome.zhdcoa.ui.activity.Activity_Yjyajx_Action +import com.rehome.zhdcoa.utils.AuthenticationLoginUtils +import com.rehome.zhdcoa.utils.GsonUtils +import com.rehome.zhdcoa.utils.HttpUtils +import com.rehome.zhdcoa.utils.RSAUtils +import com.rehome.zhdcoa.utils.SPUtils +import retrofit2.Call +import retrofit2.Response +import java.text.SimpleDateFormat +import java.util.Calendar + +/** + * Create By HuangWenFei + * 创建日期:2024-09-15 10:13 + * 描述:代码改成kotlin,应急预案 + */ + +class YjyadFragment : BaseViewBindingKotlinFragment() { + + private lateinit var adapter: YjyaBaseAdapter + private var rowsBeanList: MutableList = mutableListOf() + + var stime: String = "" + var etime: String = "" + + private var userName = "" + private var password = "" + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?) = FragmentYjyadBinding.inflate(inflater) + + override fun initView() { + + binding?.tvNodata?.visibility = View.VISIBLE + binding?.lv?.visibility = View.GONE + + //人员组织结构模块 用户验证接口 + userName = App.getInstance().userInfo.manid + val passwordTemp = SPUtils.get(context, Contans.SP.AF_PASS_WORD, "".toString()) as String + if (!TextUtils.isEmpty(passwordTemp)) { + password = RSAUtils.decryptBASE64StrLocal(passwordTemp) + showLog("Contans.SP.AF_PASS_WORD") + showLog(password) + } + + adapter = YjyaBaseAdapter(context, rowsBeanList) + binding?.lv?.setAdapter(adapter) + binding?.lv?.setOnItemClickListener(AdapterView.OnItemClickListener { parent, view, position, id -> + val bean = rowsBeanList[position] + Log.i("bean", GsonUtils.GsonString(bean)) + val intent = Intent(activity, Activity_Yjyajx_Action::class.java) + intent.putExtra("jlid", bean.id) + intent.putExtra("zstype", "2") + intent.putExtra("state", "0") + intent.putExtra("title", "应急演练执行") + startActivity(intent) + }) + + } + + override fun initData() { + checkToken() + } + + fun reloadData() { + checkToken() + } + + fun resetStime(stime: String) { + this.stime = stime + } + + fun resetEtime(etime: String) { + this.etime = etime + } + + override fun onResume() { + super.onResume() + checkToken() + } + + fun checkToken() { + val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + val expires = SPUtils.get(activity, Contans.AUTHENTICATIONLOGINNEXTDATE, 0L) as Long + val calendar = Calendar.getInstance() + calendar.timeInMillis = expires + showLog("expires:" + format.format(calendar.time)) + + if (expires != 0L) { + val time = format.format(calendar.time) + Log.i("完整的时间和日期: ", time) + val calendarNow = Calendar.getInstance() + val timeNow = format.format(calendarNow.time) + Log.i("完整的时间和日期now: ", timeNow) + //a比c早,返回-1, + //a与c相同,返回0 + //a比c晚,返回1 + if (calendar.compareTo(calendarNow) > 0) { + //token有效 + val token = SPUtils.get(context, Contans.AUTHENTICATIONLOGINTOKEN, "") as String + showLog("完整的时间和日期: " + "token有效") + showLog(token) + getListDatas(token) + } else { + //token已过期 + showLog("完整的时间和日期: " + "token已过期") + if (userName == "" == false && password == "" == false) { + AuthenticationLoginUtils.authenticationLogin( + requireActivity(), userName, password + ) { result, token -> + if (result) { + getListDatas(token) + } + } + } + } + } else { + if (userName == "" == false && password == "" == false) { + AuthenticationLoginUtils.authenticationLogin( + requireActivity(), userName, password + ) { result, token -> + if (result) { + getListDatas(token) + } + } + } + } + } + + private fun getListDatas(token: String) { + showLog("getListDatas") + showLog("YJYAJX/GetList") + HttpUtils.getCompanyServerApi(token).GetyjyaListData( + this.stime, + this.etime, "1", "2" + ).enqueue(object : BaseCallBack(context) { + + override fun onSuccess(call: Call?, response: Response?) { + val bean = response?.body() + showLog(GsonUtils.GsonString(bean)) + if (bean != null) { + if (bean.total == "0") { + //showToast("暂无数据"); + rowsBeanList.clear() + binding?.tvNodata?.visibility = View.VISIBLE + binding?.lv?.visibility = View.GONE + adapter.notifyDataSetChanged() + } else { + binding?.tvNodata?.visibility = View.GONE + binding?.lv?.visibility = View.VISIBLE + rowsBeanList = bean.data + adapter.notifyDataSetChanged() + } + } else { + rowsBeanList.clear() + binding?.tvNodata?.visibility = View.VISIBLE + binding?.lv?.visibility = View.GONE + adapter.notifyDataSetChanged() + } + } + + override fun onError(call: Call?, t: Throwable?) { + + } + }) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YunXingFragment.kt b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YunXingFragment.kt index 889ce2d..4f93cd7 100644 --- a/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YunXingFragment.kt +++ b/app/src/main/java/com/rehome/zhdcoa/ui/fragment/YunXingFragment.kt @@ -69,6 +69,11 @@ import com.yolanda.nohttp.rest.Response import org.litepal.crud.DataSupport import java.io.File +/** + * Create By HuangWenFei + * 创建日期:2024-09-15 10:13 + * 描述:代码改成kotlin,生产页面 + */ class YunXingFragment : BaseViewBindingKotlinFragment() { private var beanList: MutableList = mutableListOf() diff --git a/app/src/main/java/com/rehome/zhdcoa/utils/EditTextListener.java b/app/src/main/java/com/rehome/zhdcoa/utils/EditTextListener.java index 6816784..bc36f28 100755 --- a/app/src/main/java/com/rehome/zhdcoa/utils/EditTextListener.java +++ b/app/src/main/java/com/rehome/zhdcoa/utils/EditTextListener.java @@ -3,9 +3,9 @@ package com.rehome.zhdcoa.utils; import android.content.Context; import android.text.Editable; import android.text.TextWatcher; +import android.util.Log; import android.widget.Toast; -import com.orhanobut.logger.Logger; /** * EditText文本变化监听器 @@ -37,7 +37,7 @@ public class EditTextListener implements TextWatcher { @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { - Logger.v("输入数据:" + charSequence + "====" + num); + //Log.i("app","输入数据:" + charSequence + "====" + num); double inputnum = 0; try { inputnum = Double.parseDouble(num); diff --git a/app/src/main/java/com/rehome/zhdcoa/utils/LogUtils.java b/app/src/main/java/com/rehome/zhdcoa/utils/LogUtils.java index 0b915fc..439c5e2 100644 --- a/app/src/main/java/com/rehome/zhdcoa/utils/LogUtils.java +++ b/app/src/main/java/com/rehome/zhdcoa/utils/LogUtils.java @@ -206,7 +206,7 @@ public class LogUtils { String tag = generateTag(caller); if (customLogger != null) { - customLogger.v(tag, content); + Log.i(tag, content); } else { Log.v(tag, content); } @@ -224,7 +224,7 @@ public class LogUtils { String tag = generateTag(caller); if (customLogger != null) { - customLogger.v(tag, content, e); + Log.i(tag, content, e); } else { Log.v(tag, content, e); } diff --git a/app/src/main/java/com/rehome/zhdcoa/utils/QRCodeUtil.java b/app/src/main/java/com/rehome/zhdcoa/utils/QRCodeUtil.java index 41ad684..424b7de 100644 --- a/app/src/main/java/com/rehome/zhdcoa/utils/QRCodeUtil.java +++ b/app/src/main/java/com/rehome/zhdcoa/utils/QRCodeUtil.java @@ -2,14 +2,12 @@ package com.rehome.zhdcoa.utils; import android.graphics.Bitmap; import android.graphics.Canvas; - import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; - import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; diff --git a/app/src/main/java/com/rehome/zhdcoa/weiget/GridViewDialog.kt b/app/src/main/java/com/rehome/zhdcoa/weiget/GridViewDialog.kt index b96fe4d..612cb56 100644 --- a/app/src/main/java/com/rehome/zhdcoa/weiget/GridViewDialog.kt +++ b/app/src/main/java/com/rehome/zhdcoa/weiget/GridViewDialog.kt @@ -66,9 +66,11 @@ import com.rehome.zhdcoa.ui.activity.ZxDjtpActivity import com.rehome.zhdcoa.ui.activity.ZxtpActivity /** - * Created by Rehome-rjb1 on 2017/5/18. - * 每个模块弹窗,选择模块的对话框 + * Created by HuangWenFei + * 创建日期:2024-09-25 14:13 + * 描述:代码改成kotlin,每个模块弹窗,首页选择模块的对话框 */ + class GridViewDialog(context:Context) : Dialog(context) { companion object{//伴生对象是可以指定名字的,不过一般都省略掉。 val TAG_VISIT:String = "TAG_VISIT";//来访 diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/AutoFocusCallback.java b/app/src/main/java/com/rehome/zhdcoa/zxing/camera/AutoFocusCallback.java deleted file mode 100755 index 7106550..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/AutoFocusCallback.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.camera; - -import android.hardware.Camera; -import android.os.Handler; -import android.os.Message; -import android.util.Log; - -final class AutoFocusCallback implements Camera.AutoFocusCallback { - - private static final String TAG = AutoFocusCallback.class.getSimpleName(); - - private static final long AUTOFOCUS_INTERVAL_MS = 1500L; - - private Handler autoFocusHandler; - private int autoFocusMessage; - - void setHandler(Handler autoFocusHandler, int autoFocusMessage) { - this.autoFocusHandler = autoFocusHandler; - this.autoFocusMessage = autoFocusMessage; - } - - public void onAutoFocus(boolean success, Camera camera) { - if (autoFocusHandler != null) { - Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success); - autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS); - autoFocusHandler = null; - } else { - Log.d(TAG, "Got auto-focus callback, but no handler for it"); - } - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/CameraConfigurationManager.java b/app/src/main/java/com/rehome/zhdcoa/zxing/camera/CameraConfigurationManager.java deleted file mode 100755 index 08abc00..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/CameraConfigurationManager.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.camera; - -import android.content.Context; -import android.graphics.Point; -import android.hardware.Camera; -import android.os.Build; -import android.util.Log; -import android.view.Display; -import android.view.WindowManager; - -import java.lang.reflect.Method; -import java.util.regex.Pattern; - -final class CameraConfigurationManager { - - private static final String TAG = CameraConfigurationManager.class.getSimpleName(); - - private static final int TEN_DESIRED_ZOOM = 27; - private static final int DESIRED_SHARPNESS = 30; - - private static final Pattern COMMA_PATTERN = Pattern.compile(","); - - private final Context context; - private Point screenResolution; - private Point cameraResolution; - private int previewFormat; - private String previewFormatString; - - CameraConfigurationManager(Context context) { - this.context = context; - } - - /** - * Reads, one time, values from the camera that are needed by the app. - */ - void initFromCameraParameters(Camera camera) { - Camera.Parameters parameters = camera.getParameters(); - previewFormat = parameters.getPreviewFormat(); - previewFormatString = parameters.get("preview-format"); - Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString); - WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); - Display display = manager.getDefaultDisplay(); - screenResolution = new Point(display.getWidth(), display.getHeight()); - Log.d(TAG, "Screen resolution: " + screenResolution); - cameraResolution = getCameraResolution(parameters, screenResolution); - Log.d(TAG, "Camera resolution: " + screenResolution); - } - - /** - * Sets the camera up to take preview images which are used for both preview and decoding. - * We detect the preview format here so that buildLuminanceSource() can build an appropriate - * LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest, - * and the planar Y can be used for barcode scanning without background copy in some cases. - */ - void setDesiredCameraParameters(Camera camera) { - Camera.Parameters parameters = camera.getParameters(); - Log.d(TAG, "Setting preview size: " + cameraResolution); - parameters.setPreviewSize(cameraResolution.x, cameraResolution.y); - setFlash(parameters); - setZoom(parameters); - setDisplayOrientation(camera, 90); - camera.setParameters(parameters); - } - - Point getCameraResolution() { - return cameraResolution; - } - - Point getScreenResolution() { - return screenResolution; - } - - int getPreviewFormat() { - return previewFormat; - } - - String getPreviewFormatString() { - return previewFormatString; - } - - private static Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) { - - String previewSizeValueString = parameters.get("preview-size-values"); - // saw this on Xperia - if (previewSizeValueString == null) { - previewSizeValueString = parameters.get("preview-size-value"); - } - - Point cameraResolution = null; - - if (previewSizeValueString != null) { - Log.d(TAG, "preview-size-values parameter: " + previewSizeValueString); - cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution); - } - - if (cameraResolution == null) { - // Ensure that the camera resolution is background multiple of 8, as the screen may not be. - cameraResolution = new Point( - (screenResolution.x >> 3) << 3, - (screenResolution.y >> 3) << 3); - } - - return cameraResolution; - } - - private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) { - int bestX = 0; - int bestY = 0; - int diff = Integer.MAX_VALUE; - for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) { - - previewSize = previewSize.trim(); - int dimPosition = previewSize.indexOf('x'); - if (dimPosition < 0) { - Log.w(TAG, "Bad preview-size: " + previewSize); - continue; - } - - int newX; - int newY; - try { - newX = Integer.parseInt(previewSize.substring(0, dimPosition)); - newY = Integer.parseInt(previewSize.substring(dimPosition + 1)); - } catch (NumberFormatException nfe) { - Log.w(TAG, "Bad preview-size: " + previewSize); - continue; - } - - int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y); - if (newDiff == 0) { - bestX = newX; - bestY = newY; - break; - } else if (newDiff < diff) { - bestX = newX; - bestY = newY; - diff = newDiff; - } - - } - - if (bestX > 0 && bestY > 0) { - return new Point(bestX, bestY); - } - return null; - } - - private static int findBestMotZoomValue(CharSequence stringValues, int tenDesiredZoom) { - int tenBestValue = 0; - for (String stringValue : COMMA_PATTERN.split(stringValues)) { - stringValue = stringValue.trim(); - double value; - try { - value = Double.parseDouble(stringValue); - } catch (NumberFormatException nfe) { - return tenDesiredZoom; - } - int tenValue = (int) (10.0 * value); - if (Math.abs(tenDesiredZoom - value) < Math.abs(tenDesiredZoom - tenBestValue)) { - tenBestValue = tenValue; - } - } - return tenBestValue; - } - - private void setFlash(Camera.Parameters parameters) { - // FIXME: This is background hack to turn the flash off on the Samsung Galaxy. - // And this is background hack-hack to work around background different value on the Behold II - // Restrict Behold II check to Cupcake, per Samsung's advice - //if (Build.MODEL.contains("Behold II") && - // CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) { - if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // icon3 = Cupcake - parameters.set("flash-value", 1); - } else { - parameters.set("flash-value", 2); - } - // This is the standard setting to turn the flash off that all devices should honor. - parameters.set("flash-mode", "off"); - } - - private void setZoom(Camera.Parameters parameters) { - - String zoomSupportedString = parameters.get("zoom-supported"); - if (zoomSupportedString != null && !Boolean.parseBoolean(zoomSupportedString)) { - return; - } - - int tenDesiredZoom = TEN_DESIRED_ZOOM; - - String maxZoomString = parameters.get("max-zoom"); - if (maxZoomString != null) { - try { - int tenMaxZoom = (int) (10.0 * Double.parseDouble(maxZoomString)); - if (tenDesiredZoom > tenMaxZoom) { - tenDesiredZoom = tenMaxZoom; - } - } catch (NumberFormatException nfe) { - Log.w(TAG, "Bad max-zoom: " + maxZoomString); - } - } - - String takingPictureZoomMaxString = parameters.get("taking-picture-zoom-max"); - if (takingPictureZoomMaxString != null) { - try { - int tenMaxZoom = Integer.parseInt(takingPictureZoomMaxString); - if (tenDesiredZoom > tenMaxZoom) { - tenDesiredZoom = tenMaxZoom; - } - } catch (NumberFormatException nfe) { - Log.w(TAG, "Bad taking-picture-zoom-max: " + takingPictureZoomMaxString); - } - } - - String motZoomValuesString = parameters.get("mot-zoom-values"); - if (motZoomValuesString != null) { - tenDesiredZoom = findBestMotZoomValue(motZoomValuesString, tenDesiredZoom); - } - - String motZoomStepString = parameters.get("mot-zoom-step"); - if (motZoomStepString != null) { - try { - double motZoomStep = Double.parseDouble(motZoomStepString.trim()); - int tenZoomStep = (int) (10.0 * motZoomStep); - if (tenZoomStep > 1) { - tenDesiredZoom -= tenDesiredZoom % tenZoomStep; - } - } catch (NumberFormatException nfe) { - // continue - } - } - - // Set zoom. This helps encourage the user to pull back. - // Some devices like the Behold have background zoom parameter - if (maxZoomString != null || motZoomValuesString != null) { - parameters.set("zoom", String.valueOf(tenDesiredZoom / 10.0)); - } - - // Most devices, like the Hero, appear to expose this zoom parameter. - // It takes on values like "27" which appears to mean icon2.7x zoom - if (takingPictureZoomMaxString != null) { - parameters.set("taking-picture-zoom", tenDesiredZoom); - } - } - - public static int getDesiredSharpness() { - return DESIRED_SHARPNESS; - } - - /** - * compatible icon1.icon6 - * @param camera - * @param angle - */ - protected void setDisplayOrientation(Camera camera, int angle){ - Method downPolymorphic; - try - { - downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", int.class); - if (downPolymorphic != null) - downPolymorphic.invoke(camera, angle); - } - catch (Exception e1) - { - } - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/CameraManager.java b/app/src/main/java/com/rehome/zhdcoa/zxing/camera/CameraManager.java deleted file mode 100755 index b247edf..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/CameraManager.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.camera; - -import android.content.Context; -import android.graphics.PixelFormat; -import android.graphics.Point; -import android.graphics.Rect; -import android.hardware.Camera; -import android.os.Build; -import android.os.Handler; -import android.util.Log; -import android.view.SurfaceHolder; - -import java.io.IOException; - -/** - * This object wraps the Camera service object and expects to be the only one talking to it. The - * implementation encapsulates the steps needed to take preview-sized images, which are used for - * both preview and decoding. - * - */ -public final class CameraManager { - - private static final String TAG = CameraManager.class.getSimpleName(); - - private static final int MIN_FRAME_WIDTH = 350; - private static final int MIN_FRAME_HEIGHT = 350; - private static final int MAX_FRAME_WIDTH = 700; - private static final int MAX_FRAME_HEIGHT - = 630; - - private static CameraManager cameraManager; - - static final int SDK_INT; // Later we can use Build.VERSION.SDK_INT - static { - int sdkInt; - try { - sdkInt = Integer.parseInt(Build.VERSION.SDK); - } catch (NumberFormatException nfe) { - // Just to be safe - sdkInt = 10000; - } - SDK_INT = sdkInt; - } - - private final Context context; - private final CameraConfigurationManager configManager; - private Camera camera; - private Rect framingRect; - private Rect framingRectInPreview; - private boolean initialized; - private boolean previewing; - private final boolean useOneShotPreviewCallback; - /** - * Preview frames are delivered here, which we pass on to the registered handler. Make sure to - * clear the handler so it will only receive one message. - */ - private final PreviewCallback previewCallback; - /** Autofocus callbacks arrive here, and are dispatched to the Handler which requested them. */ - private final AutoFocusCallback autoFocusCallback; - - /** - * Initializes this static object with the Context of the calling Activity. - * - * @param context The Activity which wants to use the camera. - */ - public static void init(Context context) { - if (cameraManager == null) { - cameraManager = new CameraManager(context); - } - } - - /** - * Gets the CameraManager singleton instance. - * - * @return A reference to the CameraManager singleton. - */ - public static CameraManager get() { - return cameraManager; - } - - private CameraManager(Context context) { - - this.context = context; - this.configManager = new CameraConfigurationManager(context); - - // Camera.setOneShotPreviewCallback() has background race condition in Cupcake, so we use the older - // Camera.setPreviewCallback() on icon1.icon5 and earlier. For Donut and later, we need to use - // the more efficient one shot callback, as the older one can swamp the system and cause it - // to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK. - //useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.CUPCAKE; - useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > 3; // icon3 = Cupcake - - previewCallback = new PreviewCallback(configManager, useOneShotPreviewCallback); - autoFocusCallback = new AutoFocusCallback(); - } - - /** - * Opens the camera driver and initializes the hardware parameters. - * - * @param holder The surface object which the camera will draw preview frames into. - * @throws IOException Indicates the camera driver failed to open. - */ - public void openDriver(SurfaceHolder holder) throws IOException { - if (camera == null) { - camera = Camera.open(); - if (camera == null) { - throw new IOException(); - } - camera.setPreviewDisplay(holder); - - if (!initialized) { - initialized = true; - configManager.initFromCameraParameters(camera); - } - configManager.setDesiredCameraParameters(camera); - - - FlashlightManager.enableFlashlight(); - } - } - - /** - * Closes the camera driver if still in use. - */ - public void closeDriver() { - if (camera != null) { - FlashlightManager.disableFlashlight(); - camera.release(); - camera = null; - } - } - - /** - * Asks the camera hardware to begin drawing preview frames to the screen. - */ - public void startPreview() { - if (camera != null && !previewing) { - camera.startPreview(); - previewing = true; - } - } - - /** - * Tells the camera to stop drawing preview frames. - */ - public void stopPreview() { - if (camera != null && previewing) { - if (!useOneShotPreviewCallback) { - camera.setPreviewCallback(null); - } - camera.stopPreview(); - previewCallback.setHandler(null, 0); - autoFocusCallback.setHandler(null, 0); - previewing = false; - } - } - - /** - * A single preview frame will be returned to the handler supplied. The data will arrive as byte[] - * in the message.obj field, with width and height encoded as message.arg1 and message.arg2, - * respectively. - * - * @param handler The handler to send the message to. - * @param message The what field of the message to be sent. - */ - public void requestPreviewFrame(Handler handler, int message) { - if (camera != null && previewing) { - previewCallback.setHandler(handler, message); - if (useOneShotPreviewCallback) { - camera.setOneShotPreviewCallback(previewCallback); - } else { - camera.setPreviewCallback(previewCallback); - } - } - } - - /** - * Asks the camera hardware to perform an autofocus. - * - * @param handler The Handler to notify when the autofocus completes. - * @param message The message to deliver. - */ - public void requestAutoFocus(Handler handler, int message) { - if (camera != null && previewing) { - autoFocusCallback.setHandler(handler, message); - //Log.d(TAG, "Requesting auto-focus callback"); - camera.autoFocus(autoFocusCallback); - } - } - - /** - * Calculates the framing rect which the UI should draw to show the user where to place the - * barcode. This target helps with alignment as well as forces the user to hold the device - * far enough away to ensure the image will be in focus. - * - * @return The rectangle to draw on screen in window coordinates. - */ - public Rect getFramingRect() { - Point screenResolution = configManager.getScreenResolution(); - if (framingRect == null) { - if (camera == null) { - return null; - } - int width = screenResolution.x * 3 / 4; - if (width < MIN_FRAME_WIDTH) { - width = MIN_FRAME_WIDTH; - } else if (width > MAX_FRAME_WIDTH) { - width = MAX_FRAME_WIDTH; - } - int height = screenResolution.y * 3 / 4; - if (height < MIN_FRAME_HEIGHT) { - height = MIN_FRAME_HEIGHT; - } else if (height > MAX_FRAME_HEIGHT) { - height = MAX_FRAME_HEIGHT; - } - int leftOffset = (screenResolution.x - width) / 2; - int topOffset = (screenResolution.y - height) / 2; - framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height); - Log.d(TAG, "Calculated framing rect: " + framingRect); - } - return framingRect; - } - - /** - * Like {@link #getFramingRect} but coordinates are in terms of the preview frame, - * not UI / screen. - */ - public Rect getFramingRectInPreview() { - if (framingRectInPreview == null) { - Rect rect = new Rect(getFramingRect()); - Point cameraResolution = configManager.getCameraResolution(); - Point screenResolution = configManager.getScreenResolution(); - //modify here -// rect.left = rect.left * cameraResolution.x / screenResolution.x; -// rect.right = rect.right * cameraResolution.x / screenResolution.x; -// rect.top = rect.top * cameraResolution.y / screenResolution.y; -// rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y; - rect.left = rect.left * cameraResolution.y / screenResolution.x; - rect.right = rect.right * cameraResolution.y / screenResolution.x; - rect.top = rect.top * cameraResolution.x / screenResolution.y; - rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y; - framingRectInPreview = rect; - } - return framingRectInPreview; - } - - /** - * Converts the result points from still resolution coordinates to screen coordinates. - * - * @param points The points returned by the Reader subclass through Result.getResultPoints(). - * @return An array of Points scaled to the size of the framing rect and offset appropriately - * so they can be drawn in screen coordinates. - */ - /* - public Point[] convertResultPoints(ResultPoint[] points) { - Rect frame = getFramingRectInPreview(); - int count = points.length; - Point[] output = new Point[count]; - for (int x = 0; x < count; x++) { - output[x] = new Point(); - output[x].x = frame.left + (int) (points[x].getX() + 0.5f); - output[x].y = frame.top + (int) (points[x].getY() + 0.5f); - } - return output; - } - */ - - /** - * A factory method to build the appropriate LuminanceSource object based on the format - * of the preview buffers, as described by Camera.Parameters. - * - * @param data A preview frame. - * @param width The width of the image. - * @param height The height of the image. - * @return A PlanarYUVLuminanceSource instance. - */ - public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) { - Rect rect = getFramingRectInPreview(); - int previewFormat = configManager.getPreviewFormat(); - String previewFormatString = configManager.getPreviewFormatString(); - switch (previewFormat) { - // This is the standard Android format which all devices are REQUIRED to support. - // In theory, it's the only one we should ever care about. - case PixelFormat.YCbCr_420_SP: - // This format has never been seen in the wild, but is compatible as we only care - // about the Y channel, so allow it. - case PixelFormat.YCbCr_422_SP: - return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, - rect.width(), rect.height()); - default: - // The Samsung Moment incorrectly uses this variant instead of the 'sp' version. - // Fortunately, it too has all the Y data up front, so we can read it. - if ("yuv420p".equals(previewFormatString)) { - return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, - rect.width(), rect.height()); - } - } - throw new IllegalArgumentException("Unsupported picture format: " + - previewFormat + '/' + previewFormatString); - } - - public Context getContext() { - return context; - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/FlashlightManager.java b/app/src/main/java/com/rehome/zhdcoa/zxing/camera/FlashlightManager.java deleted file mode 100755 index 24c4669..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/FlashlightManager.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.camera; - -import android.os.IBinder; -import android.util.Log; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * This class is used to activate the weak light on some camera phones (not flash) - * in order to illuminate surfaces for scanning. There is no official way to do this, - * but, classes which allow access to this function still exist on some devices. - * This therefore proceeds through background great deal of reflection. - * - * See - * http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/ and - * - * http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java. - * Thanks to Ryan Alford for pointing out the availability of this class. - */ -final class FlashlightManager { - - private static final String TAG = FlashlightManager.class.getSimpleName(); - - private static final Object iHardwareService; - private static final Method setFlashEnabledMethod; - static { - iHardwareService = getHardwareService(); - setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService); - if (iHardwareService == null) { - Log.v(TAG, "This device does supports control of background flashlight"); - } else { - Log.v(TAG, "This device does not support control of background flashlight"); - } - } - - private FlashlightManager() { - } - - - //FIXME - static void enableFlashlight() { - setFlashlight(false); - } - - static void disableFlashlight() { - setFlashlight(false); - } - - private static Object getHardwareService() { - Class serviceManagerClass = maybeForName("android.os.ServiceManager"); - if (serviceManagerClass == null) { - return null; - } - - Method getServiceMethod = maybeGetMethod(serviceManagerClass, "getService", String.class); - if (getServiceMethod == null) { - return null; - } - - Object hardwareService = invoke(getServiceMethod, null, "hardware"); - if (hardwareService == null) { - return null; - } - - Class iHardwareServiceStubClass = maybeForName("android.os.IHardwareService$Stub"); - if (iHardwareServiceStubClass == null) { - return null; - } - - Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface", IBinder.class); - if (asInterfaceMethod == null) { - return null; - } - - return invoke(asInterfaceMethod, null, hardwareService); - } - - private static Method getSetFlashEnabledMethod(Object iHardwareService) { - if (iHardwareService == null) { - return null; - } - Class proxyClass = iHardwareService.getClass(); - return maybeGetMethod(proxyClass, "setFlashlightEnabled", boolean.class); - } - - private static Class maybeForName(String name) { - try { - return Class.forName(name); - } catch (ClassNotFoundException cnfe) { - // OK - return null; - } catch (RuntimeException re) { - Log.w(TAG, "Unexpected error while finding class " + name, re); - return null; - } - } - - private static Method maybeGetMethod(Class clazz, String name, Class... argClasses) { - try { - return clazz.getMethod(name, argClasses); - } catch (NoSuchMethodException nsme) { - // OK - return null; - } catch (RuntimeException re) { - Log.w(TAG, "Unexpected error while finding method " + name, re); - return null; - } - } - - private static Object invoke(Method method, Object instance, Object... args) { - try { - return method.invoke(instance, args); - } catch (IllegalAccessException e) { - Log.w(TAG, "Unexpected error while invoking " + method, e); - return null; - } catch (InvocationTargetException e) { - Log.w(TAG, "Unexpected error while invoking " + method, e.getCause()); - return null; - } catch (RuntimeException re) { - Log.w(TAG, "Unexpected error while invoking " + method, re); - return null; - } - } - - private static void setFlashlight(boolean active) { - if (iHardwareService != null) { - invoke(setFlashEnabledMethod, iHardwareService, active); - } - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/PlanarYUVLuminanceSource.java b/app/src/main/java/com/rehome/zhdcoa/zxing/camera/PlanarYUVLuminanceSource.java deleted file mode 100755 index 723464a..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/PlanarYUVLuminanceSource.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.camera; - -import android.graphics.Bitmap; - -import com.google.zxing.LuminanceSource; - -/** - * This object extends LuminanceSource around an array of YUV data returned from the camera driver, - * with the option to crop to background rectangle within the full data. This can be used to exclude - * superfluous pixels around the perimeter and speed up decoding. - * - * It works for any pixel format where the Y channel is planar and appears first, including - * YCbCr_420_SP and YCbCr_422_SP. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public final class PlanarYUVLuminanceSource extends LuminanceSource { - private final byte[] yuvData; - private final int dataWidth; - private final int dataHeight; - private final int left; - private final int top; - - public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top, - int width, int height) { - super(width, height); - - if (left + width > dataWidth || top + height > dataHeight) { - throw new IllegalArgumentException("Crop rectangle does not fit within image data."); - } - - this.yuvData = yuvData; - this.dataWidth = dataWidth; - this.dataHeight = dataHeight; - this.left = left; - this.top = top; - } - - @Override - public byte[] getRow(int y, byte[] row) { - if (y < 0 || y >= getHeight()) { - throw new IllegalArgumentException("Requested row is outside the image: " + y); - } - int width = getWidth(); - if (row == null || row.length < width) { - row = new byte[width]; - } - int offset = (y + top) * dataWidth + left; - System.arraycopy(yuvData, offset, row, 0, width); - return row; - } - - @Override - public byte[] getMatrix() { - int width = getWidth(); - int height = getHeight(); - - // If the caller asks for the entire underlying image, save the copy and give them the - // original data. The docs specifically warn that result.length must be ignored. - if (width == dataWidth && height == dataHeight) { - return yuvData; - } - - int area = width * height; - byte[] matrix = new byte[area]; - int inputOffset = top * dataWidth + left; - - // If the width matches the full width of the underlying data, perform background single copy. - if (width == dataWidth) { - System.arraycopy(yuvData, inputOffset, matrix, 0, area); - return matrix; - } - - // Otherwise copy one cropped row at background time. - byte[] yuv = yuvData; - for (int y = 0; y < height; y++) { - int outputOffset = y * width; - System.arraycopy(yuv, inputOffset, matrix, outputOffset, width); - inputOffset += dataWidth; - } - return matrix; - } - - @Override - public boolean isCropSupported() { - return true; - } - - public int getDataWidth() { - return dataWidth; - } - - public int getDataHeight() { - return dataHeight; - } - - public Bitmap renderCroppedGreyscaleBitmap() { - int width = getWidth(); - int height = getHeight(); - int[] pixels = new int[width * height]; - byte[] yuv = yuvData; - int inputOffset = top * dataWidth + left; - - for (int y = 0; y < height; y++) { - int outputOffset = y * width; - for (int x = 0; x < width; x++) { - int grey = yuv[inputOffset + x] & 0xff; - pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101); - } - inputOffset += dataWidth; - } - - Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); - bitmap.setPixels(pixels, 0, width, 0, 0, width, height); - return bitmap; - } -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/PreviewCallback.java b/app/src/main/java/com/rehome/zhdcoa/zxing/camera/PreviewCallback.java deleted file mode 100755 index e08803d..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/camera/PreviewCallback.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.camera; - -import android.graphics.Point; -import android.hardware.Camera; -import android.os.Handler; -import android.os.Message; -import android.util.Log; - -final class PreviewCallback implements Camera.PreviewCallback { - - private static final String TAG = PreviewCallback.class.getSimpleName(); - - private final CameraConfigurationManager configManager; - private final boolean useOneShotPreviewCallback; - private Handler previewHandler; - private int previewMessage; - - PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) { - this.configManager = configManager; - this.useOneShotPreviewCallback = useOneShotPreviewCallback; - } - - void setHandler(Handler previewHandler, int previewMessage) { - this.previewHandler = previewHandler; - this.previewMessage = previewMessage; - } - - public void onPreviewFrame(byte[] data, Camera camera) { - Point cameraResolution = configManager.getCameraResolution(); - if (!useOneShotPreviewCallback) { - camera.setPreviewCallback(null); - } - if (previewHandler != null) { - Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x, - cameraResolution.y, data); - message.sendToTarget(); - previewHandler = null; - } else { - Log.d(TAG, "Got preview callback, but no handler for it"); - } - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/CaptureActivityHandler.java b/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/CaptureActivityHandler.java deleted file mode 100755 index fa49128..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/CaptureActivityHandler.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.decoding; - -import android.app.Activity; -import android.content.Intent; -import android.graphics.Bitmap; -import android.net.Uri; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.util.Log; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.Result; -import com.rehome.zhdcoa.R; -import com.rehome.zhdcoa.ui.activity.MipcaActivityCapture; -import com.rehome.zhdcoa.zxing.camera.CameraManager; -import com.rehome.zhdcoa.zxing.view.ViewfinderResultPointCallback; - -import java.util.Vector; - -/** - * This class handles all the messaging which comprises the state machine for capture. - */ -public final class CaptureActivityHandler extends Handler { - - private static final String TAG = CaptureActivityHandler.class.getSimpleName(); - - private final MipcaActivityCapture activity; - private final DecodeThread decodeThread; - private State state; - - private enum State { - PREVIEW, - SUCCESS, - DONE - } - - public CaptureActivityHandler(MipcaActivityCapture activity, Vector decodeFormats, - String characterSet) { - this.activity = activity; - decodeThread = new DecodeThread(activity, decodeFormats, characterSet, new ViewfinderResultPointCallback(activity.getViewfinderView())); - decodeThread.start(); - state = State.SUCCESS; - // Start ourselves capturing previews and decoding. - CameraManager.get().startPreview(); - restartPreviewAndDecode(); - } - - @Override - public void handleMessage(Message message) { - if(message.what==R.id.auto_focus){ - //Log.d(TAG, "Got auto-focus message"); - // When one auto focus pass finishes, start another. This is the closest thing to - // continuous AF. It does seem to hunt background bit, but I'm not sure what else to do. - if (state == State.PREVIEW) { - CameraManager.get().requestAutoFocus(this, R.id.auto_focus); - } - } - if(message.what==R.id.restart_preview){ - restartPreviewAndDecode(); - } - if(message.what==R.id.decode_succeeded){ - state = State.SUCCESS; - Bundle bundle = message.getData(); - - /***********************************************************************/ - Bitmap barcode = bundle == null ? null : - (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳� - - activity.handleDecode((Result) message.obj, barcode); - } - if(message.what==R.id.decode_failed){ - state = State.PREVIEW; - CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); - } - if(message.what==R.id.return_scan_result){ - activity.setResult(Activity.RESULT_OK, (Intent) message.obj); - activity.finish(); - } - if(message.what==R.id.launch_product_query){ - String url = (String) message.obj; - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); - activity.startActivity(intent); - } - - -// switch (message.what) { -// case R.id.auto_focus: -// //Log.d(TAG, "Got auto-focus message"); -// // When one auto focus pass finishes, start another. This is the closest thing to -// // continuous AF. It does seem to hunt background bit, but I'm not sure what else to do. -// if (state == State.PREVIEW) { -// CameraManager.get().requestAutoFocus(this, R.id.auto_focus); -// } -// break; -// case R.id.restart_preview: -// Log.d(TAG, "Got restart preview message"); -// restartPreviewAndDecode(); -// break; -// case R.id.decode_succeeded: -// Log.d(TAG, "Got decode succeeded message"); -// state = State.SUCCESS; -// Bundle bundle = message.getData(); -// -// /***********************************************************************/ -// Bitmap barcode = bundle == null ? null : -// (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//���ñ����߳� -// -// activity.handleDecode((Result) message.obj, barcode); -// //���ؽ��? /***********************************************************************/ -// break; -// case R.id.decode_failed: -// // We're decoding as fast as possible, so when one decode fails, start another. -// state = State.PREVIEW; -// CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); -// break; -// case R.id.return_scan_result: -// Log.d(TAG, "Got return scan result message"); -// activity.setResult(Activity.RESULT_OK, (Intent) message.obj); -// activity.finish(); -// break; -// case R.id.launch_product_query: -// Log.d(TAG, "Got product query message"); -// String url = (String) message.obj; -// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); -// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); -// activity.startActivity(intent); -// break; -// } - } - - public void quitSynchronously() { - state = State.DONE; - CameraManager.get().stopPreview(); - Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit); - quit.sendToTarget(); - try { - decodeThread.join(); - } catch (InterruptedException e) { - // continue - } - - // Be absolutely sure we don't send any queued up messages - removeMessages(R.id.decode_succeeded); - removeMessages(R.id.decode_failed); - } - - private void restartPreviewAndDecode() { - if (state == State.SUCCESS) { - state = State.PREVIEW; - CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); - CameraManager.get().requestAutoFocus(this, R.id.auto_focus); - activity.drawViewfinder(); - } - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeFormatManager.java b/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeFormatManager.java deleted file mode 100755 index 5260db7..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeFormatManager.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.decoding; - -import android.content.Intent; -import android.net.Uri; - -import com.google.zxing.BarcodeFormat; - -import java.util.Arrays; -import java.util.List; -import java.util.Vector; -import java.util.regex.Pattern; - -final class DecodeFormatManager { - - private static final Pattern COMMA_PATTERN = Pattern.compile(","); - - static final Vector PRODUCT_FORMATS; - static final Vector ONE_D_FORMATS; - static final Vector QR_CODE_FORMATS; - static final Vector DATA_MATRIX_FORMATS; - static { - PRODUCT_FORMATS = new Vector(5); - PRODUCT_FORMATS.add(BarcodeFormat.UPC_A); - PRODUCT_FORMATS.add(BarcodeFormat.UPC_E); - PRODUCT_FORMATS.add(BarcodeFormat.EAN_13); - PRODUCT_FORMATS.add(BarcodeFormat.EAN_8); - ONE_D_FORMATS = new Vector(PRODUCT_FORMATS.size() + 4); - ONE_D_FORMATS.addAll(PRODUCT_FORMATS); - ONE_D_FORMATS.add(BarcodeFormat.CODE_39); - ONE_D_FORMATS.add(BarcodeFormat.CODE_93); - ONE_D_FORMATS.add(BarcodeFormat.CODE_128); - ONE_D_FORMATS.add(BarcodeFormat.ITF); - QR_CODE_FORMATS = new Vector(1); - QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE); - DATA_MATRIX_FORMATS = new Vector(1); - DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX); - } - - private DecodeFormatManager() {} - - static Vector parseDecodeFormats(Intent intent) { - List scanFormats = null; - String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS); - if (scanFormatsString != null) { - scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString)); - } - return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE)); - } - - static Vector parseDecodeFormats(Uri inputUri) { - List formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS); - if (formats != null && formats.size() == 1 && formats.get(0) != null){ - formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0))); - } - return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE)); - } - - private static Vector parseDecodeFormats(Iterable scanFormats, - String decodeMode) { - if (scanFormats != null) { - Vector formats = new Vector(); - try { - for (String format : scanFormats) { - formats.add(BarcodeFormat.valueOf(format)); - } - return formats; - } catch (IllegalArgumentException iae) { - // ignore it then - } - } - if (decodeMode != null) { - if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) { - return PRODUCT_FORMATS; - } - if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) { - return QR_CODE_FORMATS; - } - if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) { - return DATA_MATRIX_FORMATS; - } - if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) { - return ONE_D_FORMATS; - } - } - return null; - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeHandler.java b/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeHandler.java deleted file mode 100755 index 70f1e8c..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeHandler.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.decoding; - - -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.util.Log; - -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.common.HybridBinarizer; -import com.rehome.zhdcoa.R; -import com.rehome.zhdcoa.ui.activity.MipcaActivityCapture; -import com.rehome.zhdcoa.ui.activity.YcryxzActivity; -import com.rehome.zhdcoa.zxing.camera.CameraManager; -import com.rehome.zhdcoa.zxing.camera.PlanarYUVLuminanceSource; - -import java.util.Hashtable; - -final class DecodeHandler extends Handler { - - private static final String TAG = DecodeHandler.class.getSimpleName(); - - private final MipcaActivityCapture activity; - private final MultiFormatReader multiFormatReader; - - DecodeHandler(MipcaActivityCapture activity, Hashtable hints) { - multiFormatReader = new MultiFormatReader(); - multiFormatReader.setHints(hints); - this.activity = activity; - } - - @Override - public void handleMessage(Message message) { - if(message.what==R.id.decode){ - decode((byte[]) message.obj, message.arg1, message.arg2); - } - if(message.what==R.id.quit){ - Looper.myLooper().quit(); - } -// switch (message.what) { -// case R.id.decode: -// //Log.d(TAG, "Got decode message"); -// decode((byte[]) message.obj, message.arg1, message.arg2); -// break; -// case R.id.quit: -// Looper.myLooper().quit(); -// break; -// } - } - - /** - * Decode the data within the viewfinder rectangle, and time how long it took. For efficiency, - * reuse the same reader objects from one decode to the next. - * - * @param data The YUV preview frame. - * @param width The width of the preview frame. - * @param height The height of the preview frame. - */ - private void decode(byte[] data, int width, int height) { - long start = System.currentTimeMillis(); - Result rawResult = null; - - //modify here - byte[] rotatedData = new byte[data.length]; - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) - rotatedData[x * height + height - y - 1] = data[x + y * width]; - } - int tmp = width; // Here we are swapping, that's the difference to #11 - width = height; - height = tmp; - - PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height); - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); - try { - rawResult = multiFormatReader.decodeWithState(bitmap); - } catch (ReaderException re) { - // continue - } finally { - multiFormatReader.reset(); - } - - if (rawResult != null) { - long end = System.currentTimeMillis(); - Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString()); - Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult); - Bundle bundle = new Bundle(); - bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap()); - message.setData(bundle); - //Log.d(TAG, "Sending decode succeeded message..."); - message.sendToTarget(); - } else { - Message message = Message.obtain(activity.getHandler(), R.id.decode_failed); - message.sendToTarget(); - } - } - -} - diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeThread.java b/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeThread.java deleted file mode 100755 index 2785cdf..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/DecodeThread.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.decoding; - -import android.os.Handler; -import android.os.Looper; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; -import com.google.zxing.ResultPointCallback; -import com.rehome.zhdcoa.ui.activity.MipcaActivityCapture; - -import java.util.Hashtable; -import java.util.Vector; -import java.util.concurrent.CountDownLatch; - - -final class DecodeThread extends Thread { - - public static final String BARCODE_BITMAP = "barcode_bitmap"; - private final MipcaActivityCapture activity; - private final Hashtable hints; - private Handler handler; - private final CountDownLatch handlerInitLatch; - - DecodeThread(MipcaActivityCapture activity, - Vector decodeFormats, - String characterSet, - ResultPointCallback resultPointCallback) { - - this.activity = activity; - handlerInitLatch = new CountDownLatch(1); - - hints = new Hashtable(3); - - if (decodeFormats == null || decodeFormats.isEmpty()) { - decodeFormats = new Vector(); - decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS); - decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS); - decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS); - } - - hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); - - if (characterSet != null) { - hints.put(DecodeHintType.CHARACTER_SET, characterSet); - } - - hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback); - } - - Handler getHandler() { - try { - handlerInitLatch.await(); - } catch (InterruptedException ie) { - // continue? - } - return handler; - } - - @Override - public void run() { - Looper.prepare(); - handler = new DecodeHandler(activity, hints); - handlerInitLatch.countDown(); - Looper.loop(); - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/FinishListener.java b/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/FinishListener.java deleted file mode 100755 index 247c227..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/FinishListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.decoding; - -import android.app.Activity; -import android.content.DialogInterface; - -/** - * Simple listener used to exit the app in background few cases. - * - */ -public final class FinishListener - implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable { - - private final Activity activityToFinish; - - public FinishListener(Activity activityToFinish) { - this.activityToFinish = activityToFinish; - } - - public void onCancel(DialogInterface dialogInterface) { - run(); - } - - public void onClick(DialogInterface dialogInterface, int i) { - run(); - } - - public void run() { - activityToFinish.finish(); - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/InactivityTimer.java b/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/InactivityTimer.java deleted file mode 100755 index 8f4a8f3..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/InactivityTimer.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.decoding; - -import android.app.Activity; - -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; - -/** - * Finishes an activity after background period of inactivity. - */ -public final class InactivityTimer { - - private static final int INACTIVITY_DELAY_SECONDS = 5 * 60; - - private final ScheduledExecutorService inactivityTimer = - Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory()); - private final Activity activity; - private ScheduledFuture inactivityFuture = null; - - public InactivityTimer(Activity activity) { - this.activity = activity; - onActivity(); - } - - public void onActivity() { - cancel(); - inactivityFuture = inactivityTimer.schedule(new FinishListener(activity), - INACTIVITY_DELAY_SECONDS, - TimeUnit.SECONDS); - } - - private void cancel() { - if (inactivityFuture != null) { - inactivityFuture.cancel(true); - inactivityFuture = null; - } - } - - public void shutdown() { - cancel(); - inactivityTimer.shutdown(); - } - - private static final class DaemonThreadFactory implements ThreadFactory { - public Thread newThread(Runnable runnable) { - Thread thread = new Thread(runnable); - thread.setDaemon(true); - return thread; - } - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/Intents.java b/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/Intents.java deleted file mode 100755 index 971ddd3..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/decoding/Intents.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.decoding; - -/** - * This class provides the constants to use when sending an Intent to Barcode Scanner. - * These strings are effectively API and cannot be changed. - */ -public final class Intents { - private Intents() { - } - - public static final class Scan { - /** - * Send this intent to open the Barcodes app in scanning mode, find background barcode, and return - * the results. - */ - public static final String ACTION = "com.google.zxing.client.android.SCAN"; - - /** - * By default, sending Scan.ACTION will decode all barcodes that we understand. However it - * may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with - * one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}). - * Optional. - * - * Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}. - * It is overridden by that setting. - */ - public static final String MODE = "SCAN_MODE"; - - /** - * Comma-separated list of formats to scan for. The values must match the names of - * {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}. - * Example: "EAN_13,EAN_8,QR_CODE" - * - * This overrides {@link #MODE}. - */ - public static final String SCAN_FORMATS = "SCAN_FORMATS"; - - /** - * @see com.google.zxing.DecodeHintType#CHARACTER_SET - */ - public static final String CHARACTER_SET = "CHARACTER_SET"; - - /** - * Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get - * prices, reviews, etc. for products. - */ - public static final String PRODUCT_MODE = "PRODUCT_MODE"; - - /** - * Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128). - */ - public static final String ONE_D_MODE = "ONE_D_MODE"; - - /** - * Decode only QR codes. - */ - public static final String QR_CODE_MODE = "QR_CODE_MODE"; - - /** - * Decode only Data Matrix codes. - */ - public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE"; - - /** - * If background barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which - * requested the scan via startSubActivity(). The barcodes contents can be retrieved with - * intent.getStringExtra(RESULT). If the user presses Back, the result code will be - * RESULT_CANCELED. - */ - public static final String RESULT = "SCAN_RESULT"; - - /** - * Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found. - * See Contents.Format for possible values. - */ - public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT"; - - /** - * Setting this to false will not save scanned codes in the history. - */ - public static final String SAVE_HISTORY = "SAVE_HISTORY"; - - private Scan() { - } - } - - public static final class Encode { - /** - * Send this intent to encode background piece of data as background QR code and display it full screen, so - * that another person can scan the barcode from your screen. - */ - public static final String ACTION = "com.google.zxing.client.android.ENCODE"; - - /** - * The data to encode. Use Intent.putExtra(DATA, data) where data is either background String or background - * Bundle, depending on the type and format specified. Non-QR Code formats should - * just use background String here. For QR Code, see Contents for details. - */ - public static final String DATA = "ENCODE_DATA"; - - /** - * The type of data being supplied if the format is QR Code. Use - * Intent.putExtra(TYPE, type) with one of Contents.Type. - */ - public static final String TYPE = "ENCODE_TYPE"; - - /** - * The barcode format to be displayed. If this isn't specified or is blank, - * it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where - * format is one of Contents.Format. - */ - public static final String FORMAT = "ENCODE_FORMAT"; - - private Encode() { - } - } - - public static final class SearchBookContents { - /** - * Use Google Book Search to search the contents of the book provided. - */ - public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS"; - - /** - * The book to search, identified by ISBN number. - */ - public static final String ISBN = "ISBN"; - - /** - * An optional field which is the text to search for. - */ - public static final String QUERY = "QUERY"; - - private SearchBookContents() { - } - } - - public static final class WifiConnect { - /** - * Internal intent used to trigger connection to background wi-fi network. - */ - public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT"; - - /** - * The network to connect to, all the configuration provided here. - */ - public static final String SSID = "SSID"; - - /** - * The network to connect to, all the configuration provided here. - */ - public static final String TYPE = "TYPE"; - - /** - * The network to connect to, all the configuration provided here. - */ - public static final String PASSWORD = "PASSWORD"; - - private WifiConnect() { - } - } - - - public static final class Share { - /** - * Give the user background choice of items to encode as background barcode, then render it as background QR Code and - * display onscreen for background friend to scan with their phone. - */ - public static final String ACTION = "com.google.zxing.client.android.SHARE"; - - private Share() { - } - } -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/view/ViewfinderResultPointCallback.java b/app/src/main/java/com/rehome/zhdcoa/zxing/view/ViewfinderResultPointCallback.java deleted file mode 100755 index b379485..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/view/ViewfinderResultPointCallback.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.view; - -import com.google.zxing.ResultPoint; -import com.google.zxing.ResultPointCallback; - -public final class ViewfinderResultPointCallback implements ResultPointCallback { - - private final ViewfinderView viewfinderView; - - public ViewfinderResultPointCallback(ViewfinderView viewfinderView) { - this.viewfinderView = viewfinderView; - } - - public void foundPossibleResultPoint(ResultPoint point) { - viewfinderView.addPossibleResultPoint(point); - } - -} diff --git a/app/src/main/java/com/rehome/zhdcoa/zxing/view/ViewfinderView.java b/app/src/main/java/com/rehome/zhdcoa/zxing/view/ViewfinderView.java deleted file mode 100755 index caf2b89..0000000 --- a/app/src/main/java/com/rehome/zhdcoa/zxing/view/ViewfinderView.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.rehome.zhdcoa.zxing.view; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.Typeface; -import android.util.AttributeSet; -import android.view.View; - -import com.google.zxing.ResultPoint; -import com.rehome.zhdcoa.R; -import com.rehome.zhdcoa.zxing.camera.CameraManager; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; - - -/** - * This view is overlaid on top of the camera preview. It adds the viewfinder - * rectangle and partial transparency outside it, as well as the laser scanner - * animation and result points. - * - */ -public final class ViewfinderView extends View { - private static final String TAG = "log"; - /** - * ˢ�½����ʱ�� - */ - private static final long ANIMATION_DELAY = 10L; - private static final int OPAQUE = 0xFF; - - /** - * �ĸ���ɫ�߽Ƕ�Ӧ�ij��� - */ - private final int ScreenRate; - - /** - * �ĸ���ɫ�߽Ƕ�Ӧ�Ŀ�� - */ - private static final int CORNER_WIDTH = 10; - /** - * ɨ����е��м��ߵĿ�� - */ - private static final int MIDDLE_LINE_WIDTH = 6; - - /** - * ɨ����е��м��ߵ���ɨ������ҵļ�϶ - */ - private static final int MIDDLE_LINE_PADDING = 5; - - /** - * �м�������ÿ��ˢ���ƶ��ľ��� - */ - private static final int SPEEN_DISTANCE = 5; - - /** - * �ֻ�����Ļ�ܶ� - */ - private static float density; - /** - * �����С - */ - private static final int TEXT_SIZE = 16; - /** - * �������ɨ�������ľ��� - */ - private static final int TEXT_PADDING_TOP = 30; - - /** - * ���ʶ�������� - */ - private final Paint paint; - - /** - * �м们���ߵ����λ�� - */ - private int slideTop; - - /** - * �м们���ߵ���׶�λ�� - */ - private int slideBottom; - - /** - * ��ɨ��Ķ�ά��������������û��������ܣ���ʱ������ - */ - private Bitmap resultBitmap; - private final int maskColor; - private final int resultColor; - - private final int resultPointColor; - private Collection possibleResultPoints; - private Collection lastPossibleResultPoints; - - boolean isFirst; - - public ViewfinderView(Context context, AttributeSet attrs) { - super(context, attrs); - - density = context.getResources().getDisplayMetrics().density; - //������ת����dp - ScreenRate = (int)(20 * density); - - paint = new Paint(); - Resources resources = getResources(); - maskColor = resources.getColor(R.color.viewfinder_mask); - resultColor = resources.getColor(R.color.result_view); - - resultPointColor = resources.getColor(R.color.possible_result_points); - possibleResultPoints = new HashSet(5); - } - - @Override - public synchronized void onDraw(Canvas canvas) { - Rect frame = CameraManager.get().getFramingRect(); - if (frame == null) { - return; - } - - //��ʼ���м��߻��������ϱߺ����±� - if(!isFirst){ - isFirst = true; - slideTop = frame.top; - slideBottom = frame.bottom; - } - - int width = canvas.getWidth(); - int height = canvas.getHeight(); - - paint.setColor(resultBitmap != null ? resultColor : maskColor); - - canvas.drawRect(0, 0, width, frame.top, paint); - canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint); - canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, - paint); - canvas.drawRect(0, frame.bottom + 1, width, height, paint); - - - - if (resultBitmap != null) { - // Draw the opaque result bitmap over the scanning rectangle - paint.setAlpha(OPAQUE); - canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint); - } else { - - paint.setColor(Color.GREEN); - canvas.drawRect(frame.left, frame.top, frame.left + ScreenRate, - frame.top + CORNER_WIDTH, paint); - canvas.drawRect(frame.left, frame.top, frame.left + CORNER_WIDTH, frame.top - + ScreenRate, paint); - canvas.drawRect(frame.right - ScreenRate, frame.top, frame.right, - frame.top + CORNER_WIDTH, paint); - canvas.drawRect(frame.right - CORNER_WIDTH, frame.top, frame.right, frame.top - + ScreenRate, paint); - canvas.drawRect(frame.left, frame.bottom - CORNER_WIDTH, frame.left - + ScreenRate, frame.bottom, paint); - canvas.drawRect(frame.left, frame.bottom - ScreenRate, - frame.left + CORNER_WIDTH, frame.bottom, paint); - canvas.drawRect(frame.right - ScreenRate, frame.bottom - CORNER_WIDTH, - frame.right, frame.bottom, paint); - canvas.drawRect(frame.right - CORNER_WIDTH, frame.bottom - ScreenRate, - frame.right, frame.bottom, paint); - - - slideTop += SPEEN_DISTANCE; - if(slideTop >= frame.bottom){ - slideTop = frame.top; - } - canvas.drawRect(frame.left + MIDDLE_LINE_PADDING, slideTop - MIDDLE_LINE_WIDTH/2, frame.right - MIDDLE_LINE_PADDING,slideTop + MIDDLE_LINE_WIDTH/2, paint); - - - //��ɨ���������� - paint.setColor(Color.WHITE); - paint.setTextSize(TEXT_SIZE * density); - paint.setAlpha(0x40); - paint.setTypeface(Typeface.create("System", Typeface.BOLD)); - canvas.drawText("将二维码/条码放入框内即可扫描", frame.left, frame.bottom + (float)TEXT_PADDING_TOP *density, paint); - - - - Collection currentPossible = possibleResultPoints; - Collection currentLast = lastPossibleResultPoints; - if (currentPossible.isEmpty()) { - lastPossibleResultPoints = null; - } else { - //possibleResultPoints = new HashSet(5); - possibleResultPoints = Collections.synchronizedSet(new HashSet(5)); - - lastPossibleResultPoints = currentPossible; - paint.setAlpha(OPAQUE); - paint.setColor(resultPointColor); - for (ResultPoint point : currentPossible) { - canvas.drawCircle(frame.left + point.getX(), frame.top - + point.getY(), 6.0f, paint); - } - } - if (currentLast != null) { - paint.setAlpha(OPAQUE / 2); - paint.setColor(resultPointColor); - for (ResultPoint point : currentLast) { - canvas.drawCircle(frame.left + point.getX(), frame.top - + point.getY(), 3.0f, paint); - } - } - - - //ֻˢ��ɨ�������ݣ������ط���ˢ�� - postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, - frame.right, frame.bottom); - - } - } - - public void drawViewfinder() { - resultBitmap = null; - invalidate(); - } - - /** - * Draw background bitmap with the result points highlighted instead of the live - * scanning display. - * - * @param barcode - * An image of the decoded barcode. - */ - public void drawResultBitmap(Bitmap barcode) { - resultBitmap = barcode; - invalidate(); - } - - public void addPossibleResultPoint(ResultPoint point) { - possibleResultPoints.add(point); - } - -} diff --git a/app/src/main/res/layout/activity_capture.xml b/app/src/main/res/layout/activity_capture.xml deleted file mode 100755 index 977391a..0000000 --- a/app/src/main/res/layout/activity_capture.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index e89f9f2..d005582 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -179,14 +179,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" - android:textColor="#d9524b" + android:textColor="#DAA520" android:text="本平台为非涉密平台,严禁处理、传输" android:textSize="16sp" /> diff --git a/app/src/main/res/layout/activity_qr_code.xml b/app/src/main/res/layout/activity_qr_code.xml index cd61589..474c3fe 100644 --- a/app/src/main/res/layout/activity_qr_code.xml +++ b/app/src/main/res/layout/activity_qr_code.xml @@ -11,6 +11,7 @@ layout="@layout/layout_base" /> diff --git a/app/src/main/res/layout/activity_qrcode.xml b/app/src/main/res/layout/activity_qrcode.xml index 5d6dd31..f5abfb1 100644 --- a/app/src/main/res/layout/activity_qrcode.xml +++ b/app/src/main/res/layout/activity_qrcode.xml @@ -21,8 +21,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" - android:text="请扫描二维码进行签到" - android:textSize="20dp" /> + android:layout_marginTop="10dp" + android:text="@string/shan_please_sign" + android:textSize="20sp" /> @@ -30,7 +31,9 @@ + android:layout_height="match_parent" + android:layout_margin="10dp" + android:contentDescription="@string/shanke_sign"> diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index c70c9a7..acd69cc 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -18,7 +18,7 @@ android:id="@+id/ll_tip" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="#fffacd" + android:background="#FFFF00" android:gravity="center" android:orientation="vertical"> diff --git a/app/src/main/res/layout/fragment_yjyac.xml b/app/src/main/res/layout/fragment_yjyac.xml index 9b79c30..e6f0cb4 100644 --- a/app/src/main/res/layout/fragment_yjyac.xml +++ b/app/src/main/res/layout/fragment_yjyac.xml @@ -24,9 +24,4 @@ android:text="暂无数据" /> - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_yjyad.xml b/app/src/main/res/layout/fragment_yjyad.xml index 6e52318..e6f0cb4 100644 --- a/app/src/main/res/layout/fragment_yjyad.xml +++ b/app/src/main/res/layout/fragment_yjyad.xml @@ -4,13 +4,24 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:layout_weight="1"> + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index be9b685..07943a4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -51,6 +51,8 @@ 删除 one hundred 将二维码/条码放入框内即可扫描 + 签到 + 请扫描二维码进行签到 diff --git a/autolayout/build.gradle b/autolayout/build.gradle index c77c962..561e714 100644 --- a/autolayout/build.gradle +++ b/autolayout/build.gradle @@ -11,5 +11,5 @@ android { } dependencies { - implementation libs.androidx.appcompat.v170 + implementation libs.androidx.appcompat.v120 } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6d1288d..1db82f9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,40 +1,97 @@ [versions] agp = "8.8.0" -androidxAppcompat = "1.2.0" -androidxRecyclerview = "1.3.0" -appcompatVersion = "1.7.0" -fragment = "1.8.3" +androidxAppcompat = "1.7.0" +androidxRecyclerview = "1.4.0" +appupdate = "4.2.6" +barcodeScanning = "16.1.1" +baserecyclerviewadapterhelperVersion = "2.9.30" +bouncycastleBcpkixJdk15on = "1.67" +circleimageview = "3.1.0" +cnHutoolAll = "5.8.5" +comGithubPhiljayMpandroidchart5 = "v3.1.0" +comGithubChrisbanesPhotoviewLibrary5 = "1.2.4" +cnJzvdJiaozivideoplayer5 = "7.2.3" +comGithubChrisbanesPhotoview5 = "2.1.3" +comDavemorrisseyLabsSubsamplingScaleImageView5 = "3.10.0" +comGithubHuangyanbinSmarttable5 = "2.2.0" +commonsCodec = "1.15" +compiler = "4.11.0" +comSquareupRetrofit2Retrofit2 = "2.9.0" +eclipseOrgEclipsePahoAndroidService = "1.1.1" +eclipseOrgEclipsePahoClientMqttv3 = "1.2.4" +emojiBundled = "1.1.0" +fragment = "1.8.6" +githubCompress = "v3.10.7" +githubPictureselector = "v3.10.7" +ioGithubJustsonAgentwebCore2 = "v5.1.1-androidx" kotlin = "1.9.24" -coreKtx = "1.10.1" +coreKtx = "1.15.0" junit = "4.13.2" -junitVersion = "1.1.5" -espressoCore = "3.5.1" -appcompat = "1.6.1" -material = "1.10.0" -activity = "1.8.0" -constraintlayout = "2.1.4" +junitVersion = "1.2.1" +espressoCore = "3.6.1" +appcompat = "1.7.0" +loggingInterceptor = "4.9.0" +material = "1.12.0" +activity = "1.10.0" +constraintlayout = "2.2.0" +meShortcutbadgerVersion = "1.1.22" +multidex = "2.0.1" +recyclerviewVersion = "1.4.0" +stepviewVersion = "1.9" supportCompat = "28.0.0" pdfiumAndroid = "1.9.0" -annotationJvm = "1.9.1" +tencentCrashreportVersion = "4.1.9.3" +xuiVersion = "1.2.1" [libraries] androidx-appcompat-v120 = { module = "androidx.appcompat:appcompat", version.ref = "androidxAppcompat" } -androidx-appcompat-v170 = { module = "androidx.appcompat:appcompat", version.ref = "appcompatVersion" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } +androidx-emoji-bundled = { module = "androidx.emoji:emoji-bundled", version.ref = "emojiBundled" } androidx-fragment = { module = "androidx.fragment:fragment", version.ref = "fragment" } +androidx-multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" } androidx-recyclerview-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "androidxRecyclerview" } +appupdate = { module = "io.github.azhon:appupdate", version.ref = "appupdate" } +baoyachi-stepview = { module = "com.github.baoyachi:StepView", version.ref = "stepviewVersion" } +barcode-scanning = { module = "com.google.mlkit:barcode-scanning", version.ref = "barcodeScanning" } +circleimageview = { module = "de.hdodenhof:circleimageview", version.ref = "circleimageview" } +cn-hutool-hutool-all = { module = "cn.hutool:hutool-all", version.ref = "cnHutoolAll" } +com-github-bumptech-glide-glide = { module = "com.github.bumptech.glide:glide", version.ref = "compiler" } +com-github-huangyanbin-smarttable6 = { module = "com.github.huangyanbin:SmartTable", version.ref = "comGithubHuangyanbinSmarttable5" } +com-davemorrissey-labs-subsampling-scale-image-view6 = { module = "com.davemorrissey.labs:subsampling-scale-image-view", version.ref = "comDavemorrisseyLabsSubsamplingScaleImageView5" } +com-github-chrisbanes-photoview6 = { module = "com.github.chrisbanes:PhotoView", version.ref = "comGithubChrisbanesPhotoview5" } +cn-jzvd-jiaozivideoplayer6 = { module = "cn.jzvd:jiaozivideoplayer", version.ref = "cnJzvdJiaozivideoplayer5" } +com-github-chrisbanes-photoview-library6 = { module = "com.github.chrisbanes.photoview:library", version.ref = "comGithubChrisbanesPhotoviewLibrary5" } +com-github-philjay-mpandroidchart6 = { module = "com.github.PhilJay:MPAndroidChart", version.ref = "comGithubPhiljayMpandroidchart5" } +com-squareup-retrofit2-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "comSquareupRetrofit2Retrofit2" } +com-squareup-retrofit2-retrofit3 = { module = "com.squareup.retrofit2:retrofit", version.ref = "comSquareupRetrofit2Retrofit2" } +com-tencent-bugly-crashreport = { module = "com.tencent.bugly:crashreport", version.ref = "tencentCrashreportVersion" } +compiler = { module = "com.github.bumptech.glide:compiler", version.ref = "compiler" } +commons-codec = { module = "commons-codec:commons-codec", version.ref = "commonsCodec" } +cymchad-baserecyclerviewadapterhelper = { module = "com.github.CymChad:BaseRecyclerViewAdapterHelper", version.ref = "baserecyclerviewadapterhelperVersion" } +eclipse-org-eclipse-paho-client-mqttv3 = { module = "org.eclipse.paho:org.eclipse.paho.client.mqttv3", version.ref = "eclipseOrgEclipsePahoClientMqttv3" } +eclipse-org-eclipse-paho-android-service = { module = "org.eclipse.paho:org.eclipse.paho.android.service", version.ref = "eclipseOrgEclipsePahoAndroidService" } +github-camerax = { module = "io.github.lucksiege:camerax", version.ref = "githubCompress" } +github-pictureselector = { module = "io.github.lucksiege:pictureselector", version.ref = "githubPictureselector" } +github-compress = { module = "io.github.lucksiege:compress", version.ref = "githubCompress" } +github-ucrop = { module = "io.github.lucksiege:ucrop", version.ref = "githubCompress" } +io-github-justson-agentweb-core3 = { module = "io.github.justson:agentweb-core", version.ref = "ioGithubJustsonAgentwebCore2" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "loggingInterceptor" } material = { group = "com.google.android.material", name = "material", version.ref = "material" } androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } +me-leolin-shortcutbadger = { module = "me.leolin:ShortcutBadger", version.ref = "meShortcutbadgerVersion" } +okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "loggingInterceptor" } +org-bouncycastle-bcpkix-jdk15on = { module = "org.bouncycastle:bcpkix-jdk15on", version.ref = "bouncycastleBcpkixJdk15on" } pdfium-android = { module = "com.github.barteksc:pdfium-android", version.ref = "pdfiumAndroid" } +recyclerview-v140 = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerviewVersion" } recyclerview-v7 = { module = "com.android.support:recyclerview-v7", version.ref = "supportCompat" } support-compat = { module = "com.android.support:support-compat", version.ref = "supportCompat" } support-v4 = { module = "com.android.support:support-v4", version.ref = "supportCompat" } -androidx-annotation-jvm = { group = "androidx.annotation", name = "annotation-jvm", version.ref = "annotationJvm" } +xuexiangjys-xui = { module = "com.github.xuexiangjys:XUI", version.ref = "xuiVersion" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } diff --git a/libs/tbs_sdk_thirdapp_v4.3.0.93_43993_sharewithdownloadwithfile_withoutGame_obfs_20210220_114728.jar b/libs/tbs_sdk_thirdapp_v4.3.0.93_43993_sharewithdownloadwithfile_withoutGame_obfs_20210220_114728.jar deleted file mode 100644 index 610f769..0000000 Binary files a/libs/tbs_sdk_thirdapp_v4.3.0.93_43993_sharewithdownloadwithfile_withoutGame_obfs_20210220_114728.jar and /dev/null differ diff --git a/zxingLite/build.gradle b/zxingLite/build.gradle index b17d29b..0e38032 100644 --- a/zxingLite/build.gradle +++ b/zxingLite/build.gradle @@ -15,5 +15,5 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation files('libs/zixing_core_3.4.1.jar') implementation libs.androidx.fragment - implementation libs.androidx.appcompat.v170 + implementation libs.androidx.appcompat.v120 }