Fix remaining registration issues

This commit is contained in:
Niels Andriesse 2019-06-05 15:33:31 +10:00
parent 3c2504418d
commit eae5e90814
2 changed files with 10 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import android.os.Bundle
import kotlinx.android.synthetic.main.activity_account_details.*
import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.R
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.api.crypto.ProfileCipher
class AccountDetailsActivity : BaseActionBarActivity() {
@ -18,8 +19,12 @@ class AccountDetailsActivity : BaseActionBarActivity() {
private fun continueIfPossible() {
val uncheckedName = nameEditText.text.toString()
val name = if (uncheckedName.isNotEmpty()) { uncheckedName.trim() } else { null }
if (name != null && name.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
if (name != null) {
if (name.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
return nameEditText.input.setError("Too Long")
} else {
TextSecurePreferences.setProfileName(this, name)
}
}
startActivity(Intent(this, KeyPairActivity::class.java))
finish()

View File

@ -13,6 +13,8 @@ import org.thoughtcrime.securesms.database.IdentityDatabase
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.libsignal.IdentityKeyPair
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
import org.whispersystems.signalservice.loki.utilities.hexEncodedPrivateKey
import org.whispersystems.signalservice.loki.utilities.hexEncodedPublicKey
import java.io.File
import java.io.FileOutputStream
@ -74,11 +76,10 @@ class KeyPairActivity : BaseActionBarActivity() {
// region Interaction
private fun register() {
val publicKey = keyPair!!.publicKey
val hexEncodedPublicKey = publicKey.fingerprint
val hexEncodedPublicKey = keyPair!!.hexEncodedPublicKey
DatabaseFactory.getIdentityDatabase(this).saveIdentity(Address.fromSerialized(hexEncodedPublicKey), publicKey,
IdentityDatabase.VerifiedStatus.VERIFIED, true, System.currentTimeMillis(), true)
TextSecurePreferences.setLocalNumber(this, hexEncodedPublicKey)
TextSecurePreferences.setProfileName(this, "User McUserFace") // TODO: For debugging purposes
TextSecurePreferences.setPromptedPushRegistration(this, true)
startActivity(Intent(this, ConversationListActivity::class.java))
finish()