diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e4f29e5532..a2eecf2251 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:noble@sha256:3f85b7caad41a95462cf5b787d8a04604c8262cdcdf9a472b8c52ef83375fe15 +FROM ubuntu:noble@sha256:e3f92abc0967a6c19d0dfa2d55838833e947b9d74edbcb0113e48535ad4be12a ARG DEBIAN_FRONTEND=noninteractive ENV ANDROID_HOME=/usr/lib/android-sdk diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 5e5a2077e0..ee633dee56 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -44,7 +44,7 @@ jobs: echo "repo=${{ github.event.pull_request.head.repo.full_name }}" } >> "$GITHUB_OUTPUT" fi - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: ${{ steps.get-vars.outputs.repo }} ref: ${{ steps.get-vars.outputs.branch }} diff --git a/.github/workflows/assembleFlavors.yml b/.github/workflows/assembleFlavors.yml index 5dcda08bfd..45898f1a3f 100644 --- a/.github/workflows/assembleFlavors.yml +++ b/.github/workflows/assembleFlavors.yml @@ -22,7 +22,7 @@ jobs: matrix: flavor: [ Generic, Gplay, Huawei ] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: set up JDK 17 uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 95afec2c35..0a79955c94 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -22,7 +22,7 @@ jobs: matrix: task: [ detekt, spotlessKotlinCheck ] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up JDK 17 uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1af57c9e71..326bd8d6cf 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,13 +33,13 @@ jobs: language: [ 'java' ] steps: - name: Checkout repository - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set Swap Space uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0 with: swap-size-gb: 10 - name: Initialize CodeQL - uses: github/codeql-action/init@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 + uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 with: languages: ${{ matrix.language }} - name: Set up JDK 17 @@ -53,4 +53,4 @@ jobs: echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties" ./gradlew assembleDebug - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 + uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 diff --git a/.github/workflows/command-rebase.yml b/.github/workflows/command-rebase.yml index ccfeb1f9a1..6f801d45f0 100644 --- a/.github/workflows/command-rebase.yml +++ b/.github/workflows/command-rebase.yml @@ -34,7 +34,7 @@ jobs: reaction-type: "+1" - name: Checkout the latest code - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 token: ${{ secrets.COMMAND_BOT_PAT }} diff --git a/.github/workflows/detectWrongSettings.yml b/.github/workflows/detectWrongSettings.yml index 75f59c4fc4..88ffc03331 100644 --- a/.github/workflows/detectWrongSettings.yml +++ b/.github/workflows/detectWrongSettings.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up JDK 17 uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index aba8a0e794..0bb1c1a8dc 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -25,5 +25,5 @@ jobs: name: "Validation" runs-on: ubuntu-latest steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: gradle/wrapper-validation-action@216d1ad2b3710bf005dc39237337b9673fd8fcd5 # v3.3.2 diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index c8eb858204..e1d5e67b23 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -23,7 +23,7 @@ jobs: - name: Check if secrets are available run: echo "::set-output name=ok::${{ secrets.KS_PASS != '' }}" id: check-secrets - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 if: ${{ steps.check-secrets.outputs.ok == 'true' }} - name: set up JDK 17 uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index fa62e61e74..3d095278e4 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -15,6 +15,6 @@ jobs: reuse-compliance-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: REUSE Compliance Check uses: fsfe/reuse-action@a46482ca367aef4454a87620aa37c2be4b2f8106 # v3.0.0 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index a67030c099..70e087f6ee 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -29,7 +29,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false @@ -42,6 +42,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8 + uses: github/codeql-action/upload-sarif@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10 with: sarif_file: results.sarif diff --git a/.github/workflows/screenShotTest.yml b/.github/workflows/screenShotTest.yml index f1faa2e4a9..224e78be54 100644 --- a/.github/workflows/screenShotTest.yml +++ b/.github/workflows/screenShotTest.yml @@ -25,7 +25,7 @@ jobs: color: [ blue ] api-level: [ 27 ] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Gradle cache uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6bf699b1c3..9d1be31a66 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -21,7 +21,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up JDK 17 uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 with: diff --git a/app/screenshots/gplay/debug/com.nextcloud.client.AuthenticatorActivityIT_login.png b/app/screenshots/gplay/debug/com.nextcloud.client.AuthenticatorActivityIT_login.png index cb5dac2868..a351456e61 100644 Binary files a/app/screenshots/gplay/debug/com.nextcloud.client.AuthenticatorActivityIT_login.png and b/app/screenshots/gplay/debug/com.nextcloud.client.AuthenticatorActivityIT_login.png differ diff --git a/app/screenshots/gplay/debug/com.nextcloud.client.FirstRunActivityIT_open.png b/app/screenshots/gplay/debug/com.nextcloud.client.FirstRunActivityIT_open.png index ebb2c94490..bb9d8107c2 100644 Binary files a/app/screenshots/gplay/debug/com.nextcloud.client.FirstRunActivityIT_open.png and b/app/screenshots/gplay/debug/com.nextcloud.client.FirstRunActivityIT_open.png differ diff --git a/app/src/androidTest/java/com/owncloud/android/utils/theme/CapabilityUtilsIT.kt b/app/src/androidTest/java/com/owncloud/android/utils/theme/CapabilityUtilsIT.kt index 877b38b116..96062279d4 100644 --- a/app/src/androidTest/java/com/owncloud/android/utils/theme/CapabilityUtilsIT.kt +++ b/app/src/androidTest/java/com/owncloud/android/utils/theme/CapabilityUtilsIT.kt @@ -30,7 +30,6 @@ class CapabilityUtilsIT : AbstractIT() { assertTrue(test(OwnCloudVersion.nextcloud_19)) assertTrue(test(OwnCloudVersion.nextcloud_18)) assertTrue(test(OwnCloudVersion.nextcloud_17)) - assertTrue(test(OwnCloudVersion.nextcloud_16)) } private fun test(version: OwnCloudVersion): Boolean { diff --git a/app/src/main/java/com/nextcloud/client/account/CurrentAccountProvider.java b/app/src/main/java/com/nextcloud/client/account/CurrentAccountProvider.java index 58b3371efc..fbe2e8503c 100644 --- a/app/src/main/java/com/nextcloud/client/account/CurrentAccountProvider.java +++ b/app/src/main/java/com/nextcloud/client/account/CurrentAccountProvider.java @@ -24,7 +24,7 @@ public interface CurrentAccountProvider { * @return Currently selected {@link Account} or first valid {@link Account} registered in OS or null, if not available at all. */ @Deprecated - @Nullable + @NonNull Account getCurrentAccount(); /** diff --git a/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java b/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java index 40709c984c..1554e68e81 100644 --- a/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java +++ b/app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java @@ -18,9 +18,9 @@ import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.text.TextUtils; -import android.util.Log; import com.nextcloud.common.NextcloudClient; +import com.nextcloud.utils.extensions.AccountExtensionsKt; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AuthenticatorActivity; @@ -39,6 +39,7 @@ import com.owncloud.android.lib.resources.users.GetUserInfoRemoteOperation; import java.io.IOException; import java.net.URI; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -132,42 +133,42 @@ public class UserAccountManagerImpl implements UserAccountManager { } @Override - @Nullable + @NonNull public Account getCurrentAccount() { Account[] ocAccounts = getAccounts(); - Account defaultAccount = null; ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProviderImpl(context); - SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context); String accountName = appPreferences.getString(PREF_SELECT_OC_ACCOUNT, null); - // account validation: the saved account MUST be in the list of ownCloud Accounts known by the AccountManager - if (accountName != null) { - for (Account account : ocAccounts) { - if (account.name.equals(accountName)) { - defaultAccount = account; - break; - } - } + Account defaultAccount = Arrays.stream(ocAccounts) + .filter(account -> account.name.equals(accountName)) + .findFirst() + .orElse(null); + + // take first which is not pending for removal account as fallback + if (defaultAccount == null) { + defaultAccount = Arrays.stream(ocAccounts) + .filter(account -> !arbitraryDataProvider.getBooleanValue(account.name, PENDING_FOR_REMOVAL)) + .findFirst() + .orElse(null); } - if (defaultAccount == null && ocAccounts.length > 0) { - // take first which is not pending for removal account as fallback - for (Account account: ocAccounts) { - boolean pendingForRemoval = arbitraryDataProvider.getBooleanValue(account.name, - PENDING_FOR_REMOVAL); - - if (!pendingForRemoval) { - defaultAccount = account; - break; - } + if (defaultAccount == null) { + if (ocAccounts.length > 0) { + defaultAccount = ocAccounts[0]; + } else { + defaultAccount = getAnonymousAccount(); } } return defaultAccount; } + private Account getAnonymousAccount() { + return new Account("Anonymous", context.getString(R.string.anonymous_account_type)); + } + /** * Temporary solution to convert platform account to user instance. * It takes null and returns null on error to ease error handling @@ -177,8 +178,8 @@ public class UserAccountManagerImpl implements UserAccountManager { * @return User instance or null, if conversion failed */ @Nullable - private User createUserFromAccount(@Nullable Account account) { - if (account == null) { + private User createUserFromAccount(@NonNull Account account) { + if (AccountExtensionsKt.isAnonymous(account, context)) { return null; } @@ -260,7 +261,7 @@ public class UserAccountManagerImpl implements UserAccountManager { } @Override - @Nullable + @NonNull public Account getAccountByName(String name) { for (Account account : getAccounts()) { if (account.name.equals(name)) { @@ -268,7 +269,7 @@ public class UserAccountManagerImpl implements UserAccountManager { } } - return null; + return getAnonymousAccount(); } @Override diff --git a/app/src/main/java/com/nextcloud/client/di/AppModule.java b/app/src/main/java/com/nextcloud/client/di/AppModule.java index 472af83d78..a87b01ee1f 100644 --- a/app/src/main/java/com/nextcloud/client/di/AppModule.java +++ b/app/src/main/java/com/nextcloud/client/di/AppModule.java @@ -100,8 +100,7 @@ class AppModule { @Provides UserAccountManager userAccountManager( Context context, - AccountManager accountManager - ) { + AccountManager accountManager) { return new UserAccountManagerImpl(context, accountManager); } diff --git a/app/src/main/java/com/nextcloud/client/mixins/SessionMixin.kt b/app/src/main/java/com/nextcloud/client/mixins/SessionMixin.kt index 4adff4d6a4..6cbd513263 100644 --- a/app/src/main/java/com/nextcloud/client/mixins/SessionMixin.kt +++ b/app/src/main/java/com/nextcloud/client/mixins/SessionMixin.kt @@ -9,14 +9,12 @@ package com.nextcloud.client.mixins import android.accounts.Account import android.app.Activity -import android.content.ContentResolver import android.content.Intent import android.os.Bundle import com.nextcloud.client.account.User import com.nextcloud.client.account.UserAccountManager -import com.owncloud.android.datamodel.FileDataStorageManager +import com.nextcloud.utils.extensions.isAnonymous import com.owncloud.android.lib.resources.status.OCCapability -import com.owncloud.android.ui.activity.BaseActivity import com.owncloud.android.utils.theme.CapabilityUtils import java.util.Optional @@ -27,36 +25,25 @@ import java.util.Optional * It is an intermediary step facilitating comprehensive rework of * account handling logic. */ -class SessionMixin constructor( +class SessionMixin( private val activity: Activity, - private val contentResolver: ContentResolver, private val accountManager: UserAccountManager ) : ActivityMixin { - - private companion object { - private val TAG = BaseActivity::class.java.simpleName - } - - var currentAccount: Account? = null - private set - var storageManager: FileDataStorageManager? = null + lateinit var currentAccount: Account private set + val capabilities: OCCapability? get() = getUser() .map { CapabilityUtils.getCapability(it, activity) } .orElse(null) - fun setAccount(account: Account?) { - val validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name) - if (validAccount) { - currentAccount = account - } else { - swapToDefaultAccount() - } + fun setAccount(account: Account) { + val validAccount = (accountManager.setCurrentOwnCloudAccount(account.name)) - currentAccount?.let { - val storageManager = FileDataStorageManager(getUser().get(), contentResolver) - this.storageManager = storageManager + currentAccount = if (validAccount) { + account + } else { + getDefaultAccount() } } @@ -64,9 +51,12 @@ class SessionMixin constructor( setAccount(user.toPlatformAccount()) } - fun getUser(): Optional = when (val it = this.currentAccount) { - null -> Optional.empty() - else -> accountManager.getUser(it.name) + fun getUser(): Optional { + return if (currentAccount.isAnonymous(activity)) { + Optional.empty() + } else { + accountManager.getUser(currentAccount.name) + } } /** @@ -75,16 +65,14 @@ class SessionMixin constructor( * If no valid ownCloud [Account] exists, then the user is requested * to create a new ownCloud [Account]. */ - private fun swapToDefaultAccount() { - // default to the most recently used account - val newAccount = accountManager.currentAccount - if (newAccount == null) { - // no account available: force account creation - currentAccount = null + private fun getDefaultAccount(): Account { + val defaultAccount = accountManager.currentAccount + + if (defaultAccount.isAnonymous(activity)) { startAccountCreation() - } else { - currentAccount = newAccount } + + return defaultAccount } /** @@ -98,7 +86,7 @@ class SessionMixin constructor( super.onNewIntent(intent) val current = accountManager.currentAccount val currentAccount = this.currentAccount - if (current != null && currentAccount != null && !currentAccount.name.equals(current.name)) { + if (!currentAccount.name.equals(current.name)) { this.currentAccount = current } } @@ -109,9 +97,9 @@ class SessionMixin constructor( */ override fun onRestart() { super.onRestart() - val validAccount = currentAccount != null && accountManager.exists(currentAccount) + val validAccount = accountManager.exists(currentAccount) if (!validAccount) { - swapToDefaultAccount() + getDefaultAccount() } } @@ -120,11 +108,4 @@ class SessionMixin constructor( val account = accountManager.currentAccount setAccount(account) } - - override fun onResume() { - super.onResume() - if (currentAccount == null) { - swapToDefaultAccount() - } - } } diff --git a/app/src/main/java/com/nextcloud/utils/extensions/AccountExtensions.kt b/app/src/main/java/com/nextcloud/utils/extensions/AccountExtensions.kt new file mode 100644 index 0000000000..c17f93c6f4 --- /dev/null +++ b/app/src/main/java/com/nextcloud/utils/extensions/AccountExtensions.kt @@ -0,0 +1,14 @@ +/* + * Nextcloud - Android Client + * + * SPDX-FileCopyrightText: 2024 Your Name + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +package com.nextcloud.utils.extensions + +import android.accounts.Account +import android.content.Context +import com.owncloud.android.R + +fun Account.isAnonymous(context: Context): Boolean = type.equals(context.getString(R.string.anonymous_account_type)) diff --git a/app/src/main/java/com/owncloud/android/MainApp.java b/app/src/main/java/com/owncloud/android/MainApp.java index 049b25c7ca..2f2b17e9d0 100644 --- a/app/src/main/java/com/owncloud/android/MainApp.java +++ b/app/src/main/java/com/owncloud/android/MainApp.java @@ -80,12 +80,12 @@ import com.owncloud.android.lib.resources.status.NextcloudVersion; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.ui.activity.SyncedFoldersActivity; import com.owncloud.android.ui.notifications.NotificationUtils; -import com.owncloud.android.utils.appConfig.AppConfigManager; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.FilesSyncHelper; import com.owncloud.android.utils.PermissionUtil; import com.owncloud.android.utils.ReceiversHelper; import com.owncloud.android.utils.SecurityUtils; +import com.owncloud.android.utils.appConfig.AppConfigManager; import com.owncloud.android.utils.theme.ViewThemeUtils; import org.conscrypt.Conscrypt; @@ -131,7 +131,7 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER */ public class MainApp extends Application implements HasAndroidInjector { public static final OwnCloudVersion OUTDATED_SERVER_VERSION = NextcloudVersion.nextcloud_26; - public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_16; + public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_17; private static final String TAG = MainApp.class.getSimpleName(); public static final String DOT = "."; diff --git a/app/src/main/java/com/owncloud/android/operations/CommentFileOperation.java b/app/src/main/java/com/owncloud/android/operations/CommentFileOperation.java index 1a3efbac94..5984d17956 100644 --- a/app/src/main/java/com/owncloud/android/operations/CommentFileOperation.java +++ b/app/src/main/java/com/owncloud/android/operations/CommentFileOperation.java @@ -7,7 +7,7 @@ */ package com.owncloud.android.operations; -import com.owncloud.android.lib.common.OwnCloudClient; +import com.nextcloud.common.NextcloudClient; 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; @@ -16,7 +16,7 @@ import com.owncloud.android.lib.resources.comments.CommentFileRemoteOperation; /** * Comment file */ -public class CommentFileOperation extends RemoteOperation { +public class CommentFileOperation extends RemoteOperation { private final String message; private final long fileId; @@ -37,8 +37,8 @@ public class CommentFileOperation extends RemoteOperation { * @param client Client object to communicate with the remote ownCloud server. */ @Override - protected RemoteOperationResult run(OwnCloudClient client) { - RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId).execute(client); + public RemoteOperationResult run(NextcloudClient client) { + RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId).execute(client); if (!result.isSuccess()) { Log_OC.e(this, "File with Id " + fileId + " could not be commented"); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java index fc17209873..05ed0a9891 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/BaseActivity.java @@ -48,6 +48,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab @Inject UserAccountManager accountManager; @Inject AppPreferences preferences; + @Inject FileDataStorageManager fileDataStorageManager; private AppPreferences.Listener onPreferencesChanged = new AppPreferences.Listener() { @Override @@ -63,9 +64,7 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - sessionMixin = new SessionMixin(this, - getContentResolver(), - accountManager); + sessionMixin = new SessionMixin(this, accountManager); mixinRegistry.add(sessionMixin); if (enableAccountHandling) { @@ -174,6 +173,6 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab } public FileDataStorageManager getStorageManager() { - return sessionMixin.getStorageManager(); + return fileDataStorageManager; } } diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java index d3a2af21dc..6069e4e6c0 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java @@ -183,8 +183,8 @@ public class FileDetailActivitiesFragment extends Fragment implements String trimmedComment = commentField.toString().trim(); - if (trimmedComment.length() > 0 && ownCloudClient != null && isDataFetched) { - new SubmitCommentTask(trimmedComment, file.getLocalId(), callback, ownCloudClient).execute(); + if (!trimmedComment.isEmpty() && nextcloudClient != null && isDataFetched) { + new SubmitCommentTask(trimmedComment, file.getLocalId(), callback, nextcloudClient).execute(); } } @@ -461,12 +461,12 @@ public class FileDetailActivitiesFragment extends Fragment implements private final String message; private final long fileId; private final VersionListInterface.CommentCallback callback; - private final OwnCloudClient client; + private final NextcloudClient client; private SubmitCommentTask(String message, long fileId, VersionListInterface.CommentCallback callback, - OwnCloudClient client) { + NextcloudClient client) { this.message = message; this.fileId = fileId; this.callback = callback; @@ -477,7 +477,7 @@ public class FileDetailActivitiesFragment extends Fragment implements protected Boolean doInBackground(Void... voids) { CommentFileOperation commentFileOperation = new CommentFileOperation(message, fileId); - RemoteOperationResult result = commentFileOperation.execute(client); + RemoteOperationResult result = commentFileOperation.execute(client); return result.isSuccess(); } diff --git a/app/src/main/res/layout/account_setup.xml b/app/src/main/res/layout/account_setup.xml index 386206d871..cd1671e3a5 100644 --- a/app/src/main/res/layout/account_setup.xml +++ b/app/src/main/res/layout/account_setup.xml @@ -26,8 +26,8 @@ diff --git a/app/src/main/res/layout/whats_new_element.xml b/app/src/main/res/layout/whats_new_element.xml index 738e8d9f38..b42a165f02 100644 --- a/app/src/main/res/layout/whats_new_element.xml +++ b/app/src/main/res/layout/whats_new_element.xml @@ -15,7 +15,7 @@ Proxy Host Name Proxy Port + AnonymousAccountType + Unable to fetch task types, please check your internet connection. Unable to fetch task list, please check your internet connection. diff --git a/app/src/test/java/com/nextcloud/client/mixins/SessionMixinTest.kt b/app/src/test/java/com/nextcloud/client/mixins/SessionMixinTest.kt index 09ef6e1a16..135eeb07c3 100644 --- a/app/src/test/java/com/nextcloud/client/mixins/SessionMixinTest.kt +++ b/app/src/test/java/com/nextcloud/client/mixins/SessionMixinTest.kt @@ -8,9 +8,7 @@ package com.nextcloud.client.mixins import android.app.Activity -import android.content.ContentResolver import com.nextcloud.client.account.UserAccountManager -import junit.framework.Assert.assertNull import org.junit.Before import org.junit.Test import org.mockito.Mock @@ -24,9 +22,6 @@ class SessionMixinTest { @Mock private lateinit var activity: Activity - @Mock - private lateinit var contentResolver: ContentResolver - @Mock private lateinit var userAccountManager: UserAccountManager @@ -38,7 +33,6 @@ class SessionMixinTest { session = spy( SessionMixin( activity, - contentResolver, userAccountManager ) ) @@ -55,15 +49,4 @@ class SessionMixinTest { // account manager receives parent activity verify(userAccountManager).startAccountCreation(same(activity)) } - - @Test - fun `trigger accountCreation on resume when currentAccount is null`() { - // WHEN - // start onResume and currentAccount is null - assertNull(session.currentAccount) - session.onResume() - // THEN - // accountCreation flow is started - verify(session).startAccountCreation() - } } diff --git a/app/src/test/java/com/nextcloud/client/network/ConnectivityServiceTest.kt b/app/src/test/java/com/nextcloud/client/network/ConnectivityServiceTest.kt index 2d84433bac..11ce740b4a 100644 --- a/app/src/test/java/com/nextcloud/client/network/ConnectivityServiceTest.kt +++ b/app/src/test/java/com/nextcloud/client/network/ConnectivityServiceTest.kt @@ -94,7 +94,7 @@ class ConnectivityServiceTest { val baseServerUri = URI.create(SERVER_BASE_URL) val newServer = Server(baseServerUri, OwnCloudVersion.nextcloud_20) - val legacyServer = Server(baseServerUri, OwnCloudVersion.nextcloud_16) + val legacyServer = Server(baseServerUri, OwnCloudVersion.nextcloud_17) @Mock lateinit var user: User diff --git a/build.gradle b/build.gradle index c1627651b0..18405f9728 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ */ buildscript { ext { - androidLibraryVersion ="84711877b4703f8df3d638a016419b4aa731db2b" + androidLibraryVersion = "84711877b4703f8df3d638a016419b4aa731db2b" androidPluginVersion = '8.4.0' androidxMediaVersion = '1.3.1' androidxTestVersion = "1.5.0" @@ -23,7 +23,6 @@ buildscript { jacoco_version = '0.8.12' kotlin_version = '2.0.0' markwonVersion = "4.6.2" - prismVersion = "2.0.0" mockitoVersion = "4.11.0" mockitoKotlinVersion = "4.1.0" mockkVersion = "1.13.10" diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 636003a195..f3deb56561 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -5813,12 +5813,15 @@ - - - - - - + + + + + +