Compare commits
3 Commits
appbase
...
aes-v15.11
| Author | SHA1 | Date | |
|---|---|---|---|
| a8b64030f1 | |||
| e3fc7a0234 | |||
| 203e59cc81 |
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed Nov 26 15:54:26 GMT 2025
|
#Thu Nov 27 13:19:41 HKT 2025
|
||||||
stageCount=7
|
stageCount=8
|
||||||
libraryProject=libaes
|
libraryProject=libaes
|
||||||
baseVersion=15.11
|
baseVersion=15.11
|
||||||
publishVersion=15.11.6
|
publishVersion=15.11.7
|
||||||
buildCount=32
|
buildCount=0
|
||||||
baseBetaVersion=15.11.7
|
baseBetaVersion=15.11.8
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#Created by .winboll/winboll_app_build.gradle
|
#Created by .winboll/winboll_app_build.gradle
|
||||||
#Wed Nov 26 15:54:26 GMT 2025
|
#Thu Nov 27 13:19:41 HKT 2025
|
||||||
stageCount=7
|
stageCount=8
|
||||||
libraryProject=libaes
|
libraryProject=libaes
|
||||||
baseVersion=15.11
|
baseVersion=15.11
|
||||||
publishVersion=15.11.6
|
publishVersion=15.11.7
|
||||||
buildCount=32
|
buildCount=0
|
||||||
baseBetaVersion=15.11.7
|
baseBetaVersion=15.11.8
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package cc.winboll.studio.libaes.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||||
|
* @Date 2025/11/27 12:35
|
||||||
|
* @Describe 隐私协议签约状态枚举
|
||||||
|
* 对应值:0-拒绝,1-赞同,2-未签约(默认)
|
||||||
|
*/
|
||||||
|
public enum PrivacyAgreeStatus {
|
||||||
|
REJECTED(0, "拒绝"), // 0: 拒绝隐私协议
|
||||||
|
AGREED(1, "赞同"), // 1: 赞同隐私协议
|
||||||
|
UN_SIGNED(2, "未签约"); // 2: 未签约(初始默认状态)
|
||||||
|
|
||||||
|
private final int statusCode; // 对应存储的int值
|
||||||
|
private final String statusDesc; // 状态描述(可选,便于日志/UI显示)
|
||||||
|
|
||||||
|
// Java 7 枚举构造方法(必须private)
|
||||||
|
private PrivacyAgreeStatus(int statusCode, String statusDesc) {
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
this.statusDesc = statusDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据int值获取枚举(SP读取时使用,兼容Java 7)
|
||||||
|
* @param code 存储的int值(0/1/2)
|
||||||
|
* @return 对应枚举,默认返回UN_SIGNED(未签约)
|
||||||
|
*/
|
||||||
|
public static PrivacyAgreeStatus fromCode(int code) {
|
||||||
|
// Java 7 不支持switch(String),用if-else兼容
|
||||||
|
if (code == REJECTED.statusCode) {
|
||||||
|
return REJECTED;
|
||||||
|
} else if (code == AGREED.statusCode) {
|
||||||
|
return AGREED;
|
||||||
|
} else {
|
||||||
|
return UN_SIGNED; // 默认未签约
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据SP存储的字符串值获取枚举(兼容原逻辑中String类型存储)
|
||||||
|
* @param codeStr 存储的字符串值("0"/"1"/"2")
|
||||||
|
* @return 对应枚举,默认返回UN_SIGNED(未签约)
|
||||||
|
*/
|
||||||
|
public static PrivacyAgreeStatus fromString(String codeStr) {
|
||||||
|
if (codeStr == null) {
|
||||||
|
return UN_SIGNED;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int code = Integer.parseInt(codeStr);
|
||||||
|
return fromCode(code);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 字符串格式异常时,默认返回未签约
|
||||||
|
return UN_SIGNED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取状态码(用于存储到SP)
|
||||||
|
public int getStatusCode() {
|
||||||
|
return statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取状态描述(用于日志/UI显示,可选)
|
||||||
|
public String getStatusDesc() {
|
||||||
|
return statusDesc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,27 +2,19 @@ package cc.winboll.studio.libaes.views;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.Display;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.Toast;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import cc.winboll.studio.libaes.R;
|
import cc.winboll.studio.libaes.R;
|
||||||
|
import cc.winboll.studio.libaes.enums.ADsMode;
|
||||||
import cc.winboll.studio.libaes.utils.MimoUtils;
|
import cc.winboll.studio.libaes.utils.MimoUtils;
|
||||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||||
import cc.winboll.studio.libappbase.LogUtils;
|
import cc.winboll.studio.libappbase.LogUtils;
|
||||||
import cc.winboll.studio.libappbase.ToastUtils;
|
|
||||||
import com.miui.zeus.mimo.sdk.ADParams;
|
import com.miui.zeus.mimo.sdk.ADParams;
|
||||||
import com.miui.zeus.mimo.sdk.BannerAd;
|
import com.miui.zeus.mimo.sdk.BannerAd;
|
||||||
import com.miui.zeus.mimo.sdk.MimoCustomController;
|
import com.miui.zeus.mimo.sdk.MimoCustomController;
|
||||||
@@ -30,8 +22,6 @@ import com.miui.zeus.mimo.sdk.MimoLocation;
|
|||||||
import com.miui.zeus.mimo.sdk.MimoSdk;
|
import com.miui.zeus.mimo.sdk.MimoSdk;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import cc.winboll.studio.libaes.enums.ADsMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||||
@@ -84,7 +74,6 @@ public class ADsBannerView extends LinearLayout {
|
|||||||
|
|
||||||
void initView(Context context) {
|
void initView(Context context) {
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
|
|
||||||
initMimoSdk(this.mContext);
|
initMimoSdk(this.mContext);
|
||||||
|
|
||||||
// 初始化主线程Handler(关键:确保广告操作在主线程执行)
|
// 初始化主线程Handler(关键:确保广告操作在主线程执行)
|
||||||
@@ -98,6 +87,10 @@ public class ADsBannerView extends LinearLayout {
|
|||||||
public void resumeADs(final Activity activity) {
|
public void resumeADs(final Activity activity) {
|
||||||
// 没有设置米盟广告支持就退出
|
// 没有设置米盟广告支持就退出
|
||||||
if (ADsControlView.getAdsModeFromStatic(this.mContext) != ADsMode.MIMO_SDK) {
|
if (ADsControlView.getAdsModeFromStatic(this.mContext) != ADsMode.MIMO_SDK) {
|
||||||
|
// 2. 释放之前的广告资源
|
||||||
|
if (mBannerAd != null) {
|
||||||
|
mBannerAd.destroy();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import com.miui.zeus.mimo.sdk.MimoCustomController;
|
|||||||
import com.miui.zeus.mimo.sdk.MimoLocation;
|
import com.miui.zeus.mimo.sdk.MimoLocation;
|
||||||
import com.miui.zeus.mimo.sdk.MimoSdk;
|
import com.miui.zeus.mimo.sdk.MimoSdk;
|
||||||
import cc.winboll.studio.libappbase.ToastUtils;
|
import cc.winboll.studio.libappbase.ToastUtils;
|
||||||
|
import cc.winboll.studio.libaes.enums.PrivacyAgreeStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
* @Author ZhanGSKen&豆包大模型<zhangsken@qq.com>
|
||||||
@@ -45,15 +46,15 @@ public class ADsControlView extends LinearLayout {
|
|||||||
ADsMode mADsMode;
|
ADsMode mADsMode;
|
||||||
private static final String PRIVACY_VALUE = "privacy_value";
|
private static final String PRIVACY_VALUE = "privacy_value";
|
||||||
// 隐私协议签约结果 0: 拒绝,1:赞同 2: 未签约
|
// 隐私协议签约结果 0: 拒绝,1:赞同 2: 未签约
|
||||||
String privacyAgreeValue;
|
PrivacyAgreeStatus mPrivacyAgreeStatus;
|
||||||
|
|
||||||
// Handler消息标识
|
// Handler消息标识
|
||||||
private static final int MSG_UPDATE_MODE = 1001;
|
private static final int MSG_UPDATE_MODE = 1001;
|
||||||
|
|
||||||
// 控件引用
|
// 控件引用
|
||||||
private RadioGroup rgAdsMode;
|
private RadioGroup rgADsMode;
|
||||||
private RadioButton rbStandalone;
|
private RadioButton rbStandalone;
|
||||||
private RadioButton rbMimoSdk;
|
private RadioButton rbMimoSDK;
|
||||||
|
|
||||||
// 外部监听、SP实例、Handler实例
|
// 外部监听、SP实例、Handler实例
|
||||||
private OnAdsModeSelectedListener listener;
|
private OnAdsModeSelectedListener listener;
|
||||||
@@ -81,13 +82,15 @@ public class ADsControlView extends LinearLayout {
|
|||||||
initView(context);
|
initView(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrivacyAgreeValue(String privacyAgreeValue) {
|
public void setPrivacyAgreeStatus(PrivacyAgreeStatus privacyAgreeStatus) {
|
||||||
this.privacyAgreeValue = privacyAgreeValue;
|
this.mPrivacyAgreeStatus = privacyAgreeStatus;
|
||||||
|
sharedPreferences.edit().putString(PRIVACY_VALUE, this.mPrivacyAgreeStatus.name()).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrivacyAgreeValue() {
|
public PrivacyAgreeStatus getPrivacyAgreeStatus() {
|
||||||
String privacyAgreeValue = sharedPreferences.getString(PRIVACY_VALUE, "0");
|
String privacyAgreeStatusStr = sharedPreferences.getString(PRIVACY_VALUE, PrivacyAgreeStatus.UN_SIGNED.name());
|
||||||
return privacyAgreeValue;
|
PrivacyAgreeStatus privacyAgreeStatus = PrivacyAgreeStatus.fromString(privacyAgreeStatusStr);
|
||||||
|
return privacyAgreeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setADsMode(ADsMode mADsMode) {
|
public void setADsMode(ADsMode mADsMode) {
|
||||||
@@ -113,9 +116,9 @@ public class ADsControlView extends LinearLayout {
|
|||||||
sharedPreferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
|
sharedPreferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
|
||||||
|
|
||||||
// 绑定控件
|
// 绑定控件
|
||||||
rgAdsMode = (RadioGroup) findViewById(R.id.rg_ads_mode);
|
rgADsMode = (RadioGroup) findViewById(R.id.rg_ads_mode);
|
||||||
rbStandalone = (RadioButton) findViewById(R.id.rb_standalone);
|
rbStandalone = (RadioButton) findViewById(R.id.rb_standalone);
|
||||||
rbMimoSdk = (RadioButton) findViewById(R.id.rb_mimo_sdk);
|
rbMimoSDK = (RadioButton) findViewById(R.id.rb_mimo_sdk);
|
||||||
|
|
||||||
// 初始化Handler(主线程Looper)
|
// 初始化Handler(主线程Looper)
|
||||||
mHandler = new InternalHandler(Looper.getMainLooper());
|
mHandler = new InternalHandler(Looper.getMainLooper());
|
||||||
@@ -124,17 +127,17 @@ public class ADsControlView extends LinearLayout {
|
|||||||
registerControlView(this);
|
registerControlView(this);
|
||||||
|
|
||||||
// 从SP读取初始模式并设置
|
// 从SP读取初始模式并设置
|
||||||
ToastUtils.show(String.format("savedMode : %s", getADsMode().name()));
|
//ToastUtils.show(String.format("savedMode : %s", getADsMode().name()));
|
||||||
setSelectedMode(getADsMode());
|
setSelectedMode(getADsMode());
|
||||||
|
|
||||||
// 单选组选择事件监听
|
// 单选组选择事件监听
|
||||||
rgAdsMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
rgADsMode.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
if (checkedId == R.id.rb_standalone) {
|
if (checkedId == R.id.rb_standalone) {
|
||||||
setADsMode(ADsMode.STANDALONE);
|
setADsMode(ADsMode.STANDALONE);
|
||||||
} else if (checkedId == R.id.rb_mimo_sdk) {
|
} else if (checkedId == R.id.rb_mimo_sdk) {
|
||||||
showPrivacy(context, new OnPrivacyChangeListener(){
|
handlePrivacyLogic((Activity)context, PrivacyAgreeStatus.UN_SIGNED , new OnPrivacyChangeListener(){
|
||||||
@Override
|
@Override
|
||||||
public void onAgreePrivacy() {
|
public void onAgreePrivacy() {
|
||||||
setADsMode(ADsMode.MIMO_SDK);
|
setADsMode(ADsMode.MIMO_SDK);
|
||||||
@@ -154,31 +157,29 @@ public class ADsControlView extends LinearLayout {
|
|||||||
* 【静态】显示隐私协议弹窗(供外部调用,带Context参数)
|
* 【静态】显示隐私协议弹窗(供外部调用,带Context参数)
|
||||||
* @param context 上下文(需传入Activity Context,用于弹窗显示)
|
* @param context 上下文(需传入Activity Context,用于弹窗显示)
|
||||||
*/
|
*/
|
||||||
public static void showPrivacy(Context context, OnPrivacyChangeListener onPrivacyChangeListener) {
|
// public void showPrivacy(OnPrivacyChangeListener onPrivacyChangeListener) {
|
||||||
if (context == null) {
|
// if (context == null) {
|
||||||
LogUtils.e(TAG, "showPrivacy: Context is null, cannot show privacy dialog");
|
// LogUtils.e(TAG, "showPrivacy: Context is null, cannot show privacy dialog");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// 校验是否为Activity Context(弹窗必须依附Activity)
|
// // 校验是否为Activity Context(弹窗必须依附Activity)
|
||||||
Activity activity = null;
|
// Activity activity = null;
|
||||||
try {
|
// try {
|
||||||
activity = (Activity) context;
|
// activity = (Activity) context;
|
||||||
} catch (ClassCastException e) {
|
// } catch (ClassCastException e) {
|
||||||
LogUtils.e(TAG, "showPrivacy: Context is not Activity Context", e);
|
// LogUtils.e(TAG, "showPrivacy: Context is not Activity Context", e);
|
||||||
Toast.makeText(context.getApplicationContext(), "请传入Activity上下文以显示隐私协议", Toast.LENGTH_SHORT).show();
|
// Toast.makeText(context.getApplicationContext(), "请传入Activity上下文以显示隐私协议", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// 校验Activity状态
|
// // 校验Activity状态
|
||||||
if (activity.isFinishing() || activity.isDestroyed()) {
|
// if (activity.isFinishing() || activity.isDestroyed()) {
|
||||||
LogUtils.e(TAG, "showPrivacy: Activity is finishing or destroyed");
|
// LogUtils.e(TAG, "showPrivacy: Activity is finishing or destroyed");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 读取隐私协议状态并处理逻辑
|
// // 读取隐私协议状态并处理逻辑
|
||||||
SbhhharedPreferences sp = getPrivacySharedPreferences(context);
|
// handlePrivacyLogic(activity, getPrivacyAgreeStatus(), onPrivacyChangeListener);
|
||||||
String privacyAgreeValue = sp.getString(PRIVACY_VALUE, null);
|
// }
|
||||||
handlePrivacyLogic(activity, privacyAgreeValue, onPrivacyChangeListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【静态】清理SP中存储的隐私协议状态(PRIVACY_VALUE)
|
* 【静态】清理SP中存储的隐私协议状态(PRIVACY_VALUE)
|
||||||
@@ -204,21 +205,21 @@ public class ADsControlView extends LinearLayout {
|
|||||||
// 使用ApplicationContext获取SP,避免内存泄漏
|
// 使用ApplicationContext获取SP,避免内存泄漏
|
||||||
Context appContext = context.getApplicationContext();
|
Context appContext = context.getApplicationContext();
|
||||||
if (appContext != null) {
|
if (appContext != null) {
|
||||||
return appContext.getSharedPreferences(PRIVACY_FILE, Context.MODE_PRIVATE);
|
return appContext.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
// 降级方案:若ApplicationContext为空,使用传入的Context
|
// 降级方案:若ApplicationContext为空,使用传入的Context
|
||||||
return context.getSharedPreferences(PRIVACY_FILE, Context.MODE_PRIVATE);
|
return context.getSharedPreferences(PRIVACY_VALUE, Context.MODE_PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 【配套静态工具方法】隐私协议逻辑处理(供上述两个静态方法调用,需一并添加)
|
// 【配套静态工具方法】隐私协议逻辑处理(供上述两个静态方法调用,需一并添加)
|
||||||
private static void handlePrivacyLogic(final Activity activity, String privacyAgreeValue, final OnPrivacyChangeListener onPrivacyChangeListener) {
|
private static void handlePrivacyLogic(final Activity activity, PrivacyAgreeStatus privacyAgreeStatus, final OnPrivacyChangeListener onPrivacyChangeListener) {
|
||||||
if (TextUtils.equals(privacyAgreeValue, String.valueOf(0))) {
|
if (privacyAgreeStatus == PrivacyAgreeStatus.REJECTED) {
|
||||||
ADsControlView.updateAdsModeByStatic(activity.getApplicationContext(), ADsMode.STANDALONE);
|
//ADsControlView.updateAdsModeByStatic(activity.getApplicationContext(), ADsMode.STANDALONE);
|
||||||
LogUtils.i(TAG, "已拒绝隐私协议,广告已处于不可用状态...");
|
LogUtils.i(TAG, "已拒绝隐私协议,广告已处于不可用状态...");
|
||||||
Toast.makeText(activity.getApplicationContext(), "已拒绝隐私协议,广告已处于不可用状态", Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity.getApplicationContext(), "已拒绝隐私协议,广告已处于不可用状态", Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
} else if (TextUtils.equals(privacyAgreeValue, String.valueOf(1))) {
|
} else if (privacyAgreeStatus == PrivacyAgreeStatus.AGREED) {
|
||||||
ADsControlView.updateAdsModeByStatic(activity.getApplicationContext(), ADsMode.MIMO_SDK);
|
//ADsControlView.updateAdsModeByStatic(activity.getApplicationContext(), ADsMode.MIMO_SDK);
|
||||||
LogUtils.i(TAG, "已同意隐私协议,开始初始化米盟SDK...");
|
LogUtils.i(TAG, "已同意隐私协议,开始初始化米盟SDK...");
|
||||||
initMimoSdkStatic(activity.getApplicationContext());
|
initMimoSdkStatic(activity.getApplicationContext());
|
||||||
return;
|
return;
|
||||||
@@ -382,7 +383,7 @@ public class ADsControlView extends LinearLayout {
|
|||||||
if (mode2 == ADsMode.STANDALONE) {
|
if (mode2 == ADsMode.STANDALONE) {
|
||||||
rbStandalone.setChecked(true);
|
rbStandalone.setChecked(true);
|
||||||
} else if (mode2 == ADsMode.MIMO_SDK) {
|
} else if (mode2 == ADsMode.MIMO_SDK) {
|
||||||
rbMimoSdk.setChecked(true);
|
rbMimoSDK.setChecked(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@@ -398,7 +399,7 @@ public class ADsControlView extends LinearLayout {
|
|||||||
* 获取当前选中模式
|
* 获取当前选中模式
|
||||||
*/
|
*/
|
||||||
public ADsMode getSelectedMode() {
|
public ADsMode getSelectedMode() {
|
||||||
int checkedId = rgAdsMode.getCheckedRadioButtonId();
|
int checkedId = rgADsMode.getCheckedRadioButtonId();
|
||||||
return checkedId == R.id.rb_mimo_sdk ? ADsMode.MIMO_SDK : ADsMode.STANDALONE;
|
return checkedId == R.id.rb_mimo_sdk ? ADsMode.MIMO_SDK : ADsMode.STANDALONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user