mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 15:13:30 +00:00
Added new media icons for audio/video
Added icons new icons, deleted an old one. Using new icons in AudioSlide/VideoSlide. Closes #2304
This commit is contained in:
committed by
Jake McGinty
parent
a4bd9fae9a
commit
79dbf2746f
@@ -83,7 +83,7 @@ public class AttachmentManager {
|
||||
|
||||
@Override
|
||||
protected Drawable doInBackground(Void... params) {
|
||||
return slide.getThumbnail(thumbnailWidth, thumbnailHeight);
|
||||
return slide.getThumbnail(context, thumbnailWidth, thumbnailHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.SmilUtil;
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||
import org.w3c.dom.smil.SMILDocument;
|
||||
import org.w3c.dom.smil.SMILMediaElement;
|
||||
import org.w3c.dom.smil.SMILRegionElement;
|
||||
@@ -28,6 +29,7 @@ import org.w3c.dom.smil.SMILRegionMediaElement;
|
||||
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
@@ -64,8 +66,8 @@ public class AudioSlide extends Slide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getThumbnail(int maxWidth, int maxHeight) {
|
||||
return context.getResources().getDrawable(R.drawable.ic_menu_add_sound);
|
||||
public Drawable getThumbnail(Context context, int maxWidth, int maxHeight) {
|
||||
return ThemeUtil.resolveIcon(context, R.attr.conversation_icon_attach_audio);
|
||||
}
|
||||
|
||||
public static PduPart constructPartFromUri(Context context, Uri uri) throws IOException, MediaTooLargeException {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ImageSlide extends Slide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getThumbnail(int maxWidth, int maxHeight) {
|
||||
public Drawable getThumbnail(Context context, int maxWidth, int maxHeight) {
|
||||
Drawable thumbnail = getCachedThumbnail();
|
||||
|
||||
if (thumbnail != null) {
|
||||
@@ -111,12 +111,12 @@ public class ImageSlide extends Slide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThumbnailOn(ImageView imageView) {
|
||||
setThumbnailOn(imageView, imageView.getWidth(), imageView.getHeight(), new ColorDrawable(Color.TRANSPARENT));
|
||||
public void setThumbnailOn(Context context, ImageView imageView) {
|
||||
setThumbnailOn(context, imageView, imageView.getWidth(), imageView.getHeight(), new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThumbnailOn(ImageView imageView, final int width, final int height, final Drawable placeholder) {
|
||||
public void setThumbnailOn(Context context, ImageView imageView, final int width, final int height, final Drawable placeholder) {
|
||||
Drawable thumbnail = getCachedThumbnail();
|
||||
|
||||
if (thumbnail != null) {
|
||||
@@ -125,6 +125,7 @@ public class ImageSlide extends Slide {
|
||||
return;
|
||||
}
|
||||
|
||||
final WeakReference<Context> weakContext = new WeakReference<>(context);
|
||||
final WeakReference<ImageView> weakImageView = new WeakReference<>(imageView);
|
||||
final Handler handler = new Handler();
|
||||
|
||||
@@ -136,7 +137,13 @@ public class ImageSlide extends Slide {
|
||||
MmsDatabase.slideResolver.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Drawable bitmap = getThumbnail(width, height);
|
||||
final Context context = weakContext.get();
|
||||
if (context == null) {
|
||||
Log.w(TAG, "context SoftReference was null, leaving");
|
||||
return;
|
||||
}
|
||||
|
||||
final Drawable bitmap = getThumbnail(context, width, height);
|
||||
final ImageView destination = weakImageView.get();
|
||||
|
||||
Log.w(TAG, "slide resolved, destination available? " + (destination == null));
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
@@ -70,16 +71,16 @@ public abstract class Slide {
|
||||
return part.getDataUri();
|
||||
}
|
||||
|
||||
public Drawable getThumbnail(int maxWidth, int maxHeight) {
|
||||
public Drawable getThumbnail(Context context, int maxWidth, int maxHeight) {
|
||||
throw new AssertionError("getThumbnail() called on non-thumbnail producing slide!");
|
||||
}
|
||||
|
||||
public void setThumbnailOn(ImageView imageView) {
|
||||
imageView.setImageDrawable(getThumbnail(imageView.getWidth(), imageView.getHeight()));
|
||||
public void setThumbnailOn(Context context, ImageView imageView) {
|
||||
imageView.setImageDrawable(getThumbnail(context, imageView.getWidth(), imageView.getHeight()));
|
||||
}
|
||||
|
||||
public void setThumbnailOn(ImageView imageView, int height, int width, Drawable placeholder) {
|
||||
imageView.setImageDrawable(getThumbnail(width, height));
|
||||
public void setThumbnailOn(Context context, ImageView imageView, int height, int width, Drawable placeholder) {
|
||||
imageView.setImageDrawable(getThumbnail(context, width, height));
|
||||
}
|
||||
|
||||
public Bitmap getGeneratedThumbnail() { return null; }
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.IOException;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.util.SmilUtil;
|
||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
||||
import org.w3c.dom.smil.SMILDocument;
|
||||
import org.w3c.dom.smil.SMILMediaElement;
|
||||
import org.w3c.dom.smil.SMILRegionElement;
|
||||
@@ -28,6 +29,7 @@ import org.w3c.dom.smil.SMILRegionElement;
|
||||
import ws.com.google.android.mms.pdu.PduPart;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
@@ -45,8 +47,8 @@ public class VideoSlide extends Slide {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getThumbnail(int width, int height) {
|
||||
return context.getResources().getDrawable(R.drawable.ic_launcher_video_player);
|
||||
public Drawable getThumbnail(Context context, int width, int height) {
|
||||
return ThemeUtil.resolveIcon(context, R.attr.conversation_icon_attach_video);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user