diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-03-14 21:26:41 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-03-14 21:26:41 +0100 |
commit | d74cf5b6f0ed5b493ea4953f57a93347c03253b3 (patch) | |
tree | ea9631c5427e653d8b6eef6da2d57319b40725bc /src/main/java/de | |
parent | ab0d3c397493377eb98f9713fc669fb5ec72a45b (diff) |
rework user name input during account creation
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/EditAccountActivity.java | 30 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/EnterNameActivity.java | 7 |
2 files changed, 16 insertions, 21 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 456b907df..f62d68bef 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -98,6 +98,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private AlertDialog mCaptchaDialog = null; private final AtomicBoolean mPendingReconnect = new AtomicBoolean(false); + private final AtomicBoolean redirectInProgress = new AtomicBoolean(false); private Jid jidToEdit; private boolean mInitMode = false; private boolean mUsernameMode = Config.DOMAIN_LOCK != null; @@ -298,10 +299,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat overridePendingTransition(R.animator.fade_in, R.animator.fade_out); finish(); } else if (mInitMode && mAccount != null && mAccount.getStatus() == Account.State.ONLINE) { - if (!mFetchingAvatar) { - mFetchingAvatar = true; - xmppConnectionService.checkForAvatar(mAccount, mAvatarFetchCallback); - } + runOnUiThread(this::performPostVerificationRedirect); } if (mAccount != null) { updateAccountInformation(false); @@ -309,6 +307,15 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat updateSaveButton(); } + private void performPostVerificationRedirect() { + if (redirectInProgress.compareAndSet(false, true)) { + Intent intent = new Intent(this, EnterNameActivity.class); + startActivity(intent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + finish(); + } + } + @Override public boolean onNavigateUp() { deleteAccountAndReturnIfNecessary(); @@ -624,18 +631,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } private void onEditYourNameClicked(View view) { - String nick; - try { - if (mAccount != null) { - nick = mAccount.getDisplayName(); - } else { - nick = ""; - } - } catch (Exception e) { - e.printStackTrace(); - nick = ""; - } - quickEdit(nick, R.string.your_name, value -> { + quickEdit(mAccount.getDisplayName(), R.string.your_name, value -> { final String displayName = value.trim(); updateDisplayName(displayName); mAccount.setDisplayName(displayName); @@ -742,6 +738,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat setTitle(getString(R.string.account_details)); configureActionBar(getSupportActionBar(), !openedFromNotification); } else { + this.binding.yourNameBox.setVisibility(View.GONE); this.binding.avater.setVisibility(View.GONE); configureActionBar(getSupportActionBar(), !(init && Config.MAGIC_CREATE_DOMAIN == null)); setTitle(R.string.action_add_account); @@ -1112,6 +1109,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } else { this.binding.accountRegisterNew.setVisibility(mInitMode ? View.VISIBLE : View.GONE); } + this.binding.yourNameBox.setVisibility(mInitMode ? View.GONE : View.VISIBLE); if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) { Features features = this.mAccount.getXmppConnection().getFeatures(); this.binding.stats.setVisibility(View.VISIBLE); diff --git a/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java b/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java index a1a6b28b5..1f59901a6 100644 --- a/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EnterNameActivity.java @@ -28,22 +28,19 @@ public class EnterNameActivity extends XmppActivity implements XmppConnectionSer this.binding = DataBindingUtil.setContentView(this, R.layout.activity_enter_name); setSupportActionBar((Toolbar) this.binding.toolbar); this.binding.next.setOnClickListener(this::next); - this.setNick.set(savedInstanceState != null && savedInstanceState.getBoolean("set_nick",false)); + this.setNick.set(savedInstanceState != null && savedInstanceState.getBoolean("set_nick", false)); } private void next(View view) { if (account != null) { - String name = this.binding.name.getText().toString().trim(); - account.setDisplayName(name); - xmppConnectionService.publishDisplayName(account); - Intent intent = new Intent(this, PublishProfilePictureActivity.class); intent.putExtra(PublishProfilePictureActivity.EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); intent.putExtra("setup", true); startActivity(intent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); } finish(); } |