Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ded76c2 authored by João Victor Mendes Freire's avatar João Victor Mendes Freire
Browse files

Fix creating multiple users from same alert dialog

Disable the button listeners after the first click to
avoid the creation of more than one user per dialog.

Bug: 252831574
Test: Manually tested by calling the API from a regular app
Change-Id: I6d343ae0a2a4d81d35a85f51a60c88c0c18dba21
parent b5a16024
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ public class ConfirmUserCreationActivity extends AlertActivity
    private String mAccountType;
    private String mAccountType;
    private PersistableBundle mAccountOptions;
    private PersistableBundle mAccountOptions;
    private boolean mCanProceed;
    private boolean mCanProceed;
    private boolean mIsFirstClick;
    private UserManager mUserManager;
    private UserManager mUserManager;


    @Override
    @Override
@@ -82,6 +83,7 @@ public class ConfirmUserCreationActivity extends AlertActivity
            ap.mNegativeButtonText = getString(android.R.string.cancel);
            ap.mNegativeButtonText = getString(android.R.string.cancel);
            ap.mNegativeButtonListener = this;
            ap.mNegativeButtonListener = this;
        }
        }
        mIsFirstClick = true;
        setupAlert();
        setupAlert();
    }
    }


@@ -128,7 +130,8 @@ public class ConfirmUserCreationActivity extends AlertActivity
    @Override
    @Override
    public void onClick(DialogInterface dialog, int which) {
    public void onClick(DialogInterface dialog, int which) {
        setResult(RESULT_CANCELED);
        setResult(RESULT_CANCELED);
        if (which == BUTTON_POSITIVE && mCanProceed) {
        if (which == BUTTON_POSITIVE && mCanProceed && mIsFirstClick) {
            mIsFirstClick = false;
            Log.i(TAG, "Ok, creating user");
            Log.i(TAG, "Ok, creating user");
            UserInfo user = mUserManager.createUser(mUserName, USER_TYPE, 0);
            UserInfo user = mUserManager.createUser(mUserName, USER_TYPE, 0);
            if (user == null) {
            if (user == null) {