pull/1319/head
gedoor 3 years ago
parent 904cd0f1e2
commit bc0bca2a30
  1. 3
      app/src/main/assets/defaultData/directLinkUpload.json
  2. 15
      app/src/main/java/io/legado/app/help/DirectLinkUpload.kt
  3. 3
      app/src/main/java/io/legado/app/ui/config/DirectLinkUploadConfig.kt
  4. 14
      app/src/main/res/layout/dialog_direct_link_upload_config.xml
  5. 1
      app/src/main/res/values-es-rES/strings.xml
  6. 1
      app/src/main/res/values-ja-rJP/strings.xml
  7. 1
      app/src/main/res/values-pt-rBR/strings.xml
  8. 1
      app/src/main/res/values-zh-rHK/strings.xml
  9. 1
      app/src/main/res/values-zh-rTW/strings.xml
  10. 1
      app/src/main/res/values-zh/strings.xml
  11. 1
      app/src/main/res/values/strings.xml

@ -1,4 +1,5 @@
{
"UploadUrl": "http://sy.miaogongzi.cc/shuyuan,{\"method\":\"POST\",\"body\": {\"file\": \"fileRequest\"},\"type\": \"multipart/form-data\"}",
"DownloadUrlRule": "$.data@js:if (result == '') \n '' \n else \n 'https://shuyuan.miaogongzi.cc/shuyuan/' + result"
"DownloadUrlRule": "$.data@js:if (result == '') \n '' \n else \n 'https://shuyuan.miaogongzi.cc/shuyuan/' + result",
"summary": "有效期2天"
}

@ -12,6 +12,7 @@ object DirectLinkUpload {
private const val uploadUrlKey = "directLinkUploadUrl"
private const val downloadUrlRuleKey = "directLinkDownloadUrlRule"
private const val summaryKey = "directSummary"
suspend fun upLoad(fileName: String, file: ByteArray, contentType: String): String {
val url = getUploadUrl()
@ -58,9 +59,23 @@ object DirectLinkUpload {
CacheManager.put(downloadUrlRuleKey, rule)
}
fun getSummary(): String? {
return CacheManager.get(summaryKey)
?: ruleDoc.readString("summary")
}
fun putSummary(summary: String?) {
if (summary != null) {
CacheManager.put(summaryKey, summary)
} else {
CacheManager.delete(summaryKey)
}
}
fun delete() {
CacheManager.delete(uploadUrlKey)
CacheManager.delete(downloadUrlRuleKey)
CacheManager.delete(summaryKey)
}
}

@ -39,6 +39,7 @@ class DirectLinkUploadConfig : BaseDialogFragment() {
binding.toolBar.setBackgroundColor(primaryColor)
binding.editUploadUrl.setText(DirectLinkUpload.getUploadUrl())
binding.editDownloadUrlRule.setText(DirectLinkUpload.getDownloadUrlRule())
binding.editSummary.setText(DirectLinkUpload.getSummary())
binding.tvCancel.onClick {
dismiss()
}
@ -49,6 +50,7 @@ class DirectLinkUploadConfig : BaseDialogFragment() {
binding.tvOk.onClick {
val uploadUrl = binding.editUploadUrl.text?.toString()
val downloadUrlRule = binding.editDownloadUrlRule.text?.toString()
val summary = binding.editSummary.text?.toString()
uploadUrl ?: let {
toastOnUi("上传Url不能为空")
return@onClick
@ -59,6 +61,7 @@ class DirectLinkUploadConfig : BaseDialogFragment() {
}
DirectLinkUpload.putUploadUrl(uploadUrl)
DirectLinkUpload.putDownloadUrlRule(downloadUrlRule)
DirectLinkUpload.putSummary(summary)
dismiss()
}
}

@ -54,6 +54,20 @@
</io.legado.app.ui.widget.text.TextInputLayout>
<io.legado.app.ui.widget.text.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="3dp">
<io.legado.app.ui.widget.text.EditText
android:id="@+id/edit_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/summary"
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />
</io.legado.app.ui.widget.text.TextInputLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

@ -873,5 +873,6 @@
<string name="copy_play_url">拷贝播放Url</string>
<string name="set_source_variable">设置源变量</string>
<string name="set_book_variable">设置书籍变量</string>
<string name="summary">注释</string>
</resources>

@ -877,5 +877,6 @@
<string name="copy_play_url">拷贝播放Url</string>
<string name="set_source_variable">设置源变量</string>
<string name="set_book_variable">设置书籍变量</string>
<string name="summary">注释</string>
</resources>

@ -877,5 +877,6 @@
<string name="copy_play_url">拷贝播放Url</string>
<string name="set_source_variable">设置源变量</string>
<string name="set_book_variable">设置书籍变量</string>
<string name="summary">注释</string>
</resources>

@ -874,5 +874,6 @@
<string name="copy_play_url">拷贝播放Url</string>
<string name="set_source_variable">设置源变量</string>
<string name="set_book_variable">设置书籍变量</string>
<string name="summary">注释</string>
</resources>

@ -876,5 +876,6 @@
<string name="copy_play_url">複製播放Url</string>
<string name="set_source_variable">設定源變數</string>
<string name="set_book_variable">設定書籍變數</string>
<string name="summary">注释</string>
</resources>

@ -876,5 +876,6 @@
<string name="copy_play_url">拷贝播放Url</string>
<string name="set_source_variable">设置源变量</string>
<string name="set_book_variable">设置书籍变量</string>
<string name="summary">注释</string>
</resources>

@ -877,5 +877,6 @@
<string name="copy_play_url">拷贝播放Url</string>
<string name="set_source_variable">设置源变量</string>
<string name="set_book_variable">设置书籍变量</string>
<string name="summary">注释</string>
</resources>

Loading…
Cancel
Save