|
@@ -5,6 +5,7 @@ import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.graphics.Color
|
|
|
import android.graphics.Typeface
|
|
|
+import android.os.Build
|
|
|
import android.view.View
|
|
|
import android.widget.Toast
|
|
|
import androidx.fragment.app.activityViewModels
|
|
@@ -118,20 +119,41 @@ class HomeFragment : BaseXFragment<FragmentHomeBinding>() {
|
|
|
binding.ivLive.setOnClickListener(object :NoDoubleClickListener(){
|
|
|
override fun onClick() {
|
|
|
binding.ivLive.isEnabled = false
|
|
|
- PermissionX.init(this@HomeFragment)
|
|
|
- .permissions(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO)
|
|
|
- .request { allGranted, grantedList, deniedList ->
|
|
|
- if (allGranted) {
|
|
|
- ARouter.getInstance().build(ARouteConstant.Room.anchor).navigation()
|
|
|
- } else {
|
|
|
- binding.ivLive.isEnabled = true
|
|
|
- Toast.makeText(
|
|
|
- AppContext.getContext(),
|
|
|
- AppContext.getContext().getString(R.string.these_permissions_denied)+" $deniedList",
|
|
|
- Toast.LENGTH_LONG
|
|
|
- ).show()
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE){
|
|
|
+ PermissionX.init(this@HomeFragment)
|
|
|
+ .permissions(Manifest.permission.CAMERA,
|
|
|
+ Manifest.permission.RECORD_AUDIO,
|
|
|
+ Manifest.permission.FOREGROUND_SERVICE_CAMERA,
|
|
|
+ Manifest.permission.FOREGROUND_SERVICE_MICROPHONE)
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ ARouter.getInstance().build(ARouteConstant.Room.anchor).navigation()
|
|
|
+ } else {
|
|
|
+ binding.ivLive.isEnabled = true
|
|
|
+ Toast.makeText(
|
|
|
+ AppContext.getContext(),
|
|
|
+ AppContext.getContext().getString(R.string.these_permissions_denied)+" $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ PermissionX.init(this@HomeFragment)
|
|
|
+ .permissions(Manifest.permission.CAMERA,
|
|
|
+ Manifest.permission.RECORD_AUDIO)
|
|
|
+ .request { allGranted, grantedList, deniedList ->
|
|
|
+ if (allGranted) {
|
|
|
+ ARouter.getInstance().build(ARouteConstant.Room.anchor).navigation()
|
|
|
+ } else {
|
|
|
+ binding.ivLive.isEnabled = true
|
|
|
+ Toast.makeText(
|
|
|
+ AppContext.getContext(),
|
|
|
+ AppContext.getContext().getString(R.string.these_permissions_denied)+" $deniedList",
|
|
|
+ Toast.LENGTH_LONG
|
|
|
+ ).show()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
|