mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Require the user to pick a display name
This commit is contained in:
parent
b425929da6
commit
48d282a864
@ -2,10 +2,8 @@
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".loki.AccountDetailsActivity">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
@ -1552,7 +1552,7 @@
|
||||
<!-- Display name activity -->
|
||||
<string name="activity_display_name_title">Create Your Loki Messenger Account</string>
|
||||
<string name="activity_display_name_subtitle">Enter a name to be shown to your contacts</string>
|
||||
<string name="activity_display_name_name_edit_text_label">Display Name (Optional)</string>
|
||||
<string name="activity_display_name_name_edit_text_label">Display Name</string>
|
||||
<string name="activity_display_name_button_title">Next</string>
|
||||
<!-- Key pair activity -->
|
||||
<string name="activity_key_pair_title">Create Your Loki Messenger Account</string>
|
||||
|
@ -157,7 +157,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
||||
super.onCreate(icicle);
|
||||
|
||||
String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(getContext());
|
||||
boolean isMasterDevice = (masterHexEncodedPublicKey != null);
|
||||
boolean isMasterDevice = (masterHexEncodedPublicKey == null);
|
||||
|
||||
Preference profilePreference = this.findPreference(PREFERENCE_CATEGORY_PROFILE);
|
||||
// Hide if this is a slave device
|
||||
|
@ -203,7 +203,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
int height = profilePictureImageView.getHeight();
|
||||
if (width == 0 || height == 0) return true;
|
||||
profilePictureImageView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
JazzIdenticonDrawable identicon = new JazzIdenticonDrawable(width, height, recipient.getAddress().serialize());
|
||||
JazzIdenticonDrawable identicon = new JazzIdenticonDrawable(width, height, recipient.getAddress().serialize().toLowerCase());
|
||||
profilePictureImageView.setImageDrawable(identicon);
|
||||
return true;
|
||||
}
|
||||
|
@ -229,7 +229,10 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (s.toString().getBytes().length > ProfileCipher.NAME_PADDED_LENGTH) {
|
||||
if (s.toString().isEmpty()) {
|
||||
name.getInput().setError("Invalid");
|
||||
finishButton.setEnabled(false);
|
||||
} else if (s.toString().getBytes().length > ProfileCipher.NAME_PADDED_LENGTH) {
|
||||
name.getInput().setError(getString(R.string.CreateProfileActivity_too_long));
|
||||
finishButton.setEnabled(false);
|
||||
} else if (name.getInput().getError() != null || !finishButton.isEnabled()) {
|
||||
|
@ -119,7 +119,7 @@ public class AvatarImageView extends AppCompatImageView {
|
||||
|
||||
image = new GeneratedContactPhoto(name, R.drawable.ic_profile_default).asDrawable(context, fallbackColor.toAvatarColor(context));
|
||||
} else {
|
||||
image = new JazzIdenticonDrawable(w, h, recipient.getAddress().serialize());
|
||||
image = new JazzIdenticonDrawable(w, h, recipient.getAddress().serialize().toLowerCase());
|
||||
}
|
||||
setImageDrawable(image);
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -100,7 +100,7 @@ public class ProfilePreference extends Preference {
|
||||
int height = avatarView.getHeight();
|
||||
if (width == 0 || height == 0) return true;
|
||||
avatarView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
JazzIdenticonDrawable identicon = new JazzIdenticonDrawable(width, height, userHexEncodedPublicKey);
|
||||
JazzIdenticonDrawable identicon = new JazzIdenticonDrawable(width, height, userHexEncodedPublicKey.toLowerCase());
|
||||
avatarView.setImageDrawable(identicon);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user