From 85caf3d5fc517b2099d17080688cafd013cf6a76 Mon Sep 17 00:00:00 2001 From: imndx Date: Sun, 16 Jul 2023 23:35:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E5=A4=B4=E5=83=8F=E6=97=B6=EF=BC=8C=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E6=9C=AA=E6=8E=88=E6=9D=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/kit/user/UserInfoFragment.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/uikit/src/main/java/cn/wildfire/chat/kit/user/UserInfoFragment.java b/uikit/src/main/java/cn/wildfire/chat/kit/user/UserInfoFragment.java index aea0b0fe2..82b5896b4 100644 --- a/uikit/src/main/java/cn/wildfire/chat/kit/user/UserInfoFragment.java +++ b/uikit/src/main/java/cn/wildfire/chat/kit/user/UserInfoFragment.java @@ -4,8 +4,11 @@ package cn.wildfire.chat.kit.user; +import android.Manifest; import android.app.Activity; import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.LayoutInflater; @@ -283,6 +286,28 @@ void showUserMessages() { private static final int REQUEST_CODE_PICK_IMAGE = 100; void portrait() { + String[] permissions; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + permissions = new String[]{ + Manifest.permission.READ_MEDIA_IMAGES, + }; + } else { + permissions = new String[]{ + Manifest.permission.READ_EXTERNAL_STORAGE, + }; + } + Activity activity = getActivity(); + if (activity == null) { + return; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + for (String permission : permissions) { + if (activity.checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { + requestPermissions(permissions, 100); + return; + } + } + } if (userInfo.uid.equals(userViewModel.getUserId())) { updatePortrait(); } else {