Skip to content

Commit

Permalink
0.0.50.beta31
Browse files Browse the repository at this point in the history
- 增加了 Android 14 debug 模式卡顿的提示,此问题系系统原因而非 DialogX 的问题,详情:https://xiaozhuanlan.com/topic/1023694578
- 修复 FitSystemBarUtils 可能存在的因 OnGlobalLayoutListener 引发的内存泄漏问题;
  • Loading branch information
kongzue committed Jan 9, 2025
1 parent f5cb34d commit ff1e4c1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.kongzue.dialogx.util.views;


import static androidx.core.view.WindowInsetsAnimationCompat.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE;

import android.app.Activity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import android.os.Looper;
import android.provider.Settings;
import android.text.InputType;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
Expand Down Expand Up @@ -298,6 +302,8 @@ public boolean onClick(BaseDialog baseDialog, View v) {

txtVer.setText("当前版本:" + BuildConfig.VERSION_NAME);

checkAndroid14InDebugMode();

// //合并处理演示,在 onDismiss 中获取用户选择进行统一处理,以防止编写大量可能在不同选择下都要处理的重复代码
// MessageDialog.show("Title", "Ask Question", "OK", "NO", "OTHER").setDialogLifecycleCallback(new DialogLifecycleCallback<MessageDialog>() {
// @Override
Expand Down Expand Up @@ -1578,4 +1584,43 @@ protected void onCreate(Bundle savedInstanceState) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
super.onCreate(savedInstanceState);
}

// 检查是否处于debug模式且系统版本为Android 14
private void checkAndroid14InDebugMode() {
if (BuildConfig.DEBUG && Build.VERSION.SDK_INT == 34) {
String fullText = "当前系统版本在debug模式下可能存在卡顿现象,属于系统故障,程序编译为release版本后将恢复正常,具体原因请参阅:《Android14 设备上 debug 调试 app 出现卡顿的问题及临时修复办法》";
String linkText = "《Android14 设备上 debug 调试 app 出现卡顿的问题及临时修复办法》";
String url = "https://xiaozhuanlan.com/topic/1023694578";

SpannableString spannableString = new SpannableString(fullText);
int start = fullText.indexOf(linkText);
int end = start + linkText.length();
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View widget) {
// 点击后跳转到指定链接
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}

@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(Color.BLUE); // 设置链接颜色
ds.setUnderlineText(true); // 添加下划线
}
};
spannableString.setSpan(clickableSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
MessageDialog.build()
.setTitle("警告")
.setMessage(spannableString)
.setOkButton("知道了", new OnDialogButtonClickListener<MessageDialog>() {
@Override
public boolean onClick(MessageDialog dialog, View v) {
return false;
}
})
.show();
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

BUILD_VERSION=0.0.50.beta30
BUILD_VERSION=0.0.50.beta31
BUILD_VERSION_INT=50
DIALOGX_STYLE_VERSION=5
android.nonTransitiveRClass=true

0 comments on commit ff1e4c1

Please sign in to comment.