From ede05f67743ff17e0718d7d1f479f16bd4d022e6 Mon Sep 17 00:00:00 2001 From: Nextcloud bot Date: Tue, 11 Jun 2024 02:39:07 +0000 Subject: [PATCH 01/13] Fix(l10n): Update translations from Transifex Signed-off-by: Nextcloud bot --- app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-sr/strings.xml | 1 + app/src/main/res/values-tr/strings.xml | 1 + 3 files changed, 3 insertions(+) diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 8fc5b31d37..3d8dda2670 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -672,6 +672,7 @@ Sem envio de notificações devido à sessão de login desatualizada. Considere readicionar sua conta. Atualmente o envio de notificações está indisponível. Não foi possível ler o código QR! + A pasta não pode ser encontrada, a operação de sincronização foi cancelada Experimente %1$s em seu dispositivo! Quero convidar você a usar %1$s em seu dispositivo.\nBaixe daqui: %2$s %1$s ou %2$s diff --git a/app/src/main/res/values-sr/strings.xml b/app/src/main/res/values-sr/strings.xml index 2d7c5ab9f1..7f6dc7a660 100644 --- a/app/src/main/res/values-sr/strings.xml +++ b/app/src/main/res/values-sr/strings.xml @@ -672,6 +672,7 @@ Нема брзих обавештења јер је сесија застарела. Избришите и додајте поново налог. Брза обавештења тренутно нису доступна. QR кôд није могао да се прочита! + Не може да се пронађе фолдер, операција синхронизације је отказана Испробај %1$s на свом уређају! Желим да те позовем да испробаш %1$s на свом уређају.\nПреузми га овде: %2$s %1$s или %2$s diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 2a77423846..d9a1b24e93 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -672,6 +672,7 @@ Oturumunuzun süresi dolduğundan anında bildirimler gönderilemez. Lütfen hesabınızı yeniden eklemeyi düşünün. Anında bildirimler şu anda kullanılamıyor. QR kodu okunamadı! + Klasör bulunamadı. Eşitleme işlemi iptal edildi %1$s uygulamasını aygıtınız üzerinde deneyin! Aygıtında %1$s kullanmanı öneriyorum!\nŞuradan indirebilirsin: %2$s %1$s ya da %2$s From 2c3b42445b8768404972ab0409f422aeb409d8c4 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Wed, 20 Dec 2023 11:11:08 +0100 Subject: [PATCH 02/13] Add toNextcloudClient extension to OwnCloudClient Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../extensions/OwnCloudClientExtensions.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt diff --git a/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt new file mode 100644 index 0000000000..55db9ed64e --- /dev/null +++ b/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt @@ -0,0 +1,37 @@ +/* + * Nextcloud Android client application + * + * @author ZetaTom + * Copyright (C) 2023 ZetaTom + * Copyright (C) 2023 Nextcloud GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.utils.extensions + +import android.content.Context +import com.nextcloud.common.NextcloudClient +import com.owncloud.android.lib.common.OwnCloudClient +import com.owncloud.android.lib.common.OwnCloudClientFactory + +fun OwnCloudClient.toNextcloudClient(context: Context): NextcloudClient { + return OwnCloudClientFactory.createNextcloudClient( + baseUri, + userId, + credentials.toOkHttpCredentials(), + context, + isFollowRedirects + ) +} \ No newline at end of file From d6c3eb0196f248c33253868fa44d5d066dc6598c Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Mon, 8 Jan 2024 12:57:15 +0100 Subject: [PATCH 03/13] Adapt OperationsService for NextcloudClient Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../android/services/OperationsService.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/services/OperationsService.java b/app/src/main/java/com/owncloud/android/services/OperationsService.java index 6ea23a8662..f7fa577966 100644 --- a/app/src/main/java/com/owncloud/android/services/OperationsService.java +++ b/app/src/main/java/com/owncloud/android/services/OperationsService.java @@ -29,6 +29,8 @@ import android.util.Pair; import com.nextcloud.client.account.User; import com.nextcloud.client.account.UserAccountManager; +import com.nextcloud.common.NextcloudClient; +import com.nextcloud.java.util.Optional; import com.nextcloud.utils.extensions.IntentExtensionsKt; import com.owncloud.android.MainApp; import com.owncloud.android.datamodel.ArbitraryDataProvider; @@ -260,7 +262,7 @@ public class OperationsService extends Service { */ private final ConcurrentMap mBoundListeners = new ConcurrentHashMap<>(); - private ServiceHandler mServiceHandler; + private final ServiceHandler mServiceHandler; public OperationsServiceBinder(ServiceHandler serviceHandler) { mServiceHandler = serviceHandler; @@ -380,7 +382,7 @@ public class OperationsService extends Service { OperationsService mService; - private ConcurrentLinkedQueue> mPendingOperations = + private final ConcurrentLinkedQueue> mPendingOperations = new ConcurrentLinkedQueue<>(); private RemoteOperation mCurrentOperation; private Target mLastTarget; @@ -416,11 +418,12 @@ public class OperationsService extends Service { if (next != null) { mCurrentOperation = next.second; RemoteOperationResult result; + OwnCloudAccount ocAccount = null; + try { /// prepare client object to send the request to the ownCloud server if (mLastTarget == null || !mLastTarget.equals(next.first)) { mLastTarget = next.first; - OwnCloudAccount ocAccount; if (mLastTarget.mAccount != null) { ocAccount = new OwnCloudAccount(mLastTarget.mAccount, mService); } else { @@ -430,9 +433,21 @@ public class OperationsService extends Service { getClientFor(ocAccount, mService); } - /// perform the operation - result = mCurrentOperation.execute(mOwnCloudClient); - } catch (AccountsException e) { + // perform the operation + try { + result = mCurrentOperation.execute(mOwnCloudClient); + } catch (UnsupportedOperationException e) { + // TODO remove - added to aid in transition to NextcloudClient + + if (ocAccount == null) { + throw e; + } + + NextcloudClient nextcloudClient = OwnCloudClientManagerFactory.getDefaultSingleton() + .getNextcloudClientFor(ocAccount, mService.getBaseContext()); + result = mCurrentOperation.run(nextcloudClient); + } + } catch (AccountsException | IOException e) { if (mLastTarget.mAccount == null) { Log_OC.e(TAG, "Error while trying to get authorization for a NULL account", e); @@ -442,15 +457,6 @@ public class OperationsService extends Service { } result = new RemoteOperationResult(e); - } catch (IOException e) { - if (mLastTarget.mAccount == null) { - Log_OC.e(TAG, "Error while trying to get authorization for a NULL account", - e); - } else { - Log_OC.e(TAG, "Error while trying to get authorization for " + - mLastTarget.mAccount.name, e); - } - result = new RemoteOperationResult(e); } catch (Exception e) { if (mLastTarget.mAccount == null) { Log_OC.e(TAG, "Unexpected error for a NULL account", e); @@ -537,10 +543,6 @@ public class OperationsService extends Service { false); updateLinkOperation.setHideFileDownload(hideFileDownload); -// if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) { -// updateLinkOperation.setPublicUpload(true); -// } - if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_LABEL)) { updateLinkOperation.setLabel(operationIntent.getStringExtra(EXTRA_SHARE_PUBLIC_LABEL)); } From 97e31644ce16bb870e4ad1c9e4e6fc0ae4061ec1 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Mon, 27 Nov 2023 14:09:57 +0100 Subject: [PATCH 04/13] Deprecate OwncloudClient - Notifications Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../ui/activity/NotificationsActivity.kt | 14 ++--- .../ui/adapter/NotificationListAdapter.java | 6 +- .../DeleteAllNotificationsTask.java | 8 +-- .../ui/asynctasks/DeleteNotificationTask.java | 6 +- .../NotificationExecuteActionTask.java | 55 ++++++++----------- 5 files changed, 39 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt index 63b9573cb7..471390356e 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.kt @@ -19,11 +19,11 @@ import com.nextcloud.client.account.User import com.nextcloud.client.account.UserAccountManager import com.nextcloud.client.jobs.NotificationWork import com.nextcloud.client.network.ClientFactory.CreationException +import com.nextcloud.common.NextcloudClient import com.owncloud.android.R import com.owncloud.android.databinding.NotificationsLayoutBinding import com.owncloud.android.datamodel.ArbitraryDataProvider import com.owncloud.android.datamodel.ArbitraryDataProviderImpl -import com.owncloud.android.lib.common.OwnCloudClient import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.notifications.GetNotificationsRemoteOperation import com.owncloud.android.lib.resources.notifications.models.Notification @@ -44,7 +44,7 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View { private var adapter: NotificationListAdapter? = null private var snackbar: Snackbar? = null - private var client: OwnCloudClient? = null + private var client: NextcloudClient? = null private var optionalUser: Optional? = null override fun onCreate(savedInstanceState: Bundle?) { @@ -213,16 +213,16 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View { val t = Thread { initializeAdapter() val getRemoteNotificationOperation = GetNotificationsRemoteOperation() - val result = getRemoteNotificationOperation.execute(client) - if (result.isSuccess && result.resultData != null) { + val result = client?.let { getRemoteNotificationOperation.execute(it) } + if (result?.isSuccess == true && result.resultData != null) { runOnUiThread { populateList(result.resultData) } } else { - Log_OC.d(TAG, result.logMessage) + Log_OC.d(TAG, result?.logMessage) // show error runOnUiThread { setEmptyContent( getString(R.string.notifications_no_results_headline), - result.logMessage + result?.logMessage ) } } @@ -235,7 +235,7 @@ class NotificationsActivity : DrawerActivity(), NotificationsContract.View { if (client == null && optionalUser?.isPresent == true) { try { val user = optionalUser?.get() - client = clientFactory.create(user) + client = clientFactory.createNextcloudClient(user) } catch (e: CreationException) { Log_OC.e(TAG, "Error initializing client", e) } diff --git a/app/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java b/app/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java index 99cf32ab66..0894dd98ac 100644 --- a/app/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java +++ b/app/src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java @@ -36,9 +36,9 @@ import com.bumptech.glide.load.resource.file.FileToStreamDecoder; import com.caverock.androidsvg.SVG; import com.google.android.material.button.MaterialButton; import com.nextcloud.android.common.ui.theme.utils.ColorRole; +import com.nextcloud.common.NextcloudClient; import com.owncloud.android.R; import com.owncloud.android.databinding.NotificationListItemBinding; -import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.resources.notifications.models.Action; import com.owncloud.android.lib.resources.notifications.models.Notification; import com.owncloud.android.lib.resources.notifications.models.RichObject; @@ -71,11 +71,11 @@ public class NotificationListAdapter extends RecyclerView.Adapter notificationsList; - private final OwnCloudClient client; + private final NextcloudClient client; private final NotificationsActivity notificationsActivity; private final ViewThemeUtils viewThemeUtils; - public NotificationListAdapter(OwnCloudClient client, + public NotificationListAdapter(NextcloudClient client, NotificationsActivity notificationsActivity, ViewThemeUtils viewThemeUtils) { this.notificationsList = new ArrayList<>(); diff --git a/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteAllNotificationsTask.java b/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteAllNotificationsTask.java index 3afbc89a12..26165a2aae 100644 --- a/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteAllNotificationsTask.java +++ b/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteAllNotificationsTask.java @@ -9,7 +9,7 @@ package com.owncloud.android.ui.asynctasks; import android.os.AsyncTask; -import com.owncloud.android.lib.common.OwnCloudClient; +import com.nextcloud.common.NextcloudClient; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.notifications.DeleteAllNotificationsRemoteOperation; import com.owncloud.android.lib.resources.notifications.models.Action; @@ -17,10 +17,10 @@ import com.owncloud.android.ui.activity.NotificationsActivity; import com.owncloud.android.ui.notifications.NotificationsContract; public class DeleteAllNotificationsTask extends AsyncTask { - private OwnCloudClient client; - private NotificationsContract.View notificationsActivity; + private NextcloudClient client; + private final NotificationsContract.View notificationsActivity; - public DeleteAllNotificationsTask(OwnCloudClient client, NotificationsActivity notificationsActivity) { + public DeleteAllNotificationsTask(NextcloudClient client, NotificationsActivity notificationsActivity) { this.client = client; this.notificationsActivity = notificationsActivity; } diff --git a/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java b/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java index 2e414e005d..458e642b49 100644 --- a/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java +++ b/app/src/main/java/com/owncloud/android/ui/asynctasks/DeleteNotificationTask.java @@ -9,7 +9,7 @@ package com.owncloud.android.ui.asynctasks; import android.os.AsyncTask; -import com.owncloud.android.lib.common.OwnCloudClient; +import com.nextcloud.common.NextcloudClient; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.notifications.DeleteNotificationRemoteOperation; import com.owncloud.android.lib.resources.notifications.models.Action; @@ -21,10 +21,10 @@ import com.owncloud.android.ui.notifications.NotificationsContract; public class DeleteNotificationTask extends AsyncTask { private Notification notification; private NotificationListAdapter.NotificationViewHolder holder; - private OwnCloudClient client; + private NextcloudClient client; private NotificationsContract.View notificationsActivity; - public DeleteNotificationTask(OwnCloudClient client, Notification notification, + public DeleteNotificationTask(NextcloudClient client, Notification notification, NotificationListAdapter.NotificationViewHolder holder, NotificationsActivity notificationsActivity) { this.client = client; diff --git a/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java b/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java index 47b6e8ba9f..79a3669294 100644 --- a/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java +++ b/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java @@ -8,7 +8,12 @@ package com.owncloud.android.ui.asynctasks; import android.os.AsyncTask; -import com.owncloud.android.lib.common.OwnCloudClient; +import com.nextcloud.common.NextcloudClient; +import com.nextcloud.common.OkHttpMethodBase; +import com.nextcloud.operations.DeleteMethod; +import com.nextcloud.operations.GetMethod; +import com.nextcloud.operations.PostMethod; +import com.nextcloud.operations.PutMethod; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.notifications.models.Action; @@ -16,23 +21,18 @@ import com.owncloud.android.lib.resources.notifications.models.Notification; import com.owncloud.android.ui.activity.NotificationsActivity; import com.owncloud.android.ui.adapter.NotificationListAdapter; -import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.methods.DeleteMethod; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PutMethod; -import org.apache.commons.httpclient.methods.Utf8PostMethod; import java.io.IOException; public class NotificationExecuteActionTask extends AsyncTask { - private NotificationListAdapter.NotificationViewHolder holder; - private OwnCloudClient client; - private Notification notification; - private NotificationsActivity notificationsActivity; + private final NotificationListAdapter.NotificationViewHolder holder; + private final NextcloudClient client; + private final Notification notification; + private final NotificationsActivity notificationsActivity; - public NotificationExecuteActionTask(OwnCloudClient client, + public NotificationExecuteActionTask(NextcloudClient client, NotificationListAdapter.NotificationViewHolder holder, Notification notification, NotificationsActivity notificationsActivity) { @@ -44,39 +44,28 @@ public class NotificationExecuteActionTask extends AsyncTask method = new GetMethod(action.link, true); + case "POST" -> method = new PostMethod(action.link, true, null); + case "DELETE" -> method = new DeleteMethod(action.link, true); + case "PUT" -> method = new PutMethod(action.link, true, null); + default -> { // do nothing - return Boolean.FALSE; + return false; + } } - method.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE); + method.addRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE); int status; try { - status = client.executeMethod(method); + status = client.execute(method); } catch (IOException e) { Log_OC.e(this, "Execution of notification action failed: " + e); - return Boolean.FALSE; + return false; } finally { method.releaseConnection(); } From 739bcd0029f33344a41e1d141c562f07be6ee07e Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:23:05 +0100 Subject: [PATCH 05/13] Set library branch in build.gradle Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b327c656a1..ad19f8742e 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ */ buildscript { ext { - androidLibraryVersion ="26dc8477962f12356db840bb1a774f0186b38e4d" + androidLibraryVersion ="depocc/notifications-SNAPSHOT" androidPluginVersion = '8.4.0' androidxMediaVersion = '1.3.1' androidxTestVersion = "1.5.0" From 1897ad19d65c081ee78c8bbc95395be9f4f2a137 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Tue, 30 Jan 2024 11:50:12 +0100 Subject: [PATCH 06/13] Replace OwnCloudClient instances Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../java/com/nextcloud/client/jobs/NotificationWork.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt b/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt index 9e560a907f..e6f37a16e2 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt @@ -29,6 +29,7 @@ import com.nextcloud.client.integrations.deck.DeckApi import com.owncloud.android.R import com.owncloud.android.datamodel.DecryptedPushMessage import com.owncloud.android.lib.common.OwnCloudClient +import com.owncloud.android.lib.common.OwnCloudClientFactory import com.owncloud.android.lib.common.OwnCloudClientManagerFactory import com.owncloud.android.lib.common.operations.RemoteOperation import com.owncloud.android.lib.common.utils.Log_OC @@ -236,8 +237,7 @@ class NotificationWork constructor( } val user = optionalUser.get() try { - val client = OwnCloudClientManagerFactory.getDefaultSingleton() - .getClientFor(user.toOwnCloudAccount(), context) + val client = OwnCloudClientFactory.createNextcloudClient(user, context) val result = GetNotificationRemoteOperation(decryptedPushMessage.nid) .execute(client) if (result.isSuccess) { @@ -287,6 +287,7 @@ class NotificationWork constructor( val user = optionalUser.get() val client = OwnCloudClientManagerFactory.getDefaultSingleton() .getClientFor(user.toOwnCloudAccount(), context) + val nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user, context) val actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE) val actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK) val success: Boolean = if (!actionType.isNullOrEmpty() && !actionLink.isNullOrEmpty()) { @@ -294,7 +295,7 @@ class NotificationWork constructor( resultCode == HttpStatus.SC_OK || resultCode == HttpStatus.SC_ACCEPTED } else { DeleteNotificationRemoteOperation(numericNotificationId) - .execute(client).isSuccess + .execute(nextcloudClient).isSuccess } if (success) { if (oldNotification == null) { From c4f5cf4cd08d8432d1b0d96c2caf35741e2bbf81 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 10 Jun 2024 16:32:17 +0200 Subject: [PATCH 07/13] update Signed-off-by: tobiasKaminsky --- scripts/analysis/detectWrongSettings.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/analysis/detectWrongSettings.sh b/scripts/analysis/detectWrongSettings.sh index e62281ac1d..d917f93168 100755 --- a/scripts/analysis/detectWrongSettings.sh +++ b/scripts/analysis/detectWrongSettings.sh @@ -4,10 +4,12 @@ # SPDX-FileCopyrightText: 2016 Tobias Kaminsky # SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only -snapshotCount=$(./gradlew dependencies | grep SNAPSHOT | grep -v "com.github.nextcloud:android-library" -c) +snapshotCount=$(./gradlew dependencies | grep SNAPSHOT -c) betaCount=$(grep "true" app/src/main/res/values/setup.xml -c) +libraryHash=$(grep library build.gradle | cut -f2 -d'"' | grep "^[0-9a-zA-Z]\{40\}$" -c) -if [[ $snapshotCount -eq 0 && $betaCount -eq 0 ]] ; then + +if [[ $snapshotCount -eq 0 && $betaCount -eq 0 && $libraryHash = 1 ]] ; then exit 0 else exit 1 From af68e379aefa32014f03b3edc010a72cf36b5c2d Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 11 Jun 2024 07:06:42 +0200 Subject: [PATCH 08/13] use jitpack Signed-off-by: tobiasKaminsky --- .../java/com/owncloud/android/services/OperationsService.java | 1 - build.gradle | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/services/OperationsService.java b/app/src/main/java/com/owncloud/android/services/OperationsService.java index f7fa577966..4cf151b3f7 100644 --- a/app/src/main/java/com/owncloud/android/services/OperationsService.java +++ b/app/src/main/java/com/owncloud/android/services/OperationsService.java @@ -30,7 +30,6 @@ import android.util.Pair; import com.nextcloud.client.account.User; import com.nextcloud.client.account.UserAccountManager; import com.nextcloud.common.NextcloudClient; -import com.nextcloud.java.util.Optional; import com.nextcloud.utils.extensions.IntentExtensionsKt; import com.owncloud.android.MainApp; import com.owncloud.android.datamodel.ArbitraryDataProvider; diff --git a/build.gradle b/build.gradle index ad19f8742e..df64b1ce23 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ */ buildscript { ext { - androidLibraryVersion ="depocc/notifications-SNAPSHOT" + androidLibraryVersion = "depocc~notifications-SNAPSHOT" androidPluginVersion = '8.4.0' androidxMediaVersion = '1.3.1' androidxTestVersion = "1.5.0" From c9372dd018bbf4877b6c4dd5084cbea6a42579bc Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 11 Jun 2024 07:08:02 +0200 Subject: [PATCH 09/13] wip Signed-off-by: tobiasKaminsky --- .../com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt index 55db9ed64e..144f72d9e5 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt @@ -34,4 +34,4 @@ fun OwnCloudClient.toNextcloudClient(context: Context): NextcloudClient { context, isFollowRedirects ) -} \ No newline at end of file +} From dfbc9f9ea16decb506bda20e6298cb51a8c612fa Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 11 Jun 2024 07:27:33 +0200 Subject: [PATCH 10/13] wip Signed-off-by: tobiasKaminsky --- .../extensions/OwnCloudClientExtensions.kt | 21 ++++--------------- build.gradle | 2 +- scripts/analysis/detectWrongSettings.sh | 16 +++++++++++--- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt index 144f72d9e5..2b36ebf5b9 100644 --- a/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt +++ b/app/src/main/java/com/nextcloud/utils/extensions/OwnCloudClientExtensions.kt @@ -1,22 +1,9 @@ /* - * Nextcloud Android client application + * Nextcloud - Android Client * - * @author ZetaTom - * Copyright (C) 2023 ZetaTom - * Copyright (C) 2023 Nextcloud GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * SPDX-FileCopyrightText: 2023 ZetaTom + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH + * SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only */ package com.nextcloud.utils.extensions diff --git a/build.gradle b/build.gradle index df64b1ce23..ccdbe63537 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ */ buildscript { ext { - androidLibraryVersion = "depocc~notifications-SNAPSHOT" + androidLibraryVersion = "cda1b08aa81b74201177f29c2326abee62f32c15" androidPluginVersion = '8.4.0' androidxMediaVersion = '1.3.1' androidxTestVersion = "1.5.0" diff --git a/scripts/analysis/detectWrongSettings.sh b/scripts/analysis/detectWrongSettings.sh index d917f93168..301d794e64 100755 --- a/scripts/analysis/detectWrongSettings.sh +++ b/scripts/analysis/detectWrongSettings.sh @@ -9,9 +9,19 @@ betaCount=$(grep "true" app/src/main/res/values/se libraryHash=$(grep library build.gradle | cut -f2 -d'"' | grep "^[0-9a-zA-Z]\{40\}$" -c) -if [[ $snapshotCount -eq 0 && $betaCount -eq 0 && $libraryHash = 1 ]] ; then - exit 0 -else +if [[ $snapshotCount -gt 0 ]] ; then + echo "Snapshot found in dependencies" + exit 1 +fi +if [[ $betaCount -gt 0 ]] ; then + echo "Beta is set in setup.xml" + exit 1 +fi + +if [[ $libraryHash = 0 ]] ; then + echo "Library hash is wrong!" exit 1 fi +exit 0 + From a951743f60747d4f567b909e33917e2f933ccda4 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 11 Jun 2024 07:31:58 +0200 Subject: [PATCH 11/13] Deprecate OwncloudClient - Notifications Signed-off-by: tobiasKaminsky --- gradle/verification-metadata.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 7180d6aafd..ca062cae51 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -5805,6 +5805,17 @@ + + + + + + + + From cc18e2b7023627401b4fe32ce6c253a7c80e0458 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 11 Jun 2024 07:38:22 +0200 Subject: [PATCH 12/13] fix script Signed-off-by: tobiasKaminsky --- scripts/analysis/detectWrongSettings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/analysis/detectWrongSettings.sh b/scripts/analysis/detectWrongSettings.sh index 301d794e64..1af82b0228 100755 --- a/scripts/analysis/detectWrongSettings.sh +++ b/scripts/analysis/detectWrongSettings.sh @@ -6,7 +6,7 @@ snapshotCount=$(./gradlew dependencies | grep SNAPSHOT -c) betaCount=$(grep "true" app/src/main/res/values/setup.xml -c) -libraryHash=$(grep library build.gradle | cut -f2 -d'"' | grep "^[0-9a-zA-Z]\{40\}$" -c) +libraryHash=$(grep androidLibraryVersion build.gradle | cut -f2 -d'"' | grep "^[0-9a-zA-Z]\{40\}$" -c) if [[ $snapshotCount -gt 0 ]] ; then @@ -18,7 +18,7 @@ if [[ $betaCount -gt 0 ]] ; then exit 1 fi -if [[ $libraryHash = 0 ]] ; then +if [[ $libraryHash -eq 0 ]] ; then echo "Library hash is wrong!" exit 1 fi From ba40293689f5611b12b724ee08f9d0910a802cd1 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 11 Jun 2024 08:21:40 +0200 Subject: [PATCH 13/13] fix Signed-off-by: tobiasKaminsky --- .../com/owncloud/android/utils/PushUtils.java | 18 +++++++----------- .../NotificationExecuteActionTask.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/src/gplay/java/com/owncloud/android/utils/PushUtils.java b/app/src/gplay/java/com/owncloud/android/utils/PushUtils.java index 30f5a93624..816612e690 100644 --- a/app/src/gplay/java/com/owncloud/android/utils/PushUtils.java +++ b/app/src/gplay/java/com/owncloud/android/utils/PushUtils.java @@ -19,6 +19,7 @@ import com.google.gson.Gson; import com.nextcloud.client.account.UserAccountManager; import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.client.preferences.AppPreferencesImpl; +import com.nextcloud.common.NextcloudClient; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.ArbitraryDataProvider; @@ -26,9 +27,7 @@ import com.owncloud.android.datamodel.ArbitraryDataProviderImpl; import com.owncloud.android.datamodel.PushConfigurationState; import com.owncloud.android.datamodel.SignatureVerification; import com.owncloud.android.lib.common.OwnCloudAccount; -import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; -import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.notifications.RegisterAccountDeviceForNotificationsOperation; @@ -131,14 +130,11 @@ public final class PushUtils { try { ocAccount = new OwnCloudAccount(account, context); - OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton(). - getClientFor(ocAccount, context); + NextcloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton(). + getNextcloudClientFor(ocAccount, context); - RemoteOperation unregisterAccountDeviceForNotificationsOperation = new - UnregisterAccountDeviceForNotificationsOperation(); - - RemoteOperationResult remoteOperationResult = unregisterAccountDeviceForNotificationsOperation. - execute(mClient); + RemoteOperationResult remoteOperationResult = + new UnregisterAccountDeviceForNotificationsOperation().execute(mClient); if (remoteOperationResult.getHttpCode() == HttpStatus.SC_ACCEPTED) { String arbitraryValue; @@ -201,8 +197,8 @@ public final class PushUtils { TextUtils.isEmpty(providerValue)) { try { OwnCloudAccount ocAccount = new OwnCloudAccount(account, context); - OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton(). - getClientFor(ocAccount, context); + NextcloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton(). + getNextcloudClientFor(ocAccount, context); RemoteOperationResult remoteOperationResult = new RegisterAccountDeviceForNotificationsOperation(pushTokenHash, diff --git a/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java b/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java index 79a3669294..1e3d15d650 100644 --- a/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java +++ b/app/src/main/java/com/owncloud/android/ui/asynctasks/NotificationExecuteActionTask.java @@ -25,6 +25,8 @@ import org.apache.commons.httpclient.HttpStatus; import java.io.IOException; +import okhttp3.RequestBody; + public class NotificationExecuteActionTask extends AsyncTask { private final NotificationListAdapter.NotificationViewHolder holder; @@ -47,14 +49,18 @@ public class NotificationExecuteActionTask extends AsyncTask method = new GetMethod(action.link, true); - case "POST" -> method = new PostMethod(action.link, true, null); + case "POST" -> method = new PostMethod(action.link, true, RequestBody.create("", null)); case "DELETE" -> method = new DeleteMethod(action.link, true); case "PUT" -> method = new PutMethod(action.link, true, null); default -> { // do nothing - return false; + return Boolean.FALSE; } } @@ -65,7 +71,7 @@ public class NotificationExecuteActionTask extends AsyncTask