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

重复点击和广告配置

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