mirror of
https://git.sr.ht/~oppen/ariane
synced 2025-01-03 13:54:43 +00:00
fix bad padding on scrollbars
This commit is contained in:
parent
a61d1d1a03
commit
3278f6358c
3 changed files with 42 additions and 10 deletions
|
@ -6,6 +6,7 @@ import androidx.preference.PreferenceManager
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import oppen.ariane.io.GemState
|
import oppen.ariane.io.GemState
|
||||||
|
import oppen.ariane.io.keymanager.ArianeKeyManager
|
||||||
import oppen.isGemini
|
import oppen.isGemini
|
||||||
import oppen.toURI
|
import oppen.toURI
|
||||||
import oppen.toUri
|
import oppen.toUri
|
||||||
|
@ -23,6 +24,7 @@ class GeminiDatasource(private val context: Context): Datasource {
|
||||||
private val addressBuilder = AddressBuilder()
|
private val addressBuilder = AddressBuilder()
|
||||||
private val runtimeHistory = mutableListOf<URI>()
|
private val runtimeHistory = mutableListOf<URI>()
|
||||||
private var forceDownload = false
|
private var forceDownload = false
|
||||||
|
private val arianeKeyManager = ArianeKeyManager()
|
||||||
|
|
||||||
override fun request(uri: URI, onUpdate: (state: GemState) -> Unit) = request(uri, false, onUpdate)
|
override fun request(uri: URI, onUpdate: (state: GemState) -> Unit) = request(uri, false, onUpdate)
|
||||||
|
|
||||||
|
@ -72,29 +74,25 @@ class GeminiDatasource(private val context: Context): Datasource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This was originally largely copied from:
|
|
||||||
|
|
||||||
https://framagit.org/waweic/gemini-client/-/blob/master/app/src/main/java/rocks/ism/decentral/geminiclient/GeminiConnection.kt
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private fun geminiRequest(uri: URI, onUpdate: (state: GemState) -> Unit){
|
private fun geminiRequest(uri: URI, onUpdate: (state: GemState) -> Unit){
|
||||||
val port = if(uri.port == -1) 1965 else uri.port
|
val port = if(uri.port == -1) 1965 else uri.port
|
||||||
|
|
||||||
|
//todo - extract and reuse this ------------------------------------------------------------
|
||||||
val protocol = prefs.getString("tls_protocol", "TLS")
|
val protocol = prefs.getString("tls_protocol", "TLS")
|
||||||
|
|
||||||
println("REQ_PROTOCOL: $protocol")
|
println("REQ_PROTOCOL: $protocol")
|
||||||
|
|
||||||
//todo - extract and reuse this
|
|
||||||
val sslContext = when (protocol) {
|
val sslContext = when (protocol) {
|
||||||
"TLS_ALL" -> SSLContext.getInstance("TLS")
|
"TLS_ALL" -> SSLContext.getInstance("TLS")
|
||||||
else -> SSLContext.getInstance(protocol)
|
else -> SSLContext.getInstance(protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
sslContext.init(null, DummyTrustManager.get(), null)
|
sslContext.init(arianeKeyManager.getFactory()?.keyManagers, DummyTrustManager.get(), null)
|
||||||
val factory: SSLSocketFactory = sslContext.socketFactory
|
val factory: SSLSocketFactory = sslContext.socketFactory
|
||||||
|
|
||||||
|
//todo to here ----------------------------------------------------------------------------
|
||||||
|
|
||||||
val socket: SSLSocket?
|
val socket: SSLSocket?
|
||||||
try {
|
try {
|
||||||
socket = factory.createSocket(uri.host, port) as SSLSocket
|
socket = factory.createSocket(uri.host, port) as SSLSocket
|
||||||
|
@ -104,6 +102,7 @@ class GeminiDatasource(private val context: Context): Datasource {
|
||||||
"TLS_ALL" -> socket.enabledProtocols = socket.supportedProtocols
|
"TLS_ALL" -> socket.enabledProtocols = socket.supportedProtocols
|
||||||
else -> socket.enabledProtocols = arrayOf(protocol)
|
else -> socket.enabledProtocols = arrayOf(protocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
println("Ariane socket handshake with ${uri.host} on port $port")
|
println("Ariane socket handshake with ${uri.host} on port $port")
|
||||||
socket.startHandshake()
|
socket.startHandshake()
|
||||||
}catch (ce: ConnectException){
|
}catch (ce: ConnectException){
|
||||||
|
@ -116,7 +115,6 @@ class GeminiDatasource(private val context: Context): Datasource {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// OUT >>>>>>>>>>>>>>>>>>>>>>>>>>
|
// OUT >>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||||
val outputStreamWriter = OutputStreamWriter(socket.outputStream)
|
val outputStreamWriter = OutputStreamWriter(socket.outputStream)
|
||||||
val bufferedWriter = BufferedWriter(outputStreamWriter)
|
val bufferedWriter = BufferedWriter(outputStreamWriter)
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package oppen.ariane.io.keymanager
|
||||||
|
|
||||||
|
import android.R
|
||||||
|
import android.content.Context
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.security.KeyStore
|
||||||
|
import javax.net.ssl.KeyManagerFactory
|
||||||
|
|
||||||
|
|
||||||
|
class ArianeKeyManager {
|
||||||
|
|
||||||
|
//todo - add other methods to update state
|
||||||
|
|
||||||
|
//If the user has a key loaded load it here - or else return null
|
||||||
|
fun getFactory(): KeyManagerFactory? {
|
||||||
|
val hasLoadedKey = false
|
||||||
|
return when {
|
||||||
|
hasLoadedKey -> {
|
||||||
|
val keyStore: KeyStore = KeyStore.getInstance("BKS")
|
||||||
|
val inputStream: InputStream = ByteArrayInputStream("dummy".toByteArray())
|
||||||
|
keyStore.load(inputStream, "yourKeyStorePassword".toCharArray())
|
||||||
|
inputStream.close()
|
||||||
|
|
||||||
|
val keyManagerFactory: KeyManagerFactory = KeyManagerFactory.getInstance("X509")
|
||||||
|
keyManagerFactory.init(keyStore, "yourKeyStorePassword".toCharArray())
|
||||||
|
|
||||||
|
keyManagerFactory
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -150,6 +150,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
|
android:scrollbarStyle="outsideOverlay"
|
||||||
android:paddingTop="@dimen/screen_margin"
|
android:paddingTop="@dimen/screen_margin"
|
||||||
android:paddingBottom="@dimen/screen_margin"
|
android:paddingBottom="@dimen/screen_margin"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue