mirror of
https://github.com/nextcloud/android.git
synced 2024-12-21 16:24:32 +03:00
Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
commit
0b7419f287
32 changed files with 114 additions and 134 deletions
|
@ -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
|
||||
|
|
2
.github/workflows/analysis.yml
vendored
2
.github/workflows/analysis.yml
vendored
|
@ -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 }}
|
||||
|
|
2
.github/workflows/assembleFlavors.yml
vendored
2
.github/workflows/assembleFlavors.yml
vendored
|
@ -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:
|
||||
|
|
2
.github/workflows/check.yml
vendored
2
.github/workflows/check.yml
vendored
|
@ -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:
|
||||
|
|
6
.github/workflows/codeql.yml
vendored
6
.github/workflows/codeql.yml
vendored
|
@ -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
|
||||
|
|
2
.github/workflows/command-rebase.yml
vendored
2
.github/workflows/command-rebase.yml
vendored
|
@ -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 }}
|
||||
|
|
2
.github/workflows/detectWrongSettings.yml
vendored
2
.github/workflows/detectWrongSettings.yml
vendored
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
2
.github/workflows/qa.yml
vendored
2
.github/workflows/qa.yml
vendored
|
@ -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
|
||||
|
|
2
.github/workflows/reuse.yml
vendored
2
.github/workflows/reuse.yml
vendored
|
@ -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
|
||||
|
|
4
.github/workflows/scorecard.yml
vendored
4
.github/workflows/scorecard.yml
vendored
|
@ -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
|
||||
|
|
2
.github/workflows/screenShotTest.yml
vendored
2
.github/workflows/screenShotTest.yml
vendored
|
@ -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
|
||||
|
|
2
.github/workflows/unit-tests.yml
vendored
2
.github/workflows/unit-tests.yml
vendored
|
@ -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:
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 15 KiB |
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -100,8 +100,7 @@ class AppModule {
|
|||
@Provides
|
||||
UserAccountManager userAccountManager(
|
||||
Context context,
|
||||
AccountManager accountManager
|
||||
) {
|
||||
AccountManager accountManager) {
|
||||
return new UserAccountManagerImpl(context, accountManager);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<User> = when (val it = this.currentAccount) {
|
||||
null -> Optional.empty()
|
||||
else -> accountManager.getUser(it.name)
|
||||
fun getUser(): Optional<User> {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
|
||||
* 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))
|
|
@ -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 = ".";
|
||||
|
|
|
@ -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<Void> {
|
||||
|
||||
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<Void> run(NextcloudClient client) {
|
||||
RemoteOperationResult<Void> result = new CommentFileRemoteOperation(message, fileId).execute(client);
|
||||
|
||||
if (!result.isSuccess()) {
|
||||
Log_OC.e(this, "File with Id " + fileId + " could not be commented");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Void> result = commentFileOperation.execute(client);
|
||||
|
||||
return result.isSuccess();
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/thumbnail"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="@dimen/splash_image_size"
|
||||
android:layout_height="@dimen/splash_image_size"
|
||||
android:layout_marginBottom="@dimen/standard_padding"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:src="@drawable/logo" />
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/whatsNewImage"
|
||||
android:layout_width="200dp"
|
||||
android:layout_width="@dimen/splash_image_size"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="@dimen/alternate_margin"
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
<string name="app_config_proxy_host_title">Proxy Host Name</string>
|
||||
<string name="app_config_proxy_port_title">Proxy Port</string>
|
||||
|
||||
<string name="anonymous_account_type" translatable="false">AnonymousAccountType</string>
|
||||
|
||||
<string name="assistant_screen_task_types_error_state_message">Unable to fetch task types, please check your internet connection.</string>
|
||||
<string name="assistant_screen_task_list_error_state_message">Unable to fetch task list, please check your internet connection.</string>
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -5813,12 +5813,15 @@
|
|||
<sha256 value="0e72841878595f83c6d8f93aa51f78a67e821f53446fcb7a5d94cfaad8ebbbac" origin="Generated by Gradle" reason="Artifact is not signed"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.github.nextcloud" name="android-library" version="84711877b4703f8df3d638a016419b4aa731db2b">
|
||||
<artifact name="android-library-84711877b4703f8df3d638a016419b4aa731db2b.aar">
|
||||
<sha256 value="d801b368fc7d4d5d2d2852765442ccbf7df21f0a9198d369181637a8142914cc" origin="Generated by Gradle" reason="Artifact is not signed"/>
|
||||
</artifact>
|
||||
<artifact name="android-library-84711877b4703f8df3d638a016419b4aa731db2b.module">
|
||||
<sha256 value="de2e7d2fdde1d6981af8fcd54812dfe510ab7e22bdf8225ed569616b6c1155f4" origin="Generated by Gradle" reason="Artifact is not signed"/>
|
||||
<component group="com.github.nextcloud" name="android-library"
|
||||
version="84711877b4703f8df3d638a016419b4aa731db2b">
|
||||
<artifact name="android-library-84711877b4703f8df3d638a016419b4aa731db2b.aar">
|
||||
<sha256 value="d801b368fc7d4d5d2d2852765442ccbf7df21f0a9198d369181637a8142914cc"
|
||||
origin="Generated by Gradle" reason="Artifact is not signed" />
|
||||
</artifact>
|
||||
<artifact name="android-library-84711877b4703f8df3d638a016419b4aa731db2b.module">
|
||||
<sha256 value="de2e7d2fdde1d6981af8fcd54812dfe510ab7e22bdf8225ed569616b6c1155f4"
|
||||
origin="Generated by Gradle" reason="Artifact is not signed" />
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="com.github.nextcloud" name="android-library" version="9fdcd0af0ff910086281f32e3b8ef74490671149">
|
||||
|
|
Loading…
Reference in a new issue