Merge branch 'app_important_fix' into appbase

This commit is contained in:
ZhanGSKen 2025-04-13 03:04:52 +08:00
commit f9bfdd3de8
6 changed files with 93 additions and 21 deletions

View File

@ -1,8 +1,8 @@
#Created by .winboll/winboll_app_build.gradle
#Tue Apr 01 17:48:43 HKT 2025
stageCount=7
#Sun Apr 13 02:46:09 HKT 2025
stageCount=8
libraryProject=
baseVersion=15.2
publishVersion=15.2.6
publishVersion=15.2.7
buildCount=0
baseBetaVersion=15.2.7
baseBetaVersion=15.2.8

View File

@ -3,11 +3,12 @@ package cc.winboll.studio.contacts.activities;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import cc.winboll.studio.contacts.R;
import cc.winboll.studio.contacts.dun.Rules;
import cc.winboll.studio.contacts.utils.IntUtils;
import cc.winboll.studio.libappbase.LogUtils;
import cc.winboll.studio.libappbase.LogView;
import android.widget.EditText;
/**
* @Author ZhanGSKen@AliYun.Com
@ -37,6 +38,9 @@ public class UnitTestActivity extends Activity {
}
public void onTestMain(View view) {
LogUtils.d(TAG, "IntUtils.unittest_getIntInRange();");
IntUtils.unittest_getIntInRange();
Rules rules = Rules.getInstance(this);
// 如果没有规则就添加测试规则
@ -86,6 +90,5 @@ public class UnitTestActivity extends Activity {
phone = "95566";
LogUtils.d(TAG, String.format("Test phone : %s\n%s", phone, rules.isAllowed(phone)));
}
}

View File

@ -9,11 +9,14 @@ import android.util.JsonReader;
import android.util.JsonWriter;
import cc.winboll.studio.libappbase.BaseBean;
import java.io.IOException;
import cc.winboll.studio.contacts.utils.IntUtils;
public class SettingsModel extends BaseBean {
public static final String TAG = "SettingsModel";
public static final int MAX_INTRANGE = 666666;
public static final int MIN_INTRANGE = 1;
// 云盾防御层数量
int dunTotalCount;
// 当前云盾防御层
@ -34,15 +37,15 @@ public class SettingsModel extends BaseBean {
}
public SettingsModel(int dunTotalCount, int dunCurrentCount, int dunResumeSecondCount, int dunResumeCount, boolean isEnableDun) {
this.dunTotalCount = dunTotalCount;
this.dunCurrentCount = dunCurrentCount;
this.dunResumeSecondCount = dunResumeSecondCount;
this.dunResumeCount = dunResumeCount;
this.dunTotalCount = getSettingsModelRangeInt(dunTotalCount);
this.dunCurrentCount = getSettingsModelRangeInt(dunCurrentCount);
this.dunResumeSecondCount = getSettingsModelRangeInt(dunResumeSecondCount);
this.dunResumeCount = getSettingsModelRangeInt(dunResumeCount);
this.isEnableDun = isEnableDun;
}
public void setDunTotalCount(int dunTotalCount) {
this.dunTotalCount = dunTotalCount;
this.dunTotalCount = getSettingsModelRangeInt(dunTotalCount);
}
public int getDunTotalCount() {
@ -50,7 +53,7 @@ public class SettingsModel extends BaseBean {
}
public void setDunCurrentCount(int dunCurrentCount) {
this.dunCurrentCount = dunCurrentCount;
this.dunCurrentCount = getSettingsModelRangeInt(dunCurrentCount);
}
public int getDunCurrentCount() {
@ -58,7 +61,7 @@ public class SettingsModel extends BaseBean {
}
public void setDunResumeSecondCount(int dunResumeSecondCount) {
this.dunResumeSecondCount = dunResumeSecondCount;
this.dunResumeSecondCount = getSettingsModelRangeInt(dunResumeSecondCount);
}
public int getDunResumeSecondCount() {
@ -66,7 +69,7 @@ public class SettingsModel extends BaseBean {
}
public void setDunResumeCount(int dunResumeCount) {
this.dunResumeCount = dunResumeCount;
this.dunResumeCount = getSettingsModelRangeInt(dunResumeCount);
}
public int getDunResumeCount() {
@ -80,7 +83,10 @@ public class SettingsModel extends BaseBean {
public boolean isEnableDun() {
return isEnableDun;
}
int getSettingsModelRangeInt(int origin) {
return IntUtils.getIntInRange(origin, MIN_INTRANGE, MAX_INTRANGE);
}
@Override
@ -103,13 +109,13 @@ public class SettingsModel extends BaseBean {
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
if (name.equals("dunTotalCount")) {
setDunTotalCount(jsonReader.nextInt());
setDunTotalCount(getSettingsModelRangeInt(jsonReader.nextInt()));
} else if (name.equals("dunCurrentCount")) {
setDunCurrentCount(jsonReader.nextInt());
setDunCurrentCount(getSettingsModelRangeInt(jsonReader.nextInt()));
} else if (name.equals("dunResumeSecondCount")) {
setDunResumeSecondCount(jsonReader.nextInt());
setDunResumeSecondCount(getSettingsModelRangeInt(jsonReader.nextInt()));
} else if (name.equals("dunResumeCount")) {
setDunResumeCount(jsonReader.nextInt());
setDunResumeCount(getSettingsModelRangeInt(jsonReader.nextInt()));
} else if (name.equals("isEnableDun")) {
setIsEnableDun(jsonReader.nextBoolean());
} else {

View File

@ -11,6 +11,7 @@ import cc.winboll.studio.contacts.beans.PhoneConnectRuleModel;
import cc.winboll.studio.contacts.beans.SettingsModel;
import cc.winboll.studio.contacts.services.MainService;
import cc.winboll.studio.contacts.utils.ContactUtils;
import cc.winboll.studio.contacts.utils.IntUtils;
import cc.winboll.studio.contacts.utils.RegexPPiUtils;
import cc.winboll.studio.libappbase.LogUtils;
import java.util.ArrayList;
@ -55,6 +56,7 @@ public class Rules {
// 盾牌恢复定时器
mDunResumeTimer = new Timer();
int ss = IntUtils.getIntInRange(mSettingsModel.getDunResumeSecondCount() * 1000, SettingsModel.MIN_INTRANGE, SettingsModel.MAX_INTRANGE);
mDunResumeTimer.schedule(new TimerTask() {
@Override
public void run() {
@ -69,7 +71,7 @@ public class Rules {
SettingsActivity.notifyDunInfoUpdate();
}
}
}, 1000, mSettingsModel.getDunResumeSecondCount() * 1000);
}, 1000, ss);
}
public void loadRules() {

View File

@ -0,0 +1,24 @@
package cc.winboll.studio.contacts.utils;
import android.widget.EditText;
import cc.winboll.studio.libappbase.LogUtils;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/13 00:59:13
* @Describe Int类型数字输入框工具集
*/
public class EditTextIntUtils {
public static final String TAG = "EditTextIntUtils";
public static int getIntFromEditText(EditText editText) {
try {
String sz = editText.getText().toString().trim();
return Integer.parseInt(sz);
} catch (NumberFormatException e) {
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
return 0;
}
}
}

