-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement authentication on sending and receiving device #28
Implement authentication on sending and receiving device #28
Conversation
Add strings required by Scanner dialog
The user nickname is now the device manufacture and model
1. Add a simple texting interface on the activity 2. Show QR Code scanning dialog on connection intiation 3. Request connection to the first device that is found 4. Enable sending of simple text messages from the select mode activity 5. Add base authentication class that can be extended for more functionality 6. Add QR Code scan result authentication with current authentication token 7. Show an authentication bypass dialog if the user cancels QR code scanning 8. Handle connection lifecycle when requesting a connection -> return to discovering mode if the connection with the device fails otherwise show the simple texting UI
1. Add QR Code generation via zxing-android-embedded 2. Add ReceiverConnectionAuthenticator to show the authentication code in QR dialog 3. Add QR Code Generator Diaog 4. Add ReceiverSyncLifecycleCallback to manage lifecycle of receiver mode 5. Show QR code when a sender device initiates a connection and enable accept/reject 6. Revert to advertising if an error occurs or if the connection is rejected
Remove lint abortOnError for module p2p-sync builds
p2p-sync/src/main/java/org/smartregister/p2p/activity/P2pModeSelectActivity.java
Outdated
Show resolved
Hide resolved
public abstract class BaseSyncConnectionAuthenticator { | ||
|
||
protected P2pModeSelectContract.View view; | ||
protected P2pModeSelectContract.Interactor interactor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In MVP only the presenter can bind the view and interactor(model). Try to decouple this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the presenter and interactor are not used by the child classes
|
||
@Override | ||
public void release() { | ||
//Todo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is supposed to release any resources being used by the processor according to https://developers.google.com/android/reference/com/google/android/gms/vision/Detector.Processor.html#release()
These are resources being used in receiveDetections
. The cameraSource
to which the detector is passed calls the release
method
We therefore are not releasing anything in that method for our case
//Todo: Show the user an error | ||
//Todo: Go back to advertising mode | ||
resetState(); | ||
view.showToast(String.format("The connection to %s has broken", endpointId), Toast.LENGTH_LONG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to strings
@Override | ||
public void onRequestConnectionSuccessful(@Nullable Object result) { | ||
// Just show a success | ||
view.showToast("CONNECTION REQUEST WAS SUCCESSFUL", Toast.LENGTH_LONG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to strings
@Override | ||
public void onRequestConnectionFailed(@NonNull Exception exception) { | ||
// Show the user an error trying to connect device XYZ | ||
view.showToast("COULD NOT INITIATE CONNECTION REQUEST TO THE DEVICE", Toast.LENGTH_LONG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move text to strings
if (currentReceiver != null) { | ||
view.showToast(String.format(view.getContext().getString(R.string.you_are_connected_to_receiver), currentReceiver.getEndpointName()) | ||
, Toast.LENGTH_LONG); | ||
view.displayMessage("CONNECTED"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move text to strings
@Override | ||
public void onDisconnected(@NonNull String endpointId) { | ||
Timber.e("Endpoint lost %s", endpointId); | ||
view.displayMessage("DISCONNECTED"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move text to strings
p2p-sync/src/main/java/org/smartregister/p2p/view/QRCodeScannerView.java
Show resolved
Hide resolved
dd66a55
to
fd596a8
Compare
Fixes #4
Fixes #5