Browse Source

Fix crash on setting password

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 years ago
parent
commit
886d42dc0f

+ 2 - 2
src/main/java/com/owncloud/android/ui/adapter/ShareeListAdapter.java

@@ -334,7 +334,7 @@ public class ShareeListAdapter extends RecyclerView.Adapter<ShareeListAdapter.Us
                 return true;
             }
             case R.id.action_password: {
-                listener.requestPasswordForShare(share);
+                listener.requestPasswordForShare(share, false);
                 return true;
             }
             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
          */
-        void requestPasswordForShare(OCShare share);
+        void requestPasswordForShare(OCShare share, boolean askForPassword);
     }
 }

+ 17 - 2
src/main/java/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java

@@ -96,7 +96,22 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
     /**
      * Public factory method to create new SharePasswordDialogFragment instances.
      *
-     * @param share        OCFile bound to the public share that which password will be set or updated
+     * @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.
+     *
+     * @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) {
@@ -195,7 +210,7 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
         if (createShare) {
             ((FileActivity) getActivity()).getFileOperationsHelper().shareFileViaPublicShare(file, password);
         } else {
-            ((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToPublicShare(share, password);
+            ((FileActivity) getActivity()).getFileOperationsHelper().setPasswordToShare(share, password);
         }
     }
 

+ 4 - 4
src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java

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