Skip to content
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

Merged

Conversation

ekigamba
Copy link
Contributor

Fixes #4
Fixes #5

ekigamba added 21 commits March 15, 2019 10:14
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
@ekigamba ekigamba requested a review from githengi March 20, 2019 08:57
public abstract class BaseSyncConnectionAuthenticator {

protected P2pModeSelectContract.View view;
protected P2pModeSelectContract.Interactor interactor;
Copy link
Contributor

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

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement this

Copy link
Contributor Author

@ekigamba ekigamba Mar 22, 2019

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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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");
Copy link
Contributor

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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move text to strings

@ekigamba ekigamba force-pushed the issue/3.4-implement-authentication-sending-receiving-devices branch from dd66a55 to fd596a8 Compare March 21, 2019 13:37
@ekigamba ekigamba merged commit 570fe36 into master Mar 22, 2019
@ekigamba ekigamba deleted the issue/3.4-implement-authentication-sending-receiving-devices branch March 22, 2019 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants