kopia lustrzana https://github.com/ryukoposting/Signal-Android
Show user a toast when an unexpected send text story fails.
rodzic
26a84c5546
commit
95a46f1ce5
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.core.widget.doAfterTextChanged
|
import androidx.core.widget.doAfterTextChanged
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -151,6 +152,10 @@ class TextStoryPostSendFragment : Fragment(R.layout.stories_send_text_post_fragm
|
||||||
TextStoryPostSendState.INIT -> shareConfirmButton.isEnabled = selection.isNotEmpty()
|
TextStoryPostSendState.INIT -> shareConfirmButton.isEnabled = selection.isNotEmpty()
|
||||||
TextStoryPostSendState.SENDING -> shareConfirmButton.isEnabled = false
|
TextStoryPostSendState.SENDING -> shareConfirmButton.isEnabled = false
|
||||||
TextStoryPostSendState.SENT -> requireActivity().finish()
|
TextStoryPostSendState.SENT -> requireActivity().finish()
|
||||||
|
else -> {
|
||||||
|
Toast.makeText(requireContext(), R.string.TextStoryPostSendFragment__an_unexpected_error_occurred_try_again, Toast.LENGTH_SHORT).show()
|
||||||
|
viewModel.onSendCancelled()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.mediasend.v2.text.send
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
import org.signal.core.util.ThreadUtil
|
import org.signal.core.util.ThreadUtil
|
||||||
|
import org.signal.core.util.logging.Log
|
||||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||||
|
@ -17,6 +18,8 @@ import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.stories.Stories
|
import org.thoughtcrime.securesms.stories.Stories
|
||||||
import org.thoughtcrime.securesms.util.Base64
|
import org.thoughtcrime.securesms.util.Base64
|
||||||
|
|
||||||
|
private val TAG = Log.tag(TextStoryPostSendRepository::class.java)
|
||||||
|
|
||||||
class TextStoryPostSendRepository {
|
class TextStoryPostSendRepository {
|
||||||
|
|
||||||
fun send(contactSearchKey: Set<ContactSearchKey>, textStoryPostCreationState: TextStoryPostCreationState, linkPreview: LinkPreview?): Single<TextStoryPostSendResult> {
|
fun send(contactSearchKey: Set<ContactSearchKey>, textStoryPostCreationState: TextStoryPostCreationState, linkPreview: LinkPreview?): Single<TextStoryPostSendResult> {
|
||||||
|
@ -27,6 +30,7 @@ class TextStoryPostSendRepository {
|
||||||
if (it is UntrustedRecords.UntrustedRecordsException) {
|
if (it is UntrustedRecords.UntrustedRecordsException) {
|
||||||
TextStoryPostSendResult.UntrustedRecordsError(it.untrustedRecords)
|
TextStoryPostSendResult.UntrustedRecordsError(it.untrustedRecords)
|
||||||
} else {
|
} else {
|
||||||
|
Log.w(TAG, "Unexpected error occurred", it)
|
||||||
TextStoryPostSendResult.Failure
|
TextStoryPostSendResult.Failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@ package org.thoughtcrime.securesms.mediasend.v2.text.send
|
||||||
enum class TextStoryPostSendState {
|
enum class TextStoryPostSendState {
|
||||||
INIT,
|
INIT,
|
||||||
SENDING,
|
SENDING,
|
||||||
SENT
|
SENT,
|
||||||
|
FAILED
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,15 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||||
import io.reactivex.rxjava3.kotlin.subscribeBy
|
import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||||
import io.reactivex.rxjava3.subjects.PublishSubject
|
import io.reactivex.rxjava3.subjects.PublishSubject
|
||||||
|
import org.signal.core.util.logging.Log
|
||||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||||
import org.thoughtcrime.securesms.database.model.IdentityRecord
|
import org.thoughtcrime.securesms.database.model.IdentityRecord
|
||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview
|
import org.thoughtcrime.securesms.linkpreview.LinkPreview
|
||||||
import org.thoughtcrime.securesms.mediasend.v2.text.TextStoryPostCreationState
|
import org.thoughtcrime.securesms.mediasend.v2.text.TextStoryPostCreationState
|
||||||
import org.thoughtcrime.securesms.util.livedata.Store
|
import org.thoughtcrime.securesms.util.livedata.Store
|
||||||
|
|
||||||
|
private val TAG = Log.tag(TextStoryPostSendViewModel::class.java)
|
||||||
|
|
||||||
class TextStoryPostSendViewModel(private val repository: TextStoryPostSendRepository) : ViewModel() {
|
class TextStoryPostSendViewModel(private val repository: TextStoryPostSendRepository) : ViewModel() {
|
||||||
|
|
||||||
private val store = Store(TextStoryPostSendState.INIT)
|
private val store = Store(TextStoryPostSendState.INIT)
|
||||||
|
@ -54,11 +57,14 @@ class TextStoryPostSendViewModel(private val repository: TextStoryPostSendReposi
|
||||||
untrustedIdentitySubject.onNext(it.untrustedRecords)
|
untrustedIdentitySubject.onNext(it.untrustedRecords)
|
||||||
store.update { TextStoryPostSendState.INIT }
|
store.update { TextStoryPostSendState.INIT }
|
||||||
}
|
}
|
||||||
|
is TextStoryPostSendResult.Failure -> {
|
||||||
|
store.update { TextStoryPostSendState.FAILED }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError = {
|
onError = {
|
||||||
// TODO [stories] -- Error of some sort.
|
Log.w(TAG, "Unexpected error occurred", it)
|
||||||
store.update { TextStoryPostSendState.INIT }
|
store.update { TextStoryPostSendState.FAILED }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4682,6 +4682,8 @@
|
||||||
<string name="TextStoryPostLinkEntryFragment__share_a_link_with_viewers_of_your_story">Share a link with viewers of your story</string>
|
<string name="TextStoryPostLinkEntryFragment__share_a_link_with_viewers_of_your_story">Share a link with viewers of your story</string>
|
||||||
<!-- Hint text for searching for a story text post recipient. -->
|
<!-- Hint text for searching for a story text post recipient. -->
|
||||||
<string name="TextStoryPostSendFragment__search">Search</string>
|
<string name="TextStoryPostSendFragment__search">Search</string>
|
||||||
|
<!-- Toast shown when an unexpected error occurs while sending a text story -->
|
||||||
|
<string name="TextStoryPostSendFragment__an_unexpected_error_occurred_try_again">An unexpected error occurred</string>
|
||||||
<!-- Title for screen allowing user to hide "My Story" entries from specific people -->
|
<!-- Title for screen allowing user to hide "My Story" entries from specific people -->
|
||||||
<string name="HideStoryFromFragment__hide_story_from">Hide story from…</string>
|
<string name="HideStoryFromFragment__hide_story_from">Hide story from…</string>
|
||||||
<!-- Done button label for hide story from screen -->
|
<!-- Done button label for hide story from screen -->
|
||||||
|
|
Ładowanie…
Reference in New Issue