mirror of
https://gitea.winboll.cc/ZhanGSKen/MyWinBoLL.git
synced 2026-08-14 21:47:11 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b50de904f2 | |||
| 18e41a7a8d | |||
| 8713872d62 | |||
| b16f29a43f | |||
| ebaf487d0a | |||
| d5d230c1bb | |||
| 1d0322252e | |||
| 22f9eff429 | |||
| c8e55730f3 | |||
| 5d73960a54 | |||
| 2661bd1d5f | |||
| 3aaa7ab4fb | |||
| c75344c238 |
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sat Jul 18 18:56:11 HKT 2026
|
||||
stageCount=11
|
||||
#Sun Jul 19 06:16:39 HKT 2026
|
||||
stageCount=12
|
||||
libraryProject=
|
||||
baseVersion=15.20
|
||||
publishVersion=15.20.10
|
||||
publishVersion=15.20.11
|
||||
buildCount=0
|
||||
baseBetaVersion=15.20.11
|
||||
baseBetaVersion=15.20.12
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.contacts">
|
||||
|
||||
<!-- 网络访问权限 -->
|
||||
<!-- 拥有完全的网络访问权限 -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
|
||||
<!-- BIND_AUTOFILL_SERVICE -->
|
||||
<uses-permission android:name="android.permission.BIND_AUTOFILL_SERVICE"/>
|
||||
|
||||
@@ -256,6 +256,8 @@
|
||||
|
||||
<service android:name="cc.winboll.studio.contacts.services.LimitedTimeSpecialChannelService"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.contacts.unittest.LayoutDraftPreViewActivity"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
@@ -31,14 +31,13 @@ import cc.winboll.studio.contacts.activities.WinBollActivity;
|
||||
import cc.winboll.studio.contacts.dun.Rules;
|
||||
import cc.winboll.studio.contacts.fragments.CallLogFragment;
|
||||
import cc.winboll.studio.contacts.fragments.ContactsFragment;
|
||||
import cc.winboll.studio.contacts.fragments.LogFragment;
|
||||
import cc.winboll.studio.contacts.fragments.DunQueryFragment;
|
||||
import cc.winboll.studio.contacts.model.MainServiceBean;
|
||||
import cc.winboll.studio.contacts.services.MainService;
|
||||
import cc.winboll.studio.contacts.utils.PermissionUtils;
|
||||
import cc.winboll.studio.contacts.views.DunTemperatureView;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -75,7 +74,6 @@ public final class MainActivity extends WinBollActivity implements IWinBoLLActiv
|
||||
private final String[] REQUIRED_PERMISSIONS = PermissionUtils.BASE_PERMISSIONS;
|
||||
|
||||
// ====================== 4. UI控件成员区 ======================
|
||||
private LogView mLogView;
|
||||
private Toolbar mToolbar;
|
||||
private CheckBox cbMainService;
|
||||
private TabLayout tabLayout;
|
||||
@@ -320,10 +318,10 @@ public final class MainActivity extends WinBollActivity implements IWinBoLLActiv
|
||||
// 添加Fragment实例(仅创建对象,不初始化业务逻辑)
|
||||
fragmentList.add(CallLogFragment.newInstance(0));
|
||||
fragmentList.add(ContactsFragment.newInstance(1));
|
||||
fragmentList.add(LogFragment.newInstance(2));
|
||||
fragmentList.add(DunQueryFragment.newInstance(2));
|
||||
tabTitleList.add("通话记录");
|
||||
tabTitleList.add("联系人");
|
||||
tabTitleList.add("应用日志");
|
||||
tabTitleList.add("云盾查询");
|
||||
|
||||
// 初始化懒加载标记数组(默认均未初始化)
|
||||
int fragmentCount = fragmentList.size();
|
||||
@@ -367,8 +365,8 @@ public final class MainActivity extends WinBollActivity implements IWinBoLLActiv
|
||||
((CallLogFragment) targetFragment).initData();
|
||||
} else if (targetFragment instanceof ContactsFragment) {
|
||||
((ContactsFragment) targetFragment).initData();
|
||||
} else if (targetFragment instanceof LogFragment) {
|
||||
((LogFragment) targetFragment).initData();
|
||||
} else if (targetFragment instanceof DunQueryFragment) {
|
||||
((DunQueryFragment) targetFragment).initData();
|
||||
}
|
||||
// 标记为已初始化
|
||||
isFragmentInit[position] = true;
|
||||
|
||||
@@ -29,6 +29,7 @@ import cc.winboll.studio.contacts.model.PhoneConnectRuleBean;
|
||||
import cc.winboll.studio.contacts.model.RingTongBean;
|
||||
import cc.winboll.studio.contacts.model.SettingsBean;
|
||||
import cc.winboll.studio.contacts.services.MainService;
|
||||
import cc.winboll.studio.contacts.views.DebugToolButtonsView;
|
||||
import cc.winboll.studio.contacts.views.DuInfoTextView;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
@@ -98,6 +99,9 @@ public class SettingsActivity extends WinBollActivity implements IWinBoLLActivit
|
||||
initDunSettings(); // 云盾设置初始化
|
||||
initBoBullToonViews(); // BoBullToon功能初始化
|
||||
|
||||
// 调试模式下加载调试工具按钮组
|
||||
initDebugTools();
|
||||
|
||||
LogUtils.d(TAG, "onCreate: 设置页面初始化完成");
|
||||
}
|
||||
|
||||
@@ -300,6 +304,26 @@ public class SettingsActivity extends WinBollActivity implements IWinBoLLActivit
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化调试工具按钮组(仅在调试模式下加载)
|
||||
*/
|
||||
private void initDebugTools() {
|
||||
LogUtils.d(TAG, "initDebugTools: 检查调试模式状态");
|
||||
if (cc.winboll.studio.libappbase.GlobalApplication.isDebugging()) {
|
||||
LogUtils.d(TAG, "initDebugTools: 调试模式已开启,加载调试工具按钮组");
|
||||
android.widget.LinearLayout contentLayout = (android.widget.LinearLayout) findViewById(R.id.activity_settings_content);
|
||||
if (contentLayout != null) {
|
||||
DebugToolButtonsView debugView = new DebugToolButtonsView(this);
|
||||
contentLayout.addView(debugView);
|
||||
LogUtils.d(TAG, "initDebugTools: 调试工具按钮组加载完成");
|
||||
} else {
|
||||
LogUtils.e(TAG, "initDebugTools: 内容布局未找到,加载失败");
|
||||
}
|
||||
} else {
|
||||
LogUtils.d(TAG, "initDebugTools: 调试模式未开启,跳过加载");
|
||||
}
|
||||
}
|
||||
|
||||
// ====================== 点击事件回调区(按功能模块归类) ======================
|
||||
/**
|
||||
* 云盾开关点击事件(联动参数编辑权限+配置保存)
|
||||
@@ -382,6 +406,21 @@ public class SettingsActivity extends WinBollActivity implements IWinBoLLActivit
|
||||
LogUtils.d(TAG, "onAddNewConnectionRule: 规则添加完成,当前共" + mRuleList.size() + "条规则");
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化测试规则
|
||||
*/
|
||||
public void onInitTestRules(View view) {
|
||||
LogUtils.d(TAG, "onInitTestRules: 初始化测试规则");
|
||||
Rules rules = Rules.getInstance(this);
|
||||
if (rules == null) {
|
||||
LogUtils.e(TAG, "onInitTestRules: Rules实例获取失败");
|
||||
return;
|
||||
}
|
||||
initTestRulesIfEmpty(rules);
|
||||
mRuleAdapter.notifyDataSetChanged();
|
||||
ToastUtils.show("测试规则初始化完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转默认电话应用设置
|
||||
*/
|
||||
@@ -528,15 +567,24 @@ public class SettingsActivity extends WinBollActivity implements IWinBoLLActivit
|
||||
WinBoLLActivityManager.getInstance().startWinBoLLActivity(this, AboutActivity.class);
|
||||
}
|
||||
|
||||
// ====================== 工具方法区(通用功能+权限相关) ======================
|
||||
/**
|
||||
* 跳转日志查看页面
|
||||
* 规则集为空时初始化测试规则
|
||||
*/
|
||||
public void onLogView(View view) {
|
||||
LogUtils.d(TAG, "onLogView: 跳转日志页面");
|
||||
WinBoLLActivityManager.getInstance().startLogActivity(this);
|
||||
public static void initTestRulesIfEmpty(Rules rules) {
|
||||
if (rules.getPhoneBlacRuleBeanList().size() == 0) {
|
||||
LogUtils.d(TAG, "initTestRulesIfEmpty: 当前无规则,添加测试规则集");
|
||||
rules.add("^1[3-9]\\d{9}$", true, true);
|
||||
rules.add("^0660\\d+$", true, true);
|
||||
rules.add("^020\\d+$", true, true);
|
||||
rules.add(".*", false, true);
|
||||
rules.saveRules();
|
||||
LogUtils.d(TAG, "initTestRulesIfEmpty: 测试规则集已保存");
|
||||
} else {
|
||||
LogUtils.d(TAG, "initTestRulesIfEmpty: 当前已有规则,跳过初始化");
|
||||
}
|
||||
}
|
||||
|
||||
// ====================== 工具方法区(通用功能+权限相关) ======================
|
||||
/**
|
||||
* 更新音量显示文本(当前音量/最大音量)
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@ import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.contacts.R;
|
||||
import cc.winboll.studio.contacts.activities.UnitTestActivity;
|
||||
import cc.winboll.studio.contacts.activities.SettingsActivity;
|
||||
import cc.winboll.studio.contacts.dun.Rules;
|
||||
import cc.winboll.studio.contacts.services.LimitedTimeSpecialChannelService;
|
||||
import cc.winboll.studio.contacts.utils.IntUtils;
|
||||
@@ -103,7 +103,7 @@ public class UnitTestActivity extends WinBollActivity implements IWinBoLLActivit
|
||||
// 初始化规则实例
|
||||
Rules rules = Rules.getInstance(this);
|
||||
// 无规则时添加测试规则集
|
||||
initTestRulesIfEmpty(rules);
|
||||
SettingsActivity.initTestRulesIfEmpty(rules);
|
||||
|
||||
// 预设测试号码列表
|
||||
String[] testPhones = {
|
||||
@@ -126,29 +126,5 @@ public class UnitTestActivity extends WinBollActivity implements IWinBoLLActivit
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
// ====================== 私有工具函数区 ======================
|
||||
/**
|
||||
* 规则集为空时初始化测试规则
|
||||
*/
|
||||
private void initTestRulesIfEmpty(Rules rules) {
|
||||
if (rules.getPhoneBlacRuleBeanList().size() == 0) {
|
||||
LogUtils.d(TAG, "initTestRulesIfEmpty: 当前无规则,添加测试规则集");
|
||||
// 规则1:中国手机号允许
|
||||
rules.add("^1[3-9]\\d{9}$", true, true);
|
||||
// 规则2:0660区号号码允许
|
||||
rules.add("^0660\\d+$", true, true);
|
||||
// 规则3:020区号号码允许
|
||||
rules.add("^020\\d+$", true, true);
|
||||
// 规则4:默认拒接所有号码
|
||||
rules.add(".*", false, true);
|
||||
|
||||
// 保存规则到本地
|
||||
rules.saveRules();
|
||||
LogUtils.d(TAG, "initTestRulesIfEmpty: 测试规则集已保存");
|
||||
} else {
|
||||
LogUtils.d(TAG, "initTestRulesIfEmpty: 当前已有规则,跳过初始化");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package cc.winboll.studio.contacts.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.contacts.R;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/07/19
|
||||
* @Describe 云盾查询区域视图(支持懒加载,仅切换到当前页才加载)
|
||||
*/
|
||||
public class DunQueryFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "DunQueryFragment";
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
|
||||
private int mPage;
|
||||
private boolean isViewInitialized = false;
|
||||
private boolean isLazyInitCompleted = false;
|
||||
|
||||
public static DunQueryFragment newInstance(int page) {
|
||||
LogUtils.d(TAG, "newInstance: 创建云盾查询Fragment实例,页码=" + page);
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_PAGE, page);
|
||||
DunQueryFragment fragment = new DunQueryFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
LogUtils.d(TAG, "onCreate: Fragment创建开始");
|
||||
if (getArguments() != null) {
|
||||
mPage = getArguments().getInt(ARG_PAGE);
|
||||
LogUtils.d(TAG, "onCreate: 读取页面参数,mPage=" + mPage);
|
||||
}
|
||||
LogUtils.d(TAG, "onCreate: Fragment创建完成");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
LogUtils.d(TAG, "onCreateView: 加载Fragment布局");
|
||||
View view = inflater.inflate(R.layout.fragment_dun_query, container, false);
|
||||
isViewInitialized = true;
|
||||
LogUtils.d(TAG, "onCreateView: Fragment布局加载完成");
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
LogUtils.d(TAG, "onDestroy: Fragment开始销毁");
|
||||
isViewInitialized = false;
|
||||
isLazyInitCompleted = false;
|
||||
LogUtils.d(TAG, "onDestroy: Fragment销毁完成");
|
||||
}
|
||||
|
||||
public void initData() {
|
||||
if (isLazyInitCompleted || !isViewInitialized || getContext() == null) {
|
||||
LogUtils.d(TAG, "initData: 懒加载已完成/视图未就绪,跳过");
|
||||
return;
|
||||
}
|
||||
LogUtils.d(TAG, "initData: 开始懒加载初始化");
|
||||
isLazyInitCompleted = true;
|
||||
LogUtils.d(TAG, "initData: 懒加载初始化完成");
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package cc.winboll.studio.contacts.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.contacts.R;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/02/20 12:58:15
|
||||
* @Describe 应用日志区域视图(支持懒加载,仅切换到当前页才启动日志)
|
||||
*/
|
||||
public class LogFragment extends Fragment {
|
||||
|
||||
// ====================== 常量定义区 ======================
|
||||
public static final String TAG = "LogFragment";
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
|
||||
// ====================== 页面参数区 ======================
|
||||
private int mPage;
|
||||
|
||||
// ====================== UI控件区 ======================
|
||||
private LogView mLogView;
|
||||
|
||||
// ====================== 懒加载标记区 ======================
|
||||
private boolean isViewInitialized = false; // 视图控件绑定完成标记
|
||||
private boolean isLazyInitCompleted = false; // 懒加载总流程完成标记
|
||||
private boolean isLogViewStarted = false; // LogView启动状态标记
|
||||
|
||||
// ====================== 实例化函数区 ======================
|
||||
public static LogFragment newInstance(int page) {
|
||||
LogUtils.d(TAG, "newInstance: 创建日志Fragment实例,页码=" + page);
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_PAGE, page);
|
||||
LogFragment fragment = new LogFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
// ====================== 生命周期函数区 ======================
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
LogUtils.d(TAG, "onCreate: Fragment创建开始");
|
||||
if (getArguments() != null) {
|
||||
mPage = getArguments().getInt(ARG_PAGE);
|
||||
LogUtils.d(TAG, "onCreate: 读取页面参数,mPage=" + mPage);
|
||||
}
|
||||
LogUtils.d(TAG, "onCreate: Fragment创建完成");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
LogUtils.d(TAG, "onCreateView: 加载Fragment布局");
|
||||
View view = inflater.inflate(R.layout.fragment_log, container, false);
|
||||
// Java7 适配:添加强制类型转换,仅初始化LogView控件(不启动)
|
||||
mLogView = (LogView) view.findViewById(R.id.logview);
|
||||
LogUtils.d(TAG, "onCreateView: LogView控件初始化完成(未启动)");
|
||||
// 标记视图控件绑定完成
|
||||
isViewInitialized = true;
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
LogUtils.d(TAG, "onResume: Fragment进入前台");
|
||||
// 已完成懒加载 → 仅重启LogView(切回页面时恢复日志显示)
|
||||
if (isLazyInitCompleted && mLogView != null && !isLogViewStarted) {
|
||||
mLogView.start();
|
||||
isLogViewStarted = true;
|
||||
LogUtils.d(TAG, "onResume: LogView已重启,恢复日志显示");
|
||||
}
|
||||
// 未完成懒加载 → 不操作(等待MainActivity调用initData触发)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
LogUtils.d(TAG, "onDestroy: Fragment开始销毁");
|
||||
if (mLogView != null) {
|
||||
// 若LogView有停止方法,必须调用(避免后台持续占用资源,根据实际API调整)
|
||||
// mLogView.stop(); // 关键:释放LogView资源,防止内存泄漏
|
||||
LogUtils.d(TAG, "onDestroy: LogView资源已释放");
|
||||
}
|
||||
// 重置所有标记,避免重建时状态异常
|
||||
mLogView = null;
|
||||
isViewInitialized = false;
|
||||
isLazyInitCompleted = false;
|
||||
isLogViewStarted = false;
|
||||
LogUtils.d(TAG, "onDestroy: Fragment销毁完成");
|
||||
}
|
||||
|
||||
// ====================== 懒加载核心方法(供MainActivity调用) ======================
|
||||
public void initData() {
|
||||
// 双重防护:避免重复初始化(标记+视图就绪+控件非空)
|
||||
if (isLazyInitCompleted || !isViewInitialized || mLogView == null || getContext() == null) {
|
||||
LogUtils.d(TAG, "initData: 懒加载已完成/视图未就绪,跳过");
|
||||
return;
|
||||
}
|
||||
LogUtils.d(TAG, "initData: 开始懒加载初始化,启动LogView");
|
||||
// 核心:启动LogView(原onCreateView中的start逻辑迁移至此)
|
||||
mLogView.start();
|
||||
isLogViewStarted = true;
|
||||
// 标记懒加载总流程完成(仅执行一次)
|
||||
isLazyInitCompleted = true;
|
||||
LogUtils.d(TAG, "initData: 懒加载初始化完成,LogView正常启动");
|
||||
}
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package cc.winboll.studio.contacts.unittest;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.contacts.R;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author 豆包&BigPickle&ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/07/18 19:35
|
||||
* @Describe 布局控件快速便捷辅助草稿
|
||||
*/
|
||||
public class LayoutDraftPreViewActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "LayoutDraftPreViewActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
LogUtils.d(TAG, "onCreate: 布局草稿预览窗口启动");
|
||||
setContentView(R.layout.activity_layoutdraft_preview);
|
||||
initToolbar();
|
||||
LogUtils.d(TAG, "onCreate: 初始化完成");
|
||||
}
|
||||
|
||||
private void initToolbar() {
|
||||
LogUtils.d(TAG, "initToolbar: 初始化工具栏");
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.activity_layoutdraft_preview_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setTitle(TAG);
|
||||
}
|
||||
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "initToolbar: 点击后退按钮,关闭页面");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
LogUtils.d(TAG, "initToolbar: 工具栏初始化完成");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package cc.winboll.studio.contacts.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import cc.winboll.studio.contacts.R;
|
||||
import cc.winboll.studio.libappbase.LogActivity;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/07/18
|
||||
* @Describe 调试工具按钮组控件:提供常用调试功能快捷入口,仅在调试模式下显示
|
||||
*/
|
||||
public class DebugToolButtonsView extends LinearLayout {
|
||||
|
||||
private static final String TAG = "DebugToolButtonsView";
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public DebugToolButtonsView(Context context) {
|
||||
super(context);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public DebugToolButtonsView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public DebugToolButtonsView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
LogUtils.d(TAG, "initView: 初始化调试工具按钮组");
|
||||
this.mContext = context;
|
||||
setOrientation(VERTICAL);
|
||||
LayoutInflater.from(context).inflate(R.layout.view_debug_tool_buttons, this, true);
|
||||
initButtons();
|
||||
LogUtils.d(TAG, "initView: 调试工具按钮组初始化完成");
|
||||
}
|
||||
|
||||
private void initButtons() {
|
||||
Button btnCrash = (Button) findViewById(R.id.btn_debug_crash);
|
||||
Button btnLayoutPreview = (Button) findViewById(R.id.btn_debug_layout_preview);
|
||||
Button btnUnitTest = (Button) findViewById(R.id.btn_debug_unit_test);
|
||||
Button btnLogView = (Button) findViewById(R.id.btn_debug_logview);
|
||||
|
||||
btnCrash.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onTestCrash();
|
||||
}
|
||||
});
|
||||
|
||||
btnLayoutPreview.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onOpenLayoutPreview();
|
||||
}
|
||||
});
|
||||
|
||||
btnUnitTest.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onOpenUnitTest();
|
||||
}
|
||||
});
|
||||
|
||||
btnLogView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onLogView();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onTestCrash() {
|
||||
LogUtils.d(TAG, "onTestCrash: 触发测试崩溃");
|
||||
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
|
||||
((android.app.Activity) mContext).getString(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void onOpenLayoutPreview() {
|
||||
LogUtils.d(TAG, "onOpenLayoutPreview: 打开布局草稿预览窗口");
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(mContext, "cc.winboll.studio.contacts.unittest.LayoutDraftPreViewActivity");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
LogUtils.d(TAG, "onOpenLayoutPreview: 跳转成功");
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "onOpenLayoutPreview: 跳转失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void onOpenUnitTest() {
|
||||
LogUtils.d(TAG, "onOpenUnitTest: 打开单元测试窗口");
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(mContext, "cc.winboll.studio.contacts.activities.UnitTestActivity");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
LogUtils.d(TAG, "onOpenUnitTest: 跳转成功");
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "onOpenUnitTest: 跳转失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转日志查看页面
|
||||
*/
|
||||
private void onLogView() {
|
||||
LogUtils.d(TAG, "onLogView: 打开日志窗口");
|
||||
LogActivity.startLogActivity(getContext(), true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package cc.winboll.studio.contacts.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.contacts.R;
|
||||
import cc.winboll.studio.contacts.dun.Rules;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2026/07/19
|
||||
* @Describe 云盾拦截查询视图控件:实时查询电话号码的云盾拦截状态
|
||||
*/
|
||||
public class DunQueryView extends LinearLayout {
|
||||
|
||||
private static final String TAG = "DunQueryView";
|
||||
|
||||
private Context mContext;
|
||||
private EditText mEtPhone;
|
||||
private TextView mTvResult;
|
||||
|
||||
public DunQueryView(Context context) {
|
||||
super(context);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public DunQueryView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
public DunQueryView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
LogUtils.d(TAG, "initView: 初始化云盾查询视图");
|
||||
this.mContext = context;
|
||||
setOrientation(VERTICAL);
|
||||
LayoutInflater.from(context).inflate(R.layout.view_dun_query, this, true);
|
||||
initViews();
|
||||
initListeners();
|
||||
LogUtils.d(TAG, "initView: 云盾查询视图初始化完成");
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
mEtPhone = (EditText) findViewById(R.id.et_dun_query_phone);
|
||||
mTvResult = (TextView) findViewById(R.id.tv_dun_query_result);
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
mEtPhone.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
queryDunStatus(s.toString().trim());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void queryDunStatus(String phoneNumber) {
|
||||
if (phoneNumber.isEmpty()) {
|
||||
mTvResult.setText("请输入电话号码");
|
||||
mTvResult.setTextColor(mContext.getResources().getColor(R.color.gray_500));
|
||||
LogUtils.d(TAG, "queryDunStatus: 输入为空,显示默认提示");
|
||||
return;
|
||||
}
|
||||
|
||||
Rules rules = Rules.getInstance(mContext);
|
||||
if (rules == null) {
|
||||
mTvResult.setText("云盾规则未初始化");
|
||||
mTvResult.setTextColor(mContext.getResources().getColor(R.color.gray_500));
|
||||
LogUtils.e(TAG, "queryDunStatus: Rules实例获取失败");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isAllowed = rules.isAllowed(phoneNumber, true);
|
||||
if (isAllowed) {
|
||||
mTvResult.setText("这个号码很新,什么防御都不会启动。");
|
||||
mTvResult.setTextColor(mContext.getResources().getColor(R.color.green_normal));
|
||||
LogUtils.d(TAG, "queryDunStatus: 号码" + phoneNumber + " 允许接通");
|
||||
} else {
|
||||
mTvResult.setText("你说我像云像雾像雨又像风~~~ 怎么来来去去,怎么也又播不通~~~");
|
||||
mTvResult.setTextColor(mContext.getResources().getColor(R.color.red_normal));
|
||||
LogUtils.d(TAG, "queryDunStatus: 号码" + phoneNumber + " 被拦截");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24"
|
||||
android:viewportWidth="24">
|
||||
<path
|
||||
android:fillColor="#ff000000"
|
||||
android:pathData="M5.8,10C5.4,8.8 4.3,8 3,8C1.3,8 0,9.3 0,11S1.3,14 3,14C4.3,14 5.4,13.2 5.8,12H7V14H9V12H11V10H5.8M3,12C2.4,12 2,11.6 2,11S2.4,10 3,10 4,10.4 4,11 3.6,12 3,12M16,4C13.8,4 12,5.8 12,8S13.8,12 16,12 20,10.2 20,8 18.2,4 16,4M16,10.1C14.8,10.1 13.9,9.2 13.9,8C13.9,6.8 14.8,5.9 16,5.9C17.2,5.9 18.1,6.8 18.1,8S17.2,10.1 16,10.1M16,13C13.3,13 8,14.3 8,17V20H24V17C24,14.3 18.7,13 16,13M22.1,18.1H9.9V17C9.9,16.4 13,14.9 16,14.9C19,14.9 22.1,16.4 22.1,17V18.1Z"/>
|
||||
|
||||
</vector>
|
||||
+6
-4
@@ -5,8 +5,10 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<cc.winboll.studio.libappbase.LogView
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/logview"/>
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/activity_layoutdraft_preview_toolbar"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -17,6 +17,7 @@
|
||||
android:id="@+id/activitymainToolbar1"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/activity_settings_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
@@ -57,7 +58,6 @@
|
||||
android:id="@+id/tv_DunInfo"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
@@ -325,29 +325,18 @@
|
||||
android:background="@drawable/recycler_view_border"
|
||||
android:layout_margin="5dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="单元测试:"/>
|
||||
android:text="初始化测试规则"
|
||||
android:onClick="onInitTestRules"
|
||||
android:layout_margin="5dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="LogView"
|
||||
android:onClick="onLogView"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Unit Test"
|
||||
android:onClick="onUnitTest"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<cc.winboll.studio.contacts.views.DunQueryView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/recycler_view_border">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="调试工具"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/red_normal"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_debug_logview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="应用日志"
|
||||
android:textSize="12sp"
|
||||
android:layout_margin="2dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_debug_unit_test"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="单元测试"
|
||||
android:textSize="12sp"
|
||||
android:layout_margin="2dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_debug_layout_preview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="布局草稿"
|
||||
android:textSize="12sp"
|
||||
android:layout_margin="2dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_debug_crash"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="测试崩溃"
|
||||
android:textSize="12sp"
|
||||
android:layout_margin="2dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/recycler_view_border">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="云盾拦截查询"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/red_normal"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_dun_query_phone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="输入电话号码查询拦截状态"
|
||||
android:inputType="phone"
|
||||
android:textSize="14sp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_dun_query_result"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="请输入电话号码"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray_500"/>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user