From d8b6e3a640ee9ebc368b34b9927722754893fdad Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sat, 30 May 2020 17:05:17 +0300 Subject: [PATCH] Animated avatars in drawer, dropped Picasso in favor of Glide --- app/build.gradle | 2 - app/proguard-rules.pro | 3 -- app/src/main/assets/apache_libraries.html | 3 -- .../gr/thmmy/mthmmy/base/BaseApplication.java | 12 ++--- .../mthmmy/utils/ui/CircleTransform.java | 47 ------------------- 5 files changed, 3 insertions(+), 64 deletions(-) delete mode 100644 app/src/main/java/gr/thmmy/mthmmy/utils/ui/CircleTransform.java diff --git a/app/build.gradle b/app/build.gradle index f7641b8e..5e0f435c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -89,8 +89,6 @@ dependencies { implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' implementation 'com.snatik:storage:2.1.0' implementation 'com.squareup.okhttp3:okhttp:3.12.12' //TODO: Warning: okhttp has dropped support for Android v.19 since okhttp 3.13! - implementation 'com.squareup.picasso:picasso:2.5.2' - implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' implementation 'org.jsoup:jsoup:1.10.3' //TODO: Warning: upgrading from 1.10.3 will break stuff! implementation 'joda-time:joda-time:2.10.4' implementation 'com.github.franmontiel:PersistentCookieJar:1.0.1' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index e7c4ece2..d78e3cec 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -29,9 +29,6 @@ # Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java. -dontwarn org.codehaus.mojo.animal_sniffer.* -# Picasso --dontwarn com.squareup.okhttp.** - #Glide -keep public class * implements com.bumptech.glide.module.GlideModule -keep public class * extends com.bumptech.glide.module.AppGlideModule diff --git a/app/src/main/assets/apache_libraries.html b/app/src/main/assets/apache_libraries.html index 0a77a925..ef777771 100644 --- a/app/src/main/assets/apache_libraries.html +++ b/app/src/main/assets/apache_libraries.html @@ -8,9 +8,6 @@
  • OkHttp v3.12.12 (Copyright ©2019 Square, Inc.)
  • -
  • -
    Picasso v2.5.2 (Copyright ©2013 Square, Inc.)
    -
  • PersistentCookieJar v1.0.1 (Copyright ©2016 Francisco José Montiel Navarro)
  • diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java index 8bdadf10..da6fb9cc 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java @@ -13,6 +13,7 @@ import android.widget.ImageView; import androidx.core.content.ContextCompat; import androidx.preference.PreferenceManager; +import com.bumptech.glide.Glide; import com.crashlytics.android.Crashlytics; import com.crashlytics.android.core.CrashlyticsCore; import com.franmontiel.persistentcookiejar.PersistentCookieJar; @@ -21,12 +22,10 @@ import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersisto import com.google.firebase.FirebaseApp; import com.google.firebase.analytics.FirebaseAnalytics; import com.itkacher.okhttpprofiler.OkHttpProfilerInterceptor; -import com.jakewharton.picasso.OkHttp3Downloader; import com.mikepenz.fontawesome_typeface_library.FontAwesome; import com.mikepenz.iconics.IconicsDrawable; import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader; import com.mikepenz.materialdrawer.util.DrawerImageLoader; -import com.squareup.picasso.Picasso; import net.gotev.uploadservice.UploadService; import net.gotev.uploadservice.okhttp.OkHttpStack; @@ -142,11 +141,6 @@ public class BaseApplication extends Application { client = builder.build(); sessionManager = new SessionManager(client, cookieJar, sharedPrefsCookiePersistor, sharedPrefs, draftsPrefs); - Picasso picasso = new Picasso.Builder(getApplicationContext()) - .downloader(new OkHttp3Downloader(client)) - .build(); - - Picasso.setSingletonInstance(picasso); //All following Picasso (with Picasso.with(Context context) requests will use this Picasso object //Sets up upload service UploadService.NAMESPACE = BuildConfig.APPLICATION_ID; @@ -156,12 +150,12 @@ public class BaseApplication extends Application { DrawerImageLoader.init(new AbstractDrawerImageLoader() { @Override public void set(ImageView imageView, Uri uri, Drawable placeholder, String tag) { - Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView); + Glide.with(imageView.getContext()).load(uri).circleCrop().error(placeholder).placeholder(placeholder).into(imageView); } @Override public void cancel(ImageView imageView) { - Picasso.with(imageView.getContext()).cancelRequest(imageView); + Glide.with(imageView.getContext()).clear(imageView); } @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ui/CircleTransform.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ui/CircleTransform.java deleted file mode 100644 index 813463bd..00000000 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/ui/CircleTransform.java +++ /dev/null @@ -1,47 +0,0 @@ -package gr.thmmy.mthmmy.utils.ui; - -import android.graphics.Bitmap; -import android.graphics.BitmapShader; -import android.graphics.Canvas; -import android.graphics.Paint; - -import com.squareup.picasso.Transformation; - -/** - * Used as parameter for PICASSO library's {@link com.squareup.picasso.RequestCreator#transform(Transformation) transform} method. - * @see com.squareup.picasso.Picasso Picasso - */ -public class CircleTransform implements Transformation { - @Override - public Bitmap transform(Bitmap source) { - int size = Math.min(source.getWidth(), source.getHeight()); - - int x = (source.getWidth() - size) / 2; - int y = (source.getHeight() - size) / 2; - - Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size); - if (squaredBitmap != source) - source.recycle(); - - // For GIF images - Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888; - Bitmap bitmap = Bitmap.createBitmap(size, size, config); - - Canvas canvas = new Canvas(bitmap); - Paint paint = new Paint(); - BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP); - paint.setShader(shader); - paint.setAntiAlias(true); - - float r = size / 2f; - canvas.drawCircle(r, r, r, paint); - - squaredBitmap.recycle(); - return bitmap; - } - - @Override - public String key() { - return "circle"; - } -} \ No newline at end of file