mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-20 22:41:38 +02:00
refactor(android): drop SDK checks below minSdk 24
Flutter 3.47.7 sets flutter.minSdkVersion to 24, which android/app/build.gradle.kts uses as minSdk. The N (24) checks around StorageManager.storageVolumes and the LOLLIPOP (21) check around finishAndRemoveTask were therefore always true, and their else branches could never run. Keep the true-branch bodies. Checks for API levels above 24 are unchanged.
This commit is contained in:
1 parent
8aca5e4ef2
commit
fcec0942b9
1 file changed
+8
-24
@@ -216,22 +216,14 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
payload.put("tree_uri", uri.toString())
|
||||
payload.put("display_name", resolveSafDisplayPath(uri))
|
||||
val storageId = resolveSafStorageId(uri)
|
||||
val volume = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
getSystemService(StorageManager::class.java).storageVolumes.firstOrNull {
|
||||
(storageId == "primary" && it.isPrimary) ||
|
||||
(!it.uuid.isNullOrBlank() && it.uuid.equals(storageId, ignoreCase = true))
|
||||
}
|
||||
} else {
|
||||
null
|
||||
val volume = getSystemService(StorageManager::class.java).storageVolumes.firstOrNull {
|
||||
(storageId == "primary" && it.isPrimary) ||
|
||||
(!it.uuid.isNullOrBlank() && it.uuid.equals(storageId, ignoreCase = true))
|
||||
}
|
||||
payload.put("volume_id", storageId ?: JSONObject.NULL)
|
||||
payload.put(
|
||||
"is_removable",
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
volume?.isRemovable ?: (storageId != null && storageId != "primary")
|
||||
} else {
|
||||
storageId != null && storageId != "primary"
|
||||
},
|
||||
volume?.isRemovable ?: (storageId != null && storageId != "primary"),
|
||||
)
|
||||
deliver(payload.toString())
|
||||
}
|
||||
@@ -264,13 +256,9 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
val prefix = if (storageId == "primary") {
|
||||
"/storage/emulated/0"
|
||||
} else {
|
||||
val volumeName = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
getSystemService(StorageManager::class.java).storageVolumes
|
||||
.firstOrNull { it.uuid.equals(storageId, ignoreCase = true) }
|
||||
?.getDescription(this)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val volumeName = getSystemService(StorageManager::class.java).storageVolumes
|
||||
.firstOrNull { it.uuid.equals(storageId, ignoreCase = true) }
|
||||
?.getDescription(this)
|
||||
volumeName?.takeIf { it.isNotBlank() } ?: "External storage"
|
||||
}
|
||||
|
||||
@@ -1147,11 +1135,7 @@ class MainActivity: FlutterFragmentActivity() {
|
||||
}
|
||||
"exitApp" -> {
|
||||
flutterBackCallback?.isEnabled = false
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
finishAndRemoveTask()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
finishAndRemoveTask()
|
||||
result.success(null)
|
||||
}
|
||||
"downloadByStrategy" -> {
|
||||
|
||||
Reference in new issue
Block a user