diff --git a/ring-android/app/src/main/java/cx/ring/account/AccountWizardActivity.java b/ring-android/app/src/main/java/cx/ring/account/AccountWizardActivity.java index 94b546695b588263d01f01207000629ee1848816..be28b404f18db7188046334d226380dd137d0c5c 100644 --- a/ring-android/app/src/main/java/cx/ring/account/AccountWizardActivity.java +++ b/ring-android/app/src/main/java/cx/ring/account/AccountWizardActivity.java @@ -33,6 +33,7 @@ import android.text.TextUtils; import android.widget.Toast; import java.io.File; +import java.util.List; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -157,6 +158,13 @@ public class AccountWizardActivity extends BaseActivity<AccountWizardPresenter> @Override public void goToProfileCreation(AccountCreationModel model) { + List<Fragment> fragments = getSupportFragmentManager().getFragments(); + if (fragments.size() > 0) { + Fragment fragment =fragments.get(0); + if (fragment instanceof JamiLinkAccountFragment) { + ((JamiLinkAccountFragment) fragment).scrollPagerFragment(model); + } + } } @Override diff --git a/ring-android/app/src/main/java/cx/ring/account/JamiAccountCreationFragment.java b/ring-android/app/src/main/java/cx/ring/account/JamiAccountCreationFragment.java index ef86e215321aeee872df9e1fe0b680020910eda7..d5bfb25d7124f09b87206da2ced060431b3d6842 100644 --- a/ring-android/app/src/main/java/cx/ring/account/JamiAccountCreationFragment.java +++ b/ring-android/app/src/main/java/cx/ring/account/JamiAccountCreationFragment.java @@ -63,7 +63,6 @@ public class JamiAccountCreationFragment extends BaseSupportFragment { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mBinding = FragAccJamiCreateBinding.inflate(inflater, container, false); - mBinding.pager.setOffscreenPageLimit(NUM_PAGES); return mBinding.getRoot(); } diff --git a/ring-android/app/src/main/java/cx/ring/account/JamiLinkAccountFragment.java b/ring-android/app/src/main/java/cx/ring/account/JamiLinkAccountFragment.java index 9a0f4cfc945dd90feec498e72548234f3adb13a4..8429f604ea6b42f47667348ee4690e7a87abbae4 100644 --- a/ring-android/app/src/main/java/cx/ring/account/JamiLinkAccountFragment.java +++ b/ring-android/app/src/main/java/cx/ring/account/JamiLinkAccountFragment.java @@ -20,16 +20,23 @@ package cx.ring.account; import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; +import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; +import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.ViewPager; import cx.ring.R; import cx.ring.application.JamiApplication; @@ -37,12 +44,27 @@ import cx.ring.databinding.FragAccJamiLinkBinding; import cx.ring.mvp.BaseSupportFragment; import cx.ring.mvp.AccountCreationModel; -public class JamiLinkAccountFragment extends BaseSupportFragment<JamiLinkAccountPresenter> - implements JamiLinkAccountView { +public class JamiLinkAccountFragment extends BaseSupportFragment { public static final String TAG = JamiLinkAccountFragment.class.getSimpleName(); private AccountCreationModel model; - private FragAccJamiLinkBinding binding; + private FragAccJamiLinkBinding mBinding; + private Fragment mCurrentFragment; + + private static final int NUM_PAGES = 2; + + private final OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(false) { + @Override + public void handleOnBackPressed() { + if (mCurrentFragment instanceof ProfileCreationFragment) { + ProfileCreationFragment fragment = (ProfileCreationFragment) mCurrentFragment; + ((AccountWizardActivity) getActivity()).profileCreated(fragment.getModel(), false); + return; + } + mBinding.pager.setCurrentItem(mBinding.pager.getCurrentItem() - 1); + } + }; + public static JamiLinkAccountFragment newInstance(AccountCreationModelImpl ringAccountViewModel) { JamiLinkAccountFragment fragment = new JamiLinkAccountFragment(); @@ -53,80 +75,110 @@ public class JamiLinkAccountFragment extends BaseSupportFragment<JamiLinkAccount @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - binding = FragAccJamiLinkBinding.inflate(inflater, container, false); - ((JamiApplication) getActivity().getApplication()).getInjectionComponent().inject(this); - return binding.getRoot(); + mBinding = FragAccJamiLinkBinding.inflate(inflater, container, false); + return mBinding.getRoot(); } @Override public void onDestroyView() { super.onDestroyView(); - binding = null; + mBinding = null; } @Override public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - binding.linkButton.setOnClickListener(v -> presenter.linkClicked()); - binding.ringAddPin.setOnEditorActionListener((v, actionId, event) -> { - if (actionId == EditorInfo.IME_ACTION_DONE) { - presenter.linkClicked(); - } - return false; - }); - binding.ringAddPin.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} + JamiLinkAccountFragment.ScreenSlidePagerAdapter pagerAdapter = new JamiLinkAccountFragment.ScreenSlidePagerAdapter(getChildFragmentManager(), model); + mBinding.pager.setAdapter(pagerAdapter); + mBinding.pager.disableScroll(true); + mBinding.pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override - public void afterTextChanged(Editable s) { - presenter.pinChanged(s.toString()); + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } - }); - binding.ringExistingPassword.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override - public void onTextChanged(CharSequence s, int start, int before, int count) {} + public void onPageSelected(int position) { + mCurrentFragment = pagerAdapter.getRegisteredFragment(position); + onBackPressedCallback.setEnabled(mCurrentFragment instanceof ProfileCreationFragment); + } @Override - public void afterTextChanged(Editable s) { - presenter.passwordChanged(s.toString()); + public void onPageScrollStateChanged(int state) { + } }); - } - @Override - protected void initPresenter(JamiLinkAccountPresenter presenter) { - presenter.init(model); } @Override - public void enableLinkButton(boolean enable) { - binding.linkButton.setEnabled(enable); + public void onAttach(@NonNull Context context) { + super.onAttach(context); + requireActivity().getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback); } - @Override - public void showPin(boolean show) { - binding.pinBox.setVisibility(show ? View.VISIBLE : View.GONE); - binding.pinHelpMessage.setVisibility(show ? View.VISIBLE : View.GONE); - binding.linkButton.setText(show ? R.string.account_link_device : R.string.account_link_archive_button); + public void scrollPagerFragment(AccountCreationModel accountCreationModel) { + if (accountCreationModel == null) { + mBinding.pager.setCurrentItem(mBinding.pager.getCurrentItem() - 1); + return; + } + mBinding.pager.setCurrentItem(mBinding.pager.getCurrentItem() + 1); + for (Fragment fragment : getChildFragmentManager().getFragments()) { + if (fragment instanceof JamiAccountPasswordFragment) { + ((JamiAccountPasswordFragment) fragment).setUsername(accountCreationModel.getUsername()); + } + } } - @Override - public void createAccount(AccountCreationModel accountCreationModel) { - ((AccountWizardActivity) requireActivity()).createAccount(accountCreationModel); - } + private static class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter { - @Override - public void cancel() { - Activity wizardActivity = getActivity(); - if (wizardActivity != null) { - wizardActivity.onBackPressed(); + AccountCreationModelImpl ringAccountViewModel; + SparseArray<Fragment> mRegisteredFragments = new SparseArray<>(); + + public ScreenSlidePagerAdapter(FragmentManager fm, AccountCreationModel model) { + super(fm); + ringAccountViewModel = (AccountCreationModelImpl) model; + } + + @Override + public Fragment getItem(int position) { + Fragment fragment = null; + + switch (position) { + case 0: + fragment = JamiLinkAccountPasswordFragment.newInstance(ringAccountViewModel); + break; + case 1: + fragment = ProfileCreationFragment.newInstance(ringAccountViewModel); + break; + } + + return fragment; + } + + @NonNull + @Override + public Object instantiateItem(@NonNull ViewGroup container, int position) { + Fragment fragment = (Fragment) super.instantiateItem(container, position); + mRegisteredFragments.put(position, fragment); + return super.instantiateItem(container, position); + } + + @Override + public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { + mRegisteredFragments.remove(position); + super.destroyItem(container, position, object); + } + + @Override + public int getCount() { + return NUM_PAGES; + } + + public Fragment getRegisteredFragment(int position) { + return mRegisteredFragments.get(position); } } + } \ No newline at end of file diff --git a/ring-android/app/src/main/java/cx/ring/account/JamiLinkAccountPasswordFragment.java b/ring-android/app/src/main/java/cx/ring/account/JamiLinkAccountPasswordFragment.java new file mode 100644 index 0000000000000000000000000000000000000000..29e52e6d9efd97268e3bc1d5d175d2ef49153480 --- /dev/null +++ b/ring-android/app/src/main/java/cx/ring/account/JamiLinkAccountPasswordFragment.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2004-2020 Savoir-faire Linux Inc. + * + * Authors: AmirHossein Naghshzan <amirhossein.naghshzan@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package cx.ring.account; + +import android.app.Activity; +import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; +import android.util.SparseArray; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.EditorInfo; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentStatePagerAdapter; + +import cx.ring.R; +import cx.ring.application.JamiApplication; +import cx.ring.databinding.FragAccJamiLinkBinding; +import cx.ring.databinding.FragAccJamiLinkPasswordBinding; +import cx.ring.mvp.AccountCreationModel; +import cx.ring.mvp.BaseSupportFragment; + +public class JamiLinkAccountPasswordFragment extends BaseSupportFragment<JamiLinkAccountPresenter> + implements JamiLinkAccountView { + + public static final String TAG = JamiLinkAccountPasswordFragment.class.getSimpleName(); + private AccountCreationModel model; + private FragAccJamiLinkPasswordBinding mBinding; + + public static JamiLinkAccountPasswordFragment newInstance(AccountCreationModel ringAccountViewModel) { + JamiLinkAccountPasswordFragment fragment = new JamiLinkAccountPasswordFragment(); + fragment.model = ringAccountViewModel; + return fragment; + } + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + mBinding = FragAccJamiLinkPasswordBinding.inflate(inflater, container, false); + ((JamiApplication) getActivity().getApplication()).getInjectionComponent().inject(this); + return mBinding.getRoot(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + mBinding = null; + } + + @Override + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + mBinding.linkButton.setOnClickListener(v -> presenter.linkClicked()); + mBinding.ringAddPin.setOnEditorActionListener((v, actionId, event) -> { + if (actionId == EditorInfo.IME_ACTION_DONE) { + presenter.linkClicked(); + } + return false; + }); + mBinding.ringAddPin.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + + @Override + public void afterTextChanged(Editable s) { + presenter.pinChanged(s.toString()); + } + }); + mBinding.ringExistingPassword.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + + @Override + public void afterTextChanged(Editable s) { + presenter.passwordChanged(s.toString()); + } + }); + } + + @Override + protected void initPresenter(JamiLinkAccountPresenter presenter) { + presenter.init(model); + } + + @Override + public void enableLinkButton(boolean enable) { + mBinding.linkButton.setEnabled(enable); + } + + @Override + public void showPin(boolean show) { + mBinding.pinBox.setVisibility(show ? View.VISIBLE : View.GONE); + mBinding.pinHelpMessage.setVisibility(show ? View.VISIBLE : View.GONE); + mBinding.linkButton.setText(show ? R.string.account_link_device : R.string.account_link_archive_button); + } + + @Override + public void createAccount(AccountCreationModel accountCreationModel) { + ((AccountWizardActivity) requireActivity()).createAccount(accountCreationModel); + } + + @Override + public void cancel() { + Activity wizardActivity = getActivity(); + if (wizardActivity != null) { + wizardActivity.onBackPressed(); + } + } + +} \ No newline at end of file diff --git a/ring-android/app/src/main/java/cx/ring/dependencyinjection/JamiInjectionComponent.java b/ring-android/app/src/main/java/cx/ring/dependencyinjection/JamiInjectionComponent.java index 029ab965579b865cde659707e2ade43a5d7a3580..e4ff71bb389753937951d06f3847e5cac62ca90d 100755 --- a/ring-android/app/src/main/java/cx/ring/dependencyinjection/JamiInjectionComponent.java +++ b/ring-android/app/src/main/java/cx/ring/dependencyinjection/JamiInjectionComponent.java @@ -24,6 +24,7 @@ import javax.inject.Singleton; import cx.ring.account.AccountEditionFragment; import cx.ring.account.JamiAccountPasswordFragment; import cx.ring.account.JamiAccountUsernameFragment; +import cx.ring.account.JamiLinkAccountPasswordFragment; import cx.ring.fragments.LocationSharingFragment; import cx.ring.account.AccountWizardActivity; import cx.ring.account.HomeAccountCreationFragment; @@ -118,8 +119,6 @@ public interface JamiInjectionComponent { void inject(ConversationSelectionActivity fragment); -// void inject(JamiAccountCreationFragment fragment); - void inject(JamiAccountUsernameFragment fragment); void inject(JamiAccountPasswordFragment fragment); @@ -178,7 +177,7 @@ public interface JamiInjectionComponent { void inject(HomeAccountCreationFragment fragment); - void inject(JamiLinkAccountFragment fragment); + void inject(JamiLinkAccountPasswordFragment fragment); void inject(JamiAccountConnectFragment fragment); diff --git a/ring-android/app/src/main/res/layout/frag_acc_jami_link.xml b/ring-android/app/src/main/res/layout/frag_acc_jami_link.xml index e426708eae739fa9b602354bbaa5e1eb929d4318..2ee017ba89522e2c528eff93a8092c01114f0a61 100644 --- a/ring-android/app/src/main/res/layout/frag_acc_jami_link.xml +++ b/ring-android/app/src/main/res/layout/frag_acc_jami_link.xml @@ -47,115 +47,16 @@ android:orientation="horizontal" app:layout_constraintGuide_percent="0.4" /> - <androidx.cardview.widget.CardView + <cx.ring.views.WizardViewPager + android:id="@+id/pager" android:layout_width="@dimen/wizard_card_width" - android:layout_height="wrap_content" - android:background="@color/white" - app:cardCornerRadius="12dp" + android:layout_height="@dimen/wizard_card_height" app:layout_constraintTop_toBottomOf="@+id/pager_guideline" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_gravity="center" android:clipChildren="false" - android:clipToPadding="false"> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical" - android:padding="@dimen/wizard_card_padding"> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="8dp"> - - <TextView - android:id="@+id/info" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_toLeftOf="@id/status" - android:layout_centerVertical="true" - android:layout_marginRight="4dp" - android:textStyle="bold" - android:text="@string/help_password_enter" /> - - <TextView - android:id="@+id/status" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:text="@string/wizard_status_required" - android:textSize="12sp" - android:textStyle="bold" - android:textColor="#ff1f62" - android:background="@drawable/background_status" - android:padding="6dp"/> - - </RelativeLayout> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/password_txt_box" - android:layout_width="match_parent" - android:layout_height="wrap_content" - app:passwordToggleEnabled="true" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/ring_existing_password" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/prompt_password" - android:drawableStart="@drawable/baseline_lock_24" - android:drawablePadding="5dp" - android:imeOptions="actionNext" - android:inputType="textPassword" /> - </com.google.android.material.textfield.TextInputLayout> - - - <TextView - android:id="@+id/pin_help_message" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingTop="16dp" - android:paddingBottom="8dp" - android:text="@string/help_pin_enter" /> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/pin_box" - android:layout_width="match_parent" - android:layout_height="wrap_content" - app:passwordToggleEnabled="true" - style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/ring_add_pin" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/account_link_prompt_pin" - android:drawableStart="@drawable/baseline_lock_24" - android:drawablePadding="5dp" - android:imeOptions="actionDone" - android:inputType="textNoSuggestions" - android:singleLine="true" /> - - </com.google.android.material.textfield.TextInputLayout> - - <com.google.android.material.button.MaterialButton - android:id="@+id/link_button" - style="@style/WizardButton" - android:layout_width="250dp" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" - android:enabled="false" - android:textSize="12sp" - android:layout_marginTop="18dp" - android:text="@string/account_link_button" - android:theme="@style/ButtonColoredInverse" /> - - </LinearLayout> + android:clipToPadding="false" /> - </androidx.cardview.widget.CardView> </androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file diff --git a/ring-android/app/src/main/res/layout/frag_acc_jami_link_password.xml b/ring-android/app/src/main/res/layout/frag_acc_jami_link_password.xml new file mode 100644 index 0000000000000000000000000000000000000000..1431c5194e23f8f6b75a978260dc97c9d93f6aec --- /dev/null +++ b/ring-android/app/src/main/res/layout/frag_acc_jami_link_password.xml @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2004-2020 Savoir-faire Linux Inc. + ~ + ~ Authors: AmirHossein Naghshzan <amirhossein.naghshzan@savoirfairelinux.com> + ~ + ~ This program is free software; you can redistribute it and/or modify + ~ it under the terms of the GNU General Public License as published by + ~ the Free Software Foundation; either version 3 of the License, or + ~ (at your option) any later version. + ~ + ~ This program is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ~ GNU General Public License for more details. + ~ + ~ You should have received a copy of the GNU General Public License + ~ along with this program; if not, write to the Free Software + ~ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + --> + +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" + tools:context="cx.ring.account.AccountWizardActivity"> + + <androidx.cardview.widget.CardView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:background="@color/white" + app:cardCornerRadius="12dp" + android:clipChildren="false" + android:clipToPadding="false"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="@dimen/wizard_card_padding"> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="8dp"> + + <TextView + android:id="@+id/info" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_toLeftOf="@id/status" + android:layout_centerVertical="true" + android:layout_marginRight="4dp" + android:textStyle="bold" + android:text="@string/help_password_enter" /> + + <TextView + android:id="@+id/status" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:layout_alignParentTop="true" + android:text="@string/wizard_status_required" + android:textSize="12sp" + android:textStyle="bold" + android:textColor="#ff1f62" + android:background="@drawable/background_status" + android:padding="6dp"/> + + </RelativeLayout> + + <com.google.android.material.textfield.TextInputLayout + android:id="@+id/password_txt_box" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:passwordToggleEnabled="true" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> + + <com.google.android.material.textfield.TextInputEditText + android:id="@+id/ring_existing_password" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/prompt_password" + android:drawableStart="@drawable/baseline_lock_24" + android:drawablePadding="5dp" + android:imeOptions="actionNext" + android:inputType="textPassword" /> + </com.google.android.material.textfield.TextInputLayout> + + + <TextView + android:id="@+id/pin_help_message" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dp" + android:paddingBottom="8dp" + android:text="@string/help_pin_enter" /> + + <com.google.android.material.textfield.TextInputLayout + android:id="@+id/pin_box" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:passwordToggleEnabled="true" + style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"> + + <com.google.android.material.textfield.TextInputEditText + android:id="@+id/ring_add_pin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:hint="@string/account_link_prompt_pin" + android:drawableStart="@drawable/baseline_lock_24" + android:drawablePadding="5dp" + android:imeOptions="actionDone" + android:inputType="textNoSuggestions" + android:singleLine="true" /> + + </com.google.android.material.textfield.TextInputLayout> + + <com.google.android.material.button.MaterialButton + android:id="@+id/link_button" + style="@style/WizardButton" + android:layout_width="250dp" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:enabled="false" + android:textSize="12sp" + android:layout_marginTop="18dp" + android:text="@string/account_link_button" + android:theme="@style/ButtonColoredInverse" /> + + </LinearLayout> + + </androidx.cardview.widget.CardView> + +</FrameLayout> \ No newline at end of file diff --git a/ring-android/libringclient/src/main/java/cx/ring/account/AccountWizardPresenter.java b/ring-android/libringclient/src/main/java/cx/ring/account/AccountWizardPresenter.java index c53aaf7d8698351ebb463237a7bafb94d1c934c2..c4ee789bb8df1ddc154f6e35e0504bcb6b15216b 100644 --- a/ring-android/libringclient/src/main/java/cx/ring/account/AccountWizardPresenter.java +++ b/ring-android/libringclient/src/main/java/cx/ring/account/AccountWizardPresenter.java @@ -96,10 +96,10 @@ public class AccountWizardPresenter extends RootPresenter<AccountWizardView> { public void initRingAccountCreation(AccountCreationModel accountCreationModel, String defaultAccountName) { Single<Map<String, String>> newAccount = initRingAccountDetails(defaultAccountName) .map(accountDetails -> { - if (!accountCreationModel.getUsername().isEmpty()) { + if (!StringUtils.isEmpty(accountCreationModel.getUsername())) { accountDetails.put(ConfigKey.ACCOUNT_REGISTERED_NAME.key(), accountCreationModel.getUsername()); } - if (!accountCreationModel.getPassword().isEmpty()) { + if (!StringUtils.isEmpty(accountCreationModel.getPassword())) { accountDetails.put(ConfigKey.ARCHIVE_PASSWORD.key(), accountCreationModel.getPassword()); } if (accountCreationModel.isPush()) { @@ -168,8 +168,6 @@ public class AccountWizardPresenter extends RootPresenter<AccountWizardView> { getView().displayProgress(false); getView().displayCannotBeFoundError(); })); - } else { - getView().goToProfileCreation(accountCreationModel); } }