View File

@ -0,0 +1,37 @@
package cc.winboll.studio.contacts.utils;
/**
* @Author ZhanGSKen@AliYun.Com
* @Date 2025/04/13 01:16:28
* @Describe Int数字操作工具集
*/
import cc.winboll.studio.libappbase.LogUtils;
public class IntUtils {
public static final String TAG = "IntUtils";
public static int getIntInRange(int origin, int range_a, int range_b) {
int min = Math.min(range_a, range_b);
int max = Math.max(range_a, range_b);
int res = Math.min(origin, max);
res = Math.max(res, min);
return res;
}
public static void unittest_getIntInRange() {
LogUtils.d(TAG, String.format("getIntInRange(-100, 5, 10); %d", getIntInRange(-100, 5, 10)));
LogUtils.d(TAG, String.format("getIntInRange(8, 5, 10); %d", getIntInRange(8, 5, 10)));
LogUtils.d(TAG, String.format("getIntInRange(200, 5, 10); %d", getIntInRange(200, 5, 10)));
LogUtils.d(TAG, String.format("getIntInRange(-100, -5, 10); %d", getIntInRange(-100, -5, 10)));
LogUtils.d(TAG, String.format("getIntInRange(9, -5, 10); %d", getIntInRange(9, -5, 10)));
LogUtils.d(TAG, String.format("getIntInRange(100, -5, 10); %d", getIntInRange(100, -5, 10)));
LogUtils.d(TAG, String.format("getIntInRange(500, 5, -10); %d", getIntInRange(500, 5, -10)));
LogUtils.d(TAG, String.format("getIntInRange(4, 5, -10); %d", getIntInRange(4, 5, -10)));
LogUtils.d(TAG, String.format("getIntInRange(-20, 5, -10); %d", getIntInRange(-20, 5, -10)));
LogUtils.d(TAG, String.format("getIntInRange(500, 50, 10); %d", getIntInRange(500, 50, 10)));
LogUtils.d(TAG, String.format("getIntInRange(30, 50, 10); %d", getIntInRange(30, 50, 10)));
LogUtils.d(TAG, String.format("getIntInRange(6, 50, 10); %d", getIntInRange(6, 50, 10)));
}
}