From ae7fb2984af6a349b8b8af797404f34555cf018c Mon Sep 17 00:00:00 2001 From: ZhanGSKen Date: Wed, 22 Jan 2025 21:16:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8B=E7=BB=8D=E9=A1=B5=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apputils/build.properties | 4 +- .../winboll/studio/apputils/MainActivity.java | 18 ++++++++- libapputils/build.properties | 4 +- libapputils/src/main/AndroidManifest.xml | 5 ++- .../libapputils/app/AppVersionUtils.java | 16 ++++++-- .../studio/libapputils/view/AboutView.java | 38 +++++++++++-------- 6 files changed, 58 insertions(+), 27 deletions(-) diff --git a/apputils/build.properties b/apputils/build.properties index 930e476..12b90a0 100644 --- a/apputils/build.properties +++ b/apputils/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed Jan 22 11:33:02 GMT 2025 +#Wed Jan 22 13:10:40 GMT 2025 stageCount=3 libraryProject=libapputils baseVersion=9.2 publishVersion=9.2.2 -buildCount=8 +buildCount=25 baseBetaVersion=9.2.3 diff --git a/apputils/src/main/java/cc/winboll/studio/apputils/MainActivity.java b/apputils/src/main/java/cc/winboll/studio/apputils/MainActivity.java index 54fd6ea..69bcb7a 100644 --- a/apputils/src/main/java/cc/winboll/studio/apputils/MainActivity.java +++ b/apputils/src/main/java/cc/winboll/studio/apputils/MainActivity.java @@ -160,18 +160,32 @@ final public class MainActivity extends WinBollActivity { } else if (item.getItemId() == R.id.item_testqrcodedecodeactivity) { Intent intent = new Intent(this, QRCodeDecodeActivity.class); startActivityForResult(intent, REQUEST_QRCODEDECODE_ACTIVITY); + } else if(item.getItemId() == R.id.item_about) { + openAboutActivity(); + return true; } return super.onOptionsItemSelected(item); } - public void onTestAboutActivity(View view) { + void openAboutActivity() { Intent intent = new Intent(this, AboutActivity.class); APPInfo appInfo = new APPInfo(); + appInfo.setAppName("APPUtils"); appInfo.setAppIcon(cc.winboll.studio.libapputils.R.drawable.ic_winboll); - appInfo.setAppName("Test APP"); + appInfo.setAppDescription("APPUtils Description"); + appInfo.setAppGitName("APP"); + appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=APP"); + appInfo.setAppAPKName("APPUtils"); + appInfo.setAppAPKFolderName("APPUtils"); intent.putExtra(AboutActivity.EXTRA_APPINFO, appInfo); WinBollActivityManager.getInstance(this).startWinBollActivity(this, intent, AboutActivity.class); } + + + public void onTestAboutActivity(View view) { + //ToastUtils.show("onTestAboutActivity"); + openAboutActivity(); + } public void onTestJavascriptHtmlActivity(View view) { Intent intent = new Intent(this, AssetsHtmlActivity.class); diff --git a/libapputils/build.properties b/libapputils/build.properties index 930e476..12b90a0 100644 --- a/libapputils/build.properties +++ b/libapputils/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Wed Jan 22 11:33:02 GMT 2025 +#Wed Jan 22 13:10:40 GMT 2025 stageCount=3 libraryProject=libapputils baseVersion=9.2 publishVersion=9.2.2 -buildCount=8 +buildCount=25 baseBetaVersion=9.2.3 diff --git a/libapputils/src/main/AndroidManifest.xml b/libapputils/src/main/AndroidManifest.xml index c5b8176..04a37a0 100644 --- a/libapputils/src/main/AndroidManifest.xml +++ b/libapputils/src/main/AndroidManifest.xml @@ -18,6 +18,9 @@ + + + - \ No newline at end of file + diff --git a/libapputils/src/main/java/cc/winboll/studio/libapputils/app/AppVersionUtils.java b/libapputils/src/main/java/cc/winboll/studio/libapputils/app/AppVersionUtils.java index 71ba826..e7f0b67 100644 --- a/libapputils/src/main/java/cc/winboll/studio/libapputils/app/AppVersionUtils.java +++ b/libapputils/src/main/java/cc/winboll/studio/libapputils/app/AppVersionUtils.java @@ -5,7 +5,7 @@ package cc.winboll.studio.libapputils.app; * @Date 2024/08/12 14:45:35 * @Describe 应用版本工具集 */ -import com.hjq.toast.ToastUtils; +import cc.winboll.studio.libapputils.log.LogUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -23,6 +23,7 @@ public class AppVersionUtils { // true 新版本 == 当前版本 // public static boolean isHasNewVersion2(String szCurrentName, String szNextName) { + LogUtils.d(TAG, String.format("isHasNewVersion2\nszCurrentName : %s\nszNextName : %s", szCurrentName, szNextName)); //szCurrentName = "AES_6.2.0-beta0_3234.apk"; //szNextName = "AES_6.1.12.apk"; //szCurrentName = "AES_6.2.0-beta0_3234.apk"; @@ -77,8 +78,9 @@ public class AppVersionUtils { //LogUtils.d(TAG, "App version is the newest. "); return false; } - + public static boolean isHasNewStageReleaseVersion(String szCurrentName, String szNextName) { + LogUtils.d(TAG, String.format("isHasNewStageReleaseVersion\nszCurrentName : %s\nszNextName : %s", szCurrentName, szNextName)); //szCurrentName = "AES_6.2.12.apk"; //szNextName = "AES_6.3.12.apk"; if (checkNewVersion(getCodeInPackageName(szCurrentName), getCodeInPackageName(szNextName))) { @@ -96,6 +98,10 @@ public class AppVersionUtils { // 返回 :true 新版本 > 当前版本 // public static Boolean checkNewVersion(String szCurrentCode, String szNextCode) { + if (szCurrentCode == null || szCurrentCode.equals("") || szNextCode == null || szNextCode.equals("")) { + LogUtils.d(TAG, String.format("checkNewVersion unexpected parameters:\nszCurrentCode : %s\nszNextCode : %s", szCurrentCode, szNextCode)); + return false; + } boolean isNew = false; String[] appVersionCurrent = szCurrentCode.split("\\."); String[] appVersionNext = szNextCode.split("\\."); @@ -106,7 +112,7 @@ public class AppVersionUtils { if (Integer.parseInt(appVersionNext[i]) > Integer.parseInt(appVersionCurrent[i])) { isNew = true; return isNew; - } else if(Integer.parseInt(appVersionNext[i]) == Integer.parseInt(appVersionCurrent[i])) { + } else if (Integer.parseInt(appVersionNext[i]) == Integer.parseInt(appVersionCurrent[i])) { continue ; } else { isNew = false; @@ -122,14 +128,17 @@ public class AppVersionUtils { // 如 :AppUtils_7.0.4.apk 版本号为 7.0.4 // public static String getCodeInPackageName(String apkName) { + LogUtils.d(TAG, String.format("getCodeInPackageName apkName : %s", apkName)); //String apkName = "AppUtils_7.0.0.apk"; Pattern pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+"); Matcher matcher = pattern.matcher(apkName); if (matcher.find()) { String version = matcher.group(); + LogUtils.d(TAG, String.format("version is %s", version)); return version; //System.out.println("Version number: " + version); // 输出:7.0.0 } + LogUtils.d(TAG, String.format("No result.")); return ""; } @@ -149,5 +158,4 @@ public class AppVersionUtils { } return ""; } - } diff --git a/libapputils/src/main/java/cc/winboll/studio/libapputils/view/AboutView.java b/libapputils/src/main/java/cc/winboll/studio/libapputils/view/AboutView.java index de4be07..8499dca 100644 --- a/libapputils/src/main/java/cc/winboll/studio/libapputils/view/AboutView.java +++ b/libapputils/src/main/java/cc/winboll/studio/libapputils/view/AboutView.java @@ -58,18 +58,22 @@ public class AboutView extends LinearLayout { String mszGitea = ""; int mnAppIcon = 0; String mszWinBollServerHost; - String mszReleaseAPKName; + //String mszReleaseAPKName; EditText metDevUserName; EditText metDevUserPassword; public AboutView(Context context, APPInfo appInfo) { super(context); + mContext = context; + setAPPInfo(appInfo); initView(context); } public AboutView(Context context, AttributeSet attrs) { super(context, attrs); + mContext = context; + initView(context, attrs); } @@ -92,8 +96,6 @@ public class AboutView extends LinearLayout { } void initView(Context context) { - mContext = context; - mszAppName = mAPPInfo.getAppName(); mszAppAPKFolderName = mAPPInfo.getAppAPKFolderName(); mszAppAPKName = mAPPInfo.getAppAPKName(); @@ -101,14 +103,14 @@ public class AboutView extends LinearLayout { mszAppDescription = mAPPInfo.getAppDescription(); mnAppIcon = mAPPInfo.getAppIcon(); - mszWinBollServerHost = WinBollUtils.isDebug() ? "http://10.8.0.13": "https://www.winboll.cc"; + mszWinBollServerHost = WinBollUtils.isDebug() ? "https://dev.winboll.cc": "https://www.winboll.cc"; try { mszAppVersionName = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); } - mszCurrentAppPackageName = mszAppName + "_" + mszAppVersionName + ".apk"; + mszCurrentAppPackageName = mszAppAPKName + "_" + mszAppVersionName + ".apk"; mszHomePage = mszWinBollServerHost + "/studio/details.php?app=" + mszAppAPKFolderName; mszGitea = "https://gitea.winboll.cc/Studio/" + mszAppGitName + ".git"; @@ -146,15 +148,16 @@ public class AboutView extends LinearLayout { //llMain.addView(createAboutPage()); // 就读取正式版应用包版本号,设置 Release 应用包文件名 - String szReleaseAppVersionName = ""; - try { - szReleaseAppVersionName = mContext.getPackageManager().getPackageInfo(subBetaSuffix(mContext.getPackageName()), 0).versionName; - } catch (PackageManager.NameNotFoundException e) { - LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); - } - mszReleaseAPKName = mszAppAPKName + "_" + szReleaseAppVersionName + ".apk"; - - +// String szReleaseAppVersionName = ""; +// try { +// //LogUtils.d(TAG, String.format("mContext.getPackageName() %s", mContext.getPackageName())); +// String szSubBetaSuffix = subBetaSuffix(mContext.getPackageName()); +// //LogUtils.d(TAG, String.format("szSubBetaSuffix : %s", szSubBetaSuffix)); +// szReleaseAppVersionName = mContext.getPackageManager().getPackageInfo(szSubBetaSuffix, 0).versionName; +// } catch (PackageManager.NameNotFoundException e) { +// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); +// } +// mszReleaseAPKName = mszAppAPKName + "_" + szReleaseAppVersionName + ".apk"; } void initView(Context context, AttributeSet attrs) { @@ -181,10 +184,13 @@ public class AboutView extends LinearLayout { return; }*/ - if (!AppVersionUtils.isHasNewStageReleaseVersion(mszReleaseAPKName, mszNewestAppPackageName)) { +// if (!AppVersionUtils.isHasNewStageReleaseVersion(mszReleaseAPKName, mszNewestAppPackageName)) { +// ToastUtils.delayedShow("Current app is the newest.", 5000); +// } + if (!AppVersionUtils.isHasNewVersion2(mszCurrentAppPackageName, mszNewestAppPackageName)) { ToastUtils.delayedShow("Current app is the newest.", 5000); } else { - String szMsg = "Current app is :\n[ " + mszReleaseAPKName + String szMsg = "Current app is :\n[ " + mszCurrentAppPackageName + " ]\nThe last app is :\n[ " + mszNewestAppPackageName + " ]\nIs download the last app?"; YesNoAlertDialog.show(mContext, "Application Update Prompt", szMsg, mIsDownlaodUpdateListener);