diff --git a/app/build.gradle b/app/build.gradle index d4839de..2740867 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "com.rehome.dywoa" minSdk 24 targetSdk 35 - versionCode 19 - versionName "1.1.8" + versionCode 20 + versionName "1.1.9" multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" //每个应用拥有不同的authorities,防止相同的在同一个手机上无法同时安装 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4f61fc5..9960eca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -220,6 +220,10 @@ android:name=".ui.activity.HightRiskActivity" android:exported="false" android:screenOrientation="portrait" /> + 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - openFrontCamera(); + openBackCamera(); } else { //权限拒绝 Toast.makeText(this, "权限拒绝,无法开启摄像头,请手动设置开启APP访问摄像头权限", Toast.LENGTH_SHORT).show(); 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 df43c4a..9f79365 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 @@ -578,7 +578,7 @@ class HomeActivity : BaseActivityOaToolbarViewBinding() { apkUrl(downloadURL) apkName("智慧电厂.apk") smallIcon(R.mipmap.ic_launcher) - showNewerToast(true) + showNewerToast(false) apkVersionCode(versionCode.toInt()) apkVersionName(versionName) apkDescription(description) 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 ec3f945..1572aee 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 @@ -216,8 +216,8 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { //瑞洪 RH00002/王总 RH00002/chao工 RH00003/范红波 - binding.etUsername.setText("RH00002") - binding.etPassword.setText("A000000a.") +// binding.etUsername.setText("RH00002") +// binding.etPassword.setText("A000000a.") // binding.etUsername.setText("RH00002") // binding.etPassword.setText("A000000a.") @@ -538,7 +538,7 @@ class LoginActivity : BaseActivityOaToolbarViewBinding() { apkUrl(downloadURL) apkName("智慧电厂.apk") smallIcon(R.mipmap.ic_launcher) - showNewerToast(true) + showNewerToast(false) apkVersionCode(versionCode.toInt()) apkVersionName(versionName) apkDescription(description) 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 new file mode 100644 index 0000000..b2eefe0 --- /dev/null +++ b/app/src/main/java/com/rehome/dywoa/ui/activity/YhscpActivity.java @@ -0,0 +1,1544 @@ +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.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.constraintlayout.widget.ConstraintLayout; +import androidx.constraintlayout.widget.ConstraintSet; +import androidx.core.content.ContextCompat; +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.ProgressDialog; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.ApplicationInfo; +import android.content.res.Configuration; +import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +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.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.WebResourceRequest; +import android.webkit.WebView; +import android.widget.CheckBox; +import android.widget.ImageView; +import android.widget.LinearLayout; +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.just.agentweb.AgentWeb; +import com.just.agentweb.DefaultWebClient; +import com.just.agentweb.WebViewClient; +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.MainActivity; +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.bean.FwSingleLoginResult; +import com.rehome.dywoa.bean.SisTokenBeanData; +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.rehome.dywoa.weiget.WebLayout; +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.net.URLEncoder; +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 javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocketFactory; + +import top.zibin.luban.CompressionPredicate; +import top.zibin.luban.Luban; +import top.zibin.luban.OnNewCompressListener; +import top.zibin.luban.OnRenameListener; + +public class YhscpActivity 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; + + private MyObject myObject; + + + static int neetUpload = 0; + + + private ProgressDialog progressDialog; + + + private String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "com.rehome.zhdcoa/images"; + + private String stFileName; + //private String filePath; + private List 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_yhscp); + + 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 -> YhscpActivity.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(YhscpActivity.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(YhscpActivity.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(YhscpActivity.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(YhscpActivity.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(YhscpActivity.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(YhscpActivity.this, media.getPath()); + media.setWidth(imageExtraInfo.getWidth()); + media.setHeight(imageExtraInfo.getHeight()); + } else if (PictureMimeType.isHasVideo(media.getMimeType())) { + MediaExtraInfo videoExtraInfo = MediaUtils.getVideoSize(YhscpActivity.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 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(YhscpActivity.this, com.luck.picture.lib.R.color.ps_color_grey)); + options.setToolbarColor(ContextCompat.getColor(YhscpActivity.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(YhscpActivity.this, com.luck.picture.lib.R.color.ps_color_white)); + } + } else { + options.setStatusBarColor(ContextCompat.getColor(YhscpActivity.this, com.luck.picture.lib.R.color.ps_color_grey)); + options.setToolbarColor(ContextCompat.getColor(YhscpActivity.this, com.luck.picture.lib.R.color.ps_color_grey)); + options.setToolbarWidgetColor(ContextCompat.getColor(YhscpActivity.this, com.luck.picture.lib.R.color.ps_color_white)); + } + return options; + } + + /** + * 创建自定义输出目录 + * + * @return + */ + private String getSandboxPath() { + File externalFilesDir = YhscpActivity.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 ""; + } + + private void openSelectPhotoOrVideo() { + // 进入相册 + PictureSelectionModel selectionModel = PictureSelector.create(YhscpActivity.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/fragment/HomeFragment.java b/app/src/main/java/com/rehome/dywoa/ui/fragment/HomeFragment.java index 54783c5..a471e79 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 @@ -49,6 +49,7 @@ import com.rehome.dywoa.ui.activity.SisBaseActivity; import com.rehome.dywoa.ui.activity.UseCarActivity; import com.rehome.dywoa.ui.activity.UseSealActivity; import com.rehome.dywoa.ui.activity.WaitForToDoActivity; +import com.rehome.dywoa.ui.activity.YhscpActivity; import com.rehome.dywoa.ui.activity.YjyaActivity; import com.rehome.dywoa.ui.activity.sbxdjgl.SbxdjglActivity; import com.rehome.dywoa.ui.activity.sbxj.XscbglActivity; @@ -225,114 +226,6 @@ public class HomeFragment extends BaseFragment { initData(); } - /** - * 创建一个ActivityResultLauncher - * - * @return - */ - private ActivityResultLauncher createFaceRecognitionActivityResultLauncher() { - return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), - new ActivityResultCallback() { - @Override - public void onActivityResult(ActivityResult result) { - int resultCode = result.getResultCode(); - if (resultCode == RESULT_OK) { - Intent resultIntent = result.getData(); - //byte[] faceByte = resultIntent.getByteArrayExtra("FaceRecognition"); - String faceTempPath = resultIntent.getStringExtra("FaceRecognitionPicPath"); - File faceFile = new File(faceTempPath); - showLog(String.valueOf(faceFile.length())); - -// String fileName = UUID.randomUUID().toString()+".png"; -// File fileDir = new File(path); -// if(!fileDir.exists()){ -// fileDir.mkdir(); -// } -// -// String fileTempName = path + File.separator + fileName; -// showLog(fileTempName); - - try { -// FileOutputStream fileOutputStream = new FileOutputStream(fileTempName); -// IoUtil.write(fileOutputStream,true,faceByte); - - //File fileFaceUpToServer = new File(fileTempName); - //showLog(String.valueOf(fileFaceUpToServer.length())); - - //String url = "http://192.168.2.115:8601/"+Contans.FACE_RECOGNITION_APP_URL; - String url = Contans.IP+Contans.FACE_RECOGNITION_APP_URL; - Request request = NoHttp.createStringRequest(url, RequestMethod.POST); -// showLog(json); -// request.setDefineRequestBodyForJson(json); - request.add("face", faceFile); - - NohttpUtils.getInstance().add(mActivity,30,request,new HttpListener(){ - @Override - public void onSucceed(int what, Response response) throws ParseException { - - String jsonResult = response.get(); - showLog("-----face------"); - showLog(jsonResult); - FaceRecognitionResult faceRecognitionResult = GsonUtils.GsonToBean(jsonResult,FaceRecognitionResult.class); - if(faceRecognitionResult!=null){ - if(faceRecognitionResult.getState()==1){ - if(faceRecognitionResult.getData()!=null){ - FaceRecognitionResult.Data data = faceRecognitionResult.getData(); - String name = data.getName(); - 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() { - @Override - public void confirm() { - - } - }); - confirmDialog.setTvTitle("人脸识别成功"); - confirmDialog.setCancelable(false); - confirmDialog.show(); - } - }else if(faceRecognitionResult.getState()==0){ - String msg = faceRecognitionResult.getMsg(); - if(TextUtils.isEmpty(msg)){ - msg="超脑连接异常"; - }else if("身份证号码为空".equals(msg)){ - msg="人脸库没有检索到当前人脸信息,人脸对比结果失败"; - } - ConfirmFaceDialog confirmDialog = new ConfirmFaceDialog(context, "人脸识别失败",msg,null,null,null,null, new ConfirmFaceDialog.ConfirmDialogFaceListener() { - @Override - public void confirm() { - - } - }); - confirmDialog.setTvTitle("人脸识别失败"); - confirmDialog.setCancelable(false); - confirmDialog.show(); - -// if(TextUtils.isEmpty(faceRecognitionResult.getMsg())){ -// showToast("人脸识别失败"); -// }else{ -// showToast(faceRecognitionResult.getMsg()); -// } - } - }else { - showToast("数据异常"); - } - } - - @Override - public void onFailed(int what, Response response) { - showLog("getSisToken onFailed"); - } - }, true, true, "人脸识别中,请稍候..."); - - } catch (Exception e) { - e.printStackTrace(); - } - } - } - }); - } private void setAdapter() { // String[] results = App.getInstance().getUserInfo().getPermissionsResult().split(";"); @@ -501,12 +394,12 @@ public class HomeFragment extends BaseFragment { checkFaceServerConnectStatus(); break; case 11: - Intent intentYhTake = new Intent(mActivity, HightRiskActivity.class); + Intent intentYhTake = new Intent(mActivity, YhscpActivity.class); intentYhTake.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); -// String typeHightRisk = "高风险"; -// String urlWHightRisk = "https://mis.dywzhny.com.cn/mobile/ebdapp/view/998396522831962120/page/1069629959971758112-8233268850081530012"; -// intentYhTake.putExtra("type",typeHightRisk); -// intentYhTake.putExtra("urlLog",urlWHightRisk); + String typeYhscp = "隐患随手拍"; + String urlYhscp = "https://mis.dywzhny.com.cn/mobile/ebdapp/view/995394113075568642/search/995404747431370874-8922672992955770021"; + intentYhTake.putExtra("type",typeYhscp); + intentYhTake.putExtra("urlLog",urlYhscp); startActivity(intentYhTake); break; // case 12: @@ -693,6 +586,116 @@ public class HomeFragment extends BaseFragment { }); } + /** + * 创建一个ActivityResultLauncher + * + * @return + */ + private ActivityResultLauncher createFaceRecognitionActivityResultLauncher() { + return registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), + new ActivityResultCallback() { + @Override + public void onActivityResult(ActivityResult result) { + int resultCode = result.getResultCode(); + if (resultCode == RESULT_OK) { + Intent resultIntent = result.getData(); + //byte[] faceByte = resultIntent.getByteArrayExtra("FaceRecognition"); + String faceTempPath = resultIntent.getStringExtra("FaceRecognitionPicPath"); + File faceFile = new File(faceTempPath); + showLog(String.valueOf(faceFile.length())); + +// String fileName = UUID.randomUUID().toString()+".png"; +// File fileDir = new File(path); +// if(!fileDir.exists()){ +// fileDir.mkdir(); +// } +// +// String fileTempName = path + File.separator + fileName; +// showLog(fileTempName); + + try { +// FileOutputStream fileOutputStream = new FileOutputStream(fileTempName); +// IoUtil.write(fileOutputStream,true,faceByte); + + //File fileFaceUpToServer = new File(fileTempName); + //showLog(String.valueOf(fileFaceUpToServer.length())); + + //String url = "http://192.168.2.115:8601/"+Contans.FACE_RECOGNITION_APP_URL; + String url = Contans.IP+Contans.FACE_RECOGNITION_APP_URL; + Request request = NoHttp.createStringRequest(url, RequestMethod.POST); +// showLog(json); +// request.setDefineRequestBodyForJson(json); + request.add("face", faceFile); + + NohttpUtils.getInstance().add(mActivity,30,request,new HttpListener(){ + @Override + public void onSucceed(int what, Response response) throws ParseException { + + String jsonResult = response.get(); + showLog("-----face------"); + showLog(jsonResult); + FaceRecognitionResult faceRecognitionResult = GsonUtils.GsonToBean(jsonResult,FaceRecognitionResult.class); + if(faceRecognitionResult!=null){ + if(faceRecognitionResult.getState()==1){ + if(faceRecognitionResult.getData()!=null){ + FaceRecognitionResult.Data data = faceRecognitionResult.getData(); + String name = data.getName(); + 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() { + @Override + public void confirm() { + + } + }); + confirmDialog.setTvTitle("人脸识别成功"); + confirmDialog.setCancelable(false); + confirmDialog.show(); + } + }else if(faceRecognitionResult.getState()==0){ + String msg = faceRecognitionResult.getMsg(); + if(TextUtils.isEmpty(msg)){ + msg="超脑连接异常"; + }else if("身份证号码为空".equals(msg)){ + msg="人脸库没有检索到当前人脸信息,人脸对比结果失败"; + } + ConfirmFaceDialog confirmDialog = new ConfirmFaceDialog(context, "人脸识别失败",msg,null,null,null,null, new ConfirmFaceDialog.ConfirmDialogFaceListener() { + @Override + public void confirm() { + + } + }); + confirmDialog.setTvTitle("人脸识别失败"); + confirmDialog.setCancelable(false); + confirmDialog.show(); + +// if(TextUtils.isEmpty(faceRecognitionResult.getMsg())){ +// showToast("人脸识别失败"); +// }else{ +// showToast(faceRecognitionResult.getMsg()); +// } + } + }else { + showToast("数据异常"); + } + } + + @Override + public void onFailed(int what, Response response) { + showLog("getSisToken onFailed"); + } + }, true, true, "人脸识别中,请稍候..."); + + } catch (Exception e) { + e.printStackTrace(); + } + } + } + }); + } + + //更新待办 public void updateWaitForToDo() { getWaitForToDo(); diff --git a/app/src/main/java/com/rehome/dywoa/ui/fragment/MineFragment.java b/app/src/main/java/com/rehome/dywoa/ui/fragment/MineFragment.java index 1411940..a28dac5 100644 --- a/app/src/main/java/com/rehome/dywoa/ui/fragment/MineFragment.java +++ b/app/src/main/java/com/rehome/dywoa/ui/fragment/MineFragment.java @@ -98,6 +98,7 @@ public class MineFragment extends BaseLazyFragment { TextView tvVersionName; TextView tv_count_to_do; LinearLayout ll_count_to_do; + LinearLayout ll_clean_cache; @@ -145,6 +146,7 @@ public class MineFragment extends BaseLazyFragment { } else { path = requireActivity().getFilesDir().getPath() + "/images"; } + } private void findView() { @@ -155,6 +157,7 @@ public class MineFragment extends BaseLazyFragment { tvVersionName = view.findViewById(R.id.tv_versionName); ll_count_to_do = view.findViewById(R.id.ll_count_to_do); tv_count_to_do = view.findViewById(R.id.tv_count_to_do); + ll_clean_cache = view.findViewById(R.id.ll_clean_cache); @@ -208,6 +211,14 @@ public class MineFragment extends BaseLazyFragment { } }); + //清除缓存 + ll_clean_cache.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + cleanCache(); + } + }); + } @Override @@ -529,9 +540,13 @@ public class MineFragment extends BaseLazyFragment { if (requireActivity().getExternalFilesDir(null) != null) { String pathSd = Objects.requireNonNull(requireActivity().getExternalFilesDir(null)).getPath() + "/Radio" ; deleteDirectory(pathSd); + deleteDirectory(path); + createDirectory(path); } else { String pathSd = requireActivity().getFilesDir().getPath() + "/Radio"; deleteDirectory(pathSd); + deleteDirectory(path); + createDirectory(path); } Toast.makeText(getActivity(), "清除缓存成功", Toast.LENGTH_LONG).show(); } @@ -585,6 +600,12 @@ public class MineFragment extends BaseLazyFragment { } } + public static void createDirectory(String filePath) { + File fileDir = new File(filePath); + if(!fileDir.exists()){ + fileDir.mkdir(); + } + } /** * 删除单个文件 * diff --git a/app/src/main/java/com/rehome/dywoa/utils/DataPassUtils.java b/app/src/main/java/com/rehome/dywoa/utils/DataPassUtils.java index 7691c01..200d666 100644 --- a/app/src/main/java/com/rehome/dywoa/utils/DataPassUtils.java +++ b/app/src/main/java/com/rehome/dywoa/utils/DataPassUtils.java @@ -10,7 +10,7 @@ public class DataPassUtils { try { //格式化日期的对象(转化成习惯的时间格式) SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy年MM月dd日"); - Date date = sdFormat.parse("2025年01月20日"); + Date date = sdFormat.parse("2025年03月21日"); Calendar calendarOne = Calendar.getInstance(); calendarOne.setTime(date); if (!Calendar.getInstance().after(calendarOne)) { @@ -27,7 +27,7 @@ public class DataPassUtils { try { //格式化日期的对象(转化成习惯的时间格式) SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy年MM月dd日"); - Date date = sdFormat.parse("2025年01月20日"); + Date date = sdFormat.parse("2026年03月21日"); Calendar calendarOne = Calendar.getInstance(); calendarOne.setTime(date); if (!Calendar.getInstance().after(calendarOne)) { @@ -43,7 +43,7 @@ public class DataPassUtils { try { //格式化日期的对象(转化成习惯的时间格式) SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy年MM月dd日"); - Date date = sdFormat.parse("2025年01月20日"); + Date date = sdFormat.parse("2025年03月22日"); Calendar calendarOne = Calendar.getInstance(); calendarOne.setTime(date); if (!Calendar.getInstance().after(calendarOne)) { @@ -58,7 +58,7 @@ public class DataPassUtils { try { //格式化日期的对象(转化成习惯的时间格式) SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy年MM月dd日"); - Date date = sdFormat.parse("2025年01月20日"); + Date date = sdFormat.parse("2025年03月23日"); Calendar calendarOne = Calendar.getInstance(); calendarOne.setTime(date); if (!Calendar.getInstance().after(calendarOne)) { diff --git a/app/src/main/res/layout/activity_yhscp.xml b/app/src/main/res/layout/activity_yhscp.xml new file mode 100644 index 0000000..9a927fb --- /dev/null +++ b/app/src/main/res/layout/activity_yhscp.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_mine.xml b/app/src/main/res/layout/fragment_mine.xml index 8d12ef4..08e2fec 100644 --- a/app/src/main/res/layout/fragment_mine.xml +++ b/app/src/main/res/layout/fragment_mine.xml @@ -133,6 +133,57 @@ + + + + + + + + + + +