Commit f807e383 authored by wanglei's avatar wanglei

Merge branch 'free-master' of gitlab.huolea.com:koko/easy-junk-cleaner-6-18 into free-master

parents 89ec2e83 72d49069
......@@ -7,6 +7,7 @@ import android.view.View
import android.widget.TextView
class CustomDialog(context: Context, layoutId: Int) : Dialog(context) {
private var countdownText: TextView? = null
init {
setContentView(layoutId)
......@@ -25,4 +26,12 @@ class CustomDialog(context: Context, layoutId: Int) : Dialog(context) {
}
}
fun setCountdownText(viewId: Int) {
countdownText = findViewById(viewId)
}
fun updateCountdownText(seconds: String) {
countdownText?.text = seconds
}
}
package com.test.easy.easycleanerjunk.helps.ads;
import android.content.Context;
import android.content.SharedPreferences;
import com.test.easy.easycleanerjunk.MyApplication;
......@@ -10,27 +9,27 @@ import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import android.content.SharedPreferences;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
public class AdDisplayUtils {
private static final int MAX_AD_DISPLAY_COUNT = 5; // 总广告展示次数限制
private static final int MAX_AD_CLICK_COUNT = 2; // 单个广告点击次数限制
private static final int DEFAULT_MAX_AD_DISPLAY_COUNT = 45; // 总广告展示次数限制默认值
private static final int DEFAULT_MAX_AD_CLICK_COUNT = 10; // 单个广告点击次数限制默认值
private static final String AD_PREFS_NAME = "ad_prefs"; // SharedPreferences 名称
private static final String AD_DISPLAY_COUNT_KEY = "ad_display_count"; // 广告展示次数的键
private static final String AD_CLICK_COUNT_KEY = "ad_click_count"; // 广告点击次数的键
private static final String MAX_AD_DISPLAY_COUNT_KEY = "max_ad_display_count"; // 总广告展示次数限制的键
private static final String MAX_AD_CLICK_COUNT_KEY = "max_ad_click_count"; // 单个广告点击次数限制的键
private static AdDisplayUtils instance; // 单例对象
private int adDisplayCount = 0; // 当前广告展示次数
private int adClickCount = 0; // 当前广告点击次数
private int maxAdDisplayCount; // 总广告展示次数限制
private int maxAdClickCount; // 单个广告点击次数限制
private String currentDate; // 当前日期
private AdDisplayUtils() {
currentDate = getCurrentDate();
SharedPreferences prefs = MyApplication.context.getSharedPreferences(AD_PREFS_NAME, 0);
maxAdDisplayCount = prefs.getInt(MAX_AD_DISPLAY_COUNT_KEY, DEFAULT_MAX_AD_DISPLAY_COUNT);
maxAdClickCount = prefs.getInt(MAX_AD_CLICK_COUNT_KEY, DEFAULT_MAX_AD_CLICK_COUNT);
adDisplayCount = prefs.getInt(getAdDisplayCountKey(), 0);
adClickCount = prefs.getInt(getAdClickCountKey(), 0);
}
......@@ -43,11 +42,14 @@ public class AdDisplayUtils {
}
public boolean shouldDisplayAd() {
return adDisplayCount < MAX_AD_DISPLAY_COUNT;
return adDisplayCount < getMaxAdDisplayCount();
}
public boolean shouldIncrementClickCount() {
return adClickCount < MAX_AD_CLICK_COUNT;
return adClickCount < getMaxAdClickCount();
}
public boolean shouldShowAd() {
return shouldDisplayAd() || shouldIncrementClickCount();
}
public void incrementAdDisplayCount() {
......@@ -95,5 +97,36 @@ public class AdDisplayUtils {
editor.putInt(getAdClickCountKey(), adClickCount);
editor.apply();
}
}
private int getMaxAdDisplayCount() {
return maxAdDisplayCount;
}
public void setMaxAdDisplayCount(int maxAdDisplayCount) {
this.maxAdDisplayCount = maxAdDisplayCount;
saveMaxAdDisplayCount();
}
private int getMaxAdClickCount() {
return maxAdClickCount;
}
public void setMaxAdClickCount(int maxAdClickCount) {
this.maxAdClickCount = maxAdClickCount;
saveMaxAdClickCount();
}
private void saveMaxAdDisplayCount() {
SharedPreferences prefs = MyApplication.context.getSharedPreferences(AD_PREFS_NAME, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(MAX_AD_DISPLAY_COUNT_KEY, maxAdDisplayCount);
editor.apply();
}
private void saveMaxAdClickCount() {
SharedPreferences prefs = MyApplication.context.getSharedPreferences(AD_PREFS_NAME, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(MAX_AD_CLICK_COUNT_KEY, maxAdClickCount);
editor.apply();
}
}
......@@ -22,6 +22,7 @@
<TextView
android:id="@+id/dialog_ad_loading_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="11dp"
......
......@@ -118,7 +118,8 @@
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginTop="14dp">
<com.noober.background.view.BLLinearLayout
android:id="@+id/id_clean_junk"
......@@ -264,7 +265,7 @@
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp">
android:layout_marginTop="10dp">
<com.noober.background.view.BLLinearLayout
android:id="@+id/id_large_file"
......@@ -436,7 +437,7 @@
android:id="@+id/id_similar_photos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginBottom="13dp"
android:gravity="center_vertical">
<androidx.appcompat.widget.AppCompatImageView
......@@ -450,7 +451,10 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="6dp"
android:layout_weight="1"
android:text="Similar Photos" />
android:text="Similar Photos"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
......@@ -461,11 +465,18 @@
</androidx.appcompat.widget.LinearLayoutCompat>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginHorizontal="14dp"
android:background="#F8F8F8" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/id_screenshot_clean"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="13dp"
android:layout_marginBottom="13dp"
android:gravity="center_vertical">
<androidx.appcompat.widget.AppCompatImageView
......@@ -479,6 +490,9 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="6dp"
android:layout_weight="1"
android:textColor="#000000"
android:textSize="13sp"
android:textStyle="bold"
android:text="Screenshot Clean" />
<androidx.appcompat.widget.AppCompatImageView
......
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