From 7b61bb984173ec314f057c8fbee7f69b6e4f8ee6 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 25 Apr 2019 19:00:59 +0200 Subject: [PATCH] rework welcome screens to split use existing account / create new closes #3440 --- src/conversations/AndroidManifest.xml | 6 +- .../conversations/ui/PickServerActivity.java | 104 ++++++++++++++++++ .../conversations/ui/WelcomeActivity.java | 25 ++--- .../conversations/utils/SignupUtils.java | 15 ++- .../res/layout/activity_pick_server.xml | 102 +++++++++++++++++ .../res/layout/activity_welcome.xml | 91 +++++++++++++++ src/conversations/res/layout/welcome.xml | 89 --------------- src/conversations/res/values/strings.xml | 9 ++ .../conversations/ui/EditAccountActivity.java | 29 ++++- src/main/res/values/strings.xml | 4 +- .../conversations/utils/SignupUtils.java | 7 +- 11 files changed, 368 insertions(+), 113 deletions(-) create mode 100644 src/conversations/java/eu/siacs/conversations/ui/PickServerActivity.java create mode 100644 src/conversations/res/layout/activity_pick_server.xml create mode 100644 src/conversations/res/layout/activity_welcome.xml delete mode 100644 src/conversations/res/layout/welcome.xml create mode 100644 src/conversations/res/values/strings.xml diff --git a/src/conversations/AndroidManifest.xml b/src/conversations/AndroidManifest.xml index 2c01f6d6c..0a01c6c0f 100644 --- a/src/conversations/AndroidManifest.xml +++ b/src/conversations/AndroidManifest.xml @@ -12,9 +12,13 @@ android:name=".ui.WelcomeActivity" android:label="@string/app_name" android:launchMode="singleTask"/> + { + final Intent intent = new Intent(this, MagicCreateActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + addInviteUri(intent); + startActivity(intent); + }); + binding.useOwnProvider.setOnClickListener(v -> { + List accounts = xmppConnectionService.getAccounts(); + Intent intent = new Intent(this, EditAccountActivity.class); + intent.putExtra(EditAccountActivity.EXTRA_FORCE_REGISTER, true); + 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(this, ManageAccountActivity.class); + } + addInviteUri(intent); + startActivity(intent); + }); + + } + + public void addInviteUri(Intent intent) { + StartConversationActivity.addInviteUri(intent, getIntent()); + } + + public static void launch(AppCompatActivity activity) { + Intent intent = new Intent(activity, PickServerActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); + activity.startActivity(intent); + activity.overridePendingTransition(0, 0); + } + +} diff --git a/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java b/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java index eb466e37a..02613f368 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/WelcomeActivity.java @@ -2,18 +2,19 @@ package eu.siacs.conversations.ui; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.databinding.DataBindingUtil; import android.os.Bundle; import android.support.annotation.NonNull; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; -import android.widget.Button; import android.widget.Toast; import java.util.List; import eu.siacs.conversations.R; +import eu.siacs.conversations.databinding.ActivityWelcomeBinding; import eu.siacs.conversations.entities.Account; import static eu.siacs.conversations.utils.PermissionUtils.allGranted; @@ -55,24 +56,18 @@ public class WelcomeActivity extends XmppActivity { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } super.onCreate(savedInstanceState); - setContentView(R.layout.welcome); - setSupportActionBar(findViewById(R.id.toolbar)); - final ActionBar ab = getSupportActionBar(); - if (ab != null) { - ab.setDisplayShowHomeEnabled(false); - ab.setDisplayHomeAsUpEnabled(false); - } - final Button createAccount = findViewById(R.id.create_account); - createAccount.setOnClickListener(v -> { - final Intent intent = new Intent(WelcomeActivity.this, MagicCreateActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + ActivityWelcomeBinding binding = DataBindingUtil.setContentView(this,R.layout.activity_welcome); + setSupportActionBar((Toolbar) binding.toolbar); + configureActionBar(getSupportActionBar(), false); + binding.registerNewAccount.setOnClickListener(v -> { + final Intent intent = new Intent(this, PickServerActivity.class); addInviteUri(intent); startActivity(intent); }); - final Button useOwnProvider = findViewById(R.id.use_own_provider); - useOwnProvider.setOnClickListener(v -> { + binding.useExisting.setOnClickListener(v -> { List accounts = xmppConnectionService.getAccounts(); Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class); + intent.putExtra(EditAccountActivity.EXTRA_FORCE_REGISTER,false); if (accounts.size() == 1) { intent.putExtra("jid", accounts.get(0).getJid().asBareJid().toString()); intent.putExtra("init", true); diff --git a/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java b/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java index ee5433cf4..6e8ed2eff 100644 --- a/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java +++ b/src/conversations/java/eu/siacs/conversations/utils/SignupUtils.java @@ -9,13 +9,23 @@ import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.ConversationsActivity; import eu.siacs.conversations.ui.EditAccountActivity; import eu.siacs.conversations.ui.ManageAccountActivity; +import eu.siacs.conversations.ui.PickServerActivity; import eu.siacs.conversations.ui.StartConversationActivity; import eu.siacs.conversations.ui.WelcomeActivity; public class SignupUtils { public static Intent getSignUpIntent(final Activity activity) { - Intent intent = new Intent(activity, WelcomeActivity.class); + return getSignUpIntent(activity, false); + } + + public static Intent getSignUpIntent(final Activity activity, final boolean toServerChooser) { + Intent intent; + if (toServerChooser) { + intent = new Intent(activity, PickServerActivity.class); + } else { + intent = new Intent(activity, WelcomeActivity.class); + } StartConversationActivity.addInviteUri(intent, activity.getIntent()); return intent; } @@ -27,6 +37,9 @@ public class SignupUtils { if (pendingAccount != null) { intent = new Intent(activity, EditAccountActivity.class); intent.putExtra("jid", pendingAccount.getJid().asBareJid().toString()); + if (!pendingAccount.isOptionSet(Account.OPTION_MAGIC_CREATE)) { + intent.putExtra(EditAccountActivity.EXTRA_FORCE_REGISTER, pendingAccount.isOptionSet(Account.OPTION_REGISTER)); + } } else { if (service.getAccounts().size() == 0) { if (Config.X509_VERIFICATION) { diff --git a/src/conversations/res/layout/activity_pick_server.xml b/src/conversations/res/layout/activity_pick_server.xml new file mode 100644 index 000000000..16be52ec4 --- /dev/null +++ b/src/conversations/res/layout/activity_pick_server.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + +