Compare commits

...

2 Commits

Author SHA1 Message Date
Kain344 8c1b105942 feat: fix bug
Build / build (push) Successful in 5m3s
2026-06-10 10:23:04 +07:00
Kain344 ee390c249a feat: fix bug
Build / build (push) Successful in 10m28s
2026-06-10 10:13:47 +07:00
6 changed files with 106 additions and 51 deletions
-1
View File
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-21" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
+2 -3
View File
@@ -22,8 +22,8 @@ android {
applicationId = "com.kain344.firefly_go_android" applicationId = "com.kain344.firefly_go_android"
minSdk = 24 minSdk = 24
targetSdk = 35 targetSdk = 35
versionCode = 1 versionCode = 2
versionName = "1.0" versionName = "1.0.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@@ -100,4 +100,3 @@ dependencies {
implementation(libs.slf4j.android) implementation(libs.slf4j.android)
} }
+42
View File
@@ -6,6 +6,13 @@
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd", "lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff" "ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
}, },
"CNBETAAndroid4.3.52": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15318724_a7af31327e74_b3328eb95329b2",
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15305751_09783637ccc4_d16f9c81138ab3",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
},
"CNBETAWin4.3.51": { "CNBETAWin4.3.51": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf", "asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3", "asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3",
@@ -13,6 +20,13 @@
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd", "lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff" "ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
}, },
"CNBETAWin4.3.52": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15318724_a7af31327e74_b3328eb95329b2",
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15305751_09783637ccc4_d16f9c81138ab3",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
},
"CNBETAiOS4.3.51": { "CNBETAiOS4.3.51": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf", "asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3", "asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3",
@@ -20,6 +34,13 @@
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd", "lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff" "ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
}, },
"CNBETAiOS4.3.52": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15318724_a7af31327e74_b3328eb95329b2",
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15305751_09783637ccc4_d16f9c81138ab3",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
},
"OSBETAAndroid4.3.51": { "OSBETAAndroid4.3.51": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf", "asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3", "asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3",
@@ -27,6 +48,13 @@
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd", "lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff" "ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
}, },
"OSBETAAndroid4.3.52": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15318724_a7af31327e74_b3328eb95329b2",
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15305751_09783637ccc4_d16f9c81138ab3",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
},
"OSBETAWin4.3.51": { "OSBETAWin4.3.51": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf", "asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3", "asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3",
@@ -34,11 +62,25 @@
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd", "lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff" "ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
}, },
"OSBETAWin4.3.52": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15318724_a7af31327e74_b3328eb95329b2",
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15305751_09783637ccc4_d16f9c81138ab3",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
},
"OSBETAiOS4.3.51": { "OSBETAiOS4.3.51": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf", "asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15261247_f6e6db2125cf_369da465b36faf",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3", "asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15235885_6091fd15561a_83828f542dc1f3",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15265964_c2fbb1eb05fc_f2238199ee2b6e", "ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15265964_c2fbb1eb05fc_f2238199ee2b6e",
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd", "lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15242148_d40f856defc0_599b68a0adf7bd",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff" "ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
},
"OSBETAiOS4.3.52": {
"asset_bundle_url": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"asset_bundle_url_b": "https://autopatchos.starrails.com/asb/BetaLive/output_15305566_fea016d35145_54bbf8ab4009f5",
"ex_resource_url": "https://autopatchos.starrails.com/design_data/BetaLive/output_15318724_a7af31327e74_b3328eb95329b2",
"lua_url": "https://autopatchos.starrails.com/lua/BetaLive/output_15305751_09783637ccc4_d16f9c81138ab3",
"ifix_url": "https://autopatchos.starrails.com/ifix/BetaLive/output_15265964_799df4f0ecef_5a94550ba64cff"
} }
} }
@@ -92,33 +92,53 @@ class MainActivity : ComponentActivity() {
if (!dataDir.exists()) dataDir.mkdirs() if (!dataDir.exists()) dataDir.mkdirs()
val sharedPrefs = getSharedPreferences("AppPrefs", MODE_PRIVATE) val sharedPrefs = getSharedPreferences("AppPrefs", MODE_PRIVATE)
val currentVersion = try {
if (Build.VERSION.SDK_INT >= 33) { // Lấy thông tin Package
packageManager.getPackageInfo(packageName, android.content.pm.PackageManager.PackageInfoFlags.of(0)).longVersionCode val packageInfo = if (Build.VERSION.SDK_INT >= 33) {
} else { packageManager.getPackageInfo(packageName, android.content.pm.PackageManager.PackageInfoFlags.of(0))
@Suppress("DEPRECATION") } else {
packageManager.getPackageInfo(packageName, 0).versionCode.toLong() @Suppress("DEPRECATION")
packageManager.getPackageInfo(packageName, 0)
}
val currentVersionCode = if (Build.VERSION.SDK_INT >= 33) packageInfo.longVersionCode else packageInfo.versionCode.toLong()
val currentLastUpdateTime = packageInfo.lastUpdateTime
val savedVersionCode = sharedPrefs.getLong("last_version_code", 0L)
val savedLastUpdateTime = sharedPrefs.getLong("last_update_time", 0L)
val isFolderEmpty = dataDir.listFiles()?.isEmpty() ?: true
val shouldOverride = currentVersionCode > savedVersionCode ||
currentLastUpdateTime > savedLastUpdateTime ||
isFolderEmpty
Log.i("AppUpdate", "Code: $currentVersionCode, LastUpdate: $currentLastUpdateTime")
Log.i("AppUpdate", "SavedCode: $savedVersionCode, SavedUpdate: $savedLastUpdateTime")
Log.i("AppUpdate", "Should Override: $shouldOverride")
if (copyRawToFile(this, dataDir, shouldOverride)) {
if (shouldOverride) {
sharedPrefs.edit()
.putLong("last_version_code", currentVersionCode)
.putLong("last_update_time", currentLastUpdateTime)
.apply()
Log.i("AppUpdate", "Updated SharedPreferences with new version and time")
}
}
val jsonString = try {
resources.openRawResource(R.raw.app_version_json).use { input ->
input.bufferedReader().use { it.readText() }
} }
} catch (e: Exception) { } 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 -> val jsonObject = if (jsonString.isNotEmpty()) JSONObject(jsonString) else JSONObject()
input.bufferedReader().use { it.readText() } val latestVersion = jsonObject.optString("latest_version", "1.0.0")
} val changelog = jsonObject.optString("changelog", "")
val apkUrl = jsonObject.optString("apk_url", "")
val jsonObject = JSONObject(jsonString)
val latestVersion = jsonObject.getString("latest_version")
val changelog = jsonObject.getString("changelog")
val apkUrl = jsonObject.getString("apk_url")
val appVersion = AppVersion(latestVersion, changelog, apkUrl) val appVersion = AppVersion(latestVersion, changelog, apkUrl)
@@ -182,27 +202,26 @@ fun requestStoragePermission(context: Context) {
} }
} }
} }
fun copyRawToFile(targetDir: File, override: Boolean = false): Boolean { fun copyRawToFile(context: Context, targetDir: File, override: Boolean = false): Boolean {
val files = listOf( val files = listOf(
"assets/data-in-game.json" to "data-in-game.json", "data-in-game.json" to "data-in-game.json",
"assets/freesr-data.json" to "freesr-data.json", "freesr-data.json" to "freesr-data.json",
"assets/version.json" to "version.json" "version.json" to "version.json"
) )
return try { return try {
if (!targetDir.exists()) targetDir.mkdirs() if (!targetDir.exists()) targetDir.mkdirs()
for ((assetPath, name) in files) { for ((assetFile, outName) in files) {
val outFile = File(targetDir, name) val outFile = File(targetDir, outName)
if (outFile.exists() && !override) continue if (outFile.exists() && !override) {
Log.i("CopyRaw", "Skipping $outName (already exists and no override)")
continue
}
val inputStream = Log.i("CopyRaw", "Copying $assetFile to ${outFile.absolutePath} (Override: $override)")
MainActivity::class.java.classLoader context.assets.open(assetFile).use { input ->
?.getResourceAsStream(assetPath)
?: return false
inputStream.use { input ->
FileOutputStream(outFile).use { output -> FileOutputStream(outFile).use { output ->
input.copyTo(output) input.copyTo(output)
output.fd.sync() output.fd.sync()
@@ -212,6 +231,7 @@ fun copyRawToFile(targetDir: File, override: Boolean = false): Boolean {
true true
} catch (e: Exception) { } catch (e: Exception) {
Log.e("CopyRaw", "Error copying asset file: ${e.message}", e)
false false
} }
} }
@@ -471,7 +491,7 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi
onClick = { onClick = {
showResetDialog = false showResetDialog = false
try { try {
copyRawToFile(dataDir, true) copyRawToFile(context, dataDir, true)
Toast.makeText(context, "Data has been reset successfully", Toast.LENGTH_SHORT).show() Toast.makeText(context, "Data has been reset successfully", Toast.LENGTH_SHORT).show()
} catch (e: Exception) { } catch (e: Exception) {
Toast.makeText(context, "Reset failed: ${e.message}", Toast.LENGTH_SHORT).show() Toast.makeText(context, "Reset failed: ${e.message}", Toast.LENGTH_SHORT).show()
@@ -655,7 +675,7 @@ fun AutoUpdateDialog(
val context = LocalContext.current val context = LocalContext.current
val autoUpdaterManager = AutoUpdaterManager(context) val autoUpdaterManager = AutoUpdaterManager(context)
var update by remember { mutableStateOf<UpdateFeatures?>(null) } var update by remember { mutableStateOf<UpdateFeatures?>(null) }
var progress by remember { mutableIntStateOf(0) } var progress by remember { mutableStateOf(0) }
var showDialog by remember { mutableStateOf(false) } var showDialog by remember { mutableStateOf(false) }
var isDownloading by remember { mutableStateOf(false) } var isDownloading by remember { mutableStateOf(false) }
var downloadComplete by remember { mutableStateOf(false) } var downloadComplete by remember { mutableStateOf(false) }
@@ -697,11 +717,6 @@ fun AutoUpdateDialog(
LaunchedEffect(progress) { LaunchedEffect(progress) {
if (progress >= 100 && isDownloading) { if (progress >= 100 && isDownloading) {
downloadComplete = true downloadComplete = true
removeFile(dataDir, "data-in-game.json" )
removeFile(dataDir, "freesr-data.json")
removeFile(dataDir, "version.json")
delay(500)
} }
} }
+2 -2
View File
@@ -1,5 +1,5 @@
{ {
"latest_version": "4.3.2-01", "latest_version": "4.3.2-02",
"changelog": "UPDATE: 4.3.5X", "changelog": "UPDATE: 4.3.5X",
"apk_url": "https://git.kain.io.vn/Firefly-Shelter/FireflyGo_Android/releases/download/4.3.2-01/firefly_go_android.apk" "apk_url": "https://git.kain.io.vn/Firefly-Shelter/FireflyGo_Android/releases/download/4.3.2-02/firefly_go_android.apk"
} }
+2 -2
View File
@@ -1,4 +1,4 @@
{ {
"tag": "4.3.2-01", "tag": "4.3.2-02",
"title": "PreBuild Version 4.3.52 - 01" "title": "PreBuild Version 4.3.52 - 02"
} }