mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Fix crash & add documentation
This commit is contained in:
parent
2132e53fb0
commit
ec9df3adb2
@ -53,6 +53,10 @@ import org.thoughtcrime.securesms.util.DateUtils
|
||||
import java.util.*
|
||||
import kotlin.math.*
|
||||
|
||||
// Some things that seemingly belong to the input bar (e.g. the voice message recording UI) are actually
|
||||
// part of the conversation activity layout. This is just because it makes the layout a lot simpler. The
|
||||
// price we pay is a bit of back and forth between the input bar and the conversation activity.
|
||||
|
||||
class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDelegate,
|
||||
InputBarRecordingViewDelegate, ConversationRecyclerViewDelegate {
|
||||
private val scrollButtonFullVisibilityThreshold by lazy { toPx(120.0f, resources) }
|
||||
@ -225,8 +229,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
if (previewState == null) return@observe
|
||||
if (previewState.isLoading) {
|
||||
inputBar.draftLinkPreview()
|
||||
} else {
|
||||
} else if (previewState.linkPreview.isPresent) {
|
||||
inputBar.updateLinkPreviewDraft(glide, previewState.linkPreview.get())
|
||||
} else {
|
||||
inputBar.cancelLinkPreviewDraft()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -8,41 +8,40 @@ import androidx.core.view.isVisible
|
||||
import kotlinx.android.synthetic.main.view_link_preview_draft.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.messaging.sending_receiving.link_preview.LinkPreview
|
||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||
import org.thoughtcrime.securesms.mms.ImageSlide
|
||||
|
||||
class LinkPreviewDraftView : LinearLayout {
|
||||
var delegate: LinkPreviewDraftViewDelegate? = null
|
||||
|
||||
// region Lifecycle
|
||||
constructor(context: Context) : super(context) { initialize() }
|
||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() }
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initialize() }
|
||||
|
||||
private fun initialize() {
|
||||
// Start out with the loader showing and the content view hidden
|
||||
LayoutInflater.from(context).inflate(R.layout.view_link_preview_draft, this)
|
||||
linkPreviewDraftContainer.isVisible = false
|
||||
thumbnailImageView.clipToOutline = true
|
||||
linkPreviewDraftCancelButton.setOnClickListener { cancel() }
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Updating
|
||||
fun update(glide: GlideRequests, linkPreview: LinkPreview) {
|
||||
// Hide the loader and show the content view
|
||||
linkPreviewDraftContainer.isVisible = true
|
||||
linkPreviewDraftLoader.isVisible = false
|
||||
thumbnailImageView.radius = toPx(4, resources)
|
||||
if (linkPreview.getThumbnail().isPresent) {
|
||||
// This internally fetches the thumbnail
|
||||
thumbnailImageView.setImageResource(glide, ImageSlide(context, linkPreview.getThumbnail().get()), false, false)
|
||||
}
|
||||
linkPreviewDraftTitleTextView.text = linkPreview.title
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region Interaction
|
||||
private fun cancel() {
|
||||
delegate?.cancelLinkPreviewDraft()
|
||||
}
|
||||
// endregion
|
||||
}
|
||||
|
||||
interface LinkPreviewDraftViewDelegate {
|
||||
|
@ -14,6 +14,7 @@ import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
|
||||
/** Shown upon sending a message to a user that's blocked. */
|
||||
class BlockedDialog(private val recipient: Recipient) : BaseDialog() {
|
||||
|
||||
override fun setContentView(builder: AlertDialog.Builder) {
|
||||
|
@ -13,6 +13,8 @@ import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||
|
||||
/** Shown when receiving media from a contact for the first time, to confirm that
|
||||
* they are to be trusted and files sent by them are to be downloaded. */
|
||||
class DownloadDialog(private val recipient: Recipient) : BaseDialog() {
|
||||
|
||||
override fun setContentView(builder: AlertDialog.Builder) {
|
||||
|
@ -11,6 +11,7 @@ import network.loki.messenger.R
|
||||
import org.session.libsession.messaging.open_groups.OpenGroupV2
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
||||
|
||||
/** Shown upon tapping an open group invitation. */
|
||||
class JoinOpenGroupDialog(private val openGroup: OpenGroupV2) : BaseDialog() {
|
||||
|
||||
override fun setContentView(builder: AlertDialog.Builder) {
|
||||
|
@ -6,6 +6,8 @@ import kotlinx.android.synthetic.main.dialog_link_preview.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
||||
|
||||
/** Shown the first time the user inputs a URL that could generate a link preview, to
|
||||
* let them know that Session offers the ability to send and receive link previews. */
|
||||
class LinkPreviewDialog() : BaseDialog() {
|
||||
|
||||
override fun setContentView(builder: AlertDialog.Builder) {
|
||||
|
@ -10,6 +10,7 @@ import kotlinx.android.synthetic.main.dialog_open_url.view.*
|
||||
import network.loki.messenger.R
|
||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
||||
|
||||
/** Shown upon tapping a URL. */
|
||||
class OpenURLDialog(private val url: String) : BaseDialog() {
|
||||
|
||||
override fun setContentView(builder: AlertDialog.Builder) {
|
||||
|
@ -96,6 +96,9 @@ class InputBar : RelativeLayout, InputBarEditTextDelegate, QuoteViewDelegate, Li
|
||||
delegate?.showVoiceMessageUI()
|
||||
}
|
||||
|
||||
// Drafting quotes and drafting link previews is mutually exclusive, i.e. you can't draft
|
||||
// a quote and a link preview at the same time.
|
||||
|
||||
fun draftQuote(message: MessageRecord) {
|
||||
linkPreviewDraftView = null
|
||||
inputBarAdditionalContentContainer.removeAllViews()
|
||||
|
@ -34,6 +34,7 @@ class LinkPreviewView : LinearLayout {
|
||||
// Thumbnail
|
||||
val linkPreview = message.linkPreviews.first()
|
||||
if (linkPreview.getThumbnail().isPresent) {
|
||||
// This internally fetches the thumbnail
|
||||
thumbnailImageView.setImageResource(glide, ImageSlide(context, linkPreview.getThumbnail().get()), false, false)
|
||||
}
|
||||
// Title
|
||||
|
@ -70,7 +70,7 @@ public class ThumbnailView extends FrameLayout {
|
||||
private SlidesClickedListener downloadClickListener = null;
|
||||
private Slide slide = null;
|
||||
|
||||
private int radius;
|
||||
public int radius;
|
||||
|
||||
public ThumbnailView(Context context) {
|
||||
this(context, null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user