diff --git a/app_pojavlauncher/src/main/java/com/firefly/feature/UpdateLauncher.java b/app_pojavlauncher/src/main/java/com/firefly/feature/UpdateLauncher.java index a3b476fe1..be0bfe40c 100644 --- a/app_pojavlauncher/src/main/java/com/firefly/feature/UpdateLauncher.java +++ b/app_pojavlauncher/src/main/java/com/firefly/feature/UpdateLauncher.java @@ -35,16 +35,14 @@ public class UpdateLauncher { private Context context; private int localVersionCode; - // 构造函数直接获取资源中的 base_version_code public UpdateLauncher(Context context) { this.context = context; - // 从资源中获取 base_version_code(处理为 string 并转换为 int) try { String versionCodeString = context.getString(R.string.base_version_code); this.localVersionCode = Integer.parseInt(versionCodeString); } catch (NumberFormatException e) { e.printStackTrace(); - this.localVersionCode = 0; // 转换失败 + this.localVersionCode = 0; } } @@ -73,11 +71,11 @@ protected void onPostExecute(JSONObject result) { if (result != null) { try { int remoteVersionCode = Integer.parseInt(result.getString("tag_name").replaceAll("[^\\d]", "")); - // 比较 GitHub 获取的版本号和本地版本号 + String version = String.valueOf(localVersionCode); if (remoteVersionCode > localVersionCode) { showUpdateDialog(result); } else { - Toast.makeText(context, "已经是最新版本", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, context.getString(R.string.pgw_settings_updatelauncher_updated, version), Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { e.printStackTrace(); @@ -94,11 +92,11 @@ private void showUpdateDialog(JSONObject releaseInfo) { String archModel = getArchModel(); AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle("检测到更新" + versionName) + builder.setTitle(context.getString(R.string.pgw_settings_updatelauncher_new_version, versionName)) .setMessage(releaseNotes) .setCancelable(true) - .setPositiveButton("更新", (dialog, id) -> showDownloadSourceDialog(tagName, versionName, archModel)) - .setNegativeButton("忽略", (dialog, id) -> dialog.cancel()) + .setPositiveButton(R.string.pgw_settings_updatelauncher_update, (dialog, id) -> showDownloadSourceDialog(tagName, versionName, archModel)) + .setNegativeButton(R.string.pgw_settings_updatelauncher_cancel, (dialog, id) -> dialog.cancel()) .show(); } catch (JSONException e) { e.printStackTrace(); @@ -110,7 +108,7 @@ private void showDownloadSourceDialog(String tagName, String versionName, String String githubUrl = String.format(GITHUB_RELEASE_URL, tagName, versionName, archModel); AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle("选择下载源") + builder.setTitle(R.string.pgw_settings_updatelauncher_source) .setCancelable(false) .setSingleChoiceItems(downloadSources, -1, (dialog, which) -> { String selectedSource = downloadSources[which]; @@ -131,7 +129,7 @@ private void showDownloadSourceDialog(String tagName, String versionName, String startDownload(apkUrl); } }) - .setNegativeButton("取消", (dialog, id) -> dialog.cancel()) + .setNegativeButton(R.string.alertdialog_cancel, (dialog, id) -> dialog.cancel()) .show(); } @@ -146,7 +144,7 @@ private class DownloadApkTask extends AsyncTask { protected void onPreExecute() { progressDialog = new ProgressDialog(context); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); - progressDialog.setTitle("下载更新"); + progressDialog.setTitle(R.string.pgw_settings_updatelauncher_downloading); progressDialog.setCancelable(false); progressDialog.show(); } @@ -197,7 +195,7 @@ protected void onPostExecute(File apkFile) { if (apkFile != null) { installApk(apkFile); } else { - Toast.makeText(context, "下载失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, context.getString(R.string.pgw_settings_updatelauncher_download_fail), Toast.LENGTH_SHORT).show(); } } } diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceExperimentalFragment.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceExperimentalFragment.java index f1cba5558..077b29fe2 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceExperimentalFragment.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceExperimentalFragment.java @@ -291,6 +291,7 @@ private void loadMesaList() { private void downloadMesa(String version) { AlertDialog dialog = new AlertDialog.Builder(requireContext()) .setMessage(R.string.preference_rendererexp_mesa_downloading) + .setCancelable(false) .show(); PojavApplication.sExecutorService.execute(() -> { boolean data = MesaUtils.INSTANCE.downloadMesa(version); diff --git a/app_pojavlauncher/src/main/res/values-zh-rCN/pgw_strings.xml b/app_pojavlauncher/src/main/res/values-zh-rCN/pgw_strings.xml index 0077cd382..50c31290a 100644 --- a/app_pojavlauncher/src/main/res/values-zh-rCN/pgw_strings.xml +++ b/app_pojavlauncher/src/main/res/values-zh-rCN/pgw_strings.xml @@ -124,5 +124,13 @@ 允许自定义Mesa图形驱动程序(目前仅Freedreno) 如果需要,您可以自由选择处理方法 选择Mesa图形驱动程序 + + 已经是最新版本 %s + 新版本 %s 可用,准备更新 + 更新 + 忽略 + 选择更新源 + 正在下载安装包 + 下载失败 \ No newline at end of file diff --git a/app_pojavlauncher/src/main/res/values-zh-rTW/pgw_strings.xml b/app_pojavlauncher/src/main/res/values-zh-rTW/pgw_strings.xml index 1797d013a..90d73f4bd 100644 --- a/app_pojavlauncher/src/main/res/values-zh-rTW/pgw_strings.xml +++ b/app_pojavlauncher/src/main/res/values-zh-rTW/pgw_strings.xml @@ -124,5 +124,13 @@ 允許自訂Mesa圖形驅動程序(目前僅Freedreno) 如果需要,您可以自由選擇處理方法 選擇Mesa圖形驅動程序 + + 已經是最新版本 %s + 新版本 %s 可用,準備更新 + 更新 + 忽略 + 選擇更新來源 + 正在下載安裝包 + 下載失敗 \ No newline at end of file diff --git a/app_pojavlauncher/src/main/res/values/pgw_strings.xml b/app_pojavlauncher/src/main/res/values/pgw_strings.xml index d90957dd3..04acdd0a1 100644 --- a/app_pojavlauncher/src/main/res/values/pgw_strings.xml +++ b/app_pojavlauncher/src/main/res/values/pgw_strings.xml @@ -124,5 +124,13 @@ Enable Custom Mesa Load Driver Override(Only for Freedreno) If need, you can freely choose processing method Choose Mesa Loader Driver Override + + Is already the latest version %s + A new version %s is available for updating + Update + Ignore + Select Update Source + Downloading installation package + Download failed \ No newline at end of file