-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pin message video audio attachments #79
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<org.thoughtcrime.securesms.components.AudioView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:id="@+id/pinned_audio_view" | ||
android:layout_width="210dp" | ||
android:layout_height="wrap_content" | ||
app:foregroundTintColor="@color/grey_500" | ||
app:backgroundTintColor="@color/white" | ||
android:visibility="gone"/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<org.thoughtcrime.securesms.components.DocumentView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/pinned_document_view" | ||
android:layout_width="210dp" | ||
android:layout_height="wrap_content" | ||
app:documentForegroundTintColor="@color/grey_500" | ||
app:documentBackgroundTintColor="@color/white" | ||
android:visibility="gone" | ||
tools:visibility="visible"/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ | |
import android.widget.RelativeLayout.LayoutParams; | ||
import android.widget.TextView; | ||
|
||
import org.thoughtcrime.securesms.components.AudioView; | ||
import org.thoughtcrime.securesms.components.DocumentView; | ||
import org.thoughtcrime.securesms.components.ThumbnailView; | ||
import org.thoughtcrime.securesms.crypto.MasterSecret; | ||
import org.thoughtcrime.securesms.database.DatabaseFactory; | ||
|
@@ -60,14 +62,18 @@ public PinnedMessageAdapter(Activity mContext, Cursor cursor, MasterSecret maste | |
} | ||
|
||
public static class ViewHolder extends RecyclerView.ViewHolder { | ||
private Stub<AudioView> audioViewStub; | ||
private Stub<DocumentView> documentViewStub; | ||
private Stub<ThumbnailView> mediaThumbnailStub; | ||
public TextView messageContent; | ||
public TextView recipient; | ||
public TextView time; | ||
public View wrapper; | ||
public TextView messageContent; | ||
public TextView recipient; | ||
public TextView time; | ||
public View wrapper; | ||
|
||
public ViewHolder(View v) { | ||
super(v); | ||
this.audioViewStub = new Stub<>(v.findViewById(R.id.pinned_audio_view_stub)); | ||
this.documentViewStub = new Stub<>(v.findViewById(R.id.pinned_document_view_stub)); | ||
this.mediaThumbnailStub = new Stub<>(v.findViewById(R.id.pinned_image_view_stub)); | ||
this.messageContent = v.findViewById(R.id.pinned_message_body); | ||
this.recipient = v.findViewById(R.id.pinned_message_recipient); | ||
|
@@ -84,17 +90,37 @@ public PinnedMessageAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int | |
return new ViewHolder(theInflatedView); | ||
} | ||
|
||
|
||
@Override | ||
public void onBindViewHolder(ViewHolder holder, int position) { | ||
dataCursor.moveToPosition(position); | ||
MmsSmsDatabase.Reader reader = db.readerFor(dataCursor, masterSecret); | ||
MessageRecord record = reader.getCurrent(); | ||
ConversationItem conversationItem = new ConversationItem(context); | ||
MmsSmsDatabase.Reader reader = db.readerFor(dataCursor, masterSecret); | ||
MessageRecord record = reader.getCurrent(); | ||
|
||
this.setMessageView(record, holder); | ||
|
||
if (record.isMms() && ((MmsMessageRecord) record).getSlideDeck().getSlides().size() != 0) { | ||
ConversationItem conversationItem = new ConversationItem(context); | ||
ConversationItem.ThumbnailClickListener thumbnailClickListener = conversationItem.new ThumbnailClickListener(record); | ||
if (isDocument(record)) { | ||
ConversationItem.ThumbnailClickListener thumbnailClickListener | ||
= conversationItem.new ThumbnailClickListener(record); | ||
ConversationItem.AttachmentDownloadClickListener attachmentDownloadClickListener | ||
= conversationItem.new AttachmentDownloadClickListener(); | ||
holder.documentViewStub.get().setDocument(((MediaMmsMessageRecord)record).getSlideDeck().getDocumentSlide(), true); | ||
holder.documentViewStub.get().setDocumentClickListener(thumbnailClickListener); | ||
holder.documentViewStub.get().setDownloadClickListener(attachmentDownloadClickListener); | ||
holder.documentViewStub.get().setVisibility(view.VISIBLE); | ||
} | ||
|
||
if (isAudio(record)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this one also be |
||
ConversationItem.AttachmentDownloadClickListener attachmentDownloadClickListener | ||
= conversationItem.new AttachmentDownloadClickListener(); | ||
holder.audioViewStub.get().setAudio(masterSecret, ((MediaMmsMessageRecord)record).getSlideDeck().getAudioSlide(), true); | ||
holder.audioViewStub.get().setDownloadClickListener(attachmentDownloadClickListener); | ||
holder.audioViewStub.get().setVisibility(view.VISIBLE); | ||
} | ||
|
||
else if (isVideo(record)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this should be on the same line as the closing bracket. https://github.com/signalapp/Signal-Android/search?utf8=%E2%9C%93&q=else+if&type=Code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting |
||
ConversationItem.ThumbnailClickListener thumbnailClickListener | ||
= conversationItem.new ThumbnailClickListener(record); | ||
|
||
holder.mediaThumbnailStub.get().setImageResource(masterSecret, glideRequests, | ||
((MmsMessageRecord) record).getSlideDeck().getThumbnailSlide(), | ||
|
@@ -146,6 +172,18 @@ private void setMessageView(MessageRecord record, ViewHolder viewHolder) { | |
viewHolder.recipient.setText(messageSenderName); | ||
} | ||
|
||
private boolean isAudio(MessageRecord messageRecord) { | ||
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getAudioSlide() != null; | ||
} | ||
|
||
private boolean isVideo(MessageRecord messageRecord) { | ||
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getThumbnailSlide() != null; | ||
} | ||
|
||
private boolean isDocument(MessageRecord messageRecord) { | ||
return messageRecord.isMms() && ((MmsMessageRecord)messageRecord).getSlideDeck().getDocumentSlide() != null; | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return (dataCursor == null) ? 0 : dataCursor.getCount(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this being used anywhere? I can't find it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has slipped