From f59b4de267050fc022a15a1488055ccfc4fac878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?He=CC=81ctor=20Abraham?= Date: Mon, 15 Jan 2024 12:49:16 +0100 Subject: [PATCH] Remove Okio dependency from WPAndroid As we've moved the Gravatar update to an external library. We no longer need the Okio dependency in this project. --- WordPress/build.gradle | 1 - .../android/networking/GravatarApiTest.java | 69 ------------------- WordPress/src/jetpack/assets/licenses.html | 1 - WordPress/src/main/assets/licenses.html | 1 - .../android/networking/StreamingRequest.java | 41 ----------- build.gradle | 1 - ...test_instructions_per_dependency_update.md | 27 ++------ 7 files changed, 5 insertions(+), 136 deletions(-) delete mode 100644 WordPress/src/androidTest/java/org/wordpress/android/networking/GravatarApiTest.java delete mode 100644 WordPress/src/main/java/org/wordpress/android/networking/StreamingRequest.java diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 5f30cf70aa97..b7d351cdb137 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -432,7 +432,6 @@ dependencies { implementation "com.github.chrisbanes:PhotoView:$chrisbanesPhotoviewVersion" implementation "org.greenrobot:eventbus:$eventBusVersion" implementation "org.greenrobot:eventbus-java:$eventBusVersion" - implementation "com.squareup.okio:okio:$squareupOkioVersion" implementation "com.squareup.retrofit2:retrofit:$squareupRetrofitVersion" implementation "org.apache.commons:commons-text:$apacheCommonsTextVersion" implementation "com.airbnb.android:lottie:$lottieVersion" diff --git a/WordPress/src/androidTest/java/org/wordpress/android/networking/GravatarApiTest.java b/WordPress/src/androidTest/java/org/wordpress/android/networking/GravatarApiTest.java deleted file mode 100644 index 831189e51940..000000000000 --- a/WordPress/src/androidTest/java/org/wordpress/android/networking/GravatarApiTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.wordpress.android.networking; - -import android.content.Context; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; - -import javax.inject.Inject; - -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; - -import dagger.hilt.android.testing.HiltAndroidRule; -import dagger.hilt.android.testing.HiltAndroidTest; -import okhttp3.Request; -import okhttp3.RequestBody; -import okio.Buffer; - -import com.gravatar.GravatarApi; - -@HiltAndroidTest -public class GravatarApiTest { - @Rule - public HiltAndroidRule hiltRule = new HiltAndroidRule(this); - - @Inject Context mContext; - - @Before - public void setUp() { - hiltRule.inject(); - } - - @Test - public void testGravatarUploadRequest() throws IOException { - final String fileContent = "abcdefg"; - - File tempFile = new File(mContext.getCacheDir(), "tempFile.jpg"); - FileOutputStream fos = new FileOutputStream(tempFile); - fos.write(fileContent.getBytes()); - fos.flush(); - fos.close(); - - final String email = "a@b.com"; - Request uploadRequest = GravatarApi.prepareGravatarUpload(email, tempFile); - - assertEquals("POST", uploadRequest.method()); - - RequestBody requestBody = uploadRequest.body(); - assertTrue(requestBody.contentType().toString().startsWith("multipart/form-data")); - - final Buffer buffer = new Buffer(); - requestBody.writeTo(buffer); - final String body = buffer.readUtf8(); - - assertTrue(body.contains("Content-Disposition: form-data; name=\"account\"")); - assertTrue(body.contains("Content-Length: " + email.length())); - assertTrue(body.contains(email)); - - assertTrue(body.contains( - "Content-Disposition: form-data; name=\"filedata\"; filename=\"" + tempFile.getName() + "\"")); - assertTrue(body.contains("Content-Type: multipart/form-data")); - assertTrue(body.contains(fileContent)); - } -} diff --git a/WordPress/src/jetpack/assets/licenses.html b/WordPress/src/jetpack/assets/licenses.html index 2164dddc6107..cece0d1c64b8 100644 --- a/WordPress/src/jetpack/assets/licenses.html +++ b/WordPress/src/jetpack/assets/licenses.html @@ -31,7 +31,6 @@

