mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Require the user to pick a display name
This commit is contained in:
parent
b425929da6
commit
48d282a864
@ -2,10 +2,8 @@
|
|||||||
<ScrollView
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
tools:context=".loki.AccountDetailsActivity">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
@ -1552,7 +1552,7 @@
|
|||||||
<!-- Display name activity -->
|
<!-- Display name activity -->
|
||||||
<string name="activity_display_name_title">Create Your Loki Messenger Account</string>
|
<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_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>
|
<string name="activity_display_name_button_title">Next</string>
|
||||||
<!-- Key pair activity -->
|
<!-- Key pair activity -->
|
||||||
<string name="activity_key_pair_title">Create Your Loki Messenger Account</string>
|
<string name="activity_key_pair_title">Create Your Loki Messenger Account</string>
|
||||||
|
@ -157,7 +157,7 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
|||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(getContext());
|
String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(getContext());
|
||||||
boolean isMasterDevice = (masterHexEncodedPublicKey != null);
|
boolean isMasterDevice = (masterHexEncodedPublicKey == null);
|
||||||
|
|
||||||
Preference profilePreference = this.findPreference(PREFERENCE_CATEGORY_PROFILE);
|
Preference profilePreference = this.findPreference(PREFERENCE_CATEGORY_PROFILE);
|
||||||
// Hide if this is a slave device
|
// Hide if this is a slave device
|
||||||
|
@ -203,7 +203,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
|||||||
int height = profilePictureImageView.getHeight();
|
int height = profilePictureImageView.getHeight();
|
||||||
if (width == 0 || height == 0) return true;
|
if (width == 0 || height == 0) return true;
|
||||||
profilePictureImageView.getViewTreeObserver().removeOnPreDrawListener(this);
|
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);
|
profilePictureImageView.setImageDrawable(identicon);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,10 @@ public class CreateProfileActivity extends BaseActionBarActivity implements Inje
|
|||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable s) {
|
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));
|
name.getInput().setError(getString(R.string.CreateProfileActivity_too_long));
|
||||||
finishButton.setEnabled(false);
|
finishButton.setEnabled(false);
|
||||||
} else if (name.getInput().getError() != null || !finishButton.isEnabled()) {
|
} 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));
|
image = new GeneratedContactPhoto(name, R.drawable.ic_profile_default).asDrawable(context, fallbackColor.toAvatarColor(context));
|
||||||
} else {
|
} else {
|
||||||
image = new JazzIdenticonDrawable(w, h, recipient.getAddress().serialize());
|
image = new JazzIdenticonDrawable(w, h, recipient.getAddress().serialize().toLowerCase());
|
||||||
}
|
}
|
||||||
setImageDrawable(image);
|
setImageDrawable(image);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package org.thoughtcrime.securesms.loki
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.inputmethod.InputMethodManager
|
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 network.loki.messenger.R
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
@ -19,21 +19,21 @@ class DisplayNameActivity : BaseActionBarActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_account_details)
|
setContentView(R.layout.activity_display_name)
|
||||||
nextButton.setOnClickListener { continueIfPossible() }
|
nextButton.setOnClickListener { continueIfPossible() }
|
||||||
Analytics.shared.track("Display Name Screen Viewed")
|
Analytics.shared.track("Display Name Screen Viewed")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun continueIfPossible() {
|
private fun continueIfPossible() {
|
||||||
val uncheckedName = nameEditText.text.toString()
|
val name = nameEditText.text.toString()
|
||||||
val name = if (uncheckedName.isNotEmpty()) { uncheckedName.trim() } else { null }
|
if (name.isEmpty()) {
|
||||||
if (name != null) {
|
return nameEditText.input.setError("Invalid")
|
||||||
if (name.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
|
}
|
||||||
return nameEditText.input.setError("Too Long")
|
if (name.toByteArray().size > ProfileCipher.NAME_PADDED_LENGTH) {
|
||||||
} else {
|
return nameEditText.input.setError("Too Long")
|
||||||
Analytics.shared.track("Display Name Updated")
|
} else {
|
||||||
TextSecurePreferences.setProfileName(this, name)
|
Analytics.shared.track("Display Name Updated")
|
||||||
}
|
TextSecurePreferences.setProfileName(this, name)
|
||||||
}
|
}
|
||||||
val inputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
val inputMethodManager = getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
inputMethodManager.hideSoftInputFromWindow(nameEditText.windowToken, 0)
|
inputMethodManager.hideSoftInputFromWindow(nameEditText.windowToken, 0)
|
||||||
@ -49,8 +49,6 @@ class DisplayNameActivity : BaseActionBarActivity() {
|
|||||||
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).privateKey.serialize()
|
val userPrivateKey = IdentityKeyUtil.getIdentityKeyPair(this).privateKey.serialize()
|
||||||
val apiDatabase = DatabaseFactory.getLokiAPIDatabase(this)
|
val apiDatabase = DatabaseFactory.getLokiAPIDatabase(this)
|
||||||
val userDatabase = DatabaseFactory.getLokiUserDatabase(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();
|
int height = avatarView.getHeight();
|
||||||
if (width == 0 || height == 0) return true;
|
if (width == 0 || height == 0) return true;
|
||||||
avatarView.getViewTreeObserver().removeOnPreDrawListener(this);
|
avatarView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||||
JazzIdenticonDrawable identicon = new JazzIdenticonDrawable(width, height, userHexEncodedPublicKey);
|
JazzIdenticonDrawable identicon = new JazzIdenticonDrawable(width, height, userHexEncodedPublicKey.toLowerCase());
|
||||||
avatarView.setImageDrawable(identicon);
|
avatarView.setImageDrawable(identicon);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user