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:
parent
c848579ba7
commit
4396544bfb
@ -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))
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user