Skip to content

Commit

Permalink
determine isPartialAccessGranted improve
Browse files Browse the repository at this point in the history
isPartialAccessGranted must media permission denied
  • Loading branch information
ted-prnd committed Aug 14, 2024
1 parent 7cbc8a9 commit 9edbcce
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ internal class TedImagePickerActivity
root.isGone = true
return@with
}
root.isVisible = isPartialAccessGranted
root.isVisible = builder.mediaType.isPartialAccessGranted
tvPartialAccessManage.setOnClickListener { showPartialAccessManageDialog() }
val mediaTypeText = getString(builder.mediaType.nameResId)
tvPartialAccessNotice.text =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ open class TedImagePickerBaseBuilder<out B : TedImagePickerBaseBuilder<B>>(
@SuppressLint("CheckResult")
protected fun startInternal(context: Context) {
val requestPermissions = getRequestPermissions()
if (TedPermissionUtil.isGranted(*requestPermissions) || isPartialAccessGranted) {
if (TedPermissionUtil.isGranted(*requestPermissions) || mediaType.isPartialAccessGranted) {
startActivity(context)
} else {
TedPermission.create()
.setPermissions(*requestPermissions)
.request()
.subscribe({ permissionResult ->
if (permissionResult.isGranted || isPartialAccessGranted) {
if (permissionResult.isGranted || mediaType.isPartialAccessGranted) {
startActivity(context)
}
}, { throwable -> onErrorListener?.onError(throwable) })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PartialAccessManageBottomSheet : BottomSheetDialogFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
savedInstanceState: Bundle?,
): View = BottomsheetPartialAccessManageBinding.inflate(inflater, container, false).also {
binding = it
}.root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import com.gun0912.tedpermission.TedPermissionUtil
import gun0912.tedimagepicker.builder.type.MediaType


internal val isPartialAccessGranted: Boolean
internal val MediaType.isPartialAccessGranted: Boolean
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
&& TedPermissionUtil.isGranted(Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED)
&& !TedPermissionUtil.isGranted(*permissions)


internal val MediaType.isFullOrPartialAccessGranted: Boolean
Expand Down

0 comments on commit 9edbcce

Please sign in to comment.