Commit 824bf5c1 authored by guest's avatar guest

修改广告需求

parent 40f47b95
package com.base.pdfviewerscannerwhite
import com.base.pdfviewerscannerwhite.utils.AppPreferences
object GlobalConfig {
// 包名
const val PACKAGE_NAME = "com.cleaner.recovery.tencgog"
// 域名
/**
* Url Event 上报接口
*/
const val URL_EVENT = "https://rp.rocioxynv2.online"
/**
* Url Api 业务接口
*/
const val URL_API = "https://api.rocioxynv2.online"
/**
* Url Privacy 隐私链接
*/
const val URL_PRIVACY = "https://sites.google.com/view/recpri/rec"
/**
* Url Use 使用条款
*/
const val URL_USE = ""
/**
* Key Aes 加密key
*/
const val KEY_AES = "5s1q2jusawhorcz0"
/**
* Key solar 归因key
*/
const val KEY_SOLAR = ""
inline val ID_ADMOB_APPLICATION get() = "ca-app-pub-3940256099942544~3347511713"
// admob广告位id
inline val ID_ADMOB_OPEN get() = "ca-app-pub-3940256099942544/9257395921"
inline val ID_ADMOB_INTER get() = "ca-app-pub-3940256099942544/1033173712"
inline val ID_ADMOB_NATIVE get() = "ca-app-pub-3940256099942544/2247696110"
inline val ID_ADMOB_BANNER get() = "ca-app-pub-3940256099942544/9214589741"
inline val ID_ADMOB_REWARD get() = ""
// max广告位id
inline val ID_MAX_OPEN get() = "d1d943cdd3127c90"
inline val ID_MAX_INTER get() = "b31e7f6d11ee659e"
inline val ID_MAX_NATIVE get() = "96e8fe78b0efc5d1"
inline val ID_MAX_BANNER get() = "ca-app-pub-3940256099942544/9214589741"
inline val ID_MAX_REWARD get() = ""
/**
* Key MAX MAX广告初始化key
*/
const val KEY_MAX =
"GGPreND6SRmCt1zJgn5faiLGD8c2PVGPLgPpSg7cHanVTud1DhtuI9MmteTqlEviaJ57WnxW68kQDaATJ5z3cW"
//
const val KEY_INIT = "key_init"
const val KEY_AD = "sAds"
const val KEY_BLACKLIST = "blacklist"
const val KEY_CLEANUP_SIZE = "key_cleanup_size"
const val KEY_SCORE = "key_score"
const val KEY_APP_BACKGROUND = "key_app_background"
const val KEY_NOTIFICATION_ID = "key_notification_id"
const val KEY_HOME_COUNT = "key_home_count"
const val KEY_INSTALL_TIME = "key_install_time"
const val KEY_CLEAN_LAST_TIME = "key_clean_last_time"
const val KEY_NOT_CLEAN_TIME = "key_not_clean_time"
const val KEY_UUID = "key_uuid"
const val KEY_GOOGLE_ADVERTISER_ID = "key_google_advertiser_id"
const val KEY_DEVICE_NAME = "key_device_name"
const val KEY_IS_FIRST = "is_first"
const val KEY_REFERRER = "referrer"
const val KEY_TOKEN = "token"
const val KEY_TOKEN_SUCCESS = "token_success"
const val KEY_PUSH_REPORT_SWITCH = "push_report_switch"
const val DEFAULT_SWITCH = "1"
inline var isInit
get() = AppPreferences.getInstance().getBoolean(KEY_INIT,false)
set(value) = AppPreferences.getInstance().put(KEY_INIT, value)
inline var isFirst
get() = AppPreferences.getInstance().getBoolean(KEY_IS_FIRST, true)
set(value) = AppPreferences.getInstance().put(KEY_IS_FIRST, value)
inline var useBlacklist
get() = AppPreferences.getInstance().getBoolean(KEY_BLACKLIST,false)
set(value) = AppPreferences.getInstance().put(KEY_BLACKLIST, value)
inline var useAdmob
get() = AppPreferences.getInstance().getString(KEY_AD, "1").toInt()
set(value) = AppPreferences.getInstance().put(KEY_AD, value)
const val KEY_GET_CONFIG = "getConfigInterval"
}
\ No newline at end of file
...@@ -3,35 +3,66 @@ package com.base.pdfviewerscannerwhite.ads ...@@ -3,35 +3,66 @@ package com.base.pdfviewerscannerwhite.ads
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.animation.ValueAnimator.INFINITE import android.animation.ValueAnimator.INFINITE
import android.app.AlertDialog import android.app.AlertDialog
import android.app.Dialog
import android.content.Context import android.content.Context
import android.os.CountDownTimer
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import android.widget.TextView
import androidx.core.view.isVisible
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.databinding.DialogAdLoadingBinding
import com.base.pdfviewerscannerwhite.databinding.DialogAdPreparingBinding import com.base.pdfviewerscannerwhite.databinding.DialogAdPreparingBinding
object AdDialog { class AdDialog(context: Context, block: (() -> Unit)? = null) :
fun Context.showAdPreparingDialog(): AlertDialog { Dialog(context, R.style.CustomDialogStyle) {
val binding = DialogAdPreparingBinding.inflate(LayoutInflater.from(this)) private var countdownText: TextView? = null
val dialog = AlertDialog.Builder(this).create()
dialog.setView(binding.root) init {
dialog.setCancelable(false) val binding = DialogAdLoadingBinding.inflate(LayoutInflater.from(context))
dialog.setCanceledOnTouchOutside(false) setContentView(binding.root)
setCancelable(false)
dialog.show() countdownText = binding.tvCountdown
val params = dialog.window?.attributes }
params?.width = resources.getDimensionPixelOffset(R.dimen.dp_200)
params?.height = resources.getDimensionPixelOffset(R.dimen.dp_146) fun setButtonClickListener(viewId: Int, listener: () -> Unit) {
dialog.window?.attributes = params val button = findViewById<View>(viewId) as? TextView
dialog.window?.setBackgroundDrawableResource(android.R.color.transparent) button?.setOnClickListener {
listener.invoke()
// 创建一个旋转动画 }
val rotateAnimator = ObjectAnimator.ofFloat(binding.iv, "rotation", 0f, -360f) }
rotateAnimator.setDuration(1000) // 设置动画持续时间为1000毫秒
rotateAnimator.repeatCount = INFINITE fun setCountdownText(viewId: Int) {
rotateAnimator.interpolator = LinearInterpolator() // 设置插值器为线性插值 countdownText = findViewById(viewId)
rotateAnimator.start() }
return dialog fun updateCountdownText(seconds: String) {
countdownText?.text = seconds
}
fun start() {
countdownTimer.start()
}
override fun dismiss() {
super.dismiss()
// 清理引用
countdownText = null
}
private val countdownTimer = object : CountDownTimer(3000, 1000) {
override fun onTick(millisUntilFinished: Long) {
val seconds = (millisUntilFinished / 1000).toInt() + 1
countdownText?.text = "(${seconds})"
countdownText?.isVisible = true
}
override fun onFinish() {
block?.invoke()
countdownText?.isVisible = false
dismiss()
}
} }
} }
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ads
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.inter_limit_click
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.inter_limit_request
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.inter_limit_show
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.native_limit_click
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.native_limit_request
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.native_limit_show
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.open_limit_click
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.open_limit_request
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.open_limit_show
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale
object AdDisplayUtils {
//region open
private val open_max_request = AppPreferences.getInstance().getString(open_limit_request, "15").toInt()
private val open_max_show = AppPreferences.getInstance().getString(open_limit_show, "10").toInt()
private val open_max_click = AppPreferences.getInstance().getString(open_limit_click, "1").toInt()
fun incrementOpenRequestCount() {
currentOpenRequest += 1
}
fun incrementOpenShow() {
currentOpenShow += 1
}
fun incrementClickShow() {
currentOpenClick += 1
}
//当前开屏请求次数
private var currentOpenRequest = 0
get() {
return AppPreferences.getInstance().getInt("currentOpenRequest_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenRequest_${currentDate()}", value, true)
}
//当前开屏展示次数
private var currentOpenShow = 0
get() {
return AppPreferences.getInstance().getInt("currentOpenShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenShow_${currentDate()}", value, true)
}
//当前开屏点击次数
private var currentOpenClick = 0
get() {
return AppPreferences.getInstance().getInt("currentOpenClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentOpenClick_${currentDate()}", value, true)
}
fun shouldShowOpenAd(): Boolean {
if (currentOpenRequest > open_max_request) {
LogEx.logDebug(TAG, "currentOpenRequest=$currentOpenRequest open_max_request=$open_max_request")
EventUtils.event("ad_limit", "currentOpenRequest=$currentOpenRequest open_max_request=$open_max_request")
return false
}
if (currentOpenShow > open_max_show) {
LogEx.logDebug(TAG, "currentOpenShow=$currentOpenShow open_max_show=$open_max_show")
EventUtils.event("ad_limit", "currentOpenShow=$currentOpenShow open_max_show=$open_max_show")
return false
}
if (currentOpenClick > open_max_click) {
LogEx.logDebug(TAG, "currentOpenClick=$currentOpenClick open_max_click=$open_max_click")
EventUtils.event("ad_limit", "currentOpenClick=$currentOpenClick open_max_click=$open_max_click")
return false
}
return true
}
//endregion
//region inter
private val inter_max_request = AppPreferences.getInstance().getString(inter_limit_request, "15").toInt()
private val inter_max_show = AppPreferences.getInstance().getString(inter_limit_show, "10").toInt()
private val inter_max_click = AppPreferences.getInstance().getString(inter_limit_click, "1").toInt()
fun incrementInterRequestCount() {
currentInterRequest += 1
}
fun incrementInterShowCount() {
currentInterShow += 1
}
fun incrementInterClickCount() {
currentInterClick += 1
}
//当前插页请求次数
private var currentInterRequest = 0
get() {
return AppPreferences.getInstance().getInt("currentInterRequest_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentInterRequest_${currentDate()}", value, true)
}
//当前插页展示次数
private var currentInterShow = 0
get() {
return AppPreferences.getInstance().getInt("currentInterShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentInterShow_${currentDate()}", value, true)
}
//当前插页点击次数
private var currentInterClick = 0
get() {
return AppPreferences.getInstance().getInt("currentInterClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentInterClick_${currentDate()}", value, true)
}
fun shouldShowInterAd(): Boolean {
if (currentInterRequest > inter_max_request) {
LogEx.logDebug(TAG, "currentInterRequest=$currentInterRequest inter_max_request=$inter_max_request")
EventUtils.event("ad_limit", "currentInterRequest=$currentInterRequest inter_max_request=$inter_max_request")
return false
}
if (currentInterShow > inter_max_show) {
LogEx.logDebug(TAG, "currentInterShow=$currentInterShow inter_max_show=$inter_max_show")
EventUtils.event("ad_limit", "currentInterShow=$currentInterShow inter_max_show=$inter_max_show")
return false
}
if (currentInterClick > inter_max_click) {
LogEx.logDebug(TAG, "currentInterClick=$currentInterClick inter_max_click=$inter_max_click")
EventUtils.event("ad_limit", "currentInterClick=$currentInterClick inter_max_click=$inter_max_click")
return false
}
return true
}
//endregion
//region native
private val native_max_request = AppPreferences.getInstance().getString(native_limit_request, "15").toInt()
private val native_max_show = AppPreferences.getInstance().getString(native_limit_show, "10").toInt()
private val native_max_click = AppPreferences.getInstance().getString(native_limit_click, "1").toInt()
fun incrementNativeRequestCount() {
currentNativeRequest += 1
}
fun incrementNativeShowCount() {
currentNativeShow += 1
}
fun incrementNativeClickCount() {
currentNativeClick += 1
}
private var currentNativeRequest = 0
get() {
return AppPreferences.getInstance().getInt("currentNativeRequest_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeRequest_${currentDate()}", value, true)
}
private var currentNativeShow = 0
get() {
return AppPreferences.getInstance().getInt("currentNativeShow_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeShow_${currentDate()}", value, true)
}
private var currentNativeClick = 0
get() {
return AppPreferences.getInstance().getInt("currentNativeClick_${currentDate()}", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("currentNativeClick_${currentDate()}", value, true)
}
fun shouldShowNative(): Boolean {
if (currentNativeRequest > native_max_request) {
LogEx.logDebug(TAG, "currentNativeRequest=$currentNativeRequest native_max_request=$native_max_request")
EventUtils.event("ad_limit", "currentNativeRequest=$currentNativeRequest native_max_request=$native_max_request")
return false
}
if (currentNativeShow > native_max_show) {
LogEx.logDebug(TAG, "currentNativeShow=$currentNativeShow native_max_show=$native_max_show")
EventUtils.event("ad_limit", "currentNativeShow=$currentNativeShow native_max_show=$native_max_show")
return false
}
if (currentNativeClick > native_max_click) {
LogEx.logDebug(TAG, "currentNativeClick=$currentNativeClick native_max_click=$native_max_click")
EventUtils.event("ad_limit", "currentNativeClick=$currentNativeClick native_max_click=$native_max_click")
return false
}
return true
}
//endregion
private val TAG = "AdDisplayUtils"
private fun currentDate(): String {
val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val currentDate = Calendar.getInstance().time
return dateFormat.format(currentDate)
}
}
package com.base.pdfviewerscannerwhite.ads
import android.app.Activity
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.google.android.gms.ads.MobileAds
import java.util.concurrent.atomic.AtomicBoolean
object AdmobHelper {
//开屏限制
const val open_limit_request = "open_limit_request"
const val open_limit_show = "open_limit_show"
const val open_limit_click = "open_limit_click"
//插页限制
const val inter_limit_request = "inter_limit_request"
const val inter_limit_show = "inter_limit_show"
const val inter_limit_click = "inter_limit_click"
//原生广告限制
const val native_limit_request = "native_limit_request"
const val native_limit_show = "native_limit_show"
const val native_limit_click = "native_limit_click"
//是否展示多语言
val showLanPage = "showLanPage"
//开屏加载ad时间
val open_ad_loading = "open_ad_loading"
//创建pdf加载ad时间
val create_pdf_loading = "create_pdf_loading"
//删除文件
val delete_loading = "delete_loading"
//打开文件
val open_file_loading = "open_file_loading"
//合并pdf
val merge_loading = "merge_loading"
//拆分pdf
val split_loading = "split_loading"
//可请求时间段(由 x 定义)
const val ad_request_period = "ad_request_interval"
//可请求时间段内允许的最大请求数(由 y 定义)
const val ad_period_max_request = "ad_period_max_request"
//可请求时间段间隔时间
const val ad_request_period_interval = "ad_request_period_interval"
var isAdInit = AtomicBoolean(false)
fun initAdmobAd(activity: Activity) {
MobileAds.initialize(MyApplication.context) { initializationStatus ->
isAdInit.set(true)
EventUtils.event("AdmobInit", "AdmobInit")
AdmobNativeUtils.loadNativeAd()
AdmobInterstitialUtils.loadInterstitialAd(activity)
}
}
//上次展示广告时间关闭赋值,通用开屏和插页
var lastShowedOnHiddenTime = 0L
get() {
return AppPreferences.getInstance().getLong("lastShowedOnHiddenTime", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastShowedOnHiddenTime", value, true)
}
/**
* 通用广告条件判断
*/
fun canCommonShowAd(): Boolean {
val interval = AppPreferences.getInstance().getString("ad_interval", "10").toInt()
if (System.currentTimeMillis() - lastShowedOnHiddenTime < interval * 1000L) {
return false
}
return true
}
//上次scan展示ad时间
var lastScanShowAd = 0L
get() {
return AppPreferences.getInstance().getLong("lastScanShowAd", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastScanShowAd", value, true)
}
//是否显示扫描功能ad
fun isShowScanInter(): Boolean {
val interval = AppPreferences.getInstance().getString("scan_ad_interval", "10").toInt()
return System.currentTimeMillis() - lastScanShowAd > interval * 1000L
}
//上次打开文档展示ad时间
var lastOpenDocumentShowAd = 0L
get() {
return AppPreferences.getInstance().getLong("lastOpenDocumentShowAd", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastOpenDocumentShowAd", value, true)
}
//打开文档是否展示广告
fun isShowOpenDocumentInter(): Boolean {
val interval = AppPreferences.getInstance().getString("open_document_ad_interval", "10").toInt()
return System.currentTimeMillis() - lastOpenDocumentShowAd > interval * 1000L
}
var lastCloseDocumentShowAd = 0L
get() {
return AppPreferences.getInstance().getLong("lastCloseDocumentShowAd", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastCloseDocumentShowAd", value, true)
}
fun isShowCloseDocumentInter(): Boolean {
val interval = AppPreferences.getInstance().getString("close_document_ad_interval", "10").toInt()
return System.currentTimeMillis() - lastCloseDocumentShowAd > interval * 1000L
}
fun isShowCloseDocument(): Boolean {
val status = AppPreferences.getInstance().getString("close_document_ad_show", "0").toInt()
return status == 1
}
fun isShowRvNativeAd(): Boolean {
val status = AppPreferences.getInstance().getString("rv_native_ad_show", "0").toInt()
return status == 1
}
fun isBackShowAd(): Boolean {
val status = AppPreferences.getInstance().getString("is_back_show_ad", "0").toInt()
return status == 1
}
}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ads.admob
import android.content.Context
import android.os.Bundle
import android.view.ViewGroup
import android.view.ViewTreeObserver
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.helper.ConfigHelper
import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.google.ads.mediation.admob.AdMobAdapter
import com.google.android.gms.ads.AdListener
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AdView
import java.util.UUID
object AdmobBannerUtils {
private const val TAG = "AdmobBannerUtils"
private var adView: AdView? = null
private var listener: ViewTreeObserver.OnGlobalLayoutListener? = null
fun showCollapsibleBannerAd(
context: Context,
collapsible: Boolean = true,
parent: ViewGroup,
adClose: (() -> Unit)? = null
) {
val isShowBanner = AppPreferences.getInstance().getString("isShowBanner", "0").toInt()
if (isShowBanner == 0) {
return
}
parent.removeAllViews()
adView?.destroy()
adView = null
adView = AdView(context)
// adView?.apply {
// onPaidEventListener = AdmobEvent.EventOnPaidEventListener(this)
// }
parent.addView(adView)
adView?.onPaidEventListener = AdmobEvent.EventOnPaidEventListener(adView)
listener = ViewTreeObserver.OnGlobalLayoutListener {
val screenPixelDensity = context.resources.displayMetrics.density
val adWidth = (parent.width / screenPixelDensity).toInt()
val adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(context, adWidth)
adView?.adUnitId = if (BuildConfig.DEBUG) ConfigHelper.bannerAdmobIdTest else ConfigHelper.bannerAdmobId
adView?.setAdSize(adSize)
loadCollapsibleBanner(collapsible, adClose)
parent.viewTreeObserver.removeOnGlobalLayoutListener(listener)
}
parent.viewTreeObserver.addOnGlobalLayoutListener(listener)
}
private fun loadCollapsibleBanner(collapsible: Boolean, adClose: (() -> Unit)?) {
val extras = Bundle()
if (collapsible) {
extras.putString("collapsible", "bottom")
extras.putString("collapsible_request_id", UUID.randomUUID().toString())
}
val adRequest =
AdRequest.Builder().addNetworkExtrasBundle(AdMobAdapter::class.java, extras).build()
adView?.adListener =
object : AdListener() {
override fun onAdLoaded() {
LogEx.logDebug(TAG, "onAdLoaded")
}
override fun onAdOpened() {
LogEx.logDebug(TAG, "onAdOpened")
}
override fun onAdClosed() {
super.onAdClosed()
LogEx.logDebug(TAG, "onAdClosed")
adClose?.invoke()
}
}
adView?.loadAd(adRequest)
}
}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ads.admob
import android.app.Activity
import android.app.Dialog
import android.widget.Toast
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.ads.AdDialog.showAdPreparingDialog
import com.base.pdfviewerscannerwhite.ads.AdDisplayUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.clickAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.pullAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.showAd
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.lastShowedOnHiddenTime
import com.base.pdfviewerscannerwhite.helper.ConfigHelper
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.FullScreenContentCallback
import com.google.android.gms.ads.LoadAdError
import com.google.android.gms.ads.interstitial.InterstitialAd
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback
import org.json.JSONObject
import java.util.UUID
object AdmobInterstitialUtils {
private var interAd: InterstitialAd? = null
private var interLoadTime = Long.MAX_VALUE
private var adLastDisplayTime: Long = 0
private val mRequest = AdRequest.Builder().build()
private fun isAdExpired(): Boolean {
return System.currentTimeMillis() - interLoadTime > 1000 * 60 * 60
}
fun showInterstitialAd(
activity: Activity,
isReLoadAd: Boolean = false,
isShowDialog: Boolean = true,
onHidden: ((showed: Boolean) -> Unit)? = null
) {
if (activity.isFinishing || activity.isDestroyed) {
return
}
if (isAdExpired()) {
val obj2 = JSONObject()
obj2.put("ad_unit", "interAd")
EventUtils.event("ad_expire", ext = obj2)
interAd = null
loadInterstitialAd(activity)
onHidden?.invoke(false)
return
}
if (!AdDisplayUtils.shouldShowInterAd()) {
onHidden?.invoke(false)
return
}
val obj1 = JSONObject()
obj1.put("ad_unit", "interAd")
EventUtils.event("ad_prepare_show", ext = obj1)
if (interAd != null) {
var dialog: Dialog? = null
if (!activity.isFinishing && !activity.isDestroyed) {
dialog = activity.showAdPreparingDialog()
}
displayInterstitialAd(activity, dialog, onHidden)
} else {
showAdDialogAndLoadInterstitial(activity, isReLoadAd, isShowDialog, onHidden)
}
}
fun loadInterstitialAd(activity: Activity, onLoad: (() -> Unit)? = null) {
if (interAd != null) {
onLoad?.invoke()
return
}
if (!AdDisplayUtils.shouldShowInterAd()) {
onLoad?.invoke()
return
}
val reqId = UUID.randomUUID().toString()
val obj = JSONObject()
obj.put("req_id", reqId)
obj.put("ad_type", "interAd")
obj.put("from", activity.javaClass.simpleName)
EventUtils.event("ad_pull_start", ext = obj)
InterstitialAd.load(
activity,
if (BuildConfig.DEBUG) ConfigHelper.interAdmobIdTest else ConfigHelper.interAdmobId,
mRequest,
object : InterstitialAdLoadCallback() {
override fun onAdFailedToLoad(p0: LoadAdError) {
interAd = null
onLoad?.invoke()
pullAd(p0.responseInfo, "interAd", p0.message, reqId = reqId)
if (BuildConfig.DEBUG) {
Toast.makeText(
MyApplication.context, "拉取失败" + p0.message, Toast.LENGTH_SHORT
).show()
}
}
override fun onAdLoaded(ad: InterstitialAd) {
interAd = ad
onLoad?.invoke()
interLoadTime = System.currentTimeMillis()
pullAd(ad.responseInfo, "interAd", reqId = reqId)
ad.onPaidEventListener = AdmobEvent.EventOnPaidEventListener(ad)
AdDisplayUtils.incrementInterRequestCount()
}
})
}
private fun showAdDialogAndLoadInterstitial(
activity: Activity,
isReLoadAd: Boolean,
isShowDialog: Boolean,
onHidden: ((showed: Boolean) -> Unit)?
) {
if (!isShowDialog) {
onHidden?.invoke(false)
return
}
var mDialog: Dialog? = null
if (!activity.isFinishing && !activity.isDestroyed) {
mDialog = activity.showAdPreparingDialog()
mDialog.show()
}
loadInterstitialAd(activity) {
mDialog?.dismiss()
if (!isReLoadAd) {
showInterstitialAd(activity, true, false) {
onHidden?.invoke(it)
}
}
}
if (isReLoadAd) {
mDialog?.dismiss()
onHidden?.invoke(false)
}
}
private fun displayInterstitialAd(
activity: Activity,
dialog: Dialog? = null,
onHidden: ((showed: Boolean) -> Unit)? = null
) {
val thisInterAd = interAd
interAd = null
thisInterAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdClicked() {
clickAd(thisInterAd?.responseInfo, "interAd")
AdDisplayUtils.incrementInterClickCount()
}
override fun onAdDismissedFullScreenContent() {
dialog?.dismiss()
interAd = null
onHidden?.invoke(true)
loadInterstitialAd(activity)
lastShowedOnHiddenTime = System.currentTimeMillis()
}
override fun onAdFailedToShowFullScreenContent(p0: AdError) {
dialog?.dismiss()
interAd = null
onHidden?.invoke(false)
loadInterstitialAd(activity)
}
override fun onAdShowedFullScreenContent() {
dialog?.dismiss()
showAd(thisInterAd?.responseInfo, "interAd", activity)
AdDisplayUtils.incrementInterShowCount()
adLastDisplayTime = System.currentTimeMillis() / 1000
}
}
thisInterAd?.show(activity)
}
fun haveReadAd(): Boolean {
return interAd != null
}
}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ads.admob
import android.app.Activity
import android.view.ViewGroup
import androidx.core.view.isVisible
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdDisplayUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.clickAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.pullAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.showAd
import com.base.pdfviewerscannerwhite.helper.ConfigHelper
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.google.android.gms.ads.AdListener
import com.google.android.gms.ads.AdLoader
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.LoadAdError
import com.google.android.gms.ads.nativead.NativeAd
import org.json.JSONObject
import java.util.UUID
object AdmobNativeUtils {
private const val TAG = "AdmobNativeUtils"
private var nativeAd: NativeAd? = null
private var isLoading = false
private var nativeLoadTime = Long.MAX_VALUE
private var loadingListener: (() -> Unit)? = null
private val mRequest = AdRequest.Builder().build()
var onAdLoaded: (() -> Unit)? = null
fun loadNativeAd() {
if (nativeAd != null) {
return
}
if (isLoading) {
return
}
isLoading = true
if (!AdDisplayUtils.shouldShowNative()) {
return
}
val reqId = UUID.randomUUID().toString()
val obj = JSONObject()
obj.put("req_id", reqId)
obj.put("ad_type", "nativeAd")
val adLoader = AdLoader.Builder(
MyApplication.context,
if (BuildConfig.DEBUG) ConfigHelper.nativeAdmobIdTest else ConfigHelper.nativeAdmobId
).forNativeAd {
nativeLoadTime = System.currentTimeMillis()
nativeAd = it
it.setOnPaidEventListener(AdmobEvent.EventOnPaidEventListener(it))
LogEx.logDebug(TAG, "nativeAd=${nativeAd.toString()}")
isLoading = false
loadingListener?.invoke()
loadingListener = null
pullAd(it.responseInfo, "nativeAd", reqId = reqId)
}.withAdListener(object : AdListener() {
override fun onAdLoaded() {
super.onAdLoaded()
onAdLoaded?.invoke()
onAdLoaded = null
AdDisplayUtils.incrementNativeRequestCount()
}
override fun onAdClicked() {
clickAd(nativeAd?.responseInfo, "nativeAd")
AdDisplayUtils.incrementNativeClickCount()
}
override fun onAdFailedToLoad(p0: LoadAdError) {
LogEx.logDebug(TAG, "onAdFailedToLoad=${p0.message}")
nativeAd = null
isLoading = false
pullAd(p0.responseInfo, "nativeAd", p0.message, reqId = reqId)
// Log.e("MXL", "NativeAdFailedToLoad: " + p0.message)
}
}).build()
adLoader.loadAd(mRequest)
}
fun showNativeAd(activity: Activity?, parent: ViewGroup, layout: Int = R.layout.layout_admob_native_custom) {
val obj = JSONObject()
obj.put("ad_unit", "nativeAd")
EventUtils.event("ad_prepare_show", ext = obj)
if (!AdDisplayUtils.shouldShowNative()) {
return
}
loadingListener = {
if (System.currentTimeMillis() - nativeLoadTime <= 1000 * 60 * 60) {
nativeAd?.let {
NativeView(parent.context, layout).run {
parent.removeAllViews()
setNativeAd(it)
parent.addView(this)
parent.isVisible = true
showAd(nativeAd?.responseInfo, "nativeAd", activity)
}
}
}
nativeAd = null
loadNativeAd()
}
if (nativeAd == null) {
loadNativeAd()
val obj2 = JSONObject()
obj2.put("reason", "no_ad")
obj2.put("ad_unit", "nativeAd")
EventUtils.event("ad_show_error", ext = obj2)
} else {
loadingListener?.invoke()
loadingListener = null
}
}
fun showReadyNativeAd(
activity: Activity?,
readyNativeAd: NativeAd?,
parent: ViewGroup,
layout: Int = R.layout.layout_admob_native_custom
) {
readyNativeAd?.let {
NativeView(parent.context, layout).run {
parent.removeAllViews()
setNativeAd(it)
parent.addView(this)
parent.isVisible = true
showAd(nativeAd?.responseInfo, "nativeAd", activity)
}
}
}
fun onDestroy() {
nativeAd?.destroy()
nativeAd = null
}
}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ads.admob
import android.app.Activity
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.ads.AdDisplayUtils
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.lastShowedOnHiddenTime
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.clickAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.pullAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobEvent.showAd
import com.base.pdfviewerscannerwhite.helper.ConfigHelper
import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.utils.LogEx
import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.FullScreenContentCallback
import com.google.android.gms.ads.LoadAdError
import com.google.android.gms.ads.appopen.AppOpenAd
import org.json.JSONObject
import java.util.UUID
object AdmobOpenUtils {
private const val TAG = "AdmobOpenUtils"
private val mRequest = AdRequest.Builder().build()
private var openLoadTime = Long.MAX_VALUE
private var mOpenAd: AppOpenAd? = null
private fun isAdExpired(): Boolean {
return System.currentTimeMillis() - openLoadTime > 1000 * 60 * 60
}
fun haveReadAd(): Boolean {
return mOpenAd != null
}
fun loadAppOpenAd(onLoad: ((loaded: Boolean) -> Unit)? = null) {
if (mOpenAd != null) {
onLoad?.invoke(true)
return
}
if (!AdDisplayUtils.shouldShowOpenAd()) {
onLoad?.invoke(false)
return
}
val reqId = UUID.randomUUID().toString()
val obj = JSONObject()
obj.put("req_id", reqId)
obj.put("ad_type", "openAd")
EventUtils.event("ad_pull_start", ext = obj)
AppOpenAd.load(
MyApplication.context,
if (BuildConfig.DEBUG) ConfigHelper.openAdmobIdTest else ConfigHelper.openAdmobId,
mRequest,
object : AppOpenAd.AppOpenAdLoadCallback() {
override fun onAdLoaded(ad: AppOpenAd) {
LogEx.logDebug(TAG, "onAdLoaded")
openLoadTime = System.currentTimeMillis()
mOpenAd = ad
onLoad?.invoke(true)
pullAd(ad.responseInfo, "openAd", reqId = reqId)
ad.onPaidEventListener = AdmobEvent.EventOnPaidEventListener(ad)
AdDisplayUtils.incrementOpenRequestCount()
}
override fun onAdFailedToLoad(p0: LoadAdError) {
LogEx.logDebug(TAG, "LoadAdError ${p0.message}")
mOpenAd = null
onLoad?.invoke(false)
pullAd(p0.responseInfo, "openAd", p0.message, reqId = reqId)
}
})
}
fun showAppOpenAd(
activity: Activity,
isRetry: Boolean = false,
showBefore: ((flag: Boolean) -> Unit)? = null,
onHidden: ((showed: Boolean) -> Unit)? = null
) {
if (activity.isFinishing || activity.isDestroyed) {
LogEx.logDebug(TAG, "activity isDestroyed")
return
}
if (!AdDisplayUtils.shouldShowOpenAd()) {
onHidden?.invoke(false)
return
}
if (isAdExpired()) {
LogEx.logDebug(TAG, "openLoadTime out time")
mOpenAd = null
loadAppOpenAd()
onHidden?.invoke(false)
val obj2 = JSONObject()
obj2.put("ad_unit", "openAd")
EventUtils.event("ad_expire", ext = obj2)
return
}
if (!isRetry) {
val obj1 = JSONObject()
obj1.put("ad_unit", "openAd")
EventUtils.event("ad_prepare_show", ext = obj1)
LogEx.logDebug(TAG, "open ad_prepare_show")
}
if (mOpenAd != null) {
LogEx.logDebug(TAG, "mOpenAd!=null")
val thisMOpenAd = mOpenAd
mOpenAd = null
thisMOpenAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdClicked() {
clickAd(thisMOpenAd?.responseInfo, "openAd")
AdDisplayUtils.incrementClickShow()
}
override fun onAdDismissedFullScreenContent() {
mOpenAd = null
onHidden?.invoke(true)
loadAppOpenAd()
lastShowedOnHiddenTime = System.currentTimeMillis()
}
override fun onAdFailedToShowFullScreenContent(p0: AdError) {
mOpenAd = null
onHidden?.invoke(false)
loadAppOpenAd()
val obj = JSONObject()
obj.put("reason", p0.message)
obj.put("code", p0.code)
obj.put("ad_unit", "openAd")
EventUtils.event("ad_show_error", ext = obj)
}
override fun onAdShowedFullScreenContent() {
showBefore?.invoke(true)
showAd(thisMOpenAd?.responseInfo, "openAd", activity)
AdDisplayUtils.incrementOpenShow()
}
}
thisMOpenAd?.show(activity)
} else {
LogEx.logDebug(TAG, "mOpenAd=null")
loadAppOpenAd {
if (mOpenAd != null) {
showAppOpenAd(activity, true, showBefore, onHidden)
} else {
val obj = JSONObject()
obj.put("reason", "no_ad")
obj.put("ad_unit", "openAd")
EventUtils.event("ad_show_error", ext = obj)
onHidden?.invoke(false)
}
}
}
}
}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ads.admob package com.zxcv.asdf.easycleanmanager.online.adhelps
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.LayoutInflater import android.view.LayoutInflater
...@@ -10,15 +9,43 @@ import android.widget.Button ...@@ -10,15 +9,43 @@ import android.widget.Button
import android.widget.FrameLayout import android.widget.FrameLayout
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import com.applovin.mediation.MaxAd
import com.applovin.mediation.nativeAds.MaxNativeAdLoader
import com.applovin.mediation.nativeAds.MaxNativeAdView
import com.applovin.mediation.nativeAds.MaxNativeAdViewBinder
import com.base.pdfviewerscannerwhite.R
import com.google.android.gms.ads.nativead.NativeAd import com.google.android.gms.ads.nativead.NativeAd
import com.google.android.gms.ads.nativead.NativeAdView import com.google.android.gms.ads.nativead.NativeAdView
import com.base.pdfviewerscannerwhite.R
@SuppressLint("ViewConstructor")
class NativeView(context: Context, val layout: Int, attrs: AttributeSet? = null) : FrameLayout(context, attrs) { class NativeView @JvmOverloads constructor(
context: Context, val layout: Int, attrs: AttributeSet? = null
): FrameLayout(context, attrs) {
init { init {
layoutParams = LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) layoutParams = LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
}
fun setNativeAd(
nativeAdLoader: MaxNativeAdLoader,
nativeAd: MaxAd,
) {
// val layout = resource ?: R.layout.native_custom_ad_view
val binder: MaxNativeAdViewBinder =
MaxNativeAdViewBinder.Builder(layout)
.setTitleTextViewId(R.id.ad_headline)
// .setBodyTextViewId(R.id.body_text_view)
// .setAdvertiserTextViewId(R.id.advertiser_text_view)
.setIconImageViewId(R.id.ad_app_icon)
.setMediaContentViewGroupId(R.id.ad_media)
// .setOptionsContentViewGroupId(R.id.options_view)
// .setStarRatingContentViewGroupId(R.id.star_rating_view)
.setCallToActionButtonId(R.id.ad_call_to_action)
.build()
val adView = MaxNativeAdView(binder, context)
nativeAdLoader.render(adView, nativeAd)
removeAllViews()
addView(adView)
} }
fun setNativeAd(nativeAd: NativeAd?) { fun setNativeAd(nativeAd: NativeAd?) {
...@@ -27,9 +54,9 @@ class NativeView(context: Context, val layout: Int, attrs: AttributeSet? = null) ...@@ -27,9 +54,9 @@ class NativeView(context: Context, val layout: Int, attrs: AttributeSet? = null)
val adView = LayoutInflater.from(context) val adView = LayoutInflater.from(context)
.inflate(layout, this, false) as NativeAdView .inflate(layout, this, false) as NativeAdView
runCatching { // runCatching {
// adView.advertiserView = adView.findViewById(R.id.ad_advertiser) // adView.advertiserView = adView.findViewById(R.id.ad_advertiser)
} // }
adView.mediaView = adView.findViewById(R.id.ad_media) adView.mediaView = adView.findViewById(R.id.ad_media)
adView.headlineView = adView.findViewById(R.id.ad_headline) adView.headlineView = adView.findViewById(R.id.ad_headline)
adView.bodyView = adView.findViewById(R.id.ad_body) adView.bodyView = adView.findViewById(R.id.ad_body)
......
package com.base.pdfviewerscannerwhite.ads.admob package com.zxcv.asdf.easycleanmanager.online.adhelps
import android.app.Activity import android.app.Activity
import android.os.Bundle import android.os.Bundle
import com.base.pdfviewerscannerwhite.helper.EventUtils import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.helper.MyApplication import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.facebook.appevents.AppEventsConstants import com.facebook.appevents.AppEventsConstants
import com.facebook.appevents.AppEventsLogger import com.facebook.appevents.AppEventsLogger
import com.google.android.gms.ads.AdValue import com.google.android.gms.ads.AdValue
...@@ -18,10 +18,32 @@ import com.google.android.gms.ads.rewarded.RewardedAd ...@@ -18,10 +18,32 @@ import com.google.android.gms.ads.rewarded.RewardedAd
import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.ktx.Firebase import com.google.firebase.ktx.Firebase
import com.reyun.solar.engine.utils.store.SPUtils
import org.json.JSONObject import org.json.JSONObject
import kotlin.random.Random
object ReportAdUtils {
private val taichiPref by lazy {
MyApplication.context.getSharedPreferences("TaichiTroasCache", 0)
}
private val taichiSharedPreferencesEditor by lazy {
taichiPref.edit()
}
fun pullStartAd(
reqId: String,
adUnit: String,
className: String,
) {
val obj = JSONObject()
obj.put("req_id", reqId)
obj.put("ad_unit", adUnit)
obj.put("from", className)
EventUtils.event("ad_pull_start", "", ext = obj)
}
object AdmobEvent {
private val TAG = "AdmobEvent"
fun pullAd( fun pullAd(
responseInfo: ResponseInfo?, responseInfo: ResponseInfo?,
adUnit: String, adUnit: String,
...@@ -46,28 +68,26 @@ object AdmobEvent { ...@@ -46,28 +68,26 @@ object AdmobEvent {
obj.put("networkname", responseInfo?.mediationAdapterClassName) obj.put("networkname", responseInfo?.mediationAdapterClassName)
obj.put("ad_unit", adUnit) obj.put("ad_unit", adUnit)
obj.put("req_id", reqId) obj.put("req_id", reqId)
obj.put("mediation", "admob")
if (error == null) { if (error == null) {
obj.put("status", "1") obj.put("status", "1")
} else { } else {
obj.put("errMsg", error) obj.put("errMsg", error)
obj.put("status", "2") obj.put("status", "2")
} }
LogEx.logDebug(TAG, "obj=$obj") EventUtils.event("ad_pull", "", ext = obj)
EventUtils.event("ad_pull", ext = obj)
}
private val taichiPref by lazy {
MyApplication.context.getSharedPreferences("TaichiTroasCache", 0)
}
private val taichiSharedPreferencesEditor by lazy {
taichiPref.edit()
} }
class EventOnPaidEventListener(private val ad: Any?) : OnPaidEventListener { class EventOnPaidEventListener(private val ad: Any?) : OnPaidEventListener {
override fun onPaidEvent(adValue: AdValue) { override fun onPaidEvent(adValue: AdValue) {
val adRatio = AppPreferences.getInstance().getString("adRatio", "100").toInt()
SolarEngineEvent.eventSolar(ad, adValue.valueMicros) val random = Random.Default.nextInt(1, 100)
if (random > adRatio) {
taichiSharedPreferencesEditor.putFloat("TaichiTroasCache", 0f)
taichiSharedPreferencesEditor.commit()
EventUtils.event("ad_price_limit")
return
}
val valueMicros = adValue.valueMicros val valueMicros = adValue.valueMicros
val currencyCode = adValue.currencyCode val currencyCode = adValue.currencyCode
...@@ -86,7 +106,6 @@ object AdmobEvent { ...@@ -86,7 +106,6 @@ object AdmobEvent {
val currentImpressionRevenue = adValue.valueMicros.toDouble() / 1000000.0 val currentImpressionRevenue = adValue.valueMicros.toDouble() / 1000000.0
params.putDouble(FirebaseAnalytics.Param.VALUE, currentImpressionRevenue) params.putDouble(FirebaseAnalytics.Param.VALUE, currentImpressionRevenue)
params.putString(FirebaseAnalytics.Param.CURRENCY, "USD") params.putString(FirebaseAnalytics.Param.CURRENCY, "USD")
LogEx.logDebug("EventOnPaidEventListener", "precisionType=${adValue.precisionType}")
val precisionType = when (adValue.precisionType) { val precisionType = when (adValue.precisionType) {
0 -> "UNKNOWN" 0 -> "UNKNOWN"
1 -> "ESTIMATED" 1 -> "ESTIMATED"
...@@ -99,7 +118,8 @@ object AdmobEvent { ...@@ -99,7 +118,8 @@ object AdmobEvent {
val previousTaichiTroasCache = taichiPref.getFloat("TaichiTroasCache", 0f) val previousTaichiTroasCache = taichiPref.getFloat("TaichiTroasCache", 0f)
val currentTaichiTroasCache = (previousTaichiTroasCache + val currentTaichiTroasCache = (previousTaichiTroasCache +
currentImpressionRevenue).toFloat() currentImpressionRevenue).toFloat()
if (currentTaichiTroasCache >= 0.01) {//如果超过0.01就触发一次tROAS taichi事件 val value = AppPreferences.getInstance().getString("adValue", "1").toInt() / 100f
if (currentTaichiTroasCache >= value) {//如果超过0.01就触发一次tROAS taichi事件
val roasbundle = Bundle() val roasbundle = Bundle()
roasbundle.putDouble( roasbundle.putDouble(
FirebaseAnalytics.Param.VALUE, FirebaseAnalytics.Param.VALUE,
...@@ -107,6 +127,7 @@ object AdmobEvent { ...@@ -107,6 +127,7 @@ object AdmobEvent {
) )
roasbundle.putString(FirebaseAnalytics.Param.CURRENCY, "USD") roasbundle.putString(FirebaseAnalytics.Param.CURRENCY, "USD")
Firebase.analytics.logEvent("Total_Ads_Revenue_001", roasbundle) Firebase.analytics.logEvent("Total_Ads_Revenue_001", roasbundle)
SolarEngineEvent.eventSolar(ad, adValue.valueMicros)
taichiSharedPreferencesEditor.putFloat("TaichiTroasCache", 0f)//重新清零,开始计算 taichiSharedPreferencesEditor.putFloat("TaichiTroasCache", 0f)//重新清零,开始计算
val logger = AppEventsLogger.newLogger(MyApplication.context) val logger = AppEventsLogger.newLogger(MyApplication.context)
...@@ -118,7 +139,6 @@ object AdmobEvent { ...@@ -118,7 +139,6 @@ object AdmobEvent {
} }
taichiSharedPreferencesEditor.commit() taichiSharedPreferencesEditor.commit()
var key = "ad_price"
when (ad) { when (ad) {
is AppOpenAd -> { is AppOpenAd -> {
val adUnitId = ad.adUnitId val adUnitId = ad.adUnitId
...@@ -190,7 +210,6 @@ object AdmobEvent { ...@@ -190,7 +210,6 @@ object AdmobEvent {
} }
is NativeAd -> { is NativeAd -> {
key = "ad_price"
val loadedAdapterResponseInfo = ad.responseInfo?.loadedAdapterResponseInfo val loadedAdapterResponseInfo = ad.responseInfo?.loadedAdapterResponseInfo
val adSourceName = loadedAdapterResponseInfo?.adSourceName val adSourceName = loadedAdapterResponseInfo?.adSourceName
val adSourceId = loadedAdapterResponseInfo?.adSourceId val adSourceId = loadedAdapterResponseInfo?.adSourceId
...@@ -214,7 +233,6 @@ object AdmobEvent { ...@@ -214,7 +233,6 @@ object AdmobEvent {
else -> { else -> {
runCatching { runCatching {
LogEx.logDebug(TAG, "banner banner")
val adView = ad as AdView val adView = ad as AdView
val adUnitId = adView.adUnitId val adUnitId = adView.adUnitId
val loadedAdapterResponseInfo = adView.responseInfo?.loadedAdapterResponseInfo val loadedAdapterResponseInfo = adView.responseInfo?.loadedAdapterResponseInfo
...@@ -237,16 +255,14 @@ object AdmobEvent { ...@@ -237,16 +255,14 @@ object AdmobEvent {
obj.put("mediationABTestName", mediationABTestName) obj.put("mediationABTestName", mediationABTestName)
obj.put("mediationABTestVariant", mediationABTestVariant) obj.put("mediationABTestVariant", mediationABTestVariant)
obj.put("session_id", sessionId) obj.put("session_id", sessionId)
LogEx.logDebug(TAG, "banner banner banner obj=$obj")
} }
} }
} }
EventUtils.event(key, ext = obj) EventUtils.event("ad_price", ext = obj)
} }
} }
fun clickAd(responseInfo: ResponseInfo?, adUnit: String) { fun clickAd(responseInfo: ResponseInfo?, adUnit: String) {
val response = responseInfo?.adapterResponses?.getOrNull(0) val response = responseInfo?.adapterResponses?.getOrNull(0)
val obj = JSONObject() val obj = JSONObject()
obj.put("source", response?.adSourceName) obj.put("source", response?.adSourceName)
...@@ -260,11 +276,8 @@ object AdmobEvent { ...@@ -260,11 +276,8 @@ object AdmobEvent {
obj.put("credentials", credentials.toString()) obj.put("credentials", credentials.toString())
obj.put("session_id", responseInfo?.responseId) obj.put("session_id", responseInfo?.responseId)
obj.put("networkname", responseInfo?.mediationAdapterClassName) obj.put("networkname", responseInfo?.mediationAdapterClassName)
if (adUnit != "nativeAd") { obj.put("mediation", "admob")
EventUtils.event("ad_click", ext = obj) EventUtils.event("ad_click", "", ext = obj)
} else {
EventUtils.event("bigimage_ad_click", ext = obj)
}
} }
fun showAd(responseInfo: ResponseInfo?, adUnit: String, activity: Activity? = null) { fun showAd(responseInfo: ResponseInfo?, adUnit: String, activity: Activity? = null) {
...@@ -281,10 +294,27 @@ object AdmobEvent { ...@@ -281,10 +294,27 @@ object AdmobEvent {
obj.put("credentials", credentials.toString()) obj.put("credentials", credentials.toString())
obj.put("session_id", responseInfo?.responseId) obj.put("session_id", responseInfo?.responseId)
obj.put("from", activity?.javaClass?.simpleName) obj.put("from", activity?.javaClass?.simpleName)
if (adUnit != "nativeAd") { obj.put("mediation", "admob")
EventUtils.event("ad_show", ext = obj) EventUtils.event("ad_show", "", ext = obj)
} else { }
EventUtils.event("ad_show", ext = obj)
} fun showErrorAd(reason: String, adUnit: String) {
val obj = JSONObject()
obj.put("reason", reason)
obj.put("ad_unit", adUnit)
EventUtils.event("ad_show_error", "", ext = obj)
}
fun showPrepareAd(adUnit: String) {
val obj = JSONObject()
obj.put("ad_unit", adUnit)
EventUtils.event("ad_prepare_show", "", ext = obj)
}
fun limitErrorAd(reason: String, adUnit: String) {
val obj = JSONObject()
obj.put("reason", reason)
obj.put("ad_unit", adUnit)
EventUtils.event("ad_limit_error", "", ext = obj)
} }
} }
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ads.admob package com.zxcv.asdf.easycleanmanager.online.adhelps
import com.base.pdfviewerscannerwhite.helper.ConfigHelper import com.base.pdfviewerscannerwhite.GlobalConfig
import com.google.android.gms.ads.appopen.AppOpenAd import com.google.android.gms.ads.appopen.AppOpenAd
import com.google.android.gms.ads.interstitial.InterstitialAd import com.google.android.gms.ads.interstitial.InterstitialAd
import com.google.android.gms.ads.nativead.NativeAd import com.google.android.gms.ads.nativead.NativeAd
...@@ -18,9 +18,9 @@ object SolarEngineEvent { ...@@ -18,9 +18,9 @@ object SolarEngineEvent {
val json = JSONObject() val json = JSONObject()
//变现平台 //变现平台
val adNetworkPlatform = "AdMob" var adNetworkPlatform = "AdMob"
//聚合平台标识 //聚合平台标识
val mediationPlatform = "admob" var mediationPlatform = "admob"
//广告的类型 //广告的类型
// adType 为激励视频时,只需要传入 1 // adType 为激励视频时,只需要传入 1
// 1:激励视频 // 1:激励视频
...@@ -36,13 +36,13 @@ object SolarEngineEvent { ...@@ -36,13 +36,13 @@ object SolarEngineEvent {
// 0:其它 // 0:其它
var adType = -1 var adType = -1
//变现平台的应用 ID //变现平台的应用 ID
val adNetworkAppID = "ca-app-pub-3640696756167444~1506657395" var adNetworkAppID = GlobalConfig.ID_ADMOB_APPLICATION
//变现平台的变现广告位 ID //变现平台的变现广告位 ID
var adNetworkADID = "" var adNetworkADID = ""
//广告 ecpm,单位:元(广告千次展现的变现收入,0或负值表示没传,单位为元) //广告 ecpm,单位:元(广告千次展现的变现收入,0或负值表示没传,单位为元)
val ecpm = valueMicros / 1000.0 var ecpm = valueMicros / 1000.0
//货币种类 //货币种类
val currencyType = "USD" var currencyType = "USD"
when (ad) { when (ad) {
is AppOpenAd -> { is AppOpenAd -> {
...@@ -57,7 +57,7 @@ object SolarEngineEvent { ...@@ -57,7 +57,7 @@ object SolarEngineEvent {
is NativeAd -> { is NativeAd -> {
adType = 6 adType = 6
adNetworkADID = ConfigHelper.nativeAdmobId adNetworkADID = GlobalConfig.ID_ADMOB_NATIVE
} }
is RewardedAd -> { is RewardedAd -> {
...@@ -65,9 +65,9 @@ object SolarEngineEvent { ...@@ -65,9 +65,9 @@ object SolarEngineEvent {
adNetworkADID = ad.adUnitId adNetworkADID = ad.adUnitId
} }
else -> {//banner else -> { //banner
adType = 5 adType = 5
adNetworkADID = ConfigHelper.bannerAdmobId adNetworkADID = GlobalConfig.ID_ADMOB_BANNER
} }
} }
......
...@@ -58,7 +58,7 @@ object ConstObject { ...@@ -58,7 +58,7 @@ object ConstObject {
const val NOTIFICATION_ACTION_SIMILAR = "notification_action_similar" const val NOTIFICATION_ACTION_SIMILAR = "notification_action_similar"
const val NOTIFICATION_ACTION_WHATSAPP = "notification_action_whatsapp" const val NOTIFICATION_ACTION_WHATSAPP = "notification_action_whatsapp"
const val NOTIFICATION_ACTION_LARGEFILE = "notification_action_largefile" const val NOTIFICATION_ACTION_LARGEFILE = "notification_action_largefile"
const val NOTIFICATION_ACTION_ZODIAC = "notification_action_zodiac" //const val NOTIFICATION_ACTION_ZODIAC = "notification_action_zodiac"
const val SHORTCUT_SCAN_PDF = "shortcut_scan_pdf" const val SHORTCUT_SCAN_PDF = "shortcut_scan_pdf"
const val SHORTCUT_SPLIT_PDF = "shortcut_split_pdf" const val SHORTCUT_SPLIT_PDF = "shortcut_split_pdf"
......
...@@ -24,7 +24,6 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_SIMIL ...@@ -24,7 +24,6 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_SIMIL
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_UN_VIEW_FILES import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_UN_VIEW_FILES
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WEATHER import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WEATHER
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WHATSAPP import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WHATSAPP
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_ZODIAC
import com.base.pdfviewerscannerwhite.bean.WeatherBean import com.base.pdfviewerscannerwhite.bean.WeatherBean
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_FCM import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_FCM
import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_LOCK import com.base.pdfviewerscannerwhite.fcm.PopupConstObject.POPUP_WHERE_LOCK
...@@ -270,22 +269,7 @@ object NotificationUiUtil { ...@@ -270,22 +269,7 @@ object NotificationUiUtil {
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews) sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
} }
NOTIFICATION_ACTION_ZODIAC -> {
smallRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_constellation_small)
bigRemoteViews = RemoteViews(MyApplication.context.packageName, R.layout.notification_constellation_big)
val content = arrayOf(
Pair("Unlock the Universe's Secrets!", "Your daily horoscope has the answers you seek. Click to discover!"),
Pair("Discover Your Hidden Fortune!", "Your horoscope opens new doors. Click to unlock your destiny!"),
Pair("Your Fate is in the Stars!", "Today's horoscope reveals life-changing secrets. Click to see!"),
Pair("Unlock Your Future Today!", "Your daily horoscope maps your path to success. Click to find it!"),
).random()
smallRemoteViews.setTextViewText(R.id.tv_desc, content.second)
bigRemoteViews.setTextViewText(R.id.tv_title, content.first)
bigRemoteViews.setTextViewText(R.id.tv_desc, content.second)
sendCustomNotification(context, intent, bigRemoteViews, smallRemoteViews)
}
NOTIFICATION_ACTION_READ_DOCUMENTS -> { NOTIFICATION_ACTION_READ_DOCUMENTS -> {
val tittle = context.getString(R.string.read_more_phone_documents) val tittle = context.getString(R.string.read_more_phone_documents)
...@@ -515,8 +499,7 @@ object NotificationUiUtil { ...@@ -515,8 +499,7 @@ object NotificationUiUtil {
NOTIFICATION_ACTION_SCREENSHOT, NOTIFICATION_ACTION_SCREENSHOT,
NOTIFICATION_ACTION_SIMILAR, NOTIFICATION_ACTION_SIMILAR,
NOTIFICATION_ACTION_WHATSAPP, NOTIFICATION_ACTION_WHATSAPP,
NOTIFICATION_ACTION_LARGEFILE, NOTIFICATION_ACTION_LARGEFILE
NOTIFICATION_ACTION_ZODIAC
) )
private var nextIdIndex = -1 private var nextIdIndex = -1
......
...@@ -6,6 +6,7 @@ import android.os.Bundle ...@@ -6,6 +6,7 @@ import android.os.Bundle
import android.os.LocaleList import android.os.LocaleList
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.bean.ConstObject.appLanguageSp import com.base.pdfviewerscannerwhite.bean.ConstObject.appLanguageSp
import com.base.pdfviewerscannerwhite.bean.ConstObject.changeLanguageSp import com.base.pdfviewerscannerwhite.bean.ConstObject.changeLanguageSp
import com.base.pdfviewerscannerwhite.ui.main.MainActivity import com.base.pdfviewerscannerwhite.ui.main.MainActivity
...@@ -101,5 +102,27 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() { ...@@ -101,5 +102,27 @@ abstract class BaseActivity<T : ViewBinding> : AppCompatActivity() {
fun checkNeedRecreate(activityLanguage: String): Boolean { fun checkNeedRecreate(activityLanguage: String): Boolean {
return appLanguageSp != changeLanguageSp || activityLanguage != changeLanguageSp return appLanguageSp != changeLanguageSp || activityLanguage != changeLanguageSp
} }
fun admobMaxShowInterstitialAd(
isShow: Boolean = AdmobManager.isShowLoadingAdInter(),
complete: (() -> Unit)? = null
) {
if (this.isFinishing || this.isDestroyed ) return
if (isShow) {
AdmobManager.showInterstitialAd(
this,
dismissed = {
complete?.invoke()
},
completed = {
},
failed = {
complete?.invoke()
}
)
}else{
complete?.invoke()
}
}
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ package com.base.pdfviewerscannerwhite.helper ...@@ -2,6 +2,7 @@ package com.base.pdfviewerscannerwhite.helper
import android.util.Log import android.util.Log
import com.base.pdfviewerscannerwhite.BuildConfig import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.GlobalConfig
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.google.gson.Gson import com.google.gson.Gson
...@@ -27,7 +28,8 @@ object NewComUtils { ...@@ -27,7 +28,8 @@ object NewComUtils {
private val url: String by lazy { private val url: String by lazy {
val packageName = ConfigHelper.packageName val packageName = ConfigHelper.packageName
val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault()) val appCode =
packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault())
val bRefer = android.util.Base64.encodeToString( val bRefer = android.util.Base64.encodeToString(
AppPreferences.getInstance().getString("referrerUrl", "").toByteArray(), AppPreferences.getInstance().getString("referrerUrl", "").toByteArray(),
...@@ -36,37 +38,45 @@ object NewComUtils { ...@@ -36,37 +38,45 @@ object NewComUtils {
"$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${ "$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences.getInstance().getString("gid", "") AppPreferences.getInstance().getString("gid", "")
}&aid=${AppPreferences.getInstance().getString("uuid", "")}" }&aid=${AppPreferences.getInstance().getString("uuid", "")}&mode=4"
// &mode=3 // &mode=3
} }
private const val KEY_LAST_CONFIG_TIME = "key_last_config_time"
private inline var updateTime
get() = AppPreferences.getInstance().getLong(KEY_LAST_CONFIG_TIME, 0)
set(value) = AppPreferences.getInstance().put(KEY_LAST_CONFIG_TIME, value)
fun requestCfg(callback: () -> Unit) { fun requestCfg(callback: () -> Unit) {
CoroutineScope(CoroutineExceptionHandler { _, _ -> } + SupervisorJob() +Dispatchers.IO).launch { val intervalLimit =
val response = doGet() AppPreferences.getInstance().getString(GlobalConfig.KEY_GET_CONFIG, "4").toInt()
if (response == null) { val interval = System.currentTimeMillis() - updateTime
withContext(Dispatchers.Main) { if (interval >= intervalLimit * 60 * 60 * 1000) {
callback() CoroutineScope(CoroutineExceptionHandler { _, _ -> } + SupervisorJob() + Dispatchers.IO).launch {
val response = doGet()
if (response == null) {
withContext(Dispatchers.Main) {
callback()
}
return@launch
}
val data = extractData(response)
if (data == null) {
withContext(Dispatchers.Main) {
callback()
}
return@launch
} }
return@launch
}
val data = extractData(response) val decryptedData = AESHelper.decrypt(data)
if (data == null) { parseConfigBean(decryptedData)
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
callback() callback()
} }
return@launch
}
val decryptedData = AESHelper.decrypt(data)
parseConfigBean(decryptedData)
withContext(Dispatchers.Main) {
callback()
} }
} } else callback.invoke()
} }
private fun doGet(): String? { private fun doGet(): String? {
...@@ -95,6 +105,7 @@ object NewComUtils { ...@@ -95,6 +105,7 @@ object NewComUtils {
} }
private fun parseConfigBean(json: String) { private fun parseConfigBean(json: String) {
Log.e("MXL", "parseConfigBean: "+json )
val gson = Gson() val gson = Gson()
val type = object : TypeToken<Map<String, String>>() {}.type val type = object : TypeToken<Map<String, String>>() {}.type
val configMap = gson.fromJson<Map<String, String>>(json, type) val configMap = gson.fromJson<Map<String, String>>(json, type)
...@@ -104,7 +115,7 @@ object NewComUtils { ...@@ -104,7 +115,7 @@ object NewComUtils {
AppPreferences.getInstance().put(t, u) AppPreferences.getInstance().put(t, u)
LogEx.logDebug(TAG, "t=$t u=$u") LogEx.logDebug(TAG, "t=$t u=$u")
} }
updateTime=System.currentTimeMillis()
val jsonObject = JSONObject() val jsonObject = JSONObject()
jsonObject.put("ut", AppPreferences.getInstance().getString("ut", "")) jsonObject.put("ut", AppPreferences.getInstance().getString("ut", ""))
EventUtils.event("user_type", ext = jsonObject) EventUtils.event("user_type", ext = jsonObject)
......
...@@ -14,8 +14,7 @@ import androidx.constraintlayout.widget.ConstraintLayout ...@@ -14,8 +14,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.airbnb.lottie.LottieAnimationView import com.airbnb.lottie.LottieAnimationView
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.helper.EventUtils import com.base.pdfviewerscannerwhite.helper.EventUtils
import com.base.pdfviewerscannerwhite.mix.DialogHelps.showExitDialog import com.base.pdfviewerscannerwhite.mix.DialogHelps.showExitDialog
import com.base.pdfviewerscannerwhite.ui.appprocess.AppProcessActivity import com.base.pdfviewerscannerwhite.ui.appprocess.AppProcessActivity
...@@ -75,7 +74,7 @@ open class BaseActivity2 : AppCompatActivity() { ...@@ -75,7 +74,7 @@ open class BaseActivity2 : AppCompatActivity() {
) { ) {
this.lottieType = lottieType this.lottieType = lottieType
this.complete = complete this.complete = complete
AdmobInterstitialUtils.showInterstitialAd(this, false, false) { admobMaxShowInterstitialAd {
// showAdInterstitial(true) { // showAdInterstitial(true) {
val animationView = findViewById<ConstraintLayout>(R.id.animation) val animationView = findViewById<ConstraintLayout>(R.id.animation)
animationView.setOnClickListener { } animationView.setOnClickListener { }
...@@ -184,11 +183,7 @@ open class BaseActivity2 : AppCompatActivity() { ...@@ -184,11 +183,7 @@ open class BaseActivity2 : AppCompatActivity() {
} }
fun backAdJump() { fun backAdJump() {
if (AdmobHelper.isShowCloseDocumentInter()) { admobMaxShowInterstitialAd (isShow = AdmobManager.isShowAdBackInter()){
AdmobInterstitialUtils.showInterstitialAd(this) {
finishToMainTop()
}
} else {
finishToMainTop() finishToMainTop()
} }
} }
...@@ -200,4 +195,27 @@ open class BaseActivity2 : AppCompatActivity() { ...@@ -200,4 +195,27 @@ open class BaseActivity2 : AppCompatActivity() {
startActivity(intent) startActivity(intent)
finish() finish()
} }
fun admobMaxShowInterstitialAd(
isShow: Boolean = AdmobManager.isShowLoadingAdInter(),
complete: (() -> Unit)? = null
) {
if (this.isFinishing || this.isDestroyed ) return
if (isShow) {
AdmobManager.showInterstitialAd(
this,
dismissed = {
complete?.invoke()
},
completed = {
},
failed = {
complete?.invoke()
}
)
}else{
complete?.invoke()
}
}
} }
\ No newline at end of file
...@@ -8,8 +8,7 @@ import android.view.LayoutInflater ...@@ -8,8 +8,7 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.databinding.DialogDeleteBinding
import com.base.pdfviewerscannerwhite.databinding.DialogDeleteMixBinding import com.base.pdfviewerscannerwhite.databinding.DialogDeleteMixBinding
import com.base.pdfviewerscannerwhite.databinding.DialogExitBinding import com.base.pdfviewerscannerwhite.databinding.DialogExitBinding
import com.base.pdfviewerscannerwhite.databinding.DialogStoragePermissionBinding import com.base.pdfviewerscannerwhite.databinding.DialogStoragePermissionBinding
...@@ -105,7 +104,7 @@ object DialogHelps { ...@@ -105,7 +104,7 @@ object DialogHelps {
dialog.dismiss() dialog.dismiss()
confirm.invoke() confirm.invoke()
} }
AdmobNativeUtils.showNativeAd(context,binding.adNative) AdmobManager.showNativeAd(context,binding.adNative)
} }
......
...@@ -9,8 +9,7 @@ import androidx.appcompat.widget.AppCompatTextView ...@@ -9,8 +9,7 @@ import androidx.appcompat.widget.AppCompatTextView
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.databinding.ActivityLargeFileCleanBinding import com.base.pdfviewerscannerwhite.databinding.ActivityLargeFileCleanBinding
import com.base.pdfviewerscannerwhite.ui.result.ResultActivity import com.base.pdfviewerscannerwhite.ui.result.ResultActivity
...@@ -85,7 +84,7 @@ class LargeFileCleanActivity : BaseActivity2() { ...@@ -85,7 +84,7 @@ class LargeFileCleanActivity : BaseActivity2() {
initView() initView()
initData() initData()
showAnimationAd(LottieType.LARGE_FILE) showAnimationAd(LottieType.LARGE_FILE)
AdmobNativeUtils.showNativeAd(this, binding.adNative) AdmobManager.showNativeAd(this, binding.idFlAd)
} }
private fun initView() { private fun initView() {
...@@ -148,7 +147,7 @@ class LargeFileCleanActivity : BaseActivity2() { ...@@ -148,7 +147,7 @@ class LargeFileCleanActivity : BaseActivity2() {
binding.tvDelete.setOnClickListener { binding.tvDelete.setOnClickListener {
if (total <= 0) return@setOnClickListener if (total <= 0) return@setOnClickListener
DialogHelps.showDeleteDialog(this, binding.tvDelete) { DialogHelps.showDeleteDialog(this, binding.tvDelete) {
AdmobInterstitialUtils.showInterstitialAd(this, false, false) { admobMaxShowInterstitialAd(true) {
startActivity(Intent(this, ResultActivity::class.java).apply { startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", ConstObject.FUNCTION_LARGEFILE) putExtra("from", ConstObject.FUNCTION_LARGEFILE)
putExtra("clean_size", total) putExtra("clean_size", total)
...@@ -165,7 +164,8 @@ class LargeFileCleanActivity : BaseActivity2() { ...@@ -165,7 +164,8 @@ class LargeFileCleanActivity : BaseActivity2() {
private fun initData() { private fun initData() {
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
files = async { MediaHelps.findFiles(this@LargeFileCleanActivity, LARGE_FILE_SIZE) }.await() files =
async { MediaHelps.findFiles(this@LargeFileCleanActivity, LARGE_FILE_SIZE) }.await()
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
binding.tvDelete.visibility = if (files.isEmpty()) View.GONE else View.VISIBLE binding.tvDelete.visibility = if (files.isEmpty()) View.GONE else View.VISIBLE
filterData() filterData()
...@@ -291,11 +291,31 @@ class LargeFileCleanActivity : BaseActivity2() { ...@@ -291,11 +291,31 @@ class LargeFileCleanActivity : BaseActivity2() {
private fun filterTime(list: List<FileBean>, position: Int): List<FileBean> { private fun filterTime(list: List<FileBean>, position: Int): List<FileBean> {
return when (position) { return when (position) {
1 -> list.filter { it.lastModified > Calendar.getInstance().apply { add(Calendar.WEEK_OF_YEAR, -1) }.timeInMillis } 1 -> list.filter {
2 -> list.filter { it.lastModified > Calendar.getInstance().apply { add(Calendar.MONTH, -1) }.timeInMillis } it.lastModified > Calendar.getInstance()
3 -> list.filter { it.lastModified > Calendar.getInstance().apply { add(Calendar.MONTH, -3) }.timeInMillis } .apply { add(Calendar.WEEK_OF_YEAR, -1) }.timeInMillis
4 -> list.filter { it.lastModified > Calendar.getInstance().apply { add(Calendar.MONTH, -6) }.timeInMillis } }
5 -> list.filter { it.lastModified > Calendar.getInstance().apply { add(Calendar.YEAR, -1) }.timeInMillis }
2 -> list.filter {
it.lastModified > Calendar.getInstance()
.apply { add(Calendar.MONTH, -1) }.timeInMillis
}
3 -> list.filter {
it.lastModified > Calendar.getInstance()
.apply { add(Calendar.MONTH, -3) }.timeInMillis
}
4 -> list.filter {
it.lastModified > Calendar.getInstance()
.apply { add(Calendar.MONTH, -6) }.timeInMillis
}
5 -> list.filter {
it.lastModified > Calendar.getInstance()
.apply { add(Calendar.YEAR, -1) }.timeInMillis
}
else -> { else -> {
list list
} }
......
...@@ -8,7 +8,6 @@ import androidx.activity.addCallback ...@@ -8,7 +8,6 @@ import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.databinding.ActivityScreenshotCleanBinding import com.base.pdfviewerscannerwhite.databinding.ActivityScreenshotCleanBinding
import com.base.pdfviewerscannerwhite.ui.result.ResultActivity import com.base.pdfviewerscannerwhite.ui.result.ResultActivity
...@@ -72,7 +71,7 @@ class ScreenshotCleanActivity : BaseActivity2() { ...@@ -72,7 +71,7 @@ class ScreenshotCleanActivity : BaseActivity2() {
binding.tvDelete.setOnClickListener { binding.tvDelete.setOnClickListener {
if (total <= 0) return@setOnClickListener if (total <= 0) return@setOnClickListener
DialogHelps.showDeleteDialog(this, binding.tvDelete) { DialogHelps.showDeleteDialog(this, binding.tvDelete) {
AdmobInterstitialUtils.showInterstitialAd(this, false, false) { admobMaxShowInterstitialAd (true) {
startActivity(Intent(this, ResultActivity::class.java).apply { startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", ConstObject.FUNCTION_WHATSAPP) putExtra("from", ConstObject.FUNCTION_WHATSAPP)
putExtra("clean_size", total) putExtra("clean_size", total)
......
...@@ -8,13 +8,11 @@ import androidx.activity.addCallback ...@@ -8,13 +8,11 @@ import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.SimilarBean import com.base.pdfviewerscannerwhite.bean.SimilarBean
import com.base.pdfviewerscannerwhite.databinding.ActivitySimilarPhotosBinding import com.base.pdfviewerscannerwhite.databinding.ActivitySimilarPhotosBinding
import com.base.pdfviewerscannerwhite.ui.result.ResultActivity import com.base.pdfviewerscannerwhite.ui.result.ResultActivity
import com.base.pdfviewerscannerwhite.utils.LogEx
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
...@@ -49,7 +47,7 @@ class SimilarPhotosActivity : BaseActivity2() { ...@@ -49,7 +47,7 @@ class SimilarPhotosActivity : BaseActivity2() {
// loadingDialog = DialogHelps.showLoadingDialog(this) // loadingDialog = DialogHelps.showLoadingDialog(this)
} }
} }
AdmobNativeUtils.showNativeAd(this,binding.adNative) AdmobManager.showNativeAd(this,binding.adNative)
onBackPressedDispatcher.addCallback { onBackPressedDispatcher.addCallback {
handleBackPressed(this@SimilarPhotosActivity) handleBackPressed(this@SimilarPhotosActivity)
} }
...@@ -76,7 +74,7 @@ class SimilarPhotosActivity : BaseActivity2() { ...@@ -76,7 +74,7 @@ class SimilarPhotosActivity : BaseActivity2() {
if (list.isEmpty()) return@setOnClickListener if (list.isEmpty()) return@setOnClickListener
val total = list.sumOf { it.size } val total = list.sumOf { it.size }
DialogHelps.showDeleteDialog(this, binding.tvDelete) { DialogHelps.showDeleteDialog(this, binding.tvDelete) {
AdmobInterstitialUtils.showInterstitialAd(this, false, false) { admobMaxShowInterstitialAd (true) {
startActivity(Intent(this, ResultActivity::class.java).apply { startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", ConstObject.FUNCTION_SIMILAR) putExtra("from", ConstObject.FUNCTION_SIMILAR)
putExtra("clean_size", total) putExtra("clean_size", total)
......
...@@ -2,15 +2,12 @@ package com.base.pdfviewerscannerwhite.mix ...@@ -2,15 +2,12 @@ package com.base.pdfviewerscannerwhite.mix
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.databinding.ActivityWhatsappCleanDetailBinding import com.base.pdfviewerscannerwhite.databinding.ActivityWhatsappCleanDetailBinding
import com.base.pdfviewerscannerwhite.ui.result.ResultActivity import com.base.pdfviewerscannerwhite.ui.result.ResultActivity
...@@ -77,7 +74,8 @@ class WhatsappCleanDetailActivity : BaseActivity2() { ...@@ -77,7 +74,8 @@ class WhatsappCleanDetailActivity : BaseActivity2() {
binding.tvDelete.setOnClickListener { binding.tvDelete.setOnClickListener {
if (total <= 0) return@setOnClickListener if (total <= 0) return@setOnClickListener
DialogHelps.showDeleteDialog(this, binding.tvDelete) { DialogHelps.showDeleteDialog(this, binding.tvDelete) {
AdmobInterstitialUtils.showInterstitialAd(this, false, false) {
admobMaxShowInterstitialAd(true) {
startActivity(Intent(this, ResultActivity::class.java).apply { startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", ConstObject.FUNCTION_WHATSAPP) putExtra("from", ConstObject.FUNCTION_WHATSAPP)
putExtra("clean_size", total) putExtra("clean_size", total)
......
...@@ -13,8 +13,7 @@ import android.text.Spanned ...@@ -13,8 +13,7 @@ import android.text.Spanned
import android.text.style.ForegroundColorSpan import android.text.style.ForegroundColorSpan
import android.view.View import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.AppBean import com.base.pdfviewerscannerwhite.bean.AppBean
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.databinding.ActivityAppProcessBinding import com.base.pdfviewerscannerwhite.databinding.ActivityAppProcessBinding
...@@ -78,11 +77,7 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() { ...@@ -78,11 +77,7 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() {
override fun initListener() { override fun initListener() {
super.initListener() super.initListener()
onBackPressedDispatcher.addCallback { onBackPressedDispatcher.addCallback {
if (AdmobHelper.isBackShowAd()) { admobMaxShowInterstitialAd(isShow = AdmobManager.isShowAdBackInter()) {
AdmobInterstitialUtils.showInterstitialAd(this@AppProcessActivity) {
finishToMain()
}
} else {
finishToMain() finishToMain()
} }
} }
...@@ -91,19 +86,13 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() { ...@@ -91,19 +86,13 @@ class AppProcessActivity : BaseActivity<ActivityAppProcessBinding>() {
} }
binding.tvBtn.setOnClickListener { binding.tvBtn.setOnClickListener {
if (AdmobHelper.isBackShowAd()) { admobMaxShowInterstitialAd(true) {
AdmobInterstitialUtils.showInterstitialAd(this) {
startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", ConstObject.FUNCTION_APP_PROCESS)
})
finish()
}
} else {
startActivity(Intent(this, ResultActivity::class.java).apply { startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", ConstObject.FUNCTION_APP_PROCESS) putExtra("from", ConstObject.FUNCTION_APP_PROCESS)
}) })
finish() finish()
} }
} }
} }
......
...@@ -7,7 +7,7 @@ import android.view.View ...@@ -7,7 +7,7 @@ import android.view.View
import android.view.animation.LinearInterpolator import android.view.animation.LinearInterpolator
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.databinding.ActivityAppProcessLoadingBinding import com.base.pdfviewerscannerwhite.databinding.ActivityAppProcessLoadingBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.utils.BarUtils import com.base.pdfviewerscannerwhite.utils.BarUtils
...@@ -51,7 +51,7 @@ class AppProcessLoadingActivity : BaseActivity<ActivityAppProcessLoadingBinding> ...@@ -51,7 +51,7 @@ class AppProcessLoadingActivity : BaseActivity<ActivityAppProcessLoadingBinding>
} }
} }
jumpAction = { jumpAction = {
AdmobInterstitialUtils.showInterstitialAd(this) { admobMaxShowInterstitialAd {
startActivity(Intent(this, AppProcessActivity::class.java)) startActivity(Intent(this, AppProcessActivity::class.java))
finish() finish()
} }
...@@ -62,7 +62,7 @@ class AppProcessLoadingActivity : BaseActivity<ActivityAppProcessLoadingBinding> ...@@ -62,7 +62,7 @@ class AppProcessLoadingActivity : BaseActivity<ActivityAppProcessLoadingBinding>
super.initListener() super.initListener()
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
jumpAction = null jumpAction = null
AdmobInterstitialUtils.showInterstitialAd(this) { admobMaxShowInterstitialAd(isShow = AdmobManager.isShowAdBackInter()) {
finishToMain() finishToMain()
} }
} }
......
...@@ -9,7 +9,6 @@ import android.widget.Toast ...@@ -9,7 +9,6 @@ import android.widget.Toast
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.animation.doOnEnd import androidx.core.animation.doOnEnd
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_SCAM_JUNK import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_SCAM_JUNK
import com.base.pdfviewerscannerwhite.databinding.ActivityLayoutCleanupingBinding import com.base.pdfviewerscannerwhite.databinding.ActivityLayoutCleanupingBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
...@@ -82,27 +81,27 @@ class CleaningActivity : BaseActivity<ActivityLayoutCleanupingBinding>() { ...@@ -82,27 +81,27 @@ class CleaningActivity : BaseActivity<ActivityLayoutCleanupingBinding>() {
binding.idTvJd.text = "${it.animatedValue as Int}" binding.idTvJd.text = "${it.animatedValue as Int}"
} }
doOnEnd { doOnEnd {
val isCleanEndAdSp = AppPreferences.getInstance().getString("isCleanEndAdSp", "1").toInt() startActivity(
if (isCleanEndAdSp == 1) { Intent(this@CleaningActivity, ResultActivity::class.java).apply {
AdmobInterstitialUtils.showInterstitialAd(this@CleaningActivity) { putExtra("from", FUNCTION_SCAM_JUNK)
startActivity( putExtra("clean_size", intentSize)
Intent(this@CleaningActivity, ResultActivity::class.java).apply {
putExtra("from", FUNCTION_SCAM_JUNK)
putExtra("clean_size", intentSize)
}
)
finish()
} }
} else { )
startActivity( finish()
Intent(this@CleaningActivity, ResultActivity::class.java).apply { // val isCleanEndAdSp = AppPreferences.getInstance().getString("isCleanEndAdSp", "1").toInt()
putExtra("from", FUNCTION_SCAM_JUNK) // if (isCleanEndAdSp == 1) {
putExtra("clean_size", intentSize) // AdmobInterstitialUtils.showInterstitialAd(this@CleaningActivity) {
} //
) // }
finish() // } else {
} // startActivity(
// Intent(this@CleaningActivity, ResultActivity::class.java).apply {
// putExtra("from", FUNCTION_SCAM_JUNK)
// putExtra("clean_size", intentSize)
// }
// )
// finish()
// }
} }
start() start()
} }
......
...@@ -11,10 +11,8 @@ import android.view.View ...@@ -11,10 +11,8 @@ import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.ChildBean import com.base.pdfviewerscannerwhite.bean.ChildBean
import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_SCAM_JUNK import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_SCAM_JUNK
import com.base.pdfviewerscannerwhite.bean.ParentBean import com.base.pdfviewerscannerwhite.bean.ParentBean
...@@ -86,51 +84,35 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() { ...@@ -86,51 +84,35 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() {
beginScan() beginScan()
binding.root.postDelayed({ binding.root.postDelayed({
AdmobInterstitialUtils.showInterstitialAd(this) admobMaxShowInterstitialAd { }
}, 2000) }, 2000)
} }
override fun initListener() { override fun initListener() {
super.initListener()
onBackPressedDispatcher.addCallback { onBackPressedDispatcher.addCallback {
if (AdmobHelper.isBackShowAd()) { admobMaxShowInterstitialAd(isShow = AdmobManager.isShowAdBackInter()) {
AdmobInterstitialUtils.showInterstitialAd(this@ScanJunkActivity, false) {
finishToMain()
}
} else {
finishToMain() finishToMain()
} }
} }
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
} }
binding.tvBtn.setOnClickListener { binding.tvBtn.setOnClickListener {
if (binding.tvBtn.text == "Got it") { admobMaxShowInterstitialAd(true) {
if (AdmobHelper.isBackShowAd()) { if (binding.tvBtn.text == "Got it") {
AdmobInterstitialUtils.showInterstitialAd(this) {
startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", FUNCTION_SCAM_JUNK)
})
finish()
}
} else {
startActivity(Intent(this, ResultActivity::class.java).apply { startActivity(Intent(this, ResultActivity::class.java).apply {
putExtra("from", FUNCTION_SCAM_JUNK) putExtra("from", FUNCTION_SCAM_JUNK)
}) })
finish() finish()
} else {
startActivity(Intent(this, CleaningActivity::class.java).apply {
val list = junkExpandAdapter.getChoosePath()
putExtra("list", list.toTypedArray())
putExtra("size", cleanSize)
})
finish()
} }
} else {
startActivity(Intent(this, CleaningActivity::class.java).apply {
val list = junkExpandAdapter.getChoosePath()
putExtra("list", list.toTypedArray())
putExtra("size", cleanSize)
})
finish()
} }
} }
} }
...@@ -155,7 +137,8 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() { ...@@ -155,7 +137,8 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() {
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES), Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES),
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC), Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC),
).forEach { dir -> ).forEach { dir ->
val list = getFileFolder(mPathFlow, dir, filter = { it.listFiles().isNullOrEmpty() }).await() val list =
getFileFolder(mPathFlow, dir, filter = { it.listFiles().isNullOrEmpty() }).await()
emptyFolder.addAll(list) emptyFolder.addAll(list)
} }
size = emptyFolder.sumOf { it.length() } size = emptyFolder.sumOf { it.length() }
...@@ -189,9 +172,12 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() { ...@@ -189,9 +172,12 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() {
if (apkList.isNotEmpty()) { if (apkList.isNotEmpty()) {
val childList2 = apkList.map { val childList2 = apkList.map {
ChildBean(R.mipmap.d_useless, it.absolutePath).apply { apkIcon = getApkDrawable(it.absolutePath) } ChildBean(R.mipmap.d_useless, it.absolutePath).apply {
apkIcon = getApkDrawable(it.absolutePath)
}
} }
val apkParent = ParentBean(tittle = "Useless installation package", childItem = childList2) val apkParent =
ParentBean(tittle = "Useless installation package", childItem = childList2)
junkExpandAdapter.addData(listOf(apkParent), false) junkExpandAdapter.addData(listOf(apkParent), false)
junkExpandAdapter.expandAllGroup() junkExpandAdapter.expandAllGroup()
} }
...@@ -231,7 +217,8 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() { ...@@ -231,7 +217,8 @@ class ScanJunkActivity : BaseActivity<ActivityScanJunkBinding>() {
} }
private fun getApkDrawable(apkPath: String): Drawable? { private fun getApkDrawable(apkPath: String): Drawable? {
val packageInfo = packageManager.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES) val packageInfo =
packageManager.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES)
if (packageInfo != null) { if (packageInfo != null) {
val applicationInfo = packageInfo.applicationInfo val applicationInfo = packageInfo.applicationInfo
return packageManager.getApplicationIcon(applicationInfo) return packageManager.getApplicationIcon(applicationInfo)
......
...@@ -12,9 +12,7 @@ import androidx.activity.addCallback ...@@ -12,9 +12,7 @@ import androidx.activity.addCallback
import androidx.core.widget.addTextChangedListener import androidx.core.widget.addTextChangedListener
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding import com.base.pdfviewerscannerwhite.databinding.ActivityExcelBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
...@@ -65,13 +63,13 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -65,13 +63,13 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
if (file.exists()) { if (file.exists()) {
binding.tvName.text = file.name binding.tvName.text = file.name
} }
AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in) AdmobManager.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in)
} }
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
binding.mDocView.onDestroy() binding.mDocView.onDestroy()
AdmobNativeUtils.onDestroy() // AdmobNativeUtils.onDestroy()
} }
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
...@@ -83,16 +81,19 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() { ...@@ -83,16 +81,19 @@ class ExcelActivity : BaseActivity<ActivityExcelBinding>() {
cancelSearchUI() cancelSearchUI()
return@addCallback return@addCallback
} }
if (AdmobHelper.isShowCloseDocumentInter()) { admobMaxShowInterstitialAd(isShow = AdmobManager.isShowAdBackInter()) {
AdmobInterstitialUtils.showInterstitialAd(this@ExcelActivity) {
if (it) {
AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
}
binding.root.postDelayed({ finishToMain() }, 500)
}
} else {
binding.root.postDelayed({ finishToMain() }, 500) binding.root.postDelayed({ finishToMain() }, 500)
} }
// if (AdmobHelper.isShowCloseDocumentInter()) {
// AdmobInterstitialUtils.showInterstitialAd(this@ExcelActivity) {
// if (it) {
// AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
// }
// binding.root.postDelayed({ finishToMain() }, 500)
// }
// } else {
// binding.root.postDelayed({ finishToMain() }, 500)
// }
} }
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
......
...@@ -26,10 +26,7 @@ import com.artifex.mupdfdemo.MuPDFView ...@@ -26,10 +26,7 @@ import com.artifex.mupdfdemo.MuPDFView
import com.artifex.mupdfdemo.SearchTask import com.artifex.mupdfdemo.SearchTask
import com.artifex.mupdfdemo.SearchTaskResult import com.artifex.mupdfdemo.SearchTaskResult
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.isShowCloseDocument
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SAVE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SAVE_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.haveGuideGesture import com.base.pdfviewerscannerwhite.bean.ConstObject.haveGuideGesture
import com.base.pdfviewerscannerwhite.databinding.ActivityPdfBinding import com.base.pdfviewerscannerwhite.databinding.ActivityPdfBinding
...@@ -84,7 +81,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -84,7 +81,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
muPDFCore?.onDestroy() muPDFCore?.onDestroy()
AdmobNativeUtils.onDestroy() // AdmobNativeUtils.onDestroy()
pdfPageAdapter?.release() pdfPageAdapter?.release()
} }
...@@ -154,7 +151,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -154,7 +151,7 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
} }
} }
AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in) AdmobManager.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in)
} }
override fun jumpPage(pageIndex: Int) { override fun jumpPage(pageIndex: Int) {
...@@ -203,17 +200,19 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -203,17 +200,19 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
cancelOperation() cancelOperation()
return@addCallback return@addCallback
} }
admobMaxShowInterstitialAd {
if (AdmobHelper.isShowCloseDocumentInter() && isShowCloseDocument()) {
AdmobInterstitialUtils.showInterstitialAd(this@PdfActivity) {
if (it) {
AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
}
binding.root.postDelayed({ finishToMain() }, 500)
}
} else {
binding.root.postDelayed({ finishToMain() }, 500) binding.root.postDelayed({ finishToMain() }, 500)
} }
// if (AdmobHelper.isShowCloseDocumentInter() && isShowCloseDocument()) {
// AdmobInterstitialUtils.showInterstitialAd(this@PdfActivity) {
// if (it) {
// AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
// }
// binding.root.postDelayed({ finishToMain() }, 500)
// }
// } else {
// binding.root.postDelayed({ finishToMain() }, 500)
// }
} }
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
...@@ -240,8 +239,10 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -240,8 +239,10 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
binding.mupdfReaderView.setMode(MuPDFReaderView.Mode.Drawing) binding.mupdfReaderView.setMode(MuPDFReaderView.Mode.Drawing)
} }
binding.ivWancheng.setOnClickListener { binding.ivWancheng.setOnClickListener {
changeEditSaveUI() admobMaxShowInterstitialAd(true) {
binding.mupdfReaderView.setMode(MuPDFReaderView.Mode.Viewing) changeEditSaveUI()
binding.mupdfReaderView.setMode(MuPDFReaderView.Mode.Viewing)
}
} }
binding.ivBianji.setOnClickListener { binding.ivBianji.setOnClickListener {
bianJiScaleXiao { bianJiScaleXiao {
...@@ -268,13 +269,16 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView { ...@@ -268,13 +269,16 @@ class PdfActivity : BaseActivity<ActivityPdfBinding>(), PdfView {
} }
binding.tvBtnSave.setOnClickListener { binding.tvBtnSave.setOnClickListener {
PdfLoadingActivity.muPDFCore = muPDFCore admobMaxShowInterstitialAd(true) {
reallySave() PdfLoadingActivity.muPDFCore = muPDFCore
startActivity(Intent(this, PdfLoadingActivity::class.java).apply { reallySave()
putExtra("doWhat", DO_SAVE_PDF) startActivity(Intent(this, PdfLoadingActivity::class.java).apply {
putExtra("srcPath", path) putExtra("doWhat", DO_SAVE_PDF)
}) putExtra("srcPath", path)
finish() })
finish()
}
} }
binding.ivXuanzhuan.setOnClickListener { binding.ivXuanzhuan.setOnClickListener {
switchOrientation() switchOrientation()
......
...@@ -3,8 +3,6 @@ package com.base.pdfviewerscannerwhite.ui.document.pdf ...@@ -3,8 +3,6 @@ package com.base.pdfviewerscannerwhite.ui.document.pdf
import android.content.Intent import android.content.Intent
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.artifex.mupdfdemo.MuPDFCore import com.artifex.mupdfdemo.MuPDFCore
import com.base.pdfviewerscannerwhite.ads.AdmobHelper
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_MERGE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_MERGE_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SAVE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SAVE_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SPLIT_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SPLIT_PDF
...@@ -46,13 +44,16 @@ class PdfLoadingActivity : BaseActivity<ActivityPdfLoadingBinding>() { ...@@ -46,13 +44,16 @@ class PdfLoadingActivity : BaseActivity<ActivityPdfLoadingBinding>() {
} }
fun progressFinishAd(next: () -> Unit) { fun progressFinishAd(next: () -> Unit) {
if (AdmobHelper.canCommonShowAd()) { admobMaxShowInterstitialAd {
AdmobInterstitialUtils.showInterstitialAd(this) {
next.invoke()
}
} else {
next.invoke() next.invoke()
} }
// if (AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(this) {
// next.invoke()
// }
// } else {
// next.invoke()
// }
} }
......
...@@ -57,11 +57,13 @@ class PdfMergeActivity : BaseActivity<ActivityPdfMergeBinding>() { ...@@ -57,11 +57,13 @@ class PdfMergeActivity : BaseActivity<ActivityPdfMergeBinding>() {
verificationPasswordDialogs { verificationPasswordDialogs {
showDocumentRenameDialog(name = "Merge_${System.currentTimeMillis().toFormatTime2()}", okAction = { name -> showDocumentRenameDialog(name = "Merge_${System.currentTimeMillis().toFormatTime2()}", okAction = { name ->
startActivity(Intent(this, PdfLoadingActivity::class.java).apply { admobMaxShowInterstitialAd (true){
putExtra("doWhat", DO_MERGE_PDF) startActivity(Intent(this, PdfLoadingActivity::class.java).apply {
putExtra("newPath", pdfPresenter.createNewPdfPath(name)) putExtra("doWhat", DO_MERGE_PDF)
}) putExtra("newPath", pdfPresenter.createNewPdfPath(name))
finish() })
finish()
}
}) })
} }
......
...@@ -6,8 +6,6 @@ import android.view.View ...@@ -6,8 +6,6 @@ import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_LOCK_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_LOCK_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_MERGE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_MERGE_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SPLIT_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.DO_SPLIT_PDF
...@@ -19,7 +17,6 @@ import com.base.pdfviewerscannerwhite.helper.MyApplication ...@@ -19,7 +17,6 @@ import com.base.pdfviewerscannerwhite.helper.MyApplication
import com.base.pdfviewerscannerwhite.ui.main.DocumentAdapter import com.base.pdfviewerscannerwhite.ui.main.DocumentAdapter
import com.base.pdfviewerscannerwhite.ui.main.DocumentPresenter import com.base.pdfviewerscannerwhite.ui.main.DocumentPresenter
import com.base.pdfviewerscannerwhite.ui.main.DocumentView import com.base.pdfviewerscannerwhite.ui.main.DocumentView
import com.base.pdfviewerscannerwhite.ui.main.MainActivity.Companion.jumpDocument
import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
...@@ -89,10 +86,11 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView ...@@ -89,10 +86,11 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView
binding.tvBtnNext.setOnClickListener { binding.tvBtnNext.setOnClickListener {
if (doWhat == DO_MERGE_PDF) { if (doWhat == DO_MERGE_PDF) {
val selectList = adapter.items.filter { it.isSelect } val selectList = adapter.items.filter { it.isSelect }
PdfMergeActivity.mergePdfList.clear() PdfMergeActivity.mergePdfList.clear()
PdfMergeActivity.mergePdfList.addAll(selectList) PdfMergeActivity.mergePdfList.addAll(selectList)
startActivity(Intent(this, PdfMergeActivity::class.java)) startActivity(Intent(this, PdfMergeActivity::class.java))
} }
} }
} }
...@@ -122,24 +120,30 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView ...@@ -122,24 +120,30 @@ class PdfSelectActivity : BaseActivity<ActivityPdfSelectBinding>(), DocumentView
} }
if (doWhat == DO_LOCK_PDF) { if (doWhat == DO_LOCK_PDF) {
showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = { showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = {
if (AdmobHelper.canCommonShowAd()) { admobMaxShowInterstitialAd(true) {
AdmobInterstitialUtils.showInterstitialAd(this) { flag ->
adapter.remove(it)
}
} else {
adapter.remove(it) adapter.remove(it)
} }
// if (AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(this) { flag ->
// adapter.remove(it)
// }
// } else {
// adapter.remove(it)
// }
}) })
} }
if (doWhat == DO_UNLOCK_PDF) { if (doWhat == DO_UNLOCK_PDF) {
showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = { showPdfPwdDialog(state = it.state, path = it.path, encryptionAction = {
if (AdmobHelper.canCommonShowAd()) { admobMaxShowInterstitialAd(true) {
AdmobInterstitialUtils.showInterstitialAd(this) { flag ->
adapter.remove(it)
}
} else {
adapter.remove(it) adapter.remove(it)
} }
// if (AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(this) { flag ->
// adapter.remove(it)
// }
// } else {
// adapter.remove(it)
// }
}) })
} }
} }
......
...@@ -58,14 +58,16 @@ class PdfSplitActivity : BaseActivity<ActivityPdfSplitBinding>(), PdfView { ...@@ -58,14 +58,16 @@ class PdfSplitActivity : BaseActivity<ActivityPdfSplitBinding>(), PdfView {
binding.tvBtnSplit.setOnClickListener { binding.tvBtnSplit.setOnClickListener {
val splitIndex = pdfPagerAdapter.items.filter { it.isSelect }.map { it.pageIndex } val splitIndex = pdfPagerAdapter.items.filter { it.isSelect }.map { it.pageIndex }
showDocumentRenameDialog(okAction = { newName -> showDocumentRenameDialog(okAction = { newName ->
startActivity(Intent(this, PdfLoadingActivity::class.java).apply { admobMaxShowInterstitialAd(true) {
putExtra("doWhat", ConstObject.DO_SPLIT_PDF) startActivity(Intent(this, PdfLoadingActivity::class.java).apply {
putExtra("srcPath", path) putExtra("doWhat", ConstObject.DO_SPLIT_PDF)
putExtra("pwd", pwd) putExtra("srcPath", path)
putExtra("newPath", pdfPresenter.createNewPdfPath(newName)) putExtra("pwd", pwd)
putExtra("splitIndex", splitIndex.joinToString(separator = ",")) putExtra("newPath", pdfPresenter.createNewPdfPath(newName))
}) putExtra("splitIndex", splitIndex.joinToString(separator = ","))
finish() })
finish()
}
}) })
} }
} }
......
...@@ -10,9 +10,7 @@ import android.view.animation.TranslateAnimation ...@@ -10,9 +10,7 @@ import android.view.animation.TranslateAnimation
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.view.isVisible import androidx.core.view.isVisible
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding import com.base.pdfviewerscannerwhite.databinding.ActivityPptBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
...@@ -81,28 +79,31 @@ class PptActivity : BaseActivity<ActivityPptBinding>() { ...@@ -81,28 +79,31 @@ class PptActivity : BaseActivity<ActivityPptBinding>() {
LogEx.logDebug(TAG, "show") LogEx.logDebug(TAG, "show")
} }
} }
AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in) AdmobManager.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in)
} }
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
binding.mDocView.onDestroy() binding.mDocView.onDestroy()
AdmobNativeUtils.onDestroy() // AdmobNativeUtils.onDestroy()
} }
override fun initListener() { override fun initListener() {
super.initListener() super.initListener()
onBackPressedDispatcher.addCallback { onBackPressedDispatcher.addCallback {
if (AdmobHelper.isShowCloseDocumentInter()) { admobMaxShowInterstitialAd (isShow = AdmobManager.isShowAdBackInter()){
AdmobInterstitialUtils.showInterstitialAd(this@PptActivity) {
if (it) {
AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
}
binding.root.postDelayed({ finishToMain() }, 500)
}
} else {
binding.root.postDelayed({ finishToMain() }, 500) binding.root.postDelayed({ finishToMain() }, 500)
} }
// if (AdmobHelper.isShowCloseDocumentInter()) {
// AdmobInterstitialUtils.showInterstitialAd(this@PptActivity) {
// if (it) {
// AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
// }
//
// }
// } else {
// binding.root.postDelayed({ finishToMain() }, 500)
// }
} }
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
......
...@@ -14,9 +14,7 @@ import androidx.core.content.ContextCompat ...@@ -14,9 +14,7 @@ import androidx.core.content.ContextCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.widget.addTextChangedListener import androidx.core.widget.addTextChangedListener
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.databinding.ActivityWordBinding import com.base.pdfviewerscannerwhite.databinding.ActivityWordBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
...@@ -80,7 +78,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() { ...@@ -80,7 +78,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
LogEx.logDebug(TAG, "show") LogEx.logDebug(TAG, "show")
} }
} }
AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in) AdmobManager.showNativeAd(this, binding.flAd, R.layout.layout_admob_document_in)
} }
private fun setVerticalSeekbar(current: Int, max: Int) { private fun setVerticalSeekbar(current: Int, max: Int) {
...@@ -104,16 +102,19 @@ class WordActivity : BaseActivity<ActivityWordBinding>() { ...@@ -104,16 +102,19 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
return@addCallback return@addCallback
} }
LogEx.logDebug(TAG, "finishToMain") LogEx.logDebug(TAG, "finishToMain")
if (AdmobHelper.isShowCloseDocumentInter()) { admobMaxShowInterstitialAd {
AdmobInterstitialUtils.showInterstitialAd(this@WordActivity) {
if (it) {
AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
}
binding.root.postDelayed({ finishToMain() }, 500)
}
} else {
binding.root.postDelayed({ finishToMain() }, 500) binding.root.postDelayed({ finishToMain() }, 500)
} }
// if (AdmobHelper.isShowCloseDocumentInter()) {
// AdmobInterstitialUtils.showInterstitialAd(this@WordActivity) {
// if (it) {
// AdmobHelper.lastCloseDocumentShowAd = System.currentTimeMillis()
// }
// binding.root.postDelayed({ finishToMain() }, 500)
// }
// } else {
// binding.root.postDelayed({ finishToMain() }, 500)
// }
} }
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
...@@ -344,7 +345,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() { ...@@ -344,7 +345,7 @@ class WordActivity : BaseActivity<ActivityWordBinding>() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
binding.mDocView.onDestroy() binding.mDocView.onDestroy()
AdmobNativeUtils.onDestroy() // AdmobNativeUtils.onDestroy()
} }
} }
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ui.guide
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.databinding.FragmentFullScreenBinding
import com.base.pdfviewerscannerwhite.helper.BaseFragment
class AdFragment : BaseFragment<FragmentFullScreenBinding>() {
override val binding: FragmentFullScreenBinding by lazy {
FragmentFullScreenBinding.inflate(layoutInflater)
}
var page: Int = 2
override fun setView() {
binding.idClose.setOnClickListener {
(requireActivity() as GuideActivity).changePage(3)
}
AdmobManager.showNativeAd(requireActivity(), binding.idFlNative, layout = R.layout.native_layout_full)
}
}
\ No newline at end of file
...@@ -6,6 +6,7 @@ import androidx.activity.addCallback ...@@ -6,6 +6,7 @@ import androidx.activity.addCallback
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.databinding.ActivityGuideBinding import com.base.pdfviewerscannerwhite.databinding.ActivityGuideBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.helper.MyApplication import com.base.pdfviewerscannerwhite.helper.MyApplication
...@@ -14,16 +15,20 @@ import com.base.pdfviewerscannerwhite.ui.permission.PermissionActivity ...@@ -14,16 +15,20 @@ import com.base.pdfviewerscannerwhite.ui.permission.PermissionActivity
class GuideActivity : BaseActivity<ActivityGuideBinding>() { class GuideActivity : BaseActivity<ActivityGuideBinding>() {
private val page1 by lazy { private val page1 by lazy {
GuidePageFragment(1) GuidePageFragment().apply { page = 0 }
} }
private val page2 by lazy { private val page2 by lazy {
GuidePageFragment(2) GuidePageFragment().apply { page = 1 }
} }
private val adPage: AdFragment by lazy {
AdFragment().apply { page = 2 }
}
private val page3 by lazy { private val page3 by lazy {
GuidePageFragment(3) GuidePageFragment().apply { page = 3 }
} }
private val fragments = arrayOf(page1, page2, page3) private val fragments = mutableListOf(page1, page2, adPage, page3)
override val binding: ActivityGuideBinding by lazy { override val binding: ActivityGuideBinding by lazy {
ActivityGuideBinding.inflate(layoutInflater) ActivityGuideBinding.inflate(layoutInflater)
...@@ -31,12 +36,13 @@ class GuideActivity : BaseActivity<ActivityGuideBinding>() { ...@@ -31,12 +36,13 @@ class GuideActivity : BaseActivity<ActivityGuideBinding>() {
override fun initView() { override fun initView() {
if (!AdmobManager.checkNative()) {
fragments.removeAt(2)
}
updateAppLanguage(MyApplication.guideLanguage) { updateAppLanguage(MyApplication.guideLanguage) {
MyApplication.guideLanguage = it MyApplication.guideLanguage = it
} }
binding.viewPager2.visibility = View.VISIBLE
initViewPager2() initViewPager2()
// showGuideDialog(close = { // showGuideDialog(close = {
...@@ -72,7 +78,11 @@ class GuideActivity : BaseActivity<ActivityGuideBinding>() { ...@@ -72,7 +78,11 @@ class GuideActivity : BaseActivity<ActivityGuideBinding>() {
} }
binding.viewPager2.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { binding.viewPager2.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { override fun onPageScrolled(
position: Int,
positionOffset: Float,
positionOffsetPixels: Int
) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels) super.onPageScrolled(position, positionOffset, positionOffsetPixels)
} }
......
...@@ -4,40 +4,46 @@ import android.content.Intent ...@@ -4,40 +4,46 @@ import android.content.Intent
import android.view.View import android.view.View
import androidx.core.view.isEmpty import androidx.core.view.isEmpty
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.databinding.FragmentGuidePageBinding import com.base.pdfviewerscannerwhite.databinding.FragmentGuidePageBinding
import com.base.pdfviewerscannerwhite.helper.BaseFragment import com.base.pdfviewerscannerwhite.helper.BaseFragment
import com.base.pdfviewerscannerwhite.ui.permission.PermissionActivity import com.base.pdfviewerscannerwhite.ui.permission.PermissionActivity
class GuidePageFragment( class GuidePageFragment : BaseFragment<FragmentGuidePageBinding>() {
val page: Int = 1 var page: Int = 0
) : BaseFragment<FragmentGuidePageBinding>() {
override val binding: FragmentGuidePageBinding by lazy { override val binding: FragmentGuidePageBinding by lazy {
FragmentGuidePageBinding.inflate(layoutInflater) FragmentGuidePageBinding.inflate(layoutInflater)
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (binding.flAd.isEmpty()) { // if (binding.flAd.isEmpty()) {
AdmobNativeUtils.showNativeAd(requireActivity(), binding.flAd, R.layout.layout_admob_document_in) // AdmobNativeUtils.showNativeAd(requireActivity(), binding.flAd, R.layout.layout_admob_document_in)
} // }
} }
override fun setView() { override fun setView() {
AdmobNativeUtils.showNativeAd(requireActivity(), binding.flAd, R.layout.layout_admob_document_in) // AdmobNativeUtils.showNativeAd(requireActivity(), binding.flAd, R.layout.layout_admob_document_in)
if (page == 0) {
AdmobManager.showNativeAd(requireActivity(), binding.flAd)
} else {
AdmobManager.showNativeAd(
requireActivity(),
binding.flAd, isShowAdNative = AdmobManager.isShowAdNativeBottom()
)
}
when (page) { when (page) {
1 -> { 0 -> {
binding.tvNo.text = "1 / " binding.tvNo.text = "1 / "
binding.tv1.text = requireContext().getString(R.string.discover_the_feature_of_smart_pdf_reader) binding.tv1.text =
requireContext().getString(R.string.discover_the_feature_of_smart_pdf_reader)
binding.tv2.visibility = View.GONE binding.tv2.visibility = View.GONE
binding.iv.setImageResource(R.mipmap.ydyetu2) binding.iv.setImageResource(R.mipmap.ydyetu2)
binding.tvBtn.text = requireContext().getString(R.string.next) binding.tvBtn.text = requireContext().getString(R.string.next)
} }
2 -> { 1 -> {
binding.tvNo.text = "2 / " binding.tvNo.text = "2 / "
binding.tv1.text = requireContext().getString(R.string.easy_and_immersive_to_read) binding.tv1.text = requireContext().getString(R.string.easy_and_immersive_to_read)
binding.tv2.visibility = View.VISIBLE binding.tv2.visibility = View.VISIBLE
...@@ -46,6 +52,15 @@ class GuidePageFragment( ...@@ -46,6 +52,15 @@ class GuidePageFragment(
binding.tvBtn.text = requireContext().getString(R.string.next) binding.tvBtn.text = requireContext().getString(R.string.next)
} }
2 -> {
binding.tvNo.text = "3 / "
binding.tv1.text = getString(R.string.pdf_toolkit_solutions)
binding.tv2.visibility = View.VISIBLE
binding.tv2.text = getString(R.string.convert_multiple_file_types)
binding.iv.setImageResource(R.mipmap.ydyetu4)
binding.tvBtn.text = requireContext().getString(R.string.go_to_start)
}
3 -> { 3 -> {
binding.tvNo.text = "3 / " binding.tvNo.text = "3 / "
binding.tv1.text = getString(R.string.pdf_toolkit_solutions) binding.tv1.text = getString(R.string.pdf_toolkit_solutions)
...@@ -67,19 +82,25 @@ class GuidePageFragment( ...@@ -67,19 +82,25 @@ class GuidePageFragment(
private fun click() { private fun click() {
val activity = requireActivity() as GuideActivity val activity = requireActivity() as GuideActivity
when (page) { when (page) {
1 -> { 0 -> {
activity.changePage(1) activity.changePage(1)
} }
2 -> { 1 -> {
activity.changePage(2) activity.changePage(2)
} }
3 -> { 2 -> {
// AdmobInterstitialUtils.showInterstitialAd(activity) { activity.changePage(3)
startActivity(Intent(activity, PermissionActivity::class.java)) }
requireActivity().finish()
// } else -> {
ConstObject.isFirstStart = false
activity.admobMaxShowInterstitialAd {
startActivity(Intent(activity, PermissionActivity::class.java))
requireActivity().finish()
}
} }
} }
} }
......
...@@ -8,7 +8,6 @@ import android.view.View.OnClickListener ...@@ -8,7 +8,6 @@ import android.view.View.OnClickListener
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.DocumentBean import com.base.pdfviewerscannerwhite.bean.DocumentBean
import com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL import com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_EXCEL
import com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PDF import com.base.pdfviewerscannerwhite.bean.DocumentBean.Companion.TYPE_PDF
...@@ -22,7 +21,6 @@ import com.base.pdfviewerscannerwhite.utils.AppPreferences ...@@ -22,7 +21,6 @@ import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatTime
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
import com.base.pdfviewerscannerwhite.utils.XmlEx.inflate import com.base.pdfviewerscannerwhite.utils.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter import com.chad.library.adapter4.BaseQuickAdapter
import java.io.File import java.io.File
...@@ -43,7 +41,7 @@ class DocumentAdapter(val activity: Activity) : BaseQuickAdapter<DocumentBean, D ...@@ -43,7 +41,7 @@ class DocumentAdapter(val activity: Activity) : BaseQuickAdapter<DocumentBean, D
if (item == null) return if (item == null) return
if (item.isAd) { if (item.isAd) {
val binding = ItemAdBinding.bind(holder.itemView) val binding = ItemAdBinding.bind(holder.itemView)
AdmobNativeUtils.showNativeAd(activity, binding.flAd, R.layout.layout_admob_document) // AdmobNativeUtils.showNativeAd(activity, binding.flAd, R.layout.layout_admob_document)
} else { } else {
val binding = ItemDocumentBinding.bind(holder.itemView) val binding = ItemDocumentBinding.bind(holder.itemView)
changeIcon(item, binding) changeIcon(item, binding)
......
package com.base.pdfviewerscannerwhite.ui.main package com.base.pdfviewerscannerwhite.ui.main
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent import android.content.Intent
import android.view.View import android.view.View
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.lastOpenDocumentShowAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_FINAL_MODIFIED import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_FINAL_MODIFIED
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_NAME_A_Z import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_NAME_A_Z
...@@ -61,7 +56,6 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu ...@@ -61,7 +56,6 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
} }
override fun setListener() { override fun setListener() {
super.setListener()
binding.swipeRefreshLayout.setOnRefreshListener { binding.swipeRefreshLayout.setOnRefreshListener {
val documentFragment = requireParentFragment() as DocumentFragment? val documentFragment = requireParentFragment() as DocumentFragment?
binding.swipeRefreshLayout.isRefreshing = true binding.swipeRefreshLayout.isRefreshing = true
...@@ -117,21 +111,21 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu ...@@ -117,21 +111,21 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
binding.llEmpty.isVisible = arrayList.isEmpty() binding.llEmpty.isVisible = arrayList.isEmpty()
} }
val flag = AdmobHelper.isShowRvNativeAd() //val flag = AdmobHelper.isShowRvNativeAd()
LogEx.logDebug(TAG, "isShowRvNativeAd flag=$flag") // LogEx.logDebug(TAG, "isShowRvNativeAd flag=$flag")
if (arrayList.isEmpty()) { // if (arrayList.isEmpty()) {
isEmpty = true // isEmpty = true
binding.flAd.visibility = View.VISIBLE // binding.flAd.visibility = View.VISIBLE
if (flag) { // if (flag) {
AdmobNativeUtils.showNativeAd(requireActivity(), binding.flAd, R.layout.layout_admob_document) // AdmobNativeUtils.showNativeAd(requireActivity(), binding.flAd, R.layout.layout_admob_document)
} // }
} else { // } else {
binding.flAd.visibility = View.GONE // binding.flAd.visibility = View.GONE
if (flag) { // if (flag) {
arrayList.add(1, DocumentBean().apply { isAd = true }) // arrayList.add(1, DocumentBean().apply { isAd = true })
} // }
} // }
adapter.submitList(arrayList) adapter.submitList(arrayList)
} }
// Log.d("glc", "加载数据成功:" + type + " list:" + list.size) // Log.d("glc", "加载数据成功:" + type + " list:" + list.size)
...@@ -173,16 +167,19 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu ...@@ -173,16 +167,19 @@ class DocumentPageFragment() : BaseFragment<FragmentDocumentPageBinding>(), Docu
documentPresenter.saveBookmarkChange(addRemove, path) documentPresenter.saveBookmarkChange(addRemove, path)
} }
adapter.itemClick = { item -> adapter.itemClick = { item ->
if (AdmobHelper.isShowOpenDocumentInter()) { (requireActivity() as MainActivity).admobMaxShowInterstitialAd {
AdmobInterstitialUtils.showInterstitialAd(requireActivity()) {
if (it) {
lastOpenDocumentShowAd = System.currentTimeMillis()
}
requireActivity().jumpDocument(item)
}
} else {
requireActivity().jumpDocument(item) requireActivity().jumpDocument(item)
} }
// if (AdmobHelper.isShowOpenDocumentInter()) {
// AdmobInterstitialUtils.showInterstitialAd(requireActivity()) {
// if (it) {
// lastOpenDocumentShowAd = System.currentTimeMillis()
// }
// requireActivity().jumpDocument(item)
// }
// } else {
// requireActivity().jumpDocument(item)
// }
} }
adapter.moreAction = { item -> adapter.moreAction = { item ->
documentMoreAction.invoke(item) documentMoreAction.invoke(item)
......
...@@ -14,7 +14,7 @@ import androidx.fragment.app.Fragment ...@@ -14,7 +14,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.BuildConfig import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobBannerUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE
...@@ -28,7 +28,6 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_SCREE ...@@ -28,7 +28,6 @@ import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_SCREE
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_SIMILAR import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_SIMILAR
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WEATHER import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WEATHER
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WHATSAPP import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_WHATSAPP
import com.base.pdfviewerscannerwhite.bean.ConstObject.NOTIFICATION_ACTION_ZODIAC
import com.base.pdfviewerscannerwhite.bean.ConstObject.RECENT_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.RECENT_DATA_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.SHORTCUT_MERGE_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.SHORTCUT_MERGE_PDF
import com.base.pdfviewerscannerwhite.bean.ConstObject.SHORTCUT_SCAN_PDF import com.base.pdfviewerscannerwhite.bean.ConstObject.SHORTCUT_SCAN_PDF
...@@ -60,7 +59,6 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission ...@@ -60,7 +59,6 @@ import com.base.pdfviewerscannerwhite.ui.view.DialogView.showStoragePermission
import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import com.base.pdfviewerscannerwhite.ui.view.RateDialog.showRateDialog import com.base.pdfviewerscannerwhite.ui.view.RateDialog.showRateDialog
import com.base.pdfviewerscannerwhite.ui.weather.WeatherInterface import com.base.pdfviewerscannerwhite.ui.weather.WeatherInterface
import com.base.pdfviewerscannerwhite.ui.webview.WebBrowserActivity
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.BarUtils import com.base.pdfviewerscannerwhite.utils.BarUtils
import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments import com.base.pdfviewerscannerwhite.utils.IntentShareUtils.shareMutDocuments
...@@ -203,10 +201,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -203,10 +201,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
} }
return return
} }
if (actionId == NOTIFICATION_ACTION_ZODIAC) {
startActivity(Intent(this, WebBrowserActivity::class.java))
return
}
} }
...@@ -223,9 +218,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -223,9 +218,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
// binding.tvTest.text = "imageUri=$imageUri\n\n\n\npdfUri=$pdfUri" // binding.tvTest.text = "imageUri=$imageUri\n\n\n\npdfUri=$pdfUri"
showDocumentRenameDialog(file.name, showDocumentRenameDialog(file.name,
okAction = { okAction = {
val newFile = File(mainPresenter.getDocumentAppDir(), "$it.pdf") admobMaxShowInterstitialAd(true) {
mainPresenter.copyFile(file, newFile) val newFile = File(mainPresenter.getDocumentAppDir(), "$it.pdf")
this.updateMediaStore() mainPresenter.copyFile(file, newFile)
this.updateMediaStore()
}
}, },
dismissAction = { dismissAction = {
avoidScanThenDialog = false avoidScanThenDialog = false
...@@ -332,7 +329,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -332,7 +329,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
private fun showMainBanner() { private fun showMainBanner() {
if (!bannerShowed) { if (!bannerShowed) {
bannerShowed = true bannerShowed = true
AdmobBannerUtils.showCollapsibleBannerAd(this, true, binding.flBanner) { AdmobManager.showBannerAd(this,binding.flBanner)
// AdmobBannerUtils.showCollapsibleBannerAd(this, true, binding.flBanner) {
//通知弹窗 //通知弹窗
// if (!todayShowNotificationDialog && !checkNotificationPermission()) { // if (!todayShowNotificationDialog && !checkNotificationPermission()) {
// todayShowNotificationDialog = true // todayShowNotificationDialog = true
...@@ -344,7 +342,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView { ...@@ -344,7 +342,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), MainView {
// showRateDialog() // showRateDialog()
// } // }
// } // }
} // }
} }
} }
......
...@@ -11,9 +11,6 @@ import androidx.activity.result.IntentSenderRequest ...@@ -11,9 +11,6 @@ import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LifecycleCoroutineScope
import com.base.pdfviewerscannerwhite.ads.AdmobHelper
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.lastScanShowAd
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.BOOKMARK_DATA_TYPE
import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE import com.base.pdfviewerscannerwhite.bean.ConstObject.DOCUMENT_DATA_TYPE
...@@ -364,17 +361,19 @@ class MainPresenter( ...@@ -364,17 +361,19 @@ class MainPresenter(
fun starAdGmsScan(activity: Activity) { fun starAdGmsScan(activity: Activity) {
(activity as MainActivity).admobMaxShowInterstitialAd {
if (AdmobHelper.isShowScanInter() && AdmobHelper.canCommonShowAd()) {
AdmobInterstitialUtils.showInterstitialAd(activity) {
if (it) {
lastScanShowAd = System.currentTimeMillis()
}
starGmsScan(activity)
}
} else {
starGmsScan(activity) starGmsScan(activity)
} }
// if (AdmobHelper.isShowScanInter() && AdmobHelper.canCommonShowAd()) {
// AdmobInterstitialUtils.showInterstitialAd(activity) {
// if (it) {
// lastScanShowAd = System.currentTimeMillis()
// }
// starGmsScan(activity)
// }
// } else {
// starGmsScan(activity)
// }
} }
......
...@@ -45,7 +45,6 @@ import com.base.pdfviewerscannerwhite.ui.set.SetActivity ...@@ -45,7 +45,6 @@ import com.base.pdfviewerscannerwhite.ui.set.SetActivity
import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog import com.base.pdfviewerscannerwhite.ui.view.PdfDialog.showPdfPwdDialog
import com.base.pdfviewerscannerwhite.ui.view.ProgressBean import com.base.pdfviewerscannerwhite.ui.view.ProgressBean
import com.base.pdfviewerscannerwhite.ui.weather.WeatherInterface import com.base.pdfviewerscannerwhite.ui.weather.WeatherInterface
import com.base.pdfviewerscannerwhite.ui.webview.WebBrowserActivity
import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize import com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatSize
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission import com.base.pdfviewerscannerwhite.utils.PermissionUtils.checkStorePermission
...@@ -204,9 +203,7 @@ class ToolFragment : BaseFragment<FragmentToolBinding>() { ...@@ -204,9 +203,7 @@ class ToolFragment : BaseFragment<FragmentToolBinding>() {
binding.llWeather.setOnClickListener { binding.llWeather.setOnClickListener {
startActivity(Intent(requireContext(), WeatherInterface::class.java)) startActivity(Intent(requireContext(), WeatherInterface::class.java))
} }
binding.tvZodiac.setOnClickListener {
startActivity(Intent(requireContext(), WebBrowserActivity::class.java))
}
} }
override fun onResume() { override fun onResume() {
......
package com.base.pdfviewerscannerwhite.ui.permission package com.base.pdfviewerscannerwhite.ui.permission
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
...@@ -11,10 +10,8 @@ import android.text.style.ForegroundColorSpan ...@@ -11,10 +10,8 @@ import android.text.style.ForegroundColorSpan
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.postDelayed
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.databinding.ActivityPermissionBinding import com.base.pdfviewerscannerwhite.databinding.ActivityPermissionBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.helper.MyApplication import com.base.pdfviewerscannerwhite.helper.MyApplication
...@@ -60,8 +57,7 @@ class PermissionActivity : BaseActivity<ActivityPermissionBinding>() { ...@@ -60,8 +57,7 @@ class PermissionActivity : BaseActivity<ActivityPermissionBinding>() {
override fun initListener() { override fun initListener() {
super.initListener() super.initListener()
onBackPressedDispatcher.addCallback { onBackPressedDispatcher.addCallback {
admobMaxShowInterstitialAd {
AdmobInterstitialUtils.showInterstitialAd(this@PermissionActivity) {
binding.root.postDelayed({ finishToMain() }, 300) binding.root.postDelayed({ finishToMain() }, 300)
} }
......
...@@ -5,7 +5,7 @@ import android.content.Intent ...@@ -5,7 +5,7 @@ import android.content.Intent
import android.graphics.Color import android.graphics.Color
import androidx.activity.addCallback import androidx.activity.addCallback
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_APP_PROCESS import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_APP_PROCESS
import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_LARGEFILE import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_LARGEFILE
import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_SCAM_JUNK import com.base.pdfviewerscannerwhite.bean.ConstObject.FUNCTION_SCAM_JUNK
...@@ -36,7 +36,7 @@ class ResultActivity : BaseActivity<ActivityResultBinding>() { ...@@ -36,7 +36,7 @@ class ResultActivity : BaseActivity<ActivityResultBinding>() {
BarUtils.setStatusBarLightMode(this, true) BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.parseColor("#00B7DD")) BarUtils.setStatusBarColor(this, Color.parseColor("#00B7DD"))
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight()) // binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_app_exit) AdmobManager.showNativeAd(this, binding.flAd, R.layout.layout_admob_app_exit)
from = intent.extras?.getString("from") ?: "" from = intent.extras?.getString("from") ?: ""
...@@ -146,9 +146,11 @@ class ResultActivity : BaseActivity<ActivityResultBinding>() { ...@@ -146,9 +146,11 @@ class ResultActivity : BaseActivity<ActivityResultBinding>() {
} }
override fun initListener() { override fun initListener() {
super.initListener()
onBackPressedDispatcher.addCallback { onBackPressedDispatcher.addCallback {
finishToMainTop() admobMaxShowInterstitialAd (isShow = AdmobManager.isShowAdResultBackInter()){
finishToMainTop()
}
} }
binding.flFanhui.setOnClickListener { binding.flFanhui.setOnClickListener {
onBackPressedDispatcher.onBackPressed() onBackPressedDispatcher.onBackPressed()
......
...@@ -3,7 +3,7 @@ package com.base.pdfviewerscannerwhite.ui.set ...@@ -3,7 +3,7 @@ package com.base.pdfviewerscannerwhite.ui.set
import android.content.Intent import android.content.Intent
import androidx.activity.addCallback import androidx.activity.addCallback
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.bean.ConstObject.appLanguageSp import com.base.pdfviewerscannerwhite.bean.ConstObject.appLanguageSp
import com.base.pdfviewerscannerwhite.bean.ConstObject.changeLanguageSp import com.base.pdfviewerscannerwhite.bean.ConstObject.changeLanguageSp
...@@ -12,7 +12,6 @@ import com.base.pdfviewerscannerwhite.bean.LanguageBean ...@@ -12,7 +12,6 @@ import com.base.pdfviewerscannerwhite.bean.LanguageBean
import com.base.pdfviewerscannerwhite.databinding.ActivitySetLanguageBinding import com.base.pdfviewerscannerwhite.databinding.ActivitySetLanguageBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity import com.base.pdfviewerscannerwhite.helper.BaseActivity
import com.base.pdfviewerscannerwhite.ui.guide.GuideActivity import com.base.pdfviewerscannerwhite.ui.guide.GuideActivity
import com.base.pdfviewerscannerwhite.ui.permission.PermissionActivity
import com.base.pdfviewerscannerwhite.utils.LanguageUtils.getSystemLanguageDefault import com.base.pdfviewerscannerwhite.utils.LanguageUtils.getSystemLanguageDefault
import java.util.Locale import java.util.Locale
...@@ -30,7 +29,7 @@ class SetLanguageActivity : BaseActivity<ActivitySetLanguageBinding>() { ...@@ -30,7 +29,7 @@ class SetLanguageActivity : BaseActivity<ActivitySetLanguageBinding>() {
adapter = LanguageAdapter() adapter = LanguageAdapter()
binding.rv.adapter = adapter binding.rv.adapter = adapter
AdmobNativeUtils.showNativeAd(this, binding.flAd) AdmobManager.showNativeAd(this, binding.flAd)
initData() initData()
} }
......
...@@ -5,13 +5,12 @@ import android.annotation.SuppressLint ...@@ -5,13 +5,12 @@ import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.CountDownTimer
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.BuildConfig import com.base.pdfviewerscannerwhite.BuildConfig
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.initAdmobAd import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobOpenUtils
import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy import com.base.pdfviewerscannerwhite.bean.ConstObject.ifAgreePrivacy
import com.base.pdfviewerscannerwhite.bean.ConstObject.isFirstStart import com.base.pdfviewerscannerwhite.bean.ConstObject.isFirstStart
import com.base.pdfviewerscannerwhite.databinding.ActivitySplash2Binding import com.base.pdfviewerscannerwhite.databinding.ActivitySplash2Binding
...@@ -141,55 +140,94 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView { ...@@ -141,55 +140,94 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
} }
} }
private var isLoadAdComplete = false
override fun showAd() { override fun showAd() {
LogEx.logDebug(TAG, "showAd") LogEx.logDebug(TAG, "showAd")
if (AdmobOpenUtils.haveReadAd()) { AdmobManager.init(
showReadOpenAd() this,
} else { {
if (AdmobInterstitialUtils.haveReadAd()) { if (isFinishing || isDestroyed) return@init
showReadInterAd() isLoadAdComplete = true
} else { // showProgress(binding.pb.progress,10)
LogEx.logDebug("time",System.currentTimeMillis().toString()+"loadAppOpenAd") when (it) {
0 -> {
AdmobOpenUtils.loadAppOpenAd { loaded -> countdownTimer.start()
LogEx.logDebug("time",System.currentTimeMillis().toString()+"loaded")
LogEx.logDebug(TAG, "loadAppOpenAd loaded=$loaded")
if (loaded) {
showReadOpenAd()
} else {
LogEx.logDebug(TAG, "no load ad jumpNext")
jumpNext()
} }
1 -> {
AdmobManager.showInterstitialAd(
this,
dismissed = { delayedToHome() },
failed = { delayedToHome() }
)
}
else -> { jumpNext() }
} }
}, {
delayedToHome()
} }
} )
// if (AdmobOpenUtils.haveReadAd()) {
// showReadOpenAd()
// } else {
// if (AdmobInterstitialUtils.haveReadAd()) {
// showReadInterAd()
// } else {
// LogEx.logDebug("time",System.currentTimeMillis().toString()+"loadAppOpenAd")
//
// AdmobOpenUtils.loadAppOpenAd { loaded ->
// LogEx.logDebug("time",System.currentTimeMillis().toString()+"loaded")
// LogEx.logDebug(TAG, "loadAppOpenAd loaded=$loaded")
// if (loaded) {
// showReadOpenAd()
// } else {
// LogEx.logDebug(TAG, "no load ad jumpNext")
// jumpNext()
// }
// }
// }
// }
} }
private val countdownTimer = object : CountDownTimer(3000, 1000) {
override fun onTick(millisUntilFinished: Long) {
val seconds = (millisUntilFinished / 1000).toInt()
binding.tvAdDes.text = "This process may contain ads (${seconds})"
}
override fun onFinish() {
AdmobManager.showAppOpenAd(
this@SplashActivity,
dismissed = { delayedToHome() },
failed = { delayedToHome() }
)
}
}
private fun delayedToHome() {
binding.root.postDelayed({ jumpNext() }, 300)
}
private fun showReadOpenAd() { private fun showReadOpenAd() {
AdmobOpenUtils.showAppOpenAd(this, showBefore = { // AdmobOpenUtils.showAppOpenAd(this, showBefore = {
LogEx.logDebug("time",System.currentTimeMillis().toString()+"showReadOpenAd") // LogEx.logDebug("time",System.currentTimeMillis().toString()+"showReadOpenAd")
if (it) { // if (it) {
splashPresenter.pauseJumpJob() // splashPresenter.pauseJumpJob()
} // }
}, onHidden = { // }, onHidden = {
LogEx.logDebug(TAG, "ad jumpNext") // LogEx.logDebug(TAG, "ad jumpNext")
jumpNext() // jumpNext()
}) // })
} }
private fun showReadInterAd() { private fun showReadInterAd() {
splashPresenter.pauseJumpJob() // splashPresenter.pauseJumpJob()
AdmobInterstitialUtils.showInterstitialAd(this) { // AdmobInterstitialUtils.showInterstitialAd(this) {
jumpNext() // jumpNext()
} // }
} }
override fun agreePrivacy() { override fun agreePrivacy() {
if (umpCanAd) { if (umpCanAd) {
LogEx.logDebug("time",System.currentTimeMillis().toString()+"_agreePrivacy") LogEx.logDebug("time",System.currentTimeMillis().toString()+"_agreePrivacy")
initAdmobAd(this) // initAdmobAd(this)
showAd() showAd()
splashPresenter.startJumpJob = true splashPresenter.startJumpJob = true
splashPresenter.startJumpJob(lifecycleScope) splashPresenter.startJumpJob(lifecycleScope)
...@@ -245,7 +283,6 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView { ...@@ -245,7 +283,6 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
} }
private fun firstStartJump() { private fun firstStartJump() {
isFirstStart = false
if (Locale.getDefault().language != Locale.ENGLISH.language) { if (Locale.getDefault().language != Locale.ENGLISH.language) {
startActivity(Intent(this, SetLanguageActivity::class.java)) startActivity(Intent(this, SetLanguageActivity::class.java))
} else { } else {
......
package com.base.pdfviewerscannerwhite.ui.splash package com.base.pdfviewerscannerwhite.ui.splash
import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LifecycleCoroutineScope
import com.base.pdfviewerscannerwhite.ads.AdmobHelper.open_ad_loading
import com.base.pdfviewerscannerwhite.bean.ConstObject import com.base.pdfviewerscannerwhite.bean.ConstObject
import com.base.pdfviewerscannerwhite.utils.AppPreferences import com.base.pdfviewerscannerwhite.utils.AppPreferences
import com.base.pdfviewerscannerwhite.utils.LogEx import com.base.pdfviewerscannerwhite.utils.LogEx
...@@ -16,7 +15,7 @@ class SplashPresenter( ...@@ -16,7 +15,7 @@ class SplashPresenter(
private var jumpJob: Job? = null private var jumpJob: Job? = null
var loadingTime = AppPreferences.getInstance().getString(open_ad_loading, "15").toInt() var loadingTime = AppPreferences.getInstance().getString("open_ad_loading", "15").toInt()
var startJumpJob: Boolean = false var startJumpJob: Boolean = false
......
...@@ -21,7 +21,7 @@ import android.widget.LinearLayout ...@@ -21,7 +21,7 @@ import android.widget.LinearLayout
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.widget.addTextChangedListener import androidx.core.widget.addTextChangedListener
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_FINAL_MODIFIED import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_FINAL_MODIFIED
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_LAST_MODIFIED import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_LAST_MODIFIED
import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_NAME_A_Z import com.base.pdfviewerscannerwhite.bean.ConstObject.UI_SORT_NAME_A_Z
...@@ -497,7 +497,7 @@ object DialogView { ...@@ -497,7 +497,7 @@ object DialogView {
//展开 //展开
behavior.state = BottomSheetBehavior.STATE_EXPANDED behavior.state = BottomSheetBehavior.STATE_EXPANDED
AdmobNativeUtils.showNativeAd(this, binding.flAd, R.layout.layout_admob_app_exit) AdmobManager.showNativeAd(this, binding.flAd, R.layout.layout_admob_app_exit)
binding.cardNo.setOnClickListener { binding.cardNo.setOnClickListener {
finish() finish()
......
...@@ -127,8 +127,11 @@ object PdfDialog { ...@@ -127,8 +127,11 @@ object PdfDialog {
firstDialog = dialog, firstDialog = dialog,
isCheckPwd = false, isCheckPwd = false,
encryptionAction = { encryptionAction = {
dialog.dismiss() mainActivity.admobMaxShowInterstitialAd(true) {
mainActivity.mainPresenter.changePdfLock(item, documentPageFragment) dialog.dismiss()
mainActivity.mainPresenter.changePdfLock(item, documentPageFragment)
}
}) })
} }
dialog.setOnDismissListener { dialog.setOnDismissListener {
......
...@@ -12,9 +12,7 @@ import androidx.core.view.isVisible ...@@ -12,9 +12,7 @@ import androidx.core.view.isVisible
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.base.pdfviewerscannerwhite.R import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.AdmobHelper import com.base.pdfviewerscannerwhite.ads.admob.AdmobManager
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.bean.ListBean import com.base.pdfviewerscannerwhite.bean.ListBean
import com.base.pdfviewerscannerwhite.bean.WeatherBean import com.base.pdfviewerscannerwhite.bean.WeatherBean
import com.base.pdfviewerscannerwhite.databinding.ActivityWeatherBinding import com.base.pdfviewerscannerwhite.databinding.ActivityWeatherBinding
...@@ -34,7 +32,7 @@ class WeatherInterface : BaseActivity<ActivityWeatherBinding>() { ...@@ -34,7 +32,7 @@ class WeatherInterface : BaseActivity<ActivityWeatherBinding>() {
binding.root.updatePadding(top = BarUtils.getStatusBarHeight()) binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
getData() getData()
AdmobNativeUtils.showNativeAd(this, binding.idFlAd)
} }
override fun initListener() { override fun initListener() {
...@@ -43,12 +41,7 @@ class WeatherInterface : BaseActivity<ActivityWeatherBinding>() { ...@@ -43,12 +41,7 @@ class WeatherInterface : BaseActivity<ActivityWeatherBinding>() {
} }
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) { onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {
admobMaxShowInterstitialAd(isShow = AdmobManager.isShowAdBackInter()) {
if (AdmobHelper.isBackShowAd()) {
AdmobInterstitialUtils.showInterstitialAd(this@WeatherInterface) {
finishToMain()
}
} else {
finishToMain() finishToMain()
} }
} }
...@@ -64,8 +57,9 @@ class WeatherInterface : BaseActivity<ActivityWeatherBinding>() { ...@@ -64,8 +57,9 @@ class WeatherInterface : BaseActivity<ActivityWeatherBinding>() {
WeatherUtils.requestWeatherData() WeatherUtils.requestWeatherData()
} }
binding.root.postDelayed({ binding.root.postDelayed({
AdmobInterstitialUtils.showInterstitialAd(this, false) { admobMaxShowInterstitialAd {
binding.idFlLoading.isVisible = false binding.idFlLoading.isVisible = false
AdmobManager.showNativeAd(this, binding.idFlAd)
} }
}, Random.nextLong(800, 2000)) }, Random.nextLong(800, 2000))
......
package com.base.pdfviewerscannerwhite.ui.webview
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.net.http.SslError
import android.view.View
import android.webkit.CookieManager
import android.webkit.JsResult
import android.webkit.SslErrorHandler
import android.webkit.ValueCallback
import android.webkit.WebChromeClient
import android.webkit.WebResourceError
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebSettings
import android.webkit.WebStorage
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope
import com.base.pdfviewerscannerwhite.R
import com.base.pdfviewerscannerwhite.ads.admob.AdmobInterstitialUtils
import com.base.pdfviewerscannerwhite.ads.admob.AdmobNativeUtils
import com.base.pdfviewerscannerwhite.databinding.ActivityWebBrowserBinding
import com.base.pdfviewerscannerwhite.helper.BaseActivity
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlin.random.Random
class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
override val binding: ActivityWebBrowserBinding by lazy {
ActivityWebBrowserBinding.inflate(layoutInflater)
}
var showed: Boolean = false
override fun initView() {
initWebSettings()
binding.webView.loadUrl("https://www.horoscope.com/us/index.aspx")
AdmobNativeUtils.showNativeAd(this, binding.flNative, R.layout.layout_admob_document_in)
AdmobInterstitialUtils.showInterstitialAd(this) {
showed = it
}
}
override fun initListener() {
super.initListener()
binding.refreshLayout.setOnRefreshListener {
lifecycleScope.launch {
binding.refreshLayout.isRefreshing = true
delay(Random.nextLong(1500, 2500))
binding.refreshLayout.isRefreshing = false
}
binding.webView.reload()
}
onBackPressedDispatcher.addCallback {
if (binding.webView.canGoBack()) {
binding.webView.goBack()
} else {
if (showed) {
finishToMainTop()
} else {
AdmobInterstitialUtils.showInterstitialAd(this@WebBrowserActivity) {
finishToMainTop()
}
}
}
}
}
@SuppressLint("JavascriptInterface")
private fun initWebSettings() {
val webSettings = binding.webView.settings
webSettings.allowFileAccess = true// 设置允许访问文件数据
webSettings.setSupportZoom(false)
webSettings.builtInZoomControls = true
webSettings.cacheMode = WebSettings.LOAD_NO_CACHE
webSettings.domStorageEnabled = true
webSettings.databaseEnabled = true
@Suppress("DEPRECATION")
webSettings.allowFileAccessFromFileURLs = true
WebStorage.getInstance().deleteAllData()
// 关键性代码,这里要给webView添加这行代码,才可以点击之后正常播放音频。记录一下。
webSettings.mediaPlaybackRequiresUserGesture = false
//设置WebView属性,能够执行Javascript脚本
webSettings.javaScriptEnabled = true
//设置混合内容模式:对于HTTPS和HTTP混合内容的加载,需要设置WebView以允许混合内容:
webSettings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
//使用CookieManager设置允许跨域Cookie
CookieManager.getInstance().setAcceptThirdPartyCookies(binding.webView, true)
//适应屏幕设置
webSettings.useWideViewPort = true
webSettings.loadWithOverviewMode = true
//网页使用localStorage等Web存储API,需要启用DOM存储
webSettings.domStorageEnabled = true
webSettings.setUseWideViewPort(false)
webSettings.setLoadsImagesAutomatically(true) // 确保自动加载图片
//设置WebChromeClient
binding.webView.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView, newProgress: Int) {
binding.progressBar.progress = newProgress
if (binding.progressBar.progress >= 100) {
binding.progressBar.visibility = View.GONE
}
}
override fun onReceivedTitle(view: WebView?, title: String?) {
super.onReceivedTitle(view, title)
}
override fun onShowFileChooser(
webView: WebView?,
filePathCallback: ValueCallback<Array<Uri?>?>,
fileChooserParams: FileChooserParams?
): Boolean {
return true
}
override fun onJsAlert(
view: WebView?,
url: String?,
message: String?,
result: JsResult?
): Boolean = true
}
binding.webView.webViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(view: WebView?, request: WebResourceRequest?): WebResourceResponse? {
val url = request?.url.toString()
if (url.contains("//ads.") || url.contains("https://play.google.com")) {
return WebResourceResponse(null, null, null) // 拦截广告请
}
return super.shouldInterceptRequest(view, request)
}
override fun onLoadResource(view: WebView?, url: String?) {
super.onLoadResource(view, url)
}
override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?
): Boolean {
if (request != null) {
val uri = request.url
val scheme = uri.scheme
// 检查 URL 是否是 scheme 类型
if (scheme != null && (scheme == "http" || scheme == "https")) {
} else {
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
if (packageManager != null && intent.resolveActivity(packageManager) != null) {
startActivity(intent)
}
return true // 返回 true,表示 URL 已经被处理
}
return super.shouldOverrideUrlLoading(view, request)
}
return false
}
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
}
override fun onPageFinished(view: WebView?, url: String?) {
val jsCode = "javascript:" +
"var ads = document.querySelectorAll('.ad-container');" + // 替换为广告的CSS选择器
"for (var i = 0; i < ads.length; i++) {" +
" ads[i].parentNode.removeChild(ads[i]);" +
"}"
view?.loadUrl(jsCode)
}
override fun onReceivedSslError(
view: WebView?,
handler: SslErrorHandler?,
error: SslError?
) {
}
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
error: WebResourceError?
) {
super.onReceivedError(view, request, error)
}
}
//设置Cookie
val instance = CookieManager.getInstance()
instance.setAcceptThirdPartyCookies(binding.webView, true)
binding.webView.addJavascriptInterface(this, "android")
binding.webView.swipeRefreshLayout = binding.refreshLayout
}
}
\ No newline at end of file
package com.base.pdfviewerscannerwhite.ui.webview
import android.content.Context
import android.util.AttributeSet
import android.webkit.WebView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
/**
*Create by SleepDog on 2025-01-21
*/
class WebRefreshView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null
) : WebView(context, attrs) {
var swipeRefreshLayout: SwipeRefreshLayout? = null
override fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int) {
super.onScrollChanged(l, t, oldl, oldt)
swipeRefreshLayout?.isEnabled = scrollY == 0
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colo_00b8de"/>
<corners android:radius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colo_00b8de"/>
<corners android:radius="4dp"/>
</shape>
\ No newline at end of file
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
<androidx.viewpager2.widget.ViewPager2 <androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager2" android:id="@+id/viewPager2"
android:visibility="invisible"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...@@ -168,14 +168,6 @@ ...@@ -168,14 +168,6 @@
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
<com.base.pdfviewerscannerwhite.mix.NativeView
android:id="@+id/ad_native"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="10dp"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/ll_tab" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_empty" android:id="@+id/iv_empty"
...@@ -195,7 +187,7 @@ ...@@ -195,7 +187,7 @@
android:paddingVertical="6dp" android:paddingVertical="6dp"
android:scrollbars="none" android:scrollbars="none"
app:layout_constraintBottom_toTopOf="@id/tv_delete" app:layout_constraintBottom_toTopOf="@id/tv_delete"
app:layout_constraintTop_toBottomOf="@id/ad_native" /> app:layout_constraintTop_toBottomOf="@id/ll_tab" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_delete" android:id="@+id/tv_delete"
...@@ -212,7 +204,7 @@ ...@@ -212,7 +204,7 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent" /> app:layout_constraintBottom_toTopOf="@+id/id_fl_ad" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_tab" android:id="@+id/cl_tab"
...@@ -257,6 +249,12 @@ ...@@ -257,6 +249,12 @@
</androidx.appcompat.widget.LinearLayoutCompat> </androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<FrameLayout
android:id="@+id/id_fl_ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" />
<include <include
android:id="@+id/animation" android:id="@+id/animation"
layout="@layout/custom_animation" layout="@layout/custom_animation"
......
...@@ -86,14 +86,6 @@ ...@@ -86,14 +86,6 @@
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<com.base.pdfviewerscannerwhite.mix.NativeView
android:id="@+id/ad_native"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="10dp"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/cl_select" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_photo" android:id="@+id/rv_photo"
...@@ -102,7 +94,7 @@ ...@@ -102,7 +94,7 @@
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"
android:scrollbars="none" android:scrollbars="none"
app:layout_constraintBottom_toTopOf="@id/tv_delete" app:layout_constraintBottom_toTopOf="@id/tv_delete"
app:layout_constraintTop_toBottomOf="@id/ad_native" /> app:layout_constraintTop_toBottomOf="@id/cl_select" />
<TextView <TextView
android:id="@+id/tv_delete" android:id="@+id/tv_delete"
...@@ -117,6 +109,13 @@ ...@@ -117,6 +109,13 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/ad_native" />
<FrameLayout
android:id="@+id/ad_native"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
app:layout_constraintBottom_toBottomOf="parent" /> app:layout_constraintBottom_toBottomOf="parent" />
<include <include
......
...@@ -122,5 +122,18 @@ ...@@ -122,5 +122,18 @@
android:indeterminateTintMode="src_atop" /> android:indeterminateTintMode="src_atop" />
</FrameLayout> </FrameLayout>
<TextView
android:id="@+id/tv_ad_des"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="This process may contain ads"
android:textColor="#000000"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:ignore="HardcodedText" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progress_bar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="3dp"
android:layout_marginVertical="3dp"
android:max="100"
android:progressDrawable="@drawable/progress_bar_web"
tools:progress="50" />
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.base.pdfviewerscannerwhite.ui.webview.WebRefreshView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<FrameLayout
android:id="@+id/flNative"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_ffffff_10"
android:paddingBottom="16dp">
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:indeterminate="true"
android:indeterminateTint="@color/colo_00b8de"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginBottom="24dp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/progressBar">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ads loading..."
android:textColor="@color/black"
android:textSize="16sp" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_countdown"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:text="(3)"
android:textColor="@color/black"
android:textSize="16sp"
android:visibility="gone" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<FrameLayout
android:id="@+id/id_fl_native"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="@mipmap/adzhangwei" />
</FrameLayout>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/id_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="30dp"
android:src="@mipmap/ic_big_close"
android:tint="@color/black"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.guide.GuidePageFragment"> tools:context=".ui.guide.GuidePageFragment">
<FrameLayout
android:id="@+id/fl_ad"
android:layout_width="match_parent"
android:layout_height="110dp" />
<LinearLayout <LinearLayout
android:id="@+id/llClick" android:id="@+id/llClick"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_below="@id/fl_ad" android:orientation="vertical"
android:orientation="vertical"> app:layout_constraintBottom_toTopOf="@+id/fl_ad"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginTop="8dp" android:layout_marginTop="38dp"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
...@@ -85,22 +84,30 @@ ...@@ -85,22 +84,30 @@
android:src="@mipmap/ydyetu2" android:src="@mipmap/ydyetu2"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tvBtn"
android:layout_width="250dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp"
android:layout_marginBottom="20dp"
android:background="@drawable/bg_00b8de_90"
android:gravity="center"
android:text="@string/go_to_start"
android:textColor="@color/white"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/fl_ad"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/tvBtn" <FrameLayout
android:layout_width="250dp" android:id="@+id/fl_ad"
android:layout_height="50dp" android:layout_width="match_parent"
android:layout_alignParentBottom="true" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" app:layout_constraintBottom_toBottomOf="parent" />
android:layout_gravity="center_horizontal"
android:layout_marginTop="8dp" </androidx.constraintlayout.widget.ConstraintLayout>
android:layout_marginBottom="32dp" \ No newline at end of file
android:background="@drawable/bg_00b8de_90"
android:gravity="center"
android:text="@string/go_to_start"
android:textColor="@color/white"
android:textSize="18sp" />
</RelativeLayout>
\ No newline at end of file
...@@ -73,23 +73,6 @@ ...@@ -73,23 +73,6 @@
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/tv_zodiac"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_marginEnd="16dp"
android:background="@drawable/bg_gradient_zodiac"
android:drawablePadding="3dp"
android:gravity="center"
android:paddingHorizontal="13dp"
android:paddingVertical="8dp"
android:text="@string/zodiac"
android:textColor="@color/white"
android:textSize="15sp"
app:drawableStartCompat="@mipmap/ic_zodiac"
app:layout_constraintBottom_toBottomOf="@id/ll_weather"
app:layout_constraintEnd_toStartOf="@id/ll_weather"
app:layout_constraintTop_toTopOf="@id/ll_weather" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.ads.nativead.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<com.google.android.gms.ads.nativead.MediaView
android:id="@+id/ad_media"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F0F0F0"
android:orientation="vertical"
android:paddingHorizontal="15dp"
android:paddingVertical="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<ImageView
android:id="@+id/ad_app_icon"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_marginStart="18dp"
android:layout_marginEnd="10dp"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_ad"
android:padding="4dp"
android:text="Ad"
android:textColor="@color/white"
android:textSize="10sp"
tools:ignore="HardcodedText" />
<TextView
android:id="@+id/ad_headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/ad_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:ellipsize="end"
android:maxLines="3"
android:textColor="#686868"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/ad_call_to_action"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="20dp"
android:background="@drawable/ad_bottom_bg"
android:gravity="center"
android:textColor="@color/white"
android:textSize="17sp" />
</LinearLayout>
</LinearLayout>
</com.google.android.gms.ads.nativead.NativeAdView>
\ No newline at end of file
...@@ -49,4 +49,5 @@ ...@@ -49,4 +49,5 @@
<color name="color_ffcda0">#FFCDA0</color> <color name="color_ffcda0">#FFCDA0</color>
<color name="color_999999">#999999</color> <color name="color_999999">#999999</color>
<color name="color_e3e6eb">#E3E6EB</color> <color name="color_e3e6eb">#E3E6EB</color>
</resources> </resources>
\ No newline at end of file
...@@ -25,4 +25,5 @@ ...@@ -25,4 +25,5 @@
<item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowBackground">@android:color/transparent</item>
</style> </style>
</resources> </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