Merge pull request #5757 from nextcloud/ezaquarii/migrate-edit-share-fragment-to-user

Migrate EditShareFragment to new User model
This commit is contained in:
Tobias Kaminsky 2020-04-08 13:47:35 +02:00 committed by GitHub
commit 1d8e5a2648
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

View file

@ -176,7 +176,7 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
public void showEditShare(OCShare share) { public void showEditShare(OCShare share) {
// replace current fragment with EditShareFragment on demand // replace current fragment with EditShareFragment on demand
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment editShareFragment = EditShareFragment.newInstance(share, getFile(), getAccount()); Fragment editShareFragment = EditShareFragment.newInstance(share, getFile(), accountManager.getUser());
ft.replace(R.id.share_fragment_container, editShareFragment, TAG_EDIT_SHARE_FRAGMENT); ft.replace(R.id.share_fragment_container, editShareFragment, TAG_EDIT_SHARE_FRAGMENT);
ft.addToBackStack(null); // BACK button will recover the previous fragment ft.addToBackStack(null); // BACK button will recover the previous fragment
ft.commit(); ft.commit();

View file

@ -20,7 +20,6 @@
package com.owncloud.android.ui.fragment; package com.owncloud.android.ui.fragment;
import android.accounts.Account;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -30,6 +29,7 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.TextView; import android.widget.TextView;
import com.nextcloud.client.account.User;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
@ -54,7 +54,7 @@ public class EditShareFragment extends Fragment {
/** The fragment initialization parameters */ /** The fragment initialization parameters */
private static final String ARG_SHARE = "SHARE"; private static final String ARG_SHARE = "SHARE";
private static final String ARG_FILE = "FILE"; private static final String ARG_FILE = "FILE";
private static final String ARG_ACCOUNT = "ACCOUNT"; private static final String ARG_USER = "USER";
/** Ids of CheckBoxes depending on R.id.canEdit CheckBox */ /** Ids of CheckBoxes depending on R.id.canEdit CheckBox */
private static final int sSubordinateCheckBoxIds[] = { private static final int sSubordinateCheckBoxIds[] = {
@ -70,7 +70,7 @@ public class EditShareFragment extends Fragment {
private OCFile mFile; private OCFile mFile;
/** Account of the shared file, received as a parameter in construction time */ /** Account of the shared file, received as a parameter in construction time */
private Account mAccount; private User user;
/** /**
* Capabilities of the server. * Capabilities of the server.
@ -85,15 +85,15 @@ public class EditShareFragment extends Fragment {
* *
* @param shareToEdit An {@link OCShare} to show and edit in the fragment * @param shareToEdit An {@link OCShare} to show and edit in the fragment
* @param sharedFile The {@link OCFile} bound to 'shareToEdit' * @param sharedFile The {@link OCFile} bound to 'shareToEdit'
* @param account The ownCloud account holding 'sharedFile' * @param user User holding 'sharedFile'
* @return A new instance of fragment EditShareFragment. * @return A new instance of fragment EditShareFragment.
*/ */
public static EditShareFragment newInstance(OCShare shareToEdit, OCFile sharedFile, Account account) { public static EditShareFragment newInstance(OCShare shareToEdit, OCFile sharedFile, User user) {
EditShareFragment fragment = new EditShareFragment(); EditShareFragment fragment = new EditShareFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putParcelable(ARG_SHARE, shareToEdit); args.putParcelable(ARG_SHARE, shareToEdit);
args.putParcelable(ARG_FILE, sharedFile); args.putParcelable(ARG_FILE, sharedFile);
args.putParcelable(ARG_ACCOUNT, account); args.putParcelable(ARG_USER, user);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
@ -109,11 +109,12 @@ public class EditShareFragment extends Fragment {
mShare = getArguments().getParcelable(ARG_SHARE); mShare = getArguments().getParcelable(ARG_SHARE);
mFile = getArguments().getParcelable(ARG_FILE); mFile = getArguments().getParcelable(ARG_FILE);
/* OC account holding the shared file, received as a parameter in construction time */ /* OC account holding the shared file, received as a parameter in construction time */
mAccount = getArguments().getParcelable(ARG_ACCOUNT); user = getArguments().getParcelable(ARG_USER);
} }
FileDataStorageManager storageManager = new FileDataStorageManager(mAccount, getContext().getContentResolver()); FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(),
mCapabilities = storageManager.getCapability(mAccount.name); getContext().getContentResolver());
mCapabilities = storageManager.getCapability(user.getAccountName());
} }
@ -159,7 +160,7 @@ public class EditShareFragment extends Fragment {
if (getActivity() instanceof FileActivity) { if (getActivity() instanceof FileActivity) {
FileActivity fileActivity = (FileActivity) getActivity(); FileActivity fileActivity = (FileActivity) getActivity();
if (fileActivity.getStorageManager() != null) { if (fileActivity.getStorageManager() != null) {
mCapabilities = fileActivity.getStorageManager().getCapability(mAccount.name); mCapabilities = fileActivity.getStorageManager().getCapability(user.getAccountName());
} }
} }
} }