@@ -216,7 +216,7 @@ private void setDataInView() {
216216 try {
217217 Runnable fileUriRunnable = () -> {
218218 Uri uri = Uri .parse (bundle .getString (TrimVideo .TRIM_VIDEO_URI ));
219- String path = FileUtilKt .getValidatedFileUri (ActVideoTrimmer .this ,uri );
219+ String path = FileUtilKt .getValidatedFileUri (ActVideoTrimmer .this , uri );
220220 filePath = Uri .parse (path );
221221 runOnUiThread (() -> {
222222 LogMessage .v ("VideoUri:: " + uri );
@@ -337,7 +337,7 @@ private void loadThumbnails() {
337337 try {
338338 long diff = totalDuration / 8 ;
339339 int sec = 1 ;
340- File videoFile = new File (filePath .toString ());
340+ File videoFile = new File (filePath .toString ());
341341 for (ImageView img : imageViews ) {
342342 long interval = (diff * sec ) * 1000000 ;
343343 RequestOptions options = new RequestOptions ().frame (interval );
@@ -475,8 +475,8 @@ protected void onDestroy() {
475475 videoPlayer .release ();
476476 if (progressView != null && progressView .isShowing ())
477477 progressView .dismiss ();
478- File f = new File (getCacheDir (), "temp_video_file" );
479- if (f .exists ()){
478+ File f = new File (getCacheDir (), "temp_video_file" );
479+ if (f .exists ()) {
480480 f .delete ();
481481 }
482482 stopRepeatingTask ();
@@ -697,12 +697,27 @@ private void showProcessingDialog() {
697697 }
698698
699699 private boolean checkStoragePermission () {
700- if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU )
701- {
700+ Uri uri = Uri .parse (bundle .getString (TrimVideo .TRIM_VIDEO_URI ));
701+ String fileUri = FileUtilKt .getActualFileUri (this , uri );
702+ if (fileUri !=null && new File (fileUri ).canRead ()){
703+ return true ;
704+ }
705+
706+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .UPSIDE_DOWN_CAKE ) {
707+ boolean hasPermission = ContextCompat .checkSelfPermission (this , Manifest .permission .READ_MEDIA_VISUAL_USER_SELECTED )
708+ == PackageManager .PERMISSION_GRANTED ||
709+ ContextCompat .checkSelfPermission (this , Manifest .permission .READ_MEDIA_VIDEO )
710+ == PackageManager .PERMISSION_GRANTED ;
711+ if (hasPermission ) {
712+ return true ;
713+ } else {
714+ return checkPermission (
715+ Manifest .permission .READ_MEDIA_VIDEO );
716+ }
717+ } else if (Build .VERSION .SDK_INT == Build .VERSION_CODES .TIRAMISU ) {
702718 return checkPermission (
703719 Manifest .permission .READ_MEDIA_VIDEO );
704- }
705- else if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
720+ } else if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
706721 return checkPermission (
707722 Manifest .permission .READ_EXTERNAL_STORAGE );
708723 } else
0 commit comments