diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 9960eca..e9725d7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -224,6 +224,10 @@
android:name=".ui.activity.YhscpActivity"
android:exported="false"
android:screenOrientation="portrait" />
+
filePathList = new ArrayList<>();
+ //private String duration;
+ private ArrayList videoList = new ArrayList<>();
+
+
+ private GridImageAdapter mAdapter;
+ private int maxSelectNum = 10;
+ 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;
+ //人脸识别
+ ActivityResultLauncher launcherResultFaceRecognition;
+ //二维码扫描
+ ActivityResultLauncher launcherResultQRCode;
+
+ 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;
+
+ private String urlToken = "api/app/login/singleLogin?account=";
+ private String startUrl;
+
+
+ String type;
+ String urlLog;
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_every_date_risk_controller_list);
+
+ 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");
+ urlLog = getIntent().getStringExtra("urlLog");
+ if(TextUtils.isEmpty(type)){
+ type = "";
+ }
+
+ mToolbar = this.findViewById(R.id.toolbar);
+ mToolbar.setTitleTextColor(Color.WHITE);
+ mToolbar.setTitle("");
+ mToolbar.setNavigationIcon(R.drawable.ac_back_icon);
+ mTitleTextView = this.findViewById(R.id.toolbar_title);
+ mTitleTextView.setText(type);
+ this.setSupportActionBar(mToolbar);
+ if (getSupportActionBar() != null) {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ }
+ mToolbar.setNavigationOnClickListener(v -> EveryDateRiskControllerListActivity.this.finish());
+
+
+ //支持缩放
+ mAgentWeb.getWebCreator().getWebView().getSettings().setBuiltInZoomControls(true);
+ mAgentWeb.getWebCreator().getWebView().getSettings().setDisplayZoomControls(false);
+ mAgentWeb.getWebCreator().getWebView().getSettings().setSupportZoom(true);
+
+ mAgentWeb.getWebCreator().getWebView().setWebChromeClient(new MyWebChromeClient());
+// mAgentWeb.(getWebChromeClient())
+
+ //初始化获取照片和视频
+ initTakePhotoAndVideo();
+
+ checkServerConnectStatus();
+
+ }
+
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ }
+
+
+ //检查服务器连接状态
+ private void checkServerConnectStatus() {
+ Map param = new HashMap<>();
+ param.put("login","dywoa");
+ String json = GsonUtils.GsonString(param);
+ String url = Contans.IP + Contans.check_server_connect;
+ showLog(url);
+ showLog(json);
+ Request request = NoHttp.createStringRequest(
+ url,
+ RequestMethod.POST
+ );
+ request.setDefineRequestBodyForJson(json);
+ NoProgresshttpUtils.getInstance().add(this, 0, request, new HttpListener() {
+
+ @Override
+ public void onSucceed(int what, Response response) {
+ String result = response.get();
+ showLog("-----onSucceed----");
+ showLog(result);
+ if(result.equals("1")){
+ showLog("connect server success");
+ //可以连接到服务器,请求数据
+ getSingleLoginToken();
+ }else{
+ showToast("无法连接到服务器,请检查网络环境");
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ showLog("connect server onFailed");
+ showToast("无法连接到服务器,请检查网络环境");
+ }
+ });
+ }
+
+
+ private void getSingleLoginToken() {
+ String url = Contans.IP + urlToken + App.getInstance().getUserInfo().getManid();
+
+ //String url = Contans.IP + urlToken + "803011";
+
+
+ //url = Contans.IP + urlToken + "280846";
+
+
+ Request request = NoHttp.createStringRequest(url, RequestMethod.GET);
+ showLog(url);
+
+// SSLSocketFactory socketFactory = NohttpUtils.getSisSSLSocketFactory(WaitForToDoActivity.this);
+// if (socketFactory != null) {
+// request.setSSLSocketFactory(socketFactory);
+// request.setHostnameVerifier(new HostnameVerifier() {
+// @Override
+// public boolean verify(String s, SSLSession sslSession) {
+// return true;
+// }
+// });
+// }
+
+ NohttpUtils.getInstance().add(this,1,request,new HttpListener(){
+ @Override
+ public void onSucceed(int what, Response response) throws ParseException {
+
+ String jsonResult = response.get();
+ showLog("-----login------");
+ showLog(jsonResult);
+
+ String jsonDecode = RSAUtils.decryptBASE64StrClient(jsonResult);
+ if (TextUtils.isEmpty(jsonDecode)) {
+ showToast(UiUtlis.getString(EveryDateRiskControllerListActivity.this, R.string.data_error));
+ } else {
+ 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())){
+ loadSisPage(loginResult.getToken());
+ }
+ }else{
+ showToast(loginResult.getErrmsg());
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onFailed(int what, Response response) {
+ showLog("getSisToken onFailed");
+ }
+ }, true, true, "请稍候...");
+ }
+
+ private void loadSisPage(String token) {
+ try {
+ var tempUrl = "https://mis.dywzhny.com.cn/papi/open/singleSignon?oauthType=singlesign&singleToken="+ token +"&redirect_uri=";
+ String encodeUrl = URLEncoder.encode(urlLog,"UTF-8");
+ startUrl = tempUrl + encodeUrl;
+ showLog(startUrl);
+ this.mAgentWeb.getUrlLoader().loadUrl(startUrl);
+ //this.mAgentWeb.getWebCreator().getWebView()
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ @NonNull
+ @Override
+ protected ViewGroup getAgentWebParent() {
+ return (ViewGroup) this.findViewById(R.id.container);
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event)) {
+ return true;
+ }
+
+ return super.onKeyDown(keyCode, event);
+ }
+
+ @Override
+ protected int getIndicatorColor() {
+ return Color.parseColor("#ff0000");
+ }
+
+ @Override
+ protected void setTitle(WebView view, String title) {
+ super.setTitle(view, title);
+ if (!TextUtils.isEmpty(title)) {
+ if (mTitleTextView != null) {
+ mTitleTextView.setText(type);
+ }
+ }
+ }
+
+ @Override
+ protected int getIndicatorHeight() {
+ return 3;
+ }
+
+ @Nullable
+ @Override
+ protected String getUrl() {
+ return null;
+ //return "https://www.baidu.com/";
+ }
+
+
+ private void showLog(String logText) {
+ if (isApkInDebug(EveryDateRiskControllerListActivity.this)) {
+ if (TextUtils.isEmpty(logText)) {
+ Log.i("app", "logText is null");
+ } else {
+ Log.i("app", logText);
+ }
+ }
+ }
+
+ /**
+ * 判断当前应用是否是debug状态
+ */
+
+ public static boolean isApkInDebug(Context context) {
+ try {
+ ApplicationInfo info = context.getApplicationInfo();
+ return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public void showToast(String msg) {
+ Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
+ }
+
+ public void showToast(int strId) {
+ 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(EveryDateRiskControllerListActivity.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(EveryDateRiskControllerListActivity.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(MainActivityJava.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(EveryDateRiskControllerListActivity.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);
+ }
+ });
+
+ }
+
+ /**
+ * 创建一个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("createSelectTypeActivityResultLauncher");
+ chooseMode = chooseModePhoto;
+ 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;
+ }
+ }
+ }
+ });
+ }
+
+ @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", "竖屏");
+ }
+ }
+
+ /**
+ * 清除图片磁盘缓存
+ */
+ 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();
+ for (LocalMedia media : result) {
+ if (media.getWidth() == 0 || media.getHeight() == 0) {
+ if (PictureMimeType.isHasImage(media.getMimeType())) {
+ MediaExtraInfo imageExtraInfo = MediaUtils.getImageSize(EveryDateRiskControllerListActivity.this, media.getPath());
+ media.setWidth(imageExtraInfo.getWidth());
+ media.setHeight(imageExtraInfo.getHeight());
+ } else if (PictureMimeType.isHasVideo(media.getMimeType())) {
+ MediaExtraInfo videoExtraInfo = MediaUtils.getVideoSize(EveryDateRiskControllerListActivity.this, media.getPath());
+ media.setWidth(videoExtraInfo.getWidth());
+ media.setHeight(videoExtraInfo.getHeight());
+ }
+ }
+ String filePath = media.getSandboxPath();
+ if(filePath!=null){
+ filePathList.add(filePath);
+ }
+ //videoFileName = media.getFileName();
+ //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) {
+
+ //Uri results = Uri.fromFile(new File(videoFilePath));
+ //Uri[] results = new Uri[]{Uri.parse(finalUriPath)};
+ //if (dataString != null) results = new Uri[]{Uri.parse(dataString)};
+ //Uri uri = Uri.fromFile(new File(videoFilePath));
+ ///Uri uri = FileProvider.getUriForFile(context, "com.rehome.dywoa.fileprovider", new File(videoFilePath));
+ //results[0] = uri;
+// File file = new File(videoFilePath);
+// Log.i(TAG, "文件大小: " + file.length());
+
+ 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]);
+
+ //(Uri[]) fileUriList.toArray();
+// 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 super Bitmap> 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(EveryDateRiskControllerListActivity.this, com.luck.picture.lib.R.color.ps_color_grey));
+ options.setToolbarColor(ContextCompat.getColor(EveryDateRiskControllerListActivity.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(EveryDateRiskControllerListActivity.this, com.luck.picture.lib.R.color.ps_color_white));
+ }
+ } else {
+ options.setStatusBarColor(ContextCompat.getColor(EveryDateRiskControllerListActivity.this, com.luck.picture.lib.R.color.ps_color_grey));
+ options.setToolbarColor(ContextCompat.getColor(EveryDateRiskControllerListActivity.this, com.luck.picture.lib.R.color.ps_color_grey));
+ options.setToolbarWidgetColor(ContextCompat.getColor(EveryDateRiskControllerListActivity.this, com.luck.picture.lib.R.color.ps_color_white));
+ }
+ return options;
+ }
+
+ /**
+ * 创建自定义输出目录
+ *
+ * @return
+ */
+ private String getSandboxPath() {
+ File externalFilesDir = EveryDateRiskControllerListActivity.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 super Bitmap> 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 "";
+ }
+
+ private void openSelectPhotoOrVideo() {
+ // 进入相册
+ PictureSelectionModel selectionModel = PictureSelector.create(EveryDateRiskControllerListActivity.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 class MyWebChromeClient extends android.webkit.WebChromeClient {
+ android.webkit.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));
+
+ chooseMode = chooseModePhoto;
+ mAdapter.getData().clear();
+ mAdapter.notifyDataSetChanged();
+ openSelectPhotoOrVideo();
+ 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;
+ }
+ }
+
+ // 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);
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/rehome/dywoa/ui/activity/FaceRecognitionAppActivity.java b/app/src/main/java/com/rehome/dywoa/ui/activity/FaceRecognitionAppActivity.java
index 9014d37..1e9e5ce 100644
--- a/app/src/main/java/com/rehome/dywoa/ui/activity/FaceRecognitionAppActivity.java
+++ b/app/src/main/java/com/rehome/dywoa/ui/activity/FaceRecognitionAppActivity.java
@@ -286,11 +286,14 @@ public class FaceRecognitionAppActivity extends BaseActivity {
mTextureView.setVisibility(View.GONE);
stopCamera();
+ Bitmap resizeImage=resizeImage(rectBitmap,480,640);
+// Bitmap resizeImage=resizeImage(rectBitmap,1080,1920);
+
String fileName = UUID.randomUUID().toString()+".jpeg";
String faceTempPath = path + File.separator + fileName;
showLog(faceTempPath);
- BitmapUtil.saveBitmap(faceTempPath,rectBitmap);
+ BitmapUtil.saveBitmap(faceTempPath,resizeImage);
File faceFile = new File(faceTempPath);
showLog(String.valueOf(faceFile.length()));
@@ -325,6 +328,19 @@ public class FaceRecognitionAppActivity extends BaseActivity {
return drawable;
}
+ public static Bitmap resizeImage(Bitmap originalImage, int targetWidth, int targetHeight) {
+ // 创建一个Matrix对象,用于包含缩放和平移的操作
+ Matrix matrix = new Matrix();
+ // 计算缩放比例
+ float scaleWidth = (float) targetWidth / originalImage.getWidth();
+ float scaleHeight = (float) targetHeight / originalImage.getHeight();
+ // 通过缩放比例来缩放图片
+ matrix.postScale(scaleWidth, scaleHeight);
+ // 创建新的Bitmap对象,其内容是原始图片的缩小版
+ Bitmap resizedImage = Bitmap.createBitmap(originalImage, 0, 0, originalImage.getWidth(), originalImage.getHeight(), matrix, true);
+ return resizedImage;
+ }
+
//Bitmap保存成文件
private void saveBitmapToFile(Bitmap bitmap) {
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 394b3e5..428c784 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
@@ -217,8 +217,8 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() {
// binding.etUsername.setText("RH00002")
// binding.etPassword.setText("A000000a.")
-// binding.etUsername.setText("RH00003")
-// binding.etPassword.setText("A000000a.")
+ binding.etUsername.setText("RH00003")
+ binding.etPassword.setText("A000000a.")
//重仪
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 260bc55..7579b12 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
@@ -37,6 +37,7 @@ import com.rehome.dywoa.bean.FwSingleLoginResult;
import com.rehome.dywoa.bean.GridItem;
import com.rehome.dywoa.bean.WaitForBean;
import com.rehome.dywoa.ui.activity.BiShowActivity;
+import com.rehome.dywoa.ui.activity.EveryDateRiskControllerListActivity;
import com.rehome.dywoa.ui.activity.FaceRecognitionActivity;
import com.rehome.dywoa.ui.activity.FaceRecognitionAppActivity;
import com.rehome.dywoa.ui.activity.FanWeiActivity;
@@ -403,12 +404,17 @@ public class HomeFragment extends BaseFragment {
intentYhTake.putExtra("urlLog",urlYhscp);
startActivity(intentYhTake);
break;
-// case 12:
-// TAG = GridViewDialog.TAG_AF;
-// break;
+ case 12:
+ Intent intentEveryDateRiskControllerList = new Intent(mActivity, EveryDateRiskControllerListActivity.class);
+ intentEveryDateRiskControllerList.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
+ String typeEveryDateRisk = "每日作业管控风险清单";
+ //String urlYhscp = "https://mis.dywzhny.com.cn/mobile/ebdapp/view/995394113075568642/search/995404747431370874-8922672992955770021";
+ String urlEveryDateRisk = "https://mis.dywzhny.com.cn/mobile/ebdapp/view/1082990228650598401/search/1082990559573188609-6523675387694155872";
+ intentEveryDateRiskControllerList.putExtra("type",typeEveryDateRisk);
+ intentEveryDateRiskControllerList.putExtra("urlLog",urlEveryDateRisk);
+ startActivity(intentEveryDateRiskControllerList);
+ break;
}
-// GridViewDialog dialog = new GridViewDialog(getContext(), TAG);
-// dialog.show();
}
});
}
@@ -464,9 +470,12 @@ public class HomeFragment extends BaseFragment {
// String[] titles = {"管控一体化","两票系统", "SIS系统", "机组参数","巡检","点检","运行日志","kks码查询","应急预案","用车","用印","BI"};
// int[] imgIds = {R.drawable.icon_runlog_home,R.drawable.icon_liangpiao, R.drawable.icon_sis_new, R.drawable.icon_gcjd_new,R.drawable.xjgz,R.drawable.icon_dianjian,R.drawable.icon_runlog_home,R.drawable.icon_kks,R.drawable.icon_yjya,R.drawable.icon_use_car,R.drawable.icon_use_seal,R.drawable.icon_bi};
- String[] titles = {"管控一体化","两票系统", "SIS系统", "机组参数","巡检","点检","kks码查询","应急预案","BI","高风险","人脸识别","隐患随手拍"};
- int[] imgIds = {R.drawable.icon_gkyth,R.drawable.icon_lpqt, R.drawable.icon_sis_new_first, R.drawable.icon_jzcs_new,R.drawable.icon_qj_new,R.drawable.icon_dj_new,
- R.drawable.icon_kks_search,R.drawable.icon_yjya,R.drawable.icon_bi,R.drawable.icon_high_risk,R.drawable.icon_face_re,R.drawable.icon_rinhuan_take};
+ String[] titles = {"管控一体化","两票系统", "SIS系统", "机组参数","巡检","点检","kks码查询","应急预案","BI","高风险","人脸识别","隐患随手拍","每日作业管控风险清单"};
+ int[] imgIds = {R.drawable.icon_gkyth,R.drawable.icon_lpqt, R.drawable.icon_sis_new_first,
+ R.drawable.icon_jzcs_new,R.drawable.icon_qj_new,R.drawable.icon_dj_new,
+ R.drawable.icon_kks_search,R.drawable.icon_yjya,R.drawable.icon_bi,
+ R.drawable.icon_high_risk,R.drawable.icon_face_re,R.drawable.icon_rinhuan_take,
+ R.drawable.icon_zyfx};
diff --git a/app/src/main/res/drawable-xhdpi/icon_zyfx.png b/app/src/main/res/drawable-xhdpi/icon_zyfx.png
new file mode 100644
index 0000000..1c6b798
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/icon_zyfx.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/icon_zyfx.png b/app/src/main/res/drawable-xxhdpi/icon_zyfx.png
new file mode 100644
index 0000000..808dd8a
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/icon_zyfx.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/icon_zyfx.png b/app/src/main/res/drawable-xxxhdpi/icon_zyfx.png
new file mode 100644
index 0000000..09894c7
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/icon_zyfx.png differ
diff --git a/app/src/main/res/layout/activity_every_date_risk_controller_list.xml b/app/src/main/res/layout/activity_every_date_risk_controller_list.xml
new file mode 100644
index 0000000..c4dd9e5
--- /dev/null
+++ b/app/src/main/res/layout/activity_every_date_risk_controller_list.xml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml
index 52732cf..0046d58 100644
--- a/app/src/main/res/layout/fragment_home.xml
+++ b/app/src/main/res/layout/fragment_home.xml
@@ -80,7 +80,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
- android:numColumns="3" />
+ android:numColumns="4" />
diff --git a/app/src/main/res/layout/item_grid.xml b/app/src/main/res/layout/item_grid.xml
index ef715d1..823ea7a 100644
--- a/app/src/main/res/layout/item_grid.xml
+++ b/app/src/main/res/layout/item_grid.xml
@@ -19,6 +19,7 @@
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
android:text="申请管理" />