Merge "Fix keyboard showing after dialog dismissed" into udc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
01f1f74c07
@@ -80,6 +80,8 @@ public class CreateUserDialogController {
|
|||||||
private Bitmap mSavedPhoto;
|
private Bitmap mSavedPhoto;
|
||||||
private String mSavedName;
|
private String mSavedName;
|
||||||
private Drawable mSavedDrawable;
|
private Drawable mSavedDrawable;
|
||||||
|
private String mUserName;
|
||||||
|
private Drawable mNewUserIcon;
|
||||||
private Boolean mIsAdmin;
|
private Boolean mIsAdmin;
|
||||||
private Dialog mUserCreationDialog;
|
private Dialog mUserCreationDialog;
|
||||||
private View mGrantAdminView;
|
private View mGrantAdminView;
|
||||||
@@ -89,6 +91,7 @@ public class CreateUserDialogController {
|
|||||||
private ActivityStarter mActivityStarter;
|
private ActivityStarter mActivityStarter;
|
||||||
private boolean mWaitingForActivityResult;
|
private boolean mWaitingForActivityResult;
|
||||||
private NewUserData mSuccessCallback;
|
private NewUserData mSuccessCallback;
|
||||||
|
private Runnable mCancelCallback;
|
||||||
|
|
||||||
private final String mFileAuthority;
|
private final String mFileAuthority;
|
||||||
|
|
||||||
@@ -113,6 +116,7 @@ public class CreateUserDialogController {
|
|||||||
mEditUserInfoView = null;
|
mEditUserInfoView = null;
|
||||||
mUserNameView = null;
|
mUserNameView = null;
|
||||||
mSuccessCallback = null;
|
mSuccessCallback = null;
|
||||||
|
mCancelCallback = null;
|
||||||
mCurrentState = INITIAL_DIALOG;
|
mCurrentState = INITIAL_DIALOG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,14 +188,12 @@ public class CreateUserDialogController {
|
|||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mCustomDialogHelper = new CustomDialogHelper(activity);
|
mCustomDialogHelper = new CustomDialogHelper(activity);
|
||||||
mSuccessCallback = successCallback;
|
mSuccessCallback = successCallback;
|
||||||
|
mCancelCallback = cancelCallback;
|
||||||
mActivityStarter = activityStarter;
|
mActivityStarter = activityStarter;
|
||||||
addCustomViews(isMultipleAdminEnabled);
|
addCustomViews(isMultipleAdminEnabled);
|
||||||
mUserCreationDialog = mCustomDialogHelper.getDialog();
|
mUserCreationDialog = mCustomDialogHelper.getDialog();
|
||||||
updateLayout();
|
updateLayout();
|
||||||
mUserCreationDialog.setOnDismissListener(view -> {
|
mUserCreationDialog.setOnDismissListener(view -> finish());
|
||||||
cancelCallback.run();
|
|
||||||
clear();
|
|
||||||
});
|
|
||||||
mCustomDialogHelper.setMessagePadding(MESSAGE_PADDING);
|
mCustomDialogHelper.setMessagePadding(MESSAGE_PADDING);
|
||||||
mUserCreationDialog.setCanceledOnTouchOutside(true);
|
mUserCreationDialog.setCanceledOnTouchOutside(true);
|
||||||
return mUserCreationDialog;
|
return mUserCreationDialog;
|
||||||
@@ -269,20 +271,14 @@ public class CreateUserDialogController {
|
|||||||
mGrantAdminView.setVisibility(View.GONE);
|
mGrantAdminView.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case CREATE_USER_AND_CLOSE:
|
case CREATE_USER_AND_CLOSE:
|
||||||
Drawable newUserIcon = mEditUserPhotoController != null
|
mNewUserIcon = mEditUserPhotoController != null
|
||||||
? mEditUserPhotoController.getNewUserPhotoDrawable()
|
? mEditUserPhotoController.getNewUserPhotoDrawable()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
String newName = mUserNameView.getText().toString().trim();
|
String newName = mUserNameView.getText().toString().trim();
|
||||||
String defaultName = mActivity.getString(R.string.user_new_user_name);
|
String defaultName = mActivity.getString(R.string.user_new_user_name);
|
||||||
String userName = !newName.isEmpty() ? newName : defaultName;
|
mUserName = !newName.isEmpty() ? newName : defaultName;
|
||||||
|
|
||||||
if (mSuccessCallback != null) {
|
|
||||||
mSuccessCallback.onSuccess(userName, newUserIcon,
|
|
||||||
Boolean.TRUE.equals(mIsAdmin));
|
|
||||||
}
|
|
||||||
mCustomDialogHelper.getDialog().dismiss();
|
mCustomDialogHelper.getDialog().dismiss();
|
||||||
clear();
|
|
||||||
break;
|
break;
|
||||||
case EXIT_DIALOG:
|
case EXIT_DIALOG:
|
||||||
mCustomDialogHelper.getDialog().dismiss();
|
mCustomDialogHelper.getDialog().dismiss();
|
||||||
@@ -384,4 +380,20 @@ public class CreateUserDialogController {
|
|||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return mCustomDialogHelper != null && mCustomDialogHelper.getDialog() != null;
|
return mCustomDialogHelper != null && mCustomDialogHelper.getDialog() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs callback and clears saved values after dialog is dismissed.
|
||||||
|
*/
|
||||||
|
public void finish() {
|
||||||
|
if (mCurrentState == CREATE_USER_AND_CLOSE) {
|
||||||
|
if (mSuccessCallback != null) {
|
||||||
|
mSuccessCallback.onSuccess(mUserName, mNewUserIcon, Boolean.TRUE.equals(mIsAdmin));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mCancelCallback != null) {
|
||||||
|
mCancelCallback.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ public class CreateUserDialogControllerTest {
|
|||||||
next.performClick();
|
next.performClick();
|
||||||
verify(successCallback, times(1))
|
verify(successCallback, times(1))
|
||||||
.onSuccess(expectedNewName, null, true);
|
.onSuccess(expectedNewName, null, true);
|
||||||
|
verifyNoInteractions(cancelCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -233,6 +234,7 @@ public class CreateUserDialogControllerTest {
|
|||||||
next.performClick();
|
next.performClick();
|
||||||
verify(successCallback, times(1))
|
verify(successCallback, times(1))
|
||||||
.onSuccess(expectedNewName, null, false);
|
.onSuccess(expectedNewName, null, false);
|
||||||
|
verifyNoInteractions(cancelCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestCreateUserDialogController extends CreateUserDialogController {
|
private class TestCreateUserDialogController extends CreateUserDialogController {
|
||||||
|
|||||||
Reference in New Issue
Block a user