track all successful peers, and remove all unsuccessful peers

Since it is possible to connect to a peer via NFC, "Swap back", QR Code,
etc. once a peer is successfully used, it can show up in the StartSwapView
list of peers.
This commit is contained in:
Hans-Christoph Steiner 2019-05-23 13:57:37 +02:00
parent 0727787713
commit 18a7690758
2 changed files with 11 additions and 1 deletions

View File

@ -230,6 +230,14 @@ public class SwapService extends Service {
this.peer = peer; this.peer = peer;
} }
public void addCurrentPeerToActive() {
activePeers.add(peer);
}
public void removeCurrentPeerFromActive() {
activePeers.remove(peer);
}
public boolean isConnectingWithPeer() { public boolean isConnectingWithPeer() {
return peer != null; return peer != null;
} }

View File

@ -659,7 +659,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
// can or cannot be in STEP_INTRO with a full blown repo ready to swap. // can or cannot be in STEP_INTRO with a full blown repo ready to swap.
swapWith(peer); swapWith(peer);
} else { } else {
getSwapService().swapWith(repoConfig.toPeer()); getSwapService().swapWith(peer);
startSwappingWithPeer(); startSwappingWithPeer();
} }
} }
@ -1286,10 +1286,12 @@ public class SwapWorkflowActivity extends AppCompatActivity {
status == UpdateService.STATUS_ERROR_LOCAL_SMALL) { status == UpdateService.STATUS_ERROR_LOCAL_SMALL) {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
tryAgainButton.setVisibility(View.VISIBLE); tryAgainButton.setVisibility(View.VISIBLE);
getSwapService().removeCurrentPeerFromActive();
return; return;
} else { } else {
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
tryAgainButton.setVisibility(View.GONE); tryAgainButton.setVisibility(View.GONE);
getSwapService().addCurrentPeerToActive();
} }
if (status == UpdateService.STATUS_COMPLETE_AND_SAME if (status == UpdateService.STATUS_COMPLETE_AND_SAME