|
|
@@ -62,6 +62,7 @@ public class LoginActivity extends AppCompatActivity {
|
|
|
private TextView statusText;
|
|
|
private Button installButton;
|
|
|
private AlertDialog dialog;
|
|
|
+ private SessionManager sessionManager;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -69,7 +70,7 @@ public class LoginActivity extends AppCompatActivity {
|
|
|
|
|
|
// 初始化 NetworkRepository
|
|
|
networkRepository = NetworkRepository.getInstance();
|
|
|
- SessionManager sessionManager = new SessionManager(this);
|
|
|
+ sessionManager = new SessionManager(this);
|
|
|
|
|
|
updateUtil = VersionUpdateUtil.getInstance(this);
|
|
|
|
|
|
@@ -81,7 +82,7 @@ public class LoginActivity extends AppCompatActivity {
|
|
|
.subscribe(
|
|
|
updateInfoResponse -> {
|
|
|
boolean newVersion = updateUtil.isNewVersion(currentVersion, updateInfoResponse.getData().getVersion());
|
|
|
- if (newVersion && updateInfoResponse.getData().isForce()) {
|
|
|
+ if (newVersion) {
|
|
|
// 处理强制更新逻辑 - 显示更新对话框
|
|
|
showForceUpdateDialog(updateInfoResponse);
|
|
|
} else {
|
|
|
@@ -276,14 +277,39 @@ public class LoginActivity extends AppCompatActivity {
|
|
|
TextView statusText = dialogView.findViewById(R.id.dialogStatusText);
|
|
|
Button cancelButton = dialogView.findViewById(R.id.dialogCancelButton);
|
|
|
Button installButton = dialogView.findViewById(R.id.dialogInstallButton);
|
|
|
+ TextView updateContentTextView = dialogView.findViewById(R.id.updateContent);
|
|
|
|
|
|
// 设置版本信息
|
|
|
String currentVersion = updateUtil.getCurrentVersion();
|
|
|
currentVersionText.setText(currentVersion);
|
|
|
newVersionText.setText(updateInfo.getVersion());
|
|
|
|
|
|
- // 设置状态文本
|
|
|
- statusText.setText("检测到重要更新,请立即升级");
|
|
|
+ if (updateInfo.getData() != null && updateInfo.getData().getContent() != null) {
|
|
|
+ // 将字符串中的\n替换为系统换行符
|
|
|
+ String content = updateInfo.getData().getContent().replace("\\n", "\n");
|
|
|
+ updateContentTextView.setText(content);
|
|
|
+ } else {
|
|
|
+ updateContentTextView.setText("暂无更新内容说明");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 根据是否强制更新设置取消按钮的可见性
|
|
|
+ if (updateInfo.getData() != null && updateInfo.getData().isForce()) {
|
|
|
+ // 强制更新 - 隐藏取消按钮
|
|
|
+ cancelButton.setVisibility(View.GONE);
|
|
|
+ statusText.setText("检测到重要更新,请立即升级");
|
|
|
+ } else {
|
|
|
+ // 非强制更新 - 显示取消按钮
|
|
|
+ cancelButton.setVisibility(View.VISIBLE);
|
|
|
+ statusText.setText("检测到新版本,建议升级");
|
|
|
+
|
|
|
+ // 设置取消按钮点击事件
|
|
|
+ cancelButton.setOnClickListener(v -> {
|
|
|
+ dialog.dismiss();
|
|
|
+ // 显示登录界面
|
|
|
+ checkLoginStatus(sessionManager);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
// 隐藏进度条和进度文本(初始状态)
|
|
|
progressBar.setVisibility(View.GONE);
|
|
|
@@ -294,6 +320,8 @@ public class LoginActivity extends AppCompatActivity {
|
|
|
installButton.setVisibility(View.VISIBLE);
|
|
|
installButton.setText("立即更新");
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// 设置立即更新按钮点击事件
|
|
|
installButton.setOnClickListener(v -> {
|
|
|
// 开始下载APK
|