Skip to content

Commit

Permalink
merge, and remove main background (go from splash directly to WebKit …
Browse files Browse the repository at this point in the history
…background)
  • Loading branch information
tschudin committed Sep 5, 2021
2 parents 45a01f3 + 45f24c9 commit bc9cd86
Show file tree
Hide file tree
Showing 19 changed files with 58 additions and 195 deletions.
50 changes: 13 additions & 37 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@ plugins {
// apply plugin: "kotlin-kapt"

android {
/*
signingConfigs {
release {
}
}
*/
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "nz.scuttlebutt.tremola"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName '0.1'
versionCode 2
versionName '0.1.1'
ndk {
abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86'
}

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled false
}

Expand Down Expand Up @@ -68,43 +73,25 @@ android {
}

dependencies {
api 'com.google.guava:guava:28.0-android'
api 'com.google.guava:guava:30.1.1-jre'

//JETBRAINS KOTLIN
implementation "org.jetbrains.kotlin:kotlin-reflect:1.5.20"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30"

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
// testImplementation 'junit:junit:4.+'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' // $legacy_support_version
// androidTestImplementation 'androidx.test.ext:junit:1.1.3'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.journeyapps:zxing-android-embedded:4.1.0'

implementation 'com.journeyapps:zxing-android-embedded:4.2.0'
implementation 'com.google.zxing:core:3.4.1'
// kapt 'androidx.databinding:databinding-compiler:1.0.0'

//LAZY SODIUM
implementation 'com.goterl:lazysodium-android:5.0.2@aar'
implementation 'net.java.dev.jna:jna:5.8.0@aar'

//MOSHI
implementation "com.squareup.moshi:moshi-kotlin:1.8.0"
implementation "com.squareup.moshi:moshi-adapters:1.11.0"
kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.11.0'

//OKIO
// implementation group: 'com.squareup.okio', name: 'okio', version: '2.10.0'

//REACTIVEX
// implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
// implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
// implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
implementation 'net.java.dev.jna:jna:5.9.0@aar'

//ROOM
implementation "androidx.room:room-runtime:2.3.0"
Expand All @@ -114,15 +101,4 @@ dependencies {
implementation "androidx.room:room-guava:2.3.0"
// testImplementation "androidx.room:room-testing:2.3.0"

//DAGGER
implementation "com.google.dagger:dagger:2.35.1"
kapt 'com.google.dagger:dagger-compiler:2.38.1'
implementation 'com.google.dagger:dagger-android:2.38.1'
kapt 'com.google.dagger:dagger-android-processor:2.38.1'
kapt "com.google.dagger:dagger-android-support:2.21"
annotationProcessor "com.google.dagger:dagger-android-processor:2.21"

// JAX-B dependencies for JDK 9+
// implementation "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
// implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
}
7 changes: 6 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile

# for libsodium:
-dontwarn java.awt.*
-keep class com.sun.jna.* { *; }
-keepclassmembers class * extends com.sun.jna.* { public *; }
Binary file added app/src/main/assets/web/img/map-1862.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/assets/web/img/map-1862.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
10 changes: 5 additions & 5 deletions app/src/main/assets/web/tremola.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script type="text/javascript" charset="UTF-8" src="tremola_ui.js"></script>
<script type="text/javascript" charset="UTF-8" src="qrcode.min.js"></script>
</head>
<body style="background-image: url('img/splash-as-background.png'); background-size: cover; background-color: white; overflow: hidden" onload="backend('ready');">
<body style="background-image: url('img/splash-as-background.jpg'); background-size: cover; background-color: white; overflow: hidden" onload="backend('ready');">
<div style="width: 100%; height: 100%; margin: 0px">

<div id='menu' class='menu-overlay'>
Expand All @@ -18,7 +18,7 @@
</div>

<div id='hdr' style="height: 45px;margin: 3px; width: calc(100% - 6px);">
<div width=100% style="display:flex; flex-direction: row; justify-content: center; align-items: center;">
<div style="display:flex; flex-direction: row; justify-content: center; align-items: center;">
<div id="div:qr" style="align: left;"><button id='btn:qr' class="flat" onclick="showQR();" style="background-color: transparent;"><font size=+2><strong>&nbsp;&#x2680;&nbsp;</strong></font></button></div>
<div id="div:back" style="display: none; padding-right: 10px;"><button id='back' class="flat buttontext" style="background-image: url('img/back.svg'); background-color: transparent; height: 25px; width: 25px; margin-left: 5px; margin-top: 2px;" onclick="onBackPressed();">&nbsp;<!--font size=+2><strong>&nbsp;&#x276E;&nbsp;</strong></font --></button></div>
<div id='tremolaTitle' align=center style="padding-top: 2pt; width: 100%;font-family: Helvetica;font-weight: 900;"><font size=+2 color=#e85132>T R E M O L A<!-- &#x26F0; --></font></div>
Expand Down Expand Up @@ -114,7 +114,7 @@
<div id='preview-overlay' class='qr-overlay'>
<div id='preview' style="overflow: scroll; font-size: medium; height: calc(100% - 30pt);">to_be_filled</div>
<div>
<table><tr height=40pt>
<table><tr>
<td width=90% height=100%><button class="flat passive buttontext" onclick="closeOverlay();" style="height: 40px; color: red; background-image: url('img/cancel.svg'); width: 100%;">&nbsp;</button>
<td width=10% height=100%><button class="flat passive buttontext" style="height: 40px; background-image: url('img/checked.svg'); width: 35px;" onclick="new_post(document.getElementById('draft').value);">&nbsp;</button>
</table>
Expand All @@ -131,7 +131,7 @@

<div id='about-overlay' class='qr-overlay' style="overflow: scroll; font-size: medium; height: 75%;">
<div style="text-align: center;">
<font size=+1><em>About</em></font><br><img src="img/map-1862.png" style="height: 8em;">
<font size=+1><em>About</em></font><br><img src="img/map-1862.jpg" style="height: 8em;">
<font size=-2>
<p>Tremola v0.1, August 2021

Expand Down Expand Up @@ -292,7 +292,7 @@
<del>Import new secret key (also erases DB)</del></button><hr>
<p><button class="w100 button active item" style="height: 3em;" onclick="backend('exportSecret');">
Export secret key</button><hr>
<p>&nbsp;<br>&nbsp;<br>&nbsp;<br><button class="w100 button active item" style="height: 2.5em;" onclick="settings_wipe()";>
<p>&nbsp;<br>&nbsp;<br>&nbsp;<br><button class="w100 button active item" style="height: 2.5em;" onclick="settings_wipe();">
<span style="color: var(--red);font-weight: 900;">WIPE EVERYTHING IMMEDIATELY</span></button><hr>
&nbsp;
</div></div>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/web/tremola_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getSetting(nm) {
function applySetting(nm, val) {
if (nm == 'background_map') {
if (val)
document.body.style.backgroundImage = "url('img/splash-as-background.png')";
document.body.style.backgroundImage = "url('img/splash-as-background.jpg')";
else
document.body.style.backgroundImage = null;
} else if (nm == 'hide_forgotten_conv') {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/nz/scuttlebutt/tremola/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
requestWindowFeature(Window.FEATURE_NO_TITLE)
setContentView(R.layout.activity_main)
tremolaState = TremolaState(this)
Expand Down Expand Up @@ -105,7 +105,7 @@ class MainActivity : Activity() {
}

val t1 = thread(isDaemon=true) {
val wifi = getSystemService(WIFI_SERVICE) as WifiManager
val wifi = applicationContext.getSystemService(WIFI_SERVICE) as WifiManager
val mLock = wifi.createMulticastLock("lock")
mLock.acquire()
try {
Expand All @@ -116,7 +116,7 @@ class MainActivity : Activity() {
}
val t2 = thread(isDaemon=true) { // accept loop, robust against reassigned server_socket
while (true) {
var socket: Socket? = null
var socket: Socket?
try {
socket = server_socket!!.accept()
} catch (e: Exception) {
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/java/nz/scuttlebutt/tremola/ssb/TremolaState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import nz.scuttlebutt.tremola.ssb.db.entities.Pub
import nz.scuttlebutt.tremola.ssb.core.IdStore
import nz.scuttlebutt.tremola.ssb.db.daos.LogEntryDAO
import nz.scuttlebutt.tremola.ssb.db.entities.LogEntry
import nz.scuttlebutt.tremola.utils.Constants.Companion.EBT_FORCE_FRONTIER_INTERVAL
import nz.scuttlebutt.tremola.utils.Constants.Companion.WIFI_DISCOVERY_INTERVAL


class TremolaState(val context: Context) {
Expand Down Expand Up @@ -46,12 +48,12 @@ class TremolaState(val context: Context) {
val s = u.split("~")
val a = "@" + s[1].substring(4) + ".ed25519"
val h = s[0].split(":")
peers.add(h[1], h[2].toInt(), a)
peers.add(h[1], h[2].toInt(), a) // will filter out already connected peers
}
}, 3, 5, TimeUnit.SECONDS)
}, 3, WIFI_DISCOVERY_INTERVAL, TimeUnit.SECONDS)
executorPool.scheduleAtFixedRate({ // kick EBT (send current frontier) on regular intervals
peers.kick()
}, 5, 10, TimeUnit.SECONDS)
}, 5, EBT_FORCE_FRONTIER_INTERVAL, TimeUnit.SECONDS)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package nz.scuttlebutt.tremola.ssb.peering

import android.content.Context
import android.net.DhcpInfo
import android.net.wifi.WifiManager
import android.text.format.Formatter.formatIpAddress
import android.util.Base64
import android.util.Log
import nz.scuttlebutt.tremola.MainActivity
import nz.scuttlebutt.tremola.WebAppInterface
import nz.scuttlebutt.tremola.utils.Constants
import java.lang.Thread.sleep
import java.net.DatagramPacket
import java.net.InetAddress
import java.util.concurrent.locks.ReentrantLock

import nz.scuttlebutt.tremola.MainActivity
import nz.scuttlebutt.tremola.WebAppInterface
import nz.scuttlebutt.tremola.utils.Constants
import nz.scuttlebutt.tremola.utils.Constants.Companion.UDP_BROADCAST_INTERVAL

class UDPbroadcast(val context: MainActivity, val wai: WebAppInterface?) {

Expand All @@ -37,9 +37,7 @@ class UDPbroadcast(val context: MainActivity, val wai: WebAppInterface?) {
myMark = "net:${formatIpAddress(myAddr)}:${myTcpPort}~shs:" +
Base64.encodeToString(pubkey, Base64.NO_WRAP)
val buf = myMark!!.encodeToByteArray()
// Log.d("UDP BEACON", "${myMark}")
val d = DatagramPacket(buf, buf.size, bcastAddr, Constants.SSB_IPV4_UDPPORT)
return d
return DatagramPacket(buf, buf.size, bcastAddr, Constants.SSB_IPV4_UDPPORT)
}

while (true) {
Expand All @@ -51,7 +49,8 @@ class UDPbroadcast(val context: MainActivity, val wai: WebAppInterface?) {
Log.d("beacon", "sent ${myMark}") }
catch (e: Exception) { // wait for better times
Log.d("Beacon exc", e.toString())
sleep(3000)
sleep(UDP_BROADCAST_INTERVAL)
// dgram = mkDgram()
continue
}
sleep(3000)
Expand All @@ -67,18 +66,19 @@ class UDPbroadcast(val context: MainActivity, val wai: WebAppInterface?) {
}
} finally { lck.unlock() }
}
Log.d("BEACON", "ended")
// Log.d("BEACON", "ended")
}

fun listen(lck: ReentrantLock) {
val buf = ByteArray(256)
val ingram = DatagramPacket(buf, buf.size)
while (true) {
val s = context.broadcast_socket
// val s = context.broadcast_socket
// blocks?? Log.d("listen", "${s}, ports=${s?.port}/${s?.localPort} closed=${s?.isClosed} bound=${s?.isBound}")
try { context.broadcast_socket?.receive(ingram) }
catch (e: Exception) {
sleep(3000) // wait for better conditions
// Log.d("Broadcast listen", "e=${e}, bsock=${context.broadcast_socket}")
sleep(UDP_BROADCAST_INTERVAL) // wait for better conditions
continue
}
val incoming = ingram.data.decodeToString(0, ingram.length)
Expand All @@ -96,5 +96,6 @@ class UDPbroadcast(val context: MainActivity, val wai: WebAppInterface?) {
}
}
}
// Log.d("LISTEN", "ended")
}
}

This file was deleted.

Loading

0 comments on commit bc9cd86

Please sign in to comment.