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
74542b25
Commit
74542b25
authored
Apr 01, 2024
by
zhengnw@sobot.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/sobot_module_x' into sobot_module_x
parents
b44d0f4d
616bdb53
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
40 deletions
+44
-40
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
+18
-34
RomUtils.java
...ain/java/com/sobot/widget/ui/notchlib/utils/RomUtils.java
+12
-0
SobotWidgetUtils.java
...main/java/com/sobot/widget/ui/utils/SobotWidgetUtils.java
+13
-5
No files found.
sobot_widget/sobot-widget-publish-mavencentral.gradle
View file @
74542b25
...
...
@@ -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
'
//版本号
}
...
...
sobot_widget/src/main/java/com/sobot/widget/ui/base/SobotBaseActivity.java
View file @
74542b25
...
...
@@ -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
;
...
...
sobot_widget/src/main/java/com/sobot/widget/ui/notchlib/utils/RomUtils.java
View file @
74542b25
...
...
@@ -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
;
}
...
...
sobot_widget/src/main/java/com/sobot/widget/ui/utils/SobotWidgetUtils.java
View file @
74542b25
...
...
@@ -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/*"
);
...
...
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