-
-
Notifications
You must be signed in to change notification settings - Fork 149
Sharing fixes #2974
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
base: main
Are you sure you want to change the base?
Sharing fixes #2974
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ | |
|
|
||
| import androidx.annotation.DrawableRes; | ||
| import androidx.annotation.NonNull; | ||
| import androidx.recyclerview.widget.RecyclerView; | ||
|
|
||
| import com.owncloud.android.lib.resources.shares.OCShare; | ||
|
|
||
|
|
@@ -78,7 +77,7 @@ public void bind(OCShare share, ShareeListAdapterListener listener) { | |
| binding.icon.setTag(share.getShareWith()); | ||
|
|
||
| if (share.getSharedWithDisplayName() != null) { | ||
| AvatarLoader.INSTANCE.load(context, binding.icon, account, share.getSharedWithDisplayName()); | ||
| AvatarLoader.INSTANCE.load(context, binding.icon, account, share.getShareWith()); | ||
|
Member
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. Than the if-clause needs to be updated as well |
||
| } | ||
|
|
||
| // binding.icon.setOnClickListener(v -> listener.showProfileBottomSheet(user, share.getShareWith())); | ||
|
|
@@ -89,8 +88,9 @@ public void bind(OCShare share, ShareeListAdapterListener listener) { | |
|
|
||
| binding.name.setText(name); | ||
|
|
||
| if (accountUserName.equalsIgnoreCase(share.getShareWith()) || | ||
| accountUserName.equalsIgnoreCase(share.getUserId())) { | ||
| if (accountUserName.equalsIgnoreCase(share.getShareWith()) && accountUserName.equalsIgnoreCase(share.getUserId())) { | ||
| binding.overflowMenu.setVisibility(View.GONE); | ||
| } else { | ||
| binding.overflowMenu.setVisibility(View.VISIBLE); | ||
|
|
||
| String permissionName = SharingMenuHelper.getPermissionName(context, share); | ||
|
|
@@ -99,8 +99,6 @@ public void bind(OCShare share, ShareeListAdapterListener listener) { | |
| // bind listener to edit privileges | ||
| binding.overflowMenu.setOnClickListener(v -> listener.showSharingMenuActionSheet(share)); | ||
| binding.shareNameLayout.setOnClickListener(v -> listener.showPermissionsDialog(share)); | ||
| } else { | ||
| binding.overflowMenu.setVisibility(View.GONE); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ import it.niedermann.owncloud.notes.shared.util.StringConstants | |
| import it.niedermann.owncloud.notes.shared.util.extensions.getErrorMessage | ||
| import it.niedermann.owncloud.notes.shared.util.extensions.toExpirationDateString | ||
| import org.json.JSONObject | ||
| import retrofit2.Response | ||
| import java.util.Date | ||
|
|
||
| class ShareRepository(private val applicationContext: Context, private val account: SingleSignOnAccount) { | ||
|
|
@@ -58,13 +59,7 @@ class ShareRepository(private val applicationContext: Context, private val accou | |
| val notesPathResponseResult = getNotesPathResponseResult() ?: return null | ||
| val notesPath = notesPathResponseResult.notesPath | ||
| val notesSuffix = notesPathResponseResult.fileSuffix | ||
| return if (note.category.isEmpty()) { | ||
| StringConstants.PATH + notesPath + StringConstants.PATH + note.title + notesSuffix | ||
| } else { | ||
| StringConstants.PATH + notesPath + StringConstants.PATH + note.category + StringConstants.PATH + | ||
| note.title + | ||
| notesSuffix | ||
| } | ||
| return StringConstants.PATH + notesPath + StringConstants.PATH + note.category + StringConstants.PATH + note.title + notesSuffix | ||
|
Member
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. this will fail for notes not in a category I guess because it woudl add a |
||
| } | ||
|
|
||
| fun getShareEntitiesForSpecificNote(note: Note): List<ShareEntity> { | ||
|
|
@@ -286,25 +281,37 @@ class ShareRepository(private val applicationContext: Context, private val accou | |
| } | ||
| } | ||
|
|
||
| fun getShareFromNote(note: Note): List<OCShare>? { | ||
| fun getShareFromNote(note: Note): List<OCShare> { | ||
| val shareAPI = apiProvider.getShareAPI(applicationContext, account) | ||
| val path = getNotePath(note) ?: return null | ||
| val call = shareAPI.getShareFromNote(path) | ||
| val response = call.execute() | ||
| val path = getNotePath(note) ?: return emptyList<OCShare>() | ||
|
|
||
| val callSharedWithMe = shareAPI.getShareFromNote(path, true) | ||
| var response = callSharedWithMe.execute() | ||
| val sharedWithMe = parseResponse(response) | ||
|
|
||
| val callSharedWithOthers = shareAPI.getShareFromNote(path, false) | ||
| response = callSharedWithOthers.execute() | ||
| val sharedWithOthers = parseResponse(response) | ||
|
|
||
| sharedWithOthers.addAll(sharedWithMe) | ||
|
|
||
| return sharedWithOthers | ||
| } | ||
|
|
||
| private fun parseResponse(response: Response<OcsResponse<List<CreateShareResponse>>>): MutableList<OCShare> { | ||
| return try { | ||
| if (response.isSuccessful) { | ||
| val body = response.body() | ||
| Log_OC.d(tag, "Response successful: $body") | ||
| body?.ocs?.data?.toOCShareList() | ||
| body?.ocs?.data?.toOCShareList()?.toMutableList() ?: mutableListOf() | ||
| } else { | ||
| val errorBody = response.errorBody()?.string() | ||
| Log_OC.d(tag, "Response failed: $errorBody") | ||
| null | ||
| mutableListOf() | ||
| } | ||
| } catch (e: Exception) { | ||
| Log_OC.d(tag, "Exception while getting share from note: ", e) | ||
| null | ||
| mutableListOf() | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
The web calls
So I am not sure if this is correct to be changed