Skip to content

Commit

Permalink
优化 部分变量的判空方式。
Browse files Browse the repository at this point in the history
优化 部分文案及其对应的翻译。
修复 转换页,当歌单来源为“酷狗音乐”且获取方式为“在线”时,即使先前未进行过登录步骤,也判断为“已登录”状态的问题。
修复 转换也,当歌单来源为“汽水音乐”且获取方式为“在线”时,显示登录二维码后,获取登录状态会出现异常闪退的问题。
修复 赞赏对话框中,若设备处于横屏状态,或因屏幕高度不够,导致内容显示不全且无法上下滑动的问题。

Optimized: The way of null-checking for some variables.
Optimized: Some copywriting and their corresponding translations.
Fixed: On the conversion page, when the playlist source is “Kugou Music” and the acquisition method is “Online”, even if the login step has not been performed previously, it is judged as “Logged in” status.
Fixed: On the conversion page, when the playlist source is “Soda Music” and the acquisition method is “Online”, after displaying the login QR code, getting the login status will cause an abnormal crash.
Fixed: In the appreciation dialog box, if the device is in landscape mode, or due to insufficient screen height, the content is not fully displayed and cannot be scrolled up and down.
  • Loading branch information
Winnie0408 committed May 30, 2024
1 parent 85be3d8 commit 61e5735
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 52 deletions.
4 changes: 2 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 = 65
versionName = "1.5.0"
versionCode = 66
versionName = "1.5.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
83 changes: 38 additions & 45 deletions app/src/main/java/com/hwinzniej/musichelper/activity/ConvertPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.apache.commons.csv.CSVFormat
import org.apache.commons.csv.CSVParser
import java.io.File
Expand Down Expand Up @@ -3390,7 +3389,7 @@ class ConvertPage(
6 -> spotifyUserId.value
else -> ""
}
if (temp == null || temp.isBlank()) {
if (temp.isNullOrBlank()) {
return ""
}
val cookieValid = when (selectedSourceApp.intValue) {
Expand Down Expand Up @@ -3421,11 +3420,6 @@ class ConvertPage(
if (cookieValid) {
if (selectedSourceApp.intValue != 3)
selectedLoginMethod.intValue = 1
Toast.makeText(
context,
context.getString(R.string.use_last_login_info),
Toast.LENGTH_SHORT
).show()
return temp
}
}
Expand Down Expand Up @@ -3763,48 +3757,49 @@ class ConvertPage(
}
cancelLogin.value = false
while (!cancelLogin.value) {
var response = Response.Builder().build()
try {
response = client.newCall(request.build()).execute()
val responseJson = JSON.parseObject(response.body?.string()).getJSONObject("data")
?: throw Exception(context.getString(R.string.failed_get_login_qr_code))
if (responseJson.getInteger("error_code") != 0) {
if (responseJson.containsKey("verify_ticket")) {
responseJson.getJSONArray("verify_ways").forEach {
val way = it as JSONObject
if (way.getString("verify_way") == "mobile_up_sms_verify") {
needSmsVerify = true
lunaVerifyRelated.putAll(
mapOf(
"ticket" to responseJson.getString("verify_ticket"),
"target" to way.getString("channel_mobile"),
"phone" to way.getString("mobile"),
"content" to way.getString("sms_content")
client.newCall(request.build()).execute().use { response ->
val responseJson =
JSON.parseObject(response.body?.string()).getJSONObject("data")
?: throw Exception(context.getString(R.string.failed_get_login_qr_code))
if (responseJson.getInteger("error_code") != 0) {
if (responseJson.containsKey("verify_ticket")) {
responseJson.getJSONArray("verify_ways").forEach {
val way = it as JSONObject
if (way.getString("verify_way") == "mobile_up_sms_verify") {
needSmsVerify = true
lunaVerifyRelated.putAll(
mapOf(
"ticket" to responseJson.getString("verify_ticket"),
"target" to way.getString("channel_mobile"),
"phone" to way.getString("mobile"),
"content" to way.getString("sms_content")
)
)
)
}
}
if (needSmsVerify) {
showLunaVerifyDialog.value = true
return false
} else {
throw Exception(context.getString(R.string.unsupported_auth_method))
}
} else
throw Exception(context.getString(R.string.failed_get_login_status))
}
val status = responseJson.getString("status")
if (status == "confirmed") {
var cookie = ""
response.headers.values("Set-Cookie").forEach {
cookie += it.substring(0, it.indexOf("; ") + 2)
}
if (needSmsVerify) {
showLunaVerifyDialog.value = true
return false
} else {
throw Exception(context.getString(R.string.unsupported_auth_method))
dataStore.edit { settings ->
settings[DataStoreConstants.LAST_LOGIN_TIMESTAMP] =
System.currentTimeMillis()
settings[DataStoreConstants.LUNA_COOKIE] = cookie
}
} else
throw Exception(context.getString(R.string.failed_get_login_status))
}
val status = responseJson.getString("status")
if (status == "confirmed") {
var cookie = ""
response.headers.values("Set-Cookie").forEach {
cookie += it.substring(0, it.indexOf("; ") + 2)
}
dataStore.edit { settings ->
settings[DataStoreConstants.LAST_LOGIN_TIMESTAMP] =
System.currentTimeMillis()
settings[DataStoreConstants.LUNA_COOKIE] = cookie
return true
}
return true
}
} catch (_: SocketTimeoutException) {
} catch (e: Exception) {
Expand All @@ -3817,8 +3812,6 @@ class ConvertPage(
).show()
}
return false
} finally {
response.close()
}
delay(1250L)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
Expand Down Expand Up @@ -503,8 +504,11 @@ fun AboutPageUi(
min = 0.1.dp,
max = (LocalConfiguration.current.screenHeightDp / 1.5).dp
)
.align(Alignment.CenterHorizontally)
.fillMaxWidth()
.padding(vertical = 8.dp)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(
modifier = Modifier.align(Alignment.CenterHorizontally),
Expand Down
20 changes: 19 additions & 1 deletion app/src/main/java/com/hwinzniej/musichelper/ui/ConvertPageUi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,26 @@ fun ConvertPageUi(
dataStore.data.first()[DataStoreConstants.KUGOU_TOKEN] ?: ""
kugouUserRelated["userId"] =
dataStore.data.first()[DataStoreConstants.KUGOU_USER_ID] ?: ""
if (!kugouUserRelated["token"].isNullOrBlank() && !kugouUserRelated["userId"].isNullOrBlank()) {
userLoggedIn = true
withContext(Dispatchers.Main) {
Toast.makeText(
context,
context.getString(R.string.use_last_login_info),
Toast.LENGTH_SHORT
).show()
}
}
} else {
userLoggedIn = true
withContext(Dispatchers.Main) {
Toast.makeText(
context,
context.getString(R.string.use_last_login_info),
Toast.LENGTH_SHORT
).show()
}
}
userLoggedIn = true
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
<string name="service_agreements">사용자 서비스 계약</string>
<string name="agree">동의하다</string>
<string name="disagree">동의하지 않다</string>
<string name="agree_the_user_service_agreement">본인은 소프트웨어에 대한 사용자 서비스 계약을 읽었으며 이에 동의합니다.</string>
<string name="agree_the_user_service_agreement">본인은 소프트웨어에 대한 사용자 서비스 계약을 읽었으며 이에 동의합니다</string>
<string name="service_agreements_content">## 사용자 서비스 계약#n#n사용자 서비스 계약(이하 “계약”) 및 그 약관은 “경계 없는 노래 목록” 소프트웨어(이하 “소프트웨어”)의 다운로드, 설치 및 사용과 관련하여 귀하가 체결하는 것입니다. (이하 “소프트웨어”라 함)와 귀하 사이의 권리와 의무를 설명합니다.#n#n소프트웨어를 사용하기 전에 본 계약의 내용을 주의 깊게 읽고 각 조항의 내용을 완전히 이해한 후 이의가 있는 경우 소프트웨어에서 탈퇴할 수 있습니다. 본 사용자 서비스 계약을 확인하면 본 계약은 귀하와 소프트웨어 간에 법적 효력을 가지며, 이는 귀하가 본 계약의 모든 조항에 완전히 동의하고 수락함을 의미합니다. 본 계약을 자세히 읽고 동의 여부를 선택하시기 바랍니다(미성년자는 법정 보호자와 함께 읽어야 합니다).#n#n### 사용자 사용#n#n- 본 애플리케이션을 사용할 경우, 이용자는 국내 법규 및 저작권 규정을 엄격히 준수해야 하며, 사용하거나 생성한 데이터를 상업적 목적으로 사용해서는 안 됩니다. 이를 위반할 경우 본 앱과 개발사는 어떠한 법적 책임도 지지 않습니다.#n#n- 본 애플리케이션과 개발자는 본 애플리케이션에 참조된 데이터의 사용으로 인해 귀하에게 발생할 수 있는 직간접적인 손실에 대해 책임을 지지 않습니다. 이 애플리케이션을 사용하는 것은 전적으로 사용자의 책임입니다.#n#n- 앱과 개발자는 앱을 사용할 때 저작권 관련 법률 및 규정과 윤리 지침을 준수하고, 인용된 데이터를 합리적이고 표준화된 방식으로 사용할 것을 강력히 권장합니다. 저작권 침해를 발견하면 즉시 개발자에게 다음 연락처 정보로 연락하여 신속하게 처리해야 합니다: `hwinzniej@foxmail.com`.#n#n- 이 소프트웨어 플랫폼 및/또는 관련 커뮤니티 및 주제에 표현된 귀하의 의견과 입장은 애플리케이션 및 개발자의 입장을 대변하지 않으며, 그 내용에 대한 책임은 귀하에게 있습니다.#n#n### 면책 조항#n#n- 이 애플리케이션에 사용된 이미지, 데이터 및 기타 자료는 인터넷에서 얻은 것으로, 연구 및 참고용으로만 비상업적으로 사용하기 위한 것입니다. 모든 자료의 저작권은 원저작자에게 있으며 앱과 개발자는 이에 대한 어떠한 권리도 가지고 있지 않음을 인지해야 합니다.#n#n- 앱과 개발자는 앱 사용으로 인해 발생하는 분쟁, 논쟁 또는 기타 결과에 대해 책임을 지지 않으며, 이러한 분쟁으로 인해 발생하는 모든 문제는 사용자가 직접 해결해야 합니다.#n#n회원님의 이해와 협조에 감사드리며, 건전하고 질서 있는 온라인 환경을 유지하기 위해 회원님과 함께 노력하겠습니다!</string>
<string name="confirm_disagree_agreement_title">사용자 서비스 계약에 동의하지 않으시나요?</string>
<string name="go_back">돌아가기</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@
<string name="service_agreements">用户服务协议</string>
<string name="agree">同意</string>
<string name="disagree">不同意</string>
<string name="agree_the_user_service_agreement">我已阅读并同意本软件的用户服务协议</string>
<string name="agree_the_user_service_agreement">我已阅读并同意本软件的用户服务协议</string>
<string name="service_agreements_content">## 用户服务协议#n#n《用户服务协议》(以下简称“协议”)及其条款,系您下载、安装及使用“歌单无界”软件(以下简称“本软件”)所订立的、描述您与本软件之间权利义务的协议。#n#n在使用前,请您务必认真阅读本协议的内容、充分理解各条款内容,如有异议,您可选择退出本软件。一旦您确认本用户服务协议后,本协议即在您和本软件之间产生法律效力,意味着您完全同意并接受协议的全部条款。请您审慎阅读并选择接受或不接受协议(未成年人应在法定监护人的陪同下阅读)。#n#n### 用户使用#n#n- 您在使用本应用时,应严格遵守国家法律法规和版权规定,不得将所使用、生成的数据用于任何商业性目的。如有违反,本应用与开发者不承担任何法律责任。#n#n- 对于您因使用本应用所引用的数据而可能导致的直接或间接损失,本应用与开发者不承担任何法律责任。您应自行承担因使用本应用而产生的风险。#n#n- 本应用与开发者强烈建议您在使用本应用时,务必遵守版权法律法规和道德准则,合理、规范地使用所引用的数据。若您发现任何侵权行为,应立即通过以下联系方式与开发者取得联系,以便及时处理:`hwinzniej@foxmail.com`#n#n- 您在本软件平台与/或相关的社区、话题中,发表的观点及立场,均不代表本应用与开发者的立场,您应自行对发表内容负责。#n#n### 免责申明#n#n- 本应用所使用的图片、数据等素材均来源于互联网,仅限于您进行学习和参考等非商业性用途。您应明确知晓,所有素材的版权归原作者所有,本应用与开发者对此不享有任何形式的权利。#n#n- 本应用与开发者对于因您使用本应用而引发的任何争议、纠纷或其他后果,均不承担任何责任,您应自行解决由此产生的任何问题。#n#n感谢您的理解与配合,我们期待与您共同维护一个健康、有序的网络环境!#n</string>
<string name="confirm_disagree_agreement_title">不同意用户服务协议吗?</string>
<string name="go_back">返回</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@
<string name="service_agreements">User Service Agreement</string>
<string name="agree">Agree</string>
<string name="disagree">Disagree</string>
<string name="agree_the_user_service_agreement">I have read and agree to the User Service Agreement for the Software.</string>
<string name="agree_the_user_service_agreement">I have read and agree to the User Service Agreement for the Software</string>
<string name="service_agreements_content">## User Service Agreement#n#nThis User Service Agreement (‘Agreement’) and its terms and conditions describe the rights and obligations between you and the Software when you download, install and use the ‘Playlist NB’ software (‘Software’). (‘the Software’), which describes the rights and obligations between you and the Software.#n#nBefore using the Software, please read this Agreement carefully and fully understand the terms and conditions, and if you have any objections, you may choose to withdraw from the Software. Once you confirm this user service agreement, this agreement will have legal effect between you and the Software, which means that you fully agree and accept all the terms of the agreement. Please read carefully and choose to accept or not to accept the agreement (minors should be accompanied by a legal guardian to read).#n#n### User Use#n#n- When you use this application, you should strictly abide by national laws and regulations and copyright provisions, and shall not use the data used or generated for any commercial purposes. In case of any violation, this app and the developer shall not bear any legal responsibility.#n#n- The application and the developer shall not be liable for any direct or indirect losses that may be incurred by you as a result of the use of the data referenced in this application. You use this application at your own risk.#n#n- The app and its developers strongly recommend that you comply with copyright laws and regulations and ethical guidelines when using the app, and use the quoted data in a reasonable and standardised manner. If you discover any infringement of copyright, you should immediately contact the developer via the following contact information for prompt handling: `hwinzniej@foxmail.com`.#n#n- Your opinions and positions expressed in this software platform and/or related communities and topics do not represent the position of the application and the developer, and you shall be responsible for the content of your own.#n#n### Disclaimer#n#n- The images, data and other materials used in this application are obtained from the Internet and are intended for your non-commercial use for study and reference only. You should be aware that the copyright of all materials belongs to the original authors and that the app and its developers do not have any rights of any kind in them.#n#n- The app and the developer are not responsible for any disputes, controversies or other consequences arising from your use of the app, and you should resolve any issues arising from such disputes on your own.#n#nThank you for your understanding and co-operation, we look forward to working with you to maintain a healthy and orderly online environment!</string>
<string name="confirm_disagree_agreement_title">Disagree with the User Service Agreement?</string>
<string name="go_back">Go back</string>
Expand Down

0 comments on commit 61e5735

Please sign in to comment.