diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt index 5b24961a49..e78d8e38a5 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt @@ -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(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 "" - } } diff --git a/vector/src/main/java/im/vector/app/features/settings/threepids/ThreePidsSettingsController.kt b/vector/src/main/java/im/vector/app/features/settings/threepids/ThreePidsSettingsController.kt index e8321ad456..06a3a87421 100644 --- a/vector/src/main/java/im/vector/app/features/settings/threepids/ThreePidsSettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/threepids/ThreePidsSettingsController.kt @@ -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 -> diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 975525c750..1e14e0b78a 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -675,6 +675,7 @@ Email Add email address Phone + No phone number has been added to your account Add phone number Application info Show the application info in the system settings. @@ -683,6 +684,7 @@ Authentication is required Email addresses + No email has been added to your account Phone numbers Remove %s? Ensure that you have clicked on the link in the email we have sent to you.