Update for new username API

This commit is contained in:
Niels Andriesse 2019-10-07 10:06:19 +11:00
parent 9f7437aa9e
commit 4f58bc11a1
5 changed files with 25 additions and 4 deletions

View File

@ -464,7 +464,7 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>
<!-- Loki -->
<activity android:name="org.thoughtcrime.securesms.loki.AccountDetailsActivity"
<activity android:name="org.thoughtcrime.securesms.loki.DisplayNameActivity"
android:launchMode="singleTask"
android:theme="@style/TextSecure.DarkRegistrationTheme"
android:windowSoftInputMode="stateUnchanged"

View File

@ -35,11 +35,15 @@ import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.dependencies.InjectableType;
import org.thoughtcrime.securesms.jobs.MultiDeviceProfileKeyUpdateJob;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.loki.LokiAPIDatabase;
import org.thoughtcrime.securesms.loki.LokiUserDatabase;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
@ -57,6 +61,7 @@ import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
import org.whispersystems.signalservice.api.crypto.ProfileCipher;
import org.whispersystems.signalservice.api.util.StreamDetails;
import org.whispersystems.signalservice.loki.api.LokiGroupChatAPI;
import java.io.ByteArrayInputStream;
import java.io.File;
@ -368,6 +373,12 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
TextSecurePreferences.setProfileName(context, name);
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context);
byte[] userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(context).getPrivateKey().serialize();
LokiAPIDatabase apiDatabase = DatabaseFactory.getLokiAPIDatabase(context);
LokiUserDatabase userDatabase = DatabaseFactory.getLokiUserDatabase(context);
new LokiGroupChatAPI(userHexEncodedPublicKey, userPrivateKey, apiDatabase, userDatabase).setDisplayName(name, LokiGroupChatAPI.getPublicChatServer());
// Loki - Original code
// ========
// try {

View File

@ -8,10 +8,13 @@ import network.loki.messenger.R
import org.thoughtcrime.securesms.ApplicationContext
import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.ConversationListActivity
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
import org.thoughtcrime.securesms.database.DatabaseFactory
import org.thoughtcrime.securesms.util.TextSecurePreferences
import org.whispersystems.signalservice.api.crypto.ProfileCipher
import org.whispersystems.signalservice.loki.api.LokiGroupChatAPI
class AccountDetailsActivity : BaseActionBarActivity() {
class DisplayNameActivity : BaseActionBarActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -38,5 +41,12 @@ class AccountDetailsActivity : BaseActionBarActivity() {
application.startLongPollingIfNeeded()
startActivity(Intent(this, ConversationListActivity::class.java))
finish()
val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this)
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)
}
}
}

View File

@ -34,9 +34,9 @@ class LokiGroupChatPoller(private val context: Context, private val group: LokiG
private val api: LokiGroupChatAPI
get() = {
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(context).privateKey.serialize()
val lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(context)
val lokiUserDatabase = DatabaseFactory.getLokiUserDatabase(context)
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(context).privateKey.serialize()
LokiGroupChatAPI(userHexEncodedPublicKey, userPrivateKey, lokiAPIDatabase, lokiUserDatabase)
}()
// endregion

View File

@ -161,7 +161,7 @@ class SeedActivity : BaseActionBarActivity() {
Mode.Register -> Analytics.shared.track("Seed Created")
Mode.Restore -> Analytics.shared.track("Seed Restored")
}
startActivity(Intent(this, AccountDetailsActivity::class.java))
startActivity(Intent(this, DisplayNameActivity::class.java))
finish()
}
// endregion