Reuse search result item viewmodels

This commit is contained in:
MM20
2023-04-21 13:37:00 +02:00
parent d1482ad112
commit df1aa8c119
29 changed files with 658 additions and 481 deletions
@@ -7,6 +7,7 @@ import android.net.Uri
import android.os.Bundle
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import de.mm20.launcher2.icons.ColorLayer
import de.mm20.launcher2.icons.StaticLauncherIcon
import de.mm20.launcher2.icons.TintedIconLayer
@@ -53,6 +54,18 @@ data class Wikipedia(
return context.tryStartActivity(getLaunchIntent(), options)
}
fun share(context: Context) {
val text = HtmlCompat.fromHtml(text, HtmlCompat.FROM_HTML_MODE_LEGACY).toString()
val shareIntent = Intent(Intent.ACTION_SEND)
shareIntent.putExtra(
Intent.EXTRA_TEXT, "${label}\n\n" +
"${text.substring(0, 200)}\n\n" +
url
)
shareIntent.type = "text/plain"
context.startActivity(Intent.createChooser(shareIntent, null))
}
companion object {
const val Domain = "wikipedia"
}