aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-06-25 11:32:37 +0200
committerChristian Schneppe <christian@pix-art.de>2019-06-25 11:32:37 +0200
commita7fe71c6917b3a15b10ad6a86be5438312372e67 (patch)
treeb55bc11192e456e23b9e9345e8c3b2d5dc742b81 /src/main/java/de/pixart/messenger/ui
parent230d85cdb7191e82bfdfeccc8abcaebc53af364f (diff)
fix welcome screens
fixes #361
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java29
-rw-r--r--src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/WelcomeActivity.java4
3 files changed, 29 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index e2b590d05..666c7b96d 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -87,6 +87,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
OnKeyStatusUpdated, OnCaptchaRequested, KeyChainAliasCallback, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnMamPreferencesFetched {
public static final String EXTRA_OPENED_FROM_NOTIFICATION = "opened_from_notification";
+ public static final String EXTRA_FORCE_REGISTER = "force_register";
private static final int REQUEST_DATA_SAVER = 0xf244;
private static final int REQUEST_CHANGE_STATUS = 0xee11;
@@ -98,6 +99,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
private final AtomicBoolean redirectInProgress = new AtomicBoolean(false);
private Jid jidToEdit;
private boolean mInitMode = false;
+ private Boolean mForceRegister = null;
private boolean mUsernameMode = Config.DOMAIN_LOCK != null;
private boolean mShowOptions = false;
private boolean useOwnProvider = false;
@@ -125,7 +127,12 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
}
return;
}
- final boolean registerNewAccount = binding.accountRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
+ final boolean registerNewAccount;
+ if (mForceRegister != null) {
+ registerNewAccount = mForceRegister;
+ } else {
+ registerNewAccount = binding.accountRegisterNew.isChecked() && !Config.DISALLOW_REGISTRATION_IN_UI;
+ }
if (mUsernameMode && binding.accountJid.getText().toString().contains("@")) {
binding.accountJidLayout.setError(getString(R.string.invalid_username));
removeErrorsOnAllBut(binding.accountJidLayout);
@@ -732,6 +739,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
boolean existing = intent.getBooleanExtra("existing", false);
useOwnProvider = intent.getBooleanExtra("useownprovider", false);
boolean openedFromNotification = intent.getBooleanExtra(EXTRA_OPENED_FROM_NOTIFICATION, false);
+ Log.d(Config.LOGTAG, "extras " + intent.getExtras());
+ this.mForceRegister = intent.hasExtra(EXTRA_FORCE_REGISTER) ? intent.getBooleanExtra(EXTRA_FORCE_REGISTER, false) : null;
+ Log.d(Config.LOGTAG, "force register=" + mForceRegister);
this.mInitMode = init || this.jidToEdit == null;
this.messageFingerprint = intent.getStringExtra("fingerprint");
if (!mInitMode) {
@@ -742,12 +752,12 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.binding.yourNameBox.setVisibility(View.GONE);
this.binding.avater.setVisibility(View.GONE);
configureActionBar(getSupportActionBar(), !(init && Config.MAGIC_CREATE_DOMAIN == null));
- if (existing) {
- setTitle(R.string.action_add_existing_account);
- this.binding.accountRegisterNew.setVisibility(View.GONE);
- } else {
- setTitle(R.string.action_add_new_account);
- this.binding.accountRegisterNew.setVisibility(View.VISIBLE);
+ if (mForceRegister != null) {
+ if (mForceRegister) {
+ setTitle(R.string.action_add_new_account);
+ } else {
+ setTitle(R.string.action_add_existing_account);
+ }
}
}
}
@@ -755,6 +765,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
mUseTor = QuickConversationsService.isConversations() && preferences.getBoolean("use_tor", getResources().getBoolean(R.bool.use_tor));
this.mShowOptions = mUseTor || (QuickConversationsService.isConversations() && preferences.getBoolean("show_connection_options", getResources().getBoolean(R.bool.show_connection_options)));
this.binding.namePort.setVisibility(mShowOptions ? View.VISIBLE : View.GONE);
+ if (mForceRegister != null) {
+ this.binding.accountRegisterNew.setVisibility(View.GONE);
+ }
}
@Override
@@ -1111,7 +1124,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
}
}
this.binding.accountRegisterNew.setVisibility(View.GONE);
- } else if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) {
+ } else if (this.mAccount.isOptionSet(Account.OPTION_REGISTER) && mForceRegister == null) {
this.binding.accountRegisterNew.setVisibility(View.VISIBLE);
} else {
this.binding.accountRegisterNew.setVisibility(mInitMode ? View.VISIBLE : View.GONE);
diff --git a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
index fd0e49d57..372c2bc27 100644
--- a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java
@@ -81,9 +81,12 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad
next.setOnClickListener(v -> {
try {
String username = mUsername.getText().toString();
- if (domain == null || useOwnProvider) {
+ if (domain == null && !useOwnProvider) {
domain = Config.MAGIC_CREATE_DOMAIN;
}
+ if (useOwnProvider) {
+ domain = "your-domain.com";
+ }
Jid jid = Jid.of(username.toLowerCase(), domain, null);
if (!jid.getEscapedLocal().equals(jid.getLocal()) || username.length() < 3) {
mUsername.setError(getString(R.string.invalid_username));
diff --git a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
index f5a4647b6..472684316 100644
--- a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java
@@ -16,6 +16,7 @@ import java.util.List;
import de.pixart.messenger.R;
import de.pixart.messenger.entities.Account;
+import static de.pixart.messenger.Config.DISALLOW_REGISTRATION_IN_UI;
import static de.pixart.messenger.utils.PermissionUtils.allGranted;
import static de.pixart.messenger.utils.PermissionUtils.writeGranted;
@@ -79,6 +80,9 @@ public class WelcomeActivity extends XmppActivity {
addInviteUri(intent);
startActivity(intent);
});
+ if (DISALLOW_REGISTRATION_IN_UI) {
+ createAccount.setVisibility(View.GONE);
+ }
final Button useExistingAccount = findViewById(R.id.use_existing_account);
useExistingAccount.setOnClickListener(v -> {
Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class);