Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #39 from vikulin/master
Browse files Browse the repository at this point in the history
Bug fixes and improvements
  • Loading branch information
ChronosXYZ authored Dec 28, 2020
2 parents 7294166 + e602382 commit 70fce5d
Show file tree
Hide file tree
Showing 25 changed files with 545 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/yggdrasil/yggdrasil-sources.jar
/app/src/main/assets/yggdrasil-0.3.8-linux-arm64
/app/src/main/assets/yggdrasil-0.3.8-linux-armhf
/.idea/
16 changes: 11 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "io.github.chronosx88.yggdrasil"
minSdkVersion 15
targetSdkVersion 30
versionCode 5
versionName "1.5"
versionCode 16
versionName "1.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", project.getParent().name+"-"+versionName)
}
Expand Down Expand Up @@ -42,6 +42,10 @@ android {
// but continue the build even when errors are found:
abortOnError false
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}

task ndkBuild(type: Exec) {
Expand All @@ -59,16 +63,18 @@ dependencies {
implementation project(path: ':yggdrasil')

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.preference:preference-ktx:1.1.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
implementation 'com.google.android.material:material:1.3.0-alpha02'
implementation 'com.google.android.material:material:1.3.0-alpha04'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.hbb20:ccp:2.4.0'
implementation 'com.vincentbrison.openlibraries.android:dualcache:3.1.1'
implementation 'com.vincentbrison.openlibraries.android:dualcache-jsonserializer:3.1.1'

testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
android:label="@string/title_activity_dns_list"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"/>
<activity
android:name=".CopyLocalNodeInfoActivity"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_copy_local_node_info"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"/>
<service
android:name=".YggdrasilTunService"
android:enabled="true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.github.chronosx88.yggdrasil

import android.os.Bundle
import android.widget.ListView
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceManager
import io.github.chronosx88.yggdrasil.models.NodeInfo
import io.github.chronosx88.yggdrasil.models.config.CopyInfoAdapter
import io.github.chronosx88.yggdrasil.models.config.SelectDNSInfoListAdapter

class CopyLocalNodeInfoActivity: AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_copy_local_node_info)
setSupportActionBar(findViewById(R.id.toolbar))
val preferences =
PreferenceManager.getDefaultSharedPreferences(this.baseContext)
val ipv6Address = intent.extras!!.getString(MainActivity.IPv6, "")
val signingPublicKey = preferences.getString(MainActivity.signingPublicKey, "")
val encryptionPublicKey = preferences.getString(MainActivity.encryptionPublicKey, "")
var nodeInfoListView = findViewById<ListView>(R.id.nodeInfoList)
val nodeInfoList = listOf<NodeInfo>(NodeInfo("IP address", ipv6Address!!), NodeInfo("Encryption Public Key", encryptionPublicKey!!), NodeInfo("Signing Public Key", signingPublicKey!!));
var adapter = CopyInfoAdapter(this, nodeInfoList)
nodeInfoListView.adapter = adapter
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class DNSListActivity : AppCompatActivity() {
try {

for (d in cd) {
var ping = ping(d.address, 53)
var ping = ping(d.address.hostAddress, 53)
d.ping = ping
}
for (dns in allDNS) {
var ping = ping(dns.address, 53)
var ping = ping(dns.address.hostAddress, 53)
dns.ping = ping
runOnUiThread(
Runnable
Expand Down Expand Up @@ -110,7 +110,7 @@ class DNSListActivity : AppCompatActivity() {
thread(start = true) {
var di = DNSInfo(InetAddress.getByName("["+ip+"]"), ccp, "User DNS")
try {
var ping = ping(di.address, 53)
var ping = ping(di.address.hostAddress, 53)
di.ping = ping
} catch(e: Throwable){
di.ping = Int.MAX_VALUE
Expand All @@ -127,7 +127,7 @@ class DNSListActivity : AppCompatActivity() {

override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.save, menu)
menuInflater.inflate(R.menu.save_dns, menu)
val item = menu.findItem(R.id.saveItem) as MenuItem
item.setActionView(R.layout.menu_save)
val saveButton = item
Expand Down
32 changes: 21 additions & 11 deletions app/src/main/java/io/github/chronosx88/yggdrasil/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,21 @@ class MainActivity : AppCompatActivity() {
)
val adapter = PeerInfoListAdapter(this, currentPeers.sortedWith(compareBy { it.ping }))
peersListView.adapter = adapter

if (adapter.count > 10) {
val item = adapter.getView(0, null, peersListView)
item.measure(0, 0)
val params = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
(10 * item.measuredHeight).toInt()
)
peersListView.layoutParams = params
}

if(isStarted && this.currentPeers.isEmpty()) {
updatePeers()
}
val copyAddressButton = findViewById<Button>(R.id.copyIp)
copyAddressButton.setOnClickListener {
val ip = findViewById<TextView>(R.id.ip)
val clipboard: ClipboardManager =
getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip =
ClipData.newPlainText("IP address", ip.text.toString())
clipboard.setPrimaryClip(clip)
showToast(getString(R.string.address_copied))
}

val editPeersButton = findViewById<Button>(R.id.edit)
editPeersButton.setOnClickListener {
if(isStarted){
Expand Down Expand Up @@ -150,6 +152,14 @@ class MainActivity : AppCompatActivity() {
intent.putStringArrayListExtra(DNS_LIST, serializeDNSInfoSet2StringList(currentDNS))
startActivityForResult(intent, DNS_LIST_CODE)
}
val nodeInfoButton = findViewById<Button>(R.id.nodeInfo)
nodeInfoButton.setOnClickListener {
if(isStarted) {
val intent = Intent(this@MainActivity, CopyLocalNodeInfoActivity::class.java)
intent.putExtra(IPv6, findViewById<TextView>(R.id.ip).text.toString())
startActivity(intent)
}
}
if(isStarted){
val ipLayout = findViewById<LinearLayout>(R.id.ipLayout)
ipLayout.visibility = View.VISIBLE
Expand Down Expand Up @@ -404,7 +414,7 @@ class MainActivity : AppCompatActivity() {
super.onRestoreInstanceState(savedInstanceState)
val preferences =
PreferenceManager.getDefaultSharedPreferences(this.baseContext)
findViewById<Switch>(R.id.staticIP).isChecked =
findViewById<SwitchCompat>(R.id.staticIP).isChecked =
preferences.getString(STATIC_IP, null) != null
}

Expand Down
Loading

0 comments on commit 70fce5d

Please sign in to comment.