Skip to content

Commit

Permalink
Merge pull request square#1567 from square/jw/break-all-the-things
Browse files Browse the repository at this point in the history
Next version is 3.0.
  • Loading branch information
JakeWharton authored Jan 5, 2017
2 parents 14c1541 + 9ce76e8 commit 4d5a852
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 788 deletions.
7 changes: 3 additions & 4 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ ext {
targetSdkVersion = 25
sourceCompatibilityVersion = JavaVersion.VERSION_1_7
targetCompatibilityVersion = JavaVersion.VERSION_1_7
okhttp3Version = '3.0.1'
okhttpVersion = '3.0.1'
supportLibrariesVersion = '25.1.0'

dep = [
androidPlugin : 'com.android.tools.build:gradle:2.1.3',
okhttp : 'com.squareup.okhttp:okhttp:2.7.1',
okhttp3 : "com.squareup.okhttp3:okhttp:$okhttp3Version",
mockWebServer : "com.squareup.okhttp3:mockwebserver:$okhttp3Version",
okhttp : "com.squareup.okhttp3:okhttp:$okhttpVersion",
mockWebServer : "com.squareup.okhttp3:mockwebserver:$okhttpVersion",
pollexor : 'com.squareup:pollexor:2.0.4',
supportV4 : "com.android.support:support-v4:$supportLibrariesVersion",
supportAnnotations : "com.android.support:support-annotations:$supportLibrariesVersion",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.squareup.picasso
VERSION_NAME=2.6.0-SNAPSHOT
VERSION_NAME=3.0.0-SNAPSHOT

POM_URL=https://github.com/square/picasso/
POM_SCM_URL=https://github.com/square/picasso/
Expand Down
1 change: 1 addition & 0 deletions picasso-pollexor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {
lintOptions {
textOutput 'stdout'
textReport true
lintConfig file('lint.xml')
}

dexOptions {
Expand Down
6 changes: 6 additions & 0 deletions picasso-pollexor/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="InvalidPackage" severity="error">
<ignore regexp="okio-.*jar"/>
</issue>
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,6 @@
public class PollexorRequestTransformer implements RequestTransformer {
private final Thumbor thumbor;

/**
* @deprecated Use {@link #PollexorRequestTransformer(Thumbor)} instead.
* Create a transformer for the specified Thumbor host. This will not use URL encryption.
*/
@Deprecated public PollexorRequestTransformer(String host) {
this(Thumbor.create(host));
}

/**
* @deprecated Use {@link #PollexorRequestTransformer(Thumbor)} instead.
* Create a transformer for the specified Thumbor host using the provided URL encryption key.
*/
@Deprecated public PollexorRequestTransformer(String host, String key) {
this(Thumbor.create(host, key));
}

/** Create a transformer for the specified {@link Thumbor}. */
public PollexorRequestTransformer(Thumbor thumbor) {
this.thumbor = thumbor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public class PollexorRequestTransformerTest {
private static final String IMAGE = "http://google.com/logo.png";
private static final Uri IMAGE_URI = Uri.parse(IMAGE);

private RequestTransformer transformer = new PollexorRequestTransformer(HOST);
private RequestTransformer secureTransformer = new PollexorRequestTransformer(HOST, KEY);
private RequestTransformer transformer = new PollexorRequestTransformer(Thumbor.create(HOST));
private RequestTransformer secureTransformer =
new PollexorRequestTransformer(Thumbor.create(HOST, KEY));

@Test public void resourceIdRequestsAreNotTransformed() {
Request input = new Request.Builder(12).build();
Expand Down
1 change: 0 additions & 1 deletion picasso-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ buildscript {
apply plugin: 'com.android.application'

dependencies {
compile dep.okhttp
compile dep.supportV4
compile dep.supportAnnotations
compile project(':picasso')
Expand Down
4 changes: 2 additions & 2 deletions picasso/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {
lintOptions {
textOutput 'stdout'
textReport true
lintConfig file('lint.xml')
}

dexOptions {
Expand All @@ -32,8 +33,7 @@ android {
}

dependencies {
provided dep.okhttp
provided dep.okhttp3
compile dep.okhttp
compile dep.supportAnnotations
testCompile dep.junit
testCompile dep.fest
Expand Down
11 changes: 0 additions & 11 deletions picasso/consumer-proguard-rules.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
### PICASSO

# Checks for OkHttp versions on the classpath to determine Downloader to use.
-dontnote com.squareup.picasso.Utils
# Downloader used only when OkHttp 2.x is present on the classpath.
-dontwarn com.squareup.picasso.OkHttpDownloader
# Downloader used only when OkHttp 3.x is present on the classpath.
-dontwarn com.squareup.picasso.OkHttp3Downloader


### OKHTTP

# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote okhttp3.internal.Platform
-dontnote com.squareup.okhttp.internal.Platform


### OKIO
Expand Down
6 changes: 6 additions & 0 deletions picasso/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="InvalidPackage" severity="error">
<ignore regexp="okio-.*jar"/>
</issue>
</lint>
66 changes: 2 additions & 64 deletions picasso/src/main/java/com/squareup/picasso/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,95 +58,33 @@ public ResponseException(String message, int networkPolicy, int responseCode) {
/** Response stream or bitmap and info. */
class Response {
final InputStream stream;
final Bitmap bitmap;
final boolean cached;
final long contentLength;

/**
* Response image and info.
*
* @param bitmap Image.
* @param loadedFromCache {@code true} if the source of the image is from a local disk cache.
* @deprecated Use {@link RequestHandler} for directly loading {@link Bitmap} instances.
*/
@Deprecated
public Response(@NonNull Bitmap bitmap, boolean loadedFromCache) {
if (bitmap == null) {
throw new IllegalArgumentException("Bitmap may not be null.");
}
this.stream = null;
this.bitmap = bitmap;
this.cached = loadedFromCache;
this.contentLength = -1;
}

/**
* Response stream and info.
*
* @param stream Image data stream.
* @param loadedFromCache {@code true} if the source of the stream is from a local disk cache.
* @deprecated Use {@link Response#Response(java.io.InputStream, boolean, long)} instead.
*/
@Deprecated @SuppressWarnings("UnusedDeclaration")
public Response(@NonNull InputStream stream, boolean loadedFromCache) {
this(stream, loadedFromCache, -1);
}

/**
* Response image and info.
*
* @param bitmap Image.
* @param loadedFromCache {@code true} if the source of the image is from a local disk cache.
* @param contentLength The content length of the response, typically derived by the
* {@code Content-Length} HTTP header.
* @deprecated The {@code contentLength} argument value is ignored. Use {@link #Response(Bitmap,
* boolean)}.
*/
@Deprecated @SuppressWarnings("UnusedDeclaration")
public Response(@NonNull Bitmap bitmap, boolean loadedFromCache, long contentLength) {
this(bitmap, loadedFromCache);
}

/**
* Response stream and info.
*
* @param stream Image data stream.
* @param loadedFromCache {@code true} if the source of the stream is from a local disk cache.
* @param contentLength The content length of the response, typically derived by the
* {@code Content-Length} HTTP header.
*/
public Response(@NonNull InputStream stream, boolean loadedFromCache, long contentLength) {
public Response(InputStream stream, boolean loadedFromCache, long contentLength) {
if (stream == null) {
throw new IllegalArgumentException("Stream may not be null.");
}
this.stream = stream;
this.bitmap = null;
this.cached = loadedFromCache;
this.contentLength = contentLength;
}

/**
* Input stream containing image data.
* <p>
* If this returns {@code null}, image data will be available via {@link #getBitmap()}.
*/
@Nullable public InputStream getInputStream() {
public InputStream getInputStream() {
return stream;
}

/**
* Bitmap representing the image.
* <p>
* If this returns {@code null}, image data will be available via {@link #getInputStream()}.
*
* @deprecated Use {@link RequestHandler} for directly loading {@link Bitmap} instances.
*/
@Nullable
@Deprecated
public Bitmap getBitmap() {
return bitmap;
}

/** Content length of the response. Only valid when used with {@link #getInputStream()}. */
public long getContentLength() {
return contentLength;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
*/
package com.squareup.picasso;

import android.graphics.Bitmap;
import android.net.NetworkInfo;
import android.support.annotation.Nullable;

import java.io.IOException;
import java.io.InputStream;

Expand Down Expand Up @@ -53,15 +51,7 @@ public NetworkRequestHandler(Downloader downloader, Stats stats) {

Picasso.LoadedFrom loadedFrom = response.cached ? DISK : NETWORK;

Bitmap bitmap = response.getBitmap();
if (bitmap != null) {
return new Result(bitmap, loadedFrom);
}

InputStream is = response.getInputStream();
if (is == null) {
return null;
}
// Sometimes response content length is zero when requests are being replayed. Haven't found
// root cause to this but retrying the request seems safe to do so.
if (loadedFrom == DISK && response.getContentLength() == 0) {
Expand Down
144 changes: 0 additions & 144 deletions picasso/src/main/java/com/squareup/picasso/OkHttpDownloader.java

This file was deleted.

Loading

0 comments on commit 4d5a852

Please sign in to comment.