diff --git a/CHANGELOG.md b/CHANGELOG.md index 40f1dd1..dc74fd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,4 +11,4 @@ _2015-04-02_ _2015-03-25_ - * Initial release. \ No newline at end of file + * Initial release. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 57f3d49..eca0cf2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,11 +10,11 @@ respond to requests. ## Pull Requests We actively welcome your pull requests. -1. Fork the repo and create your branch from `master`. +1. Fork the repo and create your branch from `master`. 2. If you've added code that should be tested, add tests -3. If you've changed APIs, update the documentation. -4. Ensure the test suite passes. -5. Make sure your code lints. +3. If you've changed APIs, update the documentation. +4. Ensure the test suite passes. +5. Make sure your code lints. 6. If you haven't already, complete the Contributor License Agreement ("CLA"). ## Contributor License Agreement ("CLA") @@ -23,7 +23,7 @@ to do this once to work on any of Facebook's open source projects. Complete your CLA here: -## Issues +## Issues We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue. @@ -31,7 +31,7 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue. -## Coding Style +## Coding Style * 2 spaces for indentation rather than tabs * Line wrapping indents 4 spaces * 100 character line length @@ -41,4 +41,4 @@ outlined on that page and do not file a public issue. ## License By contributing to Network Connection Class, you agree that your contributions will be licensed -under its BSD license. \ No newline at end of file +under its BSD license. diff --git a/LICENSE b/LICENSE index 6bd6bca..d00a8e4 100644 --- a/LICENSE +++ b/LICENSE @@ -27,4 +27,4 @@ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/build.gradle b/build.gradle index 25e57ba..8ccd9c9 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:2.3.1' } } + allprojects { repositories { jcenter() diff --git a/connectionclass-sample/build.gradle b/connectionclass-sample/build.gradle index d274c23..0470425 100644 --- a/connectionclass-sample/build.gradle +++ b/connectionclass-sample/build.gradle @@ -1,17 +1,13 @@ apply plugin: 'com.android.application' -repositories { - jcenter() -} - android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" + compileSdkVersion 25 + buildToolsVersion "25.0.2" defaultConfig { applicationId "com.facebook.network.connectionclass.sample" minSdkVersion 9 - targetSdkVersion 21 + targetSdkVersion 25 versionCode 1 versionName "1.0" } diff --git a/connectionclass-sample/src/main/AndroidManifest.xml b/connectionclass-sample/src/main/AndroidManifest.xml index 21648b7..ab2a382 100644 --- a/connectionclass-sample/src/main/AndroidManifest.xml +++ b/connectionclass-sample/src/main/AndroidManifest.xml @@ -1,13 +1,16 @@ + android:label="@string/app_name" + tools:ignore="GoogleAppIndexingWarning"> diff --git a/connectionclass-sample/src/main/res/drawable-xxxhdpi/ic_launcher.png b/connectionclass-sample/src/main/res/drawable-xxxhdpi/ic_launcher.png new file mode 100755 index 0000000..3ca55bf Binary files /dev/null and b/connectionclass-sample/src/main/res/drawable-xxxhdpi/ic_launcher.png differ diff --git a/connectionclass-sample/src/main/res/layout/activity_main.xml b/connectionclass-sample/src/main/res/layout/activity_main.xml index d94f91f..fe2f368 100644 --- a/connectionclass-sample/src/main/res/layout/activity_main.xml +++ b/connectionclass-sample/src/main/res/layout/activity_main.xml @@ -13,14 +13,14 @@ @@ -29,7 +29,6 @@ style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_centerHorizontal="true" android:layout_marginTop="15dp" android:visibility="gone"/> diff --git a/connectionclass/build.gradle b/connectionclass/build.gradle index 058a46f..f3c7fd6 100644 --- a/connectionclass/build.gradle +++ b/connectionclass/build.gradle @@ -1,30 +1,29 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" + compileSdkVersion 25 + buildToolsVersion "25.0.2" defaultConfig { minSdkVersion 9 - targetSdkVersion 21 + targetSdkVersion 25 versionCode 1 versionName "1.0" } } dependencies { - compile 'com.google.code.findbugs:jsr305:2.0.1' + compile 'com.google.code.findbugs:jsr305:3.0.1' testCompile 'junit:junit:4.12' - testCompile 'org.mockito:mockito-core:2.0.5-beta' - testCompile 'org.robolectric:robolectric:3.0' - testCompile ('org.powermock:powermock-api-mockito:1.6.2') { + testCompile 'org.mockito:mockito-core:2.0.44-beta' + testCompile ('org.powermock:powermock-api-mockito:1.6.3') { exclude module: 'hamcrest-core' exclude module: 'objenesis' } - testCompile ('org.powermock:powermock-module-junit4:1.6.2') { + testCompile ('org.powermock:powermock-module-junit4:1.6.3') { exclude module: 'hamcrest-core' exclude module: 'objenesis' } } -apply from: rootProject.file('release.gradle') \ No newline at end of file +apply from: rootProject.file('release.gradle') diff --git a/connectionclass/gradle.properties b/connectionclass/gradle.properties index 9c294a4..c102c90 100644 --- a/connectionclass/gradle.properties +++ b/connectionclass/gradle.properties @@ -1,3 +1,3 @@ POM_NAME=Network Connection Class POM_ARTIFACT_ID=connectionclass -POM_PACKAGING=aar \ No newline at end of file +POM_PACKAGING=aar diff --git a/connectionclass/src/main/AndroidManifest.xml b/connectionclass/src/main/AndroidManifest.xml index e30dc59..170d73a 100644 --- a/connectionclass/src/main/AndroidManifest.xml +++ b/connectionclass/src/main/AndroidManifest.xml @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/connectionclass/src/main/java/com/facebook/network/connectionclass/ConnectionClassManager.java b/connectionclass/src/main/java/com/facebook/network/connectionclass/ConnectionClassManager.java index 424c39a..690cb8a 100644 --- a/connectionclass/src/main/java/com/facebook/network/connectionclass/ConnectionClassManager.java +++ b/connectionclass/src/main/java/com/facebook/network/connectionclass/ConnectionClassManager.java @@ -245,4 +245,4 @@ private void notifyListeners() { mListenerList.get(i).onBandwidthStateChange(mCurrentBandwidthConnectionQuality.get()); } } -} \ No newline at end of file +} diff --git a/connectionclass/src/main/java/com/facebook/network/connectionclass/DeviceBandwidthSampler.java b/connectionclass/src/main/java/com/facebook/network/connectionclass/DeviceBandwidthSampler.java index 1f2e9fa..fe00b65 100644 --- a/connectionclass/src/main/java/com/facebook/network/connectionclass/DeviceBandwidthSampler.java +++ b/connectionclass/src/main/java/com/facebook/network/connectionclass/DeviceBandwidthSampler.java @@ -151,4 +151,4 @@ public void stopSamplingThread() { removeMessages(SamplingHandler.MSG_START); } } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 8ab64df..c1c2e50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,20 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + VERSION_NAME=1.0.1 -GROUP=com.facebook.network.connectionclass \ No newline at end of file +GROUP=com.facebook.network.connectionclass diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8c0fb64..86a0ae8 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6fa6790..2ac360a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Sep 03 12:41:50 PDT 2015 +#Thu Apr 20 00:02:06 SGT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip diff --git a/gradlew b/gradlew index 91a7e26..4453cce 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` @@ -154,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save ( ) { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..e95643d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,90 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/release.gradle b/release.gradle index fa17ba3..e4e2245 100644 --- a/release.gradle +++ b/release.gradle @@ -5,15 +5,15 @@ def isReleaseBuild() { return VERSION_NAME.contains("SNAPSHOT") == false } -def getRepositoryUrl() { +def getMavenRepositoryUrl() { return hasProperty('repositoryUrl') ? property('repositoryUrl') : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" } -def getRepositoryUsername() { +def getMavenRepositoryUsername() { return hasProperty('repositoryUsername') ? property('repositoryUsername') : "" } -def getRepositoryPassword() { +def getMavenRepositoryPassword() { return hasProperty('repositoryPassword') ? property('repositoryPassword') : "" } @@ -61,10 +61,10 @@ afterEvaluate { project -> MavenDeployment deployment -> signing.signPom(deployment) } - repository(url: getRepositoryUrl()) { + repository(url: getMavenRepositoryUrl()) { authentication( - userName: getRepositoryUsername(), - password: getRepositoryPassword()) + userName: getMavenRepositoryUsername(), + password: getMavenRepositoryPassword()) } diff --git a/settings.gradle b/settings.gradle index 734c188..2e99395 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,2 @@ include ':connectionclass-sample' -include ':connectionclass' \ No newline at end of file +include ':connectionclass'