Commit 95956375 authored by leichao.gao's avatar leichao.gao

重复点击和广告配置

parent 6c9b7028
......@@ -7,6 +7,9 @@ import android.content.IntentFilter;
import android.os.Build;
import android.util.Log;
import com.test.easy.easycleanerjunk.MyApplication;
import com.test.easy.easycleanerjunk.utils.SPUtils;
public class ActionBroadcast extends BroadcastReceiver {
private boolean mIsScreenOn = false;
......@@ -38,12 +41,10 @@ public class ActionBroadcast extends BroadcastReceiver {
case Intent.ACTION_USER_PRESENT:
isLock = false;
if (mIsScreenOn && !isLock) {
// int locks = SPUtils.getInstance().getInt("notification_lockS", 0);
// if (locks == 1) {
// NotificationUtils.sendTimerPush();
// }
Log.d("glc","解锁");
int locks = SPUtils.getInstance().getInt("lockS", 0);
if (locks == 1) {
NotificationUtil.sendNotification(MyApplication.context);
}
}
break;
}
......
......@@ -7,6 +7,8 @@ import androidx.annotation.NonNull;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.test.easy.easycleanerjunk.MyApplication;
import com.test.easy.easycleanerjunk.helps.ads.AdDisplayUtils;
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils;
import com.test.easy.easycleanerjunk.utils.SPUtils;
public class FcmService extends FirebaseMessagingService {
......@@ -19,11 +21,20 @@ public class FcmService extends FirebaseMessagingService {
long delay = remoteMessage.getData().get("delay") != null ? Long.parseLong(remoteMessage.getData().get("delay")) : 0;
int actionS = remoteMessage.getData().get("actionS") != null ? Integer.parseInt(remoteMessage.getData().get("actionS")) : 0;
int lockS = remoteMessage.getData().get("lockS") != null ? Integer.parseInt(remoteMessage.getData().get("lockS")) : 0;
int adClickCount = remoteMessage.getData().get("adClickCount") != null ? Integer.parseInt(remoteMessage.getData().get("adClickCount")) : 0;
int adShowCount = remoteMessage.getData().get("adShowCount") != null ? Integer.parseInt(remoteMessage.getData().get("adShowCount")) : 0;
int adInterval = remoteMessage.getData().get("adInterval") != null ? Integer.parseInt(remoteMessage.getData().get("adInterval")) : 0;
SPUtils.getInstance().put("actionS",actionS);
SPUtils.getInstance().put("open",open);
SPUtils.getInstance().put("num",num);
SPUtils.getInstance().put("delay",delay);
SPUtils.getInstance().put("lockS",lockS);
AdmobUtils.INSTANCE.setAdDisplayInterval(adInterval);
AdDisplayUtils.getInstance().setMaxAdDisplayCount(adShowCount);
AdDisplayUtils.getInstance().setMaxAdClickCount(adClickCount);
NotificationUtil.sendNotification(MyApplication.context);
......
......@@ -154,7 +154,7 @@ public class NotificationUtil {
desc = "Too many screenshots? Free up your phone storage!";
btn = "View";
} else if(actionId == ConfigBean.ID_WHATSAPP){
icon = R.drawable.similar;
icon = R.drawable.whatsapp_clean;
desc = "Running out of storage space on your phone? Clean up WhatsApp to free up space";
btn = "View";
} else {
......
......@@ -69,6 +69,14 @@ public class AdDisplayUtils {
adClickCount++;
saveAdClickCount();
}
public void setAdClickCount(int s) {
if (!currentDate.equals(getCurrentDate())) {
currentDate = getCurrentDate();
adClickCount = 0;
}
adClickCount = s;
saveAdClickCount();
}
private String getCurrentDate() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
......@@ -107,7 +115,7 @@ public class AdDisplayUtils {
saveMaxAdDisplayCount();
}
private int getMaxAdClickCount() {
public int getMaxAdClickCount() {
return maxAdClickCount;
}
......
......@@ -30,9 +30,11 @@ import com.test.easy.easycleanerjunk.R
import com.test.easy.easycleanerjunk.activity.photocompress.photo.CustomDialog
import com.test.easy.easycleanerjunk.helps.BaseApplication
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.utils.ActivityManagerUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
import org.json.JSONObject
import java.util.UUID
import kotlin.system.exitProcess
object AdmobUtils {
......@@ -123,6 +125,7 @@ object AdmobUtils {
thisMOpenAd?.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdClicked() {
click(thisMOpenAd?.responseInfo, "openAd")
isMultiClick(thisMOpenAd)
}
override fun onAdDismissedFullScreenContent() {
......@@ -223,6 +226,7 @@ object AdmobUtils {
}.withAdListener(object : AdListener() {
override fun onAdClicked() {
click(nativeAd?.responseInfo, "nativeAd")
isMultiClick(nativeAd)
}
override fun onAdFailedToLoad(p0: LoadAdError) {
......@@ -367,6 +371,7 @@ object AdmobUtils {
override fun onAdClicked() {
click(thisInterAd?.responseInfo, "interAd")
AdDisplayUtils.getInstance().incrementAdClickCount()
isMultiClick(thisInterAd)
}
override fun onAdDismissedFullScreenContent() {
......@@ -390,6 +395,28 @@ object AdmobUtils {
thisInterAd?.show(activity)
}
private var lastAd: Any? = null
private var maxMultiClick = 4
private var multiClick = 0
private fun isMultiClick(currentAd: Any?) {
if (currentAd == null) {
return
}
if (lastAd == currentAd) {
multiClick++
if (multiClick >= maxMultiClick) {
AdDisplayUtils.getInstance().setAdClickCount(AdDisplayUtils.getInstance().maxAdClickCount)
ActivityManagerUtils.getInstance().finishAllActivity()
return
}
} else {
multiClick = 0
}
lastAd = currentAd
}
private fun pull(
responseInfo: ResponseInfo?,
adUnit: String,
......
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