Use MimeTypes object instead of hard-coded strings.

This commit is contained in:
Benoit Marty 2023-11-27 21:55:39 +01:00 committed by Benoit Marty
parent 9059126b2e
commit 1df3817808
14 changed files with 37 additions and 24 deletions

View file

@ -29,6 +29,7 @@ import androidx.annotation.ChecksSdkIntAtLeast
import androidx.annotation.RequiresApi
import io.element.android.libraries.androidutils.R
import io.element.android.libraries.androidutils.compat.getApplicationInfoCompat
import io.element.android.libraries.core.mimetype.MimeTypes
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.O)
fun supportNotificationChannels() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
@ -125,7 +126,7 @@ fun Context.startSharePlainTextIntent(
noActivityFoundMessage: String = getString(R.string.error_no_compatible_app_found),
) {
val share = Intent(Intent.ACTION_SEND)
share.type = "text/plain"
share.type = MimeTypes.PlainText
share.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
// Add data to the intent, the receiving app will decide what to do with it.
share.putExtra(Intent.EXTRA_SUBJECT, subject)