diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-02 21:32:56 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-02 21:32:56 +0100 |
commit | 64826a6fd9a8f013fe78fb12e6fc366adce7e122 (patch) | |
tree | f91ae47a6cba98020da26b9cc88b1b90d21915a8 /src/main/java/de/pixart/messenger/ui/adapter | |
parent | 68d7b433d8ddaa8b684f3c7eb870a6acdbecf70a (diff) |
show audio artist and title for audio files
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 4228cd6cc..90582815e 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -865,7 +865,7 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie } private void displayAudioMessage(ViewHolder viewHolder, Message message, boolean darkBackground) { - toggleWhisperInfo(viewHolder, message, false, darkBackground); + toggleWhisperInfo(viewHolder, message, showTitle(message), darkBackground); viewHolder.image.setVisibility(View.GONE); viewHolder.gifImage.setVisibility(View.GONE); viewHolder.richlinkview.setVisibility(View.GONE); @@ -877,6 +877,31 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie this.audioPlayer.init(audioPlayer, message); } + private boolean showTitle(Message message) { + boolean show = false; + if (message.getFileParams().subject.length() != 0) { + try { + byte[] data = Base64.decode(message.getFileParams().subject, Base64.DEFAULT); + show = (new String(data, "UTF-8").length() != 0); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + return show; + } + + private String getTitle(Message message) { + if (message.getFileParams().subject.length() != 0) { + try { + byte[] data = Base64.decode(message.getFileParams().subject, Base64.DEFAULT); + return new String(data, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + return ""; + } + private void displayImageMessage(ViewHolder viewHolder, final Message message, final boolean darkBackground) { toggleWhisperInfo(viewHolder, message, false, darkBackground); viewHolder.download_button.setVisibility(View.GONE); @@ -945,6 +970,12 @@ public class MessageAdapter extends ArrayAdapter<Message> implements CopyTextVie private void toggleWhisperInfo(ViewHolder viewHolder, final Message message, final boolean includeBody, final boolean darkBackground) { SpannableStringBuilder messageBody = new SpannableStringBuilder(replaceYoutube(activity.getApplicationContext(), message.getBody())); + + final String mimeType = message.getMimeType(); + if (mimeType != null && message.getMimeType().contains("audio")) { + messageBody.clear(); + messageBody.append(getTitle(message)); + } Editable body; if (darkBackground) { viewHolder.messageBody.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Body1_OnDark); |