diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 000000000..405a2b306 --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -0,0 +1,10 @@ +name: "Validate Gradle Wrapper" +on: [push, pull_request] + +jobs: + validation: + name: "Validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 diff --git a/.travis.yml b/.travis.yml index c92d7a2cb..ddc10848e 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,16 @@ language: android sudo: false -jdk: openjdk7 +dist: trusty +jdk: openjdk8 android: components: - - build-tools-23.0.1 - - extra-android-support + - platform-tools + - tools + - build-tools-28.0.3 + - android-28 - extra-android-m2repository - - android-23 + - extra-google-m2repository licenses: - '.+' script: - # Sonatype bypass - - echo "nexusUsername=dummy" >> library/gradle.properties - - echo "nexusPassword=dummy" >> library/gradle.properties - ./gradlew clean assemble check - - ./gradlew :library:androidJavadocs diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f21beed..72c4b65f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # CHANGELOG -## 1.5.0 (future release) +## 1.4.11 + + - fix SNI issue on lower android device with Conscrypt + +## 1.4.10 + + - Fixed IP/name resolution errors #998 + - Fixed SNI compatibility + - Upgraded library HttpClient 4.5.8 from 4.3.6 ## 1.4.9 (released 19. 9. 2015) diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE.txt b/NOTICE.txt index 45deb1012..792ce018f 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -2,5 +2,8 @@ Android Async Http Client library Copyright (c) 2011-2015 James Smith https://loopj.com +Copyright (c) 2015-2019 Marek Sebera +htts://msebera.cz + This product includes software developed by The Apache Software Foundation (https://www.apache.org/). diff --git a/PUBLISHING.md b/PUBLISHING.md new file mode 100644 index 000000000..9ac180688 --- /dev/null +++ b/PUBLISHING.md @@ -0,0 +1,48 @@ +# Publish to oss.sonatype.org staging repository + +``` +gradle clean +# edit build.gradle to update allprojects.version +# edit gradle.properties to update VERSION_NAME and VERSION_CODE +# edit CHANGELOG.md and add changes for published version +# edit sample/src/main/AndroidManifest.xml and update both versionCode and versionName attributes +# edit README.md and update paths, latest version, repository links and sample codes +gradle check +# fix all possible errors and warnings before publishing +cd library +# publishing only library, so following tasks are run in "library" sub-folder +gradle generateJavadocJar +# this will create javadoc archive check the contents via following cmd (use different name and/or path if needed) +# jar -tf ./library/build/libs/android-async-http-null-Release-1.4.11-javadoc.jar +gradle publish +``` + +# Publish to maven central + +*For Nexus Repository Manager 2.14+* + + - Login into https://oss.sonatype.org/ + - Navigation, choose Build Promotion > Staging Repositories + - Explore if repo was automatically created and if contents do match expectations + - Select repository and use "Close" action, to run pre-publishing checks + - Wait a bit + - Refresh the panel with repositories + - Select repository and use "Release" action, if not available, there are issues, that need to be fixed before publishing + +# In GIT + + +**example code using 1.4.11 as released version** +``` +git tag 1.4.11 +git push origin --tags +``` + +# Github + +in *releases* https://github.com/android-async-http/android-async-http/releases + + - Create new release from appropriate tag (see GIT above) + - Describe in similar terms as in CHANGELOG.md what is being done + - Upload JAR (library, sources and javadoc) and AAR (library) along with the release + - Publish by saving form diff --git a/README.md b/README.md index f56cbc1d6..1ff6c9f85 100755 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ Asynchronous Http Client for Android ==================================== -[![Build Status](https://travis-ci.org/loopj/android-async-http.png?branch=master)](https://travis-ci.org/loopj/android-async-http) +[![Build Status](https://travis-ci.org/android-async-http/android-async-http.png?branch=master)](https://travis-ci.org/android-async-http/android-async-http) An asynchronous, callback-based Http client for Android built on top of Apache's [HttpClient](https://hc.apache.org/httpcomponents-client-ga/) libraries. Changelog --------- -See what is new in version 1.4.9 released on 19th September 2015 +See what is new in version 1.4.11 released on 29th June 2020 -https://github.com/loopj/android-async-http/blob/1.4.9/CHANGELOG.md +https://github.com/android-async-http/android-async-http/blob/1.4.11/CHANGELOG.md Javadoc ------- -Latest Javadoc for 1.4.9 release are available here (also included in Maven repository): +Latest Javadoc for 1.4.11 release are available here (also included in Maven repository): -https://loopj.com/android-async-http/doc/ +https://android-async-http.github.io/android-async-http/doc/ Features -------- @@ -30,12 +30,13 @@ Features - Automatic **gzip** response decoding support for super-fast requests - Optional built-in response parsing into **JSON** (JsonHttpResponseHandler) - Optional **persistent cookie store**, saves cookies into your app's SharedPreferences +- Support sni with Conscrypt on older android device ([wiki](https://github.com/android-async-http/android-async-http/wiki/Support-SNI-on-lower-android-device)) Examples -------- For inspiration and testing on device we've provided Sample Application. -See individual samples [here on Github](https://github.com/loopj/android-async-http/tree/1.4.9/sample/src/main/java/com/loopj/android/http/sample) +See individual samples [here on Github](https://github.com/android-async-http/android-async-http/tree/1.4.11/sample/src/main/java/com/loopj/android/http/sample) To run Sample application, simply clone the repository and run this command, to install it on connected device ```java @@ -53,29 +54,29 @@ https://repo1.maven.org/maven2/com/loopj/android/android-async-http/ Maven URL: https://repo1.maven.org/maven2/ GroupId: com.loopj.android ArtifactId: android-async-http -Version: 1.4.9 +Version: 1.4.11 Packaging: JAR or AAR ``` Gradle ```groovy repositories { - maven { - mavenCentral() - } + mavenCentral() } + dependencies { - compile 'com.loopj.android:android-async-http:1.4.9' + implementation 'com.loopj.android:android-async-http:1.4.11' } ``` **development snapshots** +snapshot might not be published yet https://oss.sonatype.org/content/repositories/snapshots/com/loopj/android/android-async-http/ ``` Maven URL: https://oss.sonatype.org/content/repositories/snapshots/ GroupId: com.loopj.android ArtifactId: android-async-http -Version: 1.5.0-SNAPSHOT +Version: 1.4.12-SNAPSHOT Packaging: JAR or AAR ``` Gradle @@ -86,7 +87,7 @@ repositories { } } dependencies { - compile 'com.loopj.android:android-async-http:1.5.0-SNAPSHOT' + implementation 'com.loopj.android:android-async-http:1.4.11-SNAPSHOT' } ``` @@ -94,5 +95,5 @@ Documentation, Features and Examples ------------------------------------ Full details and documentation can be found on the project page here: -https://loopj.com/android-async-http/ +https://android-async-http.github.io/android-async-http/ diff --git a/build.gradle b/build.gradle index 2a500d66a..2b8e1368e 100755 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,16 @@ buildscript { repositories { - mavenCentral() + jcenter() + google() + maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' + classpath 'com.android.tools.build:gradle:4.0.0' + classpath 'com.vanniktech:gradle-android-javadoc-plugin:0.4.0-SNAPSHOT' + classpath 'digital.wup:android-maven-publish:3.6.2' + classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.4" } } @@ -14,17 +20,21 @@ def isReleaseBuild() { allprojects { group = 'com.loopj.android' - version = '1.5.0-SNAPSHOT' + version = '1.4.11' repositories { - mavenLocal() + google() + jcenter() mavenCentral() } tasks.withType(JavaCompile) { options.encoding = "UTF-8" options.compilerArgs << "-Xlint:unchecked" + options.compilerArgs << "-Xlint:deprecation" } } apply plugin: 'android-reporting' +apply plugin: 'com.vanniktech.android.javadoc' +apply plugin: 'com.dorongold.task-tree' diff --git a/gradle.properties b/gradle.properties index 103245293..c9086631a 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ -VERSION_NAME=1.5.0-SNAPSHOT -VERSION_CODE=150 +VERSION_NAME=1.4.11 +VERSION_CODE=1411 GROUP=com.loopj.android POM_DESCRIPTION=An Asynchronous HTTP Library for Android -POM_URL=https://loopj.com/android-async-http/ -POM_SCM_URL=https://github.com/loopj/android-async-http -POM_SCM_CONNECTION=scm:git@github.com:loopj/android-async-http.git -POM_SCM_DEV_CONNECTION=scm:git@github.com:loopj/android-async-http.git +POM_URL=https://android-async-http.github.io/android-async-http/ +POM_SCM_URL=https://github.com/android-async-http/android-async-http +POM_SCM_CONNECTION=scm:git@github.com:android-async-http/android-async-http.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:android-async-http/android-async-http.git POM_LICENCE_NAME=The Apache Software License, Version 2.0 POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt POM_LICENCE_DIST=repo diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3af41f22a..7bfd9f1e4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jul 31 10:35:35 CEST 2015 +#Sun Jun 28 22:59:06 PDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index d463344f6..d63952f0b 100755 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,12 +1,14 @@ apply plugin: 'com.android.library' +apply plugin: 'digital.wup.android-maven-publish' +apply plugin: 'signing' android { - compileSdkVersion 23 - buildToolsVersion '23.0.1' + compileSdkVersion 28 defaultConfig { - minSdkVersion 3 - targetSdkVersion 23 + minSdkVersion 9 + targetSdkVersion 28 + consumerProguardFiles 'proguard.txt' } lintOptions { @@ -16,31 +18,92 @@ android { showAll true disable 'OldTargetApi' } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_6 - targetCompatibility JavaVersion.VERSION_1_6 - } } dependencies { - compile 'cz.msebera.android:httpclient:4.3.6' + api 'cz.msebera.android:httpclient:4.5.8' + compileOnly 'org.conscrypt:conscrypt-android:2.4.0' } -android.libraryVariants.all { variant -> - def name = variant.buildType.name - def task = project.tasks.create "jar${name.capitalize()}", Jar - task.dependsOn variant.javaCompile - task.from variant.javaCompile.destinationDir - artifacts.add('archives', task); -} +project.afterEvaluate { project -> -apply from: '../maven_push.gradle' - -afterEvaluate { project -> android.libraryVariants.all { variant -> - tasks.androidJavadocs.doFirst { - classpath += files(variant.javaCompile.classpath.files) + def name = variant.buildType.name + def task = project.tasks.create "jar${name.capitalize()}", Jar + task.dependsOn variant.javaCompileProvider.get() + task.from variant.javaCompileProvider.get().destinationDir + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + archiveClassifier = 'sources' + } + + task javadocJar(type: Jar, dependsOn: tasks.findAll { task -> task.name.contains('Javadoc') }) { + archiveClassifier = 'javadoc' + from 'build/docs/javadoc/release/' + } + + publishing { + publications { + maven(MavenPublication) { + artifactId = POM_ARTIFACT_ID + artifact javadocJar + artifact sourcesJar + artifact jarRelease + from components.android + + pom { + name = POM_NAME + description = POM_DESCRIPTION + packaging = POM_PACKAGING + url = POM_URL + + scm { + connection = POM_SCM_CONNECTION + developerConnection = POM_SCM_DEV_CONNECTION + url = POM_SCM_URL + } + + licenses { + license { + name = POM_LICENCE_NAME + url = POM_LICENCE_URL + distribution = POM_LICENCE_DIST + } + } + + developers { + developer { + id = 'mareksebera' + name = 'Marek Sebera' + } + } + } + + pom.name = POM_NAME + pom.description = POM_DESCRIPTION + pom.url = POM_URL + pom.packaging = POM_PACKAGING + } } + repositories { + maven { + def releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + def snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots/" + url = version.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl + credentials { + def NexusUsername = project.hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : '' + def NexusPassword = project.hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : '' + username NexusUsername + password NexusPassword + } + } + } + } + + signing { + sign publishing.publications.maven } } + diff --git a/library/proguard.txt b/library/proguard.txt new file mode 100644 index 000000000..e3ab81252 --- /dev/null +++ b/library/proguard.txt @@ -0,0 +1,2 @@ +-keep class cz.msebera.android.httpclient.** { *; } +-keep class com.loopj.android.http.** { *; } diff --git a/library/src/main/java/com/loopj/android/http/AsyncHttpClient.java b/library/src/main/java/com/loopj/android/http/AsyncHttpClient.java index bada27e07..f38c4fe10 100755 --- a/library/src/main/java/com/loopj/android/http/AsyncHttpClient.java +++ b/library/src/main/java/com/loopj/android/http/AsyncHttpClient.java @@ -1,14 +1,13 @@ +package com.loopj.android.http; + /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com - + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - https://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,8 +15,6 @@ limitations under the License. */ -package com.loopj.android.http; - import android.content.Context; import android.os.Looper; @@ -50,6 +47,7 @@ import cz.msebera.android.httpclient.HttpResponse; import cz.msebera.android.httpclient.HttpResponseInterceptor; import cz.msebera.android.httpclient.HttpVersion; +import cz.msebera.android.httpclient.auth.AuthSchemeRegistry; import cz.msebera.android.httpclient.auth.AuthScope; import cz.msebera.android.httpclient.auth.AuthState; import cz.msebera.android.httpclient.auth.Credentials; @@ -60,6 +58,7 @@ import cz.msebera.android.httpclient.client.RedirectHandler; import cz.msebera.android.httpclient.client.methods.HttpEntityEnclosingRequestBase; import cz.msebera.android.httpclient.client.methods.HttpHead; +import cz.msebera.android.httpclient.client.methods.HttpOptions; import cz.msebera.android.httpclient.client.methods.HttpPatch; import cz.msebera.android.httpclient.client.methods.HttpPost; import cz.msebera.android.httpclient.client.methods.HttpPut; @@ -251,6 +250,11 @@ public void process(HttpResponse response, HttpContext context) { httpClient.addRequestInterceptor(new HttpRequestInterceptor() { @Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { + + AuthSchemeRegistry authSchemeRegistry = new AuthSchemeRegistry(); + authSchemeRegistry.register("Bearer", new BearerAuthSchemeFactory()); + context.setAttribute(ClientContext.AUTHSCHEME_REGISTRY, authSchemeRegistry); + AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute( ClientContext.CREDS_PROVIDER); @@ -259,7 +263,10 @@ public void process(final HttpRequest request, final HttpContext context) throws if (authState.getAuthScheme() == null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); Credentials creds = credsProvider.getCredentials(authScope); - if (creds != null) { + if (creds instanceof TokenCredentials) { + authState.setAuthScheme(new BearerAuthSchemeFactory.BearerAuthScheme()); + authState.setCredentials(creds); + } else if (creds != null) { authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); } @@ -626,7 +633,7 @@ public void setRedirectHandler(final RedirectHandler customRedirectHandler) { /** * Sets the User-Agent header to be sent with each request. By default, "Android Asynchronous - * Http Client/VERSION (https://loopj.com/android-async-http/)" is used. + * Http Client/VERSION (https://github.com/android-async-http/android-async-http/)" is used. * * @param userAgent the string to use in the User-Agent header. */ @@ -791,6 +798,31 @@ public void removeHeader(String header) { clientHeaderMap.remove(header); } + /** + * Sets bearer authentication for the request. Uses AuthScope.ANY. This is the same as + * setBearerAuth('token',AuthScope.ANY, false) + * + * @param token Bearer Token + */ + public void setBearerAuth(String token) { + setBearerAuth(token, AuthScope.ANY, false); + } + + + /** + * Sets bearer authentication for the request. You should pass in your AuthScope for security. It + * should be like this setBearerAuth("token", new AuthScope("host",port,AuthScope.ANY_REALM), false) + * + * @param token Bearer Token + * @param scope an AuthScope object + * @param preemptive sets authorization in preemptive manner + */ + public void setBearerAuth(String token, AuthScope scope, boolean preemptive) { + TokenCredentials credentials = new TokenCredentials(token); + setCredentials(scope, credentials); + setAuthenticationPreemptive(preemptive); + } + /** * Sets basic authentication for the request. Uses AuthScope.ANY. This is the same as * setBasicAuth('username','password',AuthScope.ANY) @@ -957,6 +989,24 @@ public void cancelRequestsByTAG(Object TAG, boolean mayInterruptIfRunning) { } // [-] HTTP HEAD + // [+] HTTP OPTIONS + + /** + * Perform a HTTP OPTIONS request, without any parameters. + * + * @param url the URL to send the request to. + * @param responseHandler the response handler instance that should handle the response. + * @return RequestHandle of future request process + */ + public RequestHandle options(String url, ResponseHandlerInterface responseHandler) { + return options(null, url, null, responseHandler); + } + + public RequestHandle options(Context context, String url, RequestParams params, ResponseHandlerInterface responseHandler) { + return sendRequest(httpClient, httpContext, new HttpOptions(getUrlWithQueryString(isUrlEncodingEnabled(), url, params)), null, responseHandler, context); + } + + // [-] HTTP OPTIONS // [+] HTTP GET /** @@ -1635,4 +1685,12 @@ public void consumeContent() throws IOException { super.consumeContent(); } } + + /** + * Call this method if your app target android below 4.4 + * This method enable sni in android below 4.4 + */ + public static void useConscryptSSLProvider(){ + ConscryptSSLProvider.install(); + } } diff --git a/library/src/main/java/com/loopj/android/http/AsyncHttpRequest.java b/library/src/main/java/com/loopj/android/http/AsyncHttpRequest.java index 1d92c9e2d..346cde73e 100755 --- a/library/src/main/java/com/loopj/android/http/AsyncHttpRequest.java +++ b/library/src/main/java/com/loopj/android/http/AsyncHttpRequest.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -180,7 +180,7 @@ private void makeRequestWithRetries() throws IOException { // switching between WI-FI and mobile data networks can cause a retry which then results in an UnknownHostException // while the WI-FI is initialising. The retry logic will be invoked here, if this is NOT the first retry // (to assist in genuine cases of unknown host) which seems better than outright failure - cause = new IOException("UnknownHostException exception: " + e.getMessage()); + cause = new IOException("UnknownHostException exception: " + e.getMessage(), e); retry = (executionCount > 0) && retryHandler.retryRequest(e, ++executionCount, context); } catch (NullPointerException e) { // there's a bug in HttpClient 4.0.x that on some occasions causes @@ -203,7 +203,7 @@ private void makeRequestWithRetries() throws IOException { } catch (Exception e) { // catch anything else to ensure failure message is propagated AsyncHttpClient.log.e("AsyncHttpRequest", "Unhandled exception origin cause", e); - cause = new IOException("Unhandled exception: " + e.getMessage()); + cause = new IOException("Unhandled exception: " + e.getMessage(), cause); } // cleaned up to throw IOException diff --git a/library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java index 609cc21a7..096020d9e 100755 --- a/library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/AsyncHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.io.InputStream; import java.lang.ref.WeakReference; import java.net.URI; +import java.util.Locale; import cz.msebera.android.httpclient.Header; import cz.msebera.android.httpclient.HttpEntity; @@ -78,7 +79,7 @@ * }); * */ -@SuppressWarnings("ALL") +@SuppressWarnings("DesignForExtension") public abstract class AsyncHttpResponseHandler implements ResponseHandlerInterface { public static final String DEFAULT_CHARSET = "UTF-8"; @@ -117,13 +118,8 @@ public AsyncHttpResponseHandler() { * @param looper The looper to work with */ public AsyncHttpResponseHandler(Looper looper) { - this.looper = looper == null ? Looper.myLooper() : looper; - - // Use asynchronous mode by default. - setUseSynchronousMode(false); - // Do not use the pool's thread to fire callbacks by default. - setUsePoolThread(false); + this(looper == null ? Looper.myLooper() : looper, false); } /** @@ -133,17 +129,24 @@ public AsyncHttpResponseHandler(Looper looper) { * @param usePoolThread Whether to use the pool's thread to fire callbacks */ public AsyncHttpResponseHandler(boolean usePoolThread) { - // Whether to use the pool's thread to fire callbacks. - setUsePoolThread(usePoolThread); - - // When using the pool's thread, there's no sense in having a looper. - if (!getUsePoolThread()) { - // Use the current thread's looper. - this.looper = Looper.myLooper(); + this(usePoolThread ? null : Looper.myLooper(), usePoolThread); + } - // Use asynchronous mode by default. - setUseSynchronousMode(false); + private AsyncHttpResponseHandler(Looper looper, boolean usePoolThread) { + if (!usePoolThread) { + Utils.asserts(looper != null, "use looper thread, must call Looper.prepare() first!"); + this.looper = looper; + // Create a handler on current thread to submit tasks + this.handler = new ResponderHandler(this, looper); + } else { + Utils.asserts(looper == null, "use pool thread, looper should be null!"); + // If pool thread is to be used, there's no point in keeping a reference + // to the looper and handler. + this.looper = null; + this.handler = null; } + + this.usePoolThread = usePoolThread; } @Override @@ -239,7 +242,7 @@ public void setCharset(final String charset) { * @param totalSize total size of file */ public void onProgress(long bytesWritten, long totalSize) { - AsyncHttpClient.log.v(LOG_TAG, String.format("Progress %d from %d (%2.0f%%)", bytesWritten, totalSize, (totalSize > 0) ? (bytesWritten * 1.0 / totalSize) * 100 : -1)); + AsyncHttpClient.log.v(LOG_TAG, String.format(Locale.US, "Progress %d from %d (%2.0f%%)", bytesWritten, totalSize, (totalSize > 0) ? (bytesWritten * 1.0 / totalSize) * 100 : -1)); } /** @@ -292,7 +295,7 @@ public void onPostProcessResponse(ResponseHandlerInterface instance, HttpRespons * @param retryNo number of retry */ public void onRetry(int retryNo) { - AsyncHttpClient.log.d(LOG_TAG, String.format("Request retry no. %d", retryNo)); + AsyncHttpClient.log.d(LOG_TAG, String.format(Locale.US, "Request retry no. %d", retryNo)); } public void onCancel() { diff --git a/library/src/main/java/com/loopj/android/http/BaseJsonHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/BaseJsonHttpResponseHandler.java index f9d5f9182..69349f1d0 100755 --- a/library/src/main/java/com/loopj/android/http/BaseJsonHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/BaseJsonHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/BearerAuthSchemeFactory.java b/library/src/main/java/com/loopj/android/http/BearerAuthSchemeFactory.java new file mode 100644 index 000000000..3d17ea294 --- /dev/null +++ b/library/src/main/java/com/loopj/android/http/BearerAuthSchemeFactory.java @@ -0,0 +1,89 @@ +/* + Android Asynchronous Http Client + Copyright (c) 2011 James Smith + https://github.com/android-async-http/android-async-http + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.loopj.android.http; + +import cz.msebera.android.httpclient.Header; +import cz.msebera.android.httpclient.HttpRequest; +import cz.msebera.android.httpclient.auth.AUTH; +import cz.msebera.android.httpclient.auth.AuthScheme; +import cz.msebera.android.httpclient.auth.AuthSchemeFactory; +import cz.msebera.android.httpclient.auth.AuthenticationException; +import cz.msebera.android.httpclient.auth.ContextAwareAuthScheme; +import cz.msebera.android.httpclient.auth.Credentials; +import cz.msebera.android.httpclient.auth.MalformedChallengeException; +import cz.msebera.android.httpclient.message.BufferedHeader; +import cz.msebera.android.httpclient.params.HttpParams; +import cz.msebera.android.httpclient.protocol.HttpContext; +import cz.msebera.android.httpclient.util.CharArrayBuffer; + +public class BearerAuthSchemeFactory implements AuthSchemeFactory { + + @Override + public AuthScheme newInstance(HttpParams params) { + return new BearerAuthScheme(); + } + + public static class BearerAuthScheme implements ContextAwareAuthScheme { + private boolean complete = false; + + @Override + public void processChallenge(Header header) throws MalformedChallengeException { + this.complete = true; + } + + @Override + public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException { + return authenticate(credentials, request, null); + } + + @Override + public Header authenticate(Credentials credentials, HttpRequest request, HttpContext httpContext) + throws AuthenticationException { + CharArrayBuffer buffer = new CharArrayBuffer(32); + buffer.append(AUTH.WWW_AUTH_RESP); + buffer.append(": Bearer "); + buffer.append(credentials.getUserPrincipal().getName()); + return new BufferedHeader(buffer); + } + + @Override + public String getSchemeName() { + return "Bearer"; + } + + @Override + public String getParameter(String name) { + return null; + } + + @Override + public String getRealm() { + return null; + } + + @Override + public boolean isConnectionBased() { + return false; + } + + @Override + public boolean isComplete() { + return this.complete; + } + } +} \ No newline at end of file diff --git a/library/src/main/java/com/loopj/android/http/BinaryHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/BinaryHttpResponseHandler.java index 865fd5efe..2372a94e4 100755 --- a/library/src/main/java/com/loopj/android/http/BinaryHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/BinaryHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/ConscryptSSLProvider.java b/library/src/main/java/com/loopj/android/http/ConscryptSSLProvider.java new file mode 100644 index 000000000..67ee69060 --- /dev/null +++ b/library/src/main/java/com/loopj/android/http/ConscryptSSLProvider.java @@ -0,0 +1,18 @@ +package com.loopj.android.http; + +import android.util.Log; + +import org.conscrypt.Conscrypt; + +import java.security.Security; + +public class ConscryptSSLProvider { + public static void install(){ + try { + Security.insertProviderAt(Conscrypt.newProviderBuilder().build(),1); + }catch (NoClassDefFoundError ex){ + Log.e(AsyncHttpClient.LOG_TAG, "java.lang.NoClassDefFoundError: org.conscrypt.Conscrypt, Please add org.conscrypt.Conscrypt to your dependency"); + } + + } +} diff --git a/library/src/main/java/com/loopj/android/http/DataAsyncHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/DataAsyncHttpResponseHandler.java index bd5218668..a8d43a189 100755 --- a/library/src/main/java/com/loopj/android/http/DataAsyncHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/DataAsyncHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/FileAsyncHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/FileAsyncHttpResponseHandler.java index 96bf9aea9..ee0d5b2c5 100755 --- a/library/src/main/java/com/loopj/android/http/FileAsyncHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/FileAsyncHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/HttpDelete.java b/library/src/main/java/com/loopj/android/http/HttpDelete.java index 29d74d65d..5a426a76b 100644 --- a/library/src/main/java/com/loopj/android/http/HttpDelete.java +++ b/library/src/main/java/com/loopj/android/http/HttpDelete.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/HttpGet.java b/library/src/main/java/com/loopj/android/http/HttpGet.java index 548a4ae77..7fd882a52 100644 --- a/library/src/main/java/com/loopj/android/http/HttpGet.java +++ b/library/src/main/java/com/loopj/android/http/HttpGet.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/JsonHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/JsonHttpResponseHandler.java index b5bbe0a82..28af16d28 100755 --- a/library/src/main/java/com/loopj/android/http/JsonHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/JsonHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/JsonStreamerEntity.java b/library/src/main/java/com/loopj/android/http/JsonStreamerEntity.java index 56514bc7b..6fbee5040 100755 --- a/library/src/main/java/com/loopj/android/http/JsonStreamerEntity.java +++ b/library/src/main/java/com/loopj/android/http/JsonStreamerEntity.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/JsonValueInterface.java b/library/src/main/java/com/loopj/android/http/JsonValueInterface.java index e7b013622..303d96b22 100644 --- a/library/src/main/java/com/loopj/android/http/JsonValueInterface.java +++ b/library/src/main/java/com/loopj/android/http/JsonValueInterface.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/LogHandler.java b/library/src/main/java/com/loopj/android/http/LogHandler.java index dc7ffd2bc..2b7080a15 100644 --- a/library/src/main/java/com/loopj/android/http/LogHandler.java +++ b/library/src/main/java/com/loopj/android/http/LogHandler.java @@ -54,11 +54,7 @@ public void logWithThrowable(int logLevel, String tag, String msg, Throwable t) Log.d(tag, msg, t); break; case WTF: - if (Integer.valueOf(Build.VERSION.SDK) > 8) { - checkedWtf(tag, msg, t); - } else { - Log.e(tag, msg, t); - } + checkedWtf(tag, msg, t); break; case INFO: Log.i(tag, msg, t); diff --git a/library/src/main/java/com/loopj/android/http/MyRedirectHandler.java b/library/src/main/java/com/loopj/android/http/MyRedirectHandler.java index 5ee6f6d0f..54f385ede 100644 --- a/library/src/main/java/com/loopj/android/http/MyRedirectHandler.java +++ b/library/src/main/java/com/loopj/android/http/MyRedirectHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2014 Aymon Fournier - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java b/library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java index 6d88a68d3..7a2e6f432 100755 --- a/library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java +++ b/library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSocket; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; @@ -72,9 +74,19 @@ public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, X509TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + try { + chain[0].checkValidity(); + } catch (Exception e) { + throw new CertificateException("Certificate not valid or trusted."); + } } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + try { + chain[0].checkValidity(); + } catch (Exception e) { + throw new CertificateException("Certificate not valid or trusted."); + } } public X509Certificate[] getAcceptedIssuers() { @@ -186,12 +198,27 @@ public static DefaultHttpClient getNewHttpClient(KeyStore keyStore) { @Override public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { - return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); + Socket localSocket = sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); + enableSecureProtocols(localSocket); + return localSocket; } @Override public Socket createSocket() throws IOException { - return sslContext.getSocketFactory().createSocket(); + Socket socket = sslContext.getSocketFactory().createSocket(); + enableSecureProtocols(socket); + return socket; + } + + /** + * Activate supported protocols on the socket. + * + * @param socket The socket on which to activate secure protocols. + */ + private void enableSecureProtocols(Socket socket) { + // set all supported protocols + SSLParameters params = sslContext.getSupportedSSLParameters(); + ((SSLSocket) socket).setEnabledProtocols(params.getProtocols()); } /** @@ -200,5 +227,4 @@ public Socket createSocket() throws IOException { public void fixHttpsURLConnection() { HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); } - -} +} \ No newline at end of file diff --git a/library/src/main/java/com/loopj/android/http/PersistentCookieStore.java b/library/src/main/java/com/loopj/android/http/PersistentCookieStore.java index b3419ea16..8065d4821 100755 --- a/library/src/main/java/com/loopj/android/http/PersistentCookieStore.java +++ b/library/src/main/java/com/loopj/android/http/PersistentCookieStore.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -97,7 +97,7 @@ public void addCookie(Cookie cookie) { SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); - prefsWriter.commit(); + prefsWriter.apply(); } @Override @@ -108,7 +108,7 @@ public void clear() { prefsWriter.remove(COOKIE_NAME_PREFIX + name); } prefsWriter.remove(COOKIE_NAME_STORE); - prefsWriter.commit(); + prefsWriter.apply(); // Clear cookies from local store cookies.clear(); @@ -138,7 +138,7 @@ public boolean clearExpired(Date date) { if (clearedAny) { prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); } - prefsWriter.commit(); + prefsWriter.apply(); return clearedAny; } @@ -168,7 +168,7 @@ public void deleteCookie(Cookie cookie) { cookies.remove(name); SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.remove(COOKIE_NAME_PREFIX + name); - prefsWriter.commit(); + prefsWriter.apply(); } /** diff --git a/library/src/main/java/com/loopj/android/http/PreemptiveAuthorizationHttpRequestInterceptor.java b/library/src/main/java/com/loopj/android/http/PreemptiveAuthorizationHttpRequestInterceptor.java index 09a265b69..806c7be25 100644 --- a/library/src/main/java/com/loopj/android/http/PreemptiveAuthorizationHttpRequestInterceptor.java +++ b/library/src/main/java/com/loopj/android/http/PreemptiveAuthorizationHttpRequestInterceptor.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/RangeFileAsyncHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/RangeFileAsyncHttpResponseHandler.java index 2e6e8233d..f327a8caf 100755 --- a/library/src/main/java/com/loopj/android/http/RangeFileAsyncHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/RangeFileAsyncHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/RequestHandle.java b/library/src/main/java/com/loopj/android/http/RequestHandle.java index 6908ae93f..959190e13 100755 --- a/library/src/main/java/com/loopj/android/http/RequestHandle.java +++ b/library/src/main/java/com/loopj/android/http/RequestHandle.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2013 Jason Choy - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/RequestParams.java b/library/src/main/java/com/loopj/android/http/RequestParams.java index 0387b9285..e594f7909 100755 --- a/library/src/main/java/com/loopj/android/http/RequestParams.java +++ b/library/src/main/java/com/loopj/android/http/RequestParams.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -33,7 +33,8 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentSkipListMap; +//import java.util.concurrent.ConcurrentSkipList; import cz.msebera.android.httpclient.HttpEntity; import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity; @@ -99,11 +100,11 @@ public class RequestParams implements Serializable { "application/json"; protected final static String LOG_TAG = "RequestParams"; - protected final ConcurrentHashMap urlParams = new ConcurrentHashMap(); - protected final ConcurrentHashMap streamParams = new ConcurrentHashMap(); - protected final ConcurrentHashMap fileParams = new ConcurrentHashMap(); - protected final ConcurrentHashMap> fileArrayParams = new ConcurrentHashMap>(); - protected final ConcurrentHashMap urlParamsWithObjects = new ConcurrentHashMap(); + protected final ConcurrentSkipListMap urlParams = new ConcurrentSkipListMap(); + protected final ConcurrentSkipListMap streamParams = new ConcurrentSkipListMap(); + protected final ConcurrentSkipListMap fileParams = new ConcurrentSkipListMap(); + protected final ConcurrentSkipListMap> fileArrayParams = new ConcurrentSkipListMap>(); + protected final ConcurrentSkipListMap urlParamsWithObjects = new ConcurrentSkipListMap(); protected boolean isRepeatable; protected boolean forceMultipartEntity = false; protected boolean useJsonStreamer; @@ -425,7 +426,7 @@ public boolean has(String key) { @Override public String toString() { StringBuilder result = new StringBuilder(); - for (ConcurrentHashMap.Entry entry : urlParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : urlParams.entrySet()) { if (result.length() > 0) result.append("&"); @@ -434,7 +435,7 @@ public String toString() { result.append(entry.getValue()); } - for (ConcurrentHashMap.Entry entry : streamParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : streamParams.entrySet()) { if (result.length() > 0) result.append("&"); @@ -443,7 +444,7 @@ public String toString() { result.append("STREAM"); } - for (ConcurrentHashMap.Entry entry : fileParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : fileParams.entrySet()) { if (result.length() > 0) result.append("&"); @@ -452,7 +453,7 @@ public String toString() { result.append("FILE"); } - for (ConcurrentHashMap.Entry> entry : fileArrayParams.entrySet()) { + for (ConcurrentSkipListMap.Entry> entry : fileArrayParams.entrySet()) { if (result.length() > 0) result.append("&"); @@ -530,22 +531,22 @@ private HttpEntity createJsonStreamerEntity(ResponseHandlerInterface progressHan elapsedFieldInJsonStreamer); // Add string params - for (ConcurrentHashMap.Entry entry : urlParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : urlParams.entrySet()) { entity.addPart(entry.getKey(), entry.getValue()); } // Add non-string params - for (ConcurrentHashMap.Entry entry : urlParamsWithObjects.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : urlParamsWithObjects.entrySet()) { entity.addPart(entry.getKey(), entry.getValue()); } // Add file params - for (ConcurrentHashMap.Entry entry : fileParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : fileParams.entrySet()) { entity.addPart(entry.getKey(), entry.getValue()); } // Add stream params - for (ConcurrentHashMap.Entry entry : streamParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : streamParams.entrySet()) { StreamWrapper stream = entry.getValue(); if (stream.inputStream != null) { entity.addPart(entry.getKey(), @@ -575,7 +576,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle entity.setIsRepeatable(isRepeatable); // Add string params - for (ConcurrentHashMap.Entry entry : urlParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : urlParams.entrySet()) { entity.addPartWithCharset(entry.getKey(), entry.getValue(), contentEncoding); } @@ -586,7 +587,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle } // Add stream params - for (ConcurrentHashMap.Entry entry : streamParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : streamParams.entrySet()) { StreamWrapper stream = entry.getValue(); if (stream.inputStream != null) { entity.addPart(entry.getKey(), stream.name, stream.inputStream, @@ -595,13 +596,13 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle } // Add file params - for (ConcurrentHashMap.Entry entry : fileParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : fileParams.entrySet()) { FileWrapper fileWrapper = entry.getValue(); entity.addPart(entry.getKey(), fileWrapper.file, fileWrapper.contentType, fileWrapper.customFileName); } // Add file collection - for (ConcurrentHashMap.Entry> entry : fileArrayParams.entrySet()) { + for (ConcurrentSkipListMap.Entry> entry : fileArrayParams.entrySet()) { List fileWrapper = entry.getValue(); for (FileWrapper fw : fileWrapper) { entity.addPart(entry.getKey(), fw.file, fw.contentType, fw.customFileName); @@ -614,7 +615,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle protected List getParamsList() { List lparams = new LinkedList(); - for (ConcurrentHashMap.Entry entry : urlParams.entrySet()) { + for (ConcurrentSkipListMap.Entry entry : urlParams.entrySet()) { lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } diff --git a/library/src/main/java/com/loopj/android/http/ResponseHandlerInterface.java b/library/src/main/java/com/loopj/android/http/ResponseHandlerInterface.java index c5936fb43..4040a965b 100755 --- a/library/src/main/java/com/loopj/android/http/ResponseHandlerInterface.java +++ b/library/src/main/java/com/loopj/android/http/ResponseHandlerInterface.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2013 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/RetryHandler.java b/library/src/main/java/com/loopj/android/http/RetryHandler.java index 6f519b9f4..c9e549a2b 100755 --- a/library/src/main/java/com/loopj/android/http/RetryHandler.java +++ b/library/src/main/java/com/loopj/android/http/RetryHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/SaxAsyncHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/SaxAsyncHttpResponseHandler.java index c13428626..8198fb549 100644 --- a/library/src/main/java/com/loopj/android/http/SaxAsyncHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/SaxAsyncHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/SerializableCookie.java b/library/src/main/java/com/loopj/android/http/SerializableCookie.java index 1801b536e..f6b88ffc0 100755 --- a/library/src/main/java/com/loopj/android/http/SerializableCookie.java +++ b/library/src/main/java/com/loopj/android/http/SerializableCookie.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/SimpleMultipartEntity.java b/library/src/main/java/com/loopj/android/http/SimpleMultipartEntity.java index a9c416793..2b4758f70 100755 --- a/library/src/main/java/com/loopj/android/http/SimpleMultipartEntity.java +++ b/library/src/main/java/com/loopj/android/http/SimpleMultipartEntity.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/SyncHttpClient.java b/library/src/main/java/com/loopj/android/http/SyncHttpClient.java index 2d67f806e..dd7d8f532 100755 --- a/library/src/main/java/com/loopj/android/http/SyncHttpClient.java +++ b/library/src/main/java/com/loopj/android/http/SyncHttpClient.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/TextHttpResponseHandler.java b/library/src/main/java/com/loopj/android/http/TextHttpResponseHandler.java index c2ffc7fa9..6b8aa67ed 100755 --- a/library/src/main/java/com/loopj/android/http/TextHttpResponseHandler.java +++ b/library/src/main/java/com/loopj/android/http/TextHttpResponseHandler.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/TokenCredentials.java b/library/src/main/java/com/loopj/android/http/TokenCredentials.java new file mode 100644 index 000000000..aa361d395 --- /dev/null +++ b/library/src/main/java/com/loopj/android/http/TokenCredentials.java @@ -0,0 +1,42 @@ +/* + Android Asynchronous Http Client + Copyright (c) 2011 James Smith + https://github.com/android-async-http/android-async-http + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +package com.loopj.android.http; + +import java.security.Principal; + +import cz.msebera.android.httpclient.auth.BasicUserPrincipal; +import cz.msebera.android.httpclient.auth.Credentials; + +public class TokenCredentials implements Credentials { + private Principal userPrincipal; + + public TokenCredentials(String token) { + this.userPrincipal = new BasicUserPrincipal(token); + } + + @Override + public Principal getUserPrincipal() { + return userPrincipal; + } + + @Override + public String getPassword() { + return null; + } + +} diff --git a/library/src/main/java/com/loopj/android/http/Utils.java b/library/src/main/java/com/loopj/android/http/Utils.java index d8311e992..3f56df33f 100644 --- a/library/src/main/java/com/loopj/android/http/Utils.java +++ b/library/src/main/java/com/loopj/android/http/Utils.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/library/src/main/java/com/loopj/android/http/package-info.java b/library/src/main/java/com/loopj/android/http/package-info.java index 7d6224e1e..1e99633ca 100644 --- a/library/src/main/java/com/loopj/android/http/package-info.java +++ b/library/src/main/java/com/loopj/android/http/package-info.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2011 James Smith - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/build.gradle b/sample/build.gradle index eb44af0e7..a964a667f 100755 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -8,26 +8,18 @@ repositories { } android { - compileSdkVersion 23 - buildToolsVersion '23.0.1' + compileSdkVersion 28 defaultConfig { - minSdkVersion 3 - targetSdkVersion 23 + minSdkVersion 9 + targetSdkVersion 28 } + flavorDimensions "version" productFlavors { standard { + dimension "version" } - withLeakCanary { - minSdkVersion 8 - targetSdkVersion 23 - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_7 - targetCompatibility JavaVersion.VERSION_1_7 } lintOptions { @@ -35,7 +27,7 @@ android { warningsAsErrors true quiet false showAll true - disable 'OldTargetApi', 'UnusedAttribute', 'LongLogTag' + disable 'OldTargetApi', 'UnusedAttribute', 'LongLogTag', 'TrustAllX509TrustManager', 'GoogleAppIndexingWarning', 'Autofill', 'LabelFor', 'SetTextI18n' } packagingOptions { @@ -46,8 +38,6 @@ android { } dependencies { - compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3' - compile project(':library') - // LeakCanary - withLeakCanaryCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1' + implementation 'com.fasterxml.jackson.core:jackson-databind:2.11.0' + implementation project(':android-async-http') } diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index ba877e103..3f4f13d4f 100755 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="9" + android:versionName="1.4.11"> diff --git a/sample/src/main/java/com/loopj/android/http/sample/AsyncBackgroundThreadSample.java b/sample/src/main/java/com/loopj/android/http/sample/AsyncBackgroundThreadSample.java index 62589a3c0..3af0dbea7 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/AsyncBackgroundThreadSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/AsyncBackgroundThreadSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.FutureTask; import java.util.concurrent.TimeUnit; +import java.util.Locale; import cz.msebera.android.httpclient.Header; import cz.msebera.android.httpclient.HttpEntity; @@ -109,7 +110,7 @@ public void onStart() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] response) { - Log.d(LOG_TAG, String.format("onSuccess executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper())); + Log.d(LOG_TAG, String.format(Locale.US, "onSuccess executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper())); debugHeaders(LOG_TAG, headers); debugStatusCode(LOG_TAG, statusCode); debugResponse(LOG_TAG, new String(response)); @@ -117,7 +118,7 @@ public void onSuccess(int statusCode, Header[] headers, byte[] response) { @Override public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) { - Log.d(LOG_TAG, String.format("onFailure executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper())); + Log.d(LOG_TAG, String.format(Locale.US, "onFailure executing on main thread : %B", Looper.myLooper() == Looper.getMainLooper())); debugHeaders(LOG_TAG, headers); debugStatusCode(LOG_TAG, statusCode); debugThrowable(LOG_TAG, e); @@ -129,7 +130,7 @@ public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Th @Override public void onRetry(int retryNo) { Toast.makeText(AsyncBackgroundThreadSample.this, - String.format("Request is retried, retry no. %d", retryNo), + String.format(Locale.US, "Request is retried, retry no. %d", retryNo), Toast.LENGTH_SHORT) .show(); } diff --git a/sample/src/main/java/com/loopj/android/http/sample/BinarySample.java b/sample/src/main/java/com/loopj/android/http/sample/BinarySample.java index fea76991d..73d47a5ad 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/BinarySample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/BinarySample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/CancelAllRequestsSample.java b/sample/src/main/java/com/loopj/android/http/sample/CancelAllRequestsSample.java index ac69e69ac..7348e26e4 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/CancelAllRequestsSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/CancelAllRequestsSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/CancelRequestByTagSample.java b/sample/src/main/java/com/loopj/android/http/sample/CancelRequestByTagSample.java index aab1ce744..38f1133bd 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/CancelRequestByTagSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/CancelRequestByTagSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/CancelRequestHandleSample.java b/sample/src/main/java/com/loopj/android/http/sample/CancelRequestHandleSample.java index 5266a50e1..e41a1d1be 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/CancelRequestHandleSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/CancelRequestHandleSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ import android.util.Log; +import java.util.Locale; + import com.loopj.android.http.RequestHandle; public class CancelRequestHandleSample extends ThreadingTimeoutSample { @@ -33,14 +35,14 @@ public int getSampleTitle() { @Override public void onCancelButtonPressed() { - Log.d(LOG_TAG, String.format("Number of handles found: %d", getRequestHandles().size())); + Log.d(LOG_TAG, String.format(Locale.US, "Number of handles found: %d", getRequestHandles().size())); int counter = 0; for (RequestHandle handle : getRequestHandles()) { if (!handle.isCancelled() && !handle.isFinished()) { - Log.d(LOG_TAG, String.format("Cancelling handle %d", counter)); - Log.d(LOG_TAG, String.format("Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed")); + Log.d(LOG_TAG, String.format(Locale.US, "Cancelling handle %d", counter)); + Log.d(LOG_TAG, String.format(Locale.US, "Handle %d cancel", counter) + (handle.cancel(true) ? " succeeded" : " failed")); } else { - Log.d(LOG_TAG, String.format("Handle %d already non-cancellable", counter)); + Log.d(LOG_TAG, String.format(Locale.US, "Handle %d already non-cancellable", counter)); } counter++; } diff --git a/sample/src/main/java/com/loopj/android/http/sample/CustomCASample.java b/sample/src/main/java/com/loopj/android/http/sample/CustomCASample.java index faf14ffc2..2a3798ca2 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/CustomCASample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/CustomCASample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/DeleteSample.java b/sample/src/main/java/com/loopj/android/http/sample/DeleteSample.java index 9828894f7..69f443496 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/DeleteSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/DeleteSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/DirectorySample.java b/sample/src/main/java/com/loopj/android/http/sample/DirectorySample.java index 74c41ca2c..37b3f986d 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/DirectorySample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/DirectorySample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -32,6 +32,8 @@ import java.io.File; +import java.util.Locale; + import cz.msebera.android.httpclient.Header; import cz.msebera.android.httpclient.HttpEntity; @@ -71,8 +73,8 @@ public void onClick(View v) { clearOutputs(); if (lastResponseHandler != null) { File toBeDeleted = lastResponseHandler.getTargetFile(); - debugResponse(LOG_TAG, String.format("File was deleted? %b", toBeDeleted.delete())); - debugResponse(LOG_TAG, String.format("Delete file path: %s", toBeDeleted.getAbsolutePath())); + debugResponse(LOG_TAG, String.format(Locale.US, "File was deleted? %b", toBeDeleted.delete())); + debugResponse(LOG_TAG, String.format(Locale.US, "Delete file path: %s", toBeDeleted.getAbsolutePath())); } else { debugThrowable(LOG_TAG, new Error("You have to Run example first")); } diff --git a/sample/src/main/java/com/loopj/android/http/sample/FileSample.java b/sample/src/main/java/com/loopj/android/http/sample/FileSample.java index 08637ea1c..c06f9c480 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/FileSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/FileSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/GetSample.java b/sample/src/main/java/com/loopj/android/http/sample/GetSample.java index 02e3880c0..27b0be0e0 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/GetSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/GetSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import com.loopj.android.http.RequestHandle; import com.loopj.android.http.ResponseHandlerInterface; +import java.util.Locale; + import cz.msebera.android.httpclient.Header; import cz.msebera.android.httpclient.HttpEntity; @@ -85,7 +87,7 @@ public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Th @Override public void onRetry(int retryNo) { Toast.makeText(GetSample.this, - String.format("Request is retried, retry no. %d", retryNo), + String.format(Locale.US, "Request is retried, retry no. %d", retryNo), Toast.LENGTH_SHORT) .show(); } diff --git a/sample/src/main/java/com/loopj/android/http/sample/GzipSample.java b/sample/src/main/java/com/loopj/android/http/sample/GzipSample.java index 9025a3000..8da1c9372 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/GzipSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/GzipSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/HeadSample.java b/sample/src/main/java/com/loopj/android/http/sample/HeadSample.java index 43443970b..d3a6d0dcb 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/HeadSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/HeadSample.java @@ -23,6 +23,8 @@ import cz.msebera.android.httpclient.Header; import cz.msebera.android.httpclient.HttpEntity; +import java.util.Locale; + public class HeadSample extends FileSample { private static final String LOG_TAG = "HeadSample"; @@ -34,12 +36,12 @@ public ResponseHandlerInterface getResponseHandler() { public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { debugStatusCode(LOG_TAG, statusCode); debugHeaders(LOG_TAG, headers); - debugResponse(LOG_TAG, String.format("Response of size: %d", responseBody == null ? 0 : responseBody.length)); + debugResponse(LOG_TAG, String.format(Locale.US, "Response of size: %d", responseBody == null ? 0 : responseBody.length)); } @Override public void onProgress(long bytesWritten, long totalSize) { - addView(getColoredView(LIGHTRED, String.format("Progress %d from %d", bytesWritten, totalSize))); + addView(getColoredView(LIGHTRED, String.format(Locale.US, "Progress %d from %d", bytesWritten, totalSize))); } @Override @@ -47,7 +49,7 @@ public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Thr debugStatusCode(LOG_TAG, statusCode); debugHeaders(LOG_TAG, headers); debugThrowable(LOG_TAG, throwable); - debugResponse(LOG_TAG, String.format("Response of size: %d", responseBody == null ? 0 : responseBody.length)); + debugResponse(LOG_TAG, String.format(Locale.US, "Response of size: %d", responseBody == null ? 0 : responseBody.length)); } }; } diff --git a/sample/src/main/java/com/loopj/android/http/sample/Http401AuthSample.java b/sample/src/main/java/com/loopj/android/http/sample/Http401AuthSample.java index 06d32d171..93db38c3c 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/Http401AuthSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/Http401AuthSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -188,7 +188,7 @@ public DialogRunnable(String realm) { String prefaceText = preface.getText().toString(); // Substitute placeholders, and re-set the value. - preface.setText(String.format(prefaceText, SECRET_USERNAME, SECRET_PASSWORD)); + preface.setText(String.format(Locale.US, prefaceText, SECRET_USERNAME, SECRET_PASSWORD)); } @Override diff --git a/sample/src/main/java/com/loopj/android/http/sample/JsonSample.java b/sample/src/main/java/com/loopj/android/http/sample/JsonSample.java index 87442e1ec..59469ea9d 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/JsonSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/JsonSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/JsonStreamerSample.java b/sample/src/main/java/com/loopj/android/http/sample/JsonStreamerSample.java index 91b660f73..4d4d24d03 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/JsonStreamerSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/JsonStreamerSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/PersistentCookiesSample.java b/sample/src/main/java/com/loopj/android/http/sample/PersistentCookiesSample.java index 4be1c222d..69a72e2fb 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/PersistentCookiesSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/PersistentCookiesSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/PostSample.java b/sample/src/main/java/com/loopj/android/http/sample/PostSample.java index 81ce90d93..815961f04 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/PostSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/PostSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/PrePostProcessingSample.java b/sample/src/main/java/com/loopj/android/http/sample/PrePostProcessingSample.java index 04acb7ead..654dab769 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/PrePostProcessingSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/PrePostProcessingSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/PutSample.java b/sample/src/main/java/com/loopj/android/http/sample/PutSample.java index 6be80c5c0..5cab76591 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/PutSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/PutSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/RangeResponseSample.java b/sample/src/main/java/com/loopj/android/http/sample/RangeResponseSample.java index aecd8c5ef..e7f2e3e84 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/RangeResponseSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/RangeResponseSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -30,6 +30,8 @@ import java.io.File; import java.io.IOException; +import java.util.Locale; + import cz.msebera.android.httpclient.Header; import cz.msebera.android.httpclient.HttpEntity; import cz.msebera.android.httpclient.client.methods.HttpUriRequest; @@ -75,7 +77,7 @@ protected void onDestroy() { // Remove temporary file. if (file != null) { if (!file.delete()) { - Log.e(LOG_TAG, String.format("Couldn't remove temporary file in path: %s", file.getAbsolutePath())); + Log.e(LOG_TAG, String.format(Locale.US, "Couldn't remove temporary file in path: %s", file.getAbsolutePath())); } file = null; } diff --git a/sample/src/main/java/com/loopj/android/http/sample/Redirect302Sample.java b/sample/src/main/java/com/loopj/android/http/sample/Redirect302Sample.java index faf92cbfb..832b6a6eb 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/Redirect302Sample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/Redirect302Sample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -27,6 +27,8 @@ import cz.msebera.android.httpclient.client.HttpClient; import cz.msebera.android.httpclient.impl.client.DefaultHttpClient; +import java.util.Locale; + public class Redirect302Sample extends GetSample { private static final int MENU_ENABLE_REDIRECTS = 10; @@ -89,7 +91,7 @@ public AsyncHttpClient getAsyncHttpClient() { HttpClient client = ahc.getHttpClient(); if (client instanceof DefaultHttpClient) { Toast.makeText(this, - String.format("redirects: %b\nrelative redirects: %b\ncircular redirects: %b", + String.format(Locale.US, "redirects: %b\nrelative redirects: %b\ncircular redirects: %b", enableRedirects, enableRelativeRedirects, enableCircularRedirects), Toast.LENGTH_SHORT ).show(); diff --git a/sample/src/main/java/com/loopj/android/http/sample/RetryRequestSample.java b/sample/src/main/java/com/loopj/android/http/sample/RetryRequestSample.java index 24816064a..64c797c7f 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/RetryRequestSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/RetryRequestSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/SampleInterface.java b/sample/src/main/java/com/loopj/android/http/sample/SampleInterface.java index 3af2fed0d..a259833c7 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/SampleInterface.java +++ b/sample/src/main/java/com/loopj/android/http/sample/SampleInterface.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/SampleParentActivity.java b/sample/src/main/java/com/loopj/android/http/sample/SampleParentActivity.java index ddb3e43a6..165b2baf8 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/SampleParentActivity.java +++ b/sample/src/main/java/com/loopj/android/http/sample/SampleParentActivity.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -263,7 +263,7 @@ public List
getRequestHeadersList() { String headerName = line.substring(0, equalSignPos).trim(); String headerValue = line.substring(1 + equalSignPos).trim(); - Log.d(LOG_TAG, String.format("Added header: [%s:%s]", headerName, headerValue)); + Log.d(LOG_TAG, String.format(Locale.US, "Added header: [%s:%s]", headerName, headerValue)); headers.add(new BasicHeader(headerName, headerValue)); } catch (Throwable t) { @@ -394,7 +394,7 @@ public void setAsyncHttpClient(AsyncHttpClient client) { @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setHomeAsUpEnabled() { - if (Integer.valueOf(Build.VERSION.SDK) >= 11) { + if (Build.VERSION.SDK_INT >= 11) { if (getActionBar() != null) getActionBar().setDisplayHomeAsUpEnabled(true); } diff --git a/sample/src/main/java/com/loopj/android/http/sample/SaxSample.java b/sample/src/main/java/com/loopj/android/http/sample/SaxSample.java index 0c5ecebff..be310272c 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/SaxSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/SaxSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/SynchronousClientSample.java b/sample/src/main/java/com/loopj/android/http/sample/SynchronousClientSample.java index 77ffcc60b..59ff04186 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/SynchronousClientSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/SynchronousClientSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/ThreadingTimeoutSample.java b/sample/src/main/java/com/loopj/android/http/sample/ThreadingTimeoutSample.java index 815268335..f65ba17d8 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/ThreadingTimeoutSample.java +++ b/sample/src/main/java/com/loopj/android/http/sample/ThreadingTimeoutSample.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import com.loopj.android.http.RequestHandle; import com.loopj.android.http.ResponseHandlerInterface; +import java.util.Locale; + import cz.msebera.android.httpclient.Header; import cz.msebera.android.httpclient.HttpEntity; @@ -64,7 +66,7 @@ protected synchronized void setStatus(int id, String status) { states.put(id, current == null ? status : current + "," + status); clearOutputs(); for (int i = 0; i < states.size(); i++) { - debugResponse(LOG_TAG, String.format("%d (from %d): %s", states.keyAt(i), getCounter(), states.get(states.keyAt(i)))); + debugResponse(LOG_TAG, String.format(Locale.US, "%d (from %d): %s", states.keyAt(i), getCounter(), states.get(states.keyAt(i)))); } } diff --git a/sample/src/main/java/com/loopj/android/http/sample/WaypointsActivity.java b/sample/src/main/java/com/loopj/android/http/sample/WaypointsActivity.java index c963a0559..f1dba9d7a 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/WaypointsActivity.java +++ b/sample/src/main/java/com/loopj/android/http/sample/WaypointsActivity.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/package-info.java b/sample/src/main/java/com/loopj/android/http/sample/package-info.java index c22f5a8d1..704f0d47d 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/package-info.java +++ b/sample/src/main/java/com/loopj/android/http/sample/package-info.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/services/ExampleIntentService.java b/sample/src/main/java/com/loopj/android/http/sample/services/ExampleIntentService.java index 5742e34e7..53e069ec3 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/services/ExampleIntentService.java +++ b/sample/src/main/java/com/loopj/android/http/sample/services/ExampleIntentService.java @@ -10,6 +10,8 @@ import com.loopj.android.http.sample.IntentServiceSample; import com.loopj.android.http.sample.util.IntentUtil; +import java.util.Locale; + import cz.msebera.android.httpclient.Header; public class ExampleIntentService extends IntentService { @@ -73,7 +75,7 @@ public void onCancel() { @Override public void onRetry(int retryNo) { sendBroadcast(new Intent(IntentServiceSample.ACTION_RETRY)); - Log.d(LOG_TAG, String.format("onRetry: %d", retryNo)); + Log.d(LOG_TAG, String.format(Locale.US, "onRetry: %d", retryNo)); } @Override diff --git a/sample/src/main/java/com/loopj/android/http/sample/services/package-info.java b/sample/src/main/java/com/loopj/android/http/sample/services/package-info.java index c7c54db2b..df7d33ef2 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/services/package-info.java +++ b/sample/src/main/java/com/loopj/android/http/sample/services/package-info.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/util/FileUtil.java b/sample/src/main/java/com/loopj/android/http/sample/util/FileUtil.java index 18f4334df..faa9b7f5d 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/util/FileUtil.java +++ b/sample/src/main/java/com/loopj/android/http/sample/util/FileUtil.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/util/SampleJSON.java b/sample/src/main/java/com/loopj/android/http/sample/util/SampleJSON.java index e9f109415..60413e5ed 100755 --- a/sample/src/main/java/com/loopj/android/http/sample/util/SampleJSON.java +++ b/sample/src/main/java/com/loopj/android/http/sample/util/SampleJSON.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/main/java/com/loopj/android/http/sample/util/SecureSocketFactory.java b/sample/src/main/java/com/loopj/android/http/sample/util/SecureSocketFactory.java index 1f55730b5..fddcafcbe 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/util/SecureSocketFactory.java +++ b/sample/src/main/java/com/loopj/android/http/sample/util/SecureSocketFactory.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Sample Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package com.loopj.android.http.sample.util; -import android.os.Build; import android.util.Log; import com.loopj.android.http.AsyncHttpClient; @@ -189,11 +188,9 @@ public Socket createSocket() throws IOException { */ private void injectHostname(Socket socket, String host) { try { - if (Integer.valueOf(Build.VERSION.SDK) >= 4) { - Field field = InetAddress.class.getDeclaredField("hostName"); - field.setAccessible(true); - field.set(socket.getInetAddress(), host); - } + Field field = InetAddress.class.getDeclaredField("hostName"); + field.setAccessible(true); + field.set(socket.getInetAddress(), host); } catch (Exception ignored) { } } diff --git a/sample/src/main/java/com/loopj/android/http/sample/util/package-info.java b/sample/src/main/java/com/loopj/android/http/sample/util/package-info.java index bc0c7263c..7d28904fd 100644 --- a/sample/src/main/java/com/loopj/android/http/sample/util/package-info.java +++ b/sample/src/main/java/com/loopj/android/http/sample/util/package-info.java @@ -1,7 +1,7 @@ /* Android Asynchronous Http Client Copyright (c) 2014 Marek Sebera - https://loopj.com + https://github.com/android-async-http/android-async-http Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/sample/src/standard/java/com/loopj/android/http/sample/SampleApplication.java b/sample/src/standard/java/com/loopj/android/http/sample/SampleApplication.java index 2ef13dc0c..84522ce94 100644 --- a/sample/src/standard/java/com/loopj/android/http/sample/SampleApplication.java +++ b/sample/src/standard/java/com/loopj/android/http/sample/SampleApplication.java @@ -18,17 +18,15 @@ public void onCreate() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setStrictMode() { - if (Integer.valueOf(Build.VERSION.SDK) > 3) { - Log.d(LOG_TAG, "Enabling StrictMode policy over Sample application"); - StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() - .detectAll() - .penaltyLog() - .penaltyDeath() - .build()); - StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() - .detectAll() - .penaltyLog() - .build()); - } + Log.d(LOG_TAG, "Enabling StrictMode policy over Sample application"); + StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() + .detectAll() + .penaltyLog() + .penaltyDeath() + .build()); + StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() + .detectAll() + .penaltyLog() + .build()); } } diff --git a/settings.gradle b/settings.gradle index 612d9e44e..9a70f607b 100755 --- a/settings.gradle +++ b/settings.gradle @@ -1,2 +1,6 @@ include ':library' include ':sample' + +rootProject.name = 'android-async-http-project' +project(':library').name = 'android-async-http' +project(':sample').name = 'android-async-http-sample'