Fix emoji

This commit is contained in:
tom79 2019-08-02 15:25:54 +02:00
parent 0f87d71ba7
commit 6fa4d2f9ae
3 changed files with 71 additions and 71 deletions

View File

@ -120,8 +120,7 @@ dependencies {
implementation "ch.acra:acra-notification:$acraVersion" implementation "ch.acra:acra-notification:$acraVersion"
implementation 'com.github.stom79:Android-WYSIWYG-Editor:3.2.1' implementation 'com.github.stom79:Android-WYSIWYG-Editor:3.2.1'
implementation 'com.github.duanhong169:colorpicker:1.1.6' implementation 'com.github.duanhong169:colorpicker:1.1.6'
implementation 'com.github.penfeizhou.android.animation:gif:1.0.0' implementation 'com.github.penfeizhou.android.animation:apng:1.0.1'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.0.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0' implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
} }

View File

@ -46,10 +46,15 @@ import android.view.View;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.load.model.FileLoader;
import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.SimpleTarget; import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target; import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition; import com.bumptech.glide.request.transition.Transition;
import com.github.penfeizhou.animation.apng.APNGDrawable;
import com.github.penfeizhou.animation.loader.AssetStreamLoader;
import java.io.File;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.ArrayList; import java.util.ArrayList;
@ -1089,11 +1094,11 @@ public class Status implements Parcelable{
final int[] i = {0}; final int[] i = {0};
for (final Emojis emoji : emojis) { for (final Emojis emoji : emojis) {
Glide.with(context) Glide.with(context)
.asDrawable() .asFile()
.load(emoji.getUrl()) .load(emoji.getUrl())
.listener(new RequestListener<Drawable>() { .listener(new RequestListener<File>() {
@Override @Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { public boolean onResourceReady(File resource, Object model, Target<File> target, DataSource dataSource, boolean isFirstResource) {
return false; return false;
} }
@ -1106,10 +1111,10 @@ public class Status implements Parcelable{
return false; return false;
} }
}) })
.into(new SimpleTarget<Drawable>() { .into(new SimpleTarget<File>() {
@Override @Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { public void onResourceReady(@NonNull File resourceFile, @Nullable Transition<? super File> transition) {
Drawable resource = APNGDrawable.fromFile(resourceFile.getAbsolutePath());
final String targetedEmoji = ":" + emoji.getShortcode() + ":"; final String targetedEmoji = ":" + emoji.getShortcode() + ":";
if (contentSpan != null && contentSpan.toString().contains(targetedEmoji)) { if (contentSpan != null && contentSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop //emojis can be used several times so we have to loop
@ -1190,12 +1195,6 @@ public class Status implements Parcelable{
listener.onRetrieveEmoji(status, false); listener.onRetrieveEmoji(status, false);
} }
} }
}); });
} }

View File

@ -64,7 +64,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.browser.customtabs.CustomTabsIntent; import androidx.browser.customtabs.CustomTabsIntent;
import com.github.penfeizhou.animation.glide.AnimationDecoderOption;
import com.google.android.material.navigation.NavigationView; import com.google.android.material.navigation.NavigationView;
import androidx.exifinterface.media.ExifInterface; import androidx.exifinterface.media.ExifInterface;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
@ -3121,62 +3120,65 @@ public class Helper {
public static void loadGiF(final Context context, String url, final ImageView imageView){ public static void loadGiF(final Context context, String url, final ImageView imageView){
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false); boolean disableGif = sharedpreferences.getBoolean(SET_DISABLE_GIF, false);
Glide.with(imageView.getContext()) if( disableGif){
.asDrawable() try {
.load(url) Glide.with(imageView.getContext())
.thumbnail(0.1f) .asBitmap()
.set(AnimationDecoderOption.DISABLE_ANIMATION_GIF_DECODER, true) .load(url)
//.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10))) .thumbnail(0.1f)
.listener(new RequestListener<Drawable>() { .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
@Override .into(imageView);
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { }catch (Exception e){
return false; if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
} Glide.with(imageView.getContext())
@Override .asDrawable()
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { .load(R.drawable.missing)
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
Glide.with(imageView.getContext()) .into(imageView);
.asDrawable() }else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
.load(R.drawable.missing) Glide.with(imageView.getContext())
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10))) .asDrawable()
.into(imageView); .load(R.drawable.missing_peertube)
}else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){ .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
Glide.with(imageView.getContext()) .into(imageView);
.asDrawable() }else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA){
.load(R.drawable.missing_peertube) Glide.with(imageView.getContext())
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10))) .asDrawable()
.into(imageView); .load(R.drawable.gnu_default_avatar)
}else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA){ .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
Glide.with(imageView.getContext()) .into(imageView);
.asDrawable() }
.load(R.drawable.gnu_default_avatar) }
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10))) }else{
.into(imageView); try {
} Glide.with(imageView.getContext())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { .load(url)
imageView.setClipToOutline(true); .thumbnail(0.1f)
} .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
imageView.setBackgroundResource(R.drawable.rounded_corner_10); .into(imageView);
return false; }catch (Exception e){
} if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || BaseMainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
}) Glide.with(imageView.getContext())
.into(new SimpleTarget<Drawable>() { .asDrawable()
@Override .load(R.drawable.missing)
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
if( !disableGif) { .into(imageView);
resource.setVisible(true, true); }else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE){
imageView.setImageDrawable(resource); Glide.with(imageView.getContext())
}else{ .asDrawable()
resource.setVisible(true, true); .load(R.drawable.missing_peertube)
Bitmap bitmap = drawableToBitmap(resource.getCurrent()); .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
imageView.setImageBitmap(bitmap); .into(imageView);
} }else if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Glide.with(imageView.getContext())
imageView.setClipToOutline(true); .asDrawable()
} .load(R.drawable.gnu_default_avatar)
imageView.setBackgroundResource(R.drawable.rounded_corner_10); .apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
} .into(imageView);
}); }
}
}
} }