mirror of
https://github.com/Corewala/Buran
synced 2024-12-22 07:42:43 +00:00
Fixed sharing of relative links
This commit is contained in:
parent
13f21bc09b
commit
319b0b4d14
3 changed files with 9 additions and 7 deletions
|
@ -58,7 +58,6 @@ class OmniTerm(private val listener: Listener) {
|
||||||
link.startsWith("//") -> uri.set("gemini:$link")
|
link.startsWith("//") -> uri.set("gemini:$link")
|
||||||
link.startsWith("http://") or link.startsWith("https://") -> {
|
link.startsWith("http://") or link.startsWith("https://") -> {
|
||||||
uri.set(link)
|
uri.set(link)
|
||||||
println("MALD?")
|
|
||||||
}
|
}
|
||||||
link.contains(":") -> listener.openExternal(link)
|
link.contains(":") -> listener.openExternal(link)
|
||||||
else -> uri.resolve(link)
|
else -> uri.resolve(link)
|
||||||
|
@ -70,6 +69,14 @@ class OmniTerm(private val listener: Listener) {
|
||||||
println("OmniTerm resolved address: $address")
|
println("OmniTerm resolved address: $address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getGlobalUri(reference: String): String {
|
||||||
|
when {
|
||||||
|
reference.contains(":") -> return reference
|
||||||
|
reference.startsWith("//") -> return "gemini:$reference"
|
||||||
|
else -> return uri.resolve(reference)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun reset(){
|
fun reset(){
|
||||||
uri = penultimate.copy()
|
uri = penultimate.copy()
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ class OppenURI constructor(private var ouri: String) {
|
||||||
|
|
||||||
fun resolve(reference: String): String{
|
fun resolve(reference: String): String{
|
||||||
if(ouri == "$GEMSCHEME$host") ouri = "$ouri/"
|
if(ouri == "$GEMSCHEME$host") ouri = "$ouri/"
|
||||||
println(host)
|
|
||||||
when {
|
when {
|
||||||
reference.startsWith(GEMSCHEME) -> set(reference)
|
reference.startsWith(GEMSCHEME) -> set(reference)
|
||||||
reference.startsWith(SOLIDUS) -> ouri = "$scheme://$host$reference"
|
reference.startsWith(SOLIDUS) -> ouri = "$scheme://$host$reference"
|
||||||
|
|
|
@ -97,11 +97,7 @@ class GemActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, _: Int ->
|
private val onLink: (link: URI, longTap: Boolean, adapterPosition: Int) -> Unit = { uri, longTap, _: Int ->
|
||||||
if(longTap){
|
if(longTap){
|
||||||
val globalURI = if(!uri.toString().contains("//") and !uri.toString().contains(":")){
|
val globalURI = omniTerm.getGlobalUri(uri.toString())
|
||||||
(omniTerm.getCurrent() + uri.toString()).replace("//", "/").replace(":/", "://")
|
|
||||||
} else {
|
|
||||||
uri.toString()
|
|
||||||
}
|
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
action = Intent.ACTION_SEND
|
action = Intent.ACTION_SEND
|
||||||
putExtra(Intent.EXTRA_TEXT, globalURI)
|
putExtra(Intent.EXTRA_TEXT, globalURI)
|
||||||
|
|
Loading…
Reference in a new issue