mirror of
				https://github.com/oxen-io/session-android.git
				synced 2025-10-31 07:21:41 +00:00 
			
		
		
		
	WIP: show attachment in conversation preview as iOS
This commit is contained in:
		| @@ -1855,4 +1855,8 @@ | |||||||
|  |  | ||||||
|     <string name="view_reset_secure_session_done_message">Secure session reset done</string> |     <string name="view_reset_secure_session_done_message">Secure session reset done</string> | ||||||
|  |  | ||||||
|  |     <!-- Attachment message --> | ||||||
|  |     <string name="attachment">Attachment</string> | ||||||
|  |     <string name="attachment_type_voice_message">Voice Message</string> | ||||||
|  |  | ||||||
| </resources> | </resources> | ||||||
|   | |||||||
| @@ -618,10 +618,14 @@ public class ThreadDatabase extends Database { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   private @NonNull String getFormattedBodyFor(@NonNull MessageRecord messageRecord) { |   private @NonNull String getFormattedBodyFor(@NonNull MessageRecord messageRecord) { | ||||||
|     if (messageRecord.isMms() && ((MmsMessageRecord) messageRecord).getSharedContacts().size() > 0) { |     if (messageRecord.isMms()) { | ||||||
|  |       MmsMessageRecord record = (MmsMessageRecord) messageRecord; | ||||||
|  |       if (record.getSlideDeck().getBody()) | ||||||
|  |       if (record.getSharedContacts().size() > 0) { | ||||||
|         Contact contact = ((MmsMessageRecord) messageRecord).getSharedContacts().get(0); |         Contact contact = ((MmsMessageRecord) messageRecord).getSharedContacts().get(0); | ||||||
|         return ContactUtil.getStringSummary(context, contact).toString(); |         return ContactUtil.getStringSummary(context, contact).toString(); | ||||||
|       } |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     return messageRecord.getBody(); |     return messageRecord.getBody(); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ import android.net.Uri; | |||||||
| import androidx.annotation.DrawableRes; | import androidx.annotation.DrawableRes; | ||||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||||
| import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||||
|  | import com.google.android.exoplayer2.util.MimeTypes; | ||||||
|  |  | ||||||
| import org.thoughtcrime.securesms.attachments.Attachment; | import org.thoughtcrime.securesms.attachments.Attachment; | ||||||
| import org.thoughtcrime.securesms.attachments.UriAttachment; | import org.thoughtcrime.securesms.attachments.UriAttachment; | ||||||
| @@ -33,6 +34,8 @@ import org.whispersystems.libsignal.util.guava.Optional; | |||||||
|  |  | ||||||
| import java.security.SecureRandom; | import java.security.SecureRandom; | ||||||
|  |  | ||||||
|  | import network.loki.messenger.R; | ||||||
|  |  | ||||||
| public abstract class Slide { | public abstract class Slide { | ||||||
|  |  | ||||||
|   protected final Attachment attachment; |   protected final Attachment attachment; | ||||||
| @@ -59,7 +62,31 @@ public abstract class Slide { | |||||||
|  |  | ||||||
|   @NonNull |   @NonNull | ||||||
|   public Optional<String> getBody() { |   public Optional<String> getBody() { | ||||||
|     return Optional.absent(); |     String attachmentString = context.getString(R.string.attachment); | ||||||
|  |  | ||||||
|  |     if (MimeTypes.isAudio(attachment.getContentType())) { | ||||||
|  |       // a missing filename is the legacy way to determine if an audio attachment is | ||||||
|  |       // a voice note vs. other arbitrary audio attachments. | ||||||
|  |       if (attachment.isVoiceNote() || !attachment.getFileName().isEmpty()) { | ||||||
|  |         attachmentString = context.getString(R.string.attachment_type_voice_message); | ||||||
|  |         return Optional.fromNullable("🎤 " + attachmentString); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |     return Optional.fromNullable(emojiForMimeType(attachment.getContentType()) + attachmentString); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   private String emojiForMimeType(String contentType) { | ||||||
|  |     if (MimeTypes.isVideo(contentType)) { | ||||||
|  |       return "📷 "; | ||||||
|  |     } else if (MimeTypes.isVideo(contentType)) { | ||||||
|  |       return "🎥 "; | ||||||
|  |     } else if (MimeTypes.isAudio(contentType)) { | ||||||
|  |       return "🎧 "; | ||||||
|  |     } else if (MimeTypes.is) { | ||||||
|  |       return "🎡 "; | ||||||
|  |     } else { | ||||||
|  |       return "📎 "; | ||||||
|  |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @NonNull |   @NonNull | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ryan ZHAO
					Ryan ZHAO