mirror of
https://github.com/yggdrasil-network/yggdrasil-android.git
synced 2025-04-27 21:55:08 +03:00
Build 5
This commit is contained in:
parent
fa9532fb97
commit
27e1909aa2
6 changed files with 70 additions and 34 deletions
|
@ -11,7 +11,7 @@ android {
|
||||||
applicationId "eu.neilalexander.yggdrasil"
|
applicationId "eu.neilalexander.yggdrasil"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 4
|
versionCode 5
|
||||||
versionName "0.1"
|
versionName "0.1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.neilalexander.yggdrasil
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import mobile.Mobile
|
import mobile.Mobile
|
||||||
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -40,6 +41,18 @@ object ConfigurationProxy {
|
||||||
json.put("AdminListen", "none")
|
json.put("AdminListen", "none")
|
||||||
json.put("IfName", "none")
|
json.put("IfName", "none")
|
||||||
json.put("IfMTU", 65535)
|
json.put("IfMTU", 65535)
|
||||||
|
|
||||||
|
if (json.getJSONArray("MulticastInterfaces").get(0) is String) {
|
||||||
|
var ar = JSONArray()
|
||||||
|
ar.put(0, JSONObject("""
|
||||||
|
{
|
||||||
|
"Regex": ".*",
|
||||||
|
"Beacon": true,
|
||||||
|
"Listen": true
|
||||||
|
}
|
||||||
|
""".trimIndent()))
|
||||||
|
json.put("MulticastInterfaces", ar)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,4 +64,20 @@ object ConfigurationProxy {
|
||||||
fun getJSONByteArray(): ByteArray {
|
fun getJSONByteArray(): ByteArray {
|
||||||
return json.toString().toByteArray(Charsets.UTF_8)
|
return json.toString().toByteArray(Charsets.UTF_8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var multicastListen: Boolean
|
||||||
|
get() = (json.getJSONArray("MulticastInterfaces").get(0) as JSONObject).getBoolean("Listen")
|
||||||
|
set(value) {
|
||||||
|
updateJSON { json ->
|
||||||
|
(json.getJSONArray("MulticastInterfaces").get(0) as JSONObject).put("Listen", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var multicastBeacon: Boolean
|
||||||
|
get() = (json.getJSONArray("MulticastInterfaces").get(0) as JSONObject).getBoolean("Beacon")
|
||||||
|
set(value) {
|
||||||
|
updateJSON { json ->
|
||||||
|
(json.getJSONArray("MulticastInterfaces").get(0) as JSONObject).put("Beacon", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@ import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import mobile.Mobile
|
import mobile.Mobile
|
||||||
import org.json.JSONArray
|
|
||||||
|
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
@ -34,7 +33,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
findViewById<TextView>(R.id.versionValue).text = Mobile.getVersion()
|
findViewById<TextView>(R.id.versionValue).text = Mobile.getVersion()
|
||||||
|
|
||||||
enabledSwitch = findViewById(R.id.enableMulticastSwitch)
|
enabledSwitch = findViewById(R.id.enableMulticastBeacon)
|
||||||
enabledLabel = findViewById(R.id.yggdrasilStatusLabel)
|
enabledLabel = findViewById(R.id.yggdrasilStatusLabel)
|
||||||
ipAddressLabel = findViewById(R.id.ipAddressValue)
|
ipAddressLabel = findViewById(R.id.ipAddressValue)
|
||||||
subnetLabel = findViewById(R.id.subnetValue)
|
subnetLabel = findViewById(R.id.subnetValue)
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
package eu.neilalexander.yggdrasil
|
package eu.neilalexander.yggdrasil
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
|
||||||
import android.content.DialogInterface
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Layout
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -24,7 +19,8 @@ class PeersActivity : AppCompatActivity() {
|
||||||
private lateinit var connectedTableLabel: TextView
|
private lateinit var connectedTableLabel: TextView
|
||||||
private lateinit var configuredTableLayout: TableLayout
|
private lateinit var configuredTableLayout: TableLayout
|
||||||
private lateinit var configuredTableLabel: TextView
|
private lateinit var configuredTableLabel: TextView
|
||||||
private lateinit var multicastSwitch: Switch
|
private lateinit var multicastListenSwitch: Switch
|
||||||
|
private lateinit var multicastBeaconSwitch: Switch
|
||||||
private lateinit var addPeerButton: ImageButton
|
private lateinit var addPeerButton: ImageButton
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -40,29 +36,16 @@ class PeersActivity : AppCompatActivity() {
|
||||||
configuredTableLayout = findViewById(R.id.configuredPeersTableLayout)
|
configuredTableLayout = findViewById(R.id.configuredPeersTableLayout)
|
||||||
configuredTableLabel = findViewById(R.id.configuredPeersLabel)
|
configuredTableLabel = findViewById(R.id.configuredPeersLabel)
|
||||||
|
|
||||||
multicastSwitch = findViewById(R.id.enableMulticastSwitch)
|
multicastListenSwitch = findViewById(R.id.enableMulticastListen)
|
||||||
multicastSwitch.setOnCheckedChangeListener { button, _ ->
|
multicastListenSwitch.setOnCheckedChangeListener { button, _ ->
|
||||||
when (button.isChecked) {
|
config.multicastListen = button.isChecked
|
||||||
true -> {
|
|
||||||
config.updateJSON { json ->
|
|
||||||
json.put("MulticastInterfaces", JSONArray("[\"lo\", \".*\"]"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
false -> {
|
|
||||||
config.updateJSON { json ->
|
|
||||||
json.put("MulticastInterfaces", JSONArray("[\"lo\"]"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var multicastInterfaceFound = false
|
multicastBeaconSwitch = findViewById(R.id.enableMulticastBeacon)
|
||||||
val multicastInterfaces = config.getJSON().getJSONArray("MulticastInterfaces")
|
multicastBeaconSwitch.setOnCheckedChangeListener { button, _ ->
|
||||||
(0 until multicastInterfaces.length()).forEach {
|
config.multicastBeacon = button.isChecked
|
||||||
if (multicastInterfaces[it] == ".*") {
|
|
||||||
multicastInterfaceFound = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
multicastSwitch.isChecked = multicastInterfaceFound
|
multicastListenSwitch.isChecked = config.multicastListen
|
||||||
|
multicastBeaconSwitch.isChecked = config.multicastBeacon
|
||||||
|
|
||||||
addPeerButton = findViewById(R.id.addPeerButton)
|
addPeerButton = findViewById(R.id.addPeerButton)
|
||||||
addPeerButton.setOnClickListener {
|
addPeerButton.setOnClickListener {
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
android:layout_weight="2" />
|
android:layout_weight="2" />
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/enableMulticastSwitch"
|
android:id="@+id/enableMulticastBeacon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
|
|
@ -168,17 +168,42 @@
|
||||||
android:showDividers="middle">
|
android:showDividers="middle">
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:id="@+id/peersTableRow"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:paddingStart="4pt"
|
android:paddingStart="4pt"
|
||||||
android:paddingTop="2pt"
|
android:paddingTop="2pt"
|
||||||
android:paddingEnd="4pt"
|
android:paddingEnd="4pt"
|
||||||
|
android:paddingBottom="4pt">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Discoverable over multicast"
|
||||||
|
android:textColor="?attr/textDefault" />
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/enableMulticastBeacon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:paddingStart="4pt"
|
||||||
|
android:paddingTop="4pt"
|
||||||
|
android:paddingEnd="4pt"
|
||||||
android:paddingBottom="2pt">
|
android:paddingBottom="2pt">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/multicastLabel"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Search for multicast peers"
|
android:text="Search for multicast peers"
|
||||||
|
@ -190,7 +215,7 @@
|
||||||
android:layout_weight="2" />
|
android:layout_weight="2" />
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/enableMulticastSwitch"
|
android:id="@+id/enableMulticastListen"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue