mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2025-01-22 07:56:30 +00:00
1. added copy peer info/dns info to clipboard
This commit is contained in:
parent
0857d15340
commit
664c39d315
@ -8,7 +8,7 @@ android {
|
|||||||
applicationId "io.github.chronosx88.yggdrasil"
|
applicationId "io.github.chronosx88.yggdrasil"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 14
|
versionCode 15
|
||||||
versionName "1.6"
|
versionName "1.6"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
setProperty("archivesBaseName", project.getParent().name+"-"+versionName)
|
setProperty("archivesBaseName", project.getParent().name+"-"+versionName)
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package io.github.chronosx88.yggdrasil.models.config
|
package io.github.chronosx88.yggdrasil.models.config
|
||||||
|
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.*
|
||||||
import android.widget.CheckBox
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import io.github.chronosx88.yggdrasil.R
|
import io.github.chronosx88.yggdrasil.R
|
||||||
import io.github.chronosx88.yggdrasil.models.DNSInfo
|
import io.github.chronosx88.yggdrasil.models.DNSInfo
|
||||||
|
|
||||||
@ -66,6 +66,14 @@ class SelectDNSInfoListAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dnsInfoHolder.dnsInfoText.setOnClickListener {
|
||||||
|
val clipboard: ClipboardManager =
|
||||||
|
context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clip =
|
||||||
|
ClipData.newPlainText("DNS info", dnsId)
|
||||||
|
clipboard.setPrimaryClip(clip)
|
||||||
|
showToast(dnsId + " " + context.getString(R.string.node_info_copied))
|
||||||
|
}
|
||||||
dnsInfoHolder.checkbox.isChecked = this.currentDNS.contains(currentDNS)
|
dnsInfoHolder.checkbox.isChecked = this.currentDNS.contains(currentDNS)
|
||||||
return listItem!!
|
return listItem!!
|
||||||
}
|
}
|
||||||
@ -100,4 +108,11 @@ class SelectDNSInfoListAdapter(
|
|||||||
lateinit var dnsInfoText: TextView
|
lateinit var dnsInfoText: TextView
|
||||||
lateinit var ping: TextView
|
lateinit var ping: TextView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showToast(text: String){
|
||||||
|
val duration = Toast.LENGTH_SHORT
|
||||||
|
val toast = Toast.makeText(context, text, duration)
|
||||||
|
toast.setGravity(Gravity.CENTER, 0, 0)
|
||||||
|
toast.show()
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
package io.github.chronosx88.yggdrasil.models.config
|
package io.github.chronosx88.yggdrasil.models.config
|
||||||
|
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.*
|
||||||
import android.widget.CheckBox
|
|
||||||
import android.widget.ImageView
|
|
||||||
import android.widget.TextView
|
|
||||||
import io.github.chronosx88.yggdrasil.R
|
import io.github.chronosx88.yggdrasil.R
|
||||||
import io.github.chronosx88.yggdrasil.models.PeerInfo
|
import io.github.chronosx88.yggdrasil.models.PeerInfo
|
||||||
|
|
||||||
@ -46,12 +46,11 @@ class SelectPeerInfoListAdapter(
|
|||||||
val currentPeer = allPeers[position]
|
val currentPeer = allPeers[position]
|
||||||
peerInfoHolder.countryFlag.setImageResource(currentPeer.getCountry(mContext)!!.flagID)
|
peerInfoHolder.countryFlag.setImageResource(currentPeer.getCountry(mContext)!!.flagID)
|
||||||
val peerId = currentPeer.toString()
|
val peerId = currentPeer.toString()
|
||||||
|
peerInfoHolder.peerInfoText.text = peerId
|
||||||
if(currentPeer.ping == Int.MAX_VALUE){
|
if(currentPeer.ping == Int.MAX_VALUE){
|
||||||
peerInfoHolder.peerInfoText.text = peerId
|
|
||||||
peerInfoHolder.ping.text=""
|
peerInfoHolder.ping.text=""
|
||||||
peerInfoHolder.peerInfoText.setTextColor(Color.GRAY)
|
peerInfoHolder.peerInfoText.setTextColor(Color.GRAY)
|
||||||
} else {
|
} else {
|
||||||
peerInfoHolder.peerInfoText.text = peerId
|
|
||||||
peerInfoHolder.ping.text = currentPeer.ping.toString() + " ms"
|
peerInfoHolder.ping.text = currentPeer.ping.toString() + " ms"
|
||||||
peerInfoHolder.peerInfoText.setTextColor(Color.WHITE)
|
peerInfoHolder.peerInfoText.setTextColor(Color.WHITE)
|
||||||
}
|
}
|
||||||
@ -66,6 +65,14 @@ class SelectPeerInfoListAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
peerInfoHolder.peerInfoText.setOnClickListener {
|
||||||
|
val clipboard: ClipboardManager =
|
||||||
|
context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clip =
|
||||||
|
ClipData.newPlainText("Peer info", peerId)
|
||||||
|
clipboard.setPrimaryClip(clip)
|
||||||
|
showToast(peerId + " " + context.getString(R.string.node_info_copied))
|
||||||
|
}
|
||||||
peerInfoHolder.checkbox.isChecked = this.currentPeers.contains(currentPeer)
|
peerInfoHolder.checkbox.isChecked = this.currentPeers.contains(currentPeer)
|
||||||
return listItem!!
|
return listItem!!
|
||||||
}
|
}
|
||||||
@ -107,4 +114,10 @@ class SelectPeerInfoListAdapter(
|
|||||||
lateinit var ping: TextView
|
lateinit var ping: TextView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showToast(text: String){
|
||||||
|
val duration = Toast.LENGTH_SHORT
|
||||||
|
val toast = Toast.makeText(context, text, duration)
|
||||||
|
toast.setGravity(Gravity.CENTER, 0, 0)
|
||||||
|
toast.show()
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user