From 03017d090ae3d6ec7575c439c87e615934367f95 Mon Sep 17 00:00:00 2001 From: stom79 Date: Wed, 14 Nov 2018 14:07:25 +0100 Subject: [PATCH] Fix #564 - rounded pp everywhere --- .../activities/EditProfileActivity.java | 21 +------ .../activities/OwnerStatusActivity.java | 24 +------- .../activities/ShowAccountActivity.java | 14 +---- .../activities/ShowConversationActivity.java | 25 +------- .../mastodon/activities/TootActivity.java | 61 +++++++------------ .../gouv/etalab/mastodon/helper/Helper.java | 16 +---- 6 files changed, 29 insertions(+), 132 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java index 121ae725c..569574dcd 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java @@ -54,10 +54,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; - import com.bumptech.glide.Glide; -import com.bumptech.glide.request.target.SimpleTarget; -import com.bumptech.glide.request.transition.Transition; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; @@ -167,23 +164,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou } - Glide.with(getApplicationContext()) - .asBitmap() - .load(url) - .into(new SimpleTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, Transition transition) { - BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true)); - if( pp_actionBar != null){ - pp_actionBar.setImageDrawable(ppDrawable); - } else if( getSupportActionBar() != null){ - - getSupportActionBar().setIcon(ppDrawable); - getSupportActionBar().setDisplayShowHomeEnabled(true); - } - } - }); - + Helper.loadGiF(getApplicationContext(), url, pp_actionBar); set_profile_name = findViewById(R.id.set_profile_name); set_profile_description = findViewById(R.id.set_profile_description); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java index f59b7ba49..2e1f8a2f3 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java @@ -24,11 +24,8 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; import android.os.AsyncTask; import android.os.Bundle; -import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.widget.SwipeRefreshLayout; @@ -52,14 +49,12 @@ import android.widget.RelativeLayout; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.target.SimpleTarget; -import com.bumptech.glide.request.transition.Transition; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; + import fr.gouv.etalab.mastodon.R; import fr.gouv.etalab.mastodon.asynctasks.RetrieveFeedsAsyncTask; import fr.gouv.etalab.mastodon.client.APIResponse; @@ -190,22 +185,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds if( url.startsWith("/") ){ url = Helper.getLiveInstanceWithProtocol(OwnerStatusActivity.this) + account.getAvatar(); } - Glide.with(OwnerStatusActivity.this) - .asBitmap() - .load(url) - .into(new SimpleTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, Transition transition) { - BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(25, OwnerStatusActivity.this), (int) Helper.convertDpToPixel(25, OwnerStatusActivity.this), true)); - if( pp_actionBar != null){ - pp_actionBar.setImageDrawable(ppDrawable); - } else if( getSupportActionBar() != null){ - - getSupportActionBar().setIcon(ppDrawable); - getSupportActionBar().setDisplayShowHomeEnabled(true); - } - } - }); + Helper.loadGiF(getApplicationContext(), url, pp_actionBar); swipeRefreshLayout = findViewById(R.id.swipeContainer); new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java index a29c109b3..0feef46cb 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java @@ -20,7 +20,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Build; @@ -535,18 +534,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt if( url.startsWith("/") ){ url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar(); } - Glide.with(getApplicationContext()) - .asBitmap() - .load(url) - .into(new SimpleTarget() { - @Override - public void onResourceReady(Bitmap resource, Transition transition) { - BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true)); - if( pp_actionBar != null){ - pp_actionBar.setImageDrawable(ppDrawable); - } - } - }); + Helper.loadGiF(getApplicationContext(), url, pp_actionBar); } final AppBarLayout appBar = findViewById(R.id.appBar); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java index e91f53a97..c617e08ef 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java @@ -18,12 +18,9 @@ package fr.gouv.etalab.mastodon.activities; import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; -import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.ActionBar; @@ -39,10 +36,6 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.target.SimpleTarget; -import com.bumptech.glide.request.transition.Transition; - import java.util.ArrayList; import java.util.List; @@ -198,23 +191,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve if( url.startsWith("/") ){ url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar(); } - Glide.with(getApplicationContext()) - .asBitmap() - .load(url) - .into(new SimpleTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, Transition transition) { - BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true)); - if( pp_actionBar != null){ - pp_actionBar.setImageDrawable(ppDrawable); - } else if( getSupportActionBar() != null){ - - getSupportActionBar().setIcon(ppDrawable); - getSupportActionBar().setDisplayShowHomeEnabled(true); - } - } - }); - + Helper.loadGiF(getApplicationContext(), url, pp_actionBar); isRefreshed = false; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index 5060544d3..359e84a8e 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -17,32 +17,30 @@ package fr.gouv.etalab.mastodon.activities; import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; -import android.content.ContentResolver; -import android.content.pm.PackageManager; -import android.graphics.BitmapFactory; -import android.os.Environment; -import android.os.Parcelable; -import android.provider.MediaStore; -import android.support.annotation.NonNull; -import android.support.annotation.RequiresApi; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; -import android.net.Uri; -import android.support.v4.content.FileProvider; -import android.support.v7.app.AlertDialog; import android.content.ActivityNotFoundException; +import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; +import android.graphics.BitmapFactory; +import android.net.Uri; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; +import android.os.Environment; +import android.provider.MediaStore; import android.speech.RecognizerIntent; +import android.support.annotation.NonNull; +import android.support.annotation.RequiresApi; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.support.v4.content.FileProvider; import android.support.v7.app.ActionBar; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.text.Editable; import android.text.Html; @@ -84,7 +82,6 @@ import com.github.stom79.mytransl.client.HttpsConnectionException; import com.github.stom79.mytransl.translate.Translate; import com.vanniktech.emoji.EmojiPopup; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -102,6 +99,8 @@ import java.util.Locale; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; + +import fr.gouv.etalab.mastodon.R; import fr.gouv.etalab.mastodon.asynctasks.PostStatusAsyncTask; import fr.gouv.etalab.mastodon.asynctasks.RetrieveAccountsForReplyAsyncTask; import fr.gouv.etalab.mastodon.asynctasks.RetrieveEmojiAsyncTask; @@ -117,30 +116,29 @@ import fr.gouv.etalab.mastodon.client.Entities.Mention; import fr.gouv.etalab.mastodon.client.Entities.Results; import fr.gouv.etalab.mastodon.client.Entities.Status; import fr.gouv.etalab.mastodon.client.Entities.StoredStatus; +import fr.gouv.etalab.mastodon.client.Entities.Version; import fr.gouv.etalab.mastodon.client.Glide.GlideApp; import fr.gouv.etalab.mastodon.client.HttpsConnection; -import fr.gouv.etalab.mastodon.drawers.CustomEmojiAdapter; -import fr.gouv.etalab.mastodon.drawers.EmojisSearchAdapter; -import fr.gouv.etalab.mastodon.helper.MastalabAutoCompleteTextView; -import fr.gouv.etalab.mastodon.interfaces.OnDownloadInterface; -import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface; -import fr.gouv.etalab.mastodon.sqlite.CustomEmojiDAO; -import fr.gouv.etalab.mastodon.client.Entities.Version; import fr.gouv.etalab.mastodon.drawers.AccountsReplyAdapter; import fr.gouv.etalab.mastodon.drawers.AccountsSearchAdapter; +import fr.gouv.etalab.mastodon.drawers.CustomEmojiAdapter; import fr.gouv.etalab.mastodon.drawers.DraftsListAdapter; +import fr.gouv.etalab.mastodon.drawers.EmojisSearchAdapter; import fr.gouv.etalab.mastodon.drawers.TagsSearchAdapter; import fr.gouv.etalab.mastodon.helper.Helper; +import fr.gouv.etalab.mastodon.helper.MastalabAutoCompleteTextView; +import fr.gouv.etalab.mastodon.interfaces.OnDownloadInterface; import fr.gouv.etalab.mastodon.interfaces.OnPostStatusActionInterface; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountsReplyInterface; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAttachmentInterface; +import fr.gouv.etalab.mastodon.interfaces.OnRetrieveEmojiInterface; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearcAccountshInterface; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveSearchInterface; import fr.gouv.etalab.mastodon.jobs.ScheduledTootsSyncJob; import fr.gouv.etalab.mastodon.sqlite.AccountDAO; +import fr.gouv.etalab.mastodon.sqlite.CustomEmojiDAO; import fr.gouv.etalab.mastodon.sqlite.Sqlite; import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO; -import fr.gouv.etalab.mastodon.R; import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION; @@ -404,22 +402,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount if( url.startsWith("/") ){ url = Helper.getLiveInstanceWithProtocol(getApplicationContext()) + account.getAvatar(); } - Glide.with(getApplicationContext()) - .asBitmap() - .load(url) - .into(new SimpleTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, Transition transition) { - BitmapDrawable ppDrawable = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(resource, (int) Helper.convertDpToPixel(25, getApplicationContext()), (int) Helper.convertDpToPixel(25, getApplicationContext()), true)); - if( pp_actionBar != null){ - pp_actionBar.setImageDrawable(ppDrawable); - } else if( getSupportActionBar() != null){ - - getSupportActionBar().setIcon(ppDrawable); - getSupportActionBar().setDisplayShowHomeEnabled(true); - } - } - }); + Helper.loadGiF(getApplicationContext(), url, pp_actionBar); if( sharedContent != null ){ //Shared content diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index 4e6d14d4e..4b49819de 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -1275,17 +1275,7 @@ public class Helper { if( url.startsWith("/") ){ url = Helper.getLiveInstanceWithProtocol(activity) + url; } - - Glide.with(activity.getApplicationContext()) - .asBitmap() - .load(url) - .into(new SimpleTarget() { - @Override - public void onResourceReady(@NonNull Bitmap resource, Transition transition) { - Resources res = activity.getResources(); - imageView.setImageBitmap(resource); - } - }); + loadGiF(activity,url, imageView); } @@ -1494,9 +1484,7 @@ public class Helper { if( url.startsWith("/") ){ url = Helper.getLiveInstanceWithProtocol(activity) + account.getAvatar(); } - Glide.with(activity.getApplicationContext()) - .load(url) - .into(profilePicture); + loadGiF(activity, url, profilePicture); String urlHeader = account.getHeader(); if( urlHeader.startsWith("/") ){ urlHeader = Helper.getLiveInstanceWithProtocol(activity) + account.getHeader();