定义云盾参数有效区域值
This commit is contained in:
parent
ee421d1019
commit
c476792d7c
@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Tue Apr 01 17:48:43 HKT 2025
|
#Sat Apr 12 18:01:41 GMT 2025
|
||||||
stageCount=7
|
stageCount=7
|
||||||
libraryProject=
|
libraryProject=
|
||||||
baseVersion=15.2
|
baseVersion=15.2
|
||||||
publishVersion=15.2.6
|
publishVersion=15.2.6
|
||||||
buildCount=0
|
buildCount=6
|
||||||
baseBetaVersion=15.2.7
|
baseBetaVersion=15.2.7
|
||||||
|
@ -3,11 +3,12 @@ package cc.winboll.studio.contacts.activities;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
import cc.winboll.studio.contacts.R;
|
import cc.winboll.studio.contacts.R;
|
||||||
import cc.winboll.studio.contacts.dun.Rules;
|
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.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.LogView;
|
import cc.winboll.studio.libappbase.LogView;
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen@AliYun.Com
|
* @Author ZhanGSKen@AliYun.Com
|
||||||
@ -37,6 +38,9 @@ public class UnitTestActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onTestMain(View view) {
|
public void onTestMain(View view) {
|
||||||
|
LogUtils.d(TAG, "IntUtils.unittest_getIntInRange();");
|
||||||
|
IntUtils.unittest_getIntInRange();
|
||||||
|
|
||||||
Rules rules = Rules.getInstance(this);
|
Rules rules = Rules.getInstance(this);
|
||||||
|
|
||||||
// 如果没有规则就添加测试规则
|
// 如果没有规则就添加测试规则
|
||||||
@ -86,6 +90,5 @@ public class UnitTestActivity extends Activity {
|
|||||||
|
|
||||||
phone = "95566";
|
phone = "95566";
|
||||||
LogUtils.d(TAG, String.format("Test phone : %s\n%s", phone, rules.isAllowed(phone)));
|
LogUtils.d(TAG, String.format("Test phone : %s\n%s", phone, rules.isAllowed(phone)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,13 @@ import android.util.JsonReader;
|
|||||||
import android.util.JsonWriter;
|
import android.util.JsonWriter;
|
||||||
import cc.winboll.studio.libappbase.BaseBean;
|
import cc.winboll.studio.libappbase.BaseBean;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import cc.winboll.studio.contacts.utils.IntUtils;
|
||||||
|
|
||||||
public class SettingsModel extends BaseBean {
|
public class SettingsModel extends BaseBean {
|
||||||
|
|
||||||
public static final String TAG = "SettingsModel";
|
public static final String TAG = "SettingsModel";
|
||||||
|
public static final int MAX_INTRANGE = 666666;
|
||||||
|
public static final int MIN_INTRANGE = 1;
|
||||||
|
|
||||||
// 云盾防御层数量
|
// 云盾防御层数量
|
||||||
int dunTotalCount;
|
int dunTotalCount;
|
||||||
@ -34,15 +37,15 @@ public class SettingsModel extends BaseBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SettingsModel(int dunTotalCount, int dunCurrentCount, int dunResumeSecondCount, int dunResumeCount, boolean isEnableDun) {
|
public SettingsModel(int dunTotalCount, int dunCurrentCount, int dunResumeSecondCount, int dunResumeCount, boolean isEnableDun) {
|
||||||
this.dunTotalCount = dunTotalCount;
|
this.dunTotalCount = getSettingsModelRangeInt(dunTotalCount);
|
||||||
this.dunCurrentCount = dunCurrentCount;
|
this.dunCurrentCount = getSettingsModelRangeInt(dunCurrentCount);
|
||||||
this.dunResumeSecondCount = dunResumeSecondCount;
|
this.dunResumeSecondCount = getSettingsModelRangeInt(dunResumeSecondCount);
|
||||||
this.dunResumeCount = dunResumeCount;
|
this.dunResumeCount = getSettingsModelRangeInt(dunResumeCount);
|
||||||
this.isEnableDun = isEnableDun;
|
this.isEnableDun = isEnableDun;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDunTotalCount(int dunTotalCount) {
|
public void setDunTotalCount(int dunTotalCount) {
|
||||||
this.dunTotalCount = dunTotalCount;
|
this.dunTotalCount = getSettingsModelRangeInt(dunTotalCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDunTotalCount() {
|
public int getDunTotalCount() {
|
||||||
@ -50,7 +53,7 @@ public class SettingsModel extends BaseBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDunCurrentCount(int dunCurrentCount) {
|
public void setDunCurrentCount(int dunCurrentCount) {
|
||||||
this.dunCurrentCount = dunCurrentCount;
|
this.dunCurrentCount = getSettingsModelRangeInt(dunCurrentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDunCurrentCount() {
|
public int getDunCurrentCount() {
|
||||||
@ -58,7 +61,7 @@ public class SettingsModel extends BaseBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDunResumeSecondCount(int dunResumeSecondCount) {
|
public void setDunResumeSecondCount(int dunResumeSecondCount) {
|
||||||
this.dunResumeSecondCount = dunResumeSecondCount;
|
this.dunResumeSecondCount = getSettingsModelRangeInt(dunResumeSecondCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDunResumeSecondCount() {
|
public int getDunResumeSecondCount() {
|
||||||
@ -66,7 +69,7 @@ public class SettingsModel extends BaseBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDunResumeCount(int dunResumeCount) {
|
public void setDunResumeCount(int dunResumeCount) {
|
||||||
this.dunResumeCount = dunResumeCount;
|
this.dunResumeCount = getSettingsModelRangeInt(dunResumeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDunResumeCount() {
|
public int getDunResumeCount() {
|
||||||
@ -81,6 +84,9 @@ public class SettingsModel extends BaseBean {
|
|||||||
return isEnableDun;
|
return isEnableDun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getSettingsModelRangeInt(int origin) {
|
||||||
|
return IntUtils.getIntInRange(origin, MIN_INTRANGE, MAX_INTRANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -103,13 +109,13 @@ public class SettingsModel extends BaseBean {
|
|||||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||||
if (name.equals("dunTotalCount")) {
|
if (name.equals("dunTotalCount")) {
|
||||||
setDunTotalCount(jsonReader.nextInt());
|
setDunTotalCount(getSettingsModelRangeInt(jsonReader.nextInt()));
|
||||||
} else if (name.equals("dunCurrentCount")) {
|
} else if (name.equals("dunCurrentCount")) {
|
||||||
setDunCurrentCount(jsonReader.nextInt());
|
setDunCurrentCount(getSettingsModelRangeInt(jsonReader.nextInt()));
|
||||||
} else if (name.equals("dunResumeSecondCount")) {
|
} else if (name.equals("dunResumeSecondCount")) {
|
||||||
setDunResumeSecondCount(jsonReader.nextInt());
|
setDunResumeSecondCount(getSettingsModelRangeInt(jsonReader.nextInt()));
|
||||||
} else if (name.equals("dunResumeCount")) {
|
} else if (name.equals("dunResumeCount")) {
|
||||||
setDunResumeCount(jsonReader.nextInt());
|
setDunResumeCount(getSettingsModelRangeInt(jsonReader.nextInt()));
|
||||||
} else if (name.equals("isEnableDun")) {
|
} else if (name.equals("isEnableDun")) {
|
||||||
setIsEnableDun(jsonReader.nextBoolean());
|
setIsEnableDun(jsonReader.nextBoolean());
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,6 +11,7 @@ import cc.winboll.studio.contacts.beans.PhoneConnectRuleModel;
|
|||||||
import cc.winboll.studio.contacts.beans.SettingsModel;
|
import cc.winboll.studio.contacts.beans.SettingsModel;
|
||||||
import cc.winboll.studio.contacts.services.MainService;
|
import cc.winboll.studio.contacts.services.MainService;
|
||||||
import cc.winboll.studio.contacts.utils.ContactUtils;
|
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.contacts.utils.RegexPPiUtils;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -55,6 +56,7 @@ public class Rules {
|
|||||||
|
|
||||||
// 盾牌恢复定时器
|
// 盾牌恢复定时器
|
||||||
mDunResumeTimer = new Timer();
|
mDunResumeTimer = new Timer();
|
||||||
|
int ss = IntUtils.getIntInRange(mSettingsModel.getDunResumeSecondCount() * 1000, SettingsModel.MIN_INTRANGE, SettingsModel.MAX_INTRANGE);
|
||||||
mDunResumeTimer.schedule(new TimerTask() {
|
mDunResumeTimer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -69,7 +71,7 @@ public class Rules {
|
|||||||
SettingsActivity.notifyDunInfoUpdate();
|
SettingsActivity.notifyDunInfoUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1000, mSettingsModel.getDunResumeSecondCount() * 1000);
|
}, 1000, ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadRules() {
|
public void loadRules() {
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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)));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user