Commit c374ad62 authored by maxiaoliang's avatar maxiaoliang

修改需求

parent d7db52cf
...@@ -5,10 +5,10 @@ import android.app.Activity ...@@ -5,10 +5,10 @@ import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils import android.text.TextUtils
import android.util.Log
import com.applovin.sdk.AppLovinMediationProvider import com.applovin.sdk.AppLovinMediationProvider
import com.applovin.sdk.AppLovinSdk import com.applovin.sdk.AppLovinSdk
import com.applovin.sdk.AppLovinSdkInitializationConfiguration import com.applovin.sdk.AppLovinSdkInitializationConfiguration
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.identifier.AdvertisingIdClient import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import com.test.easy.easycleanerjunk.fcm.ActionBroadcast import com.test.easy.easycleanerjunk.fcm.ActionBroadcast
...@@ -52,8 +52,8 @@ class MyApplication : BaseApplication() { ...@@ -52,8 +52,8 @@ class MyApplication : BaseApplication() {
InstallHelps.init() InstallHelps.init()
BlackUtils.requestBlack() BlackUtils.requestBlack()
if (ConfigHelper.ifAgreePrivacy) { if (ConfigHelper.ifAgreePrivacy) {
MobileAds.initialize(this) { initializationStatus -> // MobileAds.initialize(this) { initializationStatus ->
} // }
val executor = Executors.newSingleThreadExecutor() val executor = Executors.newSingleThreadExecutor()
executor.execute { executor.execute {
val initConfigBuilder = AppLovinSdkInitializationConfiguration.builder( val initConfigBuilder = AppLovinSdkInitializationConfiguration.builder(
...@@ -67,6 +67,7 @@ class MyApplication : BaseApplication() { ...@@ -67,6 +67,7 @@ class MyApplication : BaseApplication() {
val initConfig = initConfigBuilder.build() val initConfig = initConfigBuilder.build()
// Initialize the SDK with the configuration // Initialize the SDK with the configuration
AppLovinSdk.getInstance(context).initialize(initConfig) { sdkConfig -> AppLovinSdk.getInstance(context).initialize(initConfig) { sdkConfig ->
Log.e("MXL", "initApp: "+"广告初始化成功" )
} }
executor.shutdown() executor.shutdown()
} }
......
...@@ -15,11 +15,21 @@ import com.test.easy.easycleanerjunk.activity.similarphotos.RepeatPhotoAnimation ...@@ -15,11 +15,21 @@ import com.test.easy.easycleanerjunk.activity.similarphotos.RepeatPhotoAnimation
import com.test.easy.easycleanerjunk.activity.whatsapp.WhatsAppCleanerAnimationActivity import com.test.easy.easycleanerjunk.activity.whatsapp.WhatsAppCleanerAnimationActivity
import com.test.easy.easycleanerjunk.databinding.AtLayoutBackRelustBinding import com.test.easy.easycleanerjunk.databinding.AtLayoutBackRelustBinding
import com.test.easy.easycleanerjunk.helps.BaseActivity import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils
import com.test.easy.easycleanerjunk.utils.BarUtils import com.test.easy.easycleanerjunk.utils.BarUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
import com.test.easy.easycleanerjunk.view.AFunOb import com.test.easy.easycleanerjunk.view.AFunOb
class BackRelsutAt:BaseActivity<AtLayoutBackRelustBinding>() { class BackRelsutAt:BaseActivity<AtLayoutBackRelustBinding>() {
private var homeType = -1
get() {
return SPUtils.getInstance().getInt("homeShowBack", field)
}
set(value) {
field = value
SPUtils.getInstance().put("homeShowBack", value)
}
private val hp = ++homeType % 8
override val binding: AtLayoutBackRelustBinding by lazy { override val binding: AtLayoutBackRelustBinding by lazy {
AtLayoutBackRelustBinding.inflate(layoutInflater) AtLayoutBackRelustBinding.inflate(layoutInflater)
} }
...@@ -53,10 +63,10 @@ class BackRelsutAt:BaseActivity<AtLayoutBackRelustBinding>() { ...@@ -53,10 +63,10 @@ class BackRelsutAt:BaseActivity<AtLayoutBackRelustBinding>() {
listOf(R.mipmap.b_photocompress, "Compress images to save storage space", "Compress", StartCompressionPhotoActivity::class.java), listOf(R.mipmap.b_photocompress, "Compress images to save storage space", "Compress", StartCompressionPhotoActivity::class.java),
listOf(R.mipmap.b_appguanli, "Low on storage space? Free up space on your device by managing unused apps!", "View", AppManagerAnimationActivity::class.java), listOf(R.mipmap.b_appguanli, "Low on storage space? Free up space on your device by managing unused apps!", "View", AppManagerAnimationActivity::class.java),
listOf(R.mipmap.b_similar, "Check similar photos and free up space", "Clean Up", RepeatPhotoAnimationActivity::class.java), listOf(R.mipmap.b_similar, "Check similar photos and free up space", "Clean Up", RepeatPhotoAnimationActivity::class.java),
listOf(R.mipmap.b_screenshot, "Free up storage space by cleaning up screenshots", "View", ScreenShotAnimationActivity::class.java), listOf(R.mipmap.b_screenshot, "Free up storage space by cleaning up screenshots", "View", ScreenShotAnimationActivity::class.java)
).let { ).let {
val item = it[(index + 1) % it.size] // val item = it[(index + 1) % it.size]
val item = it[hp % it.size]
binding.idImg.setImageResource(item[0] as Int) binding.idImg.setImageResource(item[0] as Int)
binding.idTvDesc.text = item[1] as String binding.idTvDesc.text = item[1] as String
binding.idBtn.text = item[2] as String binding.idBtn.text = item[2] as String
...@@ -71,7 +81,10 @@ class BackRelsutAt:BaseActivity<AtLayoutBackRelustBinding>() { ...@@ -71,7 +81,10 @@ class BackRelsutAt:BaseActivity<AtLayoutBackRelustBinding>() {
override fun initListener() { override fun initListener() {
binding.idClose.setOnClickListener { binding.idClose.setOnClickListener {
MaxAdUtils.showInterstitialAd(this){
finishToMain() finishToMain()
} }
}
} }
} }
\ No newline at end of file
...@@ -127,17 +127,21 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() { ...@@ -127,17 +127,21 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) { onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() { override fun handleOnBackPressed() {
// val s = SPUtils.getInstance().getInt("isShowBackIntAd", 0) val s = SPUtils.getInstance().getInt("outcomeReturnCount", 0)
// if (s == 1) { if (s == 0) {
// MaxAdUtils.showInterstitialAd(this@ResultActivity) { val s = SPUtils.getInstance().getInt("isShowBackIntAd", 0)
// finishToMain() if (s == 1) {
// } MaxAdUtils.showInterstitialAd(this@ResultActivity) {
// } else { finishToMain()
// finishToMain() }
// } } else {
finishToMain()
}
}else{
BackRelsutAt.launch(this@ResultActivity, from) BackRelsutAt.launch(this@ResultActivity, from)
finish() finish()
} }
}
}) })
binding.ivBack.setOnClickListener { binding.ivBack.setOnClickListener {
......
package com.test.easy.easycleanerjunk.activity.home package com.test.easy.easycleanerjunk.activity.home
import android.content.Intent
import android.graphics.Color import android.graphics.Color
import android.graphics.Typeface import android.graphics.Typeface
import android.os.Build import android.os.Build
import android.util.Log
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.view.updatePadding
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.test.easy.easycleanerjunk.activity.BackRelsutAt
import com.test.easy.easycleanerjunk.databinding.ActivityMainBinding import com.test.easy.easycleanerjunk.databinding.ActivityMainBinding
import com.test.easy.easycleanerjunk.fragment.HomeFragment import com.test.easy.easycleanerjunk.fragment.HomeFragment
import com.test.easy.easycleanerjunk.fragment.ToolsFragment import com.test.easy.easycleanerjunk.fragment.ToolsFragment
import com.test.easy.easycleanerjunk.helps.BaseActivity import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.EventUtils import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.utils.BarUtils import com.test.easy.easycleanerjunk.utils.BarUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
import com.test.easy.easycleanerjunk.view.NotifyTips import com.test.easy.easycleanerjunk.view.NotifyTips
import com.test.easy.easycleanerjunk.view.PopExitWindow import com.test.easy.easycleanerjunk.view.PopExitWindow
import com.test.easy.easycleanerjunk.view.RateStarPop import com.test.easy.easycleanerjunk.view.RateStarPop
...@@ -43,6 +47,7 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() { ...@@ -43,6 +47,7 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
@RequiresApi(Build.VERSION_CODES.O) @RequiresApi(Build.VERSION_CODES.O)
override fun initView() { override fun initView() {
ConfigHelper.enter_homePage++
BarUtils.setStatusBarLightMode(this, true) BarUtils.setStatusBarLightMode(this, true)
BarUtils.setStatusBarColor(this, Color.TRANSPARENT) BarUtils.setStatusBarColor(this, Color.TRANSPARENT)
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight()) // binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
...@@ -81,6 +86,14 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() { ...@@ -81,6 +86,14 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
PopExitWindow.show(this@NewMainActivity) PopExitWindow.show(this@NewMainActivity)
} }
}) })
Log.e("MXL", "initView: " + ConfigHelper.enter_homePage)
if (ConfigHelper.enter_homePage == 2) {
//第二次进入首页
val s = SPUtils.getInstance().getInt("dayoutcomeHomePage", 0)
if (s == 1) {
startActivity(Intent(this, BackRelsutAt::class.java))
}
}
} }
private fun setPage(p: Int) { private fun setPage(p: Int) {
...@@ -106,11 +119,27 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() { ...@@ -106,11 +119,27 @@ class NewMainActivity : BaseActivity<ActivityMainBinding>() {
RateStarPop.dismiss(this) RateStarPop.dismiss(this)
} }
var isPause = false
override fun onPause() {
super.onPause()
isPause = true
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
lifecycleScope.launch(Dispatchers.Main) { lifecycleScope.launch(Dispatchers.Main) {
delay(1000) delay(1000)
RateStarPop.show(this@NewMainActivity) RateStarPop.show(this@NewMainActivity)
} }
if (isPause) {
val localCount = SPUtils.getInstance().getInt("localCount", 0)
SPUtils.getInstance().put("localCount", localCount + 1)
val n = SPUtils.getInstance().getInt("outcomeReturnHomeCount", 0)
if (n > 0) {
if (localCount % n == 0) {
startActivity(Intent(this, BackRelsutAt::class.java))
}
}
}
} }
} }
...@@ -72,7 +72,10 @@ class NewSplashActivity : BaseActivity<ActivityLayoutSplashBinding>(), ...@@ -72,7 +72,10 @@ class NewSplashActivity : BaseActivity<ActivityLayoutSplashBinding>(),
startNotification() startNotification()
} }
mProgressManager?.startProgress() mProgressManager?.startProgress()
binding.root.postDelayed({
loadAd() loadAd()
},800)
} }
......
...@@ -19,4 +19,8 @@ class ConfigBean() { ...@@ -19,4 +19,8 @@ class ConfigBean() {
var isShowBackIntAd: Int = 0 var isShowBackIntAd: Int = 0
var isShowResultNaAd: Int = 0 var isShowResultNaAd: Int = 0
var loadingPageTime: Int = 15 var loadingPageTime: Int = 15
var outcomeReturnCount: Int = 0//每次从结果页面关闭到首页时
var outcomeReturnHomeCount: Int = 0//返回主页弹几次
var dayoutcomeHomePage: Int = 0 //第二次打开到首页开关
} }
...@@ -2,60 +2,58 @@ package com.test.easy.easycleanerjunk.helps ...@@ -2,60 +2,58 @@ package com.test.easy.easycleanerjunk.helps
import android.util.Log import android.util.Log
import com.google.gson.Gson import com.google.gson.Gson
import com.test.easy.easycleanerjunk.BuildConfig
import com.test.easy.easycleanerjunk.bean.ConfigBean import com.test.easy.easycleanerjunk.bean.ConfigBean
import com.test.easy.easycleanerjunk.helps.ads.AdDisplayUtils import com.test.easy.easycleanerjunk.helps.ads.AdDisplayUtils
import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils.adDisplayInterval import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils.adDisplayInterval
import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils.maxMultiClick import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils.maxMultiClick
import com.test.easy.easycleanerjunk.utils.SPUtils import com.test.easy.easycleanerjunk.utils.SPUtils
import java.io.BufferedReader import okhttp3.Call
import java.io.InputStreamReader import okhttp3.Callback
import java.net.HttpURLConnection import okhttp3.OkHttpClient
import java.net.URL import okhttp3.Request
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import java.io.IOException
object ComUtils { object ComUtils {
//
private val url by lazy { private val url by lazy {
val pkg = ConfigHelper.packageName val pkg = ConfigHelper.packageName
val url = StringBuilder( val url = StringBuilder(
"${ConfigHelper.apiUrl}/${ "${ConfigHelper.apiUrl}/${
pkg.filter { it.isLowerCase() }.substring(4, 9) pkg.filter { it.isLowerCase() }.substring(4, 9)
}cl" }spk"
) )
url.append("?pkg=$pkg") url.append("?pkg=$pkg")
url.append("&source=${SPUtils.getInstance().getString("install_source", "origin")}")
url.toString() url.toString()
} }
fun requestCfg(callback: (ConfigBean) -> Unit) {
fun doGet(): String { val client = OkHttpClient.Builder().apply {
val urlPath = url if (BuildConfig.DEBUG) {
Log.d("okhttp", urlPath ?: "") addInterceptor(HttpLoggingInterceptor().apply {
try { level = HttpLoggingInterceptor.Level.BODY
val conn: HttpURLConnection = URL(urlPath).openConnection() as HttpURLConnection })
conn.setRequestMethod("GET")
conn.connectTimeout = 150000
if (200 == conn.getResponseCode()) {
val json = BufferedReader(InputStreamReader(conn.getInputStream())).readLine()
Log.d("okhttp", json)
return json
}
} catch (e: Exception) {
e.printStackTrace()
Log.d("okhttp", e.toString())
} }
return "{ \"success\": false,\n \"errorMsg\": \"后台服务器开小差了!\",\n \"result\":{}}" }.build()
val request = Request.Builder()
.url(url)
.get()
.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
EventUtils.event("config_api_error", value = e.toString())
} }
override fun onResponse(call: Call, response: Response) {
response.body?.string()?.let {
fun requestCfg(callback: (ConfigBean) -> Unit) { val i = Regex("\"data\":\"(.*?)\"").find(it)
val s = doGet()
val i = Regex("\"data\":\"(.*?)\"").find(s)
if (i.toString() != "null") { if (i.toString() != "null") {
i!!.groupValues[1].let { i!!.groupValues[1].let {
val str = AESHelper.decrypt(it) val str = AESHelper.decrypt(it)
Log.e("MXL", "requestCfg: "+str)
val gson = Gson() val gson = Gson()
val bean = gson.fromJson(str, ConfigBean::class.java) val bean = gson.fromJson(str, ConfigBean::class.java)
Log.d("jiekou", str) Log.e("MXL", str)
SPUtils.getInstance().put("actionS", bean.actionS); SPUtils.getInstance().put("actionS", bean.actionS);
SPUtils.getInstance().put("open", bean.open); SPUtils.getInstance().put("open", bean.open);
SPUtils.getInstance().put("num", bean.num); SPUtils.getInstance().put("num", bean.num);
...@@ -69,6 +67,9 @@ object ComUtils { ...@@ -69,6 +67,9 @@ object ComUtils {
SPUtils.getInstance().put("isShowBackIntAd", bean.isShowBackIntAd) SPUtils.getInstance().put("isShowBackIntAd", bean.isShowBackIntAd)
SPUtils.getInstance().put("isShowResultNaAd", bean.isShowResultNaAd) SPUtils.getInstance().put("isShowResultNaAd", bean.isShowResultNaAd)
SPUtils.getInstance().put("loading_page_time", bean.loadingPageTime) SPUtils.getInstance().put("loading_page_time", bean.loadingPageTime)
SPUtils.getInstance().put("outcomeReturnCount", bean.outcomeReturnCount)
SPUtils.getInstance().put("outcomeReturnHomeCount", bean.outcomeReturnHomeCount)
SPUtils.getInstance().put("dayoutcomeHomePage", bean.dayoutcomeHomePage)
adDisplayInterval = bean.adInterval adDisplayInterval = bean.adInterval
maxMultiClick = bean.maxMultiClick maxMultiClick = bean.maxMultiClick
AdDisplayUtils.getInstance().setMaxAdDisplayCount(bean.adShowCount) AdDisplayUtils.getInstance().setMaxAdDisplayCount(bean.adShowCount)
...@@ -78,5 +79,9 @@ object ComUtils { ...@@ -78,5 +79,9 @@ object ComUtils {
} }
} }
}
})
}
} }
\ No newline at end of file
...@@ -20,10 +20,12 @@ object ConfigHelper { ...@@ -20,10 +20,12 @@ object ConfigHelper {
const val interAdmobId = "ca-app-pub-3940256099942544/1033173712" const val interAdmobId = "ca-app-pub-3940256099942544/1033173712"
const val nativeAdmobId = "ca-app-pub-3940256099942544/2247696110" const val nativeAdmobId = "ca-app-pub-3940256099942544/2247696110"
const val openAdmobId = "/6499/example/app-open" const val openAdmobId = "/6499/example/app-open"
//max广告id //max广告id
const val interMaxId = "636e57ec33ac5698" const val interMaxId = "636e57ec33ac5698"
const val nativeMaxId = "63d874bafb4c4841" const val nativeMaxId = "63d874bafb4c4841"
const val openMaxId = "1fce760852e47224" const val openMaxId = "1fce760852e47224"
// 正式包名 // 正式包名
const val packageName = "com.kk.junkcleaner.easy.zxkk" const val packageName = "com.kk.junkcleaner.easy.zxkk"
...@@ -86,6 +88,14 @@ object ConfigHelper { ...@@ -86,6 +88,14 @@ object ConfigHelper {
field = value field = value
SPUtils.getInstance().put("fcmNotification", value, true) SPUtils.getInstance().put("fcmNotification", value, true)
} }
//进入主页的次数
var enter_homePage = 0
get() {
return SPUtils.getInstance().getInt("enter_homePage", field)
}
set(value) {
field = value
SPUtils.getInstance().put("enter_homePage", value)
}
} }
\ No newline at end of file
...@@ -72,7 +72,6 @@ object MaxAdUtils { ...@@ -72,7 +72,6 @@ object MaxAdUtils {
openLoadTime = System.currentTimeMillis() openLoadTime = System.currentTimeMillis()
onLoad?.invoke() onLoad?.invoke()
maxAdPullReport(p0, "openAd", reqId = reqId) maxAdPullReport(p0, "openAd", reqId = reqId)
Log.e("MXL", "开屏onAdLoaded: ")
} }
override fun onAdDisplayed(p0: MaxAd) {} override fun onAdDisplayed(p0: MaxAd) {}
...@@ -202,7 +201,7 @@ object MaxAdUtils { ...@@ -202,7 +201,7 @@ object MaxAdUtils {
interAd = MaxInterstitialAd(interAdUnit, activity) interAd = MaxInterstitialAd(interAdUnit, activity)
interAd?.setListener(object : MaxAdListener { interAd?.setListener(object : MaxAdListener {
override fun onAdLoaded(p0: MaxAd) { override fun onAdLoaded(p0: MaxAd) {
Log.e("MXL", "interAd:onAdLoaded: ") //Log.e("MXL", "interAd:onAdLoaded: ")
maxAdPullReport(p0, "InterstitialAd") maxAdPullReport(p0, "InterstitialAd")
retryAttempt = 0 retryAttempt = 0
onLoad?.invoke() onLoad?.invoke()
...@@ -220,7 +219,6 @@ object MaxAdUtils { ...@@ -220,7 +219,6 @@ object MaxAdUtils {
} }
override fun onAdLoadFailed(p0: String, p1: MaxError) { override fun onAdLoadFailed(p0: String, p1: MaxError) {
Log.e("MXL", "InteronAdLoadFailed: " + p1)
maxAdPullReport(null, "InterstitialAd", p1.message) maxAdPullReport(null, "InterstitialAd", p1.message)
onLoad?.invoke() onLoad?.invoke()
AdDisplayUtils.getInstance().incrementAdRequestFailCount() AdDisplayUtils.getInstance().incrementAdRequestFailCount()
...@@ -278,7 +276,6 @@ object MaxAdUtils { ...@@ -278,7 +276,6 @@ object MaxAdUtils {
onHidden?.invoke() onHidden?.invoke()
return return
} }
Log.e("MXL", "showInterstitialAd: ")
if (interAd != null) { if (interAd != null) {
interAd?.setRevenueListener(EventOnPaidEventListener()) interAd?.setRevenueListener(EventOnPaidEventListener())
showIntervalDialogAndShowAd(activity, isLoadAdNow, isShowInterVal, onHidden, 0) showIntervalDialogAndShowAd(activity, isLoadAdNow, isShowInterVal, onHidden, 0)
......
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