This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from novoda/develop
Captive Portal to release
- Loading branch information
Showing
14 changed files
with
233 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
allprojects { | ||
version = '1.1.8' | ||
version = '1.2.0' | ||
repositories { | ||
mavenCentral() | ||
google() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
core/src/main/java/com/novoda/merlin/MerlinsBeardBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.novoda.merlin; | ||
|
||
import android.content.Context; | ||
import android.net.ConnectivityManager; | ||
|
||
public class MerlinsBeardBuilder { | ||
|
||
private Endpoint endpoint = Endpoint.captivePortalEndpoint(); | ||
private ResponseCodeValidator responseCodeValidator = new ResponseCodeValidator.CaptivePortalResponseCodeValidator(); | ||
|
||
MerlinsBeardBuilder() { | ||
// Uses builder pattern. | ||
} | ||
|
||
/** | ||
* Sets a custom endpoint. | ||
* | ||
* @param endpoint to ping, by default {@link Endpoint#CAPTIVE_PORTAL_ENDPOINT}. | ||
* @return MerlinsBeardBuilder. | ||
*/ | ||
public MerlinsBeardBuilder withEndpoint(Endpoint endpoint) { | ||
this.endpoint = endpoint; | ||
return this; | ||
} | ||
|
||
/** | ||
* Validator used to check the response code when performing a ping. | ||
* | ||
* @param responseCodeValidator A validator implementation used for checking that the response code is what you expect. | ||
* The default endpoint returns a 204 No Content response, so the default validator checks for that. | ||
* @return MerlinsBeardBuilder. | ||
*/ | ||
public MerlinsBeardBuilder withResponseCodeValidator(ResponseCodeValidator responseCodeValidator) { | ||
this.responseCodeValidator = responseCodeValidator; | ||
return this; | ||
} | ||
|
||
public MerlinsBeard build(Context context) { | ||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); | ||
AndroidVersion androidVersion = new AndroidVersion(); | ||
EndpointPinger captivePortalpinger = EndpointPinger.withCustomEndpointAndValidation(endpoint, responseCodeValidator); | ||
Ping captivePortalPing = new Ping(endpoint, new EndpointPinger.ResponseCodeFetcher(), responseCodeValidator); | ||
|
||
return new MerlinsBeard(connectivityManager, androidVersion, captivePortalpinger, captivePortalPing); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.