Play gifs inside chat also disables animated avatar and animated status images

(cherry picked from commit 03eb51ad46)
This commit is contained in:
12aw 2024-03-20 21:52:21 +01:00
parent 9f1f1348e8
commit 49ec864c54
4 changed files with 81 additions and 34 deletions

View file

@ -756,8 +756,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
if (containsLink(statusMessages.get(i))) { if (containsLink(statusMessages.get(i))) {
List<String> url = extractUrls(statusMessages.get(i)); List<String> url = extractUrls(statusMessages.get(i));
for (int j = 0; j < url.size(); j++) { for (int j = 0; j < url.size(); j++) {
if (this != null) { if (this != null && xmppConnectionService.getBooleanPreference("play_gif_inside", R.bool.play_gif_inside)) {
Glide.with(this).load(url.get(j)).into(binding.statusImage); Glide.with(this).load(url.get(j)).into(binding.statusImage);
} else {
Picasso.get().load(url.get(j)).into(binding.statusImage);
} }
binding.statusImage.setOnClickListener(new View.OnClickListener() { binding.statusImage.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
@ -787,8 +789,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
if (containsLink(statusMessages.get(i))) { if (containsLink(statusMessages.get(i))) {
List<String> url = extractUrls(statusMessages.get(i)); List<String> url = extractUrls(statusMessages.get(i));
for (int j = 0; j < url.size(); j++) { for (int j = 0; j < url.size(); j++) {
if (this != null) { if (this != null && xmppConnectionService.getBooleanPreference("play_gif_inside", R.bool.play_gif_inside)) {
Glide.with(this).load(url.get(j)).into(binding.statusImage); Glide.with(this).load(url.get(j)).into(binding.statusImage);
} else {
Picasso.get().load(url.get(j)).into(binding.statusImage);
} }
binding.statusImage.setOnClickListener(new View.OnClickListener() { binding.statusImage.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {

View file

@ -1290,6 +1290,8 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference
xmppConnectionService.reinitializeMuclumbusService(); xmppConnectionService.reinitializeMuclumbusService();
} else if (name.equals("enforce_dane")) { } else if (name.equals("enforce_dane")) {
reconnectAccounts(); reconnectAccounts();
} else if (name.equals("play_gif_inside")) {
reconnectAccounts();
} else if (name.equals("show_less_avatars")) { } else if (name.equals("show_less_avatars")) {
refreshUiReal(); refreshUiReal();
} else if (name.equals("show_record_voice_btn")) { } else if (name.equals("show_record_voice_btn")) {

View file

@ -1616,7 +1616,7 @@ public abstract class XmppActivity extends ActionBarActivity {
} }
}); });
imageDataThread.start(); imageDataThread.start();
if (activity != null) { if (activity != null && getBooleanPreference("play_gif_inside", R.bool.play_gif_inside)) {
Glide.with(activity).load(imageUrl).into(statusimage); Glide.with(activity).load(imageUrl).into(statusimage);
} }
} }

View file

@ -100,42 +100,83 @@ public class AvatarWorkerTask extends AsyncTask<AvatarService.Avatarable, Void,
if (activity == null) { if (activity == null) {
return; return;
} }
final Drawable bm = activity.avatarService().get(avatarable, (int) activity.getResources().getDimension(size), true); if (activity.xmppConnectionService.getBooleanPreference("play_gif_inside", R.bool.play_gif_inside)) {
setContentDescription(avatarable, imageView); final Drawable bm = activity.avatarService().get(avatarable, (int) activity.getResources().getDimension(size), true);
if (bm != null && JidFromJabberNetwork == null) { setContentDescription(avatarable, imageView);
cancelPotentialWork(avatarable, imageView); if (bm != null && JidFromJabberNetwork == null) {
if (overlay) { cancelPotentialWork(avatarable, imageView);
activity.xmppConnectionService.fileBackend.drawOverlay(bm, R.drawable.pencil_overlay, 0.35f, true); if (overlay) {
imageView.setImageDrawable(bm); activity.xmppConnectionService.fileBackend.drawOverlay(bm, R.drawable.pencil_overlay, 0.35f, true);
imageView.setImageDrawable(bm);
} else {
imageView.setImageDrawable(bm);
}
imageView.setBackgroundColor(0x00000000);
} else if (JidFromJabberNetwork != null) {
try {
new GetAvatarFromJabberNetwork(activity.xmppConnectionService, avatarable, imageView, size, overlay).execute(Config.CHANNEL_DISCOVERY + "/avatar/v1/" + JidFromJabberNetwork);
} catch (Exception e) {
e.printStackTrace();
loadAvatar(avatarable, imageView, size, overlay, null);
}
if (Build.VERSION.SDK_INT >= 28 && bm instanceof AnimatedImageDrawable) {
((AnimatedImageDrawable) bm).start();
}
} else { } else {
imageView.setImageDrawable(bm); imageView.setBackgroundColor(avatarable.getAvatarBackgroundColor());
} imageView.setImageDrawable(null);
imageView.setBackgroundColor(0x00000000); final AvatarWorkerTask task = new AvatarWorkerTask(imageView, size);
} else if (JidFromJabberNetwork != null) { final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
try { if (overlay) {
new GetAvatarFromJabberNetwork(activity.xmppConnectionService, avatarable, imageView, size, overlay).execute(Config.CHANNEL_DISCOVERY + "/avatar/v1/" + JidFromJabberNetwork); activity.xmppConnectionService.fileBackend.drawOverlayFromDrawable(asyncDrawable, R.drawable.pencil_overlay, 1.0f);
} catch (Exception e) { imageView.setImageDrawable(asyncDrawable);
e.printStackTrace(); } else {
loadAvatar(avatarable, imageView, size, overlay, null); imageView.setImageDrawable(asyncDrawable);
}
if (Build.VERSION.SDK_INT >= 28 && bm instanceof AnimatedImageDrawable) { }
((AnimatedImageDrawable) bm).start(); try {
task.execute(avatarable);
} catch (final RejectedExecutionException ignored) {
}
} }
} else { } else {
imageView.setBackgroundColor(avatarable.getAvatarBackgroundColor()); final Drawable bm = activity.avatarService().get(avatarable, (int) activity.getResources().getDimension(size), false);
imageView.setImageDrawable(null); setContentDescription(avatarable, imageView);
final AvatarWorkerTask task = new AvatarWorkerTask(imageView, size); if (bm != null && JidFromJabberNetwork == null) {
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task); cancelPotentialWork(avatarable, imageView);
if (overlay) { if (overlay) {
activity.xmppConnectionService.fileBackend.drawOverlayFromDrawable(asyncDrawable, R.drawable.pencil_overlay, 1.0f); activity.xmppConnectionService.fileBackend.drawOverlay(bm, R.drawable.pencil_overlay, 0.35f, true);
imageView.setImageDrawable(asyncDrawable); imageView.setImageDrawable(bm);
} else {
imageView.setImageDrawable(bm);
}
imageView.setBackgroundColor(0x00000000);
} else if (JidFromJabberNetwork != null) {
try {
new GetAvatarFromJabberNetwork(activity.xmppConnectionService, avatarable, imageView, size, overlay).execute(Config.CHANNEL_DISCOVERY + "/avatar/v1/" + JidFromJabberNetwork);
} catch (Exception e) {
e.printStackTrace();
loadAvatar(avatarable, imageView, size, overlay, null);
}
if (Build.VERSION.SDK_INT >= 28 && bm instanceof AnimatedImageDrawable) {
((AnimatedImageDrawable) bm).start();
}
} else { } else {
imageView.setImageDrawable(asyncDrawable); imageView.setBackgroundColor(avatarable.getAvatarBackgroundColor());
imageView.setImageDrawable(null);
final AvatarWorkerTask task = new AvatarWorkerTask(imageView, size);
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
if (overlay) {
activity.xmppConnectionService.fileBackend.drawOverlayFromDrawable(asyncDrawable, R.drawable.pencil_overlay, 1.0f);
imageView.setImageDrawable(asyncDrawable);
} else {
imageView.setImageDrawable(asyncDrawable);
} }
try { try {
task.execute(avatarable); task.execute(avatarable);
} catch (final RejectedExecutionException ignored) { } catch (final RejectedExecutionException ignored) {
}
} }
} }
} }