From fdf3b5d172f6d17d7f70c29a89f001b5b00ddee3 Mon Sep 17 00:00:00 2001 From: hwf453 Date: Fri, 20 Dec 2024 17:55:44 +0800 Subject: [PATCH] 1.2.0 release --- app/build.gradle | 5 +- .../main/java/com/rehome/dywoa/Contans.java | 5 + .../dywoa/bean/FaceRecognitionResult.java | 22 + .../dywoa/ui/activity/FanWeiActivity.java | 1550 ++++++++++++++++- .../rehome/dywoa/ui/activity/HomeActivity.kt | 4 + .../rehome/dywoa/ui/activity/LoginActivity.kt | 45 +- .../dywoa/ui/activity/YhscpActivity.java | 2 +- .../dywoa/ui/activity/sbxj/SxgzActivity.java | 7 +- .../ui/activity/sbxj/XzxsjhFragment.java | 2 +- .../dywoa/ui/fragment/HomeFragment.java | 9 +- .../dywoa/weiget/ConfirmFaceDialog.java | 51 +- .../layout/activity_face_recognition_app.xml | 2 +- app/src/main/res/layout/activity_fan_wei.xml | 55 + .../main/res/layout/dialog_confirm_face.xml | 181 +- 14 files changed, 1845 insertions(+), 95 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2740867..39d9adb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.rehome.dywoa" minSdk 24 targetSdk 35 - versionCode 20 - versionName "1.1.9" + versionCode 21 + versionName "1.2.0" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" //每个应用拥有不同的authorities,防止相同的在同一个手机上无法同时安装 @@ -162,6 +162,7 @@ dependencies { // If you want to additionally use the CameraX Extensions library implementation "androidx.camera:camera-extensions:${camerax_version}" + testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/app/src/main/java/com/rehome/dywoa/Contans.java b/app/src/main/java/com/rehome/dywoa/Contans.java index 875709b..fec343c 100644 --- a/app/src/main/java/com/rehome/dywoa/Contans.java +++ b/app/src/main/java/com/rehome/dywoa/Contans.java @@ -10,6 +10,11 @@ public class Contans { // public static String BI_TOKEN_IP = "https://bi.dywzhny.com.cn/"; +// public static String IP = "http://192.168.2.22:8601/"; +// public static String IP_INTRANET = "http://192.168.2.22:8601/"; +// public static String IP_EXTRANET = "http://192.168.2.22:8601/"; +// public static String SIS_TOKEN_IP = "https://sis.dywzhny.com.cn/"; +// public static String BI_TOKEN_IP = "https://bi.dywzhny.com.cn/"; //APP登录接口厂内服务器IP diff --git a/app/src/main/java/com/rehome/dywoa/bean/FaceRecognitionResult.java b/app/src/main/java/com/rehome/dywoa/bean/FaceRecognitionResult.java index abb2a61..a53f308 100644 --- a/app/src/main/java/com/rehome/dywoa/bean/FaceRecognitionResult.java +++ b/app/src/main/java/com/rehome/dywoa/bean/FaceRecognitionResult.java @@ -1,5 +1,7 @@ package com.rehome.dywoa.bean; +import java.util.List; + public class FaceRecognitionResult { private int state; private String msg; @@ -36,6 +38,10 @@ public class FaceRecognitionResult { private String phone; private String sex; private String faceType; + //承包商公司名称 + private String contractor; + //技能证书 + private List skills; public String getName() { return name; @@ -84,5 +90,21 @@ public class FaceRecognitionResult { public void setFaceType(String faceType) { this.faceType = faceType; } + + public String getContractor() { + return contractor; + } + + public void setContractor(String contractor) { + this.contractor = contractor; + } + + public List getSkills() { + return skills; + } + + public void setSkills(List skills) { + this.skills = skills; + } } } diff --git a/app/src/main/java/com/rehome/dywoa/ui/activity/FanWeiActivity.java b/app/src/main/java/com/rehome/dywoa/ui/activity/FanWeiActivity.java index dc53b9f..6cc715d 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/activity/FanWeiActivity.java +++ b/app/src/main/java/com/rehome/dywoa/ui/activity/FanWeiActivity.java @@ -1,48 +1,238 @@ package com.rehome.dywoa.ui.activity; - - - +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.annotation.Nullable; import androidx.appcompat.widget.Toolbar; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.constraintlayout.widget.ConstraintSet; +import androidx.core.content.ContextCompat; +import androidx.core.content.FileProvider; +import androidx.fragment.app.Fragment; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.SimpleItemAnimator; + +import android.Manifest; +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.ClipData; import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.res.Configuration; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.os.Environment; +import android.os.Handler; +import android.os.Looper; +import android.provider.MediaStore; +import android.text.Spannable; +import android.text.SpannableStringBuilder; import android.text.TextUtils; +import android.text.style.AbsoluteSizeSpan; +import android.text.style.ForegroundColorSpan; +import android.util.Base64; import android.util.Log; import android.view.KeyEvent; +import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; +import android.webkit.ConsoleMessage; +import android.webkit.ValueCallback; +import android.webkit.WebChromeClient; import android.webkit.WebView; +import android.widget.CheckBox; +import android.widget.ImageView; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.target.CustomTarget; +import com.bumptech.glide.request.transition.Transition; +import com.google.gson.Gson; +import com.luck.picture.lib.PictureSelectorPreviewFragment; +import com.luck.picture.lib.animators.AnimationType; +import com.luck.picture.lib.basic.IBridgeViewLifecycle; +import com.luck.picture.lib.basic.PictureSelectionModel; +import com.luck.picture.lib.basic.PictureSelector; +import com.luck.picture.lib.config.InjectResourceSource; +import com.luck.picture.lib.config.PictureMimeType; +import com.luck.picture.lib.config.PictureSelectionConfig; +import com.luck.picture.lib.config.SelectLimitType; +import com.luck.picture.lib.config.SelectMimeType; +import com.luck.picture.lib.config.SelectModeConfig; +import com.luck.picture.lib.decoration.GridSpacingItemDecoration; +import com.luck.picture.lib.engine.CompressFileEngine; +import com.luck.picture.lib.engine.CropFileEngine; +import com.luck.picture.lib.engine.ImageEngine; +import com.luck.picture.lib.engine.UriToFileTransformEngine; +import com.luck.picture.lib.engine.VideoPlayerEngine; +import com.luck.picture.lib.entity.LocalMedia; +import com.luck.picture.lib.entity.MediaExtraInfo; +import com.luck.picture.lib.interfaces.OnBitmapWatermarkEventListener; +import com.luck.picture.lib.interfaces.OnCameraInterceptListener; +import com.luck.picture.lib.interfaces.OnCustomLoadingListener; +import com.luck.picture.lib.interfaces.OnExternalPreviewEventListener; +import com.luck.picture.lib.interfaces.OnInjectActivityPreviewListener; +import com.luck.picture.lib.interfaces.OnInjectLayoutResourceListener; +import com.luck.picture.lib.interfaces.OnKeyValueResultCallbackListener; +import com.luck.picture.lib.interfaces.OnMediaEditInterceptListener; +import com.luck.picture.lib.interfaces.OnPermissionDeniedListener; +import com.luck.picture.lib.interfaces.OnPermissionDescriptionListener; +import com.luck.picture.lib.interfaces.OnPreviewInterceptListener; +import com.luck.picture.lib.interfaces.OnQueryFilterListener; +import com.luck.picture.lib.interfaces.OnRecordAudioInterceptListener; +import com.luck.picture.lib.interfaces.OnSelectLimitTipsListener; +import com.luck.picture.lib.interfaces.OnVideoThumbnailEventListener; +import com.luck.picture.lib.language.LanguageConfig; +import com.luck.picture.lib.permissions.PermissionChecker; +import com.luck.picture.lib.permissions.PermissionConfig; +import com.luck.picture.lib.permissions.PermissionResultCallback; +import com.luck.picture.lib.style.PictureSelectorStyle; +import com.luck.picture.lib.style.SelectMainStyle; +import com.luck.picture.lib.style.TitleBarStyle; +import com.luck.picture.lib.utils.DateUtils; +import com.luck.picture.lib.utils.DensityUtil; +import com.luck.picture.lib.utils.MediaUtils; +import com.luck.picture.lib.utils.PictureFileUtils; +import com.luck.picture.lib.utils.SandboxTransformUtils; +import com.luck.picture.lib.utils.StyleUtils; +import com.luck.picture.lib.utils.ToastUtils; +import com.luck.picture.lib.widget.MediumBoldTextView; import com.rehome.dywoa.App; import com.rehome.dywoa.Contans; +import com.rehome.dywoa.CustomDialogActivity; +import com.rehome.dywoa.Listener.GlideEngine; +import com.rehome.dywoa.Listener.ImageLoaderUtils; +import com.rehome.dywoa.MyObject; import com.rehome.dywoa.R; +import com.rehome.dywoa.adapter.luck.GridImageAdapter; import com.rehome.dywoa.base.BaseAgentWebActivity; +import com.rehome.dywoa.base.MipcaActivityCapture; import com.rehome.dywoa.bean.FwSingleLoginResult; +import com.rehome.dywoa.utils.FullyGridLayoutManager; import com.rehome.dywoa.utils.GsonUtils; import com.rehome.dywoa.utils.HttpListener; import com.rehome.dywoa.utils.NoProgresshttpUtils; import com.rehome.dywoa.utils.NohttpUtils; import com.rehome.dywoa.utils.RSAUtils; import com.rehome.dywoa.utils.UiUtlis; +import com.yalantis.ucrop.UCrop; +import com.yalantis.ucrop.UCropImageEngine; import com.yolanda.nohttp.NoHttp; import com.yolanda.nohttp.RequestMethod; import com.yolanda.nohttp.rest.Request; import com.yolanda.nohttp.rest.Response; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.text.ParseException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.UUID; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocketFactory; +import cn.hutool.core.io.IoUtil; +import top.zibin.luban.CompressionPredicate; +import top.zibin.luban.Luban; +import top.zibin.luban.OnNewCompressListener; +import top.zibin.luban.OnRenameListener; + public class FanWeiActivity extends BaseAgentWebActivity { + private static final String[] permission = new String[]{ + Manifest.permission.CAMERA, + Manifest.permission.WRITE_EXTERNAL_STORAGE + }; + + private static final int CAMERA_REQUEST_CODE = 3;//人脸识别请求摄像头权限 + private static final int QRCODE_SCAN_CAMERA_REQUEST_CODE = 4;//扫描二維码请求摄像头权限 + private LocalBroadcastManager localBroadcastManager; + private static final int STXC = 102; + private static final int STEND = 301; + + private Uri uriTakePicSt; + private Uri uriTakePicOutputSt; + + + static int neetUpload = 0; + + + private ProgressDialog progressDialog; + + + private String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "com.rehome.dywoa/images"; + + private String stFileName; + private String videoFilePath; + private String duration; + private ArrayList videoList = new ArrayList<>(); + + private List filePathList = new ArrayList<>(); + + + private GridImageAdapter mAdapter; + private int maxSelectNum = 10; + private int maxSelectVideoNum = 1; + private final List mData = new ArrayList<>(); + + private int language = LanguageConfig.UNKNOWN_LANGUAGE; + private ImageEngine imageEngine; + private VideoPlayerEngine videoPlayerEngine; + private PictureSelectorStyle selectorStyle; + private int chooseModePhoto = SelectMimeType.ofImage(); + private int chooseModeVideo = SelectMimeType.ofVideo(); + private int chooseMode = chooseModePhoto; + private final static String TAG_EXPLAIN_VIEW = "TAG_EXPLAIN_VIEW"; + private final static String TAG = "app"; + private int animationMode = AnimationType.DEFAULT_ANIMATION; + + + private final static int FILE_CHOOSER_RESULT_CODE = 10000; + private ValueCallback uploadMessage; + private ValueCallback uploadMessageAboveL; + + + private ActivityResultLauncher launcherResult; + ActivityResultLauncher launcherResultSelectType; + //选择拍照 + ActivityResultLauncher launcherResultTakePhoto; + //选择拍照后截图 + ActivityResultLauncher launcherResultTakePhotoZoom; + + private WebView webview; + private RecyclerView recycle; + private CheckBox cb_crop; + private CheckBox cb_compress; + private CheckBox cb_editor; + + + // 进度条的定义 + private ProgressBar progressBar; + + private Toolbar mToolbar; private TextView mTitleTextView; @@ -54,15 +244,23 @@ public class FanWeiActivity extends BaseAgentWebActivity { String url; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fan_wei); + recycle = findViewById(R.id.recycle); + cb_crop = findViewById(R.id.cb_crop); + cb_compress = findViewById(R.id.cb_compress); + cb_editor = findViewById(R.id.cb_editor); + progressBar = (ProgressBar) findViewById(R.id.progressBar); + + progressBar.setMax(100); + + type = getIntent().getStringExtra("type"); url = getIntent().getStringExtra("url"); - if(TextUtils.isEmpty(type)){ + if (TextUtils.isEmpty(type)) { type = ""; } @@ -83,6 +281,10 @@ public class FanWeiActivity extends BaseAgentWebActivity { mAgentWeb.getWebCreator().getWebView().getSettings().setBuiltInZoomControls(true); mAgentWeb.getWebCreator().getWebView().getSettings().setDisplayZoomControls(false); mAgentWeb.getWebCreator().getWebView().getSettings().setSupportZoom(true); + mAgentWeb.getWebCreator().getWebView().setWebChromeClient(new MyWebChromeClient()); + + //初始化获取照片和视频 + initTakePhotoAndVideo(); checkServerConnectStatus(); @@ -101,8 +303,8 @@ public class FanWeiActivity extends BaseAgentWebActivity { //检查服务器连接状态 private void checkServerConnectStatus() { - Map param = new HashMap<>(); - param.put("login","dywoa"); + Map param = new HashMap<>(); + param.put("login", "dywoa"); String json = GsonUtils.GsonString(param); String url = Contans.IP + Contans.check_server_connect; showLog(url); @@ -119,11 +321,11 @@ public class FanWeiActivity extends BaseAgentWebActivity { String result = response.get(); showLog("-----onSucceed----"); showLog(result); - if(result.equals("1")){ + if (result.equals("1")) { showLog("connect server success"); //可以连接到服务器,请求数据 getSingleLoginToken(); - }else{ + } else { showToast("无法连接到服务器,请检查网络环境"); } } @@ -157,7 +359,7 @@ public class FanWeiActivity extends BaseAgentWebActivity { // }); // } - NohttpUtils.getInstance().add(this,1,request,new HttpListener(){ + NohttpUtils.getInstance().add(this, 1, request, new HttpListener() { @Override public void onSucceed(int what, Response response) throws ParseException { @@ -172,11 +374,11 @@ public class FanWeiActivity extends BaseAgentWebActivity { FwSingleLoginResult loginResult = GsonUtils.GsonToBean(jsonDecode, FwSingleLoginResult.class); showLog(jsonDecode); if (loginResult != null) { - if (loginResult.getErrmsg()!=null&&loginResult.getErrmsg().equals("success")) { - if(!TextUtils.isEmpty(loginResult.getToken())){ + if (loginResult.getErrmsg() != null && loginResult.getErrmsg().equals("success")) { + if (!TextUtils.isEmpty(loginResult.getToken())) { loadSisPage(loginResult.getToken()); } - }else{ + } else { showToast(loginResult.getErrmsg()); } } @@ -191,7 +393,7 @@ public class FanWeiActivity extends BaseAgentWebActivity { } private void loadSisPage(String token) { - var tempUrl = "https://mis.dywzhny.com.cn/papi/open/singleSignon?oauthType=singlesign&singleToken="+ token +"&redirect_uri="; + var tempUrl = "https://mis.dywzhny.com.cn/papi/open/singleSignon?oauthType=singlesign&singleToken=" + token + "&redirect_uri="; startUrl = tempUrl + url; showLog(startUrl); @@ -201,7 +403,6 @@ public class FanWeiActivity extends BaseAgentWebActivity { } - @NonNull @Override protected ViewGroup getAgentWebParent() { @@ -276,4 +477,1323 @@ public class FanWeiActivity extends BaseAgentWebActivity { Toast.makeText(this, strId, Toast.LENGTH_SHORT).show(); } + private void initTakePhotoAndVideo() { + launcherResult = createActivityResultLauncher(); + launcherResultSelectType = createSelectTypeActivityResultLauncher(); + +// launcherResultTakePhoto = createTakePhotoActivityResultLauncher(); +// launcherResultTakePhotoZoom = createTakePhotoZoomActivityResultLauncher(); + + + progressDialog = new ProgressDialog(this); + progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); + progressDialog.setProgress(R.mipmap.ic_launcher); + progressDialog.setSecondaryProgress(R.mipmap.ic_launcher_round);//设置二级进度条的背景 + progressDialog.setCancelable(false);// 设置是否可以通过点击Back键取消 + progressDialog.setCanceledOnTouchOutside(false);// 设置在点击Dialog外是否取消Dialog进度条 + progressDialog.setIcon(R.mipmap.ic_launcher);// + progressDialog.setMessage("压缩视频中,请稍等 ..."); + progressDialog.setTitle("视频压缩"); + progressDialog.setMax(100); + + //android 10 以上 + if (getExternalFilesDir(null) != null) { + path = Objects.requireNonNull(getExternalFilesDir(null)).getPath() + "/images"; + } else { + path = getFilesDir().getPath() + "/images"; + } + + neetUpload = 0; + clearImageDiskCache(FanWeiActivity.this); + + FullyGridLayoutManager manager = new FullyGridLayoutManager(this, + 4, GridLayoutManager.VERTICAL, false); + recycle.setLayoutManager(manager); + RecyclerView.ItemAnimator itemAnimator = recycle.getItemAnimator(); + if (itemAnimator != null) { + ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false); + } + recycle.addItemDecoration(new GridSpacingItemDecoration(4, + DensityUtil.dip2px(this, 8), false)); + mAdapter = new GridImageAdapter(this, mData); + mAdapter.setSelectMax(maxSelectNum); + recycle.setAdapter(mAdapter); + + + imageEngine = GlideEngine.createGlideEngine(); + selectorStyle = new PictureSelectorStyle(); + mAdapter.setOnItemClickListener(new GridImageAdapter.OnItemClickListener() { + @Override + public void onItemClick(View v, int position) { + // 预览图片、视频、音频 + PictureSelector.create(FanWeiActivity.this) + .openPreview() + .setImageEngine(imageEngine) + .setVideoPlayerEngine(videoPlayerEngine) + .setSelectorUIStyle(selectorStyle) + .setLanguage(language) + .isAutoVideoPlay(false) + .isLoopAutoVideoPlay(false) + .isPreviewFullScreenMode(true) + .isVideoPauseResumePlay(false) + .setCustomLoadingListener(getCustomLoadingListener()) + .isPreviewZoomEffect(chooseMode != SelectMimeType.ofAudio(), recycle) + .setAttachViewLifecycle(new IBridgeViewLifecycle() { + @Override + public void onViewCreated(Fragment fragment, View view, Bundle savedInstanceState) { +// PictureSelectorPreviewFragment previewFragment = (PictureSelectorPreviewFragment) fragment; +// MediumBoldTextView tvShare = view.findViewById(R.id.tv_share); +// tvShare.setVisibility(View.VISIBLE) +// previewFragment.addAminViews(tvShare); +// ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) tvShare.getLayoutParams(); +// layoutParams.topMargin = cb_preview_full.isChecked() ? DensityUtil.getStatusBarHeight(getContext()) : 0; +// tvShare.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View v) { +// PicturePreviewAdapter previewAdapter = previewFragment.getAdapter(); +// ViewPager2 viewPager2 = previewFragment.getViewPager2(); +// LocalMedia media = previewAdapter.getItem(viewPager2.getCurrentItem()); +// ToastUtils.showToast(fragment.getContext(), "自定义分享事件:" + viewPager2.getCurrentItem()); +// } +// }); + } + + @Override + public void onDestroy(Fragment fragment) { + //取消注册广播,防止内存泄漏 + //localBroadcastManager.unregisterReceiver( myReceiver ); +// if (cb_preview_full.isChecked()) { +// // 如果是全屏预览模式且是startFragmentPreview预览,回到自己的界面时需要恢复一下自己的沉浸式状态 +// // 以下提供2种解决方案: +// // 1.通过ImmersiveManager.immersiveAboveAPI23重新设置一下沉浸式 +// int statusBarColor = ContextCompat.getColor(getContext(), R.color.ps_color_grey); +// int navigationBarColor = ContextCompat.getColor(getContext(), R.color.ps_color_grey); +// ImmersiveManager.immersiveAboveAPI23(FanWeiActivityJava.this, +// true, true, +// statusBarColor, navigationBarColor, false); +// // 2.让自己的titleBar的高度加上一个状态栏高度且内容PaddingTop下沉一个状态栏的高度 +// } + } + }) + .setInjectLayoutResourceListener(new OnInjectLayoutResourceListener() { + @Override + public int getLayoutResourceId(Context context, int resourceSource) { + return resourceSource == InjectResourceSource.PREVIEW_LAYOUT_RESOURCE + ? R.layout.ps_custom_fragment_preview + : InjectResourceSource.DEFAULT_LAYOUT_RESOURCE; + } + }) + .setExternalPreviewEventListener(new MyExternalPreviewEventListener()) + .setInjectActivityPreviewFragment(new OnInjectActivityPreviewListener() { + @Override + public PictureSelectorPreviewFragment onInjectPreviewFragment() { + return null; + } + }) + .startActivityPreview(position, true, mAdapter.getData()); + } + + @Override + public void openPicture() { + // 进入相册 + PictureSelectionModel selectionModel = PictureSelector.create(FanWeiActivity.this) + .openGallery(chooseMode) + .setSelectorUIStyle(selectorStyle) + .setImageEngine(imageEngine) + .setVideoPlayerEngine(videoPlayerEngine) + .setCropEngine(getCropFileEngine()) + .setCompressEngine(getCompressFileEngine()) + .setSandboxFileEngine(new MeSandboxFileEngine()) + .setCameraInterceptListener(getCustomCameraEvent()) + .setRecordAudioInterceptListener(new MeOnRecordAudioInterceptListener()) + .setSelectLimitTipsListener(new MeOnSelectLimitTipsListener()) + .setEditMediaInterceptListener(getCustomEditMediaEvent()) + .setPermissionDescriptionListener(getPermissionDescriptionListener()) + .setPreviewInterceptListener(getPreviewInterceptListener()) + .setPermissionDeniedListener(getPermissionDeniedListener()) + .setAddBitmapWatermarkListener(getAddBitmapWatermarkListener()) + .setVideoThumbnailListener(getVideoThumbnailEventListener()) + .isAutoVideoPlay(false) + .isLoopAutoVideoPlay(false) + .isPageSyncAlbumCount(true) + .setRecordVideoMaxSecond(10) + .setCustomLoadingListener(getCustomLoadingListener()) + .setQueryFilterListener(new OnQueryFilterListener() { + @Override + public boolean onFilter(LocalMedia media) { + return false; + } + }) + .setSelectionMode(SelectModeConfig.MULTIPLE) + .setLanguage(language) + .setOutputCameraDir(getSandboxCameraOutputPath()) + .setQuerySandboxDir(getSandboxCameraOutputPath()) + .isDisplayTimeAxis(true) + .isOnlyObtainSandboxDir(false) + .isPageStrategy(true) + .isOriginalControl(false) + .isDisplayCamera(true) + .isOpenClickSound(false) + .setSkipCropMimeType(getNotSupportCrop()) + .isFastSlidingSelect(true) + //.setOutputCameraImageFileName("luck.jpeg") + //.setOutputCameraVideoFileName("luck.mp4") + .isWithSelectVideoImage(true) + .isPreviewFullScreenMode(true) + .isVideoPauseResumePlay(false) + .isPreviewZoomEffect(true) + .isPreviewImage(true) + .isPreviewVideo(true) + .isPreviewAudio(true) + .setGridItemSelectAnimListener(null) + //.setQueryOnlyMimeType(PictureMimeType.ofGIF()) + .isMaxSelectEnabledMask(true) + .setMaxSelectNum(maxSelectNum) + .setMaxVideoSelectNum(maxSelectVideoNum) + .setRecyclerAnimationMode(animationMode) + .isGif(false) + .setSelectedData(mAdapter.getData()); + forSelectResult(selectionModel); + } + }); + + } + + + /** + * 清除图片磁盘缓存 + */ + public void clearImageDiskCache(Context context) { + try { + if (Looper.myLooper() == Looper.getMainLooper()) { + new Thread(new Runnable() { + @Override + public void run() { + Glide.get(context).clearDiskCache(); + } + }).start(); + } else { + Glide.get(context).clearDiskCache(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void forSelectResult(PictureSelectionModel model) { + model.forResult(launcherResult); + } + + + /** + * 处理选择结果 + * + * @param result + */ + private void analyticalSelectResults(ArrayList result) { + + filePathList.clear(); + videoList.clear(); + + for (LocalMedia media : result) { + if (media.getWidth() == 0 || media.getHeight() == 0) { + if (PictureMimeType.isHasImage(media.getMimeType())) { + MediaExtraInfo imageExtraInfo = MediaUtils.getImageSize(FanWeiActivity.this, media.getPath()); + media.setWidth(imageExtraInfo.getWidth()); + media.setHeight(imageExtraInfo.getHeight()); + } else if (PictureMimeType.isHasVideo(media.getMimeType())) { + MediaExtraInfo videoExtraInfo = MediaUtils.getVideoSize(FanWeiActivity.this, media.getPath()); + media.setWidth(videoExtraInfo.getWidth()); + media.setHeight(videoExtraInfo.getHeight()); + } + } + String filePath = media.getSandboxPath(); + if(filePath!=null){ + if (chooseMode == chooseModePhoto) { + filePathList.add(filePath); + } else if (PictureMimeType.isHasVideo(media.getMimeType())) { + videoList.add(filePath); + videoFilePath = media.getSandboxPath(); + duration = DateUtils.formatDurationTime(media.getDuration()); + } + } + + + + + Log.i(TAG, "文件名: " + media.getFileName()); + Log.i(TAG, "是否压缩:" + media.isCompressed()); + Log.i(TAG, "压缩:" + media.getCompressPath()); + Log.i(TAG, "初始路径:" + media.getPath()); + Log.i(TAG, "绝对路径:" + media.getRealPath()); + Log.i(TAG, "是否裁剪:" + media.isCut()); + Log.i(TAG, "裁剪路径:" + media.getCutPath()); + Log.i(TAG, "是否开启原图:" + media.isOriginal()); + Log.i(TAG, "原图路径:" + media.getOriginalPath()); + Log.i(TAG, "沙盒路径:" + media.getSandboxPath()); + Log.i(TAG, "水印路径:" + media.getWatermarkPath()); + Log.i(TAG, "视频缩略图:" + media.getVideoThumbnailPath()); + Log.i(TAG, "原始宽高: " + media.getWidth() + "x" + media.getHeight()); + Log.i(TAG, "裁剪宽高: " + media.getCropImageWidth() + "x" + media.getCropImageHeight()); + Log.i(TAG, "文件大小: " + PictureFileUtils.formatAccurateUnitFileSize(media.getSize())); + Log.i(TAG, "文件时长: " + media.getDuration()); + Log.i(TAG, "文件时长: " + duration); + //Log.i(TAG, "videoStFilePath: " + videoStFilePath); + File file = new File(filePath); + Log.i(TAG, "文件大小: " + file.length()); + +// String extensionName = FileUtils.getFileType(videoFileName); +// videoCompressFilePath = context.getExternalFilesDir(null).getPath() + "/Movies/" + UUID.randomUUID() + "_compress_video." + extensionName; +// showLog(videoCompressFilePath); +// if(chooseMode==chooseModeVideo){ +// VideoCompress.compressVideoLow(videoFilePath, videoCompressFilePath, new VideoCompress.CompressListener() { +// @Override +// public void onStart() { +// progressDialog.show(); +// } +// +// @Override +// public void onSuccess() { +// progressDialog.dismiss(); +// showLog(videoCompressFilePath); +// File file = new File(videoCompressFilePath); +// showLog("压缩后文件大小:"+String.valueOf(file.length())); +// +// } +// +// @Override +// public void onFail() { +// progressDialog.dismiss(); +// } +// +// @Override +// public void onProgress(float percent) { +// progressDialog.setProgress((int) percent); +// } +// }); +// } + + + } + + runOnUiThread(new Runnable() { + @Override + public void run() { + boolean isMaxSize = result.size() == mAdapter.getSelectMax(); + int oldSize = mAdapter.getData().size(); + mAdapter.notifyItemRangeRemoved(0, isMaxSize ? oldSize + 1 : oldSize); + mAdapter.getData().clear(); + mAdapter.getData().addAll(result); + mAdapter.notifyItemRangeInserted(0, result.size()); + + if (filePathList.size()>0) { + List fileUriList = new ArrayList<>(); + for(String filePath:filePathList){ + File file = new File(filePath); + Uri uri = Uri.fromFile(file); + fileUriList.add(uri); + } + + Uri[] results = fileUriList.toArray(new Uri[0]); + if (uploadMessageAboveL != null) { + uploadMessageAboveL.onReceiveValue(results); + uploadMessageAboveL = null; + } + } else { + if (videoFilePath != null) { + File file = new File(videoFilePath); + Uri uri = Uri.fromFile(file); + Uri[] results = new Uri[]{uri}; + if (uploadMessageAboveL != null) { + uploadMessageAboveL.onReceiveValue(results); + uploadMessageAboveL = null; + } + } else { + //這裏uploadMessage跟uploadMessageAboveL在不同系統版本下分別持有了 + //WebView對象,在用戶取消文件選擇器的情況下,需給onReceiveValue傳null返回值 + //否則WebView在未收到返回值的情況下,無法進行任何操作,文件選擇器會失效 + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } else if (uploadMessageAboveL != null) { + uploadMessageAboveL.onReceiveValue(null); + uploadMessageAboveL = null; + } + } + } + } + }); + } + + /** + * 自定义loading + * + * @return + */ + private OnCustomLoadingListener getCustomLoadingListener() { + return null; + } + + /** + * 外部预览监听事件 + */ + private class MyExternalPreviewEventListener implements OnExternalPreviewEventListener { + + @Override + public void onPreviewDelete(int position) { + mAdapter.remove(position); + mAdapter.notifyItemRemoved(position); + } + + @Override + public boolean onLongPressDownload(LocalMedia media) { + return false; + } + } + + /** + * 裁剪引擎 + * + * @return + */ + private ImageFileCropEngine getCropFileEngine() { + return cb_crop.isChecked() ? new ImageFileCropEngine() : null; + } + + /** + * 自定义裁剪 + */ + private class ImageFileCropEngine implements CropFileEngine { + + @Override + public void onStartCrop(Fragment fragment, Uri srcUri, Uri destinationUri, ArrayList dataSource, int requestCode) { + UCrop.Options options = buildOptions(); + UCrop uCrop = UCrop.of(srcUri, destinationUri, dataSource); + uCrop.withOptions(options); + uCrop.setImageEngine(new UCropImageEngine() { + @Override + public void loadImage(Context context, String url, ImageView imageView) { + if (!ImageLoaderUtils.assertValidRequest(context)) { + return; + } + Glide.with(context).load(url).override(180, 180).into(imageView); + } + + @Override + public void loadImage(Context context, Uri url, int maxWidth, int maxHeight, OnCallbackListener call) { + Glide.with(context).asBitmap().load(url).override(maxWidth, maxHeight).into(new CustomTarget() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { + if (call != null) { + call.onCall(resource); + } + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + if (call != null) { + call.onCall(null); + } + } + }); + } + }); + uCrop.start(fragment.requireActivity(), fragment, requestCode); + } + } + + /** + * 配制UCrop,可根据需求自我扩展 + * + * @return + */ + private UCrop.Options buildOptions() { + UCrop.Options options = new UCrop.Options(); + options.setHideBottomControls(false); + options.setFreeStyleCropEnabled(false); + options.setShowCropFrame(true); + options.setShowCropGrid(true); + options.setCircleDimmedLayer(false); + options.withAspectRatio(0, 0); + options.setCropOutputPathDir(getSandboxPath()); + options.isCropDragSmoothToCenter(false); + options.setSkipCropMimeType(getNotSupportCrop()); + options.isForbidCropGifWebp(false); + options.isForbidSkipMultipleCrop(true); + options.setMaxScaleMultiplier(100); + if (selectorStyle != null && selectorStyle.getSelectMainStyle().getStatusBarColor() != 0) { + SelectMainStyle mainStyle = selectorStyle.getSelectMainStyle(); + boolean isDarkStatusBarBlack = mainStyle.isDarkStatusBarBlack(); + int statusBarColor = mainStyle.getStatusBarColor(); + options.isDarkStatusBarBlack(isDarkStatusBarBlack); + if (StyleUtils.checkStyleValidity(statusBarColor)) { + options.setStatusBarColor(statusBarColor); + options.setToolbarColor(statusBarColor); + } else { + options.setStatusBarColor(ContextCompat.getColor(FanWeiActivity.this, com.luck.picture.lib.R.color.ps_color_grey)); + options.setToolbarColor(ContextCompat.getColor(FanWeiActivity.this, com.luck.picture.lib.R.color.ps_color_grey)); + } + TitleBarStyle titleBarStyle = selectorStyle.getTitleBarStyle(); + if (StyleUtils.checkStyleValidity(titleBarStyle.getTitleTextColor())) { + options.setToolbarWidgetColor(titleBarStyle.getTitleTextColor()); + } else { + options.setToolbarWidgetColor(ContextCompat.getColor(FanWeiActivity.this, com.luck.picture.lib.R.color.ps_color_white)); + } + } else { + options.setStatusBarColor(ContextCompat.getColor(FanWeiActivity.this, com.luck.picture.lib.R.color.ps_color_grey)); + options.setToolbarColor(ContextCompat.getColor(FanWeiActivity.this, com.luck.picture.lib.R.color.ps_color_grey)); + options.setToolbarWidgetColor(ContextCompat.getColor(FanWeiActivity.this, com.luck.picture.lib.R.color.ps_color_white)); + } + return options; + } + + /** + * 创建自定义输出目录 + * + * @return + */ + private String getSandboxPath() { + File externalFilesDir = FanWeiActivity.this.getExternalFilesDir(""); + File customFile = new File(externalFilesDir.getAbsolutePath(), "Sandbox"); + if (!customFile.exists()) { + customFile.mkdirs(); + } + return customFile.getAbsolutePath() + File.separator; + } + + private String[] getNotSupportCrop() { + //跳过裁剪GIF +// if (true) { +// return new String[]{PictureMimeType.ofGIF(), PictureMimeType.ofWEBP()}; +// } + return null; + } + + /** + * 压缩引擎 + * + * @return + */ + private ImageFileCompressEngine getCompressFileEngine() { + return cb_compress.isChecked() ? new ImageFileCompressEngine() : null; + } + + /** + * 自定义压缩 + */ + private static class ImageFileCompressEngine implements CompressFileEngine { + + @Override + public void onStartCompress(Context context, ArrayList source, OnKeyValueResultCallbackListener call) { + Luban.with(context).load(source).ignoreBy(100).setRenameListener(new OnRenameListener() { + @Override + public String rename(String filePath) { + int indexOf = filePath.lastIndexOf("."); + String postfix = indexOf != -1 ? filePath.substring(indexOf) : ".jpg"; + return DateUtils.getCreateFileName("CMP_") + postfix; + } + }).filter(new CompressionPredicate() { + @Override + public boolean apply(String path) { + if (PictureMimeType.isUrlHasImage(path) && !PictureMimeType.isHasHttp(path)) { + return true; + } + return !PictureMimeType.isUrlHasGif(path); + } + }).setCompressListener(new OnNewCompressListener() { + @Override + public void onStart() { + + } + + @Override + public void onSuccess(String source, File compressFile) { + if (call != null) { + call.onCallback(source, compressFile.getAbsolutePath()); + } + } + + @Override + public void onError(String source, Throwable e) { + if (call != null) { + call.onCallback(source, null); + } + } + }).launch(); + } + } + + /** + * 自定义沙盒文件处理 + */ + private static class MeSandboxFileEngine implements UriToFileTransformEngine { + + @Override + public void onUriToFileAsyncTransform(Context context, String srcPath, String mineType, OnKeyValueResultCallbackListener call) { + if (call != null) { + call.onCallback(srcPath, SandboxTransformUtils.copyPathToSandbox(context, srcPath, mineType)); + } + } + } + + /** + * 自定义相机事件 + * + * @return + */ + private OnCameraInterceptListener getCustomCameraEvent() { + return null; + } + + /** + * 录音回调事件 + */ + private static class MeOnRecordAudioInterceptListener implements OnRecordAudioInterceptListener { + + @Override + public void onRecordAudio(Fragment fragment, int requestCode) { + String[] recordAudio = {android.Manifest.permission.RECORD_AUDIO}; + if (PermissionChecker.isCheckSelfPermission(fragment.getContext(), recordAudio)) { + startRecordSoundAction(fragment, requestCode); + } else { + addPermissionDescription(false, (ViewGroup) fragment.requireView(), recordAudio); + PermissionChecker.getInstance().requestPermissions(fragment, + new String[]{android.Manifest.permission.RECORD_AUDIO}, new PermissionResultCallback() { + @Override + public void onGranted() { + removePermissionDescription((ViewGroup) fragment.requireView()); + startRecordSoundAction(fragment, requestCode); + } + + @Override + public void onDenied() { + removePermissionDescription((ViewGroup) fragment.requireView()); + } + }); + } + } + } + + /** + * 启动录音意图 + * + * @param fragment + * @param requestCode + */ + private static void startRecordSoundAction(Fragment fragment, int requestCode) { + Intent recordAudioIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); + if (recordAudioIntent.resolveActivity(fragment.requireActivity().getPackageManager()) != null) { + fragment.startActivityForResult(recordAudioIntent, requestCode); + } else { + ToastUtils.showToast(fragment.getContext(), "The system is missing a recording component"); + } + } + + /** + * 添加权限说明 + * + * @param viewGroup + * @param permissionArray + */ + private static void addPermissionDescription(boolean isHasSimpleXCamera, ViewGroup viewGroup, String[] permissionArray) { + int dp10 = DensityUtil.dip2px(viewGroup.getContext(), 10); + int dp15 = DensityUtil.dip2px(viewGroup.getContext(), 15); + MediumBoldTextView view = new MediumBoldTextView(viewGroup.getContext()); + view.setTag(TAG_EXPLAIN_VIEW); + view.setTextSize(14); + view.setTextColor(Color.parseColor("#333333")); + view.setPadding(dp10, dp15, dp10, dp15); + + String title; + String explain; + + if (TextUtils.equals(permissionArray[0], PermissionConfig.CAMERA[0])) { + title = "相机权限使用说明"; + explain = "相机权限使用说明\n用户app用于拍照/录视频"; + } else if (TextUtils.equals(permissionArray[0], Manifest.permission.RECORD_AUDIO)) { + if (isHasSimpleXCamera) { + title = "麦克风权限使用说明"; + explain = "麦克风权限使用说明\n用户app用于录视频时采集声音"; + } else { + title = "录音权限使用说明"; + explain = "录音权限使用说明\n用户app用于采集声音"; + } + } else { + title = "存储权限使用说明"; + explain = "存储权限使用说明\n用户app写入/下载/保存/读取/修改/删除图片、视频、文件等信息"; + } + int startIndex = 0; + int endOf = startIndex + title.length(); + SpannableStringBuilder builder = new SpannableStringBuilder(explain); + builder.setSpan(new AbsoluteSizeSpan(DensityUtil.dip2px(viewGroup.getContext(), 16)), startIndex, endOf, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + builder.setSpan(new ForegroundColorSpan(0xFF333333), startIndex, endOf, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + view.setText(builder); + view.setBackground(ContextCompat.getDrawable(viewGroup.getContext(), R.drawable.ps_demo_permission_desc_bg)); + + if (isHasSimpleXCamera) { + RelativeLayout.LayoutParams layoutParams = + new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); + layoutParams.topMargin = DensityUtil.getStatusBarHeight(viewGroup.getContext()); + layoutParams.leftMargin = dp10; + layoutParams.rightMargin = dp10; + viewGroup.addView(view, layoutParams); + } else { + ConstraintLayout.LayoutParams layoutParams = + new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.WRAP_CONTENT); + layoutParams.topToBottom = R.id.title_bar; + layoutParams.leftToLeft = ConstraintSet.PARENT_ID; + layoutParams.leftMargin = dp10; + layoutParams.rightMargin = dp10; + viewGroup.addView(view, layoutParams); + } + } + + /** + * 移除权限说明 + * + * @param viewGroup + */ + private static void removePermissionDescription(ViewGroup viewGroup) { + View tagExplainView = viewGroup.findViewWithTag(TAG_EXPLAIN_VIEW); + viewGroup.removeView(tagExplainView); + } + + /** + * 拦截自定义提示 + */ + private static class MeOnSelectLimitTipsListener implements OnSelectLimitTipsListener { + + @Override + public boolean onSelectLimitTips(Context context, @Nullable LocalMedia media, PictureSelectionConfig config, int limitType) { + if (limitType == SelectLimitType.SELECT_MIN_SELECT_LIMIT) { + ToastUtils.showToast(context, "图片最少不能低于" + config.minSelectNum + "张"); + return true; + } else if (limitType == SelectLimitType.SELECT_MIN_VIDEO_SELECT_LIMIT) { + ToastUtils.showToast(context, "视频最少不能低于" + config.minVideoSelectNum + "个"); + return true; + } else if (limitType == SelectLimitType.SELECT_MIN_AUDIO_SELECT_LIMIT) { + ToastUtils.showToast(context, "音频最少不能低于" + config.minAudioSelectNum + "个"); + return true; + } + return false; + } + } + + /** + * 自定义编辑事件 + * + * @return + */ + private OnMediaEditInterceptListener getCustomEditMediaEvent() { + return cb_editor.isChecked() ? new MeOnMediaEditInterceptListener(getSandboxPath(), buildOptions()) : null; + } + + + /** + * 自定义编辑 + */ + private static class MeOnMediaEditInterceptListener implements OnMediaEditInterceptListener { + private final String outputCropPath; + private final UCrop.Options options; + + public MeOnMediaEditInterceptListener(String outputCropPath, UCrop.Options options) { + this.outputCropPath = outputCropPath; + this.options = options; + } + + @Override + public void onStartMediaEdit(Fragment fragment, LocalMedia currentLocalMedia, int requestCode) { + String currentEditPath = currentLocalMedia.getAvailablePath(); + Uri inputUri = PictureMimeType.isContent(currentEditPath) + ? Uri.parse(currentEditPath) : Uri.fromFile(new File(currentEditPath)); + Uri destinationUri = Uri.fromFile( + new File(outputCropPath, DateUtils.getCreateFileName("CROP_") + ".jpeg")); + UCrop uCrop = UCrop.of(inputUri, destinationUri); + options.setHideBottomControls(false); + uCrop.withOptions(options); + uCrop.setImageEngine(new UCropImageEngine() { + @Override + public void loadImage(Context context, String url, ImageView imageView) { + if (!ImageLoaderUtils.assertValidRequest(context)) { + return; + } + Glide.with(context).load(url).override(180, 180).into(imageView); + } + + @Override + public void loadImage(Context context, Uri url, int maxWidth, int maxHeight, OnCallbackListener call) { + Glide.with(context).asBitmap().load(url).override(maxWidth, maxHeight).into(new CustomTarget() { + @Override + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { + if (call != null) { + call.onCall(resource); + } + } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + if (call != null) { + call.onCall(null); + } + } + }); + } + }); + uCrop.startEdit(fragment.requireActivity(), fragment, requestCode); + } + } + + /** + * 权限说明 + * + * @return + */ + private OnPermissionDescriptionListener getPermissionDescriptionListener() { + return null; + } + + /** + * 自定义预览 + * + * @return + */ + private OnPreviewInterceptListener getPreviewInterceptListener() { + return null; + } + + /** + * 权限拒绝后回调 + * + * @return + */ + private OnPermissionDeniedListener getPermissionDeniedListener() { + return null; + } + + /** + * 给图片添加水印 + */ + private OnBitmapWatermarkEventListener getAddBitmapWatermarkListener() { + return null; + } + + /** + * 处理视频缩略图 + */ + private OnVideoThumbnailEventListener getVideoThumbnailEventListener() { + return null; + } + + /** + * 创建相机自定义输出目录 + * + * @return + */ + private String getSandboxCameraOutputPath() { + return ""; + } + + /** + * 创建一个ActivityResultLauncher + * + * @return + */ + private ActivityResultLauncher createActivityResultLauncher() { + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), + new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + int resultCode = result.getResultCode(); + if (resultCode == RESULT_OK) { + ArrayList selectList = PictureSelector.obtainSelectorList(result.getData()); + analyticalSelectResults(selectList); + } else if (resultCode == RESULT_CANCELED) { + //這裏uploadMessage跟uploadMessageAboveL在不同系統版本下分別持有了 + //WebView對象,在用戶取消文件選擇器的情況下,需給onReceiveValue傳null返回值 + //否則WebView在未收到返回值的情況下,無法進行任何操作,文件選擇器會失效 + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } else if (uploadMessageAboveL != null) { + uploadMessageAboveL.onReceiveValue(null); + uploadMessageAboveL = null; + } + } + } + }); + } + + private ActivityResultLauncher createSelectTypeActivityResultLauncher() { + //java写法 + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + Intent data = result.getData(); + int resultCode = result.getResultCode(); + if (resultCode == RESULT_OK && data != null) { + showLog("if"); + String type = data.getStringExtra("type"); + if (type.equals("1")) { + chooseMode = chooseModePhoto; + mAdapter.getData().clear(); + mAdapter.notifyDataSetChanged(); + openSelectPhotoOrVideo(); + } + if (type.equals("2")) { + chooseMode = chooseModeVideo; + mAdapter.getData().clear(); + mAdapter.notifyDataSetChanged(); + openSelectPhotoOrVideo(); + } + } else { + showLog("else"); + //這裏uploadMessage跟uploadMessageAboveL在不同系統版本下分別持有了 + //WebView對象,在用戶取消文件選擇器的情況下,需給onReceiveValue傳null返回值 + //否則WebView在未收到返回值的情況下,無法進行任何操作,文件選擇器會失效 + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } else if (uploadMessageAboveL != null) { + uploadMessageAboveL.onReceiveValue(null); + uploadMessageAboveL = null; + } + } + } + }); + } + + private ActivityResultLauncher createTakePhotoActivityResultLauncher() { + //java写法 + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + Intent data = result.getData(); + int resultCode = result.getResultCode(); + if (resultCode == RESULT_OK && data != null) { + try { + uriTakePicSt = uriToExternalFile(data.getData(), stFileName); + startPhotoZoom(uriTakePicSt, stFileName, STEND); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + //這裏uploadMessage跟uploadMessageAboveL在不同系統版本下分別持有了 + //WebView對象,在用戶取消文件選擇器的情況下,需給onReceiveValue傳null返回值 + //否則WebView在未收到返回值的情況下,無法進行任何操作,文件選擇器會失效 + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } else if (uploadMessageAboveL != null) { + uploadMessageAboveL.onReceiveValue(null); + uploadMessageAboveL = null; + } + } + } + }); + } + + private ActivityResultLauncher createTakePhotoZoomActivityResultLauncher() { + //java写法 + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + Intent data = result.getData(); + int resultCode = result.getResultCode(); + if (resultCode == RESULT_OK && data != null) { + try { + Bitmap stBitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uriTakePicOutputSt)); + //stEndName = stFileName; + //binding.ivSt.setImageBitmap(stBitmap); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + //這裏uploadMessage跟uploadMessageAboveL在不同系統版本下分別持有了 + //WebView對象,在用戶取消文件選擇器的情況下,需給onReceiveValue傳null返回值 + //否則WebView在未收到返回值的情況下,無法進行任何操作,文件選擇器會失效 + if (uploadMessage != null) { + uploadMessage.onReceiveValue(null); + uploadMessage = null; + } else if (uploadMessageAboveL != null) { + uploadMessageAboveL.onReceiveValue(null); + uploadMessageAboveL = null; + } + } + } + }); + } + + + private void closeCurrentActivity() { + finish(); + } + + // 2.回調方法觸發本地選擇文件 + private void openImageChooserActivity() { + Intent i = new Intent(Intent.ACTION_GET_CONTENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("image/*");//圖片上傳 + // i.setType("file/*");//文件上傳 + //i.setType("*/*");//文件上傳 + startActivityForResult(Intent.createChooser(i, "Image Chooser"), FILE_CHOOSER_RESULT_CODE); + } + + // 3.選擇圖片後處理 +// @Override +// protected void onActivityResult(int requestCode, int resultCode, Intent data) { +// super.onActivityResult(requestCode, resultCode, data); +// if (requestCode == FILE_CHOOSER_RESULT_CODE) { +// Uri result = data == null || resultCode != RESULT_OK ? null : data.getData(); +// // Uri result = (((data == null) || (resultCode != RESULT_OK)) ? null : data.getData()); +// onActivityResultAboveL(requestCode, resultCode, data); +// } else { +// //這裏uploadMessage跟uploadMessageAboveL在不同系統版本下分別持有了 +// //WebView對象,在用戶取消文件選擇器的情況下,需給onReceiveValue傳null返回值 +// //否則WebView在未收到返回值的情況下,無法進行任何操作,文件選擇器會失效 +// if (uploadMessage != null) { +// uploadMessage.onReceiveValue(null); +// uploadMessage = null; +// } else if (uploadMessageAboveL != null) { +// uploadMessageAboveL.onReceiveValue(null); +// uploadMessageAboveL = null; +// } +// } +// } + + // 4. 選擇內容回調到Html頁面 + private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) { + if (requestCode != FILE_CHOOSER_RESULT_CODE) return; + Uri[] results = null; + if (resultCode == Activity.RESULT_OK) { + if (intent != null) { + String dataString = intent.getDataString(); + ClipData clipData = intent.getClipData(); + if (clipData != null) { + showLog(new Gson().toJson(clipData)); + results = new Uri[clipData.getItemCount()]; + for (int i = 0; i < clipData.getItemCount(); i++) { + ClipData.Item item = clipData.getItemAt(i); + results[i] = item.getUri(); + } + } + if (dataString != null) results = new Uri[]{Uri.parse(dataString)}; + } + } + + uploadMessageAboveL.onReceiveValue(results); + uploadMessageAboveL = null; + } + + + @Override + public void onConfigurationChanged(@NonNull Configuration config) { + super.onConfigurationChanged(config); + switch (config.orientation) { + case Configuration.ORIENTATION_LANDSCAPE: + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + break; + case Configuration.ORIENTATION_PORTRAIT: + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); + break; + case Configuration.ORIENTATION_SQUARE: + case Configuration.ORIENTATION_UNDEFINED: + break; + } + } + + private void fullScreen() { + if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + Log.i("ToVmp", "横屏"); + } else { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + Log.i("ToVmp", "竖屏"); + } + } + + ; + + + private class MyWebChromeClient extends WebChromeClient { + WebChromeClient.CustomViewCallback mCallback; + + // 当加载页面时会调用这个方法 + @Override + public void onProgressChanged(WebView view, int newProgress) { + if (newProgress == 100) { + // 页面加载完成 + progressBar.setVisibility(View.GONE); + } else { + // 页面正在加载 + progressBar.setProgress(newProgress); + progressBar.setVisibility(View.VISIBLE); + } + } + + @Override + public void onShowCustomView(View view, CustomViewCallback callback) { + Log.i("ToVmp", "onShowCustomView"); + fullScreen(); + mCallback = callback; + super.onShowCustomView(view, callback); + } + + @Override + public void onHideCustomView() { + Log.i("ToVmp", "onHideCustomView"); + fullScreen(); + super.onHideCustomView(); + + } + + // For Android < 3.0 + public void openFileChooser(ValueCallback valueCallback) { + showLog("openFileChooser(ValueCallback valueCallback)"); + uploadMessage = valueCallback; + openImageChooserActivity(); + } + + // For Android >= 3.0 + public void openFileChooser(ValueCallback valueCallback, String acceptType) { + showLog("openFileChooser(ValueCallback valueCallback, String acceptType)"); + uploadMessage = valueCallback; + openImageChooserActivity(); + } + + //For Android >= 4.1 + public void openFileChooser(ValueCallback valueCallback, String acceptType, String capture) { + showLog("openFileChooser(ValueCallback valueCallback, String acceptType, String capture) "); + uploadMessage = valueCallback; + openImageChooserActivity(); + } + + // For Android >= 5.0 + @Override + public boolean onShowFileChooser(WebView webView, ValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { + + showLog("onShowFileChooser"); + uploadMessageAboveL = filePathCallback; + //openImageChooserActivity(); + Intent intent = new Intent(getApplicationContext(), CustomDialogActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + launcherResultSelectType.launch(intent); + showLog(String.valueOf(uploadMessageAboveL==null)); + return true; + } + + + @Override + public boolean onConsoleMessage(ConsoleMessage consoleMessage) { + if (!TextUtils.isEmpty(consoleMessage.message())) { + //consoleMessageHandler.onConsoleMessage(consoleMessage.message(), consoleMessage.lineNumber(), consoleMessage.sourceId()); + showLog(consoleMessage.message()); + } + return true; + } + + } + + private void openSelectPhotoOrVideo() { + // 进入相册 + PictureSelectionModel selectionModel = PictureSelector.create(FanWeiActivity.this) + .openGallery(chooseMode) + .setSelectorUIStyle(selectorStyle) + .setImageEngine(imageEngine) + .setVideoPlayerEngine(videoPlayerEngine) + .setCropEngine(getCropFileEngine()) + .setCompressEngine(getCompressFileEngine()) + .setSandboxFileEngine(new MeSandboxFileEngine()) + .setCameraInterceptListener(getCustomCameraEvent()) + .setRecordAudioInterceptListener(new MeOnRecordAudioInterceptListener()) + .setSelectLimitTipsListener(new MeOnSelectLimitTipsListener()) + .setEditMediaInterceptListener(getCustomEditMediaEvent()) + .setPermissionDescriptionListener(getPermissionDescriptionListener()) + .setPreviewInterceptListener(getPreviewInterceptListener()) + .setPermissionDeniedListener(getPermissionDeniedListener()) + .setAddBitmapWatermarkListener(getAddBitmapWatermarkListener()) + .setVideoThumbnailListener(getVideoThumbnailEventListener()) + .isAutoVideoPlay(false) + .isLoopAutoVideoPlay(false) + .isPageSyncAlbumCount(true) + .setRecordVideoMaxSecond(10) + .setCustomLoadingListener(getCustomLoadingListener()) + .setQueryFilterListener(new OnQueryFilterListener() { + @Override + public boolean onFilter(LocalMedia media) { + return false; + } + }) + .setSelectionMode(SelectModeConfig.MULTIPLE) + .setLanguage(language) + .setOutputCameraDir(getSandboxCameraOutputPath()) + .setQuerySandboxDir(getSandboxCameraOutputPath()) + .isDisplayTimeAxis(true) + .isOnlyObtainSandboxDir(false) + .isPageStrategy(true) + .isOriginalControl(false) + .isDisplayCamera(true) + .isOpenClickSound(false) + .setSkipCropMimeType(getNotSupportCrop()) + .isFastSlidingSelect(true) + //.setOutputCameraImageFileName("luck.jpeg") + //.setOutputCameraVideoFileName("luck.mp4") + .isWithSelectVideoImage(true) + .isPreviewFullScreenMode(true) + .isVideoPauseResumePlay(false) + .isPreviewZoomEffect(true) + .isPreviewImage(true) + .isPreviewVideo(true) + .isPreviewAudio(true) + .setGridItemSelectAnimListener(null) + //.setQueryOnlyMimeType(PictureMimeType.ofGIF()) + .isMaxSelectEnabledMask(true) + .setMaxSelectNum(maxSelectNum) + .setMaxVideoSelectNum(maxSelectNum) + .setRecyclerAnimationMode(animationMode) + .isGif(false) + .setSelectedData(mAdapter.getData()); + forSelectResult(selectionModel); + } + + private long exitTime = 0; + + + // 在sd卡中创建一保存图片(原图和缩略图共用的)文件夹 + public File createFileIfNeed(String dirPath, String fileName) throws IOException { + File fileDir = new File(dirPath); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + File file = new File(fileDir, fileName); + if (!file.exists()) { + file.createNewFile(); + } + return file; + } + + // 在app外置存储私有文件目录中删除文件 + public void deleteFileIfNeed(String dirPath, String fileName) { + File fileDir = new File(dirPath); + if (fileDir.exists()) { + File file = new File(fileDir, fileName); + if (file.exists()) { + file.delete(); + } + } + } + + /** + * 通过 通过SAF访问照片拿到Uri,然后保存到APP内置的外部存储 + * + * @param uri + * @return + */ + private Uri uriToExternalFile(Uri uri, String filename) { + //this.deleteFileIfNeed(path, filename); + InputStream fis = null; + OutputStream out = null; + try { + String applicationId = App.getApplicationId(FanWeiActivity.this); + File fos = this.createFileIfNeed(path, filename); + Uri uriOut = FileProvider.getUriForFile(FanWeiActivity.this, applicationId + ".fileprovider", fos); + out = getContentResolver().openOutputStream(uriOut); + fis = getContentResolver().openInputStream(uri); + IoUtil.copy(fis, out); + return FileProvider.getUriForFile(FanWeiActivity.this, applicationId + ".fileprovider", fos); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (out != null) { + try { + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return null; + } + + /** + * 申请权限回调 + * + * @param requestCode + * @param permissions + * @param grantResults + */ + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (requestCode == STXC) { + this.choosePhoto(STXC); + } + } + + /** + * 缩图选择像册 + * + * @param flag + */ + private void choosePhoto(int flag) { + + stFileName = UUID.randomUUID() + ".jpg"; + this.deleteFileIfNeed(path, stFileName); + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + Intent fjtxc = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); + launcherResultTakePhoto.launch(fjtxc); + //startActivityForResult(fjtxc, flag); + } else { + // Android 10以上 通过SAF访问图片 + Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); + intent.addCategory(Intent.CATEGORY_OPENABLE); + //选择图片 + intent.setType("image/jpeg"); + launcherResultTakePhoto.launch(intent); + //startActivityForResult(intent, flag); + } + } + + /** + * 缩图 拍照或者选择像片成功后发起截图 + * + * @param uri + * @param fileName + * @param flags + * @throws IOException + */ + private void startPhotoZoom(Uri uri, String fileName, int flags) throws IOException { + String applicationId = App.getApplicationId(FanWeiActivity.this); + File CropPhoto = this.createFileIfNeed(path, fileName); + uriTakePicOutputSt = FileProvider.getUriForFile(FanWeiActivity.this, applicationId + ".fileprovider", CropPhoto); + + Intent intent = new Intent("com.android.camera.action.CROP"); + intent.setDataAndType(uri, "image/*"); + + //添加这一句表示对目标应用临时授权该Uri所代表的文件 + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + + intent.putExtra("crop", "true"); + //intent.putExtra("scale", true); + //intent.putExtra("aspectX", 1); + //intent.putExtra("aspectY", 1); + //输出的宽高 + //intent.putExtra("outputX", 300); + //intent.putExtra("outputY", 300); + intent.putExtra("return-data", false); + intent.putExtra(MediaStore.EXTRA_OUTPUT, uriTakePicOutputSt); + intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); + intent.putExtra("noFaceDetection", true); // no face detection + //startActivityForResult(intent, flags); + launcherResultTakePhotoZoom.launch(intent); + } + } \ No newline at end of file diff --git a/app/src/main/java/com/rehome/dywoa/ui/activity/HomeActivity.kt b/app/src/main/java/com/rehome/dywoa/ui/activity/HomeActivity.kt index 9f79365..28c79ff 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/activity/HomeActivity.kt +++ b/app/src/main/java/com/rehome/dywoa/ui/activity/HomeActivity.kt @@ -775,7 +775,11 @@ class HomeActivity : BaseActivityOaToolbarViewBinding() { val url = Contans.IP + Contans.XSCB_PLAN_UPLOAD_TASK_ONE showLog(url) val request = NoHttp.createStringRequest(url, RequestMethod.POST) + showLog("----------itemXSJJHDataBean--------->>>") + showLog(GsonUtils.GsonString(itemXSJJHDataBean)) val json = getJsonUploadSingleTaskXj(itemXSJJHDataBean) + showLog("----------json--------->>>") + showLog(json) request.setDefineRequestBodyForJson(json) if (App.getInstance().userInfo != null && App.getInstance().userInfo.token != null) { diff --git a/app/src/main/java/com/rehome/dywoa/ui/activity/LoginActivity.kt b/app/src/main/java/com/rehome/dywoa/ui/activity/LoginActivity.kt index 1572aee..394b3e5 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/activity/LoginActivity.kt +++ b/app/src/main/java/com/rehome/dywoa/ui/activity/LoginActivity.kt @@ -37,7 +37,6 @@ import com.rehome.dywoa.bean.LoginCommitBean import com.rehome.dywoa.bean.UserInfoBean import com.rehome.dywoa.databinding.ActivityLoginBinding import com.rehome.dywoa.ui.activity.vpn.PrimaryAuthActivity -import com.rehome.dywoa.utils.DataPassUtils import com.rehome.dywoa.utils.GsonUtils import com.rehome.dywoa.utils.HttpListener import com.rehome.dywoa.utils.NoProgresshttpUtils @@ -46,7 +45,6 @@ import com.rehome.dywoa.utils.RSAUtils import com.rehome.dywoa.utils.SPUtils import com.rehome.dywoa.utils.StatusBarUtil import com.rehome.dywoa.utils.UiUtlis -import com.rehome.dywoa.weiget.toastviewbymyself import com.sangfor.sdk.SFUemSDK import com.yolanda.nohttp.NoHttp import com.yolanda.nohttp.RequestMethod @@ -219,7 +217,7 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { // binding.etUsername.setText("RH00002") // binding.etPassword.setText("A000000a.") -// binding.etUsername.setText("RH00002") +// binding.etUsername.setText("RH00003") // binding.etPassword.setText("A000000a.") @@ -227,6 +225,11 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { // binding.etUsername.setText("CY00005") // binding.etPassword.setText("A000000a.") +// binding.etUsername.setText("CY00001") +// binding.etPassword.setText("A000000a.") + +// binding.etUsername.setText("CY0001") +// binding.etPassword.setText("A000000a.") @@ -273,11 +276,11 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { // } if (TextUtils.isEmpty(binding.etUsername.text.toString())) { - toastviewbymyself.makeText(context, "用户名不能为空", Toast.LENGTH_LONG).show() + showToast("用户名不能为空") return@OnClickListener } if (TextUtils.isEmpty(binding.etPassword.text.toString())) { - toastviewbymyself.makeText(context, "密码不能为空", Toast.LENGTH_LONG).show() + showToast("密码不能为空") return@OnClickListener } @@ -302,6 +305,11 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { checkConnectServerToUpdate(); } + override fun onDestroy() { + super.onDestroy() + showLog("LoginActivity onDestroy") + } + private fun startAutoTicket() { /** * 这里是自动免密认证接口,返回true表示认证成功,此时用户就可以进行资源访问了, @@ -419,11 +427,11 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { private fun checkInput(): Boolean{ if (TextUtils.isEmpty(binding.etUsername.text.toString())) { - toastviewbymyself.makeText(context, "用户名不能为空", Toast.LENGTH_LONG).show() + showToast("用户名不能为空") return false } if (TextUtils.isEmpty(binding.etPassword.text.toString())) { - toastviewbymyself.makeText(context, "密码不能为空", Toast.LENGTH_LONG).show() + showToast("密码不能为空") return false } return true; @@ -608,9 +616,6 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { override fun onFailed(what: Int, response: Response?) { showLog("connect server onFailed") - //离线登录 - offLineLogin() -// showToast("无法连接到服务器,请检查网络环境") } }) } @@ -623,7 +628,7 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { //val json: String = "Ms97MbjVaypr+CF04BTQ+Y7hbYp+orLZbXM2u+I+PZKSPSSaqR1dcuM3tsig3UpJ7s2qEw5DsJcVd0t4eJM79ABUFWW/0Nplhx37+6jR2YVaSJgA30L0O2FbuyG7SOjP0qfISNaN1L8eC3a7W5oFPpHxkZdxUf5sxJIQHA2c6lCI+Mo/BUgU1MgTIjM3puiWx99mvxOyl9k2oLZUjcjMOygzNUYYD21SQYQ6dtvdVz3iAtqeJ+0EVCtScPXePG/CH/s0Ti/VS54/KSrlRVfdn5s2pHqw5fd2BZX+ZGtIWTGpWb+Wt1ZtrPXPdv/r1Zx84Zcw0EqKicieeuYpfUH+eg=="; val url = Contans.IP + Contans.APPLOGINRSA - //val url = "http://192.168.2.150:8601/" + Contans.APPLOGINRSA + //val url = "http://192.168.2.115:8601/" + Contans.APPLOGINRSA val request = NoHttp.createStringRequest(url, RequestMethod.POST) @@ -744,11 +749,7 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { } } else { showLog(userInfo.statusMsg) - toastviewbymyself.makeText( - context, - userInfo.statusMsg, - Toast.LENGTH_LONG - ).show() + showToast(userInfo.statusMsg) } } else { showToast("服务器请求失败") @@ -926,11 +927,7 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { } } else { Log.i("login", userInfo.statusMsg) - toastviewbymyself.makeText( - context, - userInfo.statusMsg, - Toast.LENGTH_LONG - ).show() + showToast(userInfo.statusMsg) } } } @@ -995,11 +992,7 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { } } else { Log.i("login", userInfo.statusMsg) - toastviewbymyself.makeText( - context, - userInfo.statusMsg, - Toast.LENGTH_LONG - ).show() + showToast(userInfo.statusMsg) } } } diff --git a/app/src/main/java/com/rehome/dywoa/ui/activity/YhscpActivity.java b/app/src/main/java/com/rehome/dywoa/ui/activity/YhscpActivity.java index b2eefe0..064314c 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/activity/YhscpActivity.java +++ b/app/src/main/java/com/rehome/dywoa/ui/activity/YhscpActivity.java @@ -182,7 +182,7 @@ public class YhscpActivity extends BaseAgentWebActivity { private ProgressDialog progressDialog; - private String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "com.rehome.zhdcoa/images"; + private String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "com.rehome.dywoa/images"; private String stFileName; //private String filePath; diff --git a/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/SxgzActivity.java b/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/SxgzActivity.java index 4cb63ad..7c17086 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/SxgzActivity.java +++ b/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/SxgzActivity.java @@ -210,7 +210,6 @@ public class SxgzActivity extends BaseActivity { SPUtils.put(context,Contans.SP.QJ_FIRST_JIZHU_STATUS_SELECT,firstJiZhuStatus); SPUtils.put(context,Contans.SP.QJ_SECOND_JIZHU_STATUS_SELECT,secondJiZhuStatus); if(xsjjhxzDataBeanList!=null&&xsjjhxzDataBeanList.size()>0){ - ContentValues values = new ContentValues(); if("开机".equals(firstJiZhuStatus)){ values.put("firstAssembling", "1"); @@ -367,6 +366,8 @@ public class SxgzActivity extends BaseActivity { @Override public void confirm(String firstJiZhuStatus, String secondJiZhuStatus) { + showLog("-------confirm----->"); + showLog(Contans.SP.QJ_JIZHU_STATUS_SELECT + nowStr); SPUtils.put(context,Contans.SP.QJ_FIRST_JIZHU_STATUS_SELECT,firstJiZhuStatus); SPUtils.put(context,Contans.SP.QJ_SECOND_JIZHU_STATUS_SELECT,secondJiZhuStatus); SPUtils.put(context,Contans.SP.QJ_JIZHU_STATUS_SELECT + nowStr,nowStr); @@ -587,8 +588,8 @@ public class SxgzActivity extends BaseActivity { // result = "048B94EAC21B91"; - //result = "041894EAC21B91"; -// result = "044092EAC21B90"; +// result = "041894EAC21B91"; +// result = "04261EEA211991"; if(TextUtils.isEmpty(result)){ return; diff --git a/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/XzxsjhFragment.java b/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/XzxsjhFragment.java index 2616b80..9f457c1 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/XzxsjhFragment.java +++ b/app/src/main/java/com/rehome/dywoa/ui/activity/sbxj/XzxsjhFragment.java @@ -380,7 +380,7 @@ public class XzxsjhFragment extends BaseFragment { info.setAction("XSCB_ ZXJHD_GET"); info.setZxid(zxid); info.setJhmc(jhmc); - //info.setGh(username); + info.setGh(username); String json = GsonUtils.GsonString(info); showLog(json); return json; diff --git a/app/src/main/java/com/rehome/dywoa/ui/fragment/HomeFragment.java b/app/src/main/java/com/rehome/dywoa/ui/fragment/HomeFragment.java index a471e79..260bc55 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/fragment/HomeFragment.java +++ b/app/src/main/java/com/rehome/dywoa/ui/fragment/HomeFragment.java @@ -397,7 +397,8 @@ public class HomeFragment extends BaseFragment { Intent intentYhTake = new Intent(mActivity, YhscpActivity.class); intentYhTake.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); String typeYhscp = "隐患随手拍"; - String urlYhscp = "https://mis.dywzhny.com.cn/mobile/ebdapp/view/995394113075568642/search/995404747431370874-8922672992955770021"; + //String urlYhscp = "https://mis.dywzhny.com.cn/mobile/ebdapp/view/995394113075568642/search/995404747431370874-8922672992955770021"; + String urlYhscp = "https://mis.dywzhny.com.cn/mobile/workflow/flowpage/create/995422124768387075?fieldAssignKeys=&noConvertPath=1"; intentYhTake.putExtra("type",typeYhscp); intentYhTake.putExtra("urlLog",urlYhscp); startActivity(intentYhTake); @@ -643,7 +644,9 @@ public class HomeFragment extends BaseFragment { String gh = data.getGh(); String faceType = data.getFaceType(); String msg = faceRecognitionResult.getMsg(); - ConfirmFaceDialog confirmDialog = new ConfirmFaceDialog(context, "人脸识别成功",msg,name,gh,faceType,faceTempPath,new ConfirmFaceDialog.ConfirmDialogFaceListener() { + String contractor = data.getContractor(); + List skills = data.getSkills(); + ConfirmFaceDialog confirmDialog = new ConfirmFaceDialog(context, "人脸识别成功",msg,name,gh,faceType,contractor,skills,faceTempPath,new ConfirmFaceDialog.ConfirmDialogFaceListener() { @Override public void confirm() { @@ -660,7 +663,7 @@ public class HomeFragment extends BaseFragment { }else if("身份证号码为空".equals(msg)){ msg="人脸库没有检索到当前人脸信息,人脸对比结果失败"; } - ConfirmFaceDialog confirmDialog = new ConfirmFaceDialog(context, "人脸识别失败",msg,null,null,null,null, new ConfirmFaceDialog.ConfirmDialogFaceListener() { + ConfirmFaceDialog confirmDialog = new ConfirmFaceDialog(context, "人脸识别失败",msg,null,null,null,null,null,null, new ConfirmFaceDialog.ConfirmDialogFaceListener() { @Override public void confirm() { diff --git a/app/src/main/java/com/rehome/dywoa/weiget/ConfirmFaceDialog.java b/app/src/main/java/com/rehome/dywoa/weiget/ConfirmFaceDialog.java index 24d5538..b549228 100644 --- a/app/src/main/java/com/rehome/dywoa/weiget/ConfirmFaceDialog.java +++ b/app/src/main/java/com/rehome/dywoa/weiget/ConfirmFaceDialog.java @@ -22,6 +22,8 @@ import com.rehome.dywoa.databinding.DialogConfirmFaceBinding; import com.rehome.dywoa.ui.activity.FaceRecognitionAppActivity; import com.rehome.dywoa.utils.BitmapUtil; +import java.util.List; + /** * Create By HuangWenFei * 创建日期:2023-01-12 11:55 @@ -43,7 +45,7 @@ public class ConfirmFaceDialog extends Dialog { setContentView(mView); Window window = getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); - lp.width = (getScreenWidth(context)) * 2 / 3; + lp.width = (getScreenWidth(context)) * 4 / 5; window.setGravity(Gravity.CENTER); setTvMsg(msg); binding.bottomBtnView.dialogCommit.setOnClickListener(new View.OnClickListener() { @@ -58,7 +60,7 @@ public class ConfirmFaceDialog extends Dialog { } - public ConfirmFaceDialog(@NonNull Context context, String titleName, String msg, String name, String gh, String faceType, String facePath,ConfirmDialogFaceListener listener) { + public ConfirmFaceDialog(@NonNull Context context, String titleName, String msg, String name, String gh, String faceType, String contractor, List skills, String facePath,ConfirmDialogFaceListener listener) { super(context); this.context=context; this.listener = listener; @@ -71,7 +73,7 @@ public class ConfirmFaceDialog extends Dialog { if (!TextUtils.isEmpty(titleName)) { if("人脸识别成功".equals(titleName)){ - binding.tvMsg.setVisibility(View.GONE); + binding.llMsg.setVisibility(View.GONE); Bitmap rectBitmap = BitmapUtil.readBitmapFromFile(facePath); Drawable drawable = bitmapToDrawable(context,rectBitmap); binding.ivPhoto.setImageDrawable(drawable); @@ -79,28 +81,49 @@ public class ConfirmFaceDialog extends Dialog { binding.tvName.setVisibility(View.VISIBLE); binding.tvGh.setVisibility(View.VISIBLE); binding.tvFaceType.setVisibility(View.VISIBLE); + if(!TextUtils.isEmpty(name)){ - binding.tvName.setText("姓名:"+name); + binding.tvName.setText(name); }else{ - binding.tvName.setText("姓名:"); + binding.tvName.setText(""); } if(!TextUtils.isEmpty(gh)){ - binding.tvGh.setText("工号:"+gh); + binding.tvGh.setText(gh); }else{ - binding.tvGh.setText("工号:"); + binding.tvGh.setText(""); } if(!TextUtils.isEmpty(faceType)){ - binding.tvFaceType.setText("人员类型:"+faceType); + binding.tvFaceType.setText(faceType); + if("承包商".equals(faceType)){ + binding.llCompany.setVisibility(View.VISIBLE); + binding.llTzzyz.setVisibility(View.VISIBLE); + }else{ + binding.llCompany.setVisibility(View.GONE); + binding.llTzzyz.setVisibility(View.GONE); + } + }else{ + binding.tvFaceType.setText(""); + } + if(!TextUtils.isEmpty(contractor)){ + binding.tvCompany.setText(contractor); + }else{ + binding.tvCompany.setText(""); + } + if(skills!=null&&skills.size()>0){ + String tzzyz = String.join(",", skills); + binding.tvTzzyz.setText(tzzyz); }else{ - binding.tvFaceType.setText("人员类型:"); + binding.tvTzzyz.setText(""); } }else{ binding.ivPhoto.setVisibility(View.GONE); - binding.tvName.setVisibility(View.GONE); - binding.tvGh.setVisibility(View.GONE); - binding.tvFaceType.setVisibility(View.GONE); - binding.tvMsg.setVisibility(View.VISIBLE); - binding.tvMsg.setText("错误提示:"+msg); + binding.llName.setVisibility(View.GONE); + binding.llGh.setVisibility(View.GONE); + binding.llFaceType.setVisibility(View.GONE); + binding.llCompany.setVisibility(View.GONE); + binding.llTzzyz.setVisibility(View.GONE); + binding.llMsg.setVisibility(View.VISIBLE); + binding.tvMsg.setText(msg); } } } diff --git a/app/src/main/res/layout/activity_face_recognition_app.xml b/app/src/main/res/layout/activity_face_recognition_app.xml index 2117779..7ac7f54 100644 --- a/app/src/main/res/layout/activity_face_recognition_app.xml +++ b/app/src/main/res/layout/activity_face_recognition_app.xml @@ -30,7 +30,7 @@ + + + + + + + + + + + + - + + + + - + + + + - + + + + - + + + + + android:minWidth="200dp" + android:layout_gravity="center_horizontal" + android:gravity="center_vertical" + android:layout_marginTop="10dp" + android:orientation="horizontal"> + + + + + + + +