Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
87fab9a
Rename .java to .kt
alperozturk96 Feb 10, 2026
f5d936f
fix(share): permission
alperozturk96 Feb 10, 2026
eab3191
fix(share): permission
alperozturk96 Feb 10, 2026
f7cfbba
fix link label update
alperozturk96 Feb 10, 2026
8f17b99
fix link label update
alperozturk96 Feb 10, 2026
9782d4c
remove unexisting permissions
alperozturk96 Feb 10, 2026
a0d8401
remove unexisting permissions
alperozturk96 Feb 10, 2026
cfb2531
remove unexisting permissions
alperozturk96 Feb 10, 2026
5b2996d
remove unexisting permissions
alperozturk96 Feb 10, 2026
add23dc
remove unexisting permissions
alperozturk96 Feb 10, 2026
440ea4b
remove unexisting permissions
alperozturk96 Feb 10, 2026
9d5f16f
fix update share
alperozturk96 Feb 10, 2026
bcc1605
handle set password
alperozturk96 Feb 10, 2026
dd883d3
remove unexisting share types
alperozturk96 Feb 10, 2026
e4b18e8
remove unexisting share types
alperozturk96 Feb 10, 2026
cd80bd1
fix send email
alperozturk96 Feb 11, 2026
ef86f1c
fix email address appearance in suggestion adapter
alperozturk96 Feb 11, 2026
1137461
add documentations
alperozturk96 Feb 11, 2026
d32ca3c
implement allow download and sync
alperozturk96 Feb 11, 2026
f7eedb9
implement allow download and sync
alperozturk96 Feb 11, 2026
0d0e813
fix allowDownloadAndSync during create
alperozturk96 Feb 11, 2026
6dfccb9
change unshare text for user share type
alperozturk96 Feb 12, 2026
944a1b8
change unshare text for user share type
alperozturk96 Feb 12, 2026
31eec7c
fix note enter for share create
alperozturk96 Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,21 @@
import it.niedermann.owncloud.notes.shared.model.Capabilities;

@Database(
entities = {
Account.class,
Note.class,
CategoryOptions.class,
SingleNoteWidgetData.class,
NotesListWidgetData.class,
ShareEntity.class,
Capabilities.class
}, version = 28,
autoMigrations = {
@AutoMigration(from = 25, to = 26),
@AutoMigration(from = 26, to = 27),
@AutoMigration(from = 27, to = 28),
}
entities = {
Account.class,
Note.class,
CategoryOptions.class,
SingleNoteWidgetData.class,
NotesListWidgetData.class,
ShareEntity.class,
Capabilities.class
}, version = 29,
autoMigrations = {
@AutoMigration(from = 25, to = 26),
@AutoMigration(from = 26, to = 27),
@AutoMigration(from = 27, to = 28),
@AutoMigration(from = 28, to = 29),
}
)
@TypeConverters({Converters.class})
public abstract class NotesDatabase extends RoomDatabase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import com.nextcloud.android.sso.helper.SingleAccountHelper;
import com.nextcloud.android.sso.model.SingleSignOnAccount;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.shares.OCShare;

import java.util.ArrayList;
import java.util.Calendar;
Expand Down Expand Up @@ -1006,8 +1007,16 @@ public void addShareEntities(List<ShareEntity> entities) {
db.getShareDao().addShareEntities(entities);
}

