mirror of
https://github.com/yggdrasil-network/crispa-android.git
synced 2024-11-09 12:01:01 +00:00
1. allow empty peer list fo WiFi Direct
This commit is contained in:
parent
c0a779ce3c
commit
b09f180020
@ -87,8 +87,9 @@ class MainActivity : AppCompatActivity() {
|
||||
isStarted = isYggServiceRunning(this)
|
||||
val switchOn = findViewById<Switch>(R.id.switchOn)
|
||||
switchOn.isChecked = isStarted
|
||||
val wifiDirect = findViewById<Switch>(R.id.wifiDirect)
|
||||
switchOn.setOnCheckedChangeListener { _, isChecked ->
|
||||
if(currentPeers.isEmpty()){
|
||||
if(currentPeers.isEmpty() && !wifiDirect.isChecked){
|
||||
switchOn.isChecked = false
|
||||
return@setOnCheckedChangeListener
|
||||
}
|
||||
@ -104,7 +105,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
val wifiDirect = findViewById<Switch>(R.id.wifiDirect)
|
||||
|
||||
wifiDirect.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
this,
|
||||
@ -242,9 +243,10 @@ class MainActivity : AppCompatActivity() {
|
||||
if (requestCode == PEER_LIST_CODE && resultCode== Activity.RESULT_OK){
|
||||
if(data!!.extras!=null){
|
||||
var currentPeers = data.extras!!.getStringArrayList(PEER_LIST)
|
||||
if(currentPeers==null || currentPeers.size==0){
|
||||
showToast("No peers selected!")
|
||||
} else {
|
||||
/*WiFi Direct test. need peer empty list*/
|
||||
//if(currentPeers==null || currentPeers.size==0){
|
||||
// showToast("No peers selected!")
|
||||
//} else {
|
||||
this.currentPeers = deserializeStringList2PeerInfoSet(currentPeers)
|
||||
val adapter = PeerInfoListAdapter(this, this.currentPeers.sortedWith(compareBy { it.ping }))
|
||||
val listView = findViewById<ListView>(R.id.peers)
|
||||
@ -264,7 +266,7 @@ class MainActivity : AppCompatActivity() {
|
||||
i.putExtra(START_VPN, true)
|
||||
startActivity(i)
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,6 +133,7 @@ class PeerListActivity : AppCompatActivity() {
|
||||
val result = Intent(this, MainActivity::class.java)
|
||||
var adapter = findViewById<ListView>(R.id.peerList).adapter as SelectPeerInfoListAdapter
|
||||
val selectedPeers = adapter.getSelectedPeers()
|
||||
/* WiFi Direct test - no peers is needed
|
||||
if(selectedPeers.size>0) {
|
||||
result.putExtra(MainActivity.PEER_LIST, serializePeerInfoSet2StringList(selectedPeers))
|
||||
setResult(Activity.RESULT_OK, result)
|
||||
@ -143,8 +144,10 @@ class PeerListActivity : AppCompatActivity() {
|
||||
val toast = Toast.makeText(applicationContext, text, duration)
|
||||
toast.setGravity(Gravity.CENTER, 0, 0)
|
||||
toast.show()
|
||||
}
|
||||
|
||||
}*/
|
||||
result.putExtra(MainActivity.PEER_LIST, serializePeerInfoSet2StringList(selectedPeers))
|
||||
setResult(Activity.RESULT_OK, result)
|
||||
finish()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user