Compare commits

..

4 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
Kain344 55ab8136f3 feat: update version to 4.3.2-01 and changelog
Build / build (push) Successful in 5m13s
2026-06-09 19:32:34 +07:00
Kain344 dd2f98c809 feat: optimaze
Build / build (push) Successful in 5m41s
2026-06-07 13:20:59 +07:00
7 changed files with 139 additions and 38 deletions
+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)
} }
BIN
View File
Binary file not shown.
+2
View File
@@ -15,6 +15,8 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"
tools:ignore="RequestInstallPackagesPolicy" /> tools:ignore="RequestInstallPackagesPolicy" />
<uses-permission android:name="android.permission.READ_LOGS"/> <uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<application <application
+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"
} }
} }
@@ -85,21 +85,60 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
requestBatteryExemption(this) requestBatteryExemption(this)
requestInstallPermission(this) requestInstallPermission(this)
requestStoragePermission(this)
val appDataPath = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "FireflyGo").absolutePath val appDataPath = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "FireflyGo").absolutePath
val dataDir = File("$appDataPath/data") val dataDir = File("$appDataPath/data")
if (!dataDir.exists()) dataDir.mkdirs() if (!dataDir.exists()) dataDir.mkdirs()
copyRawToFile(dataDir) val sharedPrefs = getSharedPreferences("AppPrefs", MODE_PRIVATE)
val jsonString = resources.openRawResource(R.raw.app_version_json).use { input -> // Lấy thông tin Package
input.bufferedReader().use { it.readText() } val packageInfo = if (Build.VERSION.SDK_INT >= 33) {
packageManager.getPackageInfo(packageName, android.content.pm.PackageManager.PackageInfoFlags.of(0))
} else {
@Suppress("DEPRECATION")
packageManager.getPackageInfo(packageName, 0)
} }
val jsonObject = JSONObject(jsonString) val currentVersionCode = if (Build.VERSION.SDK_INT >= 33) packageInfo.longVersionCode else packageInfo.versionCode.toLong()
val latestVersion = jsonObject.getString("latest_version") val currentLastUpdateTime = packageInfo.lastUpdateTime
val changelog = jsonObject.getString("changelog")
val apkUrl = jsonObject.getString("apk_url") 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) {
"{}"
}
val jsonObject = if (jsonString.isNotEmpty()) JSONObject(jsonString) else JSONObject()
val latestVersion = jsonObject.optString("latest_version", "1.0.0")
val changelog = jsonObject.optString("changelog", "")
val apkUrl = jsonObject.optString("apk_url", "")
val appVersion = AppVersion(latestVersion, changelog, apkUrl) val appVersion = AppVersion(latestVersion, changelog, apkUrl)
@@ -142,27 +181,47 @@ fun requestInstallPermission(context: Context) {
} }
} }
} }
fun copyRawToFile(targetDir: File, override: Boolean = false): Boolean {
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(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()
@@ -172,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
} }
} }
@@ -317,7 +377,8 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi
// Widget icons row // Widget icons row
Row( Row(
horizontalArrangement = Arrangement.spacedBy(32.dp), modifier = Modifier.fillMaxWidth(0.85f),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
@@ -325,6 +386,7 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier modifier = Modifier
.width(80.dp)
.clickable { showUpdateDialog = true } .clickable { showUpdateDialog = true }
.background( .background(
Color.White.copy(alpha = 0.8f), Color.White.copy(alpha = 0.8f),
@@ -352,6 +414,7 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier modifier = Modifier
.width(80.dp)
.clickable { showResetDialog = true } .clickable { showResetDialog = true }
.background( .background(
Color.White.copy(alpha = 0.8f), Color.White.copy(alpha = 0.8f),
@@ -379,6 +442,7 @@ fun ServerControlScreen(appDataPath: String, dataDir: File, appVersion: AppVersi
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier modifier = Modifier
.width(80.dp)
.clickable { .clickable {
showLogs = true // mở popup log showLogs = true // mở popup log
} }
@@ -427,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()
@@ -611,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) }
@@ -653,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.1-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.1-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 -3
View File
@@ -1,5 +1,4 @@
{ {
"tag": "4.3.1-01", "tag": "4.3.2-02",
"title": "PreBuild Version 4.3.51 - 01" "title": "PreBuild Version 4.3.52 - 02"
} }