Merge pull request #3044 from nextcloud/handlePermissions

Correct handle write protected folders
This commit is contained in:
Andy Scherzinger 2018-09-17 08:12:59 +02:00 committed by GitHub
commit d9ce5b0228
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 19 deletions

View file

@ -59,6 +59,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
private final static String PERMISSION_SHARED_WITH_ME = "S"; // TODO move to better location
private final static String PERMISSION_CAN_RESHARE = "R";
private final static String PERMISSION_CAN_WRITE = "CK";
public static final String PATH_SEPARATOR = "/";
public static final String ROOT_PATH = PATH_SEPARATOR;
@ -784,6 +785,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
return permissions != null && permissions.contains(PERMISSION_CAN_RESHARE);
}
public boolean canWrite() {
String permissions = getPermissions();
return permissions != null && permissions.contains(PERMISSION_CAN_WRITE);
}
public WebdavEntry.MountType getMountType() {
return mMountType;
}

View file

@ -363,6 +363,9 @@ public class RefreshFolderOperation extends RemoteOperation {
boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, mStorageManager);
mLocalFolder.setEncrypted(encryptedAncestor);
// update permission
mLocalFolder.setPermissions(remoteFolder.getPermissions());
DecryptedFolderMetadata metadata = getDecryptedFolderMetadata(encryptedAncestor);
// get current data about local contents of the folder to synchronize

View file

@ -24,6 +24,7 @@ package com.owncloud.android.ui.fragment;
import android.animation.LayoutTransition;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.os.Handler;
@ -208,7 +209,7 @@ public class ExtendedListFragment extends Fragment
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)) {
if (!(getActivity() instanceof UploadFilesActivity)) {
setFabEnabled(!hasFocus);
setFabVisible(!hasFocus);
}
boolean searchSupported = AccountUtils.hasSearchSupport(AccountUtils.
@ -588,21 +589,42 @@ public class ExtendedListFragment extends Fragment
/**
* Sets the 'visibility' state of the FAB contained in the fragment.
* <p>
* When 'false' is set, FAB visibility is set to View.GONE programmatically,
*
* When 'false' is set, FAB visibility is set to View.GONE programmatically.
*
* @param visible Desired visibility for the FAB.
*/
public void setFabVisible(final boolean visible) {
if (getActivity() != null) {
getActivity().runOnUiThread(() -> {
if (visible) {
mFabMain.setVisibility(View.VISIBLE);
ThemeUtils.tintDrawable(mFabMain.getBackground(), ThemeUtils.primaryColor(getContext()));
} else {
mFabMain.setVisibility(View.GONE);
}
});
}
}
/**
* Sets the 'visibility' state of the FAB contained in the fragment.
*
* When 'false' is set, FAB is greyed out
*
* @param enabled Desired visibility for the FAB.
*/
public void setFabEnabled(final boolean enabled) {
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (enabled) {
mFabMain.setVisibility(View.VISIBLE);
} else {
mFabMain.setVisibility(View.GONE);
}
getActivity().runOnUiThread(() -> {
mFabMain.setVisibility(View.VISIBLE);
if (enabled) {
mFabMain.setEnabled(true);
ThemeUtils.tintDrawable(mFabMain.getBackground(), ThemeUtils.primaryColor(getContext()));
} else {
mFabMain.setEnabled(false);
ThemeUtils.tintDrawable(mFabMain.getBackground(), Color.GRAY);
}
});
}

View file

@ -93,7 +93,7 @@ public class LocalFileListFragment extends ExtendedListFragment implements Local
}
setSwipeEnabled(false); // Disable pull-to-refresh
setFabEnabled(false); // Disable FAB
setFabVisible(false); // Disable FAB
Log_OC.i(TAG, "onCreateView() end");
return v;

View file

@ -319,9 +319,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
mHideFab = args != null && args.getBoolean(ARG_HIDE_FAB, false);
if (mHideFab) {
setFabEnabled(false);
setFabVisible(false);
} else {
setFabEnabled(true);
setFabVisible(true);
registerFabListener();
}
@ -514,7 +514,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
ThemeUtils.colorToolbarProgressBar(getActivity(), mProgressBarActionModeColor);
// hide FAB in multi selection mode
setFabEnabled(false);
setFabVisible(false);
mAdapter.setMultiSelect(true);
return true;
@ -563,7 +563,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
// show FAB on multi selection mode exit
if (!mHideFab && !searchFragment) {
setFabEnabled(true);
setFabVisible(true);
}
mAdapter.setMultiSelect(false);
@ -1023,7 +1023,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
public void refreshDirectory() {
searchFragment = false;
setFabEnabled(true);
setFabVisible(true);
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
}
@ -1098,6 +1098,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
switchToListView();
}
// FAB
setFabEnabled(mFile.canWrite());
invalidateActionMode();
}
@ -1307,7 +1310,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
getActivity().getIntent().removeExtra(OCFileListFragment.SEARCH_EVENT);
getArguments().putParcelable(OCFileListFragment.SEARCH_EVENT, null);
setFabEnabled(true);
setFabVisible(true);
}
@Subscribe(threadMode = ThreadMode.BACKGROUND)
@ -1354,7 +1357,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
setEmptyListLoadingMessage();
mAdapter.setData(new ArrayList<>(), SearchType.NO_SEARCH, mContainerActivity.getStorageManager(), mFile);
setFabEnabled(false);
setFabVisible(false);
if (event.getUnsetType().equals(SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR)) {
unsetAllMenuItems(false);