Skip to content

Commit

Permalink
Merge pull request #20590 from wordpress-mobile/maxime/remove-gravata…
Browse files Browse the repository at this point in the history
…r-utils-from-wputils-squashed

 Replace GravatarUtils from WPUtils, use Gravatar-SDK-Android instead
  • Loading branch information
maxme authored Apr 9, 2024
2 parents db2858d + 1bdd94d commit 17f5845
Show file tree
Hide file tree
Showing 44 changed files with 298 additions and 400 deletions.
3 changes: 2 additions & 1 deletion WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ repositories {
includeGroupByRegex "org.wordpress.react-native-libraries.*"
includeGroup "com.automattic"
includeGroup "com.automattic.tracks"
includeGroup "com.gravatar"
}
}
maven {
Expand Down Expand Up @@ -388,6 +389,7 @@ dependencies {
exclude group: 'com.mcxiaoke.volley'
}
implementation "org.wordpress:persistentedittext:$wordPressPersistentEditTextVersion"
implementation "$gradle.ext.gravatarBinaryPath:$gravatarVersion"

implementation "androidx.arch.core:core-common:$androidxArchCoreVersion"
implementation "androidx.arch.core:core-runtime:$androidxArchCoreVersion"
Expand Down Expand Up @@ -438,7 +440,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"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.wordpress.android.util

import com.gravatar.DefaultAvatarOption
import dagger.hilt.android.testing.HiltAndroidTest
import junit.framework.TestCase.assertEquals
import org.junit.Test

@HiltAndroidTest
class WPAvatarUtilsTest {
@Test
fun rewriteAvatarUrlReplaceNonGravatarUrlToPhotonUrl() {
assertEquals(
"https://i0.wp.com/example.com/image.jpg?strip=info&quality=65&resize=100,100&ssl=1",
WPAvatarUtils.rewriteAvatarUrl("https://example.com/image.jpg", 100)
)
}

@Test
fun rewriteAvatarUrlDropQueryParamsFromGravatarUrlAndAddDefaults() {
assertEquals(
"https://www.gravatar.com/avatar/" +
"31c5543c1734d25c7206f5fd591525d0295bec6fe84ff82f946a34fe970a1e66?d=mp&s=100",
WPAvatarUtils.rewriteAvatarUrl(
"https://www.gravatar.com/avatar/" +
"31c5543c1734d25c7206f5fd591525d0295bec6fe84ff82f946a34fe970a1e66?d=wavatar&s=1000",
100
)
)
}

@Test
fun rewriteAvatarUrlAddDefaultsToGravatarUrl() {
assertEquals(
"https://www.gravatar.com/avatar/" +
"31c5543c1734d25c7206f5fd591525d0295bec6fe84ff82f946a34fe970a1e66?d=404&s=200",
WPAvatarUtils.rewriteAvatarUrl(
"https://www.gravatar.com/avatar/" +
"31c5543c1734d25c7206f5fd591525d0295bec6fe84ff82f946a34fe970a1e66",
200, DefaultAvatarOption.Status404
)
)
}
}
1 change: 0 additions & 1 deletion WordPress/src/jetpack/assets/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ <h2>Additional Libraries</h2>
<li><a href="https://github.com/jukka/tagsoup">TagSoup</a>: Copyright 2002-2008, John Cowan</li>
<li><a href="https://github.com/Yalantis/uCrop">uCrop</a>: Copyright 2017, Yalantis</li>
<li><a href="https://github.com/xizzhu/simple-tool-tip">Simple Tool Tip</a>: Copyright 2016, Xizhi Zhu</li>
<li><a href="https://github.com/square/okio">okio/okhttp</a>: Copyright 2013 Square, Inc.</li>
<li><a href="https://github.com/greenrobot/EventBus">EventBus</a>: Copyright 2012-2016 Markus Junginger, greenrobot</li>
<li><a href="https://github.com/INDExOS/media-for-mobile">Mobile 4 Media</a>: Copyright 2016, INDExOS</li>
<li><a href="https://github.com/Tenor-Inc/tenor-android-core">Tenor Android Core</a>: Copyright 2017, Tenor Inc</li>
Expand Down
1 change: 0 additions & 1 deletion WordPress/src/main/assets/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ <h2>Additional Libraries</h2>
<li><a href="https://github.com/jukka/tagsoup">TagSoup</a>: Copyright 2002-2008, John Cowan</li>
<li><a href="https://github.com/Yalantis/uCrop">uCrop</a>: Copyright 2017, Yalantis</li>
<li><a href="https://github.com/xizzhu/simple-tool-tip">Simple Tool Tip</a>: Copyright 2016, Xizhi Zhu</li>
<li><a href="https://github.com/square/okio">okio/okhttp</a>: Copyright 2013 Square, Inc.</li>
<li><a href="https://github.com/greenrobot/EventBus">EventBus</a>: Copyright 2012-2016 Markus Junginger, greenrobot</li>
<li><a href="https://github.com/INDExOS/media-for-mobile">Mobile 4 Media</a>: Copyright 2016, INDExOS</li>
<li><a href="https://github.com/Tenor-Inc/tenor-android-core">Tenor Android Core</a>: Copyright 2017, Tenor Inc</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.wordpress.android.models.ReaderUser;
import org.wordpress.android.models.ReaderUserIdList;
import org.wordpress.android.models.ReaderUserList;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.util.WPAvatarUtils;
import org.wordpress.android.util.SqlUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -108,7 +108,7 @@ public static ArrayList<String> getAvatarUrls(ReaderUserIdList userIds, int max,
if (c.moveToFirst()) {
do {
long userId = c.getLong(0);
String url = GravatarUtils.fixGravatarUrl(c.getString(1), avatarSz);
String url = WPAvatarUtils.rewriteAvatarUrl(c.getString(1), avatarSz);
// add current user to the top
if (userId == wpComUserId) {
avatars.add(0, url);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.wordpress.android.modules

import com.gravatar.services.AvatarService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@InstallIn(SingletonComponent::class)
@Module
class GravatarModule {
@Singleton
@Provides
fun provideGravatarApi(
): AvatarService = AvatarService()
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 17f5845

Please sign in to comment.