[Modify]安卓13适配和谷歌充值页面加loading

This commit is contained in:
wushaocheng
2023-09-18 11:43:10 +08:00
parent 306e0a99a0
commit 957b64476f
15 changed files with 108 additions and 65 deletions

View File

@@ -3,8 +3,13 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32"
tools:ignore="ScopedStorage" />
<application>

View File

@@ -7,6 +7,7 @@ import android.content.Context;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.text.TextUtils;
@@ -60,7 +61,7 @@ public class AlbumModel {
public void query(Context context, final CallBack callBack) {
final Context appCxt = context.getApplicationContext();
if (PermissionChecker.checkSelfPermission(context,
Manifest.permission.READ_EXTERNAL_STORAGE) != PermissionChecker.PERMISSION_GRANTED) {
Build.VERSION.SDK_INT >= 33 ? Manifest.permission.READ_MEDIA_IMAGES : Manifest.permission.READ_EXTERNAL_STORAGE) != PermissionChecker.PERMISSION_GRANTED) {
if (null != callBack) callBack.onAlbumWorkedCallBack();
return;
}

View File

@@ -210,11 +210,9 @@ public class EasyPhotosActivity extends AppCompatActivity implements AlbumItemsA
protected String[] getNeedPermissions() {
if (Setting.isShowCamera) {
return new String[]{Manifest.permission.CAMERA,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE};
Build.VERSION.SDK_INT >= 33 ? Manifest.permission.READ_MEDIA_IMAGES : Manifest.permission.READ_EXTERNAL_STORAGE};
} else {
return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE};
return new String[]{Build.VERSION.SDK_INT >= 33 ? Manifest.permission.READ_MEDIA_IMAGES : Manifest.permission.READ_EXTERNAL_STORAGE};
}
}
@@ -499,6 +497,7 @@ public class EasyPhotosActivity extends AppCompatActivity implements AlbumItemsA
shouldShowMenuDone();
}
@SuppressLint("Range")
private Photo getPhoto(Uri uri) {
Photo p = null;
String path;
@@ -625,12 +624,17 @@ public class EasyPhotosActivity extends AppCompatActivity implements AlbumItemsA
}
}
final Photo photo = new Photo(mTempImageFile.getName(), uri,
mTempImageFile.getAbsolutePath(),
mTempImageFile.lastModified() / 1000, width, height, orientation,
mTempImageFile.length(),
DurationUtils.getDuration(mTempImageFile.getAbsolutePath()),
options.outMimeType);
final Photo photo;
try {
photo = new Photo(mTempImageFile.getName(), uri,
mTempImageFile.getAbsolutePath(),
mTempImageFile.lastModified() / 1000, width, height, orientation,
mTempImageFile.length(),
DurationUtils.getDuration(mTempImageFile.getAbsolutePath()),
options.outMimeType);
} catch (IOException e) {
throw new RuntimeException(e);
}
runOnUiThread(new Runnable() {
@Override

View File

@@ -7,6 +7,7 @@ import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
@@ -459,10 +460,15 @@ public class PuzzleActivity extends AppCompatActivity implements View.OnClickLis
public void onSuccess(File file) {
Intent intent = new Intent();
Photo photo = new Photo(file.getName(), UriUtils.getUri(PuzzleActivity.this,
file), file.getAbsolutePath(), file.lastModified() / 1000,
puzzleView.getWidth(), puzzleView.getHeight(), 0, file.length(),
DurationUtils.getDuration(file.getAbsolutePath()), "image/png");
Photo photo = null;
try {
photo = new Photo(file.getName(), UriUtils.getUri(PuzzleActivity.this,
file), file.getAbsolutePath(), file.lastModified() / 1000,
puzzleView.getWidth(), puzzleView.getHeight(), 0, file.length(),
DurationUtils.getDuration(file.getAbsolutePath()), "image/png");
} catch (IOException e) {
throw new RuntimeException(e);
}
intent.putExtra(EasyPhotos.RESULT_PHOTOS, photo);
setResult(RESULT_OK, intent);
PuzzleActivity.this.finish();
@@ -576,8 +582,7 @@ public class PuzzleActivity extends AppCompatActivity implements View.OnClickLis
protected String[] getNeedPermissions() {
return new String[]{Manifest.permission.CAMERA,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE};
Build.VERSION.SDK_INT >= 33 ? Manifest.permission.READ_MEDIA_IMAGES : Manifest.permission.READ_EXTERNAL_STORAGE};
}
@Override

View File

@@ -3,6 +3,8 @@ package com.yizhuan.xchat_android_library.easyphoto.utils.media;
import android.media.MediaMetadataRetriever;
import android.text.format.DateUtils;
import java.io.IOException;
/**
* DurationUtils
* Create By lishilin On 2019/3/25
@@ -15,7 +17,7 @@ public class DurationUtils {
* @param path path
* @return duration
*/
public static long getDuration(String path) {
public static long getDuration(String path) throws IOException {
MediaMetadataRetriever mmr = null;
try {
mmr = new MediaMetadataRetriever();