From b1e2a018d83e30d473aee88c294bc5013dda4323 Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Sun, 30 Mar 2025 01:01:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BA=94=E7=94=A8=E4=BB=8B?= =?UTF-8?q?=E7=BB=8D=E9=A1=B5UI=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aes/build.properties | 4 +- .../cc/winboll/studio/aes/AboutActivity.java | 30 +++-- .../winboll/studio/aes/WinBollActivity.java | 50 ++++++++ aes/src/main/res/layout/activity_about.xml | 22 ++++ libaes/build.properties | 4 +- .../WinBollServerConnectionTestThread.java | 113 ++++++++++++------ 6 files changed, 175 insertions(+), 48 deletions(-) create mode 100644 aes/src/main/java/cc/winboll/studio/aes/WinBollActivity.java create mode 100644 aes/src/main/res/layout/activity_about.xml diff --git a/aes/build.properties b/aes/build.properties index 9c0e439..f35b191 100644 --- a/aes/build.properties +++ b/aes/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Sat Mar 29 09:33:15 GMT 2025 +#Sat Mar 29 16:59:59 GMT 2025 stageCount=2 libraryProject=libaes baseVersion=15.2 publishVersion=15.2.1 -buildCount=16 +buildCount=25 baseBetaVersion=15.2.2 diff --git a/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java b/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java index 80fc544..208327c 100644 --- a/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java +++ b/aes/src/main/java/cc/winboll/studio/aes/AboutActivity.java @@ -5,23 +5,25 @@ package cc.winboll.studio.aes; * @Date 2025/03/24 23:52:29 * @Describe AES应用介绍窗口 */ +import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.ViewGroup; import android.widget.LinearLayout; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import cc.winboll.studio.libaes.winboll.APPInfo; import cc.winboll.studio.libaes.winboll.AboutView; import cc.winboll.studio.libappbase.GlobalApplication; import cc.winboll.studio.libappbase.winboll.IWinBollActivity; -import android.app.Activity; -public class AboutActivity extends AppCompatActivity implements IWinBollActivity { +public class AboutActivity extends WinBollActivity implements IWinBollActivity { public static final String TAG = "AboutActivity"; Context mContext; - + Toolbar mToolbar; + @Override public Activity getActivity() { return this; @@ -36,17 +38,31 @@ public class AboutActivity extends AppCompatActivity implements IWinBollActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; - + setContentView(R.layout.activity_about); + + mToolbar = findViewById(R.id.toolbar); + setSupportActionBar(mToolbar); + mToolbar.setSubtitle(TAG); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + AboutView aboutView = CreateAboutView(); // 在 Activity 的 onCreate 或其他生命周期方法中调用 - LinearLayout layout = new LinearLayout(this); - layout.setOrientation(LinearLayout.VERTICAL); +// LinearLayout layout = new LinearLayout(this); +// layout.setOrientation(LinearLayout.VERTICAL); +// // 创建布局参数(宽度和高度) +// ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( +// ViewGroup.LayoutParams.MATCH_PARENT, +// ViewGroup.LayoutParams.MATCH_PARENT +// ); +// addContentView(aboutView, params); + + LinearLayout layout = findViewById(R.id.aboutviewroot_ll); // 创建布局参数(宽度和高度) ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ); - addContentView(aboutView, params); + layout.addView(aboutView, params); GlobalApplication.getWinBollActivityManager().add(this); } diff --git a/aes/src/main/java/cc/winboll/studio/aes/WinBollActivity.java b/aes/src/main/java/cc/winboll/studio/aes/WinBollActivity.java new file mode 100644 index 0000000..a57c782 --- /dev/null +++ b/aes/src/main/java/cc/winboll/studio/aes/WinBollActivity.java @@ -0,0 +1,50 @@ +package cc.winboll.studio.aes; + +import android.app.Activity; +import android.os.Bundle; +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; + +/** + * @Author ZhanGSKen@AliYun.Com + * @Date 2025/03/30 00:34:02 + * @Describe WinBoll 活动窗口通用基类 + */ +public class WinBollActivity extends AppCompatActivity implements IWinBollActivity { + + public static final String TAG = "WinBollActivity"; + + protected volatile AESThemeBean.ThemeType mThemeType; + + @Override + public Activity getActivity() { + return this; + } + + @Override + public String getTag() { + return TAG; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + mThemeType = getThemeType(); + setThemeStyle(); + 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())); + } + + void setThemeStyle() { + //setTheme(AESThemeBean.getThemeStyle(getThemeType())); + setTheme(AESThemeUtil.getThemeTypeID(getApplicationContext())); + } +} diff --git a/aes/src/main/res/layout/activity_about.xml b/aes/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..3de4825 --- /dev/null +++ b/aes/src/main/res/layout/activity_about.xml @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/libaes/build.properties b/libaes/build.properties index 9c0e439..f35b191 100644 --- a/libaes/build.properties +++ b/libaes/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Sat Mar 29 09:33:15 GMT 2025 +#Sat Mar 29 16:59:59 GMT 2025 stageCount=2 libraryProject=libaes baseVersion=15.2 publishVersion=15.2.1 -buildCount=16 +buildCount=25 baseBetaVersion=15.2.2 diff --git a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java index d2a1c34..ba24017 100644 --- a/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java +++ b/libaes/src/main/java/cc/winboll/studio/libaes/winboll/WinBollServerConnectionTestThread.java @@ -8,6 +8,8 @@ package cc.winboll.studio.libaes.winboll; import cc.winboll.studio.libappbase.LogUtils; import java.io.IOException; import okhttp3.Authenticator; +import okhttp3.Call; +import okhttp3.Callback; import okhttp3.Credentials; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -42,6 +44,7 @@ public class WinBollServerConnectionTestThread extends Thread { @Override public void run() { + LogUtils.d(TAG, String.format("run() url %s\nusername %s\npassword %s", url, username, password)); OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(connectTimeout, java.util.concurrent.TimeUnit.MILLISECONDS) .readTimeout(readTimeout, java.util.concurrent.TimeUnit.MILLISECONDS) @@ -58,44 +61,80 @@ public class WinBollServerConnectionTestThread extends Thread { Request request = new Request.Builder() .url(url) .build(); - - int retryCount = 0; - while (!testComplete && retryCount <= maxRetries) { - try { - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - String responseBody = response.body().string(); - if ("OK".equalsIgnoreCase(responseBody.trim())) { - LogUtils.d(TAG, "[" + new java.util.Date() + "] 测试成功,服务器返回OK"); - testComplete = true; - } else { - LogUtils.d(TAG, "[" + new java.util.Date() + "] 响应内容不符合预期:" + responseBody); - } - } else { - LogUtils.d(TAG, "[" + new java.util.Date() + "] 请求失败,状态码:" + response.code()); - } - } catch (IOException e) { - LogUtils.d(TAG, "[" + new java.util.Date() + "] 连接异常:" + e.getMessage()); - } - - if (!testComplete) { - try { - Thread.sleep(2000); // 等待2秒后重试 - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - LogUtils.d(TAG, "测试线程被中断"); - return; - } - retryCount++; - LogUtils.d(TAG, "[" + new java.util.Date() + "] 第" + retryCount + "次重试..."); - } - } - - if (testComplete) { - } else { - LogUtils.d(TAG, "[" + new java.util.Date() + "] 达到最大重试次数,测试失败"); - } + Call call = client.newCall(request); + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + // 处理网络请求失败 + LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + if (!response.isSuccessful()) { + LogUtils.d(TAG, "Unexpected code " + response, Thread.currentThread().getStackTrace()); + return; + } + + try { + // 读取响应体作为字符串,注意这里可能需要解码 + String text = response.body().string(); + org.jsoup.nodes.Document doc = org.jsoup.Jsoup.parse(text); + LogUtils.d(TAG, doc.text()); + + // 使用id选择器找到具有特定id的元素 + org.jsoup.nodes.Element elementWithId = doc.select("#LastRelease").first(); // 获取第一个匹配的元素 + + // 提取并打印元素的文本内容 + //mszNewestAppPackageName = elementWithId.text(); + //ToastUtils.delayedShow(text + "\n" + mszNewestAppPackageName, 5000); + + //mHandler.sendMessage(mHandler.obtainMessage(MSG_APPUPDATE_CHECKED)); + } catch (Exception e) { + LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); + } + } + }); + +// int retryCount = 0; +// while (!testComplete && retryCount <= maxRetries) { +// LogUtils.d(TAG, "while (!testComplete && retryCount <= maxRetries) {"); +// try { +// Response response = client.newCall(request).execute(); +// if (response.isSuccessful()) { +// String responseBody = response.body().string(); +// if ("OK".equalsIgnoreCase(responseBody.trim())) { +// LogUtils.d(TAG, "[" + new java.util.Date() + "] 测试成功,服务器返回OK"); +// testComplete = true; +// } else { +// LogUtils.d(TAG, "[" + new java.util.Date() + "] 响应内容不符合预期:" + responseBody); +// } +// } else { +// LogUtils.d(TAG, "[" + new java.util.Date() + "] 请求失败,状态码:" + response.code()); +// } +// } catch (IOException e) { +// LogUtils.d(TAG, "[" + new java.util.Date() + "] 连接异常:" + e.getMessage()); +// } +// +// if (!testComplete) { +// try { +// Thread.sleep(2000); // 等待2秒后重试 +// } catch (InterruptedException e) { +// Thread.currentThread().interrupt(); +// LogUtils.d(TAG, "测试线程被中断"); +// return; +// } +// retryCount++; +// LogUtils.d(TAG, "[" + new java.util.Date() + "] 第" + retryCount + "次重试..."); +// } +// } +// +// if (testComplete) { +// +// } else { +// LogUtils.d(TAG, "[" + new java.util.Date() + "] 达到最大重试次数,测试失败"); +// } } // public static void main(String[] args) {