Skip to content

Commit

Permalink
新增 Android 13及以上版本中的“单色主题图标”的适配。
Browse files Browse the repository at this point in the history
新增 通过汽水音乐平台缓存在本地的JSON文件,读取歌单数据。
新增 在进行部分较长时间的操作时,若用户尝试返回,则会弹出Toast“请等待操作完成”。
新增 加载歌单列表、歌单列表为空时的提示文案。
新增、优化 部分文案及其对应的翻译。
优化 应用图标的样式与清晰度。
优化 转换页,页面间跳转的逻辑。
优化 部分变量初始化的时机。
优化 自动清理过期数据时,也能删除目录。
优化 删除无用的变量。
修复 转换页,点击下一步按钮后。数据获取完成时,设备可能会震动多次的问题。
修复 启用“使用Root权限”时,若未安装对应平台的App,点击下一步时后,弹出的对话框中缺失了平台名称的问题。
修复 若设备未连接互联网或网络状况不佳,尝试进行扫码登录酷狗音乐,应用会闪退的问题。
修复 应用的主数据库可能会被错误关闭的问题。
修复 转换页,若已选择了数据库文件,此时再将“歌单获取方式”改为“在线”,“已选择”项未被隐藏的问题。

Added: Adaptation of “Monochrome Theme Icons” in Android 13 and above versions.
Added: Reading playlist data through JSON files cached locally by the Soda Music platform.
Added: When performing some longer operations, if the user tries to return, a Toast will pop up saying “Please wait for the operation to complete”.
Added: Prompt copywriting when loading the playlist list and when the playlist list is empty.
Added/Optimized: Some copywriting and their corresponding translations.
Optimized: The style and clarity of the application icon.
Optimized: The logic of page jumps on the conversion page.
Optimized: The timing of some variable initialization.
Optimized: When automatically cleaning up expired data, directories can also be deleted.
Optimized: Removed useless variables.
Fixed: On the conversion page, after clicking the next step button, the device may vibrate multiple times when data acquisition is completed.
Fixed: When “Use Root Permissions” is enabled, if the corresponding platform App is not installed, the platform name is missing in the dialog box that pops up after clicking next.
Fixed: If the device is not connected to the Internet or the network condition is poor, trying to log in to Kugou Music by scanning the code, the application will crash.
Fixed: The main database of the application may be closed incorrectly.
Fixed: On the conversion page, if a database file has been selected, and then the “Playlist Acquisition Method” is changed to “Online”, the “Selected” item is not hidden.
  • Loading branch information
