Merge pull request #16 from vikulin/master

DNS only number in IP fix, #12 task
This commit is contained in:
Vadym Vikulin 2020-07-19 19:55:31 +03:00 committed by GitHub
commit d7b6a66f5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 18 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "io.github.chronosx88.yggdrasil"
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "1.2"
versionCode 3
versionName "1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
project.ext.set("archivesBaseName", project.getParent().name+"-"+versionName)
}

View File

@ -16,11 +16,13 @@
tools:ignore="GoogleAppIndexingWarning">
<activity
android:name=".PeerListActivity"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_peer_list"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"/>
<activity
android:name=".DNSListActivity"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_dns_list"
android:theme="@style/AppTheme.NoActionBar"
android:screenOrientation="portrait"/>

View File

@ -100,7 +100,9 @@ class MainActivity : AppCompatActivity() {
currentPeers = deserializeStringSet2PeerInfoSet(preferences.getStringSet(CURRENT_PEERS, HashSet())!!)
val adapter = PeerInfoListAdapter(this, currentPeers.sortedWith(compareBy { it.ping }))
peersListView.adapter = adapter
if(isStarted && this.currentPeers.isEmpty()) {
updatePeers()
}
val copyAddressButton = findViewById<Button>(R.id.copyIp)
copyAddressButton.setOnClickListener {
val ip = findViewById<TextView>(R.id.ip)
@ -185,6 +187,18 @@ class MainActivity : AppCompatActivity() {
startService(intent)
}
private fun checkPeers(){
//this is Mesh mode, send Peers update every 5 sec
thread(start = true) {
while(true) {
Thread.sleep(5000)
if(isStarted && this.currentPeers.isEmpty()) {
updatePeers()
}
}
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
@ -251,15 +265,7 @@ class MainActivity : AppCompatActivity() {
STATUS_START -> {
print("service started")
if(this.currentPeers.isEmpty()){
//this is Mesh mode, send Peers update every 5 sec
thread(start = true) {
while(true) {
Thread.sleep(5000)
if(isStarted && this.currentPeers.isEmpty()) {
updatePeers()
}
}
}
checkPeers()
}
}
STATUS_FINISH -> {

View File

@ -1,9 +1,6 @@
package io.github.chronosx88.yggdrasil
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.app.*
import android.content.Context
import android.content.Intent
import android.net.ConnectivityManager
@ -292,8 +289,13 @@ class YggdrasilTunService : VpnService() {
// https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context)
""
}
var intent = Intent(this, MainActivity::class.java)
var stackBuilder = TaskStackBuilder.create(this)
stackBuilder.addNextIntentWithParentStack(intent)
var pi = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
val b = NotificationCompat.Builder(this, channelId)
b.setOngoing(true)
.setContentIntent(pi)
.setContentTitle(getString(R.string.app_name))
.setContentText(text)
.setSmallIcon(R.mipmap.ic_launcher)

View File

@ -21,7 +21,7 @@
android:id="@+id/ipInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:digits="0,1,2,3,4,5,6,7,8,9,:"
android:digits="0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,:"
android:hint="IPv6"
android:inputType="textNoSuggestions"
android:textColor="@color/white"

View File

@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files