Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,313 changes: 1,313 additions & 0 deletions app/schemas/com.nextcloud.client.database.NextcloudDatabase/101.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

package com.nextcloud.utils

import com.nextcloud.utils.e2ee.E2EVersionHelper
import com.owncloud.android.lib.resources.status.E2EVersion
import org.junit.Assert.assertEquals
import org.junit.Test

class EndToEndEncryptionVersionTests {

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenUnknownShouldReturnUnknown() {
assertEquals(
E2EVersion.UNKNOWN,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.UNKNOWN)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV1_0ShouldReturnV1_0() {
assertEquals(
E2EVersion.V1_0,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V1_0)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV1_1ShouldReturnV1_1() {
assertEquals(
E2EVersion.V1_1,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V1_1)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV1_2ShouldReturnV1_2() {
assertEquals(
E2EVersion.V1_2,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V1_2)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV1AboveClientMaxShouldReturnClientV1Max() {
assertEquals(
E2EVersion.V1_2,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V1_2)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV2_0ShouldReturnV2_0() {
assertEquals(
E2EVersion.V2_0,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V2_0)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV2_1ShouldReturnV2_1() {
assertEquals(
E2EVersion.V2_1,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V2_1)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV1_2ShouldNotApplyV2CeilingShouldReturnV1_2() {
assertEquals(
E2EVersion.V1_2,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V1_2)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV2_0ShouldNotApplyV1CeilingShouldReturnV2_0() {
assertEquals(
E2EVersion.V2_0,
E2EVersionHelper.getMaxCompatibleE2EEVersion(E2EVersion.V2_0)
)
}

@Test
fun testGetMaxCompatibleE2EEVersionWhenGivenV3_0ShouldReturnV2_1() {
assertEquals(
E2EVersion.V2_1,
E2EVersionHelper.getMaxCompatibleE2EEVersionFromString("3.0")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ import com.owncloud.android.db.ProviderMeta
AutoMigration(from = 95, to = 96),
AutoMigration(from = 96, to = 97, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
// manual migration used for 97 to 98
AutoMigration(from = 98, to = 99)
AutoMigration(from = 98, to = 99),
// manual migration used for 99 to 100
AutoMigration(from = 100, to = 101, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class)
],
exportSchema = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ data class CapabilityEntity(
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_HAS_VALID_SUBSCRIPTION)
val hasValidSubscription: Int?,
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_CLIENT_INTEGRATION_JSON)
val clientIntegrationJson: String?
val clientIntegrationJson: String?,
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_SHARING_JSON)
val sharingJson: String?
)

@Suppress("LongMethod", "ReturnCount")
Expand Down Expand Up @@ -232,6 +234,7 @@ fun CapabilityEntity?.toOCCapability(): OCCapability {
capability.defaultPermissions = this.defaultPermissions ?: 0
capability.hasValidSubscription = intToBoolean(this.hasValidSubscription)
capability.clientIntegrationJson = this.clientIntegrationJson
capability.sharingJson = this.sharingJson

return capability
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package com.nextcloud.utils.extensions

import android.content.Context
import com.nextcloud.android.common.ui.network.auth.ServerCredentials
import com.nextcloud.common.NextcloudClient
import com.owncloud.android.lib.common.OwnCloudClient
import com.owncloud.android.lib.common.OwnCloudClientFactory
Expand All @@ -27,3 +28,9 @@ fun OwnCloudClient.getPreviewEndpoint(localFileId: Long, x: Int, y: Int): String
localFileId +
"&x=" + (x / 2) + "&y=" + (y / 2) +
"&a=1&mode=cover&forceIcon=0"

/**
* Used in Android Common
*/
fun OwnCloudClient.toServerCredentials(baseURL: String): ServerCredentials =
ServerCredentials(baseURL, userIdPlain, credentials.authToken)
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,8 @@ private ContentValues createContentValues(String accountName, OCCapability capab

contentValues.put(ProviderTableMeta.CAPABILITIES_CLIENT_INTEGRATION_JSON, capability.getClientIntegrationJson());

contentValues.put(ProviderTableMeta.CAPABILITIES_SHARING_JSON, capability.getSharingJson());

return contentValues;
}

Expand Down Expand Up @@ -2612,6 +2614,9 @@ private OCCapability createCapabilityInstance(Cursor cursor) {
capability.setHasValidSubscription(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_HAS_VALID_SUBSCRIPTION));

capability.setClientIntegrationJson(getString(cursor, ProviderTableMeta.CAPABILITIES_CLIENT_INTEGRATION_JSON));

capability.setSharingJson(getString(cursor, ProviderTableMeta.CAPABILITIES_SHARING_JSON));

}

return capability;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/owncloud/android/db/ProviderMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 100;
public static final int DB_VERSION = 101;

private ProviderMeta() {
// No instance
Expand Down Expand Up @@ -293,6 +293,7 @@ static public class ProviderTableMeta implements BaseColumns {
public static final String CAPABILITIES_DEFAULT_PERMISSIONS = "default_permissions";
public static final String CAPABILITIES_HAS_VALID_SUBSCRIPTION = "has_valid_subscription";
public static final String CAPABILITIES_CLIENT_INTEGRATION_JSON = "client_integration_json";
public static final String CAPABILITIES_SHARING_JSON = "sharing_json";

//Columns of Uploads table
public static final String UPLOADS_LOCAL_PATH = "local_path";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,30 @@ class FileDisplayActivity :
startMetadataSyncForRoot()
handleBackPress()
setupDrawer(menuItemId)
logOcsCredentials()
}

@Suppress("DEPRECATION")
private fun logOcsCredentials() {
lifecycleScope.launch(Dispatchers.IO) {
val user = accountManager.user
val serverUrl = user.server.uri.toString()
val accountName = user.accountName

try {
val client = clientFactory.create(user)
val username = client.userIdPlain
val authToken = client.credentials.authToken
Log_OC.d(TAG, "OCS credentials — serverUrl=$serverUrl")
Log_OC.d(TAG, "OCS credentials — accountName=$accountName username=$username authToken=$authToken")
} catch (e: CreationException) {
Log_OC.e(
TAG,
"OCS credentials — serverUrl=$serverUrl accountName=$accountName (client creation failed)",
e
)
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.button.MaterialButton
import com.nextcloud.android.common.ui.share.initShareScreen
import com.nextcloud.android.common.ui.theme.utils.ColorRole
import com.nextcloud.client.account.User
import com.nextcloud.client.account.UserAccountManager
import com.nextcloud.client.di.Injectable
import com.nextcloud.client.network.ClientFactory
import com.nextcloud.client.utils.IntentUtil
import com.nextcloud.utils.extensions.getParcelableArgument
import com.nextcloud.utils.extensions.getTypedActivity
import com.nextcloud.utils.extensions.mergeDistinctByToken
import com.nextcloud.utils.extensions.setVisibleIf
import com.nextcloud.utils.extensions.toServerCredentials
import com.nextcloud.utils.mdm.MDMConfig.shareViaUser
import com.owncloud.android.R
import com.owncloud.android.databinding.FileDetailsSharingFragmentBinding
Expand Down Expand Up @@ -141,11 +144,17 @@ class FileDetailSharingFragment :

binding?.pickContactEmailBtn?.setOnClickListener { checkContactPermission() }

fetchSharees()
// TODO: REPLACE FAKE CONDITION
if (user?.server?.version?.isNewerOrEqual(NextcloudVersion.nextcloud_34) == true || 2 < 4) {
showUnifiedShare()
} else {
fetchSharees()
}

setupView()
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
binding = FileDetailsSharingFragmentBinding.inflate(inflater, container, false)
return binding!!.getRoot()
}
Expand Down Expand Up @@ -178,6 +187,34 @@ class FileDetailSharingFragment :
// endregion

// region private methods
private fun showUnifiedShare() {
val binding = binding ?: return

binding.shareContainer.visibility = View.GONE
binding.unifiedShare.visibility = View.VISIBLE

val shimmerLayout = binding.shimmerLayout.root
shimmerLayout.clearAnimation()
shimmerLayout.visibility = View.GONE

val fileActivity = getTypedActivity(FileActivity::class.java)

lifecycleScope.launch(Dispatchers.IO) {
val client = fileActivity?.clientRepository?.getOwncloudClient() ?: return@launch
val baseURL = user?.server?.uri?.toString() ?: return@launch
val serverCredentials = client.toServerCredentials(baseURL)
val sourceId = file?.remoteId ?: return@launch

withContext(Dispatchers.Main) {
binding.unifiedShare.initShareScreen(
sourceId,
serverCredentials,
viewThemeUtils.files.getColorScheme(fileActivity)
)
}
}
}

private fun initArguments(savedInstanceState: Bundle?) {
val args = (savedInstanceState ?: arguments) ?: return
file = args.getParcelableArgument(ARG_FILE, OCFile::class.java)
Expand Down
Loading
Loading