Merge pull request #6760 from nextcloud/passwortToShare

Fix crash on setting password
This commit is contained in:
Andy Scherzinger 2020-08-20 14:00:11 +02:00 committed by GitHub
commit dcf7455e57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 8 deletions

View file

@ -334,7 +334,7 @@ public class ShareeListAdapter extends RecyclerView.Adapter<ShareeListAdapter.Us
return true; return true;
} }
case R.id.action_password: { case R.id.action_password: {
listener.requestPasswordForShare(share); listener.requestPasswordForShare(share, false);
return true; return true;
} }
case R.id.action_expiration_date: { case R.id.action_expiration_date: {
@ -428,6 +428,6 @@ public class ShareeListAdapter extends RecyclerView.Adapter<ShareeListAdapter.Us
* *
* @param share the share for which a password shall be configured/removed * @param share the share for which a password shall be configured/removed
*/ */
void requestPasswordForShare(OCShare share); void requestPasswordForShare(OCShare share, boolean askForPassword);
} }
} }

View file

@ -93,6 +93,21 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
return frag; return frag;
} }
/**
* Public factory method to create new SharePasswordDialogFragment instances.
*
* @param share OCFile bound to the public share that which password will be set or updated
* @return Dialog ready to show.
*/
public static SharePasswordDialogFragment newInstance(OCShare share, boolean askForPassword) {
SharePasswordDialogFragment frag = new SharePasswordDialogFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_SHARE, share);
args.putBoolean(ARG_ASK_FOR_PASSWORD, askForPassword);
frag.setArguments(args);
return frag;
}
/** /**
* Public factory method to create new SharePasswordDialogFragment instances. * Public factory method to create new SharePasswordDialogFragment instances.
* *
@ -195,7 +210,7 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
if (createShare) { if (createShare) {
((FileActivity) getActivity()).getFileOperationsHelper().shareFileViaPublicShare(file, password); ((FileActivity) getActivity()).getFileOperationsHelper().shareFileViaPublicShare(file, password);
} else { } else {
((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToPublicShare(share, password); ((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToShare(share, password);
} }
} }

View file

@ -415,7 +415,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
RenamePublicShareDialogFragment.RENAME_PUBLIC_SHARE_FRAGMENT); RenamePublicShareDialogFragment.RENAME_PUBLIC_SHARE_FRAGMENT);
return true; return true;
case R.id.action_password: { case R.id.action_password: {
requestPasswordForShareViaLink(false, requestPasswordForShare(publicShare,
capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue()); capabilities.getFilesSharingPublicAskForOptionalPassword().isTrue());
return true; return true;
} }
@ -517,8 +517,8 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
} }
@Override @Override
public void requestPasswordForShare(OCShare share) { public void requestPasswordForShare(OCShare share, boolean askForPassword) {
SharePasswordDialogFragment dialog = SharePasswordDialogFragment.newInstance(share); SharePasswordDialogFragment dialog = SharePasswordDialogFragment.newInstance(share, askForPassword);
dialog.show(getChildFragmentManager(), SharePasswordDialogFragment.PASSWORD_FRAGMENT); dialog.show(getChildFragmentManager(), SharePasswordDialogFragment.PASSWORD_FRAGMENT);
} }