mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 17:27:45 +00:00
WIP
This commit is contained in:
parent
063e0967df
commit
1498a2e382
@ -1,13 +1,18 @@
|
|||||||
package org.thoughtcrime.securesms.loki
|
package org.thoughtcrime.securesms.loki
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import kotlinx.android.synthetic.main.activity_key_pair.*
|
import kotlinx.android.synthetic.main.activity_key_pair.*
|
||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
|
import org.thoughtcrime.securesms.ConversationListActivity
|
||||||
import org.thoughtcrime.securesms.R
|
import org.thoughtcrime.securesms.R
|
||||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||||
|
import org.thoughtcrime.securesms.database.Address
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
|
import org.thoughtcrime.securesms.database.IdentityDatabase
|
||||||
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import org.whispersystems.libsignal.IdentityKeyPair
|
import org.whispersystems.libsignal.IdentityKeyPair
|
||||||
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
import org.whispersystems.signalservice.loki.crypto.MnemonicCodec
|
||||||
import org.whispersystems.signalservice.loki.utilities.hexEncodedPrivateKey
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
|
|
||||||
@ -24,6 +29,7 @@ class KeyPairActivity : BaseActionBarActivity() {
|
|||||||
setContentView(R.layout.activity_key_pair)
|
setContentView(R.layout.activity_key_pair)
|
||||||
setUpLanguageFileDirectory()
|
setUpLanguageFileDirectory()
|
||||||
updateKeyPair()
|
updateKeyPair()
|
||||||
|
nextButton.setOnClickListener { register() }
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
@ -64,4 +70,16 @@ class KeyPairActivity : BaseActionBarActivity() {
|
|||||||
mnemonicTextView.text = mnemonic!!
|
mnemonicTextView.text = mnemonic!!
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
// region Interaction
|
||||||
|
private fun register() {
|
||||||
|
val publicKey = keyPair!!.publicKey
|
||||||
|
val hexEncodedPublicKey = publicKey.fingerprint
|
||||||
|
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
|
||||||
|
startActivity(Intent(this, ConversationListActivity::class.java))
|
||||||
|
}
|
||||||
|
// endregion
|
||||||
}
|
}
|
@ -8,17 +8,17 @@ import org.whispersystems.signalservice.loki.messaging.LokiPreKeyBundleStoreProt
|
|||||||
class LokiPreKeyBundleStore(val context: Context) : LokiPreKeyBundleStoreProtocol {
|
class LokiPreKeyBundleStore(val context: Context) : LokiPreKeyBundleStoreProtocol {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val fileLock = Object()
|
private val lock = Object()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPreKeyBundle(pubKey: String): PreKeyBundle? {
|
override fun getPreKeyBundle(pubKey: String): PreKeyBundle? {
|
||||||
synchronized (fileLock) {
|
synchronized(lock) {
|
||||||
return DatabaseFactory.getLokiPreKeyBundleDatabase(context).getPreKeyBundle(pubKey)
|
return DatabaseFactory.getLokiPreKeyBundleDatabase(context).getPreKeyBundle(pubKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun removePreKeyBundle(pubKey: String) {
|
override fun removePreKeyBundle(pubKey: String) {
|
||||||
synchronized (fileLock) {
|
synchronized(lock) {
|
||||||
DatabaseFactory.getLokiPreKeyBundleDatabase(context).removePreKeyBundle(pubKey)
|
DatabaseFactory.getLokiPreKeyBundleDatabase(context).removePreKeyBundle(pubKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user