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 discovering in sending mode and advertising in receiving mode #26

Merged
merged 20 commits into from
Mar 14, 2019

Conversation

ekigamba
Copy link
Contributor

@ekigamba ekigamba commented Mar 12, 2019

Fixes #2
Fixes #1

When installed on two devices, the sender should be able to discover the receiver. This will be shown with a toast message giving the name John Doe and packageName

ekigamba added 10 commits March 11, 2019 11:23
- Receive button click shows a dialog notifying the user that we are waiting for a device to connect
- Enable cancel button to cancel the dialog
- Send and receive buttons are disabled when the dialog is shown
- Add Nearby Connections API
- Add Timber dependency
- Add P2PLibrary which will enable adding implementation of interfaces and requirements for the library
- Instantiate the P2pModeSelectInteractor in the P2pModeSelectPresenter
1. Enforce username when initialising username
2. Make the presenter testable by allowing the interactor as a param
3. Enforce initialising the P2PLibrary by introducing a RuntimeException if it is accessed without being intialised. This means that it will fail fast during developmental testing since getInstance has to be called whenever interacting with the library
1. Add Nearby Connections API permissions check & request
2. Check if location is enabled & request for enabling it if not
3. Add onResume and onActivityResult handlers for the activity
4. Add Permissions util class
Also added P2pModeSelectInteractor tests
Fixes #2

1. Show discovering progress dialog
2. Start discovery when the send button is clicked
3. Check for permissions when send button is clicked & ensure location
is enabled before starting discovering
4. Stop discovering when the cancel button is clicked
5. Fixed bug where advertising is not stopped since the connection
client used to stop advertising is not the same as the one that
started advertising
6. Add onActivityRequestionPermissionHandler interface to enable
easily switching of different handlers for the same permissions
request
7. Rename handlers package to handler for more consistency on package
naming
@ekigamba
Copy link
Contributor Author

BLOCKED: This branch and PR depends on #23

Added the line enabling robolectric to use the normal module resources as per http://robolectric.org/migrating/\#project-configuration
- Added a TestApplication class to set the theme for the activities
1. Removing references to context and other context carrying objects to remove memory leaks
2. Stop advertising, discovering and any active endpoints
3. Re-initialise context carrying objects on activity start
@ekigamba ekigamba requested a review from githengi March 13, 2019 14:25
@ekigamba
Copy link
Contributor Author

Closed #23 and included in this PR

@ekigamba ekigamba changed the title Implement sending mode Implement discovering in sending mode and advertising in receiving mode Mar 13, 2019
@ekigamba ekigamba removed the BLOCKED label Mar 13, 2019
initializePresenter();

sendButton.setOnClickListener(null);
receiveButton.setOnClickListener(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed

        sendButton.setOnClickListener(null);
        receiveButton.setOnClickListener(null);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The activity is/was behaving kinda weird whereby the onCreate method is called twice everytime it starts. This also weirdly resulted in the presenter.onSendButtonClicked() being called twice (😞 which shouldn't be remotely possible) I think that this should remedy the situation. I'll retest it and get back to you

Copy link
Contributor

Choose a reason for hiding this comment

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

After testing on my device onCreate and onStart is only invoked only once.

Shouldn't the click handlers be setup in onCreate?
Also if you set them up on onStart then you should unregister then on onStop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool

* Created by Ephraim Kigamba - ekigamba@ona.io on 11/03/2019
*/

public abstract class Constants {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using an interface instead on abstract class for configs


public static final Strategy STRATEGY = Strategy.P2P_STAR;

public abstract static class RQ_CODE {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using an interface instead on abstract class for configs

- Change Constants class to interface instead of abstract class
@ekigamba ekigamba merged commit 887460b into master Mar 14, 2019
@ekigamba ekigamba deleted the issue/2-implement-sending-mode branch March 14, 2019 10:27
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