Commit 15c83002 authored by wanglei's avatar wanglei

...

parent 669ea17a
...@@ -2,6 +2,7 @@ package com.base.datarecovery.activity ...@@ -2,6 +2,7 @@ package com.base.datarecovery.activity
import android.graphics.Color import android.graphics.Color
import android.graphics.Typeface import android.graphics.Typeface
import android.view.View
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
...@@ -48,10 +49,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>() { ...@@ -48,10 +49,12 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
if (!checkStorePermission()) { if (!checkStorePermission()) {
if (dialog == null) { if (dialog == null) {
dialog = showPermissionBottomSheet(launcher) { dialog = showPermissionBottomSheet(launcher) {
binding.flBanner.visibility = View.VISIBLE
AdmobBannerUtils.showCollapsibleBannerAd(this, binding.flBanner) AdmobBannerUtils.showCollapsibleBannerAd(this, binding.flBanner)
} }
} }
} else { } else {
binding.flBanner.visibility = View.VISIBLE
AdmobBannerUtils.showCollapsibleBannerAd(this, binding.flBanner) AdmobBannerUtils.showCollapsibleBannerAd(this, binding.flBanner)
} }
binding.viewpager2.run { binding.viewpager2.run {
......
...@@ -3,11 +3,14 @@ package com.base.datarecovery.ads.admob ...@@ -3,11 +3,14 @@ package com.base.datarecovery.ads.admob
import android.content.Context import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import androidx.core.view.children
import com.base.datarecovery.BuildConfig import com.base.datarecovery.BuildConfig
import com.base.datarecovery.help.ConfigHelper import com.base.datarecovery.help.ConfigHelper
import com.base.datarecovery.utils.AppPreferences import com.base.datarecovery.utils.AppPreferences
import com.base.datarecovery.utils.LogEx
import com.google.ads.mediation.admob.AdMobAdapter import com.google.ads.mediation.admob.AdMobAdapter
import com.google.android.gms.ads.AdListener import com.google.android.gms.ads.AdListener
import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.AdRequest
...@@ -17,6 +20,7 @@ import java.util.UUID ...@@ -17,6 +20,7 @@ import java.util.UUID
object AdmobBannerUtils { object AdmobBannerUtils {
private val TAG = "AdmobBannerUtils"
private var adView: AdView? = null private var adView: AdView? = null
private var listener: ViewTreeObserver.OnGlobalLayoutListener? = null private var listener: ViewTreeObserver.OnGlobalLayoutListener? = null
...@@ -29,7 +33,15 @@ object AdmobBannerUtils { ...@@ -29,7 +33,15 @@ object AdmobBannerUtils {
adView?.destroy() adView?.destroy()
} }
adView = AdView(context) adView = AdView(context)
parent.removeAllViews() // parent.removeAllViews()
adView?.tag = "CollapsibleBannerAd"
// parent.removeAllViews()
val list = parent.children
list.forEach {
if (it.tag != "zhanweitu") {
parent.removeView(it)
}
}
parent.addView(adView) parent.addView(adView)
listener = ViewTreeObserver.OnGlobalLayoutListener { listener = ViewTreeObserver.OnGlobalLayoutListener {
val screenPixelDensity = context.resources.displayMetrics.density val screenPixelDensity = context.resources.displayMetrics.density
...@@ -37,13 +49,13 @@ object AdmobBannerUtils { ...@@ -37,13 +49,13 @@ object AdmobBannerUtils {
val adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(context, adWidth) val adSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(context, adWidth)
adView?.adUnitId = if (BuildConfig.DEBUG) ConfigHelper.bannerAdmobIdTest else ConfigHelper.bannerAdmobId adView?.adUnitId = if (BuildConfig.DEBUG) ConfigHelper.bannerAdmobIdTest else ConfigHelper.bannerAdmobId
adView?.setAdSize(adSize) adView?.setAdSize(adSize)
loadCollapsibleBanner() loadCollapsibleBanner(parent)
parent.viewTreeObserver.removeOnGlobalLayoutListener(listener) parent.viewTreeObserver.removeOnGlobalLayoutListener(listener)
} }
parent.viewTreeObserver.addOnGlobalLayoutListener(listener) parent.viewTreeObserver.addOnGlobalLayoutListener(listener)
} }
private fun loadCollapsibleBanner() { private fun loadCollapsibleBanner(parent: ViewGroup) {
val extras = Bundle() val extras = Bundle()
extras.putString("collapsible", "bottom") extras.putString("collapsible", "bottom")
extras.putString("collapsible_request_id", UUID.randomUUID().toString()) extras.putString("collapsible_request_id", UUID.randomUUID().toString())
...@@ -52,6 +64,19 @@ object AdmobBannerUtils { ...@@ -52,6 +64,19 @@ object AdmobBannerUtils {
adView?.adListener = adView?.adListener =
object : AdListener() { object : AdListener() {
override fun onAdLoaded() {} override fun onAdLoaded() {}
override fun onAdClosed() {
super.onAdClosed()
LogEx.logDebug(TAG, "onAdClosed")
val removeList = arrayListOf<View>()
parent.children.forEach {
if (it.tag != "CollapsibleBannerAd") {
removeList.add(it)
}
}
removeList.forEach {
parent.removeView(it)
}
}
} }
adView?.loadAd(adRequest) adView?.loadAd(adRequest)
} }
......
...@@ -137,6 +137,7 @@ object AdmobInterstitialUtils { ...@@ -137,6 +137,7 @@ object AdmobInterstitialUtils {
onHidden: (() -> Unit)? onHidden: (() -> Unit)?
) { ) {
if (!isShowDialog) { if (!isShowDialog) {
onHidden?.invoke()
return return
} }
var mDialog: Dialog? = null var mDialog: Dialog? = null
......
...@@ -185,7 +185,7 @@ object AdMaxInterstitialUtils { ...@@ -185,7 +185,7 @@ object AdMaxInterstitialUtils {
if (interstitialAd?.isReady == true) { if (interstitialAd?.isReady == true) {
return false return false
} }
if (isAdInit.get()) { // if (isAdInit.get()) {
LogEx.logDebug(TAG, "loadInterstitialAd") LogEx.logDebug(TAG, "loadInterstitialAd")
val reqId = UUID.randomUUID().toString() val reqId = UUID.randomUUID().toString()
val obj = JSONObject() val obj = JSONObject()
...@@ -195,11 +195,11 @@ object AdMaxInterstitialUtils { ...@@ -195,11 +195,11 @@ object AdMaxInterstitialUtils {
interstitialAd?.loadAd() interstitialAd?.loadAd()
AdDisplayUtils.getInstance().incrementAdRequestCount() AdDisplayUtils.getInstance().incrementAdRequestCount()
return true return true
} else { // } else {
LogEx.logDebug(TAG, "isAdInit=$isAdInit") // LogEx.logDebug(TAG, "isAdInit=$isAdInit")
EventUtils.event("isAdInit", value = "loadInterstitialAd isAdInit=${isAdInit.get()}") // EventUtils.event("isAdInit", value = "loadInterstitialAd isAdInit=${isAdInit.get()}")
} // }
return false // return false
} }
......
...@@ -117,11 +117,11 @@ object AdMaxOpenUtils { ...@@ -117,11 +117,11 @@ object AdMaxOpenUtils {
appOpenAd?.loadAd() appOpenAd?.loadAd()
} }
if (!isAdInit.get()) { // if (!isAdInit.get()) {
EventUtils.event("isAdInit", value = "showAppOpenAd isAdInit=${isAdInit.get()}") // EventUtils.event("isAdInit", value = "showAppOpenAd isAdInit=${isAdInit.get()}")
onHidden?.invoke() // onHidden?.invoke()
return // return
} // }
LogEx.logDebug(TAG, "showAppOpenAd") LogEx.logDebug(TAG, "showAppOpenAd")
...@@ -171,8 +171,8 @@ object AdMaxOpenUtils { ...@@ -171,8 +171,8 @@ object AdMaxOpenUtils {
return false return false
} }
if (isAdInit.get()) { // if (isAdInit.get()) {
EventUtils.event("isAdInit", value = "loadAppOpenAd isAdInit=${isAdInit.get()}") // EventUtils.event("isAdInit", value = "loadAppOpenAd isAdInit=${isAdInit.get()}")
LogEx.logDebug(TAG, "appOpenAd loadAd") LogEx.logDebug(TAG, "appOpenAd loadAd")
val reqId = UUID.randomUUID().toString() val reqId = UUID.randomUUID().toString()
val obj = JSONObject() val obj = JSONObject()
...@@ -182,8 +182,8 @@ object AdMaxOpenUtils { ...@@ -182,8 +182,8 @@ object AdMaxOpenUtils {
appOpenAd?.loadAd() appOpenAd?.loadAd()
AdDisplayUtils.getInstance().incrementAdRequestCount() AdDisplayUtils.getInstance().incrementAdRequestCount()
return true return true
} // }
return false // return false
} }
fun isOpenAdLoaded(): Boolean { fun isOpenAdLoaded(): Boolean {
......
...@@ -12,10 +12,10 @@ public class AppManagerStringManager { ...@@ -12,10 +12,10 @@ public class AppManagerStringManager {
static { static {
// 初始化并添加文案到列表 // 初始化并添加文案到列表
appManagerCopies.add("Keep your device clutter-free with our App Management tool."); appManagerCopies.add("Keep your device clutter-free with our App Management tool.");
appManagerCopies.add("Stay in control. Manage your apps with our intuitive App Management feature."); // appManagerCopies.add("Stay in control. Manage your apps with our intuitive App Management feature.");
appManagerCopies.add("Take charge of your apps. Try our App Management feature for organized bliss."); // appManagerCopies.add("Take charge of your apps. Try our App Management feature for organized bliss.");
appManagerCopies.add("Say goodbye to app chaos. Our App Management feature makes it easy."); appManagerCopies.add("Say goodbye to app chaos. Our App Management feature makes it easy.");
appManagerCopies.add("Simplify your digital life. Experience the ease of our App Management tool."); // appManagerCopies.add("Simplify your digital life. Experience the ease of our App Management tool.");
} }
public static String getNextDesc() { public static String getNextDesc() {
......
...@@ -11,10 +11,10 @@ public class AppProcessStringManager { ...@@ -11,10 +11,10 @@ public class AppProcessStringManager {
static { static {
// 初始化并添加文案到列表 // 初始化并添加文案到列表
appManagerCopies.add("Manage Your Apps: Keep your device running smoothly with our App Process Manager."); appManagerCopies.add("Keep your device running smoothly with our App Process Manager.");
appManagerCopies.add("App Process Alert: Time to clean up your device's background processes."); appManagerCopies.add("Time to clean up your device's background processes.");
appManagerCopies.add("Optimize Performance: Discover which apps are running in the background and manage them with ease."); appManagerCopies.add("Discover which apps are running in the background and manage them with ease.");
appManagerCopies.add("App Process Check: Ensure your device is running efficiently by managing your app processes."); appManagerCopies.add("Ensure your device is running efficiently by managing your app processes.");
} }
public static String getNextPrivacySpaceCopy() { public static String getNextPrivacySpaceCopy() {
......
...@@ -9,11 +9,11 @@ public class DocumentRecoveryStringManager { ...@@ -9,11 +9,11 @@ public class DocumentRecoveryStringManager {
static { static {
// 初始化并添加文案到列表 // 初始化并添加文案到列表
documentRecoveryCopies.add("Lost a vital document? Our recovery service might be able to help."); documentRecoveryCopies.add("Our recovery service might be able to help.");
documentRecoveryCopies.add("Can't find an important document? Try our recovery tool today."); documentRecoveryCopies.add("Try our recovery tool today.");
documentRecoveryCopies.add("Accidentally deleted a document? Recover it with ease using our service."); documentRecoveryCopies.add("Recover it with ease using our service.");
documentRecoveryCopies.add("Don't panic over lost documents – our recovery feature is here to assist."); documentRecoveryCopies.add("our recovery feature is here to assist.");
documentRecoveryCopies.add("Regain access to deleted documents with our simple recovery process."); // documentRecoveryCopies.add("Regain access to deleted documents with our simple recovery process.");
} }
public static String getNextRecoveryCopy() { public static String getNextRecoveryCopy() {
......
...@@ -11,9 +11,9 @@ public class DuplicatePhotoStringResourceManager { ...@@ -11,9 +11,9 @@ public class DuplicatePhotoStringResourceManager {
static { static {
// 添加推送文案到列表 // 添加推送文案到列表
duplicatePhotoCopyList.add("Discover duplicate photos and free up space on your device."); duplicatePhotoCopyList.add("Discover duplicate photos and free up space on your device.");
duplicatePhotoCopyList.add("Neat trick: Find and remove duplicate photos to instantly gain more storage."); duplicatePhotoCopyList.add("Find and remove duplicate photos to instantly gain more storage.");
duplicatePhotoCopyList.add("Twin photos taking up space? Identify and delete them easily with our app."); duplicatePhotoCopyList.add("Identify and delete them easily with our app.");
duplicatePhotoCopyList.add("Clear the clutter: Spot and remove look-alike photos to free up your phone."); duplicatePhotoCopyList.add("Spot and remove look-alike photos to free up your phone.");
duplicatePhotoCopyList.add("Don't let duplicates drain your storage. Clean up similar photos now."); duplicatePhotoCopyList.add("Don't let duplicates drain your storage. Clean up similar photos now.");
duplicatePhotoCopyList.add("Double trouble? Find and delete duplicate photos to reclaim your space."); duplicatePhotoCopyList.add("Double trouble? Find and delete duplicate photos to reclaim your space.");
} }
......
...@@ -9,11 +9,11 @@ public class PhotoRecoveryStringManager { ...@@ -9,11 +9,11 @@ public class PhotoRecoveryStringManager {
static { static {
// 添加照片恢复功能的推送文案到列表 // 添加照片恢复功能的推送文案到列表
photoRecoveryCopies.add("Lost a precious photo? Our recovery tool can help you find it!"); photoRecoveryCopies.add("Our recovery tool can help you find precious photo!");
photoRecoveryCopies.add("Accidentally deleted a photo? Recover it easily with our app."); photoRecoveryCopies.add("Recover a deleted photo easily with our app.");
photoRecoveryCopies.add("Bring back lost memories: Use our photo recovery feature now."); photoRecoveryCopies.add("Use our photo recovery feature now.");
photoRecoveryCopies.add("Don't let deleted photos stay lost. Restore them with a few taps."); photoRecoveryCopies.add("Restore deleted photos with a few taps.");
photoRecoveryCopies.add("Regret deleting a photo? Try our recovery service to get it back today."); photoRecoveryCopies.add("Try our recovery service to get it back today.");
} }
public static String getNextRecoveryCopy() { public static String getNextRecoveryCopy() {
......
...@@ -11,11 +11,11 @@ public class PrivacySpaceStringManager { ...@@ -11,11 +11,11 @@ public class PrivacySpaceStringManager {
static { static {
// 初始化并添加文案到列表 // 初始化并添加文案到列表
privacySpaceCopies.add("Secure your private content. Tuck away photos and videos in your hidden space."); privacySpaceCopies.add("Tuck away photos and videos in your hidden space.");
privacySpaceCopies.add("Keep your memories safe. Store them in your private hideaway."); privacySpaceCopies.add("Store them in your private hideaway.");
privacySpaceCopies.add("Don't let others see your private moments. Use our secure hideaway."); privacySpaceCopies.add("Don't let others see your private moments.");
privacySpaceCopies.add("Your privacy is important. Lock away your photos and videos securely."); privacySpaceCopies.add("Lock away your photos and videos securely.");
privacySpaceCopies.add("Add an extra layer of security to your personal media with our hidden space."); // privacySpaceCopies.add("Add an extra layer of security to your personal media with our hidden space.");
} }
public static String getNextPrivacySpaceCopy() { public static String getNextPrivacySpaceCopy() {
......
...@@ -10,11 +10,11 @@ public class ScreenshotCleanupStringManager { ...@@ -10,11 +10,11 @@ public class ScreenshotCleanupStringManager {
static { static {
// 添加截图清理功能的推送文案到列表 // 添加截图清理功能的推送文案到列表
screenshotCleanupCopies.add("Declutter your gallery: It's time to remove those old screenshots!"); screenshotCleanupCopies.add("It's time to remove those old screenshots!");
screenshotCleanupCopies.add("Clean up your phone's memory: Delete unwanted screenshots now!"); screenshotCleanupCopies.add("Delete unwanted screenshots now!");
screenshotCleanupCopies.add("Free up space with ease: Get rid of unnecessary screenshots."); screenshotCleanupCopies.add("Get rid of unnecessary screenshots.");
screenshotCleanupCopies.add("Regain control over your storage: Clear out old screenshots today."); screenshotCleanupCopies.add("Clear out old screenshots today.");
screenshotCleanupCopies.add("A tidy phone is a happy phone: Remove excess screenshots and save space."); screenshotCleanupCopies.add("Remove excess screenshots and save space.");
} }
public static String getNextCleanupCopy() { public static String getNextCleanupCopy() {
......
...@@ -9,11 +9,11 @@ public class VideoRecoveryStringManager { ...@@ -9,11 +9,11 @@ public class VideoRecoveryStringManager {
static { static {
// 添加视频恢复功能的推送文案到列表 // 添加视频恢复功能的推送文案到列表
videoRecoveryCopies.add("Regain lost video moments. Start your video recovery now!"); videoRecoveryCopies.add("Start your video recovery now!");
videoRecoveryCopies.add("Don't let lost videos be gone forever. Recover them today with our app."); videoRecoveryCopies.add("Recover lost videos today with our app.");
videoRecoveryCopies.add("Accidentally deleted a video? Our recovery feature can bring it back."); videoRecoveryCopies.add("Our recovery feature can bring it back.");
videoRecoveryCopies.add("Revive those deleted video clips – it's easy with our recovery tool."); videoRecoveryCopies.add("it's easy with our recovery tool.");
videoRecoveryCopies.add("Missing a special video? Try our recovery service to retrieve it."); videoRecoveryCopies.add("Try our recovery service to retrieve it.");
} }
public static String getNextRecoveryCopy() { public static String getNextRecoveryCopy() {
......
...@@ -93,8 +93,18 @@ ...@@ -93,8 +93,18 @@
<FrameLayout <FrameLayout
android:id="@+id/fl_banner" android:id="@+id/fl_banner"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="60dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/ll" /> app:layout_constraintTop_toBottomOf="@id/ll">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/zhanweitu2"
android:tag="zhanweitu"
tools:ignore="ContentDescription" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ 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