diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-04-28 14:42:15 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-04-28 14:42:15 +0200 |
commit | da896e202d1d286b60fa1f950d76dfdb403b0176 (patch) | |
tree | 6f155f928950e5c96cf4bb24f4f779bfd3ac83f4 /src/main/java/de/pixart/messenger | |
parent | 53f83844124806163b2030c4f7a1c75bd90dae76 (diff) |
improve welcome screens
Diffstat (limited to '')
3 files changed, 38 insertions, 16 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index bba551a6c..33d0a8e7c 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -41,7 +41,6 @@ import org.openintents.openpgp.util.OpenPgpUtils; import java.net.URL; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -55,7 +54,6 @@ import de.pixart.messenger.databinding.DialogPresenceBinding; import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.Presence; import de.pixart.messenger.entities.PresenceTemplate; -import de.pixart.messenger.entities.ServiceDiscoveryResult; import de.pixart.messenger.services.BarcodeProvider; import de.pixart.messenger.services.QuickConversationsService; import de.pixart.messenger.services.XmppConnectionService; @@ -68,7 +66,6 @@ import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.ui.util.SoftKeyboardUtils; import de.pixart.messenger.utils.CryptoHelper; import de.pixart.messenger.utils.MenuDoubleTabUtil; -import de.pixart.messenger.utils.Namespace; import de.pixart.messenger.utils.Resolver; import de.pixart.messenger.utils.SignupUtils; import de.pixart.messenger.utils.TorServiceUtils; @@ -103,6 +100,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat private boolean mInitMode = false; private boolean mUsernameMode = Config.DOMAIN_LOCK != null; private boolean mShowOptions = false; + private boolean useOwnProvider = false; private Account mAccount; private String messageFingerprint; @@ -731,6 +729,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } } boolean init = intent.getBooleanExtra("init", false); + boolean existing = intent.getBooleanExtra("existing", false); + useOwnProvider = intent.getBooleanExtra("useownprovider", false); boolean openedFromNotification = intent.getBooleanExtra(EXTRA_OPENED_FROM_NOTIFICATION, false); this.mInitMode = init || this.jidToEdit == null; this.messageFingerprint = intent.getStringExtra("fingerprint"); @@ -742,7 +742,13 @@ 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)); - setTitle(R.string.action_add_account); + 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); + } } } SharedPreferences preferences = getPreferences(); @@ -793,7 +799,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat xmppConnectionService.reconnectAccountInBackground(mAccount); } this.mInitMode |= this.mAccount.isOptionSet(Account.OPTION_REGISTER); - this.mUsernameMode |= mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && mAccount.isOptionSet(Account.OPTION_REGISTER); + this.mUsernameMode |= mAccount.isOptionSet(Account.OPTION_MAGIC_CREATE) && mAccount.isOptionSet(Account.OPTION_REGISTER) && !useOwnProvider; if (this.mAccount.getPrivateKeyAlias() != null) { binding.accountPassword.setHint(R.string.authenticate_with_certificate); if (this.mInitMode) { @@ -1101,7 +1107,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (this.mAccount.isOptionSet(Account.OPTION_REGISTER)) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { - actionBar.setTitle(R.string.create_account); + setTitle(R.string.action_add_new_account); } } this.binding.accountRegisterNew.setVisibility(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 89da3d3d8..99eb2f508 100644 --- a/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java +++ b/src/main/java/de/pixart/messenger/ui/MagicCreateActivity.java @@ -10,6 +10,8 @@ import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; @@ -25,11 +27,13 @@ import de.pixart.messenger.entities.Account; import de.pixart.messenger.utils.CryptoHelper; import rocks.xmpp.addr.Jid; -public class MagicCreateActivity extends XmppActivity implements TextWatcher, AdapterView.OnItemSelectedListener { +public class MagicCreateActivity extends XmppActivity implements TextWatcher, AdapterView.OnItemSelectedListener, CompoundButton.OnCheckedChangeListener { private TextView mFullJidDisplay; private EditText mUsername; + private CheckBox mUseOwnProvider; private Spinner mServer; + private boolean useOwnProvider = false; String domain = null; @Override @@ -66,16 +70,18 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_selectable_list_item, domains); int defaultServer = adapter.getPosition("blabber.im"); mUsername = findViewById(R.id.username); + mUseOwnProvider = findViewById(R.id.use_own); + mUseOwnProvider.setOnCheckedChangeListener(this); mServer = findViewById(R.id.server); mServer.setAdapter(adapter); mServer.setSelection(defaultServer); mServer.setOnItemSelectedListener(this); - adapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Button next = findViewById(R.id.create_account); next.setOnClickListener(v -> { try { String username = mUsername.getText().toString(); - if (domain == null) { + if (domain == null || useOwnProvider) { domain = Config.MAGIC_CREATE_DOMAIN; } Jid jid = Jid.of(username.toLowerCase(), domain, null); @@ -96,6 +102,8 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad Intent intent = new Intent(MagicCreateActivity.this, EditAccountActivity.class); intent.putExtra("jid", account.getJid().asBareJid().toString()); intent.putExtra("init", true); + intent.putExtra("existing", false); + intent.putExtra("useownprovider", useOwnProvider); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); AlertDialog.Builder builder = new AlertDialog.Builder(this); @@ -170,4 +178,17 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher, Ad mFullJidDisplay.setVisibility(View.INVISIBLE); } } + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (mUseOwnProvider.isChecked()) { + mServer.setEnabled(false); + mFullJidDisplay.setVisibility(View.GONE); + useOwnProvider = true; + } else { + mServer.setEnabled(true); + mFullJidDisplay.setVisibility(View.VISIBLE); + useOwnProvider = false; + } + } } diff --git a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java index f871a095b..f5a4647b6 100644 --- a/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java +++ b/src/main/java/de/pixart/messenger/ui/WelcomeActivity.java @@ -81,14 +81,9 @@ public class WelcomeActivity extends XmppActivity { }); final Button useExistingAccount = findViewById(R.id.use_existing_account); useExistingAccount.setOnClickListener(v -> { - List<Account> accounts = xmppConnectionService.getAccounts(); Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class); - if (accounts.size() == 1) { - intent.putExtra("jid", accounts.get(0).getJid().asBareJid().toString()); - intent.putExtra("init", true); - } else if (accounts.size() >= 1) { - intent = new Intent(WelcomeActivity.this, ManageAccountActivity.class); - } + intent.putExtra("init", true); + intent.putExtra("existing", true); addInviteUri(intent); startActivity(intent); overridePendingTransition(R.animator.fade_in, R.animator.fade_out); |