Commit 74542b25 by zhengnw@sobot.com

Merge remote-tracking branch 'origin/sobot_module_x' into sobot_module_x

parents b44d0f4d 616bdb53
......@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'widget_x' //项目名
PUBLISH_VERSION = '1.2.1' //版本号
PUBLISH_VERSION = '1.2.2' //版本号
}
......
......@@ -521,7 +521,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
for (int i = 0; i < grantResults.length; i++) {
if (permissions[i] != null && permissions[i].equals(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)) {
// SobotLogUtils.d("=====android 14权限===="+permissions[i].equals(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)+"====="+grantResults[i]);
if(grantResults[i] == PackageManager.PERMISSION_GRANTED){
if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
if (permissionListener != null) {
permissionListener.onPermissionSuccessListener();
}
......@@ -610,7 +610,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
/**
* 检查存储权限
*
* @param checkType 0:图片权限 1:视频权限,2:音频权限,3,所有细分的权限, android 13 使用 4:相册权限,读取相册图片和视频
* @param checkType 0:图片权限 1:视频权限,2:音频权限,3:选文件,图片、视频、录音所有细分的权限 4:图片和视频权限,读取相册图片和视频
* @return true, 已经获取权限;false,没有权限,尝试获取
*/
protected boolean checkStoragePermission(int checkType) {
......@@ -619,19 +619,9 @@ public abstract class SobotBaseActivity extends FragmentActivity {
//如果是升级Android13之后新装的应用,并且targetSDK大于等于33,则申请READ_EXTERNAL_STORAGE权限时会自动拒绝。
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (checkType == 0) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES)
!= PackageManager.PERMISSION_GRANTED) {
//申请图片权限
this.requestPermissions(new String[]{Manifest.permission.READ_MEDIA_IMAGES}, SobotBaseConstant.REQUEST_CODE_PICTURE);
return false;
}
return true;
} else if (checkType == 1) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO)
!= PackageManager.PERMISSION_GRANTED) {
//申请视频权限
this.requestPermissions(new String[]{Manifest.permission.READ_MEDIA_VIDEO}, SobotBaseConstant.REQUEST_CODE_PICTURE);
return false;
}
return true;
} else if (checkType == 2) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
......@@ -640,10 +630,10 @@ public abstract class SobotBaseActivity extends FragmentActivity {
return false;
}
} else if (checkType == 3) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES)
!= PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO)
!= PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
//为适配Android 14
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_AUDIO) != PackageManager.PERMISSION_GRANTED) {
//申请:图片权限 视频权限 音频权限
this.requestPermissions(new String[]{Manifest.permission.READ_MEDIA_AUDIO, Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VIDEO}, SobotBaseConstant.REQUEST_CODE_PICTURE);
return false;
......@@ -671,37 +661,31 @@ public abstract class SobotBaseActivity extends FragmentActivity {
/**
* 判断是否有存储卡权限
*
* @param checkPermissionType 0:图片权限 1:视频权限,2:音频权限,3,所有细分的权限, android 13 使用 4:相册权限,读取相册图片和视频
* @param checkPermissionType 0:图片权限 1:视频权限,2:音频权限,3:选文件,图片、视频、录音所有细分的权限 4:图片和视频权限,读取相册图片和视频
* @return true, 已经获取权限;false,没有权限
*/
protected boolean isHasStoragePermission(int checkPermissionType) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (checkPermissionType == 0) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES)
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
return true;
} else if (checkPermissionType == 1) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO)
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
return true;
} else if (checkPermissionType == 2) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
} else if (checkPermissionType == 3) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES)
!= PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO)
!= PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE &&
ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) == PackageManager.PERMISSION_GRANTED) {
return true;
}
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_AUDIO) != PackageManager.PERMISSION_GRANTED) {
return false;
}
} else {
// SobotLogUtils.d("=======READ_MEDIA_IMAGES=====" + ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES)+"===="+(ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED));
// SobotLogUtils.d("=======READ_MEDIA_VIDEO=====" + ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO)+"===="+(ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED));
// SobotLogUtils.d("=======READ_MEDIA_VISUAL_USER_SELECTED=====" + ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)+"===="+(ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) == PackageManager.PERMISSION_GRANTED));
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED) {
return false;
......
......@@ -20,11 +20,13 @@ public final class RomUtils {
private static final String VIVO = "vivo";
private static final String XIAOMI = "xiaomi";
private static final String OPPO = "oppo";
private static final String OnePlus = "oneplus";
private static final String VERSION_PROPERTY_HUAWEI = "ro.build.version.emui";
private static final String VERSION_PROPERTY_VIVO = "ro.vivo.os.build.display.id";
private static final String VERSION_PROPERTY_XIAOMI = "ro.build.version.incremental";
private static final String VERSION_PROPERTY_OPPO = "ro.build.version.opporom";
private static final String VERSION_PROPERTY_ONEPLUS = "ro.build.version.opporom";
private static final String UNKNOWN = "unknown";
private static RomInfo bean = null;
......@@ -68,6 +70,9 @@ public final class RomUtils {
public static boolean isOppo() {
return OPPO.equals(getRomInfo().name);
}
public static boolean isOnePlus() {
return OnePlus.equals(getRomInfo().name);
}
/**
* Return the rom's information.
......@@ -107,6 +112,13 @@ public final class RomUtils {
} else {
bean.name = manufacturer;
}
if (isRightRom(brand, manufacturer, OnePlus)) {
bean.name = OnePlus;
bean.version = getRomVersion(VERSION_PROPERTY_ONEPLUS);
return bean;
} else {
bean.name = manufacturer;
}
bean.version = getRomVersion("");
return bean;
}
......
......@@ -15,6 +15,7 @@ import androidx.core.content.FileProvider;
import com.sobot.utils.SobotIOUtils;
import com.sobot.widget.ui.SobotBaseConstant;
import com.sobot.widget.ui.notchlib.utils.RomUtils;
import com.sobot.widget.ui.toast.SobotToastUtil;
import java.io.File;
......@@ -41,12 +42,16 @@ public class SobotWidgetUtils {
return;
}
Intent intent;
if (Build.VERSION.SDK_INT < 19) {
intent = new Intent(Intent.ACTION_GET_CONTENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
intent.setType("image/*");
} else {
// intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, 1);//设置获取最大图片数量
}else if(Build.VERSION.SDK_INT >= 19){
intent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
}else{
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
}
try {
if (childFragment != null) {
......@@ -89,9 +94,12 @@ public class SobotWidgetUtils {
return;
}
Intent intent;
if (Build.VERSION.SDK_INT < 19) {
if (Build.VERSION.SDK_INT < 19 || RomUtils.isOppo() || RomUtils.isOnePlus()) {
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("video/*");
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent = new Intent(Intent.ACTION_PICK_ACTIVITY);
intent.setType("video/*");
} else {
intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
intent.setDataAndType(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, "video/*");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment