Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sobot_module_Dev
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sobot_android
Sobot_module_Dev
Commits
3447e50a
Commit
3447e50a
authored
Mar 13, 2024
by
郭倩芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
相册选照片、视频权限提示
parent
d89fd9a5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
15 deletions
+29
-15
sobot-widget-publish-mavencentral.gradle
sobot_widget/sobot-widget-publish-mavencentral.gradle
+1
-1
SobotBaseActivity.java
...main/java/com/sobot/widget/ui/base/SobotBaseActivity.java
+24
-14
strings.xml
sobot_widget/src/main/res/values-en/strings.xml
+2
-0
strings.xml
sobot_widget/src/main/res/values/strings.xml
+2
-0
No files found.
sobot_widget/sobot-widget-publish-mavencentral.gradle
View file @
3447e50a
...
@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
...
@@ -12,7 +12,7 @@ task androidSourcesJar(type: Jar) {
ext
{
ext
{
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_GROUP_ID
=
"com.sobot.library"
//项目包名
PUBLISH_ARTIFACT_ID
=
'widget_x'
//项目名
PUBLISH_ARTIFACT_ID
=
'widget_x'
//项目名
PUBLISH_VERSION
=
'1.
1.8
'
//版本号
PUBLISH_VERSION
=
'1.
2.0
'
//版本号
}
}
...
...
sobot_widget/src/main/java/com/sobot/widget/ui/base/SobotBaseActivity.java
View file @
3447e50a
...
@@ -12,10 +12,12 @@ import android.hardware.Camera;
...
@@ -12,10 +12,12 @@ import android.hardware.Camera;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.LocaleList
;
import
android.os.LocaleList
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.app.ActivityCompat
;
import
androidx.fragment.app.FragmentActivity
;
import
androidx.fragment.app.FragmentActivity
;
import
androidx.core.content.ContextCompat
;
import
androidx.core.content.ContextCompat
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.DisplayMetrics
;
import
android.util.DisplayMetrics
;
import
android.view.View
;
import
android.view.View
;
...
@@ -26,6 +28,7 @@ import android.widget.LinearLayout;
...
@@ -26,6 +28,7 @@ import android.widget.LinearLayout;
import
android.widget.RelativeLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.sobot.utils.SobotLogUtils
;
import
com.sobot.utils.SobotSharedPreferencesUtil
;
import
com.sobot.utils.SobotSharedPreferencesUtil
;
import
com.sobot.utils.SobotSystemUtils
;
import
com.sobot.utils.SobotSystemUtils
;
import
com.sobot.widget.R
;
import
com.sobot.widget.R
;
...
@@ -513,6 +516,19 @@ public abstract class SobotBaseActivity extends FragmentActivity {
...
@@ -513,6 +516,19 @@ public abstract class SobotBaseActivity extends FragmentActivity {
switch
(
requestCode
)
{
switch
(
requestCode
)
{
case
SobotBaseConstant
.
REQUEST_CODE_PICTURE
:
case
SobotBaseConstant
.
REQUEST_CODE_PICTURE
:
try
{
try
{
//判断是否选择部分的权限
// SobotLogUtils.d("=====判断是否选择部分的权限=======");
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
(
permissionListener
!=
null
)
{
permissionListener
.
onPermissionSuccessListener
();
}
return
;
}
}
}
for
(
int
i
=
0
;
i
<
grantResults
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
grantResults
.
length
;
i
++)
{
//判断权限的结果,如果有被拒绝,就return
//判断权限的结果,如果有被拒绝,就return
if
(
grantResults
[
i
]
!=
PackageManager
.
PERMISSION_GRANTED
)
{
if
(
grantResults
[
i
]
!=
PackageManager
.
PERMISSION_GRANTED
)
{
...
@@ -548,7 +564,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
...
@@ -548,7 +564,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
}
}
}
}
}
else
if
(
permissions
[
i
]
!=
null
&&
permissions
[
i
].
equals
(
Manifest
.
permission
.
READ_MEDIA_IMAGES
))
{
}
else
if
(
permissions
[
i
]
!=
null
&&
permissions
[
i
].
equals
(
Manifest
.
permission
.
READ_MEDIA_IMAGES
))
{
permissionTitle
=
getResources
().
getString
(
R
.
string
.
sobot_no_
write_external_storage
_permission
);
permissionTitle
=
getResources
().
getString
(
R
.
string
.
sobot_no_
record_images
_permission
);
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
Manifest
.
permission
.
READ_MEDIA_IMAGES
)
&&
!
SobotWidgetApi
.
getSwitchMarkStatus
(
SobotMarkConfig
.
SHOW_PERMISSION_TIPS_POP
))
{
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
Manifest
.
permission
.
READ_MEDIA_IMAGES
)
&&
!
SobotWidgetApi
.
getSwitchMarkStatus
(
SobotMarkConfig
.
SHOW_PERMISSION_TIPS_POP
))
{
SobotToastUtil
.
showCustomLongToast
(
this
,
SobotSystemUtils
.
getAppName
(
this
)
+
getResources
().
getString
(
R
.
string
.
sobot_want_use_your
)
+
getString
(
R
.
string
.
sobot_memory_card
)
+
" , "
+
getString
(
R
.
string
.
sobot_memory_card_yongtu
));
SobotToastUtil
.
showCustomLongToast
(
this
,
SobotSystemUtils
.
getAppName
(
this
)
+
getResources
().
getString
(
R
.
string
.
sobot_want_use_your
)
+
getString
(
R
.
string
.
sobot_memory_card
)
+
" , "
+
getString
(
R
.
string
.
sobot_memory_card_yongtu
));
}
else
{
}
else
{
...
@@ -558,7 +574,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
...
@@ -558,7 +574,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
}
}
}
}
}
else
if
(
permissions
[
i
]
!=
null
&&
permissions
[
i
].
equals
(
Manifest
.
permission
.
READ_MEDIA_VIDEO
))
{
}
else
if
(
permissions
[
i
]
!=
null
&&
permissions
[
i
].
equals
(
Manifest
.
permission
.
READ_MEDIA_VIDEO
))
{
permissionTitle
=
getResources
().
getString
(
R
.
string
.
sobot_no_
write_external_storage
_permission
);
permissionTitle
=
getResources
().
getString
(
R
.
string
.
sobot_no_
record_video
_permission
);
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
Manifest
.
permission
.
READ_MEDIA_VIDEO
)
&&
!
SobotWidgetApi
.
getSwitchMarkStatus
(
SobotMarkConfig
.
SHOW_PERMISSION_TIPS_POP
))
{
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
Manifest
.
permission
.
READ_MEDIA_VIDEO
)
&&
!
SobotWidgetApi
.
getSwitchMarkStatus
(
SobotMarkConfig
.
SHOW_PERMISSION_TIPS_POP
))
{
SobotToastUtil
.
showCustomLongToast
(
this
,
SobotSystemUtils
.
getAppName
(
this
)
+
getResources
().
getString
(
R
.
string
.
sobot_want_use_your
)
+
getString
(
R
.
string
.
sobot_memory_card
)
+
" , "
+
getString
(
R
.
string
.
sobot_memory_card_yongtu
));
SobotToastUtil
.
showCustomLongToast
(
this
,
SobotSystemUtils
.
getAppName
(
this
)
+
getResources
().
getString
(
R
.
string
.
sobot_want_use_your
)
+
getString
(
R
.
string
.
sobot_memory_card
)
+
" , "
+
getString
(
R
.
string
.
sobot_memory_card_yongtu
));
}
else
{
}
else
{
...
@@ -568,9 +584,9 @@ public abstract class SobotBaseActivity extends FragmentActivity {
...
@@ -568,9 +584,9 @@ public abstract class SobotBaseActivity extends FragmentActivity {
}
}
}
}
}
else
if
(
permissions
[
i
]
!=
null
&&
permissions
[
i
].
equals
(
Manifest
.
permission
.
READ_MEDIA_AUDIO
))
{
}
else
if
(
permissions
[
i
]
!=
null
&&
permissions
[
i
].
equals
(
Manifest
.
permission
.
READ_MEDIA_AUDIO
))
{
permissionTitle
=
getResources
().
getString
(
R
.
string
.
sobot_no_
write_external_storage
_permission
);
permissionTitle
=
getResources
().
getString
(
R
.
string
.
sobot_no_
record_audio
_permission
);
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
Manifest
.
permission
.
READ_MEDIA_AUDIO
)
&&
!
SobotWidgetApi
.
getSwitchMarkStatus
(
SobotMarkConfig
.
SHOW_PERMISSION_TIPS_POP
))
{
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
Manifest
.
permission
.
READ_MEDIA_AUDIO
)
&&
!
SobotWidgetApi
.
getSwitchMarkStatus
(
SobotMarkConfig
.
SHOW_PERMISSION_TIPS_POP
))
{
SobotToastUtil
.
showCustomLongToast
(
this
,
SobotSystemUtils
.
getAppName
(
this
)
+
getResources
().
getString
(
R
.
string
.
sobot_want_use_your
)
+
getString
(
R
.
string
.
sobot_m
emory_card
)
+
" , "
+
getString
(
R
.
string
.
sobot_memory_card
_yongtu
));
SobotToastUtil
.
showCustomLongToast
(
this
,
SobotSystemUtils
.
getAppName
(
this
)
+
getResources
().
getString
(
R
.
string
.
sobot_want_use_your
)
+
getString
(
R
.
string
.
sobot_m
icrophone
)
+
" , "
+
getString
(
R
.
string
.
sobot_microphone
_yongtu
));
}
else
{
}
else
{
//调用权限失败
//调用权限失败
if
(
permissionListener
!=
null
)
{
if
(
permissionListener
!=
null
)
{
...
@@ -633,12 +649,9 @@ public abstract class SobotBaseActivity extends FragmentActivity {
...
@@ -633,12 +649,9 @@ public abstract class SobotBaseActivity extends FragmentActivity {
return
false
;
return
false
;
}
}
}
else
{
}
else
{
if
(
ContextCompat
.
checkSelfPermission
(
getSobotBaseActivity
(),
Manifest
.
permission
.
READ_MEDIA_IMAGES
)
==
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_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
);
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
;
return
false
;
...
@@ -689,11 +702,8 @@ public abstract class SobotBaseActivity extends FragmentActivity {
...
@@ -689,11 +702,8 @@ public abstract class SobotBaseActivity extends FragmentActivity {
// 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_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_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));
// 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
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_VIDEO
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
||
ContextCompat
.
checkSelfPermission
(
getSobotBaseActivity
(),
Manifest
.
permission
.
READ_MEDIA_VISUAL_USER_SELECTED
)
==
PackageManager
.
PERMISSION_GRANTED
)
{
return
true
;
}
else
{
return
false
;
return
false
;
}
}
}
}
...
...
sobot_widget/src/main/res/values-en/strings.xml
View file @
3447e50a
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
<string
name=
"sobot_no_write_external_storage_permission"
>
No write external storage permission
</string>
<string
name=
"sobot_no_write_external_storage_permission"
>
No write external storage permission
</string>
<string
name=
"sobot_no_record_audio_permission"
>
Unable to record
</string>
<string
name=
"sobot_no_record_audio_permission"
>
Unable to record
</string>
<string
name=
"sobot_no_record_images_permission"
>
No permission to obtain images
</string>
<string
name=
"sobot_no_record_video_permission"
>
No video permission obtained
</string>
<string
name=
"sobot_no_camera_permission"
>
No camera permission
</string>
<string
name=
"sobot_no_camera_permission"
>
No camera permission
</string>
<string
name=
"sobot_want_use_your"
>
want to visit yours
</string>
<string
name=
"sobot_want_use_your"
>
want to visit yours
</string>
<string
name=
"sobot_memory_card"
>
File
</string>
<string
name=
"sobot_memory_card"
>
File
</string>
...
...
sobot_widget/src/main/res/values/strings.xml
View file @
3447e50a
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
<string
name=
"sobot_no_write_external_storage_permission"
>
没有存储权限
</string>
<string
name=
"sobot_no_write_external_storage_permission"
>
没有存储权限
</string>
<string
name=
"sobot_no_record_audio_permission"
>
没有麦克风权限
</string>
<string
name=
"sobot_no_record_audio_permission"
>
没有麦克风权限
</string>
<string
name=
"sobot_no_record_images_permission"
>
没有读取图片权限
</string>
<string
name=
"sobot_no_record_video_permission"
>
没有读取视频权限
</string>
<string
name=
"sobot_no_camera_permission"
>
没有相机权限
</string>
<string
name=
"sobot_no_camera_permission"
>
没有相机权限
</string>
<string
name=
"sobot_want_use_your"
>
想访问您的
</string>
<string
name=
"sobot_want_use_your"
>
想访问您的
</string>
<string
name=
"sobot_memory_card"
>
文件
</string>
<string
name=
"sobot_memory_card"
>
文件
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment