From ece0c656120571cb06f5f5eca3457c916abdc76b Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 25 Jan 2023 17:54:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/help}/IntentType.kt | 7 ++--- .../java/io/legado/app/help/IntentType.kt | 28 +++++++++++++++++++ .../io/legado/app/service/DownloadService.kt | 2 +- .../io/legado/app/utils/ContextExtensions.kt | 1 + 4 files changed, 33 insertions(+), 5 deletions(-) rename app/src/{main/java/io/legado/app/utils => app/java/io/legado/app/help}/IntentType.kt (89%) create mode 100644 app/src/google/java/io/legado/app/help/IntentType.kt diff --git a/app/src/main/java/io/legado/app/utils/IntentType.kt b/app/src/app/java/io/legado/app/help/IntentType.kt similarity index 89% rename from app/src/main/java/io/legado/app/utils/IntentType.kt rename to app/src/app/java/io/legado/app/help/IntentType.kt index e1b88f6c2..ff2d0632d 100644 --- a/app/src/main/java/io/legado/app/utils/IntentType.kt +++ b/app/src/app/java/io/legado/app/help/IntentType.kt @@ -1,21 +1,20 @@ -package io.legado.app.utils +package io.legado.app.help import android.net.Uri +import androidx.annotation.Keep import java.io.File +@Keep object IntentType { - @JvmStatic fun from(uri: Uri): String? { return from(uri.toString()) } - @JvmStatic fun from(file: File): String? { return from(file.absolutePath) } - @JvmStatic fun from(path: String?): String? { return when (path?.substringAfterLast(".")?.lowercase()) { "apk" -> "application/vnd.android.package-archive" diff --git a/app/src/google/java/io/legado/app/help/IntentType.kt b/app/src/google/java/io/legado/app/help/IntentType.kt new file mode 100644 index 000000000..d884120e5 --- /dev/null +++ b/app/src/google/java/io/legado/app/help/IntentType.kt @@ -0,0 +1,28 @@ +package io.legado.app.help + +import android.net.Uri +import androidx.annotation.Keep +import java.io.File + +@Keep +object IntentType { + + fun from(uri: Uri): String? { + return from(uri.toString()) + } + + fun from(file: File): String? { + return from(file.absolutePath) + } + + fun from(path: String?): String? { + return when (path?.substringAfterLast(".")?.lowercase()) { + "m4a", "mp3", "mid", "xmf", "ogg", "wav" -> "video/*" + "3gp", "mp4" -> "audio/*" + "jpg", "gif", "png", "jpeg", "bmp" -> "image/*" + "txt", "json" -> "text/plain" + else -> null + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/DownloadService.kt b/app/src/main/java/io/legado/app/service/DownloadService.kt index 1677d2d65..e5bfe2f58 100644 --- a/app/src/main/java/io/legado/app/service/DownloadService.kt +++ b/app/src/main/java/io/legado/app/service/DownloadService.kt @@ -12,7 +12,7 @@ import io.legado.app.R import io.legado.app.base.BaseService import io.legado.app.constant.AppConst import io.legado.app.constant.IntentAction -import io.legado.app.utils.IntentType +import io.legado.app.help.IntentType import io.legado.app.utils.openFileUri import io.legado.app.utils.servicePendingIntent import io.legado.app.utils.toastOnUi diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index 9ecf84e99..c902805e5 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -29,6 +29,7 @@ import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import io.legado.app.R import io.legado.app.constant.AppConst import io.legado.app.help.IntentHelp +import io.legado.app.help.IntentType import splitties.systemservices.clipboardManager import splitties.systemservices.connectivityManager import java.io.File