Winnie0408 committed May 9, 2024
1 parent 3b7e78c commit 0c18b86
Show file tree
Hide file tree
Showing 31 changed files with 766 additions and 323 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
minSdk = 26
// targetSdk = 28
targetSdk = 34
versionCode = 54
versionName = "1.3.9"
versionCode = 55
versionName = "1.4.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -67,6 +67,7 @@ dependencies {
implementation("androidx.compose.material:material")
implementation("androidx.compose.material3:material3")
implementation("androidx.annotation:annotation:1.7.1")
implementation("androidx.documentfile:documentfile:1.0.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions app/src/main/java/com/hwinzniej/musichelper/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import java.util.Locale
class MainActivity : ComponentActivity() {

private lateinit var openDirectoryLauncher: ActivityResultLauncher<Uri?>
private lateinit var openLunaJSONDirLauncher: ActivityResultLauncher<Uri?>
private lateinit var openEncryptDirectoryLauncher: ActivityResultLauncher<Uri?>
private lateinit var openDecryptDirectoryLauncher: ActivityResultLauncher<Uri?>
private lateinit var openMusicPlatformSqlFileLauncher: ActivityResultLauncher<Array<String>>
Expand Down Expand Up @@ -156,6 +157,10 @@ class MainActivity : ComponentActivity() {
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri ->
scanPage.handleUri(uri)
}
openLunaJSONDirLauncher =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri ->
convertPage.handelLunaDirUri(uri)
}
openEncryptDirectoryLauncher =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri ->
unlockPage.handleSelectedInputPath(uri)
Expand Down Expand Up @@ -214,6 +219,7 @@ class MainActivity : ComponentActivity() {
openMusicPlatformSqlFileLauncher = openMusicPlatformSqlFileLauncher,
openResultSqlFileLauncher = openResultSqlFileLauncher,
openPlaylistFileLauncher = openPlaylistFileLauncher,
openLunaJSONDirLauncher = openLunaJSONDirLauncher,
db = db,
componentActivity = this,
encryptServer = settingsPage.encryptServer,
Expand Down
243 changes: 206 additions & 37 deletions app/src/main/java/com/hwinzniej/musichelper/activity/ConvertPage.kt

Large diffs are not rendered by default.

166 changes: 109 additions & 57 deletions app/src/main/java/com/hwinzniej/musichelper/ui/ConvertPageUi.kt

Large diffs are not rendered by default.

82 changes: 64 additions & 18 deletions app/src/main/java/com/hwinzniej/musichelper/utils/Tools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Bitmap
import android.net.Uri
import android.provider.OpenableColumns
import androidx.documentfile.provider.DocumentFile
import com.alibaba.fastjson2.JSON
import com.alibaba.fastjson2.JSONObject
import com.google.zxing.BarcodeFormat
Expand Down Expand Up @@ -77,6 +78,45 @@ class Tools {
return outputFile.absolutePath
}

fun copyFilesToExternalFilesDir(
uri: Uri,
context: Context,
dirName: String,
clean: Boolean = false
): String {
val directory = DocumentFile.fromTreeUri(context, uri)
val files = directory?.listFiles()
if (clean) {
val externalFilesDir =
File("${context.getExternalFilesDir(null)?.absolutePath}/${dirName}")
if (externalFilesDir.isDirectory)
externalFilesDir.listFiles()?.forEach { file ->
file.delete()
}
}

files?.forEach { file ->
if (file.isFile) {
val inputStream: InputStream? = context.contentResolver.openInputStream(file.uri)
val outputFile = File(
"${context.getExternalFilesDir(null)?.absolutePath}/${dirName}",
file.name ?: ""
)
if (outputFile.parentFile?.exists() == false) {
outputFile.parentFile?.mkdirs()
}
val outputStream: OutputStream = FileOutputStream(outputFile)

inputStream?.use { input ->
outputStream.use { output ->
input.copyTo(output)
}
}
}
}
return directory?.name ?: ""
}

fun deleteOldFiles(context: Context) {
val directory = context.getExternalFilesDir(null)
val currentTime = System.currentTimeMillis()
Expand All @@ -86,7 +126,7 @@ class Tools {
val fileAgeInDays = TimeUnit.MILLISECONDS.toDays(fileAge)

if (fileAgeInDays > 3) {
file.delete()
file.deleteRecursively()
}
}
}
Expand Down Expand Up @@ -381,10 +421,9 @@ class Tools {
)
.get()
.build()

return JSON.parseObject(
client.newCall(request).execute().body?.string()
)
client.newCall(request).execute().use {
return JSON.parseObject(it.body?.string())
}
}

fun copyAssetFileToExternalFilesDir(context: Context, filename: String) {
Expand All @@ -399,7 +438,7 @@ class Tools {
if (outFile.exists()) {
outFile.delete()
}
outputStream = FileOutputStream(outFile)
outputStream = FileOutputStream(outFile, false)

val buffer = ByteArray(1024)
var read: Int
Expand Down Expand Up @@ -507,18 +546,25 @@ class Tools {
}

fun getCurrentIp(): String {
val client = OkHttpClient()
var request = Request.Builder()
request = request.url("https://myip.ipip.net/s").get()
var currentIp =
client.newCall(request.build()).execute().body?.string()?.replace("\n", "")
if (currentIp == null) {
request = Request.Builder()
request = request.url("https://ip.3322.net").get()
currentIp =
client.newCall(request.build()).execute().body?.string()?.replace("\n", "")
if (currentIp == null)
currentIp = "1.180.115.20"
var currentIp: String
try {
val client = OkHttpClient()
var request = Request.Builder()
request = request.url("https://myip.ipip.net/s").get()
client.newCall(request.build()).execute().use {
currentIp = it.body?.string()?.replace("\n", "") ?: ""
}
if (currentIp.isBlank()) {
request = Request.Builder()
request = request.url("https://ip.3322.net").get()
client.newCall(request.build()).execute().use {
currentIp = it.body?.string()?.replace("\n", "") ?: ""
}
if (currentIp.isBlank())
currentIp = "1.180.115.20"
}
} catch (e: Exception) {
currentIp = "1.180.115.20"
}
return currentIp
}
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

170 changes: 0 additions & 170 deletions app/src/main/res/drawable/ic_launcher_background.xml

This file was deleted.

Loading

0 comments on commit 0c18b86

Please sign in to comment.