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.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
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.SENDING -> shareConfirmButton.isEnabled = false
|
||||
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 org.signal.core.util.ThreadUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
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.util.Base64
|
||||
|
||||
private val TAG = Log.tag(TextStoryPostSendRepository::class.java)
|
||||
|
||||
class TextStoryPostSendRepository {
|
||||
|
||||
fun send(contactSearchKey: Set<ContactSearchKey>, textStoryPostCreationState: TextStoryPostCreationState, linkPreview: LinkPreview?): Single<TextStoryPostSendResult> {
|
||||
|
@ -27,6 +30,7 @@ class TextStoryPostSendRepository {
|
|||
if (it is UntrustedRecords.UntrustedRecordsException) {
|
||||
TextStoryPostSendResult.UntrustedRecordsError(it.untrustedRecords)
|
||||
} else {
|
||||
Log.w(TAG, "Unexpected error occurred", it)
|
||||
TextStoryPostSendResult.Failure
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,5 +3,6 @@ package org.thoughtcrime.securesms.mediasend.v2.text.send
|
|||
enum class TextStoryPostSendState {
|
||||
INIT,
|
||||
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.subscribeBy
|
||||
import io.reactivex.rxjava3.subjects.PublishSubject
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
|
||||
import org.thoughtcrime.securesms.database.model.IdentityRecord
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview
|
||||
import org.thoughtcrime.securesms.mediasend.v2.text.TextStoryPostCreationState
|
||||
import org.thoughtcrime.securesms.util.livedata.Store
|
||||
|
||||
private val TAG = Log.tag(TextStoryPostSendViewModel::class.java)
|
||||
|
||||
class TextStoryPostSendViewModel(private val repository: TextStoryPostSendRepository) : ViewModel() {
|
||||
|
||||
private val store = Store(TextStoryPostSendState.INIT)
|
||||
|
@ -54,11 +57,14 @@ class TextStoryPostSendViewModel(private val repository: TextStoryPostSendReposi
|
|||
untrustedIdentitySubject.onNext(it.untrustedRecords)
|
||||
store.update { TextStoryPostSendState.INIT }
|
||||
}
|
||||
is TextStoryPostSendResult.Failure -> {
|
||||
store.update { TextStoryPostSendState.FAILED }
|
||||
}
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
// TODO [stories] -- Error of some sort.
|
||||
store.update { TextStoryPostSendState.INIT }
|
||||
Log.w(TAG, "Unexpected error occurred", it)
|
||||
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>
|
||||
<!-- Hint text for searching for a story text post recipient. -->
|
||||
<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 -->
|
||||
<string name="HideStoryFromFragment__hide_story_from">Hide story from…</string>
|
||||
<!-- Done button label for hide story from screen -->
|
||||
|
|
Ładowanie…
Reference in New Issue