0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00

refactor: extract text/plain as constant (#16518)

* refactor: extract text/plain as constant

* remove extra constant

* refactor:constant location
This commit is contained in:
Shruti Gitte 2024-06-03 13:05:59 +05:30 committed by GitHub
parent c848579ba7
commit 4396544bfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -26,6 +26,7 @@ import com.ichi2.anki.tests.InstrumentedTest
import com.ichi2.anki.testutil.GrantStoragePermission
import com.ichi2.testutils.Flaky
import com.ichi2.testutils.OS
import com.ichi2.utils.AssetHelper.TEXT_PLAIN
import junit.framework.TestCase.assertFalse
import org.hamcrest.MatcherAssert
import org.hamcrest.Matchers
@ -62,7 +63,7 @@ class NoteEditorIntentTest : InstrumentedTest() {
fun intentLaunchedWithNonImageIntent() {
val intent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
type = TEXT_PLAIN
}
assertFalse(intentLaunchedWithImage(intent))
}

View File

@ -30,6 +30,7 @@ import com.ichi2.anki.AnkiActivity
import com.ichi2.anki.R
import com.ichi2.anki.analytics.UsageAnalytics
import com.ichi2.annotations.NeedsTest
import com.ichi2.utils.AssetHelper.TEXT_PLAIN
import com.ichi2.utils.title
import kotlinx.parcelize.Parcelize
import timber.log.Timber
@ -96,7 +97,7 @@ class ImportFileSelectionFragment : DialogFragment() {
multiple = false,
mimeType = "*/*",
extraMimes = arrayOf(
"text/plain",
TEXT_PLAIN,
"text/comma-separated-values",
"text/csv",
"text/tab-separated-values"

View File

@ -68,7 +68,10 @@ object AssetHelper {
"js" -> "text/javascript"
"mjs" -> "text/javascript"
"json" -> "application/json"
else -> MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) ?: "text/plain"
else -> MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) ?: TEXT_PLAIN
}
}
/** Used for mime type or Intent type when sharing text via other applications **/
const val TEXT_PLAIN = "text/plain"
}