Resharing toggle hidden if the resharing is disabled in server settings #1177

This commit is contained in:
Victor Nidens 2017-07-28 16:15:02 +03:00 committed by AndyScherzinger
parent bfe2b71210
commit 0991b14904
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B

View file

@ -43,6 +43,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.SharePermissionsBuilder; import com.owncloud.android.lib.resources.shares.SharePermissionsBuilder;
import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.utils.AnalyticsUtils; import com.owncloud.android.utils.AnalyticsUtils;
@ -75,6 +76,11 @@ public class EditShareFragment extends Fragment {
/** 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 Account mAccount;
/**
* Capabilities of the server.
*/
private OCCapability mCapabilities;
/** Listener for changes on privilege checkboxes */ /** Listener for changes on privilege checkboxes */
private CompoundButton.OnCheckedChangeListener mOnPrivilegeChangeListener; private CompoundButton.OnCheckedChangeListener mOnPrivilegeChangeListener;
@ -109,6 +115,8 @@ public class EditShareFragment extends Fragment {
/* 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); mAccount = getArguments().getParcelable(ARG_ACCOUNT);
} }
refreshCapabilitiesFromDB();
} }
@ -144,6 +152,20 @@ public class EditShareFragment extends Fragment {
return view; return view;
} }
/**
* Get known server capabilities from DB
* <p/>
* Depends on the parent Activity provides a {@link com.owncloud.android.datamodel.FileDataStorageManager}
* instance ready to use. If not ready, does nothing.
*/
public void refreshCapabilitiesFromDB() {
if(getActivity() instanceof FileActivity){
FileActivity fileActivity = ((FileActivity)getActivity());
if(fileActivity.getStorageManager() != null){
mCapabilities = fileActivity.getStorageManager().getCapability(mAccount.name);
}
}
}
/** /**
* Updates the UI with the current permissions in the edited {@OCShare} * Updates the UI with the current permissions in the edited {@OCShare}
@ -167,7 +189,10 @@ public class EditShareFragment extends Fragment {
if (isFederated) { if (isFederated) {
shareSwitch.setVisibility(View.INVISIBLE); shareSwitch.setVisibility(View.INVISIBLE);
} else if(mCapabilities != null && mCapabilities.getFilesSharingResharing().isFalse()){
shareSwitch.setVisibility(View.GONE);
} }
shareSwitch.setChecked((sharePermissions & OCShare.SHARE_PERMISSION_FLAG) > 0); shareSwitch.setChecked((sharePermissions & OCShare.SHARE_PERMISSION_FLAG) > 0);
SwitchCompat switchCompat = (SwitchCompat) editShareView.findViewById(R.id.canEditSwitch); SwitchCompat switchCompat = (SwitchCompat) editShareView.findViewById(R.id.canEditSwitch);