Skip to content
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
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(remoteId: String, x: Int, y: Int): String
remoteId +
"&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 @@ -2414,6 +2414,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 @@ -2601,6 +2603,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 @@ -299,6 +299,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 @@ -34,6 +34,7 @@
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;

import com.nextcloud.android.common.ui.share.ShareScreenKt;
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
Expand All @@ -43,6 +44,7 @@
import com.nextcloud.client.utils.IntentUtil;
import com.nextcloud.utils.extensions.BundleExtensionsKt;
import com.nextcloud.utils.extensions.OCShareExtensionsKt;
import com.nextcloud.utils.extensions.OwnCloudClientExtensionsKt;
import com.nextcloud.utils.extensions.ViewExtensionsKt;
import com.nextcloud.utils.mdm.MDMConfig;
import com.owncloud.android.R;
Expand Down Expand Up @@ -208,11 +210,51 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
binding.pickContactEmailBtn.setOnClickListener(v -> checkContactPermission());

// start loading process
fetchSharees();

// TODO: REPLACE FAKE CONDITION
if (user.getServer().getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_34) || 2 < 4) {
showUnifiedShare();
} else {
fetchSharees();
}
setupView();
}

private void showUnifiedShare() {
if (binding == null) {
return;
}

binding.shareContainer.setVisibility(View.GONE);
binding.unifiedShare.setVisibility(View.VISIBLE);

final LinearLayout shimmerLayout = binding.shimmerLayout.getRoot();
shimmerLayout.clearAnimation();
shimmerLayout.setVisibility(View.GONE);

new Thread(() -> {{
try {
final var baseURL = user.getServer().getUri().toString();
final var client = clientFactory.create(user);
final var serverCredentials = OwnCloudClientExtensionsKt.toServerCredentials(client, baseURL);
final var activity = getActivity();
final var sharingCapabilities = fileDataStorageManager.getCapability(user).getSharingJson();

if (activity != null && sharingCapabilities != null) {
activity.runOnUiThread(() -> ShareScreenKt.initShareScreen(
binding.unifiedShare,
String.valueOf(file.getRemoteId()),
sharingCapabilities,
serverCredentials,
viewThemeUtils.files.getColorScheme(activity))
);

}
} catch (ClientFactory.CreationException e) {
Log_OC.e(TAG, "client creation failed");
}
}}).start();
}

private void fetchSharees() {
final var activity = fileActivity;
if (activity == null) {
Expand Down
60 changes: 33 additions & 27 deletions app/src/main/res/layout/file_details_sharing_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
~ SPDX-FileCopyrightText: 2018 Andy Scherzinger <info@andy-scherzinger.de>
~ SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
-->
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/standard_eight_padding">
android:layout_below="@id/appbar">

<FrameLayout
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/appbar">
android:paddingTop="@dimen/standard_eight_padding">

<LinearLayout
android:id="@+id/shareContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible"
android:orientation="vertical">
tools:visibility="visible">

<LinearLayout
android:id="@+id/shared_with_you_container"
Expand Down Expand Up @@ -139,33 +139,33 @@
android:layout_marginHorizontal="@dimen/standard_margin"
android:layout_marginTop="@dimen/standard_half_padding"
android:layout_marginBottom="@dimen/standard_half_padding"
android:text="@string/send_copy_to"
app:icon="@drawable/file_link"
app:iconGravity="textStart"
android:text="@string/send_copy_to" />
app:iconGravity="textStart" />

<TextView
android:id="@+id/internal_share_headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:paddingTop="@dimen/standard_half_padding"
android:paddingEnd="@dimen/zero"
android:paddingBottom="@dimen/standard_half_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/internal_shares"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/internal_share_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/standard_padding"
android:visibility="gone"
tools:visibility="visible"
android:paddingEnd="@dimen/zero"
android:paddingTop="@dimen/standard_half_padding"
android:paddingEnd="@dimen/zero"
android:paddingBottom="@dimen/standard_half_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/internal_share_description_end_to_end_encrypted"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="gone"
tools:visibility="visible" />


<androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -193,12 +193,12 @@

<TextView
android:id="@+id/external_shares_headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/standard_padding"
android:paddingEnd="@dimen/zero"
android:paddingTop="@dimen/standard_half_padding"
android:paddingEnd="@dimen/zero"
android:paddingBottom="@dimen/standard_half_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/external_shares"
android:textAppearance="?android:attr/textAppearanceMedium" />

Expand All @@ -209,9 +209,9 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/standard_margin"
android:layout_marginEnd="@dimen/standard_margin"
android:text="@string/create_link"
app:icon="@drawable/file_link"
app:iconGravity="textStart"
android:text="@string/create_link" />
app:iconGravity="textStart" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sharesList_external"
Expand All @@ -231,10 +231,16 @@
android:text="@string/show_all" />
</LinearLayout>

<include
layout="@layout/file_details_sharing_shimmer"
android:id="@+id/shimmer_layout"/>
</androidx.core.widget.NestedScrollView>

<androidx.compose.ui.platform.ComposeView
android:id="@+id/unifiedShare"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />

</FrameLayout>
<include
android:id="@+id/shimmer_layout"
layout="@layout/file_details_sharing_shimmer" />

</androidx.core.widget.NestedScrollView>
</FrameLayout>
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later

[versions]
androidCommonLibraryVersion = "0.33.2"
androidCommonLibraryVersion = "38fffa4a03"
androidGifDrawableVersion = "1.2.31"
androidImageCropperVersion = "4.7.0"
androidLibraryVersion ="1f476c0ab14fb280172be2aefd70db80e50bb17b"
Expand Down Expand Up @@ -114,7 +114,7 @@ photoview = { module = "com.github.Baseflow:PhotoView", version.ref = "photoview
material = { module = "com.google.android.material:material", version.ref = "materialVersion" }
android-gif-drawable = { module = "pl.droidsonroids.gif:android-gif-drawable", version.ref = "androidGifDrawableVersion" }
android-image-cropper = { module = "com.vanniktech:android-image-cropper", version.ref = "androidImageCropperVersion" }
androidsvg = { module = "com.caverock:androidsvg", version.ref = "androidsvgVersion" }
androidsvg = { module = "com.caverock:androidsvg-aar", version.ref = "androidsvgVersion" }
coil = { module = "io.coil-kt:coil", version.ref = "coilVersion" }
constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayoutVersion" }
emoji-google = { module = "com.vanniktech:emoji-google", version.ref = "emojiGoogleVersion" }
Expand Down
Loading
Loading