Commit 71f83fde authored by wanglei's avatar wanglei

...

parent dbea0a0b
......@@ -35,6 +35,14 @@
android:theme="@style/Theme.ScanQR"
tools:targetApi="31">
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:exported="false"
android:multiprocess="true"
android:theme="@android:style/Theme.Translucent"
tools:ignore="MissingClass" />
<activity
android:name=".ui.start.StartActivity"
android:exported="true"
......@@ -48,6 +56,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.main.MainActivity"
android:exported="false"
......
package com.base.scanqr.ads
import android.app.Activity
import android.app.Dialog
import android.content.Context
import java.lang.ref.WeakReference
class adState<T>() {
class AdState<T>() {
var adDialog: Dialog? = null
......@@ -84,63 +83,3 @@ class adState<T>() {
}
}
/**
* 特定广告管理基类
* @param T 缓存广告的类
*/
abstract class BaseAdMgr<T> {
/**
* 广告展示回调
*/
protected var showCallBack: AdsShowCallBack? = null
/**
* 当前缓存的广告
*/
protected var currentAd: T? = null
/**
* 是否正在缓存加载广告
*/
protected var loadingAd: Boolean = false
/**
* 是否正在显示广告
*/
protected var showingAd: Boolean = false
/**
* 用于保存引用现有页面,在此页面显示广告(因为要等待广告加载完毕)
*/
protected var activityRef: WeakReference<Activity>? = null
/**
* 上一次的缓存成功时间
*/
protected var lastLoadTime: Long = 0
/**
* 预加载广告
*
* @param context 加载所用的上下文,一般使用appContext
*/
abstract fun loadAd(context: Context, isUnLimit: Boolean = true, adEvent: AdEvent)
/**
* 广告显示
*
* @param activity 当前页面
*/
abstract fun show(activity: Activity, isUnLimit: Boolean = true, adEvent: AdEvent, showCallBack: AdsShowCallBack? = null)
/**
* 预加载的缓存超时判断
*
* @return true:没有超时 false:超时需要重新加载
*/
abstract fun adAvailable(): Boolean
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import com.base.scanqr.ads.AdEvent
import com.base.scanqr.ads.AdsShowCallBack
import com.base.scanqr.ads.AdsType
import com.base.scanqr.ads.LimitUtils
import com.base.scanqr.ads.adState
import com.base.scanqr.ads.AdState
import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.FullScreenContentCallback
......@@ -22,7 +22,7 @@ import java.lang.ref.WeakReference
*/
class AdInsertMgr {
private var adState = adState<InterstitialAd>()
private var adState = AdState<InterstitialAd>()
private var showCallBack: AdsShowCallBack? = null
fun show(activity: Activity, isUnLimit: Boolean, adEvent: AdEvent, showCallBack: AdsShowCallBack?) {
......
......@@ -2,12 +2,14 @@ package com.base.scanqr.ads.admob
import android.app.Activity
import android.content.Context
import android.nfc.Tag
import com.base.scanqr.GlobalConfig
import com.base.scanqr.ads.AdEvent
import com.base.scanqr.ads.AdsShowCallBack
import com.base.scanqr.ads.AdsType
import com.base.scanqr.ads.LimitUtils
import com.base.scanqr.ads.adState
import com.base.scanqr.ads.AdState
import com.base.scanqr.utils.LogEx
import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.FullScreenContentCallback
......@@ -20,7 +22,8 @@ import java.lang.ref.WeakReference
*/
class AdOpenMgr {
private val adState = adState<AppOpenAd>()
private val TAG = "AdOpenMgr"
private val adState = AdState<AppOpenAd>()
private var showCallBack: AdsShowCallBack? = null
......@@ -62,6 +65,7 @@ class AdOpenMgr {
}
private fun showReadyAd(adEvent: AdEvent, activity: Activity) {
LogEx.logDebug(TAG, "activity=$activity showReadyAd")
adState.currentAd?.run {
fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdShowedFullScreenContent() {
......@@ -72,6 +76,7 @@ class AdOpenMgr {
adState.onAdDisplayed()
//计数
LimitUtils.addDisplayNum()
}
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
......@@ -93,6 +98,7 @@ class AdOpenMgr {
adState.onAdHidden()
loadAd(activity.applicationContext, false, AdmobEvent("openAd", "preload"))
}
......
......@@ -12,7 +12,7 @@ import com.base.scanqr.ads.AdEvent
import com.base.scanqr.ads.AdsShowCallBack
import com.base.scanqr.ads.AdsType
import com.base.scanqr.ads.LimitUtils
import com.base.scanqr.ads.adState
import com.base.scanqr.ads.AdState
import java.lang.ref.WeakReference
/**
......@@ -20,7 +20,7 @@ import java.lang.ref.WeakReference
*/
class MaxInsertMgr {
private var adState = adState<MaxInterstitialAd>()
private var adState = AdState<MaxInterstitialAd>()
private var showCallBack: AdsShowCallBack? = null
fun show(
......
......@@ -11,7 +11,7 @@ import com.base.scanqr.ads.AdEvent
import com.base.scanqr.ads.AdsShowCallBack
import com.base.scanqr.ads.AdsType
import com.base.scanqr.ads.LimitUtils
import com.base.scanqr.ads.adState
import com.base.scanqr.ads.AdState
import java.lang.ref.WeakReference
/**
......@@ -19,7 +19,7 @@ import java.lang.ref.WeakReference
*/
class MaxOpenMgr {
private val adState = adState<MaxAppOpenAd>()
private val adState = AdState<MaxAppOpenAd>()
private var showCallBack: AdsShowCallBack? = null
fun show(activity: Activity, isUnLimit: Boolean, adEvent: AdEvent, showCallBack: AdsShowCallBack?) {
......
......@@ -30,7 +30,7 @@ class NotificationSendBean(
const val POPUP_WHERE_FILE_JOB = "FileJob"
const val ACTION_ID_STAY_SCAN = "action_id_scan_1"
const val ACTION_ID_SCAN = "action_id_scan_2"
const val ACTION_ID_STAY_SCAN = "action_id_stay_scan"
const val ACTION_ID_SCAN = "action_id_scan"
}
}
\ No newline at end of file
......@@ -149,8 +149,8 @@ object NotificationManager {
//当天推送次数
val count = popupConfigBean.popupCount
if (dayPopupCount > count) {
LogEx.logDebug("canSendNotification", "count")
EventUtils.event("Notification_Error", "dayPopupCount=$dayPopupCount count=$count ")
LogEx.logDebug(TAG, "dayPopupCount=$dayPopupCount count=$count")
EventUtils.event("Notification_Error", "dayPopupCount=$dayPopupCount count=$count")
return false
}
......@@ -160,7 +160,7 @@ object NotificationManager {
val calendar = Calendar.getInstance()
val currentHour = calendar.get(Calendar.HOUR_OF_DAY)
if (currentHour !in start until end) {
LogEx.logDebug("canSendNotification", "start-end currentHour=$currentHour start=$start end=$end")
LogEx.logDebug(TAG, "start=$start end=$end currentHour=$currentHour")
EventUtils.event("Notification_Error", "start=$start end=$end currentHour=$currentHour")
return false
}
......@@ -169,8 +169,8 @@ object NotificationManager {
val interval = popupConfigBean.popupInterval
val passedTime = System.currentTimeMillis() - lastPopupTime
if (passedTime < interval * 60 * 1000L) {
LogEx.logDebug(TAG, "interval=$interval passedTime=$passedTime")
EventUtils.event("Notification_Error", "interval=$interval passedTime=$passedTime")
LogEx.logDebug("canSendNotification", "interval=$interval passedTime=$passedTime")
return false
}
return true
......
......@@ -20,7 +20,7 @@ class ScreenStatusReceiver : BroadcastReceiver() {
private val TAG = "ScreenStatusReceiver"
override fun onReceive(context: Context, intent: Intent) {
LogEx.logDebug(TAG,"onReceive")
LogEx.logDebug(TAG, "onReceive")
val action = intent.action
when (Objects.requireNonNull<String?>(action)) {
Intent.ACTION_SCREEN_ON -> isDeviceInteractive = true
......@@ -33,8 +33,12 @@ class ScreenStatusReceiver : BroadcastReceiver() {
isSecureLockActive = false
if (isDeviceInteractive && !isSecureLockActive) {
if (popupConfigBean.screenS) {
LogEx.logDebug(TAG,"onReceive submitSendBean")
val sendBean = NotificationSendBean(context, POPUP_WHERE_LOCK, canSend = { true }, sendSuccess = {})
LogEx.logDebug(TAG, "onReceive submitSendBean")
val sendBean = NotificationSendBean(
context,
POPUP_WHERE_LOCK,
canSend = { canScreenStatusReceiverPush() },
sendSuccess = { saveScreenPushedData() })
NotificationManager.submitSendBean(sendBean)
}
}
......@@ -118,6 +122,7 @@ class ScreenStatusReceiver : BroadcastReceiver() {
"popupScreenCount=$popupScreenCount where=$POPUP_WHERE_LOCK"
)
}
LogEx.logDebug(TAG, "canScreenStatusReceiverPush flag=$flag")
return flag
}
......@@ -127,6 +132,7 @@ class ScreenStatusReceiver : BroadcastReceiver() {
fun saveScreenPushedData() {
todayScreenPush += 1
screenLastPushTime = System.currentTimeMillis()
LogEx.logDebug(TAG, "saveScreenPushedData")
}
}
......
......@@ -2,6 +2,7 @@ package com.base.scanqr.ui.main
import android.content.Intent
import android.graphics.Color
import android.util.Log
import android.view.LayoutInflater
import android.widget.TextView
import androidx.activity.addCallback
......@@ -12,6 +13,7 @@ import com.base.scanqr.ads.AdsMgr
import com.base.scanqr.base.BaseActivity
import com.base.scanqr.bean.ConstObject.mainStartTimes
import com.base.scanqr.bean.HomeTabUIBean
import com.base.scanqr.bean.NotificationSendBean.Companion.ACTION_ID_SCAN
import com.base.scanqr.bean.NotificationSendBean.Companion.ACTION_ID_STAY_SCAN
import com.base.scanqr.databinding.ActivityMainBinding
import com.base.scanqr.databinding.ItemHomeTabBinding
......@@ -89,6 +91,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
LogEx.logDebug(TAG, "onNewIntent")
//setIntent需要调用
setIntent(intent)
handleActionIdJump()
}
......@@ -96,12 +101,13 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
val actionId = intent.extras?.getString("actionId")
LogEx.logDebug(TAG, "actionId=$actionId")
when (actionId) {
ACTION_ID_STAY_SCAN -> {
ACTION_ID_STAY_SCAN, ACTION_ID_SCAN -> {
val defaultTab = binding.tabLayout.getTabAt(1)
defaultTab?.select()
defaultTab?.setSelected()
}
}
intent.extras?.clear()
}
private fun initTab() {
......
......@@ -8,6 +8,7 @@ import com.base.scanqr.ads.AdsShowCallBack
import com.base.scanqr.base.BaseActivity
import com.base.scanqr.bean.ConstObject
import com.base.scanqr.bean.ConstObject.isFirstLauncher
import com.base.scanqr.bean.NotificationSendBean.Companion.ACTION_ID_SCAN
import com.base.scanqr.bean.NotificationSendBean.Companion.ACTION_ID_STAY_SCAN
import com.base.scanqr.databinding.ActivityStartBinding
import com.base.scanqr.service.StayJobService.Companion.startJob
......@@ -110,14 +111,21 @@ class StartActivity : BaseActivity<ActivityStartBinding>(ActivityStartBinding::i
val actionId = intent.extras?.getString("actionId")
LogEx.logDebug(TAG, "actionId=$actionId")
when (actionId) {
ACTION_ID_STAY_SCAN -> {
ACTION_ID_STAY_SCAN, ACTION_ID_SCAN -> {
LogEx.logDebug(TAG, "actionId MainActivity")
startActivity(Intent(this, MainActivity::class.java).apply {
putExtra("actionId", actionId)
addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
})
}
else -> {
startActivity(Intent(this, MainActivity::class.java).apply {
putExtra("actionId", actionId)
addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
})
}
}
startActivity(Intent(this, MainActivity::class.java).apply {
addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
putExtra("actionId", actionId)
})
finish()
}
......
......@@ -5,7 +5,6 @@
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingVertical="16dp"
tools:ignore="DisableBaselineAlignment">
......
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