-
Notifications
You must be signed in to change notification settings - Fork 5
feat: unified share #939
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
Open
alperozturk96
wants to merge
15
commits into
main
Choose a base branch
from
feat/unified-share
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: unified share #939
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ea5031c
feat: unified share
alperozturk96 805d012
add api models
alperozturk96 bc8d9ff
adopt mock models to api models
alperozturk96 1e0bb79
add translations, bind ui actions
alperozturk96 5c343b5
add translations, bind ui actions
alperozturk96 0dd93c7
wip
alperozturk96 9dcea27
wip
alperozturk96 4b25cbf
add test ocs call
alperozturk96 580e413
fix test call
alperozturk96 e45466a
use client
alperozturk96 0e2822d
wip
alperozturk96 dbce1d0
wip
alperozturk96 49879fd
wip
alperozturk96 a310a21
wip
alperozturk96 38fffa4
wip
alperozturk96 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
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
|
|
||
| /* | ||
| * Nextcloud Android Common Library | ||
| * | ||
|
|
||
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
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
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
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
43 changes: 43 additions & 0 deletions
43
ui/src/main/java/com/nextcloud/android/common/ui/network/PredefinedStatus.kt
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,43 @@ | ||
| /* | ||
| * Nextcloud Android Common Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.common.ui.network | ||
|
|
||
| import kotlinx.serialization.KSerializer | ||
| import kotlinx.serialization.Serializable | ||
| import kotlinx.serialization.descriptors.PrimitiveKind | ||
| import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
| import kotlinx.serialization.encoding.Decoder | ||
| import kotlinx.serialization.encoding.Encoder | ||
| import kotlinx.serialization.json.JsonDecoder | ||
| import kotlinx.serialization.json.JsonPrimitive | ||
|
|
||
| object ClearAtTimeSerializer : KSerializer<String> { | ||
| override val descriptor = PrimitiveSerialDescriptor("ClearAtTime", PrimitiveKind.STRING) | ||
|
|
||
| override fun deserialize(decoder: Decoder): String { | ||
| val jsonDecoder = decoder as? JsonDecoder ?: return decoder.decodeString() | ||
| return (jsonDecoder.decodeJsonElement() as? JsonPrimitive)?.content ?: "" | ||
| } | ||
|
|
||
| override fun serialize(encoder: Encoder, value: String) = encoder.encodeString(value) | ||
| } | ||
|
|
||
| @Serializable | ||
| data class ClearAt( | ||
| val type: String, | ||
| @Serializable(with = ClearAtTimeSerializer::class) | ||
| val time: String | ||
| ) | ||
|
|
||
| @Serializable | ||
| data class PredefinedStatus( | ||
| val id: String, | ||
| val icon: String, | ||
| val message: String, | ||
| val clearAt: ClearAt? = null | ||
| ) |
30 changes: 30 additions & 0 deletions
30
ui/src/main/java/com/nextcloud/android/common/ui/network/UserStatusRepository.kt
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,30 @@ | ||
| /* | ||
| * Nextcloud Android Common Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.common.ui.network | ||
|
|
||
| import com.nextcloud.android.common.ui.network.http.HttpMethod | ||
| import com.nextcloud.android.common.ui.network.http.NextcloudHttpClient | ||
| import com.nextcloud.android.common.ui.network.model.NetworkResult | ||
| import com.nextcloud.android.common.ui.network.model.OcsResponse | ||
| import com.nextcloud.android.common.ui.network.serialization.OCSSerializer | ||
|
|
||
| class UserStatusRepository(private val client: NextcloudHttpClient) { | ||
|
|
||
| private companion object { | ||
| private const val PREDEFINED_STATUSES_ENDPOINT = | ||
| "/ocs/v2.php/apps/user_status/api/v1/predefined_statuses" | ||
| } | ||
|
|
||
| suspend fun fetchPredefinedStatuses(): NetworkResult<List<PredefinedStatus>> = | ||
| client.executeRequest( | ||
| endpoint = PREDEFINED_STATUSES_ENDPOINT, | ||
| method = HttpMethod.GET | ||
| ) { body -> | ||
| OCSSerializer.json.decodeFromString<OcsResponse<List<PredefinedStatus>>>(body).ocs.data | ||
| } | ||
| } | ||
49 changes: 49 additions & 0 deletions
49
ui/src/main/java/com/nextcloud/android/common/ui/network/auth/AuthInterceptor.kt
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,49 @@ | ||
| /* | ||
| * Nextcloud Android Common Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.common.ui.network.auth | ||
|
|
||
| import okhttp3.Credentials | ||
| import okhttp3.Interceptor | ||
| import okhttp3.Response | ||
|
|
||
| class AuthInterceptor(private val credentials: ServerCredentials) : Interceptor { | ||
|
|
||
| private companion object { | ||
| private const val HTTP_PREFIX = "http://" | ||
| private const val HTTPS_PREFIX = "https://" | ||
| private const val DELIMITER = '/' | ||
|
|
||
| private const val HEADER_AUTHORIZATION = "Authorization" | ||
| private const val HEADER_OCS_REQUEST = "OCS-APIRequest" | ||
| private const val HEADER_OCS_REQUEST_VALUE = "true" | ||
| } | ||
|
|
||
| override fun intercept(chain: Interceptor.Chain): Response { | ||
| val basicCredentials = Credentials.basic(credentials.username, credentials.token) | ||
|
|
||
| val request = chain.request() | ||
| .newBuilder() | ||
| .header(HEADER_AUTHORIZATION, basicCredentials) | ||
| .header(HEADER_OCS_REQUEST, HEADER_OCS_REQUEST_VALUE) | ||
| .url(resolveUrl(chain.request().url.toString())) | ||
| .build() | ||
|
|
||
| return chain.proceed(request) | ||
| } | ||
|
|
||
| /** | ||
| * Prepends [ServerCredentials.baseURL] to relative URLs. | ||
| * Absolute URLs (starting with http/https) are passed through unchanged. | ||
| */ | ||
| private fun resolveUrl(requestUrl: String): String = | ||
| if (requestUrl.startsWith(HTTP_PREFIX) || requestUrl.startsWith(HTTPS_PREFIX)) { | ||
| requestUrl | ||
| } else { | ||
| "${credentials.baseURL.trimEnd(DELIMITER)}/${requestUrl.trimStart(DELIMITER)}" | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
ui/src/main/java/com/nextcloud/android/common/ui/network/auth/ServerCredentials.kt
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,14 @@ | ||
| /* | ||
| * Nextcloud Android Common Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.common.ui.network.auth | ||
|
|
||
| data class ServerCredentials( | ||
| val baseURL: String, | ||
| val username: String, | ||
| val token: String | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
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.
For test activity