Remove button order logic from dialog

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-10-16 10:44:55 +02:00 committed by Tobias Kaminsky
parent 917959cc5a
commit aa0608561a
2 changed files with 6 additions and 21 deletions

View file

@ -528,9 +528,7 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList
// to the ownCloud folder instead of copying
String[] args = {getString(R.string.app_name)};
ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(
R.string.upload_query_move_foreign_files, args, 0, R.string.common_yes, -1,
R.string.common_no
);
R.string.upload_query_move_foreign_files, args, 0, R.string.common_yes, R.string.common_no, -1);
dialog.setOnConfirmationListener(this);
dialog.show(getSupportFragmentManager(), QUERY_TO_MOVE_DIALOG_TAG);
}

View file

@ -63,7 +63,7 @@ public class ConfirmationDialogFragment extends DialogFragment implements Inject
* @return Dialog ready to show.
*/
public static ConfirmationDialogFragment newInstance(int messageResId, String[] messageArguments, int titleResId,
int positiveButtonTextId, int neutralButtonTextId, int negativeButtonTextId) {
int positiveButtonTextId, int negativeButtonTextId, int neutralButtonTextId) {
if (messageResId == -1) {
throw new IllegalStateException("Calling confirmation dialog without message resource");
}
@ -156,29 +156,16 @@ public class ConfirmationDialogFragment extends DialogFragment implements Inject
dialog.dismiss();
});
}
if (negativeButtonTextId != -1 && neutralButtonTextId == -1) {
if (negativeButtonTextId != -1) {
builder.setNegativeButton(negativeButtonTextId, (dialog, which) -> {
if (mListener != null) {
mListener.onCancel(getTag());
}
dialog.dismiss();
});
} else if (neutralButtonTextId != -1 && negativeButtonTextId == -1) {
builder.setNegativeButton(neutralButtonTextId, (dialog, which) -> {
if (mListener != null) {
mListener.onNeutral(getTag());
}
dialog.dismiss();
});
} else {
builder.setNegativeButton(negativeButtonTextId, (dialog, which) -> {
if (mListener != null) {
mListener.onCancel(getTag());
}
dialog.dismiss();
});
builder.setNeutralButton(neutralButtonTextId, (dialog, whichButton) -> {
}
if (neutralButtonTextId != -1) {
builder.setNeutralButton(neutralButtonTextId, (dialog, which) -> {
if (mListener != null) {
mListener.onNeutral(getTag());
}