Compare commits
14 Commits
positions-
...
mymessagem
| Author | SHA1 | Date | |
|---|---|---|---|
| 0a4922f767 | |||
| faf8e3b8f7 | |||
| 6b3388ec2a | |||
| 52c005feab | |||
| d4e319aae4 | |||
| b958eba720 | |||
| 8f68dc778b | |||
| 8effa62082 | |||
| d7bff51148 | |||
| dae93f07b7 | |||
| 64372e7983 | |||
| e90f905cd8 | |||
| 090070aa0e | |||
| bb94f87597 |
@@ -5,10 +5,11 @@
|
||||
## ☁ ☁ ☁ WinBoLL APP ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ WinBoLL Studio Android 应用开源项目。☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ WinBoLL 网站地址 https://www.winboll.cc/ ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ WinBoLL 源码地址 <https://gitea.winboll.cc/Studio/APPBase> ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ GitHub 源码地址 <https://github.com/ZhanGSKen/APPBase.git> ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ 码云 源码地址 <https://gitee.com/zhangsken/appbase.git> ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
|
||||
# ☁ ☁ ☁ WinBoLL 源码地址 <https://gitea.winboll.cc/Studio/WinBoLL.git> ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ GitHub 源码地址 <https://github.com/ZhanGSKen/WinBoLL.git> ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ 码云 源码地址 <https://gitee.com/zhangsken/winboll.git> ☁ ☁ ☁ ☁ ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ 在 jitpack.io 托管的 APPBase 类库源码<https://github.com/ZhanGSKen/APPBase.git> ☁ ☁ ☁ ☁
|
||||
# ☁ ☁ ☁ 在 jitpack.io 托管的 AES 类库源码<https://github.com/ZhanGSKen/AES.git> ☁ ☁ ☁ ☁
|
||||
## WinBoLL 提问
|
||||
同样是 /sdcard 目录,在开发 Android 应用时,
|
||||
能否实现手机编译与电脑编译的源码同步。
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" >
|
||||
|
||||
<application>
|
||||
|
||||
<!-- Put flavor specific code here -->
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
Manifest-Version: 1.0
|
||||
Built-By: Generated-by-ADT
|
||||
Created-By: Android Gradle 3.5.0
|
||||
|
||||
Name: AndroidManifest.xml
|
||||
SHA1-Digest: U36A0NWthb49+Rxs33tkIuNYFCI=
|
||||
|
||||
Name: jni/Android.mk
|
||||
SHA1-Digest: ZpGSlRJPL0g9OejiWbQorqj40/Y=
|
||||
|
||||
Name: jni/Application.mk
|
||||
SHA1-Digest: TKh2CbRLeKfvgL4cPfmoxcVz+vc=
|
||||
|
||||
Name: jni/hello-jni.cpp
|
||||
SHA1-Digest: 1btXO19SqB6rDvPo5ynG0brDqTk=
|
||||
|
||||
Name: project.properties
|
||||
SHA1-Digest: 0ekOiGTFMVJOWqAFzNFj/1vxPL8=
|
||||
|
||||
Name: res/values/strings.xml
|
||||
SHA1-Digest: FgRO/zbNaC1wuZKVT7h6NSYBmpY=
|
||||
|
||||
Name: src/$package_name$/HelloJni.java
|
||||
SHA1-Digest: p0e9DNKocjRnsOhetb9bnp9s9J4=
|
||||
|
||||
|
||||
@@ -29,28 +29,30 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.3"
|
||||
versionName "15.12"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
// 米盟 SDK
|
||||
packagingOptions {
|
||||
doNotStrip "*/*/libmimo_1011.so"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api 'cc.winboll.studio:libaes:15.9.3'
|
||||
api 'cc.winboll.studio:libapputils:15.8.6'
|
||||
api 'cc.winboll.studio:libappbase:15.9.5'
|
||||
|
||||
|
||||
// 米盟
|
||||
api 'com.miui.zeus:mimo-ad-sdk:5.3.+'//请使用最新版sdk
|
||||
//注意:以下5个库必须要引入
|
||||
//api 'androidx.appcompat:appcompat:1.4.1'
|
||||
api 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
api 'com.google.code.gson:gson:2.8.5'
|
||||
api 'com.github.bumptech.glide:glide:4.9.0'
|
||||
//annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
||||
|
||||
api 'io.github.medyo:android-about-page:2.0.0'
|
||||
api 'com.github.getActivity:ToastUtils:10.5'
|
||||
api 'com.jcraft:jsch:0.1.55'
|
||||
api 'org.jsoup:jsoup:1.13.1'
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
@@ -69,4 +71,14 @@ dependencies {
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
api 'com.google.android.material:material:1.0.0'
|
||||
|
||||
// WinBoLL库 nexus.winboll.cc 地址
|
||||
//api 'cc.winboll.studio:libaes:15.12.0'
|
||||
//api 'cc.winboll.studio:libappbase:15.12.2'
|
||||
|
||||
// WinBoLL备用库 jitpack.io 地址
|
||||
api 'com.github.ZhanGSKen:AES:aes-v15.12.4'
|
||||
api 'com.github.ZhanGSKen:APPBase:appbase-v15.12.2'
|
||||
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sun Sep 28 12:37:31 HKT 2025
|
||||
stageCount=10
|
||||
#Sat Dec 13 17:23:20 HKT 2025
|
||||
stageCount=5
|
||||
libraryProject=
|
||||
baseVersion=15.3
|
||||
publishVersion=15.3.9
|
||||
baseVersion=15.12
|
||||
publishVersion=15.12.4
|
||||
buildCount=0
|
||||
baseBetaVersion=15.3.10
|
||||
baseBetaVersion=15.12.5
|
||||
|
||||
138
mymessagemanager/proguard-rules.pro
vendored
138
mymessagemanager/proguard-rules.pro
vendored
@@ -9,9 +9,135 @@
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
# ============================== 基础通用规则 ==============================
|
||||
# 保留系统组件
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
-keep public class * extends android.app.backup.BackupAgentHelper
|
||||
-keep public class * extends android.preference.Preference
|
||||
|
||||
# 保留 WinBoLL 核心包及子类(合并简化规则)
|
||||
-keep class cc.winboll.studio.** { *; }
|
||||
-keepclassmembers class cc.winboll.studio.** { *; }
|
||||
|
||||
# 保留所有类中的 public static final String TAG 字段(便于日志定位)
|
||||
-keepclassmembers class * {
|
||||
public static final java.lang.String TAG;
|
||||
}
|
||||
|
||||
# 保留序列化类(避免Parcelable/Gson解析异常)
|
||||
-keep class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
||||
-keepclassmembers class * implements java.io.Serializable {
|
||||
static final long serialVersionUID;
|
||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
||||
private void writeObject(java.io.ObjectOutputStream);
|
||||
private void readObject(java.io.ObjectInputStream);
|
||||
java.lang.Object writeReplace();
|
||||
java.lang.Object readResolve();
|
||||
}
|
||||
|
||||
# 保留 R 文件(避免资源ID混淆)
|
||||
-keepclassmembers class **.R$* {
|
||||
public static <fields>;
|
||||
}
|
||||
|
||||
# 保留 native 方法(避免JNI调用失败)
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
# 保留注解和泛型(避免反射/序列化异常)
|
||||
-keepattributes *Annotation*
|
||||
-keepattributes Signature
|
||||
|
||||
# 屏蔽 Java 8+ 警告(适配 Java 7 语法)
|
||||
-dontwarn java.lang.invoke.*
|
||||
-dontwarn android.support.v8.renderscript.*
|
||||
-dontwarn java.util.function.**
|
||||
|
||||
# ============================== 第三方框架专项规则 ==============================
|
||||
# OkHttp 4.4.1(米盟广告请求依赖,完善Lambda兼容)
|
||||
-keep class okhttp3.** { *; }
|
||||
-keep interface okhttp3.** { *; }
|
||||
-keep class okhttp3.internal.** { *; }
|
||||
-keep class okio.** { *; }
|
||||
-dontwarn okhttp3.internal.platform.**
|
||||
-dontwarn okio.**
|
||||
# ============================== 必要补充规则 ==============================
|
||||
# OkHttp 4.4.1 补充规则(Java 7 兼容)
|
||||
-keep class okhttp3.internal.concurrent.** { *; }
|
||||
-keep class okhttp3.internal.connection.** { *; }
|
||||
-dontwarn okhttp3.internal.concurrent.TaskRunner
|
||||
-dontwarn okhttp3.internal.connection.RealCall
|
||||
|
||||
# Glide 4.9.0(米盟广告图片加载依赖)
|
||||
-keep public class * implements com.bumptech.glide.module.GlideModule
|
||||
-keep public class * extends com.bumptech.glide.module.AppGlideModule
|
||||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$ImageType {
|
||||
**[] $VALUES;
|
||||
public *;
|
||||
}
|
||||
-keepclassmembers class * implements com.bumptech.glide.module.AppGlideModule {
|
||||
<init>();
|
||||
}
|
||||
-dontwarn com.bumptech.glide.**
|
||||
|
||||
# Gson 2.8.5(米盟广告数据序列化依赖)
|
||||
-keep class com.google.gson.** { *; }
|
||||
-keep interface com.google.gson.** { *; }
|
||||
-keepclassmembers class * {
|
||||
@com.google.gson.annotations.SerializedName <fields>;
|
||||
}
|
||||
|
||||
# 米盟 SDK(核心广告组件,完整保留避免加载失败)
|
||||
-keep class com.miui.zeus.** { *; }
|
||||
-keep interface com.miui.zeus.** { *; }
|
||||
# 保留米盟日志字段(便于广告加载失败排查)
|
||||
-keepclassmembers class com.miui.zeus.mimo.sdk.** {
|
||||
public static final java.lang.String TAG;
|
||||
}
|
||||
|
||||
# RecyclerView 1.0.0(米盟广告布局渲染依赖)
|
||||
-keep class androidx.recyclerview.** { *; }
|
||||
-keep interface androidx.recyclerview.** { *; }
|
||||
-keepclassmembers class androidx.recyclerview.widget.RecyclerView$Adapter {
|
||||
public *;
|
||||
}
|
||||
|
||||
# 其他第三方框架(按引入依赖保留,无则可删除)
|
||||
# XXPermissions 18.63
|
||||
-keep class com.hjq.permissions.** { *; }
|
||||
-keep interface com.hjq.permissions.** { *; }
|
||||
|
||||
# ZXing 二维码(核心解析组件)
|
||||
-keep class com.google.zxing.** { *; }
|
||||
-keep class com.journeyapps.zxing.** { *; }
|
||||
|
||||
# Jsoup HTML解析
|
||||
-keep class org.jsoup.** { *; }
|
||||
|
||||
# Pinyin4j 拼音搜索
|
||||
-keep class net.sourceforge.pinyin4j.** { *; }
|
||||
|
||||
# JSch SSH组件
|
||||
-keep class com.jcraft.jsch.** { *; }
|
||||
|
||||
# AndroidX 基础组件
|
||||
-keep class androidx.appcompat.** { *; }
|
||||
-keep interface androidx.appcompat.** { *; }
|
||||
|
||||
# ============================== 优化与调试配置 ==============================
|
||||
# 优化级别(平衡混淆效果与性能)
|
||||
-optimizationpasses 5
|
||||
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
|
||||
|
||||
# 调试辅助(保留行号便于崩溃定位)
|
||||
-verbose
|
||||
-dontpreverify
|
||||
-dontusemixedcaseclassnames
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ package cc.winboll.studio.mymessagemanager;
|
||||
*/
|
||||
import android.view.Gravity;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.io.File;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
@@ -29,18 +30,23 @@ public class App extends GlobalApplication {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
setIsDebugging(BuildConfig.DEBUG);
|
||||
//setIsDebugging(false);
|
||||
|
||||
// 初始化窗口管理类
|
||||
WinBoLLActivityManager.init(this);
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
ToastUtils.setView(R.layout.toast_custom_view);
|
||||
//ToastUtils.setStyle(new WhiteToastStyle());
|
||||
ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
|
||||
//LogUtils.d(TAG, "BuildConfig.DEBUG " + Boolean.toString(BuildConfig.DEBUG));
|
||||
|
||||
_mszAppExternalFilesDir = getExternalFilesDir(TAG).toString();
|
||||
_mszConfigUtilPath = _mszAppExternalFilesDir + File.separator + _mszConfigUtilFileName;
|
||||
_mszSMSReceiveRuleUtilPath = _mszAppExternalFilesDir + File.separator + _mszSMSReceiveRuleUtilFileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
super.onTerminate();
|
||||
ToastUtils.release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ import android.os.Bundle;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.winboll.APPInfo;
|
||||
import cc.winboll.studio.libaes.winboll.AboutView;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.models.APPInfo;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libaes.views.AboutView;
|
||||
import cc.winboll.studio.mymessagemanager.App;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
|
||||
@@ -64,13 +65,13 @@ public class AboutActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
);
|
||||
layout.addView(aboutView, params);
|
||||
|
||||
App.getWinBoLLActivityManager().add(this);
|
||||
WinBoLLActivityManager.getInstance().add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
App.getWinBoLLActivityManager().registeRemove(this);
|
||||
WinBoLLActivityManager.getInstance().registeRemove(this);
|
||||
}
|
||||
|
||||
public AboutView CreateAboutView() {
|
||||
|
||||
@@ -5,25 +5,31 @@ package cc.winboll.studio.mymessagemanager.activitys;
|
||||
* @Date 2024/05/12 20:03:42
|
||||
* @Describe 应用设置窗口
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Switch;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
|
||||
import cc.winboll.studio.libaes.views.AToolbar;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.dialogs.CharsetRefuseEditDialog;
|
||||
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.PermissionUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
|
||||
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
|
||||
|
||||
public class AppSettingsActivity extends BaseActivity {
|
||||
public class AppSettingsActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "AppSettingsActivity";
|
||||
|
||||
// 讯飞语记官网下载页链接
|
||||
private static final String XUNFEI_YUJI_DOWNLOAD_URL = "https://iflynote.com/h/share-download-app.html";
|
||||
|
||||
AppConfigUtil mAppConfigUtil;
|
||||
AToolbar mAToolbar;
|
||||
AOHPCTCSeekBar mAOHPCTCSeekBar;
|
||||
@@ -31,8 +37,19 @@ public class AppSettingsActivity extends BaseActivity {
|
||||
EditText metPhoneMergePrefix;
|
||||
Switch mswMergePrefixPhone;
|
||||
Switch mswSMSRecycleProtectMode;
|
||||
EditText metProtectModerRefuseChars;
|
||||
//EditText metProtectModerRefuseChars;
|
||||
EditText metProtectModerReplaceChars;
|
||||
String mszProtectModerRefuseChars = "";
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -58,13 +75,14 @@ public class AppSettingsActivity extends BaseActivity {
|
||||
|
||||
mswSMSRecycleProtectMode = findViewById(R.id.activityappsettingsSwitch3);
|
||||
mswSMSRecycleProtectMode.setChecked(mAppConfigUtil.mAppConfigBean.isSMSRecycleProtectMode());
|
||||
|
||||
metProtectModerRefuseChars = findViewById(R.id.activityappsettingsEditText3);
|
||||
metProtectModerRefuseChars.setText(mAppConfigUtil.mAppConfigBean.getProtectModerRefuseChars());
|
||||
|
||||
|
||||
//metProtectModerRefuseChars = findViewById(R.id.activityappsettingsEditText3);
|
||||
//metProtectModerRefuseChars.setText(mAppConfigUtil.mAppConfigBean.getProtectModerRefuseChars());
|
||||
mszProtectModerRefuseChars = mAppConfigUtil.mAppConfigBean.getProtectModerRefuseChars();
|
||||
|
||||
metProtectModerReplaceChars = findViewById(R.id.activityappsettingsEditText4);
|
||||
metProtectModerReplaceChars.setText(mAppConfigUtil.mAppConfigBean.getProtectModerReplaceChars());
|
||||
|
||||
|
||||
mAOHPCTCSeekBar = findViewById(R.id.activityappsettingsAOHPCTCSeekBar1);
|
||||
mAOHPCTCSeekBar.setThumb(getDrawable(R.drawable.cursor_pointer));
|
||||
mAOHPCTCSeekBar.setThumbOffset(0);
|
||||
@@ -74,7 +92,8 @@ public class AppSettingsActivity extends BaseActivity {
|
||||
public void onOHPCommit() {
|
||||
mAppConfigUtil.reLoadConfig();
|
||||
mAppConfigUtil.mAppConfigBean.setIsSMSRecycleProtectMode(mswSMSRecycleProtectMode.isChecked());
|
||||
mAppConfigUtil.mAppConfigBean.setProtectModerRefuseChars(metProtectModerRefuseChars.getText().toString());
|
||||
//mAppConfigUtil.mAppConfigBean.setProtectModerRefuseChars(metProtectModerRefuseChars.getText().toString());
|
||||
mAppConfigUtil.mAppConfigBean.setProtectModerRefuseChars(mszProtectModerRefuseChars);
|
||||
mAppConfigUtil.mAppConfigBean.setProtectModerReplaceChars(metProtectModerReplaceChars.getText().toString());
|
||||
mAppConfigUtil.mAppConfigBean.setCountryCode(metPhoneMergePrefix.getText().toString());
|
||||
mAppConfigUtil.mAppConfigBean.setIsMergeCountryCodePrefix(mswMergePrefixPhone.isChecked());
|
||||
@@ -98,18 +117,34 @@ public class AppSettingsActivity extends BaseActivity {
|
||||
Toast.makeText(getApplication(), "应用已获得所需权限。", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void onCleanOldChannels(View view) {
|
||||
YesNoAlertDialog.show(this, "通知设置清理", "是否清理旧的通知设置?", new YesNoAlertDialog.OnDialogResultListener(){
|
||||
@Override
|
||||
public void onNo() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
NotificationHelper notificationHelper = new NotificationHelper(AppSettingsActivity.this);
|
||||
notificationHelper.cleanOldChannels();
|
||||
}
|
||||
});
|
||||
public void onAddTTSSupport(View view) {
|
||||
try {
|
||||
// 1. 创建Intent,Action为“打开网页”
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
// 2. 设置要跳转的URL
|
||||
intent.setData(Uri.parse(XUNFEI_YUJI_DOWNLOAD_URL));
|
||||
// 3. 确保Intent可被解析(避免无浏览器时崩溃)
|
||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(intent); // 跳转至浏览器打开下载页
|
||||
} else {
|
||||
// 无浏览器时的提示
|
||||
Toast.makeText(this, "未找到浏览器应用,请安装后重试", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(this, "无法打开下载页面,请稍后再试", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void onCharsetRefuseEditDialog(View view) {
|
||||
CharsetRefuseEditDialog dlg = new CharsetRefuseEditDialog(this, new CharsetRefuseEditDialog.OnTextConfirmListener(){
|
||||
@Override
|
||||
public void onTextConfirmed(String editText) {
|
||||
//ToastUtils.show(editText);
|
||||
mszProtectModerRefuseChars = editText;
|
||||
}
|
||||
}, mszProtectModerRefuseChars);
|
||||
dlg.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
package cc.winboll.studio.mymessagemanager.activitys;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
|
||||
abstract public class BaseActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "BaseActivity";
|
||||
|
||||
IOnActivityMessageReceived mIOnActivityMessageReceived;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
//AppConfigUtil configUtil = AppConfigUtil.getInstance(this);
|
||||
//setTheme(configUtil.mAppConfigBean.getAppThemeID());
|
||||
LogUtils.d(TAG, "AESThemeUtil.getThemeTypeID(this) is : " + Integer.toString(AESThemeUtil.getThemeTypeID(this)));
|
||||
setTheme(AESThemeUtil.getThemeTypeID(this));
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
public void sendActivityMessage(Message msg) {
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
protected void setOnActivityMessageReceived(IOnActivityMessageReceived iOnActivityMessageReceived) {
|
||||
mIOnActivityMessageReceived = iOnActivityMessageReceived;
|
||||
}
|
||||
|
||||
Handler mHandler = new Handler(){
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (mIOnActivityMessageReceived != null) {
|
||||
mIOnActivityMessageReceived.onActivityMessageReceived(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected interface IOnActivityMessageReceived {
|
||||
void onActivityMessageReceived(Message msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
AESThemeUtil.inflateMenu(this, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
/*if (AESThemeUtil.onAppCompatThemeItemSelected(this, item)) {
|
||||
ToastUtils.show("onAppCompatThemeItemSelected");
|
||||
recreate();
|
||||
}*/
|
||||
|
||||
/*int nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEFAULT);
|
||||
if (R.id.item_depththeme == item.getItemId()) {
|
||||
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEPTH);
|
||||
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
|
||||
recreate();
|
||||
} else if (R.id.item_skytheme == item.getItemId()) {
|
||||
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.SKY);
|
||||
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
|
||||
recreate();
|
||||
} else if (R.id.item_goldentheme == item.getItemId()) {
|
||||
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.GOLDEN);
|
||||
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
|
||||
recreate();
|
||||
} else if (R.id.item_taotheme == item.getItemId()) {
|
||||
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.TAO);
|
||||
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
|
||||
recreate();
|
||||
} else if (R.id.item_defaulttheme == item.getItemId()) {
|
||||
nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEFAULT);
|
||||
AESThemeUtil.saveThemeStyleID(this, nThemeStyleID);
|
||||
recreate();
|
||||
}*/
|
||||
|
||||
//int nThemeStyleID = AESThemeBean.getThemeStyleID(AESThemeBean.ThemeType.DEFAULT);
|
||||
if (R.id.item_depththeme == item.getItemId()) {
|
||||
AESThemeUtil.saveThemeStyleID(this, R.style.MyDepthAESTheme);
|
||||
recreate();
|
||||
} else if (R.id.item_skytheme == item.getItemId()) {
|
||||
AESThemeUtil.saveThemeStyleID(this, R.style.MySkyAESTheme);
|
||||
recreate();
|
||||
} else if (R.id.item_goldentheme == item.getItemId()) {
|
||||
AESThemeUtil.saveThemeStyleID(this, R.style.MyGoldenAESTheme);
|
||||
recreate();
|
||||
} else if (R.id.item_memortheme == item.getItemId()) {
|
||||
AESThemeUtil.saveThemeStyleID(this, R.style.MyMemorAESTheme);
|
||||
recreate();
|
||||
} else if (R.id.item_taotheme == item.getItemId()) {
|
||||
AESThemeUtil.saveThemeStyleID(this, R.style.MyTaoAESTheme);
|
||||
recreate();
|
||||
} else if (R.id.item_defaulttheme == item.getItemId()) {
|
||||
AESThemeUtil.saveThemeStyleID(this, R.style.MyAppTheme);
|
||||
recreate();
|
||||
} else if (R.id.item_defaulttheme == item.getItemId()) {
|
||||
AESThemeUtil.saveThemeStyleID(this, R.style.MyAppTheme);
|
||||
recreate();
|
||||
}
|
||||
//ToastUtils.show("nThemeStyleID " + Integer.toString(nThemeStyleID));
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ package cc.winboll.studio.mymessagemanager.activitys;
|
||||
* @Date 2025/08/30 14:32
|
||||
* @Describe 联系人查询与短信发送窗口
|
||||
*/
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@@ -16,23 +18,21 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toolbar;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.beans.PhoneBean;
|
||||
import cc.winboll.studio.mymessagemanager.utils.PhoneUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import android.app.Activity;
|
||||
|
||||
public class ComposeSMSActivity extends BaseActivity {
|
||||
public class ComposeSMSActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static String TAG = "ComposeSMSActivity";
|
||||
public static String EXTRA_SMSBODY = "sms_body";
|
||||
@@ -54,6 +54,16 @@ public class ComposeSMSActivity extends BaseActivity {
|
||||
private AOHPCTCSeekBar mAOHPCTCSeekBar;
|
||||
private RelativeLayout mrlContracts;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -11,8 +11,11 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ScrollView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.utils.DevelopUtils;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libaes.views.ADsBannerView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.mymessagemanager.App;
|
||||
import cc.winboll.studio.mymessagemanager.BuildConfig;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
@@ -30,7 +33,7 @@ import cc.winboll.studio.mymessagemanager.views.PhoneListViewForScrollView;
|
||||
import com.baoyz.widget.PullRefreshLayout;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MainActivity extends BaseActivity {
|
||||
public class MainActivity extends WinBoLLActivity {
|
||||
|
||||
public final static String TAG = "MainActivity";
|
||||
|
||||
@@ -42,6 +45,8 @@ public class MainActivity extends BaseActivity {
|
||||
public static final int MY_PERMISSIONS_REQUEST = 0;
|
||||
|
||||
static MainActivity _mMainActivity;
|
||||
ADsBannerView mADsBannerView;
|
||||
|
||||
//LogView mLogView;
|
||||
AppConfigUtil mAppConfigUtil;
|
||||
ConfirmSwitchView msvEnableService;
|
||||
@@ -64,6 +69,9 @@ public class MainActivity extends BaseActivity {
|
||||
setContentView(R.layout.activity_main);
|
||||
_mMainActivity = MainActivity.this;
|
||||
|
||||
// 米盟广告栏
|
||||
mADsBannerView = findViewById(R.id.adsbanner);
|
||||
|
||||
mAppConfigUtil = AppConfigUtil.getInstance(this);
|
||||
initView();
|
||||
|
||||
@@ -256,21 +264,31 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mADsBannerView != null) {
|
||||
mADsBannerView.releaseAdResources();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
reloadSMS();
|
||||
//mLogView.start();
|
||||
if (mADsBannerView != null) {
|
||||
mADsBannerView.resumeADs(MainActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
//return super.onCreateOptionsMenu(menu);
|
||||
getMenuInflater().inflate(R.menu.toolbar_main, menu);
|
||||
super.onCreateOptionsMenu(menu);
|
||||
getMenuInflater().inflate(R.menu.toolbar_main2, menu);
|
||||
getMenuInflater().inflate(R.menu.toolbar_main_first, menu);
|
||||
// 主题菜单
|
||||
AESThemeUtil.inflateMenu(this, menu);
|
||||
// 调试工具菜单
|
||||
if (App.isDebugging()) {
|
||||
DevelopUtils.inflateMenu(this, menu);
|
||||
getMenuInflater().inflate(R.menu.toolbar_main_debug, menu);
|
||||
}
|
||||
getMenuInflater().inflate(R.menu.toolbar_main_last, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -285,7 +303,12 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int nItemId = item.getItemId();
|
||||
if (nItemId == R.id.app_ttsrule) {
|
||||
int menuItemId = item.getItemId();
|
||||
if (AESThemeUtil.onAppThemeItemSelected(this, item)) {
|
||||
recreate();
|
||||
} if (DevelopUtils.onDevelopItemSelected(this, item)) {
|
||||
LogUtils.d(TAG, String.format("onOptionsItemSelected item.getItemId() %d ", item.getItemId()));
|
||||
} else if (nItemId == R.id.app_ttsrule) {
|
||||
Intent i = new Intent(MainActivity.this, TTSPlayRuleActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
@@ -297,16 +320,10 @@ public class MainActivity extends BaseActivity {
|
||||
Intent i = new Intent(MainActivity.this, AppSettingsActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
} else if (nItemId == R.id.app_log) {
|
||||
App.getWinBoLLActivityManager().startLogActivity(this);
|
||||
} else if (nItemId == R.id.app_unittest) {
|
||||
} else if (nItemId == R.id.app_unittest) {
|
||||
Intent i = new Intent(MainActivity.this, UnitTestActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(i);
|
||||
} else if (nItemId == R.id.app_crashtest) {
|
||||
for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
|
||||
getString(i);
|
||||
}
|
||||
} else if (nItemId == R.id.app_about) {
|
||||
Intent i = new Intent(MainActivity.this, AboutActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
@@ -7,10 +7,8 @@ import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
@@ -19,6 +17,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.Toolbar;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.adapters.SMSArrayAdapter;
|
||||
@@ -27,9 +26,9 @@ import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.ViewUtil;
|
||||
import cc.winboll.studio.mymessagemanager.views.BottomPositionFixedScrollView;
|
||||
import cc.winboll.studio.mymessagemanager.views.SMSListViewForScrollView;
|
||||
import java.lang.ref.WeakReference;
|
||||
import android.app.Activity;
|
||||
|
||||
public class SMSActivity extends BaseActivity {
|
||||
public class SMSActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
public static String TAG = "SMSActivity";
|
||||
public static final String ACTION_NOTIFY_SMS_CHANGED = "cc.winboll.studio.mymessagemanager.activitys.SMSActivity.ACTION_NOTIFY_SMS_CHANGED";
|
||||
public static final String EXTRA_PHONE = "Phone";
|
||||
@@ -45,6 +44,16 @@ public class SMSActivity extends BaseActivity {
|
||||
Handler mSetFocusHandler;
|
||||
private boolean isImeVisible = false;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.mymessagemanager.App;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.SMSReceiveRuleActivity;
|
||||
@@ -29,8 +30,9 @@ import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.utils.FileUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
|
||||
import com.baoyz.widget.PullRefreshLayout;
|
||||
import android.app.Activity;
|
||||
|
||||
public class SMSReceiveRuleActivity extends BaseActivity {
|
||||
public class SMSReceiveRuleActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "SMSReceiveRuleActivity";
|
||||
|
||||
@@ -43,6 +45,16 @@ public class SMSReceiveRuleActivity extends BaseActivity {
|
||||
SMSAcceptRuleBean mSMSAcceptRuleBeanAdd;
|
||||
SMSAcceptRuleArrayAdapter mSMSAcceptRuleArrayAdapter;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -5,13 +5,15 @@ package cc.winboll.studio.mymessagemanager.activitys;
|
||||
* @Date 2024/07/19 16:56:18
|
||||
* @Describe 短信回收站
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.SMSRecycleActivity;
|
||||
import cc.winboll.studio.mymessagemanager.adapters.SMSRecycleAdapter;
|
||||
@@ -19,7 +21,7 @@ import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
|
||||
import com.baoyz.widget.PullRefreshLayout;
|
||||
import java.io.File;
|
||||
|
||||
public class SMSRecycleActivity extends BaseActivity {
|
||||
public class SMSRecycleActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "SMSRecycleActivity";
|
||||
|
||||
@@ -27,6 +29,16 @@ public class SMSRecycleActivity extends BaseActivity {
|
||||
RecyclerView mRecyclerView;
|
||||
SMSRecycleAdapter mSMSRecycleAdapter;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -74,7 +86,7 @@ public class SMSRecycleActivity extends BaseActivity {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
YesNoAlertDialog.OnDialogResultListener mDeleteListener = new YesNoAlertDialog.OnDialogResultListener() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,19 +7,34 @@ import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.SMSReceiveRuleActivity;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.SharedJSONReceiveActivity;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.mymessagemanager.utils.UriUtil;
|
||||
import java.util.ArrayList;
|
||||
import android.app.Activity;
|
||||
|
||||
public class SharedJSONReceiveActivity extends BaseActivity {
|
||||
public class SharedJSONReceiveActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "SharedJSONReceive";
|
||||
|
||||
Toolbar mToolbar;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -16,13 +16,15 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.adapters.TTSRuleBeanRecyclerViewAdapter;
|
||||
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.utils.FileUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
|
||||
import android.app.Activity;
|
||||
|
||||
public class TTSPlayRuleActivity extends BaseActivity {
|
||||
public class TTSPlayRuleActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "TTSPlayRuleActivity";
|
||||
|
||||
@@ -39,6 +41,16 @@ public class TTSPlayRuleActivity extends BaseActivity {
|
||||
EditText metPatternText;
|
||||
EditText metCurrentTTSRuleText;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -7,17 +7,18 @@ package cc.winboll.studio.mymessagemanager.activitys;
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.MenuItem;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.libaes.beans.AESThemeBean;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.mymessagemanager.enums.ThemeStyleEnum;
|
||||
|
||||
public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "WinBoLLActivity";
|
||||
|
||||
protected volatile AESThemeBean.ThemeType mThemeType;
|
||||
IOnActivityMessageReceived mIOnActivityMessageReceived;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
@@ -31,30 +32,51 @@ public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivi
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mThemeType = getThemeType();
|
||||
setThemeStyle();
|
||||
// 1. 优先读取SP中保存的主题(必须在setContentView前调用!)
|
||||
ThemeStyleEnum savedTheme = ThemeStyleEnum.getThemeFromSP(this);
|
||||
// 2. 设置主题
|
||||
setTheme(savedTheme.getStyleId());
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
AESThemeBean.ThemeType getThemeType() {
|
||||
/*SharedPreferences sharedPreferences = getSharedPreferences(
|
||||
SHAREDPREFERENCES_NAME, MODE_PRIVATE);
|
||||
return AESThemeBean.ThemeType.values()[((sharedPreferences.getInt(DRAWER_THEME_TYPE, AESThemeBean.ThemeType.DEFAULT.ordinal())))];
|
||||
*/
|
||||
return AESThemeBean.getThemeStyleType(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int selectedMenuId = item.getItemId();
|
||||
// 1. 根据菜单ID获取对应的主题枚举
|
||||
ThemeStyleEnum selectedTheme = ThemeStyleEnum.getThemeByMenuId(selectedMenuId);
|
||||
|
||||
if (selectedTheme != null) {
|
||||
// 2. 调用枚举自带方法保存主题到SP(替代AESThemeUtil)
|
||||
ThemeStyleEnum.saveThemeToSP(this, selectedTheme);
|
||||
recreate(); // 重建Activity生效主题
|
||||
} else if (selectedMenuId == android.R.id.home) {
|
||||
finish();
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected interface IOnActivityMessageReceived {
|
||||
void onActivityMessageReceived(Message msg);
|
||||
}
|
||||
|
||||
void setThemeStyle() {
|
||||
//setTheme(AESThemeBean.getThemeStyle(getThemeType()));
|
||||
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
public void sendActivityMessage(Message msg) {
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
return true;
|
||||
|
||||
protected void setOnActivityMessageReceived(IOnActivityMessageReceived iOnActivityMessageReceived) {
|
||||
mIOnActivityMessageReceived = iOnActivityMessageReceived;
|
||||
}
|
||||
|
||||
Handler mHandler = new Handler(){
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (mIOnActivityMessageReceived != null) {
|
||||
mIOnActivityMessageReceived.onActivityMessageReceived(msg);
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SMSAcceptRuleArrayAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
@@ -14,20 +14,20 @@ import android.widget.LinearLayout;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSBean;
|
||||
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSReceiveRuleUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
|
||||
import cc.winboll.studio.mymessagemanager.views.DateAgoTextView;
|
||||
import cc.winboll.studio.mymessagemanager.views.SMSView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.ArrayList;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
|
||||
|
||||
public class SMSArrayAdapter extends BaseAdapter {
|
||||
|
||||
|
||||
@@ -20,11 +20,13 @@ import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSBean;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSRecycleBean;
|
||||
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
|
||||
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSRecycleUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.SMSUtil;
|
||||
@@ -32,9 +34,7 @@ import cc.winboll.studio.mymessagemanager.utils.TTSPlayRuleUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.UserVisionSystemProtectModeUtil;
|
||||
import cc.winboll.studio.mymessagemanager.views.DateAgoTextView;
|
||||
import cc.winboll.studio.mymessagemanager.views.SMSView;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.ArrayList;
|
||||
import cc.winboll.studio.mymessagemanager.utils.AddressUtils;
|
||||
|
||||
public class SMSRecycleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package cc.winboll.studio.mymessagemanager.dialogs;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/12/13 17:04
|
||||
* @Describe 字符集编辑拒绝对话框
|
||||
* 包含标题、300dp×300dp多行编辑框、确定/取消按钮(确定在右,取消在左)
|
||||
* 支持预制文本初始化、编辑内容回传
|
||||
*/
|
||||
public class CharsetRefuseEditDialog extends Dialog {
|
||||
public static final String TAG = "CharsetRefuseEditDialog";
|
||||
// 文本回传接口
|
||||
public interface OnTextConfirmListener {
|
||||
void onTextConfirmed(String editText); // 确定按钮点击时回传编辑后的文本
|
||||
}
|
||||
|
||||
private final OnTextConfirmListener mListener; // 外部传入的回传接口
|
||||
private final String mPreText; // 预制文本框的内容
|
||||
private EditText mEditText; // 多行文本编辑框
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param context 上下文
|
||||
* @param listener 文本回传接口(外部实现)
|
||||
* @param preText 预制的编辑框初始文本
|
||||
*/
|
||||
public CharsetRefuseEditDialog(Context context, OnTextConfirmListener listener, String preText) {
|
||||
super(context);
|
||||
this.mListener = listener;
|
||||
this.mPreText = preText;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 禁用对话框默认标题,使用自定义标题
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// 初始化对话框布局
|
||||
initView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化对话框布局(标题+编辑框+按钮)
|
||||
*/
|
||||
private void initView() {
|
||||
// 根布局:垂直线性布局
|
||||
LinearLayout rootLayout = new LinearLayout(getContext());
|
||||
rootLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
rootLayout.setPadding(20, 20, 20, 20);
|
||||
rootLayout.setLayoutParams(new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
|
||||
// 1. 添加标题栏
|
||||
TextView titleTv = new TextView(getContext());
|
||||
titleTv.setText("拒绝显示字符集编辑");
|
||||
titleTv.setTextSize(18);
|
||||
titleTv.setTextColor(Color.BLACK);
|
||||
titleTv.setGravity(Gravity.CENTER);
|
||||
titleTv.setPadding(0, 0, 0, 20); // 标题与编辑框间距
|
||||
rootLayout.addView(titleTv);
|
||||
|
||||
// 2. 添加多行编辑框(300dp×300dp)
|
||||
mEditText = new EditText(getContext());
|
||||
// 转换dp为px(适配不同屏幕密度)
|
||||
int dp300 = dp2px(getContext(), 300);
|
||||
LinearLayout.LayoutParams editParams = new LinearLayout.LayoutParams(dp300, dp300);
|
||||
mEditText.setLayoutParams(editParams);
|
||||
mEditText.setLines(5); // 多行显示
|
||||
mEditText.setHint("请输入内容");
|
||||
mEditText.setText(mPreText); // 设置预制文本
|
||||
mEditText.setSelection(mPreText.length()); // 光标定位到文本末尾
|
||||
rootLayout.addView(mEditText);
|
||||
|
||||
// 3. 添加按钮栏(水平布局,确定在右、取消在左)
|
||||
LinearLayout btnLayout = new LinearLayout(getContext());
|
||||
btnLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
btnLayout.setGravity(Gravity.RIGHT); // 整体右对齐,实现确定在右、取消在左
|
||||
btnLayout.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
btnLayout.setPadding(0, 20, 0, 0); // 按钮栏与编辑框间距
|
||||
rootLayout.addView(btnLayout);
|
||||
|
||||
// 3.1 取消按钮(左侧)
|
||||
TextView cancelBtn = new TextView(getContext());
|
||||
cancelBtn.setText("取消");
|
||||
cancelBtn.setTextSize(16);
|
||||
cancelBtn.setTextColor(Color.parseColor("#666666"));
|
||||
cancelBtn.setPadding(20, 10, 20, 10);
|
||||
cancelBtn.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dismiss();
|
||||
}
|
||||
}); // 关闭对话框
|
||||
btnLayout.addView(cancelBtn);
|
||||
|
||||
// 3.2 确定按钮(右侧)
|
||||
TextView confirmBtn = new TextView(getContext());
|
||||
confirmBtn.setText("确定");
|
||||
confirmBtn.setTextSize(16);
|
||||
confirmBtn.setTextColor(Color.parseColor("#0066CC"));
|
||||
confirmBtn.setPadding(20, 10, 20, 10);
|
||||
confirmBtn.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (mListener != null) {
|
||||
// 回传编辑后的文本
|
||||
mListener.onTextConfirmed(mEditText.getText().toString().trim());
|
||||
}
|
||||
dismiss(); // 关闭对话框
|
||||
}
|
||||
});
|
||||
btnLayout.addView(confirmBtn);
|
||||
|
||||
// 设置对话框内容布局
|
||||
setContentView(rootLayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* dp转px工具方法
|
||||
* @param context 上下文
|
||||
* @param dpValue dp值
|
||||
* @return 对应的px值
|
||||
*/
|
||||
private int dp2px(Context context, float dpValue) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package cc.winboll.studio.mymessagemanager.dialogs;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen<zhangsken@qq.com>
|
||||
* @Date 2024/05/30 09:53:26
|
||||
* @Describe 用户确定与否选择框
|
||||
*/
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
public class YesNoAlertDialog {
|
||||
|
||||
public static final String TAG = "YesNoAlertDialog";
|
||||
|
||||
public static void show(Context context, String szTitle, String szMessage, final OnDialogResultListener listener) {
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
|
||||
context);
|
||||
|
||||
// set title
|
||||
alertDialogBuilder.setTitle(szTitle);
|
||||
|
||||
// set dialog message
|
||||
alertDialogBuilder
|
||||
.setMessage(szMessage)
|
||||
.setCancelable(true)
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener(){
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
listener.onNo();
|
||||
}
|
||||
})
|
||||
.setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// if this button is clicked, close
|
||||
// current activity
|
||||
listener.onYes();
|
||||
}
|
||||
})
|
||||
.setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
// if this button is clicked, just close
|
||||
// the dialog box and do nothing
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
// create alert dialog
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
// show it
|
||||
alertDialog.show();
|
||||
}
|
||||
|
||||
public interface OnDialogResultListener {
|
||||
abstract void onYes();
|
||||
abstract void onNo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package cc.winboll.studio.mymessagemanager.enums;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import androidx.annotation.StyleRes;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/12/09 14:15
|
||||
* @Describe 主题风格枚举类 - 含SharedPreferences存取方法(主题持久化)
|
||||
*/
|
||||
public enum ThemeStyleEnum {
|
||||
// 主题枚举项(与原逻辑完全对应)
|
||||
DEPTH_THEME(R.id.item_depththeme, R.style.MyDepthAESTheme),
|
||||
SKY_THEME(R.id.item_skytheme, R.style.MySkyAESTheme),
|
||||
GOLDEN_THEME(R.id.item_goldentheme, R.style.MyGoldenAESTheme),
|
||||
MEMOR_THEME(R.id.item_memortheme, R.style.MyMemorAESTheme),
|
||||
TAO_THEME(R.id.item_taotheme, R.style.MyTaoAESTheme),
|
||||
DEFAULT_THEME(R.id.item_defaulttheme, R.style.MyAppTheme);
|
||||
|
||||
// ---------------------- 基础字段(原逻辑保留) ----------------------
|
||||
private final int menuId;
|
||||
@StyleRes
|
||||
private final int styleId;
|
||||
|
||||
ThemeStyleEnum(int menuId, @StyleRes int styleId) {
|
||||
this.menuId = menuId;
|
||||
this.styleId = styleId;
|
||||
}
|
||||
|
||||
public int getMenuId() {
|
||||
return menuId;
|
||||
}
|
||||
|
||||
@StyleRes
|
||||
public int getStyleId() {
|
||||
return styleId;
|
||||
}
|
||||
|
||||
// ---------------------- SharedPreferences 配置(新增) ----------------------
|
||||
// SP文件名:主题配置(建议与枚举类关联,便于查找)
|
||||
private static final String SP_THEME_NAME = "sp_theme_config";
|
||||
// SP存储键:当前选中的主题Style ID
|
||||
private static final String KEY_CURRENT_THEME_STYLE_ID = "current_theme_style_id";
|
||||
|
||||
// ---------------------- 核心方法:保存主题到SP(新增) ----------------------
|
||||
/**
|
||||
* 保存当前选中的主题Style ID到SharedPreferences
|
||||
* @param context 上下文(Activity/Application均可)
|
||||
* @param theme 要保存的主题枚举项(如ThemeStyleEnum.DEFAULT_THEME)
|
||||
*/
|
||||
public static void saveThemeToSP(Context context, ThemeStyleEnum theme) {
|
||||
if (context == null || theme == null) return;
|
||||
// 获取SP实例(私有模式,仅当前App可访问)
|
||||
SharedPreferences sp = context.getSharedPreferences(SP_THEME_NAME, Context.MODE_PRIVATE);
|
||||
// 存入主题对应的Style ID
|
||||
sp.edit().putInt(KEY_CURRENT_THEME_STYLE_ID, theme.getStyleId()).apply();
|
||||
}
|
||||
|
||||
// ---------------------- 核心方法:从SP读取主题(新增) ----------------------
|
||||
/**
|
||||
* 从SharedPreferences读取保存的主题,无存储时返回默认主题
|
||||
* @param context 上下文
|
||||
* @return 保存的主题枚举项(默认返回DEFAULT_THEME)
|
||||
*/
|
||||
public static ThemeStyleEnum getThemeFromSP(Context context) {
|
||||
if (context == null) return DEFAULT_THEME;
|
||||
// 读取SP中保存的Style ID
|
||||
SharedPreferences sp = context.getSharedPreferences(SP_THEME_NAME, Context.MODE_PRIVATE);
|
||||
int savedStyleId = sp.getInt(KEY_CURRENT_THEME_STYLE_ID, DEFAULT_THEME.getStyleId());
|
||||
|
||||
// 根据保存的Style ID匹配对应的枚举项
|
||||
for (ThemeStyleEnum theme : values()) {
|
||||
if (theme.getStyleId() == savedStyleId) {
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
// 无匹配时返回默认主题(防止异常)
|
||||
return DEFAULT_THEME;
|
||||
}
|
||||
|
||||
// ---------------------- 辅助方法:根据菜单ID获取主题(原逻辑保留并优化) ----------------------
|
||||
public static ThemeStyleEnum getThemeByMenuId(int menuId) {
|
||||
for (ThemeStyleEnum theme : values()) {
|
||||
if (theme.getMenuId() == menuId) {
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,14 @@ import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.MainActivity;
|
||||
import cc.winboll.studio.mymessagemanager.beans.MessageNotificationBean;
|
||||
import cc.winboll.studio.mymessagemanager.receivers.SMSRecevier;
|
||||
import cc.winboll.studio.mymessagemanager.services.MainService;
|
||||
import cc.winboll.studio.mymessagemanager.utils.AppConfigUtil;
|
||||
import cc.winboll.studio.mymessagemanager.utils.NotificationHelper;
|
||||
import cc.winboll.studio.mymessagemanager.utils.ServiceUtil;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class MainService extends Service {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.BaseActivity;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.WinBoLLActivity;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
@@ -184,7 +184,7 @@ public class PermissionUtil {
|
||||
// current activity
|
||||
//MainActivity.this.finish();
|
||||
AppGoToSettingsUtil appGoToSettingsUtil = new AppGoToSettingsUtil();
|
||||
appGoToSettingsUtil.GoToSetting((BaseActivity)context);
|
||||
appGoToSettingsUtil.GoToSetting((WinBoLLActivity)context);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.ContactsContract;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libapputils.utils.RegexPPiUtils;
|
||||
import cc.winboll.studio.mymessagemanager.beans.PhoneBean;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package cc.winboll.studio.mymessagemanager.utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/12/09 11:10
|
||||
* @Describe .* 前置预防针
|
||||
* regex pointer preventive injection
|
||||
* 简称 RegexPPi
|
||||
*/
|
||||
public class RegexPPiUtils {
|
||||
|
||||
public static final String TAG = "RegexPPiUtils";
|
||||
|
||||
//
|
||||
// 检验文本是否满足适合正则表达式模式计算
|
||||
//
|
||||
public static boolean isPPiOK(String text) {
|
||||
//String text = "这里是一些任意的文本内容";
|
||||
String regex = ".*";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
/*if (matcher.matches()) {
|
||||
System.out.println("文本满足该正则表达式模式");
|
||||
} else {
|
||||
System.out.println("文本不满足该正则表达式模式");
|
||||
}*/
|
||||
return matcher.matches();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ package cc.winboll.studio.mymessagemanager.utils;
|
||||
import android.content.Context;
|
||||
import android.util.JsonReader;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libapputils.utils.RegexPPiUtils;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSAcceptRuleBean_V1;
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -18,8 +18,8 @@ import android.provider.Telephony;
|
||||
import android.telephony.gsm.SmsManager;
|
||||
import android.telephony.gsm.SmsMessage;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.mymessagemanager.beans.SMSBean;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SMSUtil {
|
||||
|
||||
@@ -10,14 +10,15 @@ import android.content.Intent;
|
||||
import android.os.Message;
|
||||
import android.util.JsonReader;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.mymessagemanager.R;
|
||||
import cc.winboll.studio.mymessagemanager.activitys.TTSPlayRuleActivity;
|
||||
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean;
|
||||
import cc.winboll.studio.mymessagemanager.beans.TTSPlayRuleBean_V1;
|
||||
import cc.winboll.studio.mymessagemanager.beans.TTSSpeakTextBean;
|
||||
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.mymessagemanager.services.TTSPlayService;
|
||||
import cc.winboll.studio.mymessagemanager.utils.FileUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -8,8 +8,8 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Switch;
|
||||
import cc.winboll.studio.libaes.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.mymessagemanager.dialogs.YesNoAlertDialog;
|
||||
|
||||
public class ConfirmSwitchView extends Switch {
|
||||
|
||||
|
||||
@@ -62,12 +62,11 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="拒绝显示的字符集:"/>
|
||||
|
||||
<EditText
|
||||
android:layout_width="0dp"
|
||||
android:ems="10"
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/activityappsettingsEditText3"/>
|
||||
android:text="点击编辑"
|
||||
android:onClick="onCharsetRefuseEditDialog"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -213,12 +212,12 @@
|
||||
android:text="检查应用权限"
|
||||
android:onClick="onCheckAndGetAppPermission"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="清理通知设置"
|
||||
android:onClick="onCleanOldChannels"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="安装TTS语音支持"
|
||||
android:onClick="onAddTTSSupport"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -227,6 +226,22 @@
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:padding="10dp"
|
||||
android:background="#FFFFFFFF">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="》"
|
||||
android:rotation="90"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
@@ -250,5 +265,12 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libaes.views.ADsControlView
|
||||
android:id="@+id/ads_control_view"
|
||||
android:background="@drawable/bg_frame"
|
||||
android:padding="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/activitymainASupportToolbar1"/>
|
||||
|
||||
<LinearLayout
|
||||
@@ -52,25 +51,37 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.baoyz.widget.PullRefreshLayout
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1.0"
|
||||
android:id="@+id/activitymainPullRefreshLayout1">
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<ScrollView
|
||||
<com.baoyz.widget.PullRefreshLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/activitymainScrollView1">
|
||||
android:id="@+id/activitymainPullRefreshLayout1">
|
||||
|
||||
<cc.winboll.studio.mymessagemanager.views.PhoneListViewForScrollView
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/activitymainListView1"/>
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/activitymainScrollView1">
|
||||
|
||||
</ScrollView>
|
||||
<cc.winboll.studio.mymessagemanager.views.PhoneListViewForScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/activitymainListView1"/>
|
||||
|
||||
</com.baoyz.widget.PullRefreshLayout>
|
||||
</ScrollView>
|
||||
|
||||
</com.baoyz.widget.PullRefreshLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libaes.views.ADsBannerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/adsbanner"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme"
|
||||
android:id="@+id/remoteviewLinearLayout1">
|
||||
|
||||
<ImageView
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/item_settings"
|
||||
android:title="Settings"/>
|
||||
|
||||
<item android:title="APP Debug">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/app_unittest"
|
||||
android:title="@string/app_unittest"/>
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
</menu>
|
||||
@@ -1,19 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item android:title="@string/app_developoptions">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/app_log"
|
||||
android:title="@string/app_log"/>
|
||||
<item
|
||||
android:id="@+id/app_unittest"
|
||||
android:title="@string/app_unittest"/>
|
||||
<item
|
||||
android:id="@+id/app_crashtest"
|
||||
android:title="@string/app_crashtest"/>
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/app_appsettings"
|
||||
android:title="@string/text_appsettings"/>
|
||||
47
mymessagemanager/src/main/res/values/styles.xml
Normal file
47
mymessagemanager/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="MyAppTheme" parent="AESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColor</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColor</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColor</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="MyDepthAESTheme" parent="DepthAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorDepth</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorDepth</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorDepth</item>
|
||||
</style>
|
||||
|
||||
<style name="MySkyAESTheme" parent="SkyAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorSky</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorSky</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorSky</item>
|
||||
</style>
|
||||
|
||||
<style name="MyGoldenAESTheme" parent="GoldenAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorGolden</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorGolden</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorGolden</item>
|
||||
</style>
|
||||
|
||||
<style name="MyMemorAESTheme" parent="MemorAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorMemor</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorMemor</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorMemor</item>
|
||||
</style>
|
||||
|
||||
<style name="MyTaoAESTheme" parent="TaoAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorTao</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorTao</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorTao</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -1,90 +0,0 @@
|
||||
<resources>
|
||||
|
||||
<style name="MyAppTheme" parent="AESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColor</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColor</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColor</item>
|
||||
</style>
|
||||
|
||||
<style name="MyDepthAESTheme" parent="DepthAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorDepth</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorDepth</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorDepth</item>
|
||||
</style>
|
||||
|
||||
<style name="MySkyAESTheme" parent="SkyAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorSky</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorSky</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorSky</item>
|
||||
</style>
|
||||
|
||||
<style name="MyGoldenAESTheme" parent="GoldenAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorGolden</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorGolden</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorGolden</item>
|
||||
</style>
|
||||
|
||||
<style name="MyMemorAESTheme" parent="MemorAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorMemor</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorMemor</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorMemor</item>
|
||||
</style>
|
||||
|
||||
<style name="MyTaoAESTheme" parent="TaoAESTheme">
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorTao</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorTao</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorTao</item>
|
||||
</style>
|
||||
|
||||
<!--<style name="AppTheme_Base" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="colorPrimary">#FFC4C4C4</item>
|
||||
<item name="colorPrimaryDark">#FF9F9F9F</item>
|
||||
<item name="colorAccent">#FF888888</item>
|
||||
</style>
|
||||
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="colorPrimary">#FFC4C4C4</item>
|
||||
<item name="colorPrimaryDark">#FF9F9F9F</item>
|
||||
<item name="colorAccent">#FF888888</item>
|
||||
</style>
|
||||
<style name="AppTheme_Default" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="aToolbar">@style/DefaultAToolbar</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColor</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColor</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColor</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme_Sky" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimarySky</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDarkSky</item>
|
||||
<item name="colorAccent">@color/colorAccentSky</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="aToolbar">@style/SKyAToolbar</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorSky</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorSky</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorSky</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme_Golden" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimaryGolden</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDarkGolden</item>
|
||||
<item name="colorAccent">@color/colorAccentGolden</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
<item name="aToolbar">@style/GoldenAToolbar</item>
|
||||
<item name="attrSMSViewSendColor">@color/colorSMSSendColorGolden</item>
|
||||
<item name="attrSMSViewInboxColor">@color/colorSMSInboxColorGolden</item>
|
||||
<item name="attrTTSRuleViewBackgroundColor">@color/colorTTSRuleViewBackgroundColorGolden</item>
|
||||
</style>
|
||||
-->
|
||||
|
||||
|
||||
</resources>
|
||||
@@ -32,28 +32,21 @@ android {
|
||||
// versionName 更新后需要手动设置
|
||||
// .winboll/winbollBuildProps.properties 文件的 stageCount=0
|
||||
// Gradle编译环境下合起来的 versionName 就是 "${versionName}.0"
|
||||
versionName "15.12"
|
||||
versionName "15.11"
|
||||
if(true) {
|
||||
versionName = genVersionName("${versionName}")
|
||||
}
|
||||
}
|
||||
|
||||
// 米盟 SDK
|
||||
packagingOptions {
|
||||
doNotStrip "*/*/libmimo_1011.so"
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// 米盟
|
||||
api 'com.miui.zeus:mimo-ad-sdk:5.3.+'//请使用最新版sdk
|
||||
//注意:以下5个库必须要引入
|
||||
//api 'androidx.appcompat:appcompat:1.4.1'
|
||||
api 'androidx.recyclerview:recyclerview:1.0.0'
|
||||
api 'com.google.code.gson:gson:2.8.5'
|
||||
api 'com.github.bumptech.glide:glide:4.9.0'
|
||||
//annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
|
||||
|
||||
// https://mvnrepository.com/artifact/com.jzxiang.pickerview/TimePickerDialog
|
||||
api 'com.jzxiang.pickerview:TimePickerDialog:1.0.1'
|
||||
|
||||
@@ -79,14 +72,7 @@ dependencies {
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
|
||||
|
||||
// WinBoLL库 nexus.winboll.cc 地址
|
||||
//api 'cc.winboll.studio:libaes:15.12.0'
|
||||
//api 'cc.winboll.studio:libappbase:15.12.2'
|
||||
|
||||
// WinBoLL备用库 jitpack.io 地址
|
||||
api 'com.github.ZhanGSKen:AES:aes-v15.12.3'
|
||||
api 'com.github.ZhanGSKen:APPBase:appbase-v15.12.2'
|
||||
|
||||
api 'cc.winboll.studio:libaes:15.11.0'
|
||||
api 'cc.winboll.studio:libappbase:15.11.0'
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sun Dec 07 23:58:27 HKT 2025
|
||||
#Sat Nov 15 08:45:48 GMT 2025
|
||||
stageCount=2
|
||||
libraryProject=
|
||||
baseVersion=15.12
|
||||
publishVersion=15.12.1
|
||||
buildCount=0
|
||||
baseBetaVersion=15.12.2
|
||||
baseVersion=15.11
|
||||
publishVersion=15.11.1
|
||||
buildCount=21
|
||||
baseBetaVersion=15.11.2
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="cc.winboll.studio.positions">
|
||||
|
||||
<!-- 只能在前台获取精确的位置信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
|
||||
<!-- 只有在前台运行时才能获取大致位置信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
|
||||
@@ -27,9 +30,6 @@
|
||||
<!-- 修改或删除您共享存储空间中的内容 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
|
||||
<!-- 只能在前台获取精确的位置信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.location.gps"
|
||||
android:required="false"/>
|
||||
@@ -65,6 +65,8 @@
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name=".activities.CrashActivity"/>
|
||||
|
||||
<activity-alias
|
||||
android:name=".MainActivityWukong"
|
||||
android:targetActivity=".MainActivity"
|
||||
@@ -109,9 +111,15 @@
|
||||
|
||||
</activity-alias>
|
||||
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.positions.activities.LocationActivity"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.positions.activities.ShortcutActionActivity"/>
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version"/>
|
||||
|
||||
<service
|
||||
android:name=".services.MainService"
|
||||
@@ -135,14 +143,6 @@
|
||||
|
||||
</receiver>
|
||||
|
||||
<meta-data
|
||||
android:name="android.max_aspect"
|
||||
android:value="4.0"/>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version"/>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
@@ -151,11 +151,11 @@
|
||||
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_provider"/>
|
||||
android:resource="@xml/file_paths"/>
|
||||
|
||||
</provider>
|
||||
|
||||
<activity android:name="cc.winboll.studio.positions.activities.SettingsActivity"/>
|
||||
<activity android:name="cc.winboll.studio.positions.activities.ShortcutActionActivity"/>
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
@@ -25,6 +24,7 @@ import android.widget.Toast;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.utils.MyActivityLifecycleCallbacks;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
@@ -44,24 +44,36 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
public static volatile AppLevel _mAppLevel = AppLevel.WUKONG;
|
||||
|
||||
public static final String COMPONENT_WUKONG = "cc.winboll.studio.positions.MainActivityWukong";
|
||||
public static final String COMPONENT_LAOJUN = "cc.winboll.studio.positions.MainActivityLaojun";
|
||||
public static final String ACTION_OPEN_APPPLUS = "cc.winboll.studio.positions.App.ACTION_OPEN_APPPLUS";
|
||||
public static final String ACTION_CLOSE_APPPLUS = "cc.winboll.studio.positions.App.ACTION_CLOSE_APPPLUS";
|
||||
|
||||
private static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
|
||||
|
||||
MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
setIsDebugging(BuildConfig.DEBUG);
|
||||
|
||||
|
||||
WinBoLLActivityManager.init(this);
|
||||
|
||||
|
||||
// 初始化 Toast 框架
|
||||
ToastUtils.init(this);
|
||||
// 设置 Toast 布局样式
|
||||
//ToastUtils.setView(R.layout.view_toast);
|
||||
//ToastUtils.setStyle(new WhiteToastStyle());
|
||||
//ToastUtils.setGravity(Gravity.BOTTOM, 0, 200);
|
||||
|
||||
|
||||
//CrashHandler.getInstance().registerGlobal(this);
|
||||
//CrashHandler.getInstance().registerPart(this);
|
||||
mMyActivityLifecycleCallbacks = new MyActivityLifecycleCallbacks();
|
||||
registerActivityLifecycleCallbacks(mMyActivityLifecycleCallbacks);
|
||||
}
|
||||
|
||||
public static void write(InputStream input, OutputStream output) throws IOException {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package cc.winboll.studio.positions;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/10 07:23
|
||||
* @Describe 应用级别类型枚举
|
||||
*/
|
||||
public enum AppLevel {
|
||||
WUKONG("wukong", "悟空级别"),
|
||||
LAOJUN("laojun", "老君级别");
|
||||
|
||||
public static final String TAG = "AppLevel";
|
||||
|
||||
// 枚举属性
|
||||
private final String code; // 编码(如 "wukong")
|
||||
private final String desc; // 描述
|
||||
|
||||
// 构造方法(Java 7 需显式定义)
|
||||
AppLevel(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
// Getter 方法(获取枚举属性)
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
// 可选:根据 code 获取枚举项(便于业务使用)
|
||||
public static AppLevel getByCode(String code) {
|
||||
for (AppLevel level : values()) {
|
||||
if (level.code.equals(code)) {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
return null; // 或抛出异常,根据业务需求调整
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,7 @@ import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
@@ -17,15 +16,14 @@ import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.utils.DevelopUtils;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libaes.views.ADsBannerView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.activities.LocationActivity;
|
||||
import cc.winboll.studio.positions.activities.SettingsActivity;
|
||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
||||
import cc.winboll.studio.positions.utils.APPPlusUtils;
|
||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
||||
import cc.winboll.studio.positions.utils.JsonShareHandler;
|
||||
import cc.winboll.studio.positions.utils.ServiceUtil;
|
||||
|
||||
/**
|
||||
@@ -36,7 +34,8 @@ import cc.winboll.studio.positions.utils.ServiceUtil;
|
||||
*/
|
||||
public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
public static final String TAG = "MainActivity";
|
||||
// 权限请求码(建议定义为类常量,避免魔法值)
|
||||
|
||||
// 权限请求码(建议定义为类常量,避免魔法值)
|
||||
private static final int REQUEST_LOCATION_PERMISSIONS = 1001;
|
||||
private static final int REQUEST_BACKGROUND_LOCATION_PERMISSION = 1002;
|
||||
|
||||
@@ -46,8 +45,7 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
private Toolbar mToolbar;
|
||||
// 服务相关:服务实例、绑定状态标记
|
||||
//private DistanceRefreshService mDistanceService;
|
||||
private boolean isServiceBound = false;
|
||||
ADsBannerView mADsBannerView;
|
||||
//private boolean isServiceBound = false;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -89,6 +87,10 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main); // 关联主页面布局
|
||||
|
||||
// 处理启动时的分享 Intent
|
||||
handleShareIntent(getIntent());
|
||||
|
||||
|
||||
// 1. 初始化顶部 Toolbar(保留原逻辑,设置页面标题)
|
||||
initToolbar();
|
||||
// 2. 初始化其他控件
|
||||
@@ -99,18 +101,36 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
}
|
||||
// 4. 绑定服务(仅用于获取服务实时状态,不影响服务独立运行)
|
||||
//bindDistanceService();
|
||||
|
||||
mADsBannerView = findViewById(R.id.adsbanner);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
// 处理后续接收的分享 Intent(如应用已在后台)
|
||||
handleShareIntent(intent);
|
||||
}
|
||||
|
||||
private void handleShareIntent(Intent intent) {
|
||||
if (intent != null && Intent.ACTION_SEND.equals(intent.getAction())) {
|
||||
// 调用工具类,弹出确认对话框
|
||||
JsonShareHandler.handleSharedJsonWithConfirm(this, intent, new JsonShareHandler.ConfirmCallback() {
|
||||
@Override
|
||||
public void onConfirm(boolean isConfirm) {
|
||||
// 回调处理:isConfirm 为 true 表示接收并保存,false 表示取消
|
||||
if (!isConfirm) {
|
||||
Log.d("MainActivity", "用户取消接收文件");
|
||||
// 可添加取消后的逻辑(如关闭页面)
|
||||
// finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mADsBannerView != null) {
|
||||
mADsBannerView.releaseAdResources();
|
||||
}
|
||||
|
||||
// 页面销毁时解绑服务,避免Activity与服务相互引用导致内存泄漏
|
||||
// if (isServiceBound) {
|
||||
// unbindService(mServiceConn);
|
||||
@@ -119,16 +139,6 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mADsBannerView != null) {
|
||||
mADsBannerView.resumeADs(MainActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------- 核心功能1:初始化UI组件(Toolbar + 服务开关) ----------------------
|
||||
/**
|
||||
* 初始化顶部 Toolbar,设置页面标题
|
||||
@@ -137,9 +147,9 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
mToolbar = (Toolbar) findViewById(R.id.toolbar); // Java 7 显式 findViewById + 强转
|
||||
setSupportActionBar(mToolbar);
|
||||
// 给ActionBar设置标题(先判断非空,避免空指针异常)
|
||||
if (getSupportActionBar() != null) {
|
||||
getSupportActionBar().setTitle(getString(R.string.app_name));
|
||||
}
|
||||
AppLevel appLevel = AppConfigsUtil.getInstance(getApplicationContext()).getAppLevel(true);
|
||||
getSupportActionBar().setTitle(getString(R.string.app_name));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,39 +188,6 @@ public class MainActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// 主题菜单
|
||||
AESThemeUtil.inflateMenu(this, menu);
|
||||
// 调试工具菜单
|
||||
if (App.isDebugging()) {
|
||||
DevelopUtils.inflateMenu(this, menu);
|
||||
}
|
||||
// 应用其他菜单
|
||||
getMenuInflater().inflate(R.menu.toolbar_main, menu);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
int menuItemId = item.getItemId();
|
||||
if (AESThemeUtil.onAppThemeItemSelected(this, item)) {
|
||||
recreate();
|
||||
} if (DevelopUtils.onDevelopItemSelected(this, item)) {
|
||||
LogUtils.d(TAG, String.format("onOptionsItemSelected item.getItemId() %d ", item.getItemId()));
|
||||
} else if (item.getItemId() == R.id.item_settings) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
// 在switch语句中处理每个ID,并在处理完后返回true,未处理的情况返回false。
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绑定服务(仅用于获取服务状态,不启动服务)
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cc.winboll.studio.positions;
|
||||
import android.os.Bundle;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/13 15:21
|
||||
* @Describe MainActivityLaojun
|
||||
*/
|
||||
public class MainActivityLaojun extends MainActivity {
|
||||
|
||||
public static final String TAG = "MainActivityLaojun";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
ToastUtils.show("道法自然");
|
||||
LogUtils.d(TAG, "玩法归臻");
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cc.winboll.studio.positions;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/15 15:14
|
||||
* @Describe 应用入口级别类型枚举
|
||||
*/
|
||||
public enum PointLevel {
|
||||
DORAEMON("doraemon", "叮铛级别"),
|
||||
WUKONG("wukong", "悟空级别"),
|
||||
LAOJUN("laojun", "老君级别");
|
||||
|
||||
public static final String TAG = "PointLevel";
|
||||
|
||||
// 枚举属性
|
||||
private final String code; // 编码(如 "wukong")
|
||||
private final String desc; // 描述
|
||||
|
||||
// 构造方法(Java 7 需显式定义)
|
||||
PointLevel(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
// Getter 方法(获取枚举属性)
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
// 可选:根据 code 获取枚举项(便于业务使用)
|
||||
public static PointLevel getByCode(String code) {
|
||||
for (PointLevel level : values()) {
|
||||
if (level.code.equals(code)) {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
return null; // 或抛出异常,根据业务需求调整
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,8 @@ import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.R;
|
||||
@@ -35,14 +33,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* 2. Adapter 初始化传入 MainService 实例,确保数据来源唯一
|
||||
* 3. 所有位置/任务操作通过 MainService 接口执行
|
||||
*/
|
||||
public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
public class LocationActivity extends Activity {
|
||||
public static final String TAG = "LocationActivity";
|
||||
|
||||
private Toolbar mToolbar;
|
||||
|
||||
private RecyclerView mRvPosition;
|
||||
private PositionAdapter mPositionAdapter;
|
||||
|
||||
|
||||
// MainService 引用+绑定状态(AtomicBoolean 确保多线程状态可见性)
|
||||
private MainService mMainService;
|
||||
private final AtomicBoolean isServiceBound = new AtomicBoolean(false);
|
||||
@@ -100,34 +96,11 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_location);
|
||||
|
||||
mToolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(mToolbar);
|
||||
mToolbar.setSubtitle(getTag());
|
||||
mToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "【导航栏】点击返回");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
// 1. 初始化视图(优先执行,避免Adapter初始化时视图为空)
|
||||
initView();
|
||||
// 2. 初始化GPS监听(提前创建,避免绑定服务后空指针)
|
||||
@@ -194,7 +167,7 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
||||
}
|
||||
}
|
||||
LogUtils.d(TAG, "数据同步完成:服务位置数=" + (servicePosList == null ? 0 : servicePosList.size())
|
||||
+ ",本地缓存数=" + mLocalPosCache.size());
|
||||
+ ",本地缓存数=" + mLocalPosCache.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, "同步服务数据失败:" + e.getMessage());
|
||||
@@ -210,9 +183,9 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
||||
// 1. 多重安全校验(避免销毁后初始化/重复初始化/依赖未就绪)
|
||||
if (isAdapterInited.get() || !isServiceBound.get() || mMainService == null || mRvPosition == null) {
|
||||
LogUtils.w(TAG, "Adapter初始化跳过:"
|
||||
+ "已初始化=" + isAdapterInited.get()
|
||||
+ ",服务绑定=" + isServiceBound.get()
|
||||
+ ",视图就绪=" + (mRvPosition != null));
|
||||
+ "已初始化=" + isAdapterInited.get()
|
||||
+ ",服务绑定=" + isServiceBound.get()
|
||||
+ ",视图就绪=" + (mRvPosition != null));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -222,54 +195,54 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
||||
|
||||
// 3. 设置删除回调(删除时同步服务+本地缓存+Adapter)
|
||||
mPositionAdapter.setOnDeleteClickListener(new PositionAdapter.OnDeleteClickListener() {
|
||||
@Override
|
||||
public void onDeleteClick(int position) {
|
||||
// 安全校验(索引有效+服务绑定+缓存非空)
|
||||
if (position < 0 || position >= mLocalPosCache.size() || !isServiceBound.get() || mMainService == null) {
|
||||
LogUtils.w(TAG, "删除位置失败:索引无效/服务未就绪(索引=" + position + ",缓存量=" + mLocalPosCache.size() + ")");
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onDeleteClick(int position) {
|
||||
// 安全校验(索引有效+服务绑定+缓存非空)
|
||||
if (position < 0 || position >= mLocalPosCache.size() || !isServiceBound.get() || mMainService == null) {
|
||||
LogUtils.w(TAG, "删除位置失败:索引无效/服务未就绪(索引=" + position + ",缓存量=" + mLocalPosCache.size() + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
PositionModel deletePos = mLocalPosCache.get(position);
|
||||
if (deletePos != null && !deletePos.getPositionId().isEmpty()) {
|
||||
// 步骤1:调用服务删除(确保服务数据一致性)
|
||||
mMainService.removePosition(deletePos.getPositionId());
|
||||
// 步骤2:删除本地缓存(确保缓存与服务同步)
|
||||
synchronized (mLocalPosCache) {
|
||||
mLocalPosCache.remove(position);
|
||||
}
|
||||
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
||||
mPositionAdapter.notifyItemRemoved(position);
|
||||
showToast("删除位置成功:" + deletePos.getMemo());
|
||||
LogUtils.d(TAG, "删除位置完成:ID=" + deletePos.getPositionId() + "(服务+缓存已同步)");
|
||||
}
|
||||
}
|
||||
});
|
||||
PositionModel deletePos = mLocalPosCache.get(position);
|
||||
if (deletePos != null && !deletePos.getPositionId().isEmpty()) {
|
||||
// 步骤1:调用服务删除(确保服务数据一致性)
|
||||
mMainService.removePosition(deletePos.getPositionId());
|
||||
// 步骤2:删除本地缓存(确保缓存与服务同步)
|
||||
synchronized (mLocalPosCache) {
|
||||
mLocalPosCache.remove(position);
|
||||
}
|
||||
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
||||
mPositionAdapter.notifyItemRemoved(position);
|
||||
showToast("删除位置成功:" + deletePos.getMemo());
|
||||
LogUtils.d(TAG, "删除位置完成:ID=" + deletePos.getPositionId() + "(服务+缓存已同步)");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 4. 设置保存回调(保存时同步服务+本地缓存+Adapter)
|
||||
mPositionAdapter.setOnSavePositionClickListener(new PositionAdapter.OnSavePositionClickListener() {
|
||||
@Override
|
||||
public void onSavePositionClick(int position, PositionModel updatedPos) {
|
||||
// 安全校验(索引有效+服务绑定+数据非空)
|
||||
if (!isServiceBound.get() || mMainService == null
|
||||
|| position < 0 || position >= mLocalPosCache.size() || updatedPos == null) {
|
||||
LogUtils.w(TAG, "保存位置失败:服务未就绪/索引无效/数据空");
|
||||
showToast("服务未就绪,保存失败");
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
public void onSavePositionClick(int position, PositionModel updatedPos) {
|
||||
// 安全校验(索引有效+服务绑定+数据非空)
|
||||
if (!isServiceBound.get() || mMainService == null
|
||||
|| position < 0 || position >= mLocalPosCache.size() || updatedPos == null) {
|
||||
LogUtils.w(TAG, "保存位置失败:服务未就绪/索引无效/数据空");
|
||||
showToast("服务未就绪,保存失败");
|
||||
return;
|
||||
}
|
||||
|
||||
// 步骤1:调用服务更新(确保服务数据一致性)
|
||||
mMainService.updatePosition(updatedPos);
|
||||
// 步骤2:更新本地缓存(确保缓存与服务同步)
|
||||
synchronized (mLocalPosCache) {
|
||||
mLocalPosCache.set(position, updatedPos);
|
||||
}
|
||||
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
||||
mPositionAdapter.notifyItemChanged(position);
|
||||
showToast("保存位置成功:" + updatedPos.getMemo());
|
||||
LogUtils.d(TAG, "保存位置完成:ID=" + updatedPos.getPositionId() + "(服务+缓存已同步)");
|
||||
}
|
||||
});
|
||||
// 步骤1:调用服务更新(确保服务数据一致性)
|
||||
mMainService.updatePosition(updatedPos);
|
||||
// 步骤2:更新本地缓存(确保缓存与服务同步)
|
||||
synchronized (mLocalPosCache) {
|
||||
mLocalPosCache.set(position, updatedPos);
|
||||
}
|
||||
// 步骤3:通知Adapter刷新(基于缓存操作,避免空数据)
|
||||
mPositionAdapter.notifyItemChanged(position);
|
||||
showToast("保存位置成功:" + updatedPos.getMemo());
|
||||
LogUtils.d(TAG, "保存位置完成:ID=" + updatedPos.getPositionId() + "(服务+缓存已同步)");
|
||||
}
|
||||
});
|
||||
|
||||
// 5. 设置Adapter到RecyclerView(最后一步,确保Adapter已配置完成)
|
||||
mRvPosition.setAdapter(mPositionAdapter);
|
||||
@@ -295,7 +268,7 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
||||
}
|
||||
Toast.makeText(this, content, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
|
||||
// ---------------------- 页面交互(新增位置逻辑保留,适配GPS数据) ----------------------
|
||||
/**
|
||||
* 新增位置(调用服务addPosition(),可选:用当前GPS位置初始化新位置)
|
||||
@@ -422,7 +395,9 @@ public class LocationActivity extends WinBoLLActivity implements IWinBoLLActivit
|
||||
LogUtils.d(TAG, "onResume:服务已绑定但Adapter未初始化,重新同步数据");
|
||||
syncDataFromMainService();
|
||||
initPositionAdapter();
|
||||
} else if (isServiceBound.get() && mMainService != null && isAdapterInited.get() && mPositionAdapter != null) {
|
||||
}
|
||||
// 2. 服务已绑定且Adapter已初始化:刷新数据(确保与服务同步)
|
||||
else if (isServiceBound.get() && mMainService != null && isAdapterInited.get() && mPositionAdapter != null) {
|
||||
syncDataFromMainService();
|
||||
mPositionAdapter.notifyDataSetChanged();
|
||||
LogUtils.d(TAG, "onResume:刷新位置数据(与服务同步)");
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package cc.winboll.studio.positions.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.R;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/12/07 23:29
|
||||
* @Describe 应用设置活动窗口
|
||||
*/
|
||||
public class SettingsActivity extends WinBoLLActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "SettingsActivity";
|
||||
|
||||
private Toolbar mToolbar;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_settings);
|
||||
|
||||
mToolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(mToolbar);
|
||||
mToolbar.setSubtitle(getTag());
|
||||
mToolbar.setTitleTextAppearance(this, R.style.Toolbar_TitleText);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
LogUtils.d(TAG, "【导航栏】点击返回");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cc.winboll.studio.positions.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.utils.APPPlusUtils;
|
||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
||||
import cc.winboll.studio.positions.AppLevel;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/15 13:45
|
||||
* @Describe 应用快捷方式活动类
|
||||
*/
|
||||
public class ShortcutActionActivity extends Activity {
|
||||
|
||||
public static final String TAG = "ShortcutActionActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 处理应用级别的切换请求
|
||||
handleSwitchRequest();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @Override
|
||||
// public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
|
||||
// super.onPostCreate(savedInstanceState, persistentState);
|
||||
// finish();
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// protected void onStart() {
|
||||
// super.onStart();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 处理应用图标快捷菜单的请求
|
||||
*/
|
||||
private void handleSwitchRequest() {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null && "open_appplus".equals(intent.getDataString())) {
|
||||
ToastUtils.show("已添加" + getString(R.string.app_name) + "附加组件");
|
||||
AppConfigsUtil.getInstance(getApplicationContext()).setAppLevel(AppLevel.LAOJUN);
|
||||
APPPlusUtils.openAPPPlus(this);
|
||||
//moveTaskToBack(true);
|
||||
}
|
||||
if (intent != null && "close_appplus".equals(intent.getDataString())) {
|
||||
ToastUtils.show("已移除" + getString(R.string.app_name) + "附加组件");
|
||||
AppConfigsUtil.getInstance(getApplicationContext()).setAppLevel(AppLevel.WUKONG);
|
||||
APPPlusUtils.closeAPPPlus(this);
|
||||
//moveTaskToBack(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,20 @@ import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.libaes.interfaces.IWinBoLLActivity;
|
||||
import cc.winboll.studio.libaes.models.AESThemeBean;
|
||||
import cc.winboll.studio.libaes.utils.AESThemeUtil;
|
||||
import cc.winboll.studio.libaes.utils.WinBoLLActivityManager;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.App;
|
||||
import cc.winboll.studio.positions.PointLevel;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.utils.ActivityAliasUtils;
|
||||
import cc.winboll.studio.positions.utils.AppConfigsUtil;
|
||||
|
||||
public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivity {
|
||||
|
||||
public static final String TAG = "WinBoLLActivity";
|
||||
|
||||
protected volatile AESThemeBean.ThemeType mThemeType;
|
||||
public static volatile PointLevel _mPointLevel = PointLevel.WUKONG;
|
||||
|
||||
@Override
|
||||
public Activity getActivity() {
|
||||
@@ -31,25 +35,58 @@ public class WinBoLLActivity extends AppCompatActivity implements IWinBoLLActivi
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mThemeType = getThemeType();
|
||||
setThemeStyle();
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
AESThemeBean.ThemeType getThemeType() {
|
||||
return AESThemeBean.getThemeStyleType(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
}
|
||||
|
||||
void setThemeStyle() {
|
||||
setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
//ToastUtils.show("onResume");
|
||||
|
||||
// ActivityAliasUtils 工具使用示例
|
||||
//
|
||||
// // 获取真实的目标组件名(即使通过 alias 启动,也能拿到 OriginalActivity)
|
||||
// String realTargetName = ActivityAliasUtils.getRealTargetNameFromIntent(this);
|
||||
// LogUtils.d("AliasActivity", "真实组件名:" + realTargetName);
|
||||
// 获取真实的目标组件名(即使通过 alias 启动,也能拿到 OriginalActivity)
|
||||
// String realTargetName = ActivityAliasUtils.getRealTargetNameFromIntent(this);
|
||||
// LogUtils.d(TAG, "真实组件名:" + realTargetName);
|
||||
// ToastUtils.show(realTargetName);
|
||||
// // 判断某个组件是否为 alias
|
||||
// String componentName = "com.winboll.app.AliasActivity";
|
||||
// boolean isAlias = ActivityAliasUtils.isActivityAlias(getApplicationContext(), componentName);
|
||||
// LogUtils.d("判断结果", componentName + " 是否为 alias:" + isAlias); // true
|
||||
// // 获取启动当前 Activity 的组件名(兼容 alias 场景)
|
||||
// String launchComponent = ActivityAliasUtils.getLaunchComponentName(this);
|
||||
// LogUtils.d("MainActivity", "启动组件名:" + launchComponent);
|
||||
|
||||
/*
|
||||
* 应用入口逻辑模块
|
||||
*/
|
||||
//
|
||||
// 检查当前活动的启动组件名,设置应用入口级别。
|
||||
String launchComponent = ActivityAliasUtils.getLaunchComponentName(this);
|
||||
LogUtils.d("MainActivity", "启动组件名:" + launchComponent);
|
||||
ToastUtils.show(launchComponent);
|
||||
// 当前应用处于活动暂停的状态时,就检查应用的入口组件名称,设置应用入口级别。
|
||||
if (WinBoLLActivity._mPointLevel == PointLevel.DORAEMON) {
|
||||
if (launchComponent.equals(App.COMPONENT_WUKONG)) {
|
||||
getSupportActionBar().setTitle(getString(R.string.appplus_name));
|
||||
ToastUtils.show("WUKONG");
|
||||
_mPointLevel = PointLevel.WUKONG;
|
||||
} else if (launchComponent.equals(App.COMPONENT_LAOJUN)) {
|
||||
getSupportActionBar().setTitle(getString(R.string.app_name));
|
||||
ToastUtils.show("LAOJUN");
|
||||
_mPointLevel = PointLevel.LAOJUN;
|
||||
} else {
|
||||
// 如果是其他应用组件入口,就关闭活动
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 应用级别设置模块
|
||||
*/
|
||||
// 读取并配置应用级别
|
||||
App._mAppLevel = AppConfigsUtil.getInstance(getApplicationContext()).getAppLevel(true);
|
||||
|
||||
LogUtils.d(TAG, String.format("onResume %s", getTag()));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,14 @@ package cc.winboll.studio.positions.models;
|
||||
import android.util.JsonWriter;
|
||||
import android.util.JsonReader;
|
||||
import java.io.IOException;
|
||||
import cc.winboll.studio.positions.AppLevel;
|
||||
|
||||
public class AppConfigsModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "AppConfigsModel";
|
||||
|
||||
boolean isEnableMainService;
|
||||
AppLevel appLevel;
|
||||
|
||||
public AppConfigsModel(boolean isEnableMainService) {
|
||||
this.isEnableMainService = isEnableMainService;
|
||||
@@ -24,6 +26,14 @@ public class AppConfigsModel extends BaseBean {
|
||||
this.isEnableMainService = false;
|
||||
}
|
||||
|
||||
public void setAppLevel(AppLevel appLevel) {
|
||||
this.appLevel = appLevel;
|
||||
}
|
||||
|
||||
public AppLevel getAppLevel() {
|
||||
return appLevel;
|
||||
}
|
||||
|
||||
public void setIsEnableMainService(boolean isEnableMainService) {
|
||||
this.isEnableMainService = isEnableMainService;
|
||||
}
|
||||
@@ -42,6 +52,7 @@ public class AppConfigsModel extends BaseBean {
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("isEnableDistanceRefreshService").value(isEnableMainService());
|
||||
jsonWriter.name("appLevel").value(getAppLevel().ordinal());
|
||||
}
|
||||
|
||||
// JSON反序列化(加载位置数据,校验字段)
|
||||
@@ -52,6 +63,8 @@ public class AppConfigsModel extends BaseBean {
|
||||
} else {
|
||||
if (name.equals("isEnableDistanceRefreshService")) {
|
||||
setIsEnableMainService(jsonReader.nextBoolean());
|
||||
} else if (name.equals("appLevel")) {
|
||||
setAppLevel((AppLevel.values()[jsonReader.nextInt()]));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
package cc.winboll.studio.positions.receivers;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/10/28 19:07
|
||||
* @Describe MotionStatusReceiver
|
||||
*/
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
import cc.winboll.studio.positions.utils.ServiceUtil;
|
||||
|
||||
/**
|
||||
* 运动状态监听Receiver
|
||||
* 功能:1.持续监听传感器(不关闭) 2.每5秒计算运动状态 3.按状态切换GPS模式(实时/30秒定时)
|
||||
*/
|
||||
public class MotionStatusReceiver extends BroadcastReceiver implements SensorEventListener {
|
||||
public static final String TAG = "MotionStatusReceiver";
|
||||
|
||||
// 广播Action
|
||||
public static final String ACTION_MOTION_STATUS_RECEIVER = "cc.winboll.studio.positions.receivers.MotionStatusReceiver";
|
||||
public static final String EXTRA_SENSORS_ENABLE = "EXTRA_SENSORS_ENABLE";
|
||||
// 传感器启动状态标志位
|
||||
boolean mIsSensorsEnable = false;
|
||||
// 运动状态常量
|
||||
private static final int MOTION_STATUS_STATIC = 0; // 静止/低运动
|
||||
private static final int MOTION_STATUS_WALKING = 1; // 行走/高速运动
|
||||
// 配置参数(按需求调整)
|
||||
private static final float ACCELEROMETER_THRESHOLD = 0.8f; // 加速度阈值
|
||||
private static final float GYROSCOPE_THRESHOLD = 0.5f; // 陀螺仪阈值
|
||||
private static final long STATUS_CALC_INTERVAL = 5000; // 运动状态计算间隔(5秒)
|
||||
private static final long GPS_STATIC_INTERVAL = 30; // 静止时GPS间隔(30秒)
|
||||
// 核心对象
|
||||
private volatile SensorManager mSensorManager;
|
||||
private Sensor mAccelerometer;
|
||||
private Sensor mGyroscope;
|
||||
private volatile boolean mIsSensorListening = false; // 传感器是否持续监听
|
||||
private int mCurrentMotionStatus = MOTION_STATUS_STATIC; // 当前运动状态
|
||||
private Handler mMainHandler; // 主线程Handler(用于定时计算)
|
||||
private Context mBroadcastContext; // 广播上下文
|
||||
// 传感器数据缓存(用于5秒内数据汇总,避免单次波动误判)
|
||||
private float mAccelMax = 0f; // 5秒内加速度最大值
|
||||
private float mGyroMax = 0f; // 5秒内陀螺仪最大值
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
LogUtils.d(TAG, "===== 接收器启动:onReceive() 开始执行 =====");
|
||||
this.mBroadcastContext = context;
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
if (TextUtils.equals(intent.getAction(), ACTION_MOTION_STATUS_RECEIVER)) {
|
||||
boolean isSettingEnable = intent.getBooleanExtra(EXTRA_SENSORS_ENABLE, false);
|
||||
if (mIsSensorsEnable == false && isSettingEnable == true) {
|
||||
mIsSensorsEnable = true;
|
||||
// 1. 初始化传感器(必执行)
|
||||
initSensors();
|
||||
|
||||
|
||||
if (mAccelerometer == null || mGyroscope == null) {
|
||||
LogUtils.e(TAG, "设备缺少加速度/陀螺仪,无法持续监听");
|
||||
cleanResources(false); // 传感器不可用才清理
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 校验参数
|
||||
if (context == null || intent == null) {
|
||||
LogUtils.d(TAG, "onReceive():无效参数,终止处理");
|
||||
cleanResources(false);
|
||||
return;
|
||||
}
|
||||
LogUtils.d(TAG, "onReceive():接收到广播Action=" + intent.getAction());
|
||||
|
||||
// 3. 启动持续传感器监听(核心:不关闭,重复调用无影响)
|
||||
startSensorListening();
|
||||
|
||||
// 4. 启动5秒定时计算运动状态(核心:持续触发状态判断)
|
||||
startStatusCalcTimer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 5. 处理外部广播触发(可选,保留外部控制能力)
|
||||
// if (TextUtils.equals(intent.getAction(), ACTION_MOTION_STATUS_RECEIVER)) {
|
||||
// int motionStatus = intent.getIntExtra(EXTRA_MOTION_STATUS, MOTION_STATUS_STATIC);
|
||||
// String statusDesc = motionStatus == MOTION_STATUS_WALKING ? "高速运动" : "静止/低运动";
|
||||
// LogUtils.d(TAG, "外部广播触发,强制设置运动状态:" + statusDesc);
|
||||
// mCurrentMotionStatus = motionStatus;
|
||||
// handleMotionStatus(mCurrentMotionStatus); // 立即执行GPS切换
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化传感器(持续监听,复用实例)
|
||||
*/
|
||||
private void initSensors() {
|
||||
LogUtils.d(TAG, "initSensors():初始化传感器");
|
||||
if (mSensorManager != null || mBroadcastContext == null) return;
|
||||
|
||||
mSensorManager = (SensorManager) mBroadcastContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
if (mSensorManager == null) {
|
||||
LogUtils.e(TAG, "设备不支持传感器服务");
|
||||
return;
|
||||
}
|
||||
// 获取传感器实例(持续复用,不销毁)
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
mGyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
|
||||
|
||||
LogUtils.d(TAG, "传感器初始化结果:加速度=" + (mAccelerometer != null) + ",陀螺仪=" + (mGyroscope != null));
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动传感器持续监听(核心:不关闭,注册一次一直生效)
|
||||
*/
|
||||
private void startSensorListening() {
|
||||
if (mSensorManager == null || mAccelerometer == null || mGyroscope == null) return;
|
||||
|
||||
if (!mIsSensorListening) {
|
||||
// 注册传感器监听(持续生效,直到服务销毁才注销)
|
||||
mSensorManager.registerListener(
|
||||
this,
|
||||
mAccelerometer,
|
||||
SensorManager.SENSOR_DELAY_NORMAL, // 正常延迟,平衡性能与精度
|
||||
mMainHandler
|
||||
);
|
||||
mSensorManager.registerListener(
|
||||
this,
|
||||
mGyroscope,
|
||||
SensorManager.SENSOR_DELAY_NORMAL,
|
||||
mMainHandler
|
||||
);
|
||||
mIsSensorListening = true;
|
||||
LogUtils.d(TAG, "startSensorListening():传感器持续监听已启动(不关闭)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动5秒定时计算运动状态(核心:周期性汇总传感器数据)
|
||||
*/
|
||||
private void startStatusCalcTimer() {
|
||||
if (mMainHandler == null) return;
|
||||
|
||||
// 移除旧任务(避免重复注册)
|
||||
mMainHandler.removeCallbacks(mStatusCalcRunnable);
|
||||
// 启动定时任务(每5秒执行一次)
|
||||
mMainHandler.postDelayed(mStatusCalcRunnable, STATUS_CALC_INTERVAL);
|
||||
LogUtils.d(TAG, "startStatusCalcTimer():5秒运动状态计算定时器已启动");
|
||||
}
|
||||
|
||||
/**
|
||||
* 运动状态计算任务(5秒执行一次)
|
||||
*/
|
||||
private final Runnable mStatusCalcRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 1. 基于5秒内缓存的最大传感器数据判断状态
|
||||
boolean isHighMotion = (mAccelMax > ACCELEROMETER_THRESHOLD) && (mGyroMax > GYROSCOPE_THRESHOLD);
|
||||
int newMotionStatus = isHighMotion ? MOTION_STATUS_WALKING : MOTION_STATUS_STATIC;
|
||||
|
||||
// 2. 状态变化时才处理(避免频繁切换GPS)
|
||||
if (newMotionStatus != mCurrentMotionStatus) {
|
||||
mCurrentMotionStatus = newMotionStatus;
|
||||
String statusDesc = isHighMotion ? "高速运动" : "静止/低运动";
|
||||
LogUtils.d(TAG, "运动状态更新(5秒计算):" + statusDesc
|
||||
+ "(加速度最大值=" + mAccelMax + ",陀螺仪最大值=" + mGyroMax + ")");
|
||||
handleMotionStatus(newMotionStatus); // 切换GPS模式
|
||||
} else {
|
||||
LogUtils.d(TAG, "运动状态无变化(5秒计算):" + (isHighMotion ? "高速运动" : "静止/低运动"));
|
||||
}
|
||||
|
||||
// 3. 重置传感器数据缓存,准备下一个5秒周期
|
||||
mAccelMax = 0f;
|
||||
mGyroMax = 0f;
|
||||
|
||||
// 4. 循环执行定时任务(核心:持续计算)
|
||||
mMainHandler.postDelayed(this, STATUS_CALC_INTERVAL);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 传感器数据变化回调(核心:实时缓存最大数据)
|
||||
*/
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
if (event == null) return;
|
||||
|
||||
// 实时缓存5秒内的最大传感器数据(避免单次波动误判)
|
||||
switch (event.sensor.getType()) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
float accelTotal = Math.abs(event.values[0]) + Math.abs(event.values[1]) + Math.abs(event.values[2]);
|
||||
if (accelTotal > mAccelMax) mAccelMax = accelTotal; // 缓存最大值
|
||||
LogUtils.d(TAG, "加速度传感器实时数据:合值=" + accelTotal + "(当前5秒最大值=" + mAccelMax + ")");
|
||||
break;
|
||||
case Sensor.TYPE_GYROSCOPE:
|
||||
float gyroTotal = Math.abs(event.values[0]) + Math.abs(event.values[1]) + Math.abs(event.values[2]);
|
||||
if (gyroTotal > mGyroMax) mGyroMax = gyroTotal; // 缓存最大值
|
||||
LogUtils.d(TAG, "陀螺仪实时数据:合值=" + gyroTotal + "(当前5秒最大值=" + mGyroMax + ")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理运动状态(核心:按状态切换GPS模式)
|
||||
*/
|
||||
private void handleMotionStatus(int motionStatus) {
|
||||
LogUtils.d(TAG, "handleMotionStatus():开始处理运动状态,切换GPS模式");
|
||||
if (mBroadcastContext == null) {
|
||||
LogUtils.w(TAG, "上下文为空,无法处理GPS");
|
||||
return;
|
||||
}
|
||||
|
||||
MainService mainService = getMainService();
|
||||
if (mainService == null) {
|
||||
LogUtils.e(TAG, "MainService未启动,GPS控制失败");
|
||||
return;
|
||||
}
|
||||
|
||||
if (motionStatus == MOTION_STATUS_WALKING) {
|
||||
// 高速运动:启动GPS实时更新(2秒/1米)
|
||||
handleHighMotionGPS(mainService);
|
||||
} else {
|
||||
// 静止/低运动:启动GPS30秒定时更新
|
||||
handleStaticGPS(mainService);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 高速运动GPS处理:实时更新
|
||||
*/
|
||||
private void handleHighMotionGPS(MainService mainService) {
|
||||
// 动态权限判断(Android 6.0+)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||
mBroadcastContext.checkSelfPermission(android.Manifest.permission.ACCESS_FINE_LOCATION)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
sendPermissionRequestBroadcast();
|
||||
return;
|
||||
}
|
||||
|
||||
// 启动实时GPS(已启动则不重复操作)
|
||||
if (!mainService.isGpsListening()) {
|
||||
mainService.startGpsLocation(); // 实时更新(2秒/1米)
|
||||
mainService.stopGpsStaticTimer(); // 停止定时GPS
|
||||
LogUtils.d(TAG, "高速运动:已启动GPS实时更新");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 静止/低运动GPS处理:30秒定时更新
|
||||
*/
|
||||
private void handleStaticGPS(MainService mainService) {
|
||||
// 停止实时GPS(已停止则不重复操作)
|
||||
if (mainService.isGpsListening()) {
|
||||
mainService.stopGpsLocation(); // 停止实时更新
|
||||
LogUtils.d(TAG, "静止/低运动:已停止GPS实时更新");
|
||||
}
|
||||
|
||||
// 启动30秒定时GPS(已启动则不重复操作)
|
||||
mainService.startGpsStaticTimer(GPS_STATIC_INTERVAL); // 30秒一次
|
||||
LogUtils.d(TAG, "静止/低运动:已启动GPS30秒定时更新");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MainService实例(复用逻辑)
|
||||
*/
|
||||
private MainService getMainService() {
|
||||
if (mBroadcastContext == null) return null;
|
||||
|
||||
// 优先获取单例
|
||||
MainService singleton = MainService.getInstance(mBroadcastContext);
|
||||
if (singleton != null && singleton.isServiceRunning()) {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
// 启动服务并重试
|
||||
if (!ServiceUtil.isServiceAlive(mBroadcastContext, MainService.class.getName())) {
|
||||
mBroadcastContext.startService(new Intent(mBroadcastContext, MainService.class));
|
||||
try {
|
||||
Thread.sleep(500); // 等待服务启动
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
return MainService.getInstance(mBroadcastContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送GPS权限申请广播(Receiver无法直接申请)
|
||||
*/
|
||||
private void sendPermissionRequestBroadcast() {
|
||||
Intent permissionIntent = new Intent("cc.winboll.studio.positions.ACTION_REQUEST_GPS_PERMISSION");
|
||||
permissionIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
mBroadcastContext.sendBroadcast(permissionIntent);
|
||||
LogUtils.d(TAG, "GPS权限缺失,已发送申请广播");
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源清理(核心:传感器不关闭,仅清理Handler和上下文)
|
||||
* @param isForceStopSensor 是否强制停止传感器(仅服务销毁时传true)
|
||||
*/
|
||||
private void cleanResources(boolean isForceStopSensor) {
|
||||
// 1. 停止定时计算任务
|
||||
if (mMainHandler != null) {
|
||||
mMainHandler.removeCallbacksAndMessages(null);
|
||||
mMainHandler = null;
|
||||
LogUtils.d(TAG, "cleanResources():已停止运动状态计算定时器");
|
||||
}
|
||||
|
||||
// 2. 强制停止传感器(仅当外部触发销毁时执行,正常情况不关闭)
|
||||
if (isForceStopSensor && mSensorManager != null && mIsSensorListening) {
|
||||
mSensorManager.unregisterListener(this);
|
||||
mIsSensorListening = false;
|
||||
LogUtils.d(TAG, "cleanResources():已强制停止传感器监听");
|
||||
}
|
||||
|
||||
// 3. 置空上下文(避免内存泄漏)
|
||||
mBroadcastContext = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 传感器精度变化回调(日志监控)
|
||||
*/
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
String sensorType = sensor.getType() == Sensor.TYPE_ACCELEROMETER ? "加速度" : "陀螺仪";
|
||||
String accuracyDesc = getAccuracyDesc(accuracy);
|
||||
LogUtils.d(TAG, sensorType + "传感器精度变化:" + accuracyDesc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 传感器精度描述转换
|
||||
*/
|
||||
private String getAccuracyDesc(int accuracy) {
|
||||
switch (accuracy) {
|
||||
case SensorManager.SENSOR_STATUS_ACCURACY_HIGH: return "高";
|
||||
case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM: return "中";
|
||||
case SensorManager.SENSOR_STATUS_ACCURACY_LOW: return "低";
|
||||
case SensorManager.SENSOR_STATUS_UNRELIABLE: return "不可靠";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补充:Receiver销毁时强制清理(需在MainService注销时调用)
|
||||
*/
|
||||
public void forceCleanResources() {
|
||||
cleanResources(true); // 强制停止传感器
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/10 09:51
|
||||
* @Describe 应用图标切换工具类(启用组件时创建对应快捷方式)
|
||||
*/
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.widget.Toast;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.positions.App;
|
||||
import cc.winboll.studio.positions.MainActivity;
|
||||
|
||||
public class APPPlusUtils {
|
||||
public static final String TAG = "APPPlusUtils";
|
||||
|
||||
// 快捷方式配置(名称+图标,需与实际资源匹配)
|
||||
// private static final String PLUS_SHORTCUT_NAME = "位置服务-Laojun";
|
||||
// private static final int PLUS_SHORTCUT_ICON = R.mipmap.ic_launcher; // Laojun 图标资源
|
||||
|
||||
/**
|
||||
* 添加Plus组件与图标
|
||||
*/
|
||||
public static boolean openAPPPlus(Context context) {
|
||||
if (context == null) {
|
||||
LogUtils.d(TAG, "切换失败:上下文为空");
|
||||
Toast.makeText(context, "图标切换失败", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ComponentName plusComponentLaojun = new ComponentName(context, App.COMPONENT_LAOJUN);
|
||||
//ComponentName plusComponentWuKong = new ComponentName(context, MainActivity.COMPONENT_WUKONG);
|
||||
|
||||
try {
|
||||
//disableComponent(pm, plusComponentWuKong);
|
||||
enableComponent(pm, plusComponentLaojun);
|
||||
|
||||
// 2. 创建 Laojun 组件对应的快捷方式(自动去重)
|
||||
// boolean shortcutCreated = createComponentShortcut(context, plusComponent, PLUS_SHORTCUT_NAME, PLUS_SHORTCUT_ICON);
|
||||
//
|
||||
// // 3. 通知桌面刷新图标
|
||||
// context.sendBroadcast(new Intent(Intent.ACTION_PACKAGE_CHANGED)
|
||||
// .setData(android.net.Uri.parse("package:" + context.getPackageName())));
|
||||
//
|
||||
// // 4. 反馈结果
|
||||
// String logMsg = shortcutCreated ? "启用 Laojun + 快捷方式创建成功" : "启用 Laojun 成功,快捷方式创建失败";
|
||||
// String toastMsg = shortcutCreated ? "图标切换为 Laojun,已创建快捷方式" : "图标切换为 Laojun,快捷方式创建失败";
|
||||
// LogUtils.d(TAG, logMsg);
|
||||
// Toast.makeText(context, toastMsg, Toast.LENGTH_SHORT).show();
|
||||
//
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "Laojun 图标切换失败:" + e.getMessage());
|
||||
// 失败兜底:启用 Wukong 组件
|
||||
//enableComponent(pm, wukongComponent);
|
||||
Toast.makeText(context, "图标切换失败" + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 移除Plus组件
|
||||
*/
|
||||
public static boolean closeAPPPlus(Context context) {
|
||||
if (context == null) {
|
||||
LogUtils.d(TAG, "切换失败:上下文为空");
|
||||
Toast.makeText(context, "图标切换失败", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ComponentName plusComponentLaojun = new ComponentName(context, App.COMPONENT_LAOJUN);
|
||||
//ComponentName plusComponentWuKong = new ComponentName(context, MainActivity.COMPONENT_WUKONG);
|
||||
|
||||
disableComponent(pm, plusComponentLaojun);
|
||||
//enableComponent(pm, plusComponentWuKong);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建指定组件的桌面快捷方式(自动去重,兼容 Android 8.0+)
|
||||
* @param component 目标组件(如 LAOJUN_ACTIVITY)
|
||||
* @param name 快捷方式名称
|
||||
* @param iconRes 快捷方式图标资源ID
|
||||
* @return 是否创建成功
|
||||
*/
|
||||
private static boolean createComponentShortcut(Context context, ComponentName component, String name, int iconRes) {
|
||||
if (context == null || component == null || name == null || iconRes == 0) {
|
||||
LogUtils.d(TAG, "快捷方式创建失败:参数为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Android 8.0+(API 26+):使用 ShortcutManager(系统推荐)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
android.content.pm.ShortcutManager shortcutManager = context.getSystemService(android.content.pm.ShortcutManager.class);
|
||||
if (shortcutManager == null || !shortcutManager.isRequestPinShortcutSupported()) {
|
||||
LogUtils.d(TAG, "系统不支持创建快捷方式");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否已存在该组件的快捷方式(去重)
|
||||
for (android.content.pm.ShortcutInfo info : shortcutManager.getPinnedShortcuts()) {
|
||||
if (component.getClassName().equals(info.getIntent().getComponent().getClassName())) {
|
||||
LogUtils.d(TAG, "快捷方式已存在:" + component.getClassName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 构建启动目标组件的意图
|
||||
Intent launchIntent = new Intent(Intent.ACTION_MAIN)
|
||||
.setComponent(component)
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
// 构建快捷方式信息
|
||||
android.content.pm.ShortcutInfo shortcutInfo = new android.content.pm.ShortcutInfo.Builder(context, component.getClassName())
|
||||
.setShortLabel(name)
|
||||
.setLongLabel(name)
|
||||
.setIcon(android.graphics.drawable.Icon.createWithResource(context, iconRes))
|
||||
.setIntent(launchIntent)
|
||||
.build();
|
||||
|
||||
// 请求创建快捷方式(需用户确认)
|
||||
shortcutManager.requestPinShortcut(shortcutInfo, null);
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, "Android O+ 快捷方式创建失败:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Android 8.0 以下:使用广播(兼容旧机型)
|
||||
try {
|
||||
// 构建启动目标组件的意图
|
||||
Intent launchIntent = new Intent(Intent.ACTION_MAIN)
|
||||
.setComponent(component)
|
||||
.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
// 构建创建快捷方式的广播意图
|
||||
Intent installIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
|
||||
installIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
|
||||
installIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
|
||||
installIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
|
||||
Intent.ShortcutIconResource.fromContext(context, iconRes));
|
||||
installIntent.putExtra("duplicate", false); // 禁止重复创建
|
||||
|
||||
context.sendBroadcast(installIntent);
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, "Android O- 快捷方式创建失败:" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用组件(带状态检查,避免重复操作)
|
||||
*/
|
||||
private static void enableComponent(PackageManager pm, ComponentName component) {
|
||||
if (pm.getComponentEnabledSetting(component) != PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
|
||||
pm.setComponentEnabledSetting(
|
||||
component,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
||||
PackageManager.DONT_KILL_APP | PackageManager.SYNCHRONOUS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用组件(带状态检查,避免重复操作)
|
||||
*/
|
||||
private static void disableComponent(PackageManager pm, ComponentName component) {
|
||||
if (pm.getComponentEnabledSetting(component) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
||||
pm.setComponentEnabledSetting(
|
||||
component,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
||||
PackageManager.DONT_KILL_APP | PackageManager.SYNCHRONOUS
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.TextUtils;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/15 15:23
|
||||
* @Describe Activity Alias 工具类(兼容 Android 所有版本,Java 7 语法)
|
||||
* 用于获取 activity-alias 对应的原始 Activity 组件名、判断 alias 类型、获取启动组件名等
|
||||
*/
|
||||
public class ActivityAliasUtils {
|
||||
private static final String TAG = "ActivityAliasUtils";
|
||||
|
||||
/**
|
||||
* 获取 activity-alias 指向的原始 Activity 组件名
|
||||
*
|
||||
* @param context 上下文(建议用 ApplicationContext)
|
||||
* @param aliasName activity-alias 的组件名(完整路径,如 ".AliasActivity" 或 "com.winboll.app.AliasActivity")
|
||||
* @return 原始 Activity 的完整组件名(如 "com.winboll.app.OriginalActivity"),失败返回 null
|
||||
*/
|
||||
public static String getTargetActivityName(Context context, String aliasName) {
|
||||
// 校验参数
|
||||
if (context == null || TextUtils.isEmpty(aliasName)) {
|
||||
LogUtils.e(TAG, "getTargetActivityName: context is null or aliasName is empty");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 补全组件名(若传入的是短名,自动拼接包名)
|
||||
String fullAliasName = aliasName.startsWith(".")
|
||||
? context.getPackageName() + aliasName
|
||||
: aliasName;
|
||||
|
||||
try {
|
||||
// 1. 获取 PackageManager
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
|
||||
// 2. 解析 activity-alias 的 ActivityInfo(flag 必须设为 PackageManager.GET_META_DATA,否则可能获取不到 targetActivity)
|
||||
ActivityInfo aliasActivityInfo = packageManager.getActivityInfo(
|
||||
new android.content.ComponentName(context.getPackageName(), fullAliasName),
|
||||
PackageManager.GET_META_DATA
|
||||
);
|
||||
|
||||
// 3. 获取 targetActivity(原始 Activity 组件名)
|
||||
String targetActivity = aliasActivityInfo.targetActivity;
|
||||
if (TextUtils.isEmpty(targetActivity)) {
|
||||
LogUtils.e(TAG, "getTargetActivityName: targetActivity is empty for alias " + fullAliasName);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 4. 补全原始 Activity 的完整包名(若 targetActivity 是短名)
|
||||
String fullTargetName = targetActivity.startsWith(".")
|
||||
? context.getPackageName() + targetActivity
|
||||
: targetActivity;
|
||||
|
||||
LogUtils.d(TAG, "getTargetActivityName: alias=" + fullAliasName + ", target=" + fullTargetName);
|
||||
return fullTargetName;
|
||||
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
LogUtils.e(TAG, "getTargetActivityName: alias not found - " + fullAliasName, e);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "getTargetActivityName: unknown error", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某个组件名是否为 activity-alias(而非原始 Activity)
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param componentName 待判断的组件名(完整路径)
|
||||
* @return true:是 activity-alias;false:不是或判断失败
|
||||
*/
|
||||
public static boolean isActivityAlias(Context context, String componentName) {
|
||||
// 调用 getTargetActivityName,若返回非空,则说明是 alias
|
||||
return !TextUtils.isEmpty(getTargetActivityName(context, componentName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 从启动的 Intent 中获取实际的目标组件名(处理 alias 场景)
|
||||
* 适用于 Activity 中获取自身真实组件名(原始 Activity 名)
|
||||
*
|
||||
* @param context 当前 Activity 上下文
|
||||
* @return 真实的目标组件名(原始 Activity 名,若为 alias 启动则返回原始 Activity,否则返回自身)
|
||||
*/
|
||||
public static String getRealTargetNameFromIntent(Context context) {
|
||||
if (context == null) {
|
||||
LogUtils.e(TAG, "getRealTargetNameFromIntent: context is null");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取当前 Activity 的组件名(可能是 alias)
|
||||
String currentComponentName = context.getClass().getName();
|
||||
// 检查是否为 alias,若是则返回 target,否则返回自身
|
||||
String targetName = getTargetActivityName(context, currentComponentName);
|
||||
return TextUtils.isEmpty(targetName) ? currentComponentName : targetName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前活动上下文(Activity)的启动组件名(即启动时使用的组件名,可能是 alias 或原始 Activity)
|
||||
* 场景:若通过 alias 启动 Activity,返回 alias 名;若直接启动原始 Activity,返回原始 Activity 名
|
||||
*
|
||||
* @param context 当前 Activity 上下文(必须是 Activity 实例,不能是 ApplicationContext)
|
||||
* @return 启动组件的完整名,失败返回 null
|
||||
*/
|
||||
public static String getLaunchComponentName(Context context) {
|
||||
// 1. 校验上下文类型(必须是 Activity,否则无法获取启动 Intent)
|
||||
if (context == null) {
|
||||
LogUtils.e(TAG, "getLaunchComponentName: context is null");
|
||||
return null;
|
||||
}
|
||||
if (!(context instanceof android.app.Activity)) {
|
||||
LogUtils.e(TAG, "getLaunchComponentName: context must be Activity instance, current is " + context.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 2. 获取启动当前 Activity 的 Intent
|
||||
android.app.Activity activity = (android.app.Activity) context;
|
||||
Intent launchIntent = activity.getIntent();
|
||||
if (launchIntent == null) {
|
||||
LogUtils.e(TAG, "getLaunchComponentName: launch Intent is null");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 3. 从 Intent 中获取启动组件名(ComponentName)
|
||||
android.content.ComponentName componentName = launchIntent.getComponent();
|
||||
if (componentName == null) {
|
||||
LogUtils.e(TAG, "getLaunchComponentName: ComponentName is null in launch Intent");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 4. 获取组件的完整类名(即启动时使用的组件名)
|
||||
String launchComponentName = componentName.getClassName();
|
||||
LogUtils.d(TAG, "getLaunchComponentName: current launch component is " + launchComponentName);
|
||||
return launchComponentName;
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "getLaunchComponentName: failed to get launch component name", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.positions.AppLevel;
|
||||
import cc.winboll.studio.positions.models.AppConfigsModel;
|
||||
import cc.winboll.studio.positions.App;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
@@ -58,11 +60,27 @@ public class AppConfigsUtil {
|
||||
}
|
||||
|
||||
public void setIsEnableMainService(boolean isEnableMainService) {
|
||||
if(mAppConfigsModel == null) {
|
||||
if (mAppConfigsModel == null) {
|
||||
mAppConfigsModel = new AppConfigsModel();
|
||||
}
|
||||
mAppConfigsModel.setIsEnableMainService(isEnableMainService);
|
||||
saveConfigs();
|
||||
}
|
||||
|
||||
public AppLevel getAppLevel(boolean isReloadConfigs) {
|
||||
if (isReloadConfigs) {
|
||||
loadConfigs();
|
||||
}
|
||||
return (mAppConfigsModel == null) ?AppLevel.WUKONG: mAppConfigsModel.getAppLevel();
|
||||
}
|
||||
|
||||
public void setAppLevel(AppLevel appLevel) {
|
||||
if (mAppConfigsModel == null) {
|
||||
mAppConfigsModel = new AppConfigsModel();
|
||||
}
|
||||
App._mAppLevel = appLevel;
|
||||
mAppConfigsModel.setAppLevel(appLevel);
|
||||
saveConfigs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,241 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/13 15:42
|
||||
* @Describe JsonShareHandler
|
||||
* 外部 JSON 文件分享处理工具类
|
||||
* 功能:接收外部分享的 .json 文件,弹出确认对话框,保存到外部存储 files/BaseBean 目录
|
||||
*/
|
||||
public class JsonShareHandler {
|
||||
private static final String TAG = "JsonShareHandler";
|
||||
private static final String TARGET_DIR = "BaseBean";
|
||||
private static final String MIME_TYPE_JSON = "application/json";
|
||||
private static final String FILE_SUFFIX_JSON = ".json";
|
||||
// 对话框回调接口(Java7 无 Lambda,用接口实现)
|
||||
public interface ConfirmCallback {
|
||||
void onConfirm(boolean isConfirm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理外部分享的 Intent,先弹出确认对话框,再决定是否接收文件
|
||||
* @param context 上下文(需为 Activity,否则无法弹出对话框)
|
||||
* @param intent 分享 Intent
|
||||
* @param callback 确认结果回调(用于 Activity 处理后续逻辑)
|
||||
*/
|
||||
public static void handleSharedJsonWithConfirm(final Context context, final Intent intent, final ConfirmCallback callback) {
|
||||
if (context == null || intent == null || callback == null) {
|
||||
Log.e(TAG, "参数为空,处理失败");
|
||||
if (callback != null) callback.onConfirm(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 先验证 Intent 合法性(提前过滤无效分享)
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
if (!Intent.ACTION_SEND.equals(action) || type == null) {
|
||||
Log.e(TAG, "非文件分享 Intent");
|
||||
Toast.makeText(context, "不支持的分享类型", Toast.LENGTH_SHORT).show();
|
||||
callback.onConfirm(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 弹出确认对话框
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle("接收 JSON 文件")
|
||||
.setMessage("是否接收并保存该 JSON 文件?")
|
||||
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
// 3. 点击 Yes,处理文件保存
|
||||
String savedPath = handleSharedJsonFile(context, intent);
|
||||
if (savedPath != null) {
|
||||
Toast.makeText(context, "文件保存成功:" + savedPath, Toast.LENGTH_LONG).show();
|
||||
callback.onConfirm(true);
|
||||
} else {
|
||||
Toast.makeText(context, "文件保存失败", Toast.LENGTH_SHORT).show();
|
||||
callback.onConfirm(false);
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
// 4. 点击 No,直接退出处理
|
||||
callback.onConfirm(false);
|
||||
}
|
||||
})
|
||||
.setCancelable(false) // 不可点击外部取消
|
||||
.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 核心文件处理逻辑(原有功能,无修改)
|
||||
*/
|
||||
private static String handleSharedJsonFile(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
|
||||
// 验证 JSON 格式
|
||||
if (!MIME_TYPE_JSON.equals(type) && !type.contains("json")) {
|
||||
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (uri == null || !getFileNameFromUri(context, uri).endsWith(FILE_SUFFIX_JSON)) {
|
||||
Log.e(TAG, "接收的文件不是 JSON 格式");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Uri sharedUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (sharedUri == null) {
|
||||
Log.e(TAG, "未获取到分享的文件 Uri");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 创建保存目录
|
||||
File saveDir = getTargetSaveDir(context);
|
||||
if (!saveDir.exists() && !saveDir.mkdirs()) {
|
||||
Log.e(TAG, "创建保存目录失败:" + saveDir.getAbsolutePath());
|
||||
return null;
|
||||
}
|
||||
|
||||
// 解析文件名(兼容低版本)
|
||||
String fileName = getFileNameFromUri(context, sharedUri);
|
||||
if (fileName == null || !fileName.endsWith(FILE_SUFFIX_JSON)) {
|
||||
fileName = "default_" + System.currentTimeMillis() + FILE_SUFFIX_JSON;
|
||||
Log.w(TAG, "文件名解析失败,使用默认名称:" + fileName);
|
||||
}
|
||||
|
||||
// 复制文件
|
||||
File targetFile = new File(saveDir, fileName);
|
||||
boolean copySuccess = copyFileFromUri(context, sharedUri, targetFile);
|
||||
return copySuccess ? targetFile.getAbsolutePath() : null;
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "处理分享文件异常:" + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目标保存目录(兼容 Android 10+ 分区存储)
|
||||
*/
|
||||
private static File getTargetSaveDir(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
return new File(context.getExternalFilesDir(null), TARGET_DIR);
|
||||
} else {
|
||||
return new File(
|
||||
Environment.getExternalStorageDirectory() + File.separator +
|
||||
"Android" + File.separator +
|
||||
"data" + File.separator +
|
||||
context.getPackageName() + File.separator +
|
||||
"files" + File.separator +
|
||||
TARGET_DIR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 Uri 解析文件名(兼容所有 Android 版本)
|
||||
*/
|
||||
private static String getFileNameFromUri(Context context, Uri uri) {
|
||||
if (uri == null) return null;
|
||||
|
||||
// 1. 文件 Uri(file:// 开头)
|
||||
if ("file".equals(uri.getScheme())) {
|
||||
return new File(uri.getPath()).getName();
|
||||
}
|
||||
|
||||
// 2. 内容 Uri(content:// 开头)
|
||||
if ("content".equals(uri.getScheme())) {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = context.getContentResolver().query(
|
||||
uri,
|
||||
new String[]{MediaStore.MediaColumns.DISPLAY_NAME},
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
int nameIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
|
||||
if (nameIndex != -1) {
|
||||
return cursor.getString(nameIndex);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "解析内容 Uri 文件名失败:" + e.getMessage());
|
||||
} finally {
|
||||
if (cursor != null) cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 解析失败,返回默认名称
|
||||
String lastPathSegment = uri.getLastPathSegment();
|
||||
return lastPathSegment != null ? lastPathSegment : "unknown.json";
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制 Uri 指向的文件到目标路径
|
||||
*/
|
||||
private static boolean copyFileFromUri(Context context, Uri sourceUri, File targetFile) {
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
inputStream = context.getContentResolver().openInputStream(sourceUri);
|
||||
if (inputStream == null) {
|
||||
Log.e(TAG, "无法打开源文件输入流");
|
||||
return false;
|
||||
}
|
||||
|
||||
outputStream = new FileOutputStream(targetFile);
|
||||
byte[] buffer = new byte[1024 * 4];
|
||||
int length;
|
||||
while ((length = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, length);
|
||||
}
|
||||
outputStream.flush();
|
||||
Log.d(TAG, "文件保存成功:" + targetFile.getAbsolutePath());
|
||||
return true;
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "文件复制异常:" + e.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
try {
|
||||
if (inputStream != null) inputStream.close();
|
||||
if (outputStream != null) outputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "关闭流异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查外部存储是否可用
|
||||
*/
|
||||
public static boolean isExternalStorageAvailable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
return Environment.MEDIA_MOUNTED.equals(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/05 15:49
|
||||
* @Describe LocalMotionDetector
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
/**
|
||||
* 本机运动状态监测工具(无联网,纯传感器)
|
||||
*/
|
||||
public class LocalMotionDetector implements SensorEventListener {
|
||||
public static final String TAG = "LocalMotionDetector";
|
||||
|
||||
// 配置参数(重点修改:调高运动阈值,适配坐立持机场景)
|
||||
private static final float MOTION_THRESHOLD = 1.8f; // 从0.5f调高到1.8f(过滤坐立轻微晃动)
|
||||
private static final long STATUS_CHECK_INTERVAL = 3000; // 3秒判断一次状态
|
||||
private static final int STEP_CHANGE_THRESHOLD = 2; // 3秒≥2步判定行走
|
||||
|
||||
private SensorManager mSensorManager;
|
||||
private Sensor mAccelerometer;
|
||||
private Sensor mStepCounter;
|
||||
private Handler mMainHandler;
|
||||
private MotionStatusCallback mCallback;
|
||||
|
||||
private boolean mIsDetecting = false;
|
||||
private float mLastAccelMagnitude = 0f;
|
||||
private int mLastStepCount = 0;
|
||||
private int mCurrentStepCount = 0;
|
||||
private boolean mIsWalking = false;
|
||||
|
||||
// 单例模式
|
||||
private static LocalMotionDetector sInstance;
|
||||
public static LocalMotionDetector getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (LocalMotionDetector.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new LocalMotionDetector();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private LocalMotionDetector() {
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始监测运动状态
|
||||
*/
|
||||
public void startDetection(Context context, MotionStatusCallback callback) {
|
||||
if (mIsDetecting) return;
|
||||
mCallback = callback;
|
||||
mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
// 初始化传感器
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
mStepCounter = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
|
||||
|
||||
// 注册传感器监听
|
||||
if (mAccelerometer != null) {
|
||||
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL, mMainHandler);
|
||||
}
|
||||
if (mStepCounter != null) {
|
||||
mSensorManager.registerListener(this, mStepCounter, SensorManager.SENSOR_DELAY_NORMAL, mMainHandler);
|
||||
LogUtils.d(TAG, "计步传感器已启动");
|
||||
} else {
|
||||
LogUtils.d(TAG, "设备不支持计步传感器,仅用加速度判断");
|
||||
}
|
||||
|
||||
// 启动定时状态检测
|
||||
mMainHandler.postDelayed(mStatusCheckRunnable, STATUS_CHECK_INTERVAL);
|
||||
mIsDetecting = true;
|
||||
LogUtils.d(TAG, "运动状态监测已启动");
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止监测
|
||||
*/
|
||||
public void stopDetection() {
|
||||
if (!mIsDetecting) return;
|
||||
if (mSensorManager != null) {
|
||||
mSensorManager.unregisterListener(this);
|
||||
}
|
||||
mMainHandler.removeCallbacksAndMessages(null);
|
||||
mIsDetecting = false;
|
||||
mIsWalking = false;
|
||||
mCallback = null;
|
||||
LogUtils.d(TAG, "运动状态监测已停止");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
if (!mIsDetecting) return;
|
||||
switch (event.sensor.getType()) {
|
||||
case Sensor.TYPE_ACCELEROMETER:
|
||||
// 计算加速度幅度(保留原逻辑,阈值已调高)
|
||||
float accelX = Math.abs(event.values[0]);
|
||||
float accelY = Math.abs(event.values[1]);
|
||||
float accelZ = Math.abs(event.values[2]);
|
||||
mLastAccelMagnitude = accelX + accelY + accelZ;
|
||||
break;
|
||||
case Sensor.TYPE_STEP_COUNTER:
|
||||
// 累计步数
|
||||
mCurrentStepCount = (int) event.values[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时判断运动状态(优化逻辑:计步为0时,即使有轻微加速度也判定为静止)
|
||||
*/
|
||||
private final Runnable mStatusCheckRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!mIsDetecting || mCallback == null) return;
|
||||
|
||||
//LogUtils.d(TAG, "mStatusCheckRunnable run");
|
||||
|
||||
boolean newIsWalking = false;
|
||||
// 结合计步器+加速度判断(优化:优先计步,无步数时严格按高阈值判断)
|
||||
if (mStepCounter != null) {
|
||||
int stepChange = mCurrentStepCount - mLastStepCount;
|
||||
// 只有“步数达标” 或 “无步数但加速度远超坐立幅度”,才判定为行走
|
||||
newIsWalking = (stepChange >= STEP_CHANGE_THRESHOLD)
|
||||
&& (mLastAccelMagnitude >= MOTION_THRESHOLD); // 增加步数+加速度双重校验
|
||||
mLastStepCount = mCurrentStepCount;
|
||||
} else {
|
||||
// 无计步器时,仅用高阈值判断
|
||||
newIsWalking = mLastAccelMagnitude >= MOTION_THRESHOLD;
|
||||
}
|
||||
|
||||
// 状态变化时回调
|
||||
if (newIsWalking != mIsWalking) {
|
||||
mIsWalking = newIsWalking;
|
||||
String statusDesc = mIsWalking ? "行走状态" : "静止/低运动状态";
|
||||
LogUtils.d(TAG, "运动状态变化:" + statusDesc + " | 加速度幅度:" + mLastAccelMagnitude); // 增加日志便于调试
|
||||
mCallback.onMotionStatusChanged(mIsWalking, statusDesc);
|
||||
}
|
||||
|
||||
LogUtils.d(TAG, String.format("运动状态 newIsWalking %s", newIsWalking));
|
||||
|
||||
// 循环检测
|
||||
mMainHandler.postDelayed(this, STATUS_CHECK_INTERVAL);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {}
|
||||
|
||||
/**
|
||||
* 运动状态回调接口
|
||||
*/
|
||||
public interface MotionStatusCallback {
|
||||
void onMotionStatusChanged(boolean isWalking, String statusDesc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.ToastUtils;
|
||||
import cc.winboll.studio.positions.PointLevel;
|
||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/15 15:59
|
||||
* @Describe 应用活动窗口状态响应类
|
||||
* 主要用于设置应用级别与组件状态
|
||||
*/
|
||||
public class MyActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
|
||||
|
||||
public static final String TAG = "MyActivityLifecycleCallbacks";
|
||||
|
||||
public String mInfo = "";
|
||||
|
||||
public MyActivityLifecycleCallbacks() {
|
||||
|
||||
}
|
||||
|
||||
void createActivityeInfo(Activity activity) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Intent receivedIntent = activity.getIntent();
|
||||
sb.append("\nCallingActivity : \n");
|
||||
if (activity.getCallingActivity() != null) {
|
||||
sb.append(activity.getCallingActivity().getPackageName());
|
||||
}
|
||||
sb.append("\nReceived Intent Package : \n");
|
||||
sb.append(receivedIntent.getPackage());
|
||||
|
||||
Bundle extras = receivedIntent.getExtras();
|
||||
if (extras != null) {
|
||||
for (String key : extras.keySet()) {
|
||||
sb.append("\nIntentInfo");
|
||||
sb.append("\n键: ");
|
||||
sb.append(key);
|
||||
sb.append(", 值: ");
|
||||
sb.append(extras.get(key));
|
||||
//Log.d("IntentInfo", "键: " + key + ", 值: " + extras.get(key));
|
||||
}
|
||||
}
|
||||
mInfo = sb.toString();
|
||||
//Log.d("IntentInfo", "发送Intent的应用包名: " + senderPackage);
|
||||
}
|
||||
|
||||
public void showActivityeInfo() {
|
||||
//ToastUtils.show("ActivityeInfo : " + mInfo);
|
||||
LogUtils.d(TAG, "ActivityeInfo : " + mInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
// 在这里可以做一些初始化相关的操作,例如记录Activity的创建时间等
|
||||
//System.out.println(activity.getLocalClassName() + " was created");
|
||||
LogUtils.d(TAG, activity.getLocalClassName() + " was created");
|
||||
createActivityeInfo(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(Activity activity) {
|
||||
//System.out.println(activity.getLocalClassName() + " was started");
|
||||
LogUtils.d(TAG, activity.getLocalClassName() + " was started");
|
||||
//createActivityeInfo(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
//System.out.println(activity.getLocalClassName() + " was resumed");
|
||||
LogUtils.d(TAG, activity.getLocalClassName() + " was resumed");
|
||||
//createActivityeInfo(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
ToastUtils.show("Activity Paused");
|
||||
// 应用从正在活动状态抽离出来时,设置应用入口级别状态,设置为时空虚幻而不确定的哆啦A梦级别。
|
||||
WinBoLLActivity._mPointLevel = PointLevel.DORAEMON;
|
||||
//System.out.println(activity.getLocalClassName() + " was paused");
|
||||
LogUtils.d(TAG, activity.getLocalClassName() + " was paused");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(Activity activity) {
|
||||
//System.out.println(activity.getLocalClassName() + " was stopped");
|
||||
LogUtils.d(TAG, activity.getLocalClassName() + " was stopped");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
// 可以在这里添加保存状态的自定义逻辑
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
//System.out.println(activity.getLocalClassName() + " was destroyed");
|
||||
LogUtils.d(TAG, activity.getLocalClassName() + " was destroyed");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
package cc.winboll.studio.positions.views;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||
* @Date 2025/11/10 08:29
|
||||
* @Describe 沙漏计时器控件
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ClipDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.text.InputFilter;
|
||||
import android.text.InputType;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* 沙漏视图类(Java 7语法,修复ProgressDrawable和setHeight问题)
|
||||
*/
|
||||
public class HourglassView extends LinearLayout {
|
||||
public static final String TAG = "HourglassView";
|
||||
// 数据模型
|
||||
private String hourglassId;
|
||||
private int hour; // 小时
|
||||
private int minute; // 分钟
|
||||
private boolean isEnabled; // 开关状态
|
||||
|
||||
// 控件引用
|
||||
private EditText etHour;
|
||||
private EditText etMinute;
|
||||
private ProgressBar progressBar;
|
||||
private Switch switchControl;
|
||||
|
||||
// 样式参数
|
||||
private int textSize = 16;
|
||||
private int padding = 8;
|
||||
private int progressColor = 0xFF2196F3; // 进度条颜色
|
||||
private int progressBgColor = 0xFFE0E0E0; // 进度条背景色
|
||||
private int textColor = 0xFF333333;
|
||||
private int editTextWidth = 40; // 输入框宽度(dp)
|
||||
private int progressHeight = 8; // 进度条高度(dp,新增参数)
|
||||
|
||||
public HourglassView(Context context) {
|
||||
super(context);
|
||||
initView();
|
||||
}
|
||||
|
||||
public HourglassView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化视图布局
|
||||
*/
|
||||
private void initView() {
|
||||
setOrientation(HORIZONTAL);
|
||||
setGravity(Gravity.CENTER_VERTICAL);
|
||||
setPadding(dp2px(padding), dp2px(padding), dp2px(padding), dp2px(padding));
|
||||
|
||||
// 1. 左侧时间输入区域(水平布局)
|
||||
LinearLayout inputLayout = new LinearLayout(getContext());
|
||||
inputLayout.setOrientation(HORIZONTAL);
|
||||
inputLayout.setGravity(Gravity.CENTER_VERTICAL);
|
||||
LayoutParams inputParams = new LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
inputParams.setMargins(0, 0, dp2px(padding * 2), 0);
|
||||
addView(inputLayout, inputParams);
|
||||
|
||||
// 小时输入框
|
||||
etHour = createNumberEditText();
|
||||
etHour.setHint("时");
|
||||
etHour.setFilters(new InputFilter[]{new InputFilter.LengthFilter(2)});
|
||||
inputLayout.addView(etHour, getEditTextParams());
|
||||
|
||||
// 分隔符
|
||||
TextView divider = new TextView(getContext());
|
||||
divider.setText(":");
|
||||
divider.setTextSize(textSize);
|
||||
divider.setTextColor(textColor);
|
||||
LayoutParams dividerParams = new LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
dividerParams.setMargins(dp2px(padding / 2), 0, dp2px(padding / 2), 0);
|
||||
inputLayout.addView(divider, dividerParams);
|
||||
|
||||
// 分钟输入框
|
||||
etMinute = createNumberEditText();
|
||||
etMinute.setHint("分");
|
||||
etMinute.setFilters(new InputFilter[]{new InputFilter.LengthFilter(2)});
|
||||
inputLayout.addView(etMinute, getEditTextParams());
|
||||
|
||||
// 2. 中间进度条(修复:通过LayoutParams设置高度,替代setHeight)
|
||||
progressBar = new ProgressBar(getContext(), null, android.R.attr.progressBarStyleHorizontal);
|
||||
progressBar.setProgressDrawable(createProgressDrawable()); // 传入Drawable类型
|
||||
|
||||
// 修复核心:用LayoutParams设置进度条高度(兼容低版本)
|
||||
LayoutParams progressParams = new LayoutParams(
|
||||
0,
|
||||
dp2px(progressHeight), // 直接在布局参数中设置高度(dp转px)
|
||||
1.0f
|
||||
);
|
||||
progressParams.setMargins(0, 0, dp2px(padding * 2), 0);
|
||||
addView(progressBar, progressParams);
|
||||
|
||||
// 3. 右侧开关
|
||||
switchControl = new Switch(getContext());
|
||||
switchControl.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(android.widget.CompoundButton buttonView, boolean isChecked) {
|
||||
isEnabled = isChecked;
|
||||
// 开关状态控制输入框是否可编辑
|
||||
etHour.setEnabled(!isChecked);
|
||||
etMinute.setEnabled(!isChecked);
|
||||
// 更新进度条(仅在开关开启时生效)
|
||||
if (isChecked) {
|
||||
updateProgressBar();
|
||||
}
|
||||
}
|
||||
});
|
||||
addView(switchControl);
|
||||
|
||||
// 初始状态
|
||||
isEnabled = false;
|
||||
etHour.setEnabled(true);
|
||||
etMinute.setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建数字输入框
|
||||
*/
|
||||
private EditText createNumberEditText() {
|
||||
EditText editText = new EditText(getContext());
|
||||
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
editText.setTextSize(textSize);
|
||||
editText.setTextColor(textColor);
|
||||
editText.setGravity(Gravity.CENTER);
|
||||
editText.setSingleLine(true);
|
||||
editText.setBackgroundResource(android.R.drawable.edit_text); // 默认输入框背景
|
||||
return editText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取输入框布局参数
|
||||
*/
|
||||
private LayoutParams getEditTextParams() {
|
||||
LayoutParams params = new LayoutParams(
|
||||
dp2px(editTextWidth),
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
params.setMargins(0, 0, dp2px(padding), 0);
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复核心:创建ProgressDrawable(返回Drawable类型,而非Paint)
|
||||
* 用LayerDrawable实现「背景+进度」的双层进度条
|
||||
*/
|
||||
private Drawable createProgressDrawable() {
|
||||
// 1. 进度条背景(灰色)
|
||||
ColorDrawable bgDrawable = new ColorDrawable(progressBgColor);
|
||||
// 2. 进度条前景(主题色)
|
||||
ColorDrawable progressDrawable = new ColorDrawable(progressColor);
|
||||
// 3. 用ClipDrawable包裹前景,实现进度裁剪
|
||||
ClipDrawable clipDrawable = new ClipDrawable(progressDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL);
|
||||
|
||||
// 4. 组合成LayerDrawable(顺序:背景在下,进度在上)
|
||||
Drawable[] layers = new Drawable[]{bgDrawable, clipDrawable};
|
||||
LayerDrawable layerDrawable = new LayerDrawable(layers);
|
||||
|
||||
// 5. 设置进度条的层级ID(必须与系统ProgressBar的ID匹配)
|
||||
layerDrawable.setId(0, android.R.id.background);
|
||||
layerDrawable.setId(1, android.R.id.progress);
|
||||
|
||||
return layerDrawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新进度条(总时间 = 小时*60 + 分钟,单位:分钟)
|
||||
*/
|
||||
private void updateProgressBar() {
|
||||
try {
|
||||
// 获取输入的时间(为空时默认0)
|
||||
int inputHour = TextUtils.isEmpty(etHour.getText().toString().trim())
|
||||
? 0 : Integer.parseInt(etHour.getText().toString().trim());
|
||||
int inputMinute = TextUtils.isEmpty(etMinute.getText().toString().trim())
|
||||
? 0 : Integer.parseInt(etMinute.getText().toString().trim());
|
||||
|
||||
// 校验时间合法性(小时0-99,分钟0-59)
|
||||
inputHour = Math.max(0, Math.min(99, inputHour));
|
||||
inputMinute = Math.max(0, Math.min(59, inputMinute));
|
||||
|
||||
// 计算总分钟数(进度条最大值)
|
||||
int totalMinutes = inputHour * 60 + inputMinute;
|
||||
totalMinutes = Math.max(1, totalMinutes); // 最小1分钟,避免进度条无长度
|
||||
|
||||
// 更新进度条
|
||||
progressBar.setMax(totalMinutes);
|
||||
progressBar.setProgress(totalMinutes); // 初始显示满进度,可根据实际需求修改
|
||||
|
||||
// 更新数据模型
|
||||
this.hour = inputHour;
|
||||
this.minute = inputMinute;
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
// 输入非法时重置进度条
|
||||
progressBar.setMax(0);
|
||||
progressBar.setProgress(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* dp转px(适配不同设备)
|
||||
*/
|
||||
private int dp2px(int dp) {
|
||||
return (int) (dp * getContext().getResources().getDisplayMetrics().density + 0.5f);
|
||||
}
|
||||
|
||||
// ------------------- 数据模型 getter/setter -------------------
|
||||
public String getHourglassId() {
|
||||
return hourglassId;
|
||||
}
|
||||
|
||||
public void setHourglassId(String hourglassId) {
|
||||
this.hourglassId = hourglassId;
|
||||
}
|
||||
|
||||
public int getHour() {
|
||||
return hour;
|
||||
}
|
||||
|
||||
public void setHour(int hour) {
|
||||
this.hour = Math.max(0, Math.min(99, hour)); // 限制范围
|
||||
etHour.setText(String.valueOf(this.hour));
|
||||
}
|
||||
|
||||
public int getMinute() {
|
||||
return minute;
|
||||
}
|
||||
|
||||
public void setMinute(int minute) {
|
||||
this.minute = Math.max(0, Math.min(59, minute)); // 限制范围
|
||||
etMinute.setText(String.valueOf(this.minute));
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
isEnabled = enabled;
|
||||
switchControl.setChecked(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动更新进度条(外部调用)
|
||||
*/
|
||||
public void refreshProgress() {
|
||||
if (isEnabled) {
|
||||
updateProgressBar();
|
||||
}
|
||||
}
|
||||
|
||||
// 工具类:判断字符串是否为空(Java7无TextUtils.isEmpty,手动实现)
|
||||
private static class TextUtils {
|
||||
public static boolean isEmpty(CharSequence str) {
|
||||
return str == null || str.length() == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import cc.winboll.studio.positions.App;
|
||||
import cc.winboll.studio.positions.AppLevel;
|
||||
import cc.winboll.studio.positions.activities.WinBoLLActivity;
|
||||
import cc.winboll.studio.positions.PointLevel;
|
||||
|
||||
public class PositionTaskListView extends LinearLayout {
|
||||
// 视图模式常量
|
||||
@@ -380,7 +384,7 @@ public class PositionTaskListView extends LinearLayout {
|
||||
// 步骤3:刷新Adapter(局部刷新+范围通知,避免列表错乱)
|
||||
notifyItemRemoved(position);
|
||||
notifyItemRangeChanged(position, mAdapterData.size());
|
||||
|
||||
|
||||
LogUtils.d(TAG, "Adapter已移除任务,刷新列表(位置索引=" + position + ")");
|
||||
|
||||
// 步骤4:通知外部(如Activity)任务已更新
|
||||
@@ -457,7 +461,7 @@ public class PositionTaskListView extends LinearLayout {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private String genSelectedTimeText(long timeMillis) {
|
||||
// 2. 格式化时间字符串(Java 7 用 SimpleDateFormat,需处理 ParseException)
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault());
|
||||
@@ -483,6 +487,16 @@ public class PositionTaskListView extends LinearLayout {
|
||||
final EditText etEditDistance = dialogView.findViewById(R.id.et_edit_distance);
|
||||
Button btnCancel = dialogView.findViewById(R.id.btn_dialog_cancel);
|
||||
Button btnSave = dialogView.findViewById(R.id.btn_dialog_save);
|
||||
HourglassView hourglassView = dialogView.findViewById(R.id.hourglassView);
|
||||
if (WinBoLLActivity._mPointLevel == PointLevel.WUKONG) {
|
||||
hourglassView.setVisibility(View.GONE);
|
||||
} else if (WinBoLLActivity._mPointLevel == PointLevel.LAOJUN) {
|
||||
hourglassView.setHourglassId("hourglass_001");
|
||||
hourglassView.setHour(1);
|
||||
hourglassView.setMinute(30);
|
||||
hourglassView.setEnabled(false); // 开启开关
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 绑定外层对话框内的控件
|
||||
|
||||
@@ -1,81 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:padding="20dp">
|
||||
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:id="@+id/toolbar"
|
||||
android:gravity="center_vertical"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_location_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="30dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:padding="20dp"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_location_info"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="30dp"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal">
|
||||
android:text="实时位置信息"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="实时位置信息"
|
||||
android:textSize="22sp"
|
||||
android:textStyle="bold"/>
|
||||
<TextView
|
||||
android:id="@+id/tv_longitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前经度:等待更新..."
|
||||
android:textSize="18sp"
|
||||
android:layout_marginTop="15dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_longitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前经度:等待更新..."
|
||||
android:textSize="18sp"
|
||||
android:layout_marginTop="15dp"/>
|
||||
<TextView
|
||||
android:id="@+id/tv_latitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前纬度:等待更新..."
|
||||
android:textSize="18sp"
|
||||
android:layout_marginTop="10dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_latitude"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前纬度:等待更新..."
|
||||
android:textSize="18sp"
|
||||
android:layout_marginTop="10dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_position_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/layout_location_info"
|
||||
android:layout_above="@id/fab_p_button"
|
||||
android:layout_marginTop="20dp"
|
||||
android:paddingBottom="10dp"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_position_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@id/layout_location_info"
|
||||
android:layout_above="@id/fab_p_button"
|
||||
android:layout_marginTop="20dp"
|
||||
android:paddingBottom="10dp"/>
|
||||
<Button
|
||||
android:id="@+id/fab_p_button"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="20dp"
|
||||
android:background="@drawable/circle_button_bg"
|
||||
android:text="P"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="24sp"
|
||||
android:elevation="6dp"
|
||||
android:padding="0dp"
|
||||
android:onClick="addNewPosition"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/fab_p_button"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_margin="20dp"
|
||||
android:background="@drawable/circle_button_bg"
|
||||
android:text="P"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="24sp"
|
||||
android:elevation="6dp"
|
||||
android:padding="0dp"
|
||||
android:onClick="addNewPosition"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -2,51 +2,38 @@
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="1.0">
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switch_service_control"
|
||||
android:layout_margin="16dp"
|
||||
android:text="GPS服务开关"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
<Switch
|
||||
android:id="@+id/switch_service_control"
|
||||
android:layout_margin="16dp"
|
||||
android:text="GPS服务开关"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:onClick="onPositions"
|
||||
android:text="位置与任务管理"
|
||||
android:id="@+id/btn_manage_positions"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:onClick="onLog"
|
||||
android:text="查看应用日志"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<cc.winboll.studio.libaes.views.ADsBannerView
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/adsbanner"
|
||||
android:layout_alignParentBottom="true"/>
|
||||
android:layout_margin="16dp"
|
||||
android:onClick="onPositions"
|
||||
android:text="位置与任务管理"
|
||||
android:id="@+id/btn_manage_positions"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:onClick="onLog"
|
||||
android:text="查看应用日志"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<cc.winboll.studio.libaes.views.ASupportToolbar
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/toolbar_height"
|
||||
android:id="@+id/toolbar"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
<cc.winboll.studio.libaes.views.ADsControlView
|
||||
android:id="@+id/ads_control_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -65,6 +65,16 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<cc.winboll.studio.positions.views.HourglassView
|
||||
android:id="@+id/hourglassView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
@@ -77,7 +87,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="开始时间"
|
||||
android:id="@+id/btn_select_time"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_selected_time"
|
||||
android:layout_width="0dp"
|
||||
@@ -85,7 +95,6 @@
|
||||
android:text="Text"
|
||||
android:layout_weight="1.0"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">悟空笔记</string>
|
||||
<string name="appplus_name">时空任务</string>
|
||||
<string name="open_appplus">开疆扩土</string>
|
||||
<string name="close_appplus">返璞归真</string>
|
||||
<string name="appplus_open_disabled">余力不足</string>
|
||||
<string name="appplus_close_disabled">辎重难返</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="toolbar_height">60dp</dimen>
|
||||
<dimen name="text_content_size">18dp</dimen>
|
||||
<dimen name="text_title_size">24dp</dimen>
|
||||
<dimen name="text_subtitle_size">16dp</dimen>
|
||||
</resources>
|
||||
@@ -1,9 +1,8 @@
|
||||
<resources>
|
||||
<string name="app_name">Positions</string>
|
||||
<string name="appplus_name">PositionsPlus</string>
|
||||
<string name="appplus_name">PositionsPlus</string>
|
||||
<string name="open_appplus">Open APP Plus</string>
|
||||
<string name="close_appplus">Close APP Plus</string>
|
||||
<string name="appplus_open_disabled">APP Plus Open Disable</string>
|
||||
<string name="appplus_close_disabled">APP Plus Close Disable</string>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -14,12 +14,4 @@
|
||||
</style>
|
||||
|
||||
|
||||
<!-- 设置Toolbar标题字体的大小 -->
|
||||
<style name="Toolbar.TitleText" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
|
||||
<item name="android:textSize">@dimen/text_title_size</item>
|
||||
</style>
|
||||
<style name="Toolbar.SubTitleText" parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
|
||||
<item name="android:textSize">@dimen/text_subtitle_size</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-files-path
|
||||
name="BaseBean"
|
||||
path="BaseBean/" />
|
||||
</paths>
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Sun Dec 07 03:42:32 HKT 2025
|
||||
#Sun Dec 07 04:17:43 GMT 2025
|
||||
stageCount=8
|
||||
libraryProject=
|
||||
baseVersion=15.11
|
||||
publishVersion=15.11.7
|
||||
buildCount=0
|
||||
buildCount=1
|
||||
baseBetaVersion=15.11.8
|
||||
|
||||
Reference in New Issue
Block a user