Code review fixes.

This commit is contained in:
onurays 2020-04-08 14:10:31 +03:00
parent dcb6af6c45
commit 5b1f887760
7 changed files with 12 additions and 10 deletions

View file

@ -14,6 +14,7 @@
* limitations under the License.
*/
// This BroadcastReceiver is used only if the build code is below 24.
@file:Suppress("DEPRECATION")
package im.vector.matrix.android.internal.network

View file

@ -188,6 +188,6 @@ fun Context.toast(resId: Int) {
}
// Not in KTX anymore
fun Context.toast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
fun Context.toast(message: String?) {
Toast.makeText(this, message ?: getString(R.string.generic_exception_error), Toast.LENGTH_SHORT).show()
}

View file

@ -153,7 +153,7 @@ class KeysBackupSetupActivity : SimpleFragmentActivity() {
}
override fun onFailure(failure: Throwable) {
failure.localizedMessage?.let { toast(it) }
toast(failure.localizedMessage ?: getString(R.string.unexpected_error))
hideWaitingView()
}
})

View file

@ -46,8 +46,10 @@ import im.vector.matrix.android.api.util.MatrixItem
import im.vector.matrix.android.api.util.toMatrixItem
import im.vector.matrix.android.internal.crypto.crosssigning.fromBase64
import im.vector.matrix.android.internal.crypto.crosssigning.isVerified
import im.vector.riotx.R
import im.vector.riotx.core.extensions.exhaustive
import im.vector.riotx.core.platform.VectorViewModel
import im.vector.riotx.core.resources.StringProvider
import timber.log.Timber
data class VerificationBottomSheetViewState(
@ -71,7 +73,8 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
@Assisted initialState: VerificationBottomSheetViewState,
@Assisted val args: VerificationBottomSheet.VerificationArgs,
private val session: Session,
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider)
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider,
private val stringProvider: StringProvider)
: VectorViewModel<VerificationBottomSheetViewState, VerificationAction, VerificationBottomSheetViewEvents>(initialState),
VerificationService.Listener {
@ -362,9 +365,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(
}
}
} catch (failure: Throwable) {
failure.localizedMessage?.let {
_viewEvents.post(VerificationBottomSheetViewEvents.ModalError(it))
}
_viewEvents.post(VerificationBottomSheetViewEvents.ModalError(failure.localizedMessage ?: stringProvider.getString(R.string.unexpected_error)))
}
}
}.exhaustive

View file

@ -782,7 +782,7 @@ class RoomDetailFragment @Inject constructor(
updateComposerText("")
}
is RoomDetailViewEvents.SlashCommandResultError -> {
sendMessageResult.throwable.localizedMessage?.let { displayCommandError(it) }
displayCommandError(sendMessageResult.throwable.localizedMessage ?: getString(R.string.unexpected_error))
}
is RoomDetailViewEvents.SlashCommandNotImplemented -> {
displayCommandError(getString(R.string.not_implemented))

View file

@ -332,7 +332,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
}
override fun onFailure(failure: Throwable) {
failure.localizedMessage?.let { appContext.toast(it) }
appContext.toast(failure.localizedMessage ?: getString(R.string.unexpected_error))
hideLoadingView()
}
})

View file

@ -52,7 +52,7 @@
<!-- BEGIN Strings added by Onuray -->
<string name="unexpected_error">An unexpected error occurred</string>
<!-- END Strings added by Onuray -->