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 'com.github.stom79:Android-WYSIWYG-Editor:3.2.1'
implementation 'com.github.duanhong169:colorpicker:1.1.6'
implementation 'com.github.penfeizhou.android.animation:gif:1.0.0'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.0.1'
implementation 'com.github.penfeizhou.android.animation:apng:1.0.1'
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.load.DataSource;
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.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
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.URISyntaxException;
import java.util.ArrayList;
@ -1089,11 +1094,11 @@ public class Status implements Parcelable{
final int[] i = {0};
for (final Emojis emoji : emojis) {
Glide.with(context)
.asDrawable()
.asFile()
.load(emoji.getUrl())
.listener(new RequestListener<Drawable>() {
.listener(new RequestListener<File>() {
@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;
}
@ -1106,10 +1111,10 @@ public class Status implements Parcelable{
return false;
}
})
.into(new SimpleTarget<Drawable>() {
.into(new SimpleTarget<File>() {
@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() + ":";
if (contentSpan != null && contentSpan.toString().contains(targetedEmoji)) {
//emojis can be used several times so we have to loop
@ -1190,12 +1195,6 @@ public class Status implements Parcelable{
listener.onRetrieveEmoji(status, false);
}
}
});
}

View File

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