Commit 213fec50 authored by wanglei's avatar wanglei

...

parent 9294c03d
......@@ -101,7 +101,22 @@ class HowUseShareActivity : BaseActivity<ActivityHowUseShareBinding>() {
if (uiType == 1) {
step2ui()
} else {
onBackPressedDispatcher.onBackPressed()
AdsMgr.showInsert(activity, showCallBack = object : AdsShowCallBack() {
override fun close(where: Int) {
LogEx.logDebug(TAG, "where=$where")
finishToMainTop()
}
override fun failed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
finishToMainTop()
}
override fun googleFailed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
finishToMainTop()
}
})
}
}
}
......
......@@ -104,7 +104,22 @@ class HowViewOtherActivity : BaseActivity<ActivityHowViewOtherBinding>() {
if (uiType == 1) {
step2ui()
} else {
onBackPressedDispatcher.onBackPressed()
AdsMgr.showInsert(activity, showCallBack = object : AdsShowCallBack() {
override fun close(where: Int) {
LogEx.logDebug(TAG, "where=$where")
finishToMainTop()
}
override fun failed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
finishToMainTop()
}
override fun googleFailed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
finishToMainTop()
}
})
}
}
}
......
package com.base.locationsharewhite.ui.locationmap
import android.Manifest
import android.animation.ValueAnimator
import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.animation.LinearInterpolator
import androidx.activity.addCallback
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.R
......@@ -16,6 +20,7 @@ import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.bean.ConstObject
import com.base.locationsharewhite.bean.ViewingBean
import com.base.locationsharewhite.databinding.ActivityLocationMapBinding
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendAllAllowedNotification
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.location.LocationPositionUtils
import com.base.locationsharewhite.location.LocationShareListUtils
......@@ -28,8 +33,10 @@ import com.base.locationsharewhite.ui.set.RenameActivity
import com.base.locationsharewhite.ui.set.RenameActivity.Companion.RENAME_VIEWING_NICK_NAME
import com.base.locationsharewhite.ui.views.DialogView.showMapTypeDialog
import com.base.locationsharewhite.ui.views.DialogView.showViewerMoreDialog
import com.base.locationsharewhite.ui.views.LocationPermissionDialog.showLocationAllowAllTimeDialog
import com.base.locationsharewhite.utils.BarUtils
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.PermissionUtils.checkAllLocationPermission
import com.base.locationsharewhite.utils.PermissionUtils.checkBackgroundLocationPermission
import com.base.locationsharewhite.utils.PermissionUtils.checkLocationPermission
import com.base.locationsharewhite.utils.PermissionUtils.requestLocationAllowAllTime
......@@ -64,6 +71,8 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
private var myMarker: Marker? = null
private var friendMarker: Marker? = null
private var currentViewingBean: ViewingBean? = null
private var allowAllTimeDialog: Dialog? = null
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
......@@ -74,20 +83,22 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
val recreated = changeLanguage(this)
if (recreated) return
if (AdsMgr.adsConfigBean.functionInShowAd) {
AdsMgr.showInsert(this, showCallBack = object : AdsShowCallBack() {
override fun close(where: Int) {
LogEx.logDebug(TAG, "where=$where")
}
if (checkAllLocationPermission()) {
if (AdsMgr.adsConfigBean.functionInShowAd) {
AdsMgr.showInsert(this, showCallBack = object : AdsShowCallBack() {
override fun close(where: Int) {
LogEx.logDebug(TAG, "where=$where")
}
override fun failed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
}
override fun failed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
}
override fun googleFailed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
}
})
override fun googleFailed(where: Int) {
LogEx.logDebug(TAG, "where=$where")
}
})
}
}
val mapFragment =
......@@ -97,10 +108,41 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
showFriendGuideOrNoFriend()
initAdapter()
initViewingData()
showAllowAllTimeDialog()
}
private fun showAllowAllTimeDialog() {
if (!checkAllLocationPermission()) {
// toast("显示权限始终允许弹窗")
if (allowAllTimeDialog == null) {
allowAllTimeDialog =
showLocationAllowAllTimeDialog(
setAction = {
sendAllAllowedNotification(this)
requestLocationAllowAllTime(launcher, jumpOutAction = {
LogEx.logDebug(TAG, "jumpOutAction")
}, permissionAllowCallBack = {})
},
dismissAction = {
allowAllTimeDialog = null
})
}
} else {
// toast("不显示权限始终允许弹窗")
allowAllTimeDialog?.dismiss()
allowAllTimeDialog = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
launcher.launch(arrayOf(Manifest.permission.POST_NOTIFICATIONS)) {}
}
requestServiceLocationUpdates()
}
}
override fun onResumeOneShoot() {
super.onResumeOneShoot()
binding.ivPermission.isVisible = !checkAllLocationPermission()
}
......@@ -286,7 +328,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
}
binding.bottomSheet.setOnClickListener { }
binding.ivPermission.setOnClickListener {
requestLocationAllowAllTime(launcher, jumpOutAction = {}, permissionAllowAction = {})
showAllowAllTimeDialog()
}
}
......
......@@ -13,7 +13,6 @@ import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.bean.config.ConfigBean
import com.base.locationsharewhite.databinding.ActivityMainBinding
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendAllAllowedNotification
import com.base.locationsharewhite.helper.BaseActivity
......@@ -27,6 +26,8 @@ import com.base.locationsharewhite.ui.views.DialogView.showAppExitDialog
import com.base.locationsharewhite.ui.views.LocationPermissionDialog.showLocationAllowAllTimeDialog
import com.base.locationsharewhite.utils.BarUtils
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.PermissionUtils.areNotificationsEnabled
import com.base.locationsharewhite.utils.PermissionUtils.checkAllLocationPermission
import com.base.locationsharewhite.utils.PermissionUtils.checkBackgroundLocationPermission
import com.base.locationsharewhite.utils.PermissionUtils.checkBackgroundLocationPermissionDeniedByUser
import com.base.locationsharewhite.utils.PermissionUtils.checkLocationPermission
......@@ -38,7 +39,6 @@ import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Marker
import com.google.gson.Gson
import java.util.concurrent.atomic.AtomicBoolean
class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
......@@ -60,6 +60,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
val recreated = changeLanguage(this)
if (recreated) return
mainPresenter = MainPresenter(this)
actionId = intent.extras?.getInt("actionId")
LogEx.logDebug(TAG, "initView actionId=$actionId", true)
......@@ -86,6 +89,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
mapFragment?.getMapAsync(this)
LocationLoginUtils.login()
if (!checkAllLocationPermission()) {
showAllowAllTimeDialog()
} else {
val flag = areNotificationsEnabled()
requestServiceLocationUpdates()
}
}
private var bannerShowed = AtomicBoolean(false)
......@@ -94,22 +104,16 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
val recreated = changeLanguage(this)
if (recreated) return
if (checkAllLocationPermission()) {
showNotificationDialog()
if (!bannerShowed.get()) {
bannerShowed.set(true)
AdsMgr.showBanner(binding.flAd)
}
}
mainPresenter.startLocationJob(lifecycleScope)
showAllowAllTimeDialog()
}
private fun showNotificationDialog() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
launcher.launch(arrayOf(Manifest.permission.POST_NOTIFICATIONS)) {
override fun onResume() {
super.onResume()
if (checkAllLocationPermission() || allowAllTimeDialog == null) {
if (!bannerShowed.get()) {
bannerShowed.set(true)
AdsMgr.showBanner(binding.flAd)
}
}
}
......@@ -119,35 +123,20 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
mainPresenter.cancelLocationJob()
}
private fun checkAllLocationPermission(): Boolean {
return checkLocationPermission() && checkBackgroundLocationPermission()
}
private fun showAllowAllTimeDialog() {
if (!checkAllLocationPermission()) {
// toast("显示权限始终允许弹窗")
if (allowAllTimeDialog == null) {
allowAllTimeDialog =
showLocationAllowAllTimeDialog(
setAction = {
sendAllAllowedNotification(this)
requestLocationAllowAllTime(launcher, jumpOutAction = {
LogEx.logDebug(TAG, "jumpOutAction")
}, permissionAllowAction = {})
},
dismissAction = {
allowAllTimeDialog = null
})
}
} else {
// toast("不显示权限始终允许弹窗")
allowAllTimeDialog?.dismiss()
allowAllTimeDialog = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
launcher.launch(arrayOf(Manifest.permission.POST_NOTIFICATIONS)) {}
}
requestServiceLocationUpdates()
if (allowAllTimeDialog == null) {
allowAllTimeDialog = showLocationAllowAllTimeDialog(
setAction = {
sendAllAllowedNotification(this)
requestLocationAllowAllTime(launcher, jumpOutAction = {
LogEx.logDebug(TAG, "jumpOutAction")
}, permissionAllowCallBack = {})
},
dismissAction = {
allowAllTimeDialog = null
})
}
}
......
......@@ -3,6 +3,7 @@ package com.base.locationsharewhite.ui.set
import android.content.Intent
import android.graphics.Color
import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.bean.ConstObject.appLanguageCountrySp
import com.base.locationsharewhite.bean.ConstObject.appLanguageSp
......@@ -28,7 +29,7 @@ class LanguageActivity : BaseActivity<ActivityLanguageBinding>() {
binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
isGuide = intent.extras?.getBoolean("isGuide") ?: false
AdsMgr.showBanner(binding.flBanner)
AdsMgr.showNative(binding.flAd, R.layout.layout_admob_app_exit)
adapter = LanguageAdapter(click = { item ->
})
......
package com.base.locationsharewhite.ui.splash
import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color
import android.os.Build
import androidx.lifecycle.lifecycleScope
import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsMgr
......@@ -59,6 +61,12 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
agreePrivacy()
}
initSolarEngine(true)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
launcher.launch(arrayOf(Manifest.permission.POST_NOTIFICATIONS)) {
LogEx.logDebug(TAG, "POST_NOTIFICATIONS")
}
}
}
override fun showAd() {
......
......@@ -2,6 +2,7 @@ package com.base.locationsharewhite.utils
import android.Manifest
import android.app.Activity
import android.app.NotificationManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
......@@ -14,6 +15,14 @@ import com.base.locationsharewhite.utils.IntentUtils.intentAppDetailsSettings
object PermissionUtils {
fun Context.areNotificationsEnabled(): Boolean {
val notificationManager =
this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val flag = notificationManager.areNotificationsEnabled()
return flag
}
fun Context.checkStorePermission(): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Environment.isExternalStorageManager()
......@@ -32,6 +41,10 @@ object PermissionUtils {
}
}
fun Context.checkAllLocationPermission(): Boolean {
return checkLocationPermission() && checkBackgroundLocationPermission()
}
fun Context.checkLocationPermission(): Boolean {
val fineLocationPermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
......@@ -56,9 +69,13 @@ object PermissionUtils {
fun Context.checkBackgroundLocationPermission(): Boolean {
return ActivityCompat.checkSelfPermission(
this, Manifest.permission.ACCESS_BACKGROUND_LOCATION
) == PackageManager.PERMISSION_GRANTED
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ActivityCompat.checkSelfPermission(
this, Manifest.permission.ACCESS_BACKGROUND_LOCATION
) == PackageManager.PERMISSION_GRANTED
} else {
true
}
}
fun Activity.checkBackgroundLocationPermissionDeniedByUser(): Boolean {
......@@ -94,7 +111,7 @@ object PermissionUtils {
fun Activity.requestLocationAllowAllTime(
launcher: ActivityLauncher,
jumpOutAction: (() -> Unit)? = null,//跳转到设置
permissionAllowAction: (() -> Unit)? = null//权限同意
permissionAllowCallBack: (() -> Unit)? = null//权限同意
) {
val TAG = "requestLocationAllowAllTime"
......@@ -115,7 +132,7 @@ object PermissionUtils {
LogEx.logDebug(TAG, "后台位置权限回调 backLocationResult=$backLocationResult")
if (backLocationResult) {
// toast("权限请求完毕")
permissionAllowAction?.invoke()
permissionAllowCallBack?.invoke()
} else {
val userBackLocationDeny = this.checkBackgroundLocationPermissionDeniedByUser()
LogEx.logDebug(TAG, "userBackLocationDeny userBackLocationDeny=$userBackLocationDeny 跳转设置")
......@@ -126,7 +143,7 @@ object PermissionUtils {
}
}
} else {
permissionAllowAction?.invoke()
permissionAllowCallBack?.invoke()
// toast("权限请求完毕")
}
} else {
......
......@@ -64,18 +64,17 @@
android:paddingTop="16dp"
android:paddingBottom="40dp"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:layout_constraintBottom_toTopOf="@id/fl_banner"
app:layout_constraintBottom_toTopOf="@id/fl_ad"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv"
app:spanCount="2"
tools:listitem="@layout/item_language" />
<FrameLayout
android:id="@+id/fl_banner"
<com.base.locationsharewhite.ads.NativeParentView
android:id="@+id/fl_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="60dp"
app:layout_constraintBottom_toBottomOf="parent" />
......
......@@ -66,6 +66,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment