commit
3249ab3c96
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
|
@ -136,6 +136,26 @@ public class DialogFragmentIT extends AbstractIT {
|
||||||
showDialog(sut);
|
showDialog(sut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@ScreenshotTest
|
||||||
|
public void testEnforcedPasswordDialog() {
|
||||||
|
if (Looper.myLooper() == null) {
|
||||||
|
Looper.prepare();
|
||||||
|
}
|
||||||
|
SharePasswordDialogFragment sut = SharePasswordDialogFragment.newInstance(new OCFile("/"), true, false);
|
||||||
|
showDialog(sut);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@ScreenshotTest
|
||||||
|
public void testOptionalPasswordDialog() {
|
||||||
|
if (Looper.myLooper() == null) {
|
||||||
|
Looper.prepare();
|
||||||
|
}
|
||||||
|
SharePasswordDialogFragment sut = SharePasswordDialogFragment.newInstance(new OCFile("/"), true, true);
|
||||||
|
showDialog(sut);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
public void testAccountChooserDialog() throws AccountUtils.AccountNotFoundException {
|
public void testAccountChooserDialog() throws AccountUtils.AccountNotFoundException {
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class SendShareDialog extends BottomSheetDialogFragment {
|
||||||
private void shareByLink() {
|
private void shareByLink() {
|
||||||
if (file.isSharedViaLink()) {
|
if (file.isSharedViaLink()) {
|
||||||
((FileActivity) getActivity()).getFileOperationsHelper().getFileWithLink(file);
|
((FileActivity) getActivity()).getFileOperationsHelper().getFileWithLink(file);
|
||||||
} else if (sharingPublicPasswordEnforced) {
|
} else if (sharingPublicPasswordEnforced || sharingPublicAskForPassword) {
|
||||||
// password enforced by server, request to the user before trying to create
|
// password enforced by server, request to the user before trying to create
|
||||||
requestPasswordForShareViaLink();
|
requestPasswordForShareViaLink();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -72,6 +72,23 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
|
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
|
||||||
ThemeButtonUtils.themeBorderlessButton(getResources().getColor(R.color.highlight_textColor_Warning),
|
ThemeButtonUtils.themeBorderlessButton(getResources().getColor(R.color.highlight_textColor_Warning),
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
|
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
|
||||||
|
|
||||||
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
|
||||||
|
String password = binding.sharePassword.getText().toString();
|
||||||
|
|
||||||
|
if (!askForPassword && TextUtils.isEmpty(password)) {
|
||||||
|
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.share_link_empty_password);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (share == null) {
|
||||||
|
setPassword(createShare, file, password);
|
||||||
|
} else {
|
||||||
|
setPassword(share, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
alertDialog.dismiss();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,19 +160,22 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
|
||||||
ThemeColorUtils.primaryColor(getActivity()));
|
ThemeColorUtils.primaryColor(getActivity()));
|
||||||
binding.sharePassword.requestFocus();
|
binding.sharePassword.requestFocus();
|
||||||
|
|
||||||
|
int negativeButtonCaption;
|
||||||
int title;
|
int title;
|
||||||
if (askForPassword) {
|
if (askForPassword) {
|
||||||
title = R.string.share_link_optional_password_title;
|
title = R.string.share_link_optional_password_title;
|
||||||
|
negativeButtonCaption = R.string.common_skip;
|
||||||
} else {
|
} else {
|
||||||
title = R.string.share_link_password_title;
|
title = R.string.share_link_password_title;
|
||||||
|
negativeButtonCaption = R.string.common_cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the dialog
|
// Build the dialog
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
|
||||||
builder.setView(view)
|
builder.setView(view)
|
||||||
.setPositiveButton(R.string.common_ok, this)
|
.setPositiveButton(R.string.common_ok, null)
|
||||||
.setNegativeButton(R.string.common_cancel, this)
|
.setNegativeButton(negativeButtonCaption, this)
|
||||||
.setNeutralButton(R.string.common_delete, this)
|
.setNeutralButton(R.string.common_delete, this)
|
||||||
.setTitle(title);
|
.setTitle(title);
|
||||||
Dialog d = builder.create();
|
Dialog d = builder.create();
|
||||||
|
@ -170,20 +190,7 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == AlertDialog.BUTTON_POSITIVE) {
|
if (which == AlertDialog.BUTTON_NEUTRAL) {
|
||||||
String password = binding.sharePassword.getText().toString();
|
|
||||||
|
|
||||||
if (!askForPassword && TextUtils.isEmpty(password)) {
|
|
||||||
DisplayUtils.showSnackMessage(binding.getRoot(), R.string.share_link_empty_password);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (share == null) {
|
|
||||||
setPassword(createShare, file, password);
|
|
||||||
} else {
|
|
||||||
setPassword(share, password);
|
|
||||||
}
|
|
||||||
} else if (which == AlertDialog.BUTTON_NEUTRAL) {
|
|
||||||
if (share == null) {
|
if (share == null) {
|
||||||
setPassword(createShare, file, null);
|
setPassword(createShare, file, null);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -126,6 +126,7 @@
|
||||||
<string name="common_delete">Delete</string>
|
<string name="common_delete">Delete</string>
|
||||||
<string name="common_send">Send</string>
|
<string name="common_send">Send</string>
|
||||||
<string name="common_share">Share</string>
|
<string name="common_share">Share</string>
|
||||||
|
<string name="common_skip">Skip</string>
|
||||||
<string name="about_title">About</string>
|
<string name="about_title">About</string>
|
||||||
<string name="delete_account">Remove account</string>
|
<string name="delete_account">Remove account</string>
|
||||||
<string name="delete_account_warning">Remove account %s and delete all local files?\n\nDeletion cannot be undone.</string>
|
<string name="delete_account_warning">Remove account %s and delete all local files?\n\nDeletion cannot be undone.</string>
|
||||||
|
|
Loading…
Reference in New Issue