mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-23 15:51:11 +01:00
Add MSISDN (WIP)
This commit is contained in:
parent
9c05efa15d
commit
931eeac548
@ -78,16 +78,17 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
||||
val clientSecret = UUID.randomUUID().toString()
|
||||
val sendAttempt = 1
|
||||
|
||||
// Get country code from the phone number
|
||||
// Get country code and national number from the phone number
|
||||
val phoneNumber = threePid.msisdn
|
||||
|
||||
val parsedNumber = PhoneNumberUtil.getInstance().parse(phoneNumber, null)
|
||||
val phoneNumberUtil = PhoneNumberUtil.getInstance()
|
||||
val parsedNumber = phoneNumberUtil.parse(phoneNumber, null)
|
||||
val countryCode = parsedNumber.countryCode
|
||||
val country = phoneNumberUtil.getRegionCodeForCountryCode(countryCode)
|
||||
|
||||
val result = executeRequest<AddMsisdnResponse>(eventBus) {
|
||||
val body = AddMsisdnBody(
|
||||
clientSecret = clientSecret,
|
||||
country = countryCode.asString(), // TODO Convert to String,
|
||||
country = country,
|
||||
phoneNumber = parsedNumber.nationalNumber.toString(),
|
||||
sendAttempt = sendAttempt
|
||||
)
|
||||
@ -107,10 +108,5 @@ internal class DefaultAddThreePidTask @Inject constructor(
|
||||
.let { realm.copyToRealm(it) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun Int.asString(): String {
|
||||
// TODO
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.Success
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.loadingItem
|
||||
import im.vector.app.core.epoxy.noResultItem
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.extensions.getFormattedValue
|
||||
import im.vector.app.core.resources.ColorProvider
|
||||
@ -97,10 +98,20 @@ class ThreePidsSettingsController @Inject constructor(
|
||||
|
||||
emails.forEach { buildThreePid("email ", it) }
|
||||
|
||||
// Pending threePids
|
||||
// Pending emails
|
||||
data.pendingThreePids.invoke()
|
||||
?.filterIsInstance(ThreePid.Email::class.java)
|
||||
?.forEach { buildPendingThreePid("p_email ", it) }
|
||||
.orEmpty()
|
||||
.let { pendingList ->
|
||||
if (pendingList.isEmpty() && emails.isEmpty()) {
|
||||
noResultItem {
|
||||
id("noEmail")
|
||||
text(stringProvider.getString(R.string.settings_emails_empty))
|
||||
}
|
||||
}
|
||||
|
||||
pendingList.forEach { buildPendingThreePid("p_email ", it) }
|
||||
}
|
||||
|
||||
when (data.state) {
|
||||
ThreePidsSettingsState.Idle ->
|
||||
@ -135,10 +146,20 @@ class ThreePidsSettingsController @Inject constructor(
|
||||
|
||||
msisdn.forEach { buildThreePid("msisdn ", it) }
|
||||
|
||||
// Pending threePids
|
||||
// Pending msisdn
|
||||
data.pendingThreePids.invoke()
|
||||
?.filterIsInstance(ThreePid.Msisdn::class.java)
|
||||
?.forEach { buildPendingThreePid("p_msisdn ", it) }
|
||||
.orEmpty()
|
||||
.let { pendingList ->
|
||||
if (pendingList.isEmpty() && msisdn.isEmpty()) {
|
||||
noResultItem {
|
||||
id("noMsisdn")
|
||||
text(stringProvider.getString(R.string.settings_phone_number_empty))
|
||||
}
|
||||
}
|
||||
|
||||
pendingList.forEach { buildPendingThreePid("p_msisdn ", it) }
|
||||
}
|
||||
|
||||
when (data.state) {
|
||||
ThreePidsSettingsState.Idle ->
|
||||
|
@ -675,6 +675,7 @@
|
||||
<string name="settings_email_address">Email</string>
|
||||
<string name="settings_add_email_address">Add email address</string>
|
||||
<string name="settings_phone_number">Phone</string>
|
||||
<string name="settings_phone_number_empty">No phone number has been added to your account</string>
|
||||
<string name="settings_add_phone_number">Add phone number</string>
|
||||
<string name="settings_app_info_link_title">Application info</string>
|
||||
<string name="settings_app_info_link_summary">Show the application info in the system settings.</string>
|
||||
@ -683,6 +684,7 @@
|
||||
<string name="settings_add_3pid_authentication_needed">Authentication is required</string>
|
||||
|
||||
<string name="settings_emails">Email addresses</string>
|
||||
<string name="settings_emails_empty">No email has been added to your account</string>
|
||||
<string name="settings_phone_numbers">Phone numbers</string>
|
||||
<string name="settings_remove_three_pid_confirmation_content">Remove %s?</string>
|
||||
<string name="error_threepid_auth_failed">Ensure that you have clicked on the link in the email we have sent to you.</string>
|
||||
|
Loading…
Reference in New Issue
Block a user