Loading app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/ShareAPI.kt +2 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import com.nextcloud.android.sso.api.EmptyResponse import com.owncloud.android.lib.resources.shares.OCShare import it.niedermann.owncloud.notes.share.model.CreateShareRequest import it.niedermann.owncloud.notes.share.model.CreateShareResponse import it.niedermann.owncloud.notes.share.model.UpdateShareRequest import it.niedermann.owncloud.notes.shared.model.OcsResponse import retrofit2.Call import retrofit2.http.Body Loading Loading @@ -38,7 +39,7 @@ interface ShareAPI { fun deleteShare(remoteShareId: Long): Call<EmptyResponse> @PATCH("shares") fun updateShare(remoteShareId: Long): Call<OcsResponse<List<OCShare>>> fun updateShare(@Body request: UpdateShareRequest): Call<OcsResponse<CreateShareResponse>> @POST("shares") fun addShare(@Body request: CreateShareRequest): Call<OcsResponse<CreateShareResponse>> Loading app/src/main/java/it/niedermann/owncloud/notes/share/NoteShareDetailActivity.kt +12 −12 Original line number Diff line number Diff line Loading @@ -552,15 +552,15 @@ class NoteShareDetailActivity : BrandedActivity(), SingleAccountHelper.getCurrentSingleSignOnAccount(this@NoteShareDetailActivity) // if modifying existing share then directly update the note and send email if (share != null && share?.note != noteText) { // repository.updateShare(ssoAcc, share, noteText) val result = if (share != null && share?.note != noteText) { repository.updateShare(ssoAcc, share!!.id, noteText) } else { if (note == null || shareeName == null) { Log_OC.d(TAG, "validateShareProcessSecond cancelled") return@launch } val result = repository.addShare( repository.addShare( ssoAcc, note!!, shareType, Loading @@ -570,6 +570,7 @@ class NoteShareDetailActivity : BrandedActivity(), permission, noteText ) } withContext(Dispatchers.Main) { if (result) { Loading @@ -583,7 +584,6 @@ class NoteShareDetailActivity : BrandedActivity(), } } } } override fun onDateSet(year: Int, monthOfYear: Int, dayOfMonth: Int, chosenDateInMillis: Long) { binding.shareProcessSelectExpDate.text = getString( Loading app/src/main/java/it/niedermann/owncloud/notes/share/model/UpdateShareRequest.kt 0 → 100644 +11 −0 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.share.model import com.google.gson.annotations.Expose data class UpdateShareRequest( @Expose val shareId: String, @Expose val noteText: String ) app/src/main/java/it/niedermann/owncloud/notes/share/repository/ShareRepository.kt +18 −9 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import it.niedermann.owncloud.notes.persistence.ApiProvider import it.niedermann.owncloud.notes.persistence.NotesRepository import it.niedermann.owncloud.notes.persistence.entity.Note import it.niedermann.owncloud.notes.share.model.CreateShareRequest import it.niedermann.owncloud.notes.share.model.UpdateShareRequest import it.niedermann.owncloud.notes.shared.model.ApiVersion import org.json.JSONArray import org.json.JSONObject Loading Loading @@ -153,14 +154,22 @@ class ShareRepository(private val applicationContext: Context) { fun updateShare( account: SingleSignOnAccount, remoteShareId: Long ): Single<List<OCShare>> { return Single.fromCallable { shareId: Long, noteText: String ): Boolean { val shareAPI = apiProvider.getShareAPI(applicationContext, account) val call = shareAPI.updateShare(remoteShareId) val requestBody = UpdateShareRequest(shareId.toString(), noteText) val call = shareAPI.updateShare(requestBody) val response = call.execute() response.body()?.ocs?.data ?: throw RuntimeException("Share update failed") }.subscribeOn(Schedulers.io()) if (response.isSuccessful) { val updateShareResponse = response.body() Log.d("", "Response successful: $updateShareResponse") } else { val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") } return response.isSuccessful } fun addShare( Loading Loading @@ -194,7 +203,7 @@ class ShareRepository(private val applicationContext: Context) { val response = call.execute() if (response.isSuccessful) { val createShareResponse = response.body() Log.d("", "Response successfull: $createShareResponse") Log.d("", "Response successful: $createShareResponse") } else { val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") Loading Loading
app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/ShareAPI.kt +2 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import com.nextcloud.android.sso.api.EmptyResponse import com.owncloud.android.lib.resources.shares.OCShare import it.niedermann.owncloud.notes.share.model.CreateShareRequest import it.niedermann.owncloud.notes.share.model.CreateShareResponse import it.niedermann.owncloud.notes.share.model.UpdateShareRequest import it.niedermann.owncloud.notes.shared.model.OcsResponse import retrofit2.Call import retrofit2.http.Body Loading Loading @@ -38,7 +39,7 @@ interface ShareAPI { fun deleteShare(remoteShareId: Long): Call<EmptyResponse> @PATCH("shares") fun updateShare(remoteShareId: Long): Call<OcsResponse<List<OCShare>>> fun updateShare(@Body request: UpdateShareRequest): Call<OcsResponse<CreateShareResponse>> @POST("shares") fun addShare(@Body request: CreateShareRequest): Call<OcsResponse<CreateShareResponse>> Loading
app/src/main/java/it/niedermann/owncloud/notes/share/NoteShareDetailActivity.kt +12 −12 Original line number Diff line number Diff line Loading @@ -552,15 +552,15 @@ class NoteShareDetailActivity : BrandedActivity(), SingleAccountHelper.getCurrentSingleSignOnAccount(this@NoteShareDetailActivity) // if modifying existing share then directly update the note and send email if (share != null && share?.note != noteText) { // repository.updateShare(ssoAcc, share, noteText) val result = if (share != null && share?.note != noteText) { repository.updateShare(ssoAcc, share!!.id, noteText) } else { if (note == null || shareeName == null) { Log_OC.d(TAG, "validateShareProcessSecond cancelled") return@launch } val result = repository.addShare( repository.addShare( ssoAcc, note!!, shareType, Loading @@ -570,6 +570,7 @@ class NoteShareDetailActivity : BrandedActivity(), permission, noteText ) } withContext(Dispatchers.Main) { if (result) { Loading @@ -583,7 +584,6 @@ class NoteShareDetailActivity : BrandedActivity(), } } } } override fun onDateSet(year: Int, monthOfYear: Int, dayOfMonth: Int, chosenDateInMillis: Long) { binding.shareProcessSelectExpDate.text = getString( Loading
app/src/main/java/it/niedermann/owncloud/notes/share/model/UpdateShareRequest.kt 0 → 100644 +11 −0 Original line number Diff line number Diff line package it.niedermann.owncloud.notes.share.model import com.google.gson.annotations.Expose data class UpdateShareRequest( @Expose val shareId: String, @Expose val noteText: String )
app/src/main/java/it/niedermann/owncloud/notes/share/repository/ShareRepository.kt +18 −9 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import it.niedermann.owncloud.notes.persistence.ApiProvider import it.niedermann.owncloud.notes.persistence.NotesRepository import it.niedermann.owncloud.notes.persistence.entity.Note import it.niedermann.owncloud.notes.share.model.CreateShareRequest import it.niedermann.owncloud.notes.share.model.UpdateShareRequest import it.niedermann.owncloud.notes.shared.model.ApiVersion import org.json.JSONArray import org.json.JSONObject Loading Loading @@ -153,14 +154,22 @@ class ShareRepository(private val applicationContext: Context) { fun updateShare( account: SingleSignOnAccount, remoteShareId: Long ): Single<List<OCShare>> { return Single.fromCallable { shareId: Long, noteText: String ): Boolean { val shareAPI = apiProvider.getShareAPI(applicationContext, account) val call = shareAPI.updateShare(remoteShareId) val requestBody = UpdateShareRequest(shareId.toString(), noteText) val call = shareAPI.updateShare(requestBody) val response = call.execute() response.body()?.ocs?.data ?: throw RuntimeException("Share update failed") }.subscribeOn(Schedulers.io()) if (response.isSuccessful) { val updateShareResponse = response.body() Log.d("", "Response successful: $updateShareResponse") } else { val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") } return response.isSuccessful } fun addShare( Loading Loading @@ -194,7 +203,7 @@ class ShareRepository(private val applicationContext: Context) { val response = call.execute() if (response.isSuccessful) { val createShareResponse = response.body() Log.d("", "Response successfull: $createShareResponse") Log.d("", "Response successful: $createShareResponse") } else { val errorBody = response.errorBody()?.string() Log.d("", "Response failed:$errorBody") Loading