Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55ab8136f3 | |||
| dd2f98c809 |
Generated
+1
@@ -1,3 +1,4 @@
|
|||||||
|
<?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">
|
||||||
|
|||||||
BIN
Binary file not shown.
@@ -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
|
||||||
|
|||||||
@@ -85,12 +85,31 @@ 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 currentVersion = try {
|
||||||
|
if (Build.VERSION.SDK_INT >= 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 ->
|
val jsonString = resources.openRawResource(R.raw.app_version_json).use { input ->
|
||||||
input.bufferedReader().use { it.readText() }
|
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 {
|
fun copyRawToFile(targetDir: File, override: Boolean = false): Boolean {
|
||||||
val files = listOf(
|
val files = listOf(
|
||||||
"assets/data-in-game.json" to "data-in-game.json",
|
"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
|
// 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 +366,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 +394,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 +422,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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"latest_version": "4.3.1-01",
|
"latest_version": "4.3.2-01",
|
||||||
"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-01/firefly_go_android.apk"
|
||||||
}
|
}
|
||||||
+2
-3
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"tag": "4.3.1-01",
|
"tag": "4.3.2-01",
|
||||||
"title": "PreBuild Version 4.3.51 - 01"
|
"title": "PreBuild Version 4.3.52 - 01"
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user