Skip to content
Snippets Groups Projects
Commit 122f1910 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

account wizard: handle state loss

Change-Id: I6a2492e13f68af0558134073382b90de47d05a16
parent 98fbf60a
No related branches found
No related tags found
No related merge requests found
Showing
with 41 additions and 22 deletions
......@@ -140,7 +140,7 @@ public class RingAccountCreationFragment extends BaseSupportFragment<RingAccount
@OnCheckedChanged(R.id.switch_ring_username)
public void onCheckedChanged(boolean isChecked) {
presenter.ringCheckChanged(isChecked);
presenter.registerUsernameChanged(isChecked);
}
@OnClick(R.id.create_account)
......@@ -250,4 +250,13 @@ public class RingAccountCreationFragment extends BaseSupportFragment<RingAccount
wizard.createAccount(accountCreationModel);
}
}
@Override
public void cancel() {
Activity wizardActivity = getActivity();
if (wizardActivity != null) {
wizardActivity.onBackPressed();
}
}
}
......@@ -119,10 +119,10 @@ public class RingLinkAccountFragment extends BaseSupportFragment<RingLinkAccount
}
@Override
public void finish() {
Activity activity = getActivity();
if(activity != null) {
activity.finish();
public void cancel() {
Activity wizardActivity = getActivity();
if (wizardActivity != null) {
wizardActivity.onBackPressed();
}
}
}
\ No newline at end of file
......@@ -66,7 +66,7 @@ public class TVRingAccountCreationFragment
boolean empty = newName.isEmpty();
/** If the username is empty make sure to set isRegisterUsernameChecked
* to False, this allows to create an account with an empty username */
presenter.ringCheckChanged(!empty);
presenter.registerUsernameChanged(!empty);
/** Send the newName even when empty (in order to reset the views) */
presenter.userNameChanged(newName);
}
......@@ -95,7 +95,7 @@ public class TVRingAccountCreationFragment
}
presenter.init(model);
presenter.ringCheckChanged(false);
presenter.registerUsernameChanged(false);
}
@Override
......@@ -282,6 +282,14 @@ public class TVRingAccountCreationFragment
}
}
@Override
public void cancel() {
Activity wizardActivity = getActivity();
if (wizardActivity != null) {
wizardActivity.onBackPressed();
}
}
@Override
public void onGuidedActionClicked(GuidedAction action) {
if (action.getId() == CONTINUE) {
......
......@@ -127,11 +127,10 @@ public class TVRingLinkAccountFragment extends RingGuidedStepFragment<RingLinkAc
}
@Override
public void finish() {
Activity activity = getActivity();
if(activity != null) {
activity.finish();
public void cancel() {
Activity wizardActivity = getActivity();
if (wizardActivity != null) {
wizardActivity.onBackPressed();
}
}
}
......@@ -32,7 +32,6 @@ import cx.ring.model.Settings;
import cx.ring.mvp.AccountCreationModel;
import cx.ring.mvp.RootPresenter;
import cx.ring.services.AccountService;
import cx.ring.services.DeviceRuntimeService;
import cx.ring.services.PreferencesService;
import cx.ring.utils.Log;
import cx.ring.utils.StringUtils;
......@@ -46,7 +45,6 @@ public class AccountWizardPresenter extends RootPresenter<AccountWizardView> {
public static final String TAG = AccountWizardPresenter.class.getSimpleName();
private final AccountService mAccountService;
private final DeviceRuntimeService mDeviceRuntimeService;
private final PreferencesService mPreferences;
private final Scheduler mUiScheduler;
......@@ -58,9 +56,8 @@ public class AccountWizardPresenter extends RootPresenter<AccountWizardView> {
private Observable<Account> newAccount;
@Inject
public AccountWizardPresenter(AccountService accountService, DeviceRuntimeService deviceRuntimeService, PreferencesService preferences, @Named("UiScheduler") Scheduler uiScheduler) {
public AccountWizardPresenter(AccountService accountService, PreferencesService preferences, @Named("UiScheduler") Scheduler uiScheduler) {
mAccountService = accountService;
mDeviceRuntimeService = deviceRuntimeService;
mPreferences = preferences;
mUiScheduler = uiScheduler;
}
......
......@@ -66,6 +66,9 @@ public class RingAccountCreationPresenter extends RootPresenter<RingAccountCreat
}
public void init(AccountCreationModel accountCreationModel) {
if (accountCreationModel == null) {
getView().cancel();
}
mAccountCreationModel = accountCreationModel;
}
......@@ -88,13 +91,15 @@ public class RingAccountCreationPresenter extends RootPresenter<RingAccountCreat
}
}
public void ringCheckChanged(boolean isChecked) {
public void registerUsernameChanged(boolean isChecked) {
getView().displayUsernameBox(isChecked);
isRegisterUsernameChecked = isChecked;
if (!isChecked) {
mAccountCreationModel.setUsername("");
if (mAccountCreationModel != null) {
if (!isChecked) {
mAccountCreationModel.setUsername("");
}
checkForms();
}
checkForms();
}
public void passwordChanged(String password) {
......
......@@ -44,4 +44,5 @@ public interface RingAccountCreationView {
void goToAccountCreation(AccountCreationModel accountCreationModel);
void cancel();
}
......@@ -35,7 +35,7 @@ public class RingLinkAccountPresenter extends RootPresenter<RingLinkAccountView>
public void init(AccountCreationModel accountCreationModel) {
mAccountCreationModel = accountCreationModel;
if (mAccountCreationModel == null) {
getView().finish();
getView().cancel();
return;
}
......
......@@ -29,5 +29,5 @@ public interface RingLinkAccountView {
void createAccount(AccountCreationModel accountCreationModel);
void finish();
void cancel();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment