You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
oppen d0a38da08b tls lib changes and titan progress 1 week ago
..
src tls lib changes and titan progress 1 week ago
.gitignore fix bad lib metadata and refactor 2 weeks ago
README.md update gemini readme 2 weeks ago
build.gradle lib management, new tls lib, new titan lib 1 week ago
consumer-rules.pro fix bad lib metadata and refactor 2 weeks ago
proguard-rules.pro fix bad lib metadata and refactor 2 weeks ago

README.md

lib_gemini : Gemini Library

A very simple Android library for the Gemini Protocol.

Usage

The library has been designed to be either as simple or as complicated as you need it to be. A basic request which is suitable for most purposes:

Gemini.request("gemini://oppen.digital"){ response ->
    //...
}

A more complete example which also includes a server certificate trust manager:

val trustManager: OppenTrustManager = trustManagerImpl

Gemini.initialiseTLS(trustManager)

//...

Gemini.request("gemini://oppen.digital"){ response ->
    //...
}

A full implementation with both a certificate trust manager and a client certificate implementation:

val keyManager: OppenKeyManager = keyManagerImpl
val trustManager: OppenTrustManager = trustManagerImpl

Gemini.initialiseTLS(keyManager, trustManager)

//...

Gemini.request("gemini://oppen.digital"){ response ->
    //...
}

File Download

Create an OppenDownloadManager which should create a suitable File when required:

val downloadManager: OppenDownloadManager = downloadManagerImpl
Gemini.initialiseDownloadManager(downloadManagerImpl)

//...

Gemini.request(Request.Download(uri)){ response ->
    //...
}

Here's a simple implementation which saves a file to an app's internal cache directory, it's used by Ariane to display inline images:

class DownloadManager(val context: Context): OppenDownloadManager {

    override fun getDownloadFile(uri: Uri): File {
        var filename: String? = null
        val fileSegmentIndex: Int = uri.path!!.lastIndexOf('/')
        
        when {
            fileSegmentIndex != -1 -> filename = uri.path!!.substring(fileSegmentIndex + 1)
        }

        val host = uri.host?.replace(".", "_")
        val cacheName = "${host}_$filename"
        val cacheFile = File(context.cacheDir, cacheName)
        if(cacheFile.exists()) cacheFile.delete()
        return cacheFile
    }
}