|
|
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.loki
|
|
|
|
|
import android.content.Intent
|
|
|
|
|
import android.os.Bundle
|
|
|
|
|
import android.view.inputmethod.InputMethodManager
|
|
|
|
|
import kotlinx.android.synthetic.main.activity_account_details.*
|
|
|
|
|
import kotlinx.android.synthetic.main.activity_display_name.*
|
|
|
|
|
import network.loki.messenger.R
|
|
|
|
|
import org.thoughtcrime.securesms.ApplicationContext
|
|
|
|
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
|
|
|
@ -19,21 +19,21 @@ class DisplayNameActivity : BaseActionBarActivity() {
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
|
setContentView(R.layout.activity_account_details)
|
|
|
|
|
setContentView(R.layout.activity_display_name)
|
|
|
|
|
nextButton.setOnClickListener { continueIfPossible() }
|
|
|
|
|
Analytics.shared.track("Display Name Screen Viewed")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun continueIfPossible() {
|
|
|
|
|
val uncheckedName = nameEditText.text.toString()
|
|
|
|
|
val name = if (uncheckedName.isNotEmpty()) { uncheckedName.trim() } else { null }
|
|
|
|
|
if (name != null) {
|
|
|
|
|
if (name.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
|
|
|
|
|
return nameEditText.input.setError("Too Long")
|
|
|
|
|
} else {
|
|
|
|
|
Analytics.shared.track("Display Name Updated")
|
|
|
|
|
TextSecurePreferences.setProfileName(this, name)
|
|
|
|
|
}
|
|
|
|
|
val name = nameEditText.text.toString()
|
|
|
|
|
if (name.isEmpty()) {
|
|
|
|
|
return nameEditText.input.setError("Invalid")
|
|
|
|
|
}
|
|
|
|
|
if (name.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
|
|
|
|
|
return nameEditText.input.setError("Too Long")
|
|
|
|
|
} else {
|
|
|
|
|
Analytics.shared.track("Display Name Updated")
|
|
|
|
|
TextSecurePreferences.setProfileName(this, name)
|
|
|
|
|
}
|
|
|
|
|
val inputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(nameEditText.windowToken, 0)
|
|
|
|
@ -49,8 +49,6 @@ class DisplayNameActivity : BaseActionBarActivity() {
|
|
|
|
|
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).privateKey.serialize()
|
|
|
|
|
val apiDatabase = DatabaseFactory.getLokiAPIDatabase(this)
|
|
|
|
|
val userDatabase = DatabaseFactory.getLokiUserDatabase(this)
|
|
|
|
|
if (name != null) {
|
|
|
|
|
LokiGroupChatAPI(userHexEncodedPublicKey, userPrivateKey, apiDatabase, userDatabase).setDisplayName(name, LokiGroupChatAPI.publicChatServer)
|
|
|
|
|
}
|
|
|
|
|
LokiGroupChatAPI(userHexEncodedPublicKey, userPrivateKey, apiDatabase, userDatabase).setDisplayName(name, LokiGroupChatAPI.publicChatServer)
|
|
|
|
|
}
|
|
|
|
|
}
|