From f99c7f2dddbbdf0e62f4f6bbb16c6d08de25f2de Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 21 Mar 2019 15:04:39 +0100 Subject: [PATCH] ReceiveExternalFiles: - fix no upload possible after creation new folder - obey canWrite permission for folder creation Signed-off-by: tobiasKaminsky --- .../operations/CreateFolderOperation.java | 1 + .../ReceiveExternalFilesActivity.java | 37 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java index 1c78c60a2d..24aca30a36 100644 --- a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java +++ b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java @@ -118,6 +118,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper newDir.setRemoteId(createdRemoteFolder.getRemoteId()); newDir.setModificationTimestamp(System.currentTimeMillis()); newDir.setEncrypted(FileStorageUtils.checkEncryptionStatus(newDir, getStorageManager())); + newDir.setPermissions(createdRemoteFolder.getPermissions()); getStorageManager().saveFile(newDir); Log_OC.d(TAG, "Create directory " + mRemotePath + " in Database"); diff --git a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index 5ed47d7702..48765a2d81 100755 --- a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -59,12 +59,24 @@ import android.widget.ListView; import android.widget.ProgressBar; import android.widget.Spinner; import android.widget.TextView; - +import androidx.annotation.DrawableRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AlertDialog.Builder; +import androidx.appcompat.widget.SearchView; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.view.MenuItemCompat; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.FragmentManager; import com.nextcloud.client.preferences.AppPreferences; +import com.nextcloud.client.preferences.PreferenceManager; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; -import com.nextcloud.client.preferences.PreferenceManager; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -104,20 +116,6 @@ import java.util.List; import java.util.Stack; import java.util.Vector; -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AlertDialog.Builder; -import androidx.appcompat.widget.SearchView; -import androidx.core.content.ContextCompat; -import androidx.core.graphics.drawable.DrawableCompat; -import androidx.core.view.MenuItemCompat; -import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.FragmentManager; - /** * This can be used to upload things to an ownCloud instance. */ @@ -1064,8 +1062,11 @@ public class ReceiveExternalFilesActivity extends FileActivity } // tint search event - final MenuItem item = menu.findItem(R.id.action_search); - SearchView searchView = (SearchView) MenuItemCompat.getActionView(item); + final MenuItem searchMenuItem = menu.findItem(R.id.action_search); + SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); + + MenuItem newFolderMenuItem = menu.findItem(R.id.action_create_dir); + newFolderMenuItem.setEnabled(mFile.canWrite()); // hacky as no default way is provided int fontColor = ThemeUtils.fontColor(this);