Commit d792d693 by 郭倩芳

相册选照片、视频

parent 3ac11a71
......@@ -3,13 +3,12 @@ plugins {
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
compileSdkVersion 34
defaultConfig {
applicationId "com.sobot.moduletest"
minSdkVersion 17
targetSdkVersion 29
targetSdkVersion 34
versionCode 1
versionName "1.0"
//添加此行
......
......@@ -13,6 +13,7 @@
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:exported="true"
android:configChanges="orientation|keyboardHidden|screenSize|touchscreen|navigation|locale|fontScale|uiMode|screenLayout|smallestScreenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -3,7 +3,7 @@ plugins {
}
android {
compileSdkVersion 33
compileSdkVersion 34
defaultConfig {
minSdkVersion 17
......
......@@ -8,6 +8,7 @@
<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_MEDIA_VISUAL_USER_SELECTED" />
<uses-permission android:name="com.google.android.apps.photos.permission.GOOGLE_PHOTOS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
......
......@@ -9,4 +9,6 @@ public class SobotBaseConstant {
public static final int REQUEST_CODE_VIDEO = 1002;
//直接照相获取图片
public static final int REQUEST_CODE_MAKEPICTUREFROMCAMERA = 1003;
//获取图库视频和相册的code
public static final int REQUEST_CODE_ALBUM = 1004;
}
\ No newline at end of file
......@@ -606,7 +606,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
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);
this.requestPermissions(new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED}, SobotBaseConstant.REQUEST_CODE_PICTURE);
return false;
}
} else if (checkType == 1) {
......@@ -623,7 +623,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
this.requestPermissions(new String[]{Manifest.permission.READ_MEDIA_AUDIO}, SobotBaseConstant.REQUEST_CODE_PICTURE);
return false;
}
} else {
} 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)
......@@ -632,6 +632,17 @@ public abstract class SobotBaseActivity extends FragmentActivity {
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;
}
} else {
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_VISUAL_USER_SELECTED) == PackageManager.PERMISSION_GRANTED
) {
return true;
} else {
//申请:图片权限 视频权限 音频权限
this.requestPermissions(new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.READ_MEDIA_VIDEO, Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED}, SobotBaseConstant.REQUEST_CODE_PICTURE);
return false;
}
}
} else if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity().getApplicationContext()) >= 23) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
......@@ -667,13 +678,24 @@ public abstract class SobotBaseActivity extends FragmentActivity {
!= PackageManager.PERMISSION_GRANTED) {
return false;
}
} else {
} 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) {
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
|| ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED) == PackageManager.PERMISSION_GRANTED) {
return true;
} else {
return false;
}
}
} else if (Build.VERSION.SDK_INT >= 23 && SobotSystemUtils.getTargetSdkVersion(getSobotBaseActivity().getApplicationContext()) >= 23) {
if (ContextCompat.checkSelfPermission(getSobotBaseActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
......@@ -792,7 +814,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
* @param title
* @param content
* @param type
* @param checkPermissionType 0:图片权限 1:视频权限,2:音频权限,3,所有细分的权限, android 13 使用
* @param checkPermissionType 0:图片权限 1:视频权限,2:音频权限,3,所有细分的权限 android 13 使用 4.相册权限,视频加图片
* @return
*/
public boolean checkIsShowPermissionPop(String title, String content, final int type, final int checkPermissionType) {
......
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