public List<ShareEntity> getShareEntities(String path) {
return db.getShareDao().getShareEntities(path);
public ShareEntity getShareByPathAndDisplayName(@NonNull OCShare share) {
if (share.getPath() == null || share.getSharedWithDisplayName() == null) {
return null;
}

return db.getShareDao().getShareByPathAndDisplayName(share.getPath(), share.getSharedWithDisplayName());
}

public void deleteShareById(int id) {
db.getShareDao().deleteById(id);
}

public void updateNote(Note note) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package it.niedermann.owncloud.notes.persistence.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
Expand All @@ -17,6 +18,17 @@ interface ShareDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun addShareEntities(entities: List<ShareEntity>)

@Query("SELECT * FROM share_table WHERE path = :path")
fun getShareEntities(path: String): List<ShareEntity>
@Query("""
SELECT * FROM share_table
WHERE path = :path
AND share_with_displayname = :displayName
LIMIT 1
""")
fun getShareByPathAndDisplayName(
path: String,
displayName: String
): ShareEntity?

@Query("DELETE FROM share_table WHERE id = :id")
fun deleteById(id: Int)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ data class ShareEntity(
val uid_owner: String? = null,
val displayname_owner: String? = null,
val url: String? = null,
val expiration_date: Long? = null
val expiration_date: Long? = null,
val permissions: Double? = null,
val attributes: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import retrofit2.http.Query

interface ShareAPI {
@GET("sharees")
fun getSharees(
fun fetchSharees(
@Query("format") format: String = "json",
@Query("itemType") itemType: String = "file",
@Query("search") search: String,
Expand All @@ -33,14 +33,8 @@ interface ShareAPI {
@Query("lookup") lookup: String = "false",
): LinkedTreeMap<String, Any?>?

@GET("shares/{remoteId}?format=json")
fun getShares(
@Path("remoteId") remoteId: Long,
@Query("include_tags") includeTags: Boolean = true,
): Call<OcsResponse<List<CreateShareResponse>>>

@GET("shares/?format=json")
fun getSharesForSpecificNote(
fun fetchSharesForSpecificNote(
@Query("path") path: String,
@Query("reshares") reshares: Boolean = true,
@Query("subfiles") subfiles: Boolean = true
Expand All @@ -52,9 +46,6 @@ interface ShareAPI {
@POST("shares?format=json")
fun addShare(@Body request: CreateShareRequest): Call<OcsResponse<CreateShareResponse>>

@POST("shares/{shareId}/send-email?format=json")
fun sendEmail(@Path("shareId") shareId: Long, @Body password: SharePasswordRequest?): Call<Any>

@PUT("shares/{shareId}?format=json")
fun updateShare(@Path("shareId") shareId: Long, @Body request: UpdateShareRequest): Call<OcsResponse<CreateShareResponse>>

Expand All @@ -65,8 +56,8 @@ interface ShareAPI {
): Call<OcsResponse<CreateShareResponse>>

@GET("shares/?format=json")
fun getShareFromNote(
fun fetchSharesFromNote(
@Query("path") path: String,
@Query("shared_with_me") sharedWithMe: Boolean = true
@Query("shared_with_me") sharedWithMe: Boolean = false
): Call<OcsResponse<List<CreateShareResponse>>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import it.niedermann.owncloud.notes.share.listener.ShareeListAdapterListener;
import it.niedermann.owncloud.notes.share.model.CreateShareResponse;
import it.niedermann.owncloud.notes.share.model.CreateShareResponseExtensionsKt;
import it.niedermann.owncloud.notes.share.model.UpdateShareRequest;
import it.niedermann.owncloud.notes.share.model.UsersAndGroupsSearchConfig;
import it.niedermann.owncloud.notes.share.repository.ShareRepository;
import it.niedermann.owncloud.notes.shared.model.Capabilities;
Expand All @@ -84,6 +85,7 @@
import it.niedermann.owncloud.notes.shared.util.ShareUtil;
import it.niedermann.owncloud.notes.shared.util.clipboard.ClipboardUtil;
import it.niedermann.owncloud.notes.shared.util.extensions.BundleExtensionsKt;
import it.niedermann.owncloud.notes.util.DateUtil;

public class NoteShareActivity extends BrandedActivity implements ShareeListAdapterListener, NoteShareItemAction, QuickSharingPermissionsBottomSheetDialog.QuickPermissionSharingBottomSheetActions, SharePasswordDialogFragment.SharePasswordDialogListener {

Expand Down Expand Up @@ -161,7 +163,7 @@ private void initializeArguments() {
final var ssoAcc = SingleAccountHelper.getCurrentSingleSignOnAccount(NoteShareActivity.this);
repository = new ShareRepository(NoteShareActivity.this, ssoAcc);
capabilities = repository.getCapabilities();
repository.getSharesForNotesAndSaveShareEntities();
repository.fetchSharesForNotesAndSaveShareEntities();

runOnUiThread(() -> {
binding.fileName.setText(note.getTitle());
Expand Down Expand Up @@ -396,7 +398,7 @@ public void createPublicShareLink() {
requestPasswordForShareViaLink(true, capabilities.getAskForOptionalPassword());
} else {
executorService.submit(() -> {
final var result = repository.addShare(note, ShareType.PUBLIC_LINK, "", "false", "", 0, "");
final var result = repository.addShare(note, ShareType.PUBLIC_LINK, "");
runOnUiThread(() -> {
if (result instanceof ApiResult.Success<OcsResponse<CreateShareResponse>> successResponse && binding.sharesList.getAdapter() instanceof ShareeListAdapter adapter) {
DisplayUtils.showSnackMessage(NoteShareActivity.this, successResponse.getMessage());
Expand Down Expand Up @@ -519,17 +521,16 @@ public void updateShareeListAdapter() {
return;
}

List<OCShare> tempShares = new ArrayList<>();

// to show share with users/groups info
List<OCShare> remoteNotes;
if (note != null) {
// get shares from local DB
populateSharesList(tempShares);
remoteNotes = repository.fetchSharesFromNote(note);
} else {
remoteNotes = new ArrayList<>();
}

runOnUiThread(() -> {
shares.clear();
shares.addAll(tempShares);
shares.addAll(remoteNotes);

adapter.removeAll();
adapter.addShares(shares);
Expand All @@ -544,35 +545,6 @@ public void updateShareeListAdapter() {
});
}

private void populateSharesList(List<OCShare> targetList) {
// Get shares from local DB
final var shareEntities = repository.getShareEntitiesForSpecificNote(note);
for (var entity : shareEntities) {
if (entity.getId() != null) {
addSharesToList(entity.getId(), targetList);
}
}

// Get shares from remote
final var remoteShares = repository.getShareFromNote(note);
if (remoteShares != null) {
for (var entity : remoteShares) {
addSharesToList(entity.getId(), targetList);
}
}
}

private void addSharesToList(long id, List<OCShare> targetList) {
final var result = repository.getShares(id);
if (result != null) {
for (OCShare ocShare : result) {
if (!targetList.contains(ocShare)) {
targetList.add(ocShare);
}
}
}
}

private void addPublicShares(ShareeListAdapter adapter) {
List<OCShare> publicShares = new ArrayList<>();

Expand Down Expand Up @@ -672,13 +644,13 @@ public void search(String query) {

@Override
public void advancedPermissions(OCShare share) {
modifyExistingShare(share, NoteShareDetailActivity.SCREEN_TYPE_PERMISSION);
modifyExistingShare(share, NoteShareDetailActivity.SCREEN_TYPE_PERMISSION, false);
}


@Override
public void sendNewEmail(OCShare share) {
modifyExistingShare(share, NoteShareDetailActivity.SCREEN_TYPE_NOTE);
modifyExistingShare(share, NoteShareDetailActivity.SCREEN_TYPE_NOTE, true);
}

@Override
Expand Down Expand Up @@ -711,13 +683,14 @@ public void addAnotherLink(OCShare share) {
createPublicShareLink();
}

private void modifyExistingShare(OCShare share, int screenTypePermission) {
private void modifyExistingShare(OCShare share, int screenTypePermission, boolean sendEmail) {
Bundle bundle = new Bundle();

bundle.putSerializable(NoteShareDetailActivity.ARG_OCSHARE, share);
bundle.putInt(NoteShareDetailActivity.ARG_SCREEN_TYPE, screenTypePermission);
bundle.putBoolean(NoteShareDetailActivity.ARG_RESHARE_SHOWN, !isReshareForbidden(share));
bundle.putBoolean(NoteShareDetailActivity.ARG_EXP_DATE_SHOWN, getExpDateShown());
bundle.putBoolean(NoteShareDetailActivity.ARG_SEND_EMAIL, sendEmail);

Intent intent = new Intent(this, NoteShareDetailActivity.class);
intent.putExtras(bundle);
Expand Down Expand Up @@ -759,12 +732,17 @@ public void onQuickPermissionChanged(OCShare share, int permission) {
}

private void updateShare(OCShare share) {
if (note == null) {
Log_OC.e(TAG, "note is null, cannot update share");
return;
}

executorService.submit(() -> {
try {
final var updatedShares = repository.getShares(share.getId());
final var updatedShares = repository.fetchSharesFromNote(note);

runOnUiThread(() -> {
if (updatedShares != null && binding.sharesList.getAdapter() instanceof ShareeListAdapter adapter) {
if (binding.sharesList.getAdapter() instanceof ShareeListAdapter adapter) {
OCShare updatedShare = null;
for (int i=0;i<updatedShares.size();i++) {
if (updatedShares.get(i).getId() == share.getId()) {
Expand Down Expand Up @@ -857,8 +835,7 @@ public void shareFileViaPublicShare(@Nullable Note note, @Nullable String passwo
"",
"false",
password,
repository.getCapabilities().getDefaultPermission(),
""
repository.getCapabilities().getDefaultPermission()
);

runOnUiThread(() -> {
Expand All @@ -881,14 +858,22 @@ public void setPasswordToShare(@NotNull OCShare share, @Nullable String password

executorService.submit(() -> {
{
final var requestBody = repository.getUpdateShareRequest(
false,
share,
"",
password,
false,
-1,
share.getPermissions()
boolean isDownloadAndAllowsSyncEnabled = repository.isAllowDownloadAndSync(share);

String attributes = UpdateShareRequest.Companion.createAttributes(
repository.getCapabilities(),
isDownloadAndAllowsSyncEnabled,
share.getShareType()
);

final var requestBody = new UpdateShareRequest(
share.getPermissions(),
password,
share.getNote(),
share.getLabel(),
DateUtil.INSTANCE.getExpirationDate(share.getExpirationDate()),
Boolean.toString(share.isHideFileDownload()),
attributes
);
final var result = repository.updateShare(share.getId(), requestBody);

Expand Down
Loading
Loading