Additional Libraries

  • TagSoup: Copyright 2002-2008, John Cowan
  • uCrop: Copyright 2017, Yalantis
  • Simple Tool Tip: Copyright 2016, Xizhi Zhu
  • -
  • okio/okhttp: Copyright 2013 Square, Inc.
  • EventBus: Copyright 2012-2016 Markus Junginger, greenrobot
  • Mobile 4 Media: Copyright 2016, INDExOS
  • Tenor Android Core: Copyright 2017, Tenor Inc
  • diff --git a/WordPress/src/main/assets/licenses.html b/WordPress/src/main/assets/licenses.html index f774c12d914c..ef5943951f07 100644 --- a/WordPress/src/main/assets/licenses.html +++ b/WordPress/src/main/assets/licenses.html @@ -31,7 +31,6 @@

    Additional Libraries

  • TagSoup: Copyright 2002-2008, John Cowan
  • uCrop: Copyright 2017, Yalantis
  • Simple Tool Tip: Copyright 2016, Xizhi Zhu
  • -
  • okio/okhttp: Copyright 2013 Square, Inc.
  • EventBus: Copyright 2012-2016 Markus Junginger, greenrobot
  • Mobile 4 Media: Copyright 2016, INDExOS
  • Tenor Android Core: Copyright 2017, Tenor Inc
  • diff --git a/WordPress/src/main/java/org/wordpress/android/networking/StreamingRequest.java b/WordPress/src/main/java/org/wordpress/android/networking/StreamingRequest.java deleted file mode 100644 index 60c6880feb27..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/networking/StreamingRequest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.wordpress.android.networking; - -import java.io.File; -import java.io.IOException; - -import okhttp3.MediaType; -import okhttp3.RequestBody; -import okhttp3.internal.Util; -import okio.BufferedSink; -import okio.Okio; -import okio.Source; - -public class StreamingRequest extends RequestBody { - public static final int CHUNK_SIZE = 2048; - - private final File mFile; - - public StreamingRequest(File file) { - mFile = file; - } - - @Override - public MediaType contentType() { - return MediaType.parse("multipart/form-data"); - } - - @Override - public void writeTo(BufferedSink sink) throws IOException { - Source source = null; - try { - source = Okio.source(mFile); - - while (source.read(sink.buffer(), CHUNK_SIZE) != -1) { - sink.flush(); - } - } finally { - Util.closeQuietly(source); - } - } -}; - diff --git a/build.gradle b/build.gradle index 30e802bf6188..fb76a8fc157e 100644 --- a/build.gradle +++ b/build.gradle @@ -81,7 +81,6 @@ ext { lottieVersion = '6.1.0' philjayMpAndroidChartVersion = 'v3.1.0' squareupKotlinPoetVersion = '1.6.0' - squareupOkioVersion = '3.6.0' squareupRetrofitVersion = '2.9.0' uCropVersion = '2.2.8' zendeskVersion = '5.1.2' diff --git a/docs/test_instructions_per_dependency_update.md b/docs/test_instructions_per_dependency_update.md index 60ef32eec1cc..3ecab7244ed1 100644 --- a/docs/test_instructions_per_dependency_update.md +++ b/docs/test_instructions_per_dependency_update.md @@ -55,19 +55,17 @@ rather than strict requirements. 4. [PlayServicesAuth](#playservicesauth) 5. [PlayServicesCoreScanner](#playservicescodescanner) 6. [PlayReview](#playreview) -5. Network - 1. [Okio](#okio) -6. Tool +5. Tool 1. [Zendesk](#zendesk) 2. [JSoup](#jsoup) -7. Other Core +6. Other Core 1. [AutoService](#autoservice) 2. [KotlinPoet](#kotlinpoet) -8. Other UI +7. Other UI 1. [Lottie](#lottie) 2. [UCrop](#ucrop) -9. [Smoke Test](#smoke-test) -10. [Special](#special) +8. [Smoke Test](#smoke-test) +9. [Special](#special) ℹ️ Every test instruction should be prefixed with one of the following: - [JP/WP] This test applies to both, the `Jetpack` and `WordPress` apps. @@ -435,21 +433,6 @@ Step.3: ----- -### Okio [[squareupOkioVersion](https://github.com/wordpress-mobile/WordPress-Android/blob/trunk/build.gradle)] - -
    - 1. [JP/WP] Me Screen [GravatarApi.java + StreamingRequest.java] - -- Go to `Me` tab. -- From the `Me` screen you are in, click on your profile's icon (`CHANGE PHOTO`). -- Choose an image and wait for the `Edit Photo` screen to appear. -- Crop the image and click the `done` menu option (top right). -- Verify the image is updated accordingly. - -
    - ------ - ### Zendesk [[zendeskVersion](https://github.com/wordpress-mobile/WordPress-Android/blob/trunk/build.gradle)]