From d931a9b41be6c810d2e45fc6d204478ca511ee52 Mon Sep 17 00:00:00 2001 From: tschudin Date: Thu, 1 Aug 2024 03:59:19 +0200 Subject: [PATCH] Add a button with the "connectedDevices" overlay, remove this function from the hamburger menues; scroll to the end of the posts --- android/tinySSB/app/build.gradle | 2 +- .../main/assets/web/img/game-controller.svg | 36 +++++++++++ .../main/assets/web/img/hand_and_coins.svg | 10 +++ .../src/main/assets/web/img/productivity.svg | 6 ++ .../app/src/main/assets/web/img/quiz.svg | 6 ++ .../app/src/main/assets/web/img/schedule.svg | 6 ++ .../app/src/main/assets/web/tremola.html | 8 +++ .../app/src/main/assets/web/tremola_ui.js | 61 ++++++++++++------- .../tremolavossbol/MainActivity.kt | 7 ++- 9 files changed, 119 insertions(+), 23 deletions(-) create mode 100644 android/tinySSB/app/src/main/assets/web/img/game-controller.svg create mode 100644 android/tinySSB/app/src/main/assets/web/img/hand_and_coins.svg create mode 100644 android/tinySSB/app/src/main/assets/web/img/productivity.svg create mode 100644 android/tinySSB/app/src/main/assets/web/img/quiz.svg create mode 100644 android/tinySSB/app/src/main/assets/web/img/schedule.svg diff --git a/android/tinySSB/app/build.gradle b/android/tinySSB/app/build.gradle index 021680d..420aa20 100644 --- a/android/tinySSB/app/build.gradle +++ b/android/tinySSB/app/build.gradle @@ -12,7 +12,7 @@ android { defaultConfig { applicationId "nz.scuttlebutt.tremolavossbol" - minSdk 24 + minSdk 23 targetSdkVersion 30 versionCode 1 versionName "0.1" diff --git a/android/tinySSB/app/src/main/assets/web/img/game-controller.svg b/android/tinySSB/app/src/main/assets/web/img/game-controller.svg new file mode 100644 index 0000000..7ebf83e --- /dev/null +++ b/android/tinySSB/app/src/main/assets/web/img/game-controller.svg @@ -0,0 +1,36 @@ + + + + + + + + \ No newline at end of file diff --git a/android/tinySSB/app/src/main/assets/web/img/hand_and_coins.svg b/android/tinySSB/app/src/main/assets/web/img/hand_and_coins.svg new file mode 100644 index 0000000..c1c3aac --- /dev/null +++ b/android/tinySSB/app/src/main/assets/web/img/hand_and_coins.svg @@ -0,0 +1,10 @@ + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + + + + + + + \ No newline at end of file diff --git a/android/tinySSB/app/src/main/assets/web/img/productivity.svg b/android/tinySSB/app/src/main/assets/web/img/productivity.svg new file mode 100644 index 0000000..8f53843 --- /dev/null +++ b/android/tinySSB/app/src/main/assets/web/img/productivity.svg @@ -0,0 +1,6 @@ + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + + + \ No newline at end of file diff --git a/android/tinySSB/app/src/main/assets/web/img/quiz.svg b/android/tinySSB/app/src/main/assets/web/img/quiz.svg new file mode 100644 index 0000000..9d62dd0 --- /dev/null +++ b/android/tinySSB/app/src/main/assets/web/img/quiz.svg @@ -0,0 +1,6 @@ + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + + + \ No newline at end of file diff --git a/android/tinySSB/app/src/main/assets/web/img/schedule.svg b/android/tinySSB/app/src/main/assets/web/img/schedule.svg new file mode 100644 index 0000000..48ca6bd --- /dev/null +++ b/android/tinySSB/app/src/main/assets/web/img/schedule.svg @@ -0,0 +1,6 @@ + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + + + \ No newline at end of file diff --git a/android/tinySSB/app/src/main/assets/web/tremola.html b/android/tinySSB/app/src/main/assets/web/tremola.html index ff765b9..6bae33d 100644 --- a/android/tinySSB/app/src/main/assets/web/tremola.html +++ b/android/tinySSB/app/src/main/assets/web/tremola.html @@ -42,6 +42,14 @@
t i n y S S B
+ +
diff --git a/android/tinySSB/app/src/main/assets/web/tremola_ui.js b/android/tinySSB/app/src/main/assets/web/tremola_ui.js index f53ca8e..62521be 100644 --- a/android/tinySSB/app/src/main/assets/web/tremola_ui.js +++ b/android/tinySSB/app/src/main/assets/web/tremola_ui.js @@ -29,22 +29,22 @@ var scenarioDisplay = { } var scenarioMenu = { - 'chats': [['Connected Devices', 'menu_connection'], // '['New conversation', 'menu_new_conversation'],' TODO reactivate when encrypted chats are implemented + 'chats': [// ['Connected Devices', 'menu_connection'], // '['New conversation', 'menu_new_conversation'],' TODO reactivate when encrypted chats are implemented ['Settings', 'menu_settings'], ['About', 'menu_about']], - 'productivity': [['Connected Devices', 'menu_connection'], + 'productivity': [// ['Connected Devices', 'menu_connection'], ['Settings', 'menu_settings'], ['About', 'menu_about']], - 'games': [['Connected Devices', 'menu_connection'], + 'games': [// ['Connected Devices', 'menu_connection'], ['Settings', 'menu_settings'], ['About', 'menu_about']], 'contacts': [['New contact', 'menu_new_contact'], - ['Connected Devices', 'menu_connection'], + // ['Connected Devices', 'menu_connection'], ['Settings', 'menu_settings'], ['About', 'menu_about']], 'connex': [['New SSB pub', 'menu_new_pub'], ['Redeem invite code', 'menu_invite'], - ['Connected Devices', 'menu_connection'], + // ['Connected Devices', 'menu_connection'], // ['Force sync', 'menu_sync'], ['Settings', 'menu_settings'], ['About', 'menu_about']], @@ -61,7 +61,7 @@ var scenarioMenu = { 'kanban': [['New Kanban board', 'menu_new_board'], ['Invitations', 'menu_board_invitations'], - ['Connected Devices', 'menu_connection'], + // ['Connected Devices', 'menu_connection'], ['Settings', 'menu_settings'], ['About', 'menu_about']], @@ -173,6 +173,16 @@ function setScenario(s) { } } + if (s == 'posts') { + // FIXME: the following does not reliably scroll to the end ... + let p = document.getElementById('div:posts'); + // console.log("scroll 1 " + p.scrollHeight) + p.scrollTop = p.scrollHeight; + // p.scrollTo(0, p.scrollHeight); // has same problem + + // var pl = document.getElementById('lst:posts'); // has same problem + // pl.rows[pl.rows.length-1].scrollIntoView() + } } } @@ -492,9 +502,17 @@ function refresh_goset_progressbar(curr, max) { document.getElementById('connection-overlay-progressbar-label-goset').textContent = "GoSet - " + delta + " key" + (delta > 1 ? "s" : "") + " left" if (delta > 0) { console.log("display progress") + // main html: + document.getElementById('gosetBar').style.display = "initial" + // document.getElementById('progressBars').style.display = "none" + // overlay: document.getElementById('goset-progress-container').style.display = "initial" document.getElementById('progress-container').style.display = "none" } else { + // main html: + document.getElementById('gosetBar').style.display = "none" + // document.getElementById('progressBars').style.display = "initial" + // overlay: document.getElementById('goset-progress-container').style.display = "none" document.getElementById('progress-container').style.display = "initial" } @@ -503,8 +521,7 @@ function refresh_goset_progressbar(curr, max) { var max_chnks = 0 function refresh_chunk_progressbar(remaining) { - - if(remaining != 0) { + if (remaining != 0) { max_chnks = Math.max(max_chnks, remaining) } else { max_chnks = 0 // reset @@ -512,16 +529,18 @@ function refresh_chunk_progressbar(remaining) { console.log("refresh_chunk_progressbar", remaining, max_chnks) - - if(remaining > 0) { - var percentage = (1 - ((remaining - 0) / (max_chnks - 0))) * 100 + if (remaining > 0) { + var percentage = Math.round( (1 - ((remaining - 0) / (max_chnks - 0))) * 100 ) + // main html: + document.getElementById('progBarChunks').style.width = `${percentage}%`; + // overlay: document.getElementById('connection-overlay-progressbar-chnk').value = percentage document.getElementById('connection-overlay-progressbar-label-chnk').textContent = remaining + " Chunks left" } else { - document.getElementById('connection-overlay-progressbar-chnk').value = 100 - document.getElementById('connection-overlay-progressbar-label-chnk').textContent = "Chunks — Synchronized" + document.getElementById('progBarChunks').style.width = '100%'; + document.getElementById('connection-overlay-progressbar-chnk').value = 100; + document.getElementById('connection-overlay-progressbar-label-chnk').textContent = "Chunks — Synchronized" } - } function refresh_connection_progressbar(min_entries, old_min_entries, old_want_entries, curr_want_entries, max_entries) { @@ -537,26 +556,26 @@ function refresh_connection_progressbar(min_entries, old_min_entries, old_want_e // update want progress - if(curr_want_entries >= max_entries || old_want_entries == max_entries) { + if (curr_want_entries >= max_entries || old_want_entries == max_entries) { + document.getElementById('progBarMissing').style.width = '100%'; document.getElementById('connection-overlay-progressbar-want').value = 100 document.getElementById('connection-overlay-progressbar-label-want').textContent = "Missing — Synchronized" } else { - var newPosReq = (curr_want_entries - old_want_entries) / (max_entries - old_want_entries) * 100 - + var newPosReq = Math.round((curr_want_entries - old_want_entries) / (max_entries - old_want_entries) * 100) console.log("newPosMax:", newPosReq) - + document.getElementById('progBarMissing').style.width = `${newPosReq}%`; document.getElementById('connection-overlay-progressbar-want').value = newPosReq document.getElementById('connection-overlay-progressbar-label-want').textContent = "Missing - " + (max_entries - curr_want_entries) + " entries left" - } // update gift progress if (curr_want_entries <= min_entries || old_min_entries == curr_want_entries) { + document.getElementById('progBarAhead').style.width = '100%'; document.getElementById('connection-overlay-progressbar-gift').value = 100 document.getElementById('connection-overlay-progressbar-label-gift').textContent = "Ahead — Synchronized" } else { - var newPosOff = (min_entries - old_min_entries) / (curr_want_entries - old_min_entries) * 100 - + var newPosOff = Math.round((min_entries - old_min_entries) / (curr_want_entries - old_min_entries) * 100) + document.getElementById('progBarAhead').style.width = `${newPosOff}%`; document.getElementById('connection-overlay-progressbar-gift').value = newPosOff document.getElementById('connection-overlay-progressbar-label-gift').textContent = "Ahead - " + (curr_want_entries - min_entries) + " entries left" } 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 e1972c3..564ccae 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 @@ -90,7 +90,12 @@ 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 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + 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()