Commit d0327d41 authored by wanglei's avatar wanglei

...

parent 512d392a
......@@ -6,6 +6,7 @@ import androidx.core.view.isVisible
import com.base.locationsharewhite.ads.AdsType
import com.base.locationsharewhite.helper.EventUtils
import com.base.locationsharewhite.helper.config.ConstConfig
import com.base.locationsharewhite.utils.LogEx
import com.google.android.gms.ads.AdListener
import com.google.android.gms.ads.AdLoader
import com.google.android.gms.ads.AdRequest
......@@ -32,7 +33,7 @@ class AdNativeMgr {
private val cacheItems = ConcurrentLinkedDeque<NativeAd>()
fun loadAd(context: Context, parent: ViewGroup? = null, layout: Int? = null) {
if (LimitUtils.isAdShow(AdsType.NATIVE)) return
if (!LimitUtils.isAdShow(AdsType.NATIVE)) return
val reqId = UUID.randomUUID().toString()
val obj = JSONObject()
......@@ -78,11 +79,13 @@ class AdNativeMgr {
fun show(parent: ViewGroup, layout: Int) {
if (!LimitUtils.isAdShow(AdsType.NATIVE)) {
cacheItems.clear()
LogEx.logDebug("AdNativeMgr", "0")
return
}
val nativeAd = cacheItems.peek()
if ((nativeAd == null).also {
if (it) {
LogEx.logDebug("AdNativeMgr", "1")
val obj2 = JSONObject()
obj2.put("reason", "no_ad")
obj2.put("ad_unit", "nativeAd")
......@@ -90,6 +93,7 @@ class AdNativeMgr {
}
} || (!adAvailable()).also {
if (it) {
LogEx.logDebug("AdNativeMgr", "2")
val obj2 = JSONObject()
obj2.put("ad_unit", "nativeAd")
EventUtils.event("ad_expire", ext = obj2)
......@@ -97,9 +101,11 @@ class AdNativeMgr {
}) {
//缓存过期了就清空
cacheItems.clear()
LogEx.logDebug("AdNativeMgr", "loadAd")
loadAd(parent.context.applicationContext, parent, layout)
return
}
LogEx.logDebug("AdNativeMgr", "3")
val obj = JSONObject()
obj.put("ad_unit", "nativeAd")
EventUtils.event("ad_prepare_show_native", ext = obj)
......
......@@ -5,6 +5,7 @@ import com.base.locationsharewhite.ads.AdsType
import com.base.locationsharewhite.helper.EventUtils
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.KotlinExt.toFormatTime4
import com.base.locationsharewhite.utils.LogEx
/**
......@@ -83,31 +84,42 @@ object LimitUtils {
AppPreferences.getInstance().put(NUM_REQUEST, 0)
AppPreferences.getInstance().put(NUM_CLICK, 0)
}
return !(isDisplayLimited.also {
if (it) EventUtils.event(
if (isDisplayLimited) {
LogEx.logDebug("LimitUtils", "isDisplayLimited")
EventUtils.event(
"ad_limit",
"current${getAdEventMsg(adsType)}Show=${
AppPreferences.getInstance()
.getInt(NUM_DISPLAY, 0)
} ${getAdEventMsg(adsType).lowercase()}_max_show=${AdsMgr.adsConfigBean?.numDisplayLimit}"
)
} || isClickLimited.also {
if (it) EventUtils.event(
}
if (isClickLimited) {
LogEx.logDebug("LimitUtils", "isClickLimited")
EventUtils.event(
"ad_limit",
"current${getAdEventMsg(adsType)}Click=${
AppPreferences.getInstance()
.getInt(NUM_CLICK, 0)
} ${getAdEventMsg(adsType).lowercase()}_max_click=${AdsMgr.adsConfigBean?.numClickLimit}"
)
} || isRequestLimited.also {
if (it) EventUtils.event(
}
if (isRequestLimited) {
LogEx.logDebug("LimitUtils", "isRequestLimited")
EventUtils.event(
"ad_limit",
"current${getAdEventMsg(adsType)}Request=${
AppPreferences.getInstance()
.getInt(NUM_REQUEST, 0)
} ${getAdEventMsg(adsType).lowercase()}_max_request=${AdsMgr.adsConfigBean?.numRequestLimit}"
)
})
}
LogEx.logDebug(
"LimitUtils",
"adsType=$adsType isDisplayLimited=$isDisplayLimited isClickLimited=$isClickLimited isRequestLimited=$isRequestLimited"
)
return !(isDisplayLimited || isClickLimited || isRequestLimited)
}
......
......@@ -8,15 +8,12 @@ import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import com.base.locationsharewhite.helper.EventUtils.event
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.LogEx.logDebug
import com.base.locationsharewhite.utils.ToastUtils.toast
class FcmReceiver : BroadcastReceiver() {
private val TAG = "FcmReceiver"
override fun onReceive(context: Context, intent: Intent) {
LogEx.logDebug("FCM", "FcmReceiver")
event("FCM_Received", null, null, false)
sendNotificationIfCan(context, PopupConstObject.POPUP_WHERE_FCM, null)
......
......@@ -6,7 +6,6 @@ import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import com.base.locationsharewhite.helper.EventUtils.event
import com.base.locationsharewhite.helper.MyApplication
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.ToastUtils.toast
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
......@@ -33,7 +32,6 @@ class MessagingService : FirebaseMessagingService() {
} finally {
}
event("FCM_Received", id, ext, false)
LogEx.logDebug("FCM", "MessagingService")
sendNotificationIfCan(this, PopupConstObject.POPUP_WHERE_FCM, null)
......@@ -45,9 +43,4 @@ class MessagingService : FirebaseMessagingService() {
}
}
}
companion object {
private const val TAG = "MessagingService"
}
}
\ No newline at end of file
......@@ -41,7 +41,7 @@ object NotificationHoverUtils {
for (i in 1..hoverCount) {
val time = i * hoverDelay
handler?.postDelayed(Runnable {
LogEx.logDebug(TAG, "handler ${MyApplication.PAUSED_VALUE}")
// LogEx.logDebug(TAG, "handler ${MyApplication.PAUSED_VALUE}")
if (MyApplication.PAUSED_VALUE == 1) {
handler?.removeCallbacksAndMessages(null)
} else {
......
......@@ -70,10 +70,6 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
locationPresenter = LocationPresenter(this, lifecycleScope)
// if (isLanguageRecreate(MyApplication.locationMapLanguage)) {
// return
// }
val mapFragment =
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
......@@ -195,9 +191,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
override fun initListener() {
super.initListener()
// if (isLanguageRecreate(MyApplication.locationMapLanguage)) {
// return
// }
onBackPressedDispatcher.addCallback {
finishToMain()
}
......@@ -276,9 +270,6 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
}
}
locationPresenter.refreshLocationCallBack = {
if (BuildConfig.DEBUG) {
// toast("updata ${it?.latitude} ${it?.longitude}")
}
LogEx.logDebug(TAG, "myLocation ${it}")
changeMyLocation(it, false, false, false)
}
......
......@@ -11,6 +11,9 @@ import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.ads.admob.AdBannerMgr
import com.base.locationsharewhite.ads.admob.AdInsertMgr
import com.base.locationsharewhite.databinding.ActivityMainBinding
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendAllAllowedNotification
import com.base.locationsharewhite.helper.BaseActivity
......@@ -35,6 +38,7 @@ 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 java.util.concurrent.atomic.AtomicBoolean
/**
* https://developer.android.com/about/versions/14/changes/data-safety?hl=zh-cn
......@@ -87,9 +91,17 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
LocationLoginUtils.login()
}
private var bannerShowed = AtomicBoolean(false)
override fun onResumeOneShoot() {
super.onResumeOneShoot()
showNotificationDialog()
if (checkAllLocationPermission()) {
showNotificationDialog()
if (!bannerShowed.get()) {
bannerShowed.set(true)
AdBannerMgr().show(binding.flAd)
}
}
mainPresenter.startLocationJob(lifecycleScope)
showAllowAllTimeDialog()
......@@ -110,8 +122,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
mainPresenter.cancelLocationJob()
}
private fun checkAllLocationPermission(): Boolean {
return checkLocationPermission() && checkBackgroundLocationPermission()
}
private fun showAllowAllTimeDialog() {
if (!checkLocationPermission() || !checkBackgroundLocationPermission()) {
if (!checkAllLocationPermission()) {
// toast("显示权限始终允许弹窗")
if (allowAllTimeDialog == null) {
allowAllTimeDialog =
......@@ -145,19 +161,29 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
showAppExitDialog()
}
binding.llMapLocation.setOnClickListener {
startActivity(Intent(this, LocationMapActivity::class.java))
showAdJump {
startActivity(Intent(this, LocationMapActivity::class.java))
}
}
binding.ivFangda.setOnClickListener {
startActivity(Intent(this, LocationMapActivity::class.java))
showAdJump {
startActivity(Intent(this, LocationMapActivity::class.java))
}
}
binding.llMap.setOnClickListener {
startActivity(Intent(this, LocationMapActivity::class.java))
showAdJump {
startActivity(Intent(this, LocationMapActivity::class.java))
}
}
binding.flMyLocationCode.setOnClickListener {
startActivity(Intent(this, LocationCodeActivity::class.java))
showAdJump {
startActivity(Intent(this, LocationCodeActivity::class.java))
}
}
binding.flShareMyLocation.setOnClickListener {
startActivity(Intent(this, LocationShareActivity::class.java))
showAdJump {
startActivity(Intent(this, LocationShareActivity::class.java))
}
}
binding.flHowUse.setOnClickListener {
startActivity(Intent(this, HowUseActivity::class.java))
......@@ -173,6 +199,22 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
}
}
private fun showAdJump(jumpAction: () -> Unit) {
AdInsertMgr().show(this, object : AdsShowCallBack() {
override fun close() {
jumpAction.invoke()
}
override fun failed() {
jumpAction.invoke()
}
override fun googleFailed() {
jumpAction.invoke()
}
})
}
private var reSetZoom = true
override fun onMapReady(googleMap: GoogleMap) {
map = googleMap
......
......@@ -12,6 +12,7 @@ import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.ads.admob.AdNativeMgr
import com.base.locationsharewhite.databinding.DialogAppExitBinding
import com.base.locationsharewhite.databinding.DialogMapTypeBinding
import com.base.locationsharewhite.databinding.DialogViewerMoreBinding
......
......@@ -213,4 +213,10 @@
</FrameLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/fl_ad"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -2,7 +2,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="345dp"
android:layout_height="250dp">
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
......@@ -94,7 +94,8 @@
android:layout_height="45dp"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="2dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_03b988_22"
android:gravity="center"
android:textAllCaps="false"
......@@ -102,6 +103,8 @@
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/ad_media"
tools:ignore="TouchTargetSizeCheck"
tools:layout_editor_absoluteX="16dp"
tools:text="Install" />
</androidx.constraintlayout.widget.ConstraintLayout>
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?><resources>
<string name="moment_please_s">请时刻...%1$d%%</string>
<string name="friend_location_map">朋友位置图</string>
<string name="view_friend_locations_on_the_map">在地图上查看好友位置</string>
<string name="my_location_code">我的位置代码</string>
<string name="share_location_code">分享我的位置</string>
<string name="share_my_location">分享我的位置</string>
<string name="how_to_use">如何使用?</string>
<string name="settings">设置</string>
<string name="friends">朋友们</string>
<string name="friend_tips">当您将位置代码发送给朋友并粘贴该代码以成功共享位置时,大约需要 1-10 分钟才能建立位置共享链接。请耐心等待!</string>
<string name="got_it">知道了</string>
<string name="do_not_show_again">不再显示</string>
<string name="no_friend_location_information">没有好友位置信息</string>
<string name="street_map">街道地图</string>
<string name="satellite_map">卫星地图</string>
<string name="location_code_tips">复制下面的位置代码并将其发送给朋友。当您的朋友将位置代码粘贴到应用程序中并单击“共享”时,您就可以获得他们的位置。</string>
<string name="copy">复制</string>
<string name="location_code_share_tips">请您的朋友向您发送位置代码。\n然后将您朋友的位置代码粘贴到下面,\n单击共享按钮共享您的位置。\n</string>
<string name="enter_others_location_code">输入其他\n位置代码</string>
<string name="share_my_location_da">分享我的位置</string>
<string name="what_do_you_want_to_do">你想让我做什么?</string>
<string name="share_my_nlocation">分享我的\n位置</string>
<string name="view_others_nlocation">查看其他\n位置</string>
<string name="how_to_share_my_location">如何分享我的位置?</string>
<string name="just_2_steps">只需 2 步</string>
<string name="how_share_location_step_1">1. 请您的朋友向您发送位置代码。</string>
<string name="how_share_location_step_2">2. 然后在下面粘贴您朋友的位置代码并单击共享按钮共享您的位置。</string>
<string name="more_two_use">温馨提示:需要两人以上同时下载AP才能使用</string>
<string name="next">下一个</string>
<string name="let_s_go">我们走吧</string>
<string name="how_to_view_others_location">如何查看别人的位置?</string>
<string name="how_view_other_step_1">1. 复制下面的位置代码并将其发送给朋友。\n</string>
<string name="how_view_other_step_2">2.当您的朋友在应用中粘贴LLocation\n代码并点击分享时,您就可以获得他们的位置\n</string>
<string name="hello_ndefault">您好,\n默认!</string>
<string name="rename">重命名</string>
<string name="language">语言</string>
<string name="rate_us">评价我们</string>
<string name="feedback">反馈</string>
<string name="about_us">关于我们</string>
<string name="share_app">分享应用程序</string>
<string name="enter_your_suggestion_please">请输入您的建议</string>
<string name="within_500_characters">500字以内</string>
<string name="thanks_for_your_feedback">感谢您的反馈</string>
<string name="thank_you_for_your_nsupport">感谢您的支持!\n</string>
<string name="cancel">取消</string>
<string name="rate">速度</string>
<string name="are_you_sure_you_want_to_exit_the_app">您确定要\n退出该应用程序吗?</string>
<string name="quit">辞职</string>
<string name="hello">你好</string>
<string name="a_simple_name_can_make_nothers_find_you_faster">一个简单的名字可以让\n其他人更快地找到你!</string>
<string name="enter_your_name">输入你的名字</string>
<string name="name_is_empty">名称为空</string>
<string name="me"></string>
<string name="delete">删除</string>
<string name="home"></string>
<string name="my_code">我的代码</string>
<string name="share">分享</string>
<string name="preparing_advertisement">准备广告</string>
<string name="enter_friend_nickname">输入好友昵称</string>
<string name="view">看法</string>
<string name="sharing_location_with_1_people">与 1 人共享位置</string>
<string name="location_sharing_not_enabled_yet">尚未启用位置共享</string>
<string name="copy_my_code_to_a_friend_to_view_his_her_location">将我的代码复制给朋友以查看他/她的位置!</string>
<string name="open">打开</string>
<string name="sort_by">排序方式</string>
<string name="allow_all_time_tip">您需要在设置中将“位置”设置为“始终允许”。如果没有,这个应用程序将无法正常工作。</string>
<string name="allow_all_time_step_1">1.点击下面的“打开设置”</string>
<string name="allow_all_time_step_2">2.单击“权限”,然后单击“位置”</string>
<string name="allow_all_time_step_3">3.设置为一直允许</string>
<string name="allow_all_the_time">允许所有时间</string>
<string name="open_settings">打开设置</string>
<string name="privacy_policy">隐私政策</string>
<string name="set_to_allow_all_the_time">设置为一直允许</string>
<string name="phone_tracker">电话追踪器</string>
<string name="background_for_location">应用程序在后台运行以进行位置更新</string>
<string name="sharing_location_people">与 1 人共享位置</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resources>
<string name="moment_please_s">请稍后...%1$d%%</string>
<string name="friend_location_map">朋友位置图</string>
<string name="view_friend_locations_on_the_map">在地图上查看好友位置</string>
<string name="my_location_code">我的位置代码</string>
<string name="share_location_code">分享我的位置</string>
<string name="share_my_location">分享我的位置</string>
<string name="how_to_use">如何使用?</string>
<string name="settings">设置</string>
<string name="friends">朋友们</string>
<string name="friend_tips">当您将位置代码发送给朋友并粘贴该代码以成功共享位置时,大约需要 1-10 分钟才能建立位置共享链接。请耐心等待!</string>
<string name="got_it">知道了</string>
<string name="do_not_show_again">不再显示</string>
<string name="no_friend_location_information">没有好友位置信息</string>
<string name="street_map">街道地图</string>
<string name="satellite_map">卫星地图</string>
<string name="location_code_tips">复制下面的位置代码并将其发送给朋友。当您的朋友将位置代码粘贴到应用程序中并单击“共享”时,您就可以获得他们的位置。</string>
<string name="copy">复制</string>
<string name="location_code_share_tips">请您的朋友向您发送位置代码。\n然后将您朋友的位置代码粘贴到下面,\n单击共享按钮共享您的位置。\n</string>
<string name="enter_others_location_code">输入其他\n位置代码</string>
<string name="share_my_location_da">分享我的位置</string>
<string name="what_do_you_want_to_do">你想让我做什么?</string>
<string name="share_my_nlocation">分享我的\n位置</string>
<string name="view_others_nlocation">查看其他\n位置</string>
<string name="how_to_share_my_location">如何分享我的位置?</string>
<string name="just_2_steps">只需 2 步</string>
<string name="how_share_location_step_1">1. 请您的朋友向您发送位置代码。</string>
<string name="how_share_location_step_2">2. 然后在下面粘贴您朋友的位置代码并单击共享按钮共享您的位置。</string>
<string name="more_two_use">温馨提示:需要两人以上同时下载AP才能使用</string>
<string name="next">下一个</string>
<string name="let_s_go">我们走吧</string>
<string name="how_to_view_others_location">如何查看别人的位置?</string>
<string name="how_view_other_step_1">1. 复制下面的位置代码并将其发送给朋友。\n</string>
<string name="how_view_other_step_2">2.当您的朋友在应用中粘贴LLocation\n代码并点击分享时,您就可以获得他们的位置\n</string>
<string name="hello_ndefault">您好,\n默认!</string>
<string name="rename">重命名</string>
<string name="language">语言</string>
<string name="rate_us">评价我们</string>
<string name="feedback">反馈</string>
<string name="about_us">关于我们</string>
<string name="share_app">分享应用程序</string>
<string name="enter_your_suggestion_please">请输入您的建议</string>
<string name="within_500_characters">500字以内</string>
<string name="thanks_for_your_feedback">感谢您的反馈</string>
<string name="thank_you_for_your_nsupport">感谢您的支持!\n</string>
<string name="cancel">取消</string>
<string name="rate">速度</string>
<string name="are_you_sure_you_want_to_exit_the_app">您确定要\n退出该应用程序吗?</string>
<string name="quit">辞职</string>
<string name="hello">你好</string>
<string name="a_simple_name_can_make_nothers_find_you_faster">一个简单的名字可以让\n其他人更快地找到你!</string>
<string name="enter_your_name">输入你的名字</string>
<string name="name_is_empty">名称为空</string>
<string name="me"></string>
<string name="delete">删除</string>
<string name="home"></string>
<string name="my_code">我的代码</string>
<string name="share">分享</string>
<string name="preparing_advertisement">准备广告</string>
<string name="enter_friend_nickname">输入好友昵称</string>
<string name="view">看法</string>
<string name="sharing_location_with_1_people">与 1 人共享位置</string>
<string name="location_sharing_not_enabled_yet">尚未启用位置共享</string>
<string name="copy_my_code_to_a_friend_to_view_his_her_location">将我的代码复制给朋友以查看他/她的位置!</string>
<string name="open">打开</string>
<string name="sort_by">排序方式</string>
<string name="allow_all_time_tip">您需要在设置中将“位置”设置为“始终允许”。如果没有,这个应用程序将无法正常工作。</string>
<string name="allow_all_time_step_1">1.点击下面的“打开设置”</string>
<string name="allow_all_time_step_2">2.单击“权限”,然后单击“位置”</string>
<string name="allow_all_time_step_3">3.设置为一直允许</string>
<string name="allow_all_the_time">允许所有时间</string>
<string name="open_settings">打开设置</string>
<string name="privacy_policy">隐私政策</string>
<string name="set_to_allow_all_the_time">设置为一直允许</string>
<string name="phone_tracker">电话追踪器</string>
<string name="background_for_location">应用程序在后台运行以进行位置更新</string>
<string name="sharing_location_people">与 1 人共享位置</string>
</resources>
\ No newline at end of file
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