From dd2f98c809927ca8acd416437da853583555d9ea Mon Sep 17 00:00:00 2001 From: AzenKain Date: Sun, 7 Jun 2026 13:20:59 +0700 Subject: [PATCH] feat: optimaze --- .idea/misc.xml | 1 + app/libs/firefly-go.aar | 4 +- app/src/main/AndroidManifest.xml | 2 + .../firefly_go_android/MainActivity.kt | 48 ++++++++++++++++++- app/src/main/res/raw/app_version_json.json | 4 +- script/release.json | 4 +- 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 6c5519f..3b0be22 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,3 +1,4 @@ + diff --git a/app/libs/firefly-go.aar b/app/libs/firefly-go.aar index 5ec13b7..04f0f5e 100644 --- a/app/libs/firefly-go.aar +++ b/app/libs/firefly-go.aar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0c8cc86eec51f87992f03922fdeb19a6145077f6afc0438aae55846f604500bf -size 14066552 +oid sha256:f022a4b1d6868486a6592e69570c92c1cc7b0f4ec932cb7d88408ab3c5557424 +size 13952548 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c123ba3..5a272d7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,6 +15,8 @@ + = 33) { + packageManager.getPackageInfo(packageName, android.content.pm.PackageManager.PackageInfoFlags.of(0)).longVersionCode + } else { + @Suppress("DEPRECATION") + packageManager.getPackageInfo(packageName, 0).versionCode.toLong() + } + } catch (e: Exception) { + 1L + } + val lastVersion = sharedPrefs.getLong("last_version_code", 0L) + val shouldOverride = currentVersion > lastVersion + + copyRawToFile(dataDir, shouldOverride) + + if (shouldOverride) { + sharedPrefs.edit().putLong("last_version_code", currentVersion).apply() + } val jsonString = resources.openRawResource(R.raw.app_version_json).use { input -> input.bufferedReader().use { it.readText() } @@ -142,6 +161,27 @@ fun requestInstallPermission(context: Context) { } } } + +fun requestStoragePermission(context: Context) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + if (!Environment.isExternalStorageManager()) { + try { + val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).apply { + data = "package:${context.packageName}".toUri() + } + context.startActivity(intent) + Toast.makeText(context, "Please allow All Files Access to load game data", Toast.LENGTH_LONG).show() + } catch (e: Exception) { + try { + val intent = Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION) + context.startActivity(intent) + } catch (ex: Exception) { + Log.e("StoragePermission", "Failed to open settings", ex) + } + } + } + } +} fun copyRawToFile(targetDir: File, override: Boolean = false): Boolean { val files = listOf( "assets/data-in-game.json" to "data-in-game.json", @@ -317,7 +357,8 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi // Widget icons row Row( - horizontalArrangement = Arrangement.spacedBy(32.dp), + modifier = Modifier.fillMaxWidth(0.85f), + horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically ) { @@ -325,6 +366,7 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier + .width(80.dp) .clickable { showUpdateDialog = true } .background( Color.White.copy(alpha = 0.8f), @@ -352,6 +394,7 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier + .width(80.dp) .clickable { showResetDialog = true } .background( Color.White.copy(alpha = 0.8f), @@ -379,6 +422,7 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi Column( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier + .width(80.dp) .clickable { showLogs = true // mở popup log } diff --git a/app/src/main/res/raw/app_version_json.json b/app/src/main/res/raw/app_version_json.json index cebdf2d..3f4d797 100644 --- a/app/src/main/res/raw/app_version_json.json +++ b/app/src/main/res/raw/app_version_json.json @@ -1,5 +1,5 @@ { - "latest_version": "4.3.1-01", + "latest_version": "4.3.1-02", "changelog": "UPDATE: 4.3.5X", - "apk_url": "https://git.kain.io.vn/Firefly-Shelter/FireflyGo_Android/releases/download/4.3.1-01/firefly_go_android.apk" + "apk_url": "https://git.kain.io.vn/Firefly-Shelter/FireflyGo_Android/releases/download/4.3.1-02/firefly_go_android.apk" } \ No newline at end of file diff --git a/script/release.json b/script/release.json index e4eee9a..4b69a64 100644 --- a/script/release.json +++ b/script/release.json @@ -1,5 +1,5 @@ { - "tag": "4.3.1-01", - "title": "PreBuild Version 4.3.51 - 01" + "tag": "4.3.1-02", + "title": "PreBuild Version 4.3.51 - 02" } \ No newline at end of file