Local link share handler double slash workaround

This commit is contained in:
Corewala 2022-01-13 09:48:02 -05:00
parent 299061ef99
commit b0f674f369
1 changed files with 4 additions and 7 deletions

View File

@ -71,16 +71,13 @@ class GemActivity : AppCompatActivity() {
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, position: Int ->
if(longTap){
var fullUri = uri.toString()
if(uri.toString().first() == '/'){
if (omniTerm.getCurrent().last() == '/'){
fullUri = fullUri.drop(1)
}
fullUri = omniTerm.getCurrent() + fullUri
var globalURI = uri.toString()
if(globalURI.first() == '/'){
globalURI = (omniTerm.getCurrent() + globalURI).replace("%2F", "/").replace("//", "/").replace("gemini:/", "gemini://")
}
Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, fullUri)
putExtra(Intent.EXTRA_TEXT, globalURI)
type = "text/plain"
startActivity(Intent.createChooser(this, null))
}