diff --git a/android/tinySSB/app/src/main/assets/web/sketch.js b/android/tinySSB/app/src/main/assets/web/sketch.js index 10b31b5..9099a96 100644 --- a/android/tinySSB/app/src/main/assets/web/sketch.js +++ b/android/tinySSB/app/src/main/assets/web/sketch.js @@ -26,19 +26,16 @@ var sketch_size_update_timer = null; // reference to size update interval function chat_openSketch() { closeOverlay() // Create a canvas element - let canvas = document.createElement('canvas'); - canvas.id = 'sketchCanvas'; - canvas.style.position = 'fixed'; - canvas.style.top = '0'; - canvas.style.left = '0'; - canvas.width = window.innerWidth; // Full screen width - canvas.height = window.innerHeight; // Full screen height - /* on API 26, the canvas is not showing. Perhaps - https://stackoverflow.com/questions/24586530/android-canvas-drawing-not-visible#24586531 - canvas.drawARGB(0, 225, 225, 255); - */ - canvas.style.backgroundColor = '#ffffff'; - document.body.appendChild(canvas); + + sketch.canvas = document.getElementById("sketchCanvas") + sketch.canvas.width = window.screen.width; + sketch.canvas.height = window.screen.height; + sketch.canvas.style.display = 'initial'; + sketch.canvas.style.backgroundColor = '#ffffff'; + sketch.ctx = sketch.canvas.getContext('2d'); + sketch.ctx.globalCompositeOperation = "source-over"; + sketch.ctx.fillStyle = "white"; + sketch.ctx.fillRect(0 , 0, sketch.canvas.width, sketch.canvas.height); let sizeDiv = document.createElement('div') sizeDiv.id = 'div:sketch_size' @@ -212,10 +209,7 @@ function chat_openSketch() { eraserSign.onclick = toggleEraser; document.body.appendChild(eraserSign); - //get the context of the canvas and set initial drawing settings - sketch.ctx = canvas.getContext('2d'); - sketch.ctx.fillStyle = "white"; - sketch.ctx.fillRect(0 , 0, canvas.width, canvas.height); + // set initial drawing settings sketch.currSize = 0; sketch.currentWidNdx = 0; sketch.strokeColor = '#000000'; @@ -225,12 +219,12 @@ function chat_openSketch() { sketch.lastY = 0; sketch.colChoice = true; sketch.currentColNdx = 0; - sketch.svg = [1,['s',canvas.width,canvas.height]] + sketch.svg = [1,['s',sketch.canvas.width,sketch.canvas.height]] - canvas.addEventListener('touchstart', startDrawing); - canvas.addEventListener('touchmove', draw); - canvas.addEventListener('touchend', endDrawing); - canvas.addEventListener('touchcancel', endDrawing); + sketch.canvas.addEventListener('touchstart', startDrawing); + sketch.canvas.addEventListener('touchmove', draw); + sketch.canvas.addEventListener('touchend', endDrawing); + sketch.canvas.addEventListener('touchcancel', endDrawing); //Drawing function when user starts drawing (on touchstart) function startDrawing(e) { @@ -353,8 +347,9 @@ function chat_closeSketch() { } // Remove the canvas element - let canvas = document.getElementById('sketchCanvas'); - canvas.parentNode.removeChild(canvas); + // let canvas = document.getElementById('sketchCanvas'); + // canvas.parentNode.removeChild(canvas); + sketch.canvas.style.display = 'none'; let sizeDiv = document.getElementById('div:sketch_size') sizeDiv.parentNode.removeChild(sizeDiv) diff --git a/android/tinySSB/app/src/main/assets/web/tremola.html b/android/tinySSB/app/src/main/assets/web/tremola.html index 0a07c9e..bcf7443 100644 --- a/android/tinySSB/app/src/main/assets/web/tremola.html +++ b/android/tinySSB/app/src/main/assets/web/tremola.html @@ -561,8 +561,11 @@ + + - diff --git a/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/MainActivity.kt b/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/MainActivity.kt index 94f5ac6..227eb83 100644 --- a/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/MainActivity.kt +++ b/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/MainActivity.kt @@ -16,6 +16,7 @@ import android.net.wifi.WifiManager import android.os.Bundle import android.os.Handler import android.util.Log +import android.view.View import android.view.Window import android.webkit.WebStorage import android.webkit.WebView @@ -88,6 +89,7 @@ class MainActivity : Activity() { Log.d("IDENTITY", "is ${idStore.identity.toRef()} (${idStore.identity.verifyKey})") val webView = findViewById(R.id.webView) + webView.setLayerType(View.LAYER_TYPE_SOFTWARE,null); // disable acceleration, needed for older WebViews wai = WebAppInterface(this, webView) // upgrades repo filesystem if necessary tinyRepo.upgrade_repo() @@ -425,9 +427,6 @@ class MainActivity : Activity() { } */ } - fun isWaiInitialized(): Boolean { - return this::wai.isInitialized; - } fun rmSockets() { try { mc_socket?.leaveGroup(mc_group); mc_socket?.close() } catch (e: Exception) {} diff --git a/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/tssb/Repo.kt b/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/tssb/Repo.kt index c4a0f0a..6e7ef7e 100644 --- a/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/tssb/Repo.kt +++ b/android/tinySSB/app/src/main/java/nz/scuttlebutt/tremolavossbol/tssb/Repo.kt @@ -85,7 +85,7 @@ class Repo(val context: MainActivity) { chnk_offs = Random.nextInt(0, context.tinyGoset.keys.size - 1) } - if(context.isWaiInitialized()) + if(context.wai.frontend_ready) // was: isWaiInitialized() context.wai.eval("b2f_new_contact(\"@${fid.toBase64()}.ed25519\")") // notify frontend want_is_valid = false