-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Iteration 5 for File detail & new sharing - Comments #2690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22d53a2
Add file version to activity stream
tobiasKaminsky c32986c
butterknife for details fragment + proper empty content handling
AndyScherzinger 1ef3d29
add avatar icons on sharee list
tobiasKaminsky 5e50b6c
Add comments
tobiasKaminsky 41528ab
replace button with borderless image button + ripple effect + click b…
AndyScherzinger 695ed0f
tint edit text according to theming
AndyScherzinger b7ac2ee
changes due to rebase
tobiasKaminsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
src/main/java/com/owncloud/android/operations/CommentFileOperation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /* | ||
| * Nextcloud Android client application | ||
| * | ||
| * @author Tobias Kaminsky | ||
| * Copyright (C) 2018 Tobias Kaminsky | ||
| * Copyright (C) 2018 Nextcloud GmbH. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.owncloud.android.operations; | ||
|
|
||
| import android.util.Log; | ||
|
|
||
| import com.google.gson.GsonBuilder; | ||
| import com.owncloud.android.lib.common.OwnCloudClient; | ||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult; | ||
| import com.owncloud.android.operations.common.SyncOperation; | ||
|
|
||
| import org.apache.commons.httpclient.HttpStatus; | ||
| import org.apache.commons.httpclient.methods.PostMethod; | ||
| import org.apache.commons.httpclient.methods.StringRequestEntity; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
|
|
||
| /** | ||
| * Restore a {@link com.owncloud.android.lib.resources.files.FileVersion}. | ||
| */ | ||
| public class CommentFileOperation extends SyncOperation { | ||
|
|
||
| private static final String TAG = CommentFileOperation.class.getSimpleName(); | ||
| private static final int POST_READ_TIMEOUT = 30000; | ||
| private static final int POST_CONNECTION_TIMEOUT = 5000; | ||
|
|
||
| private static final String ACTOR_ID = "actorId"; | ||
| private static final String ACTOR_TYPE = "actorType"; | ||
| private static final String ACTOR_TYPE_VALUE = "users"; | ||
| private static final String VERB = "verb"; | ||
| private static final String VERB_VALUE = "comment"; | ||
| private static final String MESSAGE = "message"; | ||
|
|
||
| private String message; | ||
| private String fileId; | ||
| private String userId; | ||
|
|
||
| /** | ||
| * Constructor | ||
| * | ||
| * @param message Comment to store | ||
| * @param userId userId to access correct dav endpoint | ||
| */ | ||
| public CommentFileOperation(String message, String fileId, String userId) { | ||
| this.message = message; | ||
| this.fileId = fileId; | ||
| this.userId = userId; | ||
| } | ||
|
|
||
| /** | ||
| * Performs the operation. | ||
| * | ||
| * @param client Client object to communicate with the remote ownCloud server. | ||
| */ | ||
| @Override | ||
| protected RemoteOperationResult run(OwnCloudClient client) { | ||
|
|
||
| RemoteOperationResult result; | ||
| try { | ||
| String url = client.getNewWebdavUri(false) + "/comments/files/" + fileId; | ||
| PostMethod postMethod = new PostMethod(url); | ||
| postMethod.addRequestHeader("Content-type", "application/json"); | ||
|
|
||
| Map<String, String> values = new HashMap<>(); | ||
| values.put(ACTOR_ID, userId); | ||
| values.put(ACTOR_TYPE, ACTOR_TYPE_VALUE); | ||
| values.put(VERB, VERB_VALUE); | ||
| values.put(MESSAGE, message); | ||
|
|
||
| String json = new GsonBuilder().create().toJson(values, Map.class); | ||
|
|
||
| postMethod.setRequestEntity(new StringRequestEntity(json)); | ||
|
|
||
| int status = client.executeMethod(postMethod, POST_READ_TIMEOUT, POST_CONNECTION_TIMEOUT); | ||
|
|
||
| result = new RemoteOperationResult(isSuccess(status), postMethod); | ||
|
|
||
| client.exhaustResponse(postMethod.getResponseBodyAsStream()); | ||
| } catch (IOException e) { | ||
| result = new RemoteOperationResult(e); | ||
| Log.e(TAG, "Post comment to file with id " + fileId + " failed: " + result.getLogMessage(), e); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| private boolean isSuccess(int status) { | ||
| return status == HttpStatus.SC_CREATED; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | ||
|
|
||
| Bundle bundle = getArguments(); | ||
| setFile((OCFile) bundle.getParcelable(EXTRA_FILE)); | ||
| setFile(bundle.getParcelable(EXTRA_FILE)); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I accidentally touched the file and now AndroidStudio always tries to enhance this… |
||
| } | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <!-- | ||
| @author Google LLC | ||
| Copyright (C) 2018 Google LLC | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportHeight="24" | ||
| android:viewportWidth="24"> | ||
| <path | ||
| android:fillColor="#757575" | ||
| android:pathData="M2,21L23,12L2,3V10L17,12L2,14V21Z" /> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whole file should be in a library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General issue: ATM all "operations" are afaik not in the lib but the app...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General issue maybe, but at least move this NEW issue to the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this cannot be moved this easily as these *Operation extends RemoteOperation which is a class in files app.
I guess you confuse it with *RemoteOperations, e.g.:
RemoveFileOperation is in Files app (handles app specific stuff)
RemoveRemoteFileOperation is in library (and handles the real webdav call)