mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-09 16:48:54 +01:00
Identity: Cleanup
This commit is contained in:
parent
7822660ce7
commit
d0953b8406
@ -208,8 +208,8 @@ class DiscoverySettingsController @Inject constructor(
|
|||||||
settingsInformationItem {
|
settingsInformationItem {
|
||||||
id("info${pidInfo.threePid.value}")
|
id("info${pidInfo.threePid.value}")
|
||||||
colorProvider(colorProvider)
|
colorProvider(colorProvider)
|
||||||
infoMessageColorId(R.color.vector_error_color)
|
textColorId(R.color.vector_error_color)
|
||||||
infoMessage(pidInfo.isShared.error.message ?: "")
|
message(pidInfo.isShared.error.message ?: "")
|
||||||
}
|
}
|
||||||
buildContinueCancel(pidInfo.threePid)
|
buildContinueCancel(pidInfo.threePid)
|
||||||
}
|
}
|
||||||
@ -219,8 +219,7 @@ class DiscoverySettingsController @Inject constructor(
|
|||||||
settingsInformationItem {
|
settingsInformationItem {
|
||||||
id("info${pidInfo.threePid.value}")
|
id("info${pidInfo.threePid.value}")
|
||||||
colorProvider(colorProvider)
|
colorProvider(colorProvider)
|
||||||
infoMessage(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
message(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
||||||
infoMessageColorId(R.color.vector_info_color)
|
|
||||||
}
|
}
|
||||||
buildContinueCancel(pidInfo.threePid)
|
buildContinueCancel(pidInfo.threePid)
|
||||||
}
|
}
|
||||||
@ -228,8 +227,7 @@ class DiscoverySettingsController @Inject constructor(
|
|||||||
settingsInformationItem {
|
settingsInformationItem {
|
||||||
id("info${pidInfo.threePid.value}")
|
id("info${pidInfo.threePid.value}")
|
||||||
colorProvider(colorProvider)
|
colorProvider(colorProvider)
|
||||||
infoMessage(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
message(stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value))
|
||||||
infoMessageColorId(R.color.vector_info_color)
|
|
||||||
}
|
}
|
||||||
settingsProgressItem {
|
settingsProgressItem {
|
||||||
id("progress${pidInfo.threePid.value}")
|
id("progress${pidInfo.threePid.value}")
|
||||||
@ -239,8 +237,8 @@ class DiscoverySettingsController @Inject constructor(
|
|||||||
settingsInformationItem {
|
settingsInformationItem {
|
||||||
id("info${pidInfo.threePid.value}")
|
id("info${pidInfo.threePid.value}")
|
||||||
colorProvider(colorProvider)
|
colorProvider(colorProvider)
|
||||||
infoMessage(stringProvider.getString(R.string.settings_discovery_confirm_mail_not_clicked, pidInfo.threePid.value))
|
message(stringProvider.getString(R.string.settings_discovery_confirm_mail_not_clicked, pidInfo.threePid.value))
|
||||||
infoMessageColorId(R.color.riotx_destructive_accent)
|
textColorId(R.color.riotx_destructive_accent)
|
||||||
}
|
}
|
||||||
buildContinueCancel(pidInfo.threePid)
|
buildContinueCancel(pidInfo.threePid)
|
||||||
}
|
}
|
||||||
@ -332,8 +330,8 @@ class DiscoverySettingsController @Inject constructor(
|
|||||||
settingsInformationItem {
|
settingsInformationItem {
|
||||||
id("info${pidInfo.threePid.value}")
|
id("info${pidInfo.threePid.value}")
|
||||||
colorProvider(colorProvider)
|
colorProvider(colorProvider)
|
||||||
infoMessageColorId(R.color.vector_error_color)
|
textColorId(R.color.vector_error_color)
|
||||||
infoMessage(pidInfo.isShared.error.message ?: "")
|
message(pidInfo.isShared.error.message ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
when (pidInfo.isShared()) {
|
when (pidInfo.isShared()) {
|
||||||
|
@ -133,7 +133,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||||||
is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action)
|
is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action)
|
||||||
is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action)
|
is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action)
|
||||||
is DiscoverySettingsAction.ShareThreePid -> shareThreePid(action)
|
is DiscoverySettingsAction.ShareThreePid -> shareThreePid(action)
|
||||||
is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action)
|
is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action, true)
|
||||||
is DiscoverySettingsAction.SubmitMsisdnToken -> submitMsisdnToken(action)
|
is DiscoverySettingsAction.SubmitMsisdnToken -> submitMsisdnToken(action)
|
||||||
is DiscoverySettingsAction.CancelBinding -> cancelBinding(action)
|
is DiscoverySettingsAction.CancelBinding -> cancelBinding(action)
|
||||||
}.exhaustive
|
}.exhaustive
|
||||||
@ -278,7 +278,6 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun cancelBinding(action: DiscoverySettingsAction.CancelBinding) {
|
private fun cancelBinding(action: DiscoverySettingsAction.CancelBinding) {
|
||||||
// TODO: remove the callback
|
|
||||||
identityService.cancelBindThreePid(action.threePid, object : MatrixCallback<Unit> {
|
identityService.cancelBindThreePid(action.threePid, object : MatrixCallback<Unit> {
|
||||||
override fun onSuccess(data: Unit) {
|
override fun onSuccess(data: Unit) {
|
||||||
changeThreePidState(action.threePid, Success(SharedState.NOT_SHARED))
|
changeThreePidState(action.threePid, Success(SharedState.NOT_SHARED))
|
||||||
@ -366,7 +365,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||||||
object : MatrixCallback<Unit> {
|
object : MatrixCallback<Unit> {
|
||||||
override fun onSuccess(data: Unit) {
|
override fun onSuccess(data: Unit) {
|
||||||
changeThreePidSubmitState(action.threePid, Uninitialized)
|
changeThreePidSubmitState(action.threePid, Uninitialized)
|
||||||
finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(action.threePid))
|
finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(action.threePid), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
@ -376,7 +375,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun finalizeBind3pid(action: DiscoverySettingsAction.FinalizeBind3pid) = withState { state ->
|
private fun finalizeBind3pid(action: DiscoverySettingsAction.FinalizeBind3pid, fromUser: Boolean) = withState { state ->
|
||||||
val threePid = when (action.threePid) {
|
val threePid = when (action.threePid) {
|
||||||
is ThreePid.Email -> {
|
is ThreePid.Email -> {
|
||||||
state.emailList()?.find { it.threePid.value == action.threePid.email }?.threePid ?: return@withState
|
state.emailList()?.find { it.threePid.value == action.threePid.email }?.threePid ?: return@withState
|
||||||
@ -395,7 +394,12 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(failure: Throwable) {
|
override fun onFailure(failure: Throwable) {
|
||||||
|
// If this is not from user (user did not click to "Continue", but this is a refresh when Fragment is resumed), do no display the error
|
||||||
|
if (fromUser) {
|
||||||
changeThreePidSubmitState(action.threePid, Fail(failure))
|
changeThreePidSubmitState(action.threePid, Fail(failure))
|
||||||
|
} else {
|
||||||
|
changeThreePidSubmitState(action.threePid, Uninitialized)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -404,7 +408,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor(
|
|||||||
private fun refreshPendingEmailBindings() = withState { state ->
|
private fun refreshPendingEmailBindings() = withState { state ->
|
||||||
state.emailList()?.forEach { info ->
|
state.emailList()?.forEach { info ->
|
||||||
when (info.isShared()) {
|
when (info.isShared()) {
|
||||||
SharedState.BINDING_IN_PROGRESS -> finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(info.threePid))
|
SharedState.BINDING_IN_PROGRESS -> finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(info.threePid), false)
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,21 +30,18 @@ abstract class SettingsInformationItem : EpoxyModelWithHolder<SettingsInformatio
|
|||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
lateinit var colorProvider: ColorProvider
|
lateinit var colorProvider: ColorProvider
|
||||||
|
|
||||||
// TODO Rename message
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
lateinit var infoMessage: String
|
lateinit var message: String
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
@ColorRes
|
@ColorRes
|
||||||
var infoMessageColorId: Int = R.color.vector_error_color
|
var textColorId: Int = R.color.vector_info_color
|
||||||
|
|
||||||
override fun bind(holder: Holder) {
|
override fun bind(holder: Holder) {
|
||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
|
|
||||||
holder.textView.text = infoMessage
|
holder.textView.text = message
|
||||||
|
holder.textView.setTextColor(colorProvider.getColor(textColorId))
|
||||||
val errorColor = colorProvider.getColor(infoMessageColorId)
|
|
||||||
holder.textView.setTextColor(errorColor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Holder : VectorEpoxyHolder() {
|
class Holder : VectorEpoxyHolder() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user