Compare commits

..
Author SHA1 Message Date
alperozturk 55627926e4 fix
Signed-off-by: alperozturk <[email protected]>
2025-01-07 10:00:38 +01:00
alperozturk 5c47a2273b fix
Signed-off-by: alperozturk <[email protected]>
2025-01-07 10:00:38 +01:00
2443 changed files with 56903 additions and 148828 deletions

No files matched your search

@@ -1,130 +0,0 @@
---
name: android-java-to-kotlin
description: >
Use when finishing a Java-to-Kotlin conversion in an Android project, when the user
mentions "java to kotlin", "j2k", "convert java", "migrate java to kotlin", "finish the
conversion", "make it idiomatic", or when a freshly IDE-converted .kt file needs to be
turned into clean, modern, idiomatic Kotlin. The developer first runs the IDE converter
(Android Studio: Code > Convert Java File to Kotlin File), then this skill drives the
second pass: idiomatic cleanup, fail-fast control flow, coroutines/lifecycleScope,
modern Android APIs, function decomposition, and a behaviour-locking test.
license: AGPL-3.0-or-later
SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
SPDX-License-Identifier: AGPL-3.0-or-later
metadata:
author: Nextcloud Android
version: "1.0.0"
---
# Android Java to Kotlin Conversion (Second Pass)
The IDE converter produces Kotlin that *compiles* but is not *idiomatic*: platform types
everywhere, one giant function per lifecycle callback, nested `if`/`else`, `new Thread`,
`switch`, `TextUtils.isEmpty`, magic numbers. This skill drives the disciplined second
pass that turns that output into clean, modern, testable Kotlin — **without changing
observable behaviour** — and then writes a test that proves behaviour is unchanged.
## The Two-Person Workflow
This skill assumes a hand-off:
1. **Developer** runs the mechanical IDE conversion (`Code > Convert Java File to Kotlin
File`, or ⌥⇧⌘K), producing a `.kt` file that compiles but is not idiomatic.
2. **You (Claude)** drive everything after that:
Step 0 Baseline → Step 1 Idiomatic pass → Step 2 Behaviour-locking test → Step 3
Verify. If Step 3 fails or behaviour drifts, loop back to Step 1.
If you are handed a `.java` file instead, first apply a faithful 1:1 translation to reach
the same starting point, then continue.
## The Prime Directive: Behaviour Must Not Change
Every transformation in this skill is **behaviour-preserving**. You are refactoring for
readability, safety, and modern API usage — not adding features or fixing bugs. If you
spot a real bug, surface it to the developer; do not silently "fix" it inside a
conversion. The behaviour-locking test in Step 3 exists to keep you honest.
## Step 0: Establish Baseline
Before editing anything:
1. Read the whole `.kt` file (and, if you can, the original `.java` via
`git show <rev>:<path>.java` or the IDE's local history) to understand *what it does*.
2. Write down the **public/observable surface** you must keep intact:
- Lifecycle callbacks (`onCreate`, `onViewCreated`, `onSaveInstanceState`, …) and their
ordering of side-effects.
- Any Parcelable/Bundle keys, intent extras, and `newInstance(...)` factory shapes.
3. Note threading: which work runs off the main thread today (`Thread`, `AsyncTask`,
`runOnUiThread`, executors) — this maps to coroutines in Step 2.
## Step 1: Idiomatic Pass
Apply, in this order, then re-check the invariants:
1. **Kill platform types.** Give every `!` platform type an explicit nullable/non-null
type based on the Java source and call sites.
2. **Fail fast.** Replace nested `if`/`else` pyramids and null-checks with guard clauses
and `require`/`requireNotNull`/`?: return`. See [FAIL-FAST.md](references/FAIL-FAST.md).
3. **Decompose.** Break each oversized lifecycle callback / `setupView`-style method into
small, single-purpose private functions named for their intent. See
[ANDROID-IDIOMS.md](references/ANDROID-IDIOMS.md).
4. **Modern concurrency.** Replace `new Thread`, `AsyncTask`, `runOnUiThread`, and
callback pairs with `lifecycleScope` + `suspend` + `withContext`. See
[CONCURRENCY.md](references/CONCURRENCY.md).
5. **Modern Android + Kotlin idioms.** Scope functions (`run`/`apply`/`let`), extension
functions, `when`/`partition`/`filter` over `switch`, string templates, `isNullOrEmpty`,
view/KTX extensions. See [ANDROID-IDIOMS.md](references/ANDROID-IDIOMS.md). Retire
deprecated Android APIs (`onActivityResult`, options-menu overrides,
`java.util.Observable`) — see [DEPRECATED-APIS.md](references/DEPRECATED-APIS.md).
6. **Project conventions.** SPDX header, no magic numbers (`companion object` +
`const val`), resources not hardcoded strings, ≤300 lines/file, ≤120 cols. See
[PROJECT-CONVENTIONS.md](references/PROJECT-CONVENTIONS.md).
7. **Testability seams.** Extract pure logic (URL building, permission math, partitioning)
into functions you can unit-test; mark with `@VisibleForTesting` where they must stay
`internal`/`private`-ish but be reachable from tests.
Do NOT expand scope. Unrelated files stay untouched (AGENTS.md / AI policy).
## Step 2: Write a Behaviour-Locking Test (Mandatory)
A conversion is not complete until a test proves behaviour is unchanged. See
[TESTING.md](references/TESTING.md) for the decision tree. In short:
- **Pure functions you extracted** (e.g. link builders, `isReshareForbidden`,
partitioning) → fast JVM unit tests in `app/src/test/` (JUnit4 + mockito-kotlin).
- **Fragment/Activity/DB behaviour** → instrumented test in `app/src/androidTest/`
extending the project's base test class, or a Robolectric test where the project uses it.
- Prefer testing the **seams you just created**. If the Java original had no test, your
new test is the characterization test that locks current behaviour.
Every test file gets the SPDX header and follows the project's test conventions.
## Step 3: Verify
Run and report real output — never claim green without evidence:
```bash
# Formatting + static analysis on the changed files
./gradlew spotlessKotlinCheck detektGplayDebug lintGplayDebug spotbugsGplayDebug
# Unit tests
./gradlew jacocoTestGplayDebugUnitTest
# Instrumented tests (if you wrote one), scoped to the class
./gradlew createGplayDebugCoverageReport -Pcoverage=true \
-Pandroid.testInstrumentationRunnerArguments.class=<fully.qualified.TestClass>
```
## Worked Example
[assets/worked-example.md](assets/worked-example.md) is a real before/after from
`FileDetailSharingFragment` (871-line Java fragment → idiomatic Kotlin) showing each
transformation class in context. Read it when you need a concrete pattern.
## Batch Conversion
Convert one file at a time, leaf dependencies first. Report progress per file. Warn the
developer before a change set grows into several thousand lines — split into focused PRs
(AGENTS.md). Each commit needs `Assisted-by: <agent>:<model>`; only the human adds
`Signed-off-by`.
@@ -1,163 +0,0 @@
# Worked Example: FileDetailSharingFragment
A real conversion of an 871-line Java fragment
(`com.owncloud.android.ui.fragment.FileDetailSharingFragment`) into idiomatic Kotlin. Each
section shows one transformation class from the skill, in context. Behaviour is unchanged
throughout; the only new capability (`@VisibleForTesting createInternalLink`) is a
testability seam that returns the same URL the Java produced.
## A. SPDX Header Rewrite
```diff
-/*
- * Nextcloud Android client application
- *
- * @author Andy Scherzinger
- * ...
- * Copyright (C) 2018 Andy Scherzinger
- * SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
- */
+/*
+ * Nextcloud - Android Client
+ *
+ * SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
```
## B. Fail-Fast Preconditions
```diff
-if (file == null) throw new IllegalArgumentException("File may not be null");
-if (user == null) throw new IllegalArgumentException("Account may not be null");
-fileActivity = (FileActivity) getActivity();
-if (fileActivity == null) throw new IllegalArgumentException("FileActivity may not be null");
+fileActivity = (activity as FileActivity?)
+requireNotNull(file) { "File may not be null" }
+requireNotNull(user) { "Account may not be null" }
+requireNotNull(fileActivity) { "FileActivity may not be null" }
```
## C. Decomposition of `onViewCreated`
The Java `onViewCreated` inlined adapter creation (duplicated for internal/external),
layout managers, listeners, and the fetch kick-off. It became a readable sequence plus
extracted helpers `getUserId()`, `setupInternalShares()`, `setupExternalShares()`,
`createShareListAdapter(userId, type)`, `startAnimation()`. The two near-identical adapter
blocks collapsed into one parameterized factory:
```kotlin
private fun createShareListAdapter(userId: String, type: SharesType): ShareeListAdapter =
ShareeListAdapter(
fileActivity!!, ArrayList(), this, userId, user, viewThemeUtils,
(file?.isEncrypted == true), type
).apply { setHasStableIds(true) }
```
## D. `new Thread` + `runOnUiThread` → `lifecycleScope` + `suspend`
```diff
-private void fetchE2EECounter(Runnable onComplete) {
- new Thread(() -> {
- try { ... fileDataStorageManager.saveFile(file); }
- catch (Exception e) { Log_OC.e(TAG, "..." + e.getMessage()); }
- Activity a = getActivity();
- if (a != null) a.runOnUiThread(onComplete);
- }).start();
-}
+private suspend fun fetchE2EECounter(): Boolean = withContext(Dispatchers.IO) {
+ return@withContext try {
+ val client = clientFactory.create(user)
+ val metadata = RefreshFolderOperation.getDecryptedFolderMetadata(true, file, client, user, requireContext())
+ if (metadata is DecryptedFolderMetadataFile) {
+ file?.setE2eCounter(metadata.metadata.counter)
+ fileDataStorageManager?.saveFile(file)
+ }
+ true
+ } catch (e: Exception) {
+ Log_OC.e(TAG, "Error refreshing E2E counter: " + e.message)
+ false
+ }
+}
```
Caller now `lifecycleScope.launch { if (!fetchE2EECounter()) return@launch; withContext(Main){ ... } }`.
The callback-pair `fetchSharees(onSuccess, onError)` was likewise turned into a `suspend`
call returning `Boolean`.
## E. `switch` Bucketing → `partition` + Set
```diff
-for (OCShare share : shares) {
- if (share.getShareType() != null) {
- switch (share.getShareType()) {
- case PUBLIC_LINK: case FEDERATED_GROUP: case FEDERATED: case EMAIL:
- externalShares.add(share); break;
- default: internalShares.add(share); break;
- }
- }
-}
+private val externalShareTypes = setOf(
+ ShareType.PUBLIC_LINK, ShareType.FEDERATED_GROUP, ShareType.FEDERATED, ShareType.EMAIL
+)
+val (external, internal) = shares
+ .filter { it.shareType != null }
+ .partition { it.shareType in externalShareTypes }
```
## F. Nested `if` Cursor Handling → Guard Clauses
The three-level-nested `handleContactResult` became flat sequential guards, each showing
the snackbar + log and returning, with `cursor.close()` preserved on every path. See
[FAIL-FAST.md](../references/FAIL-FAST.md) section "Deeply Nested".
## G. Scope Functions & KTX
```diff
-final LinearLayout shimmerLayout = binding.shimmerLayout.getRoot();
-shimmerLayout.clearAnimation();
-shimmerLayout.setVisibility(View.GONE);
-binding.shareContainer.setVisibility(View.VISIBLE);
+binding?.run {
+ shimmerLayout.root.run { clearAnimation(); visibility = View.GONE }
+ shareContainer.visibility = View.VISIBLE
+}
```
```diff
-for (int i = 0; i < viewGroup.getChildCount(); i++) { toggleSearchViewEnable(viewGroup.getChildAt(i), enable); }
+for (i in 0..<view.size) { toggleSearchViewEnable(view.getChildAt(i), enable) } // androidx.core.view.size
```
## H. Constants + Companion + `@JvmStatic`
```diff
-private static final String TAG = "FileDetailSharingFragment";
-ViewExtensionsKt.setVisibleIf(binding.sharesListInternalShowAll, adapter.shares.size() > 3);
+companion object {
+ private const val TAG = "FileDetailSharingFragment"
+ private const val MIN_SHOW_ALL_VISIBLE_ITEM_COUNT = 3
+ @JvmStatic fun newInstance(file: OCFile?, user: User?) = FileDetailSharingFragment().apply { ... }
+}
+binding.sharesListInternalShowAll.setVisibleIf(internalShares.size > MIN_SHOW_ALL_VISIBLE_ITEM_COUNT)
```
## I. Testability Seam
`createInternalLink` was inlined string concatenation in Java. It was extracted to a pure
`@VisibleForTesting internal fun createInternalLink(user, file, capabilities): String` that
returns the identical URL — enabling the unit test in
[TESTING.md](../references/TESTING.md) without a device.
## J. Detekt Suppression (Last Resort)
The class is genuinely large and can't be fully split within one conversion, so a
file-level suppression documents the debt honestly:
```kotlin
@Suppress("TooManyFunctions", "LargeClass", "TooGenericExceptionCaught", "ReturnCount")
class FileDetailSharingFragment : Fragment(), ... {
```
Prefer real decomposition; use this only when splitting is out of scope, and tell the
developer.
@@ -1,170 +0,0 @@
<!--
~ Nextcloud - Android Client
~
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
~ SPDX-License-Identifier: AGPL-3.0-or-later
-->
# Android + Kotlin Idioms
Transformations applied during the idiomatic pass. Every one is behaviour-preserving.
Examples are drawn from a real fragment conversion.
## 1. Decompose Oversized Functions
The IDE keeps the Java structure: one enormous `onViewCreated`/`setupView` that inflates,
themes, wires listeners, and kicks off loading in a single 80-line block. Split by
intent into small private functions. The lifecycle callback becomes a readable table of
contents.
```kotlin
// BEFORE: onViewCreated does everything inline (adapters, layout managers, listeners, fetch)
// AFTER
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
fileActivity ?: return
fileDataStorageManager = fileActivity?.storageManager
fileOperationsHelper = fileActivity?.fileOperationsHelper
startAnimation()
val userId = getUserId()
setupInternalShares(userId)
setupExternalShares(userId)
binding?.pickContactEmailBtn?.setOnClickListener { checkContactPermission() }
fetchSharees()
setupView()
}
```
Rules:
- One function = one reason to change. Name it for *what it accomplishes*
(`setupInternalShares`, `themeView`, `disableE2EEShareForV1`), not *how*.
- Factor duplicated blocks into a parameterized helper
(`createShareListAdapter(userId, SharesType.INTERNAL)`).
- Keep files ≤300 lines (project rule). Heavy decomposition sometimes means splitting a
god-class into collaborators — raise that with the developer rather than exceeding 300.
## 2. Scope Functions Over Repetition
Replace repeated `binding.x` / `viewThemeUtils.material.y` chains with `run`/`apply`/`with`.
```kotlin
// BEFORE
viewThemeUtils.material.themeSearchCardView(binding.searchCardWrapper);
viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.sendCopyBtn);
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.sharesListInternalShowAll);
// AFTER
binding.run {
viewThemeUtils.material.run {
themeSearchCardView(searchCardWrapper)
colorMaterialButtonPrimaryOutlined(sendCopyBtn)
colorMaterialButtonPrimaryBorderless(sharesListInternalShowAll)
}
}
```
Use `apply {}` when configuring and returning the receiver:
```kotlin
ShareeListAdapter(fileActivity!!, ArrayList(), this, userId, user, viewThemeUtils, encrypted, type)
.apply { setHasStableIds(true) }
```
## 3. `switch` → `when` / `filter` + `partition`
Collapse a `switch` that sorts items into buckets into a declarative pipeline with a
constant `Set`.
```kotlin
// BEFORE: for-loop with switch(shareType) adding to internalShares / externalShares
// AFTER
private val externalShareTypes = setOf(
ShareType.PUBLIC_LINK, ShareType.FEDERATED_GROUP, ShareType.FEDERATED, ShareType.EMAIL
)
val (external, internal) = shares
.filter { it.shareType != null }
.partition { it.shareType in externalShareTypes }
```
## 4. Extension Functions & KTX
Import members directly and lean on AndroidX KTX instead of verbose Java utilities.
| Java / verbose | Idiomatic Kotlin |
|---|---|
| `TextUtils.isEmpty(s)` | `s.isNullOrEmpty()` |
| `BundleExtensionsKt.getParcelableArgument(b, k, T.class)` | `b.getParcelableArgument(k, T::class.java)` |
| `for (int i = 0; i < vg.getChildCount(); i++)` | `for (i in 0..<view.size)` (`androidx.core.view.size`) |
| manual getter/setter methods | Kotlin property access (`view.visibility = View.GONE`) |
| `private int x; public int getX()` (read-only to callers) | `var columnsCount = 0; private set` |
| empty override method body | `= Unit` single-expression body |
| free-standing util call | receiver extension (`externalShares.mergeDistinctByToken(publicShares)`) |
Domain-specific extensions read best as receivers on the relevant type:
```kotlin
private fun OCCapability?.isPasswordEnforced(): Boolean =
this?.filesSharingPublicPasswordEnforced?.isTrue == true &&
filesSharingPublicAskForOptionalPassword.isTrue
```
## 5. Null Safety Instead of Platform Types
The IDE leaves `!` platform types and defensive Java null-checks. Replace with `?.`,
`?:`, and Kotlin's `require`/`requireNotNull`. A nullable `binding` (cleared in
`onDestroyView`) is the canonical Android case — guard it with `?.` / `?: return`.
```kotlin
// BEFORE
if (binding == null) return;
final LinearLayout shimmer = binding.shimmerLayout.getRoot();
shimmer.clearAnimation();
// AFTER
binding?.run {
shimmerLayout.root.run {
clearAnimation()
visibility = View.GONE
}
shareContainer.visibility = View.VISIBLE
}
```
## 6. Constants & Companion Object
Move `static final` and magic literals into a `companion object`; use `const val` for
compile-time constants. Add `@JvmStatic` to factory methods still called from Java.
```kotlin
companion object {
private const val TAG = "FileDetailSharingFragment"
private const val ARG_FILE = "FILE"
private const val MIN_SHOW_ALL_VISIBLE_ITEM_COUNT = 3
private const val INTERNAL_LINK_PATH_PRETTY = "/f/"
@JvmStatic
fun newInstance(file: OCFile?, user: User?) = FileDetailSharingFragment().apply {
arguments = Bundle().apply {
putParcelable(ARG_FILE, file)
putParcelable(ARG_USER, user)
}
}
}
```
## 7. Detekt Suppressions Are a Last Resort
If a legacy god-class genuinely cannot be split within the conversion's scope, a
file/class-level `@Suppress("TooManyFunctions", "LargeClass", ...)` is acceptable — but
prefer real decomposition and tell the developer what you suppressed and why.
## 8. `// region` Organization
For large classes, grouping members under `// region <name>` / `// endregion` (lifecycle,
private methods, overrides, companion) aids IDE folding. This is IDE structure, not a
decorative divider. Match the surrounding file's existing style; do not introduce ASCII
banner comments (`// ==== ====`), which the project forbids.
@@ -1,213 +0,0 @@
<!--
~ Nextcloud - Android Client
~
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
~ SPDX-License-Identifier: AGPL-3.0-or-later
-->
# Concurrency: Java Threads → Coroutines & `lifecycleScope`
Replace `new Thread`, `AsyncTask`, executors, and `runOnUiThread`/`Handler.post`
callback-passing with structured coroutines scoped to the component lifecycle. This is
behaviour-preserving *and* fixes leaks: `lifecycleScope`/`viewModelScope` cancel
automatically when the owner is destroyed, so no work touches a dead view.
## Choose the Right Scope
| Context | Scope |
|---|---|
| `Fragment` (UI work tied to view) | `viewLifecycleOwner.lifecycleScope` (preferred) or `lifecycleScope` |
| `Activity` | `lifecycleScope` |
| `ViewModel` | `viewModelScope` |
| No lifecycle owner | inject a `CoroutineScope` / use a repository suspend fun |
Use `Dispatchers.IO` for disk/network/DB, `Dispatchers.Main` (or `withContext(Main)`) to
touch views.
## `AsyncTask` → Coroutines
`AsyncTask` is deprecated. Map its callbacks onto a single `launch`:
| `AsyncTask` | Coroutine |
|---|---|
| `onPreExecute()` | code before `withContext(IO)` (runs on Main) |
| `doInBackground()` | `withContext(Dispatchers.IO) { ... }` |
| `onPostExecute(result)` | code after, back on `Dispatchers.Main` |
| `isCancelled()` | `isActive` (or `ensureActive()`) |
| `cancel(true)` | `job.cancel()` |
| the `AsyncTask` instance field | the returned `Job` |
A self-contained task class stops extending `AsyncTask` and holds the lifecycle owner so
its scope cancels with the screen:
```kotlin
// BEFORE: class GallerySearchTask extends AsyncTask<Void, Void, Result> { ... }
class GallerySearchTask(
private val fragment: GalleryFragment,
private val user: User,
private val storageManager: FileDataStorageManager,
private val endDate: Long,
private val limit: Int
) {
fun execute(): Job = fragment.lifecycleScope.launch(Dispatchers.IO) {
if (!isActive) return@launch
val context = fragment.context ?: return@launch
val result = performSearch(context)
withContext(Dispatchers.Main) {
fragment.searchCompleted(result.emptySearch, result.lastTimestamp)
}
}
}
```
The caller keeps the `Job` and cancels it with the view:
```kotlin
private var photoSearchTask: Job? = null
// ...
photoSearchTask = GallerySearchTask(this, user, storageManager, endDate, limit).execute()
override fun onDestroyView() {
photoSearchTask?.cancel()
photoSearchTask = null
}
```
Because `lifecycleScope` cancels on destroy, the old `WeakReference<Fragment>` leak-guard
disappears — a direct `fragment` reference plus `fragment.context ?: return@launch` is
enough. (PR #16908)
## `AsyncTask` Behind a Callback API → `runCatching` + `fold`
When a service method hid an `AsyncTask` that set mutable fields (a boolean success flag,
`errorMessage`, result fields) and dispatched them in `onPostExecute`, keep the public
callback signature but drive it from a coroutine. Return an **immutable** result from the
background function and branch with `fold`:
```kotlin
private data class ActivitiesResult(
val activities: List<Any>,
val client: NextcloudClient,
val lastGiven: Long
)
override fun getActivities(lastGiven: Long, callback: ActivitiesServiceCallback) {
scope.launch {
runCatching { withContext(Dispatchers.IO) { fetchActivities(lastGiven) } }
.fold(
onSuccess = { (activities, client, updated) ->
callback.onLoaded(activities, client, updated)
},
onFailure = { callback.onError(it.message ?: "") }
)
}
}
```
`runCatching` / `fold` replaces the boolean-success + `errorMessage`-field idiom; the
background function `fetchActivities` throws on failure instead of returning `false`, and
the immutable `ActivitiesResult` destructures straight into `onSuccess`. (PR #16654)
> **Scope caveat:** that PR launched on an ad-hoc `CoroutineScope(Dispatchers.Main)` with
> no lifecycle owner — it never cancels and can leak. Prefer an injected `CoroutineScope`
> or expose a `suspend` function the presenter runs on `lifecycleScope` / `viewModelScope`.
> Flag ad-hoc scopes in review.
## `new Thread { ... runOnUiThread(...) }` → `lifecycleScope.launch` + `withContext`
```kotlin
// BEFORE
private void fetchE2EECounter(Runnable onComplete) {
new Thread(() -> {
try {
OwnCloudClient client = clientFactory.create(user);
Object metadata = RefreshFolderOperation.getDecryptedFolderMetadata(true, file, client, user, ctx);
if (metadata instanceof DecryptedFolderMetadataFile m) {
file.setE2eCounter(m.getMetadata().getCounter());
fileDataStorageManager.saveFile(file);
}
} catch (Exception e) { Log_OC.e(TAG, "..." + e.getMessage()); }
Activity a = getActivity();
if (a != null) a.runOnUiThread(onComplete);
}).start();
}
// AFTER: background work is a suspend fun on IO; the UI reaction runs on Main
private suspend fun fetchE2EECounter(): Boolean = withContext(Dispatchers.IO) {
return@withContext try {
val context = requireContext()
val client = clientFactory.create(user)
val metadata = RefreshFolderOperation.getDecryptedFolderMetadata(true, file, client, user, context)
if (metadata is DecryptedFolderMetadataFile) {
file?.setE2eCounter(metadata.metadata.counter)
fileDataStorageManager?.saveFile(file)
}
true
} catch (e: Exception) {
Log_OC.e(TAG, "Error refreshing E2E counter: " + e.message)
false
}
}
// caller
lifecycleScope.launch {
val ok = fetchE2EECounter()
if (!ok) return@launch
withContext(Dispatchers.Main) { /* update views */ }
}
```
Notes:
- The old code returned nothing and drove the UI via a `Runnable`. The idiomatic version
returns a `Boolean` result and lets the caller decide — same observable outcome, no
callback threading.
- `getActivity() != null` guard becomes `lifecycleScope` cancellation + `binding?`/`?:
return` guards. Preserve any "is the view still alive?" check as a `binding == null`
guard inside `launch`.
## Callback-Pair API → `suspend` Result
Repositories that took `onSuccess`/`onError` lambdas become `suspend` functions returning
a result, awaited inside a coroutine.
```kotlin
// BEFORE
shareRepository.fetchSharees(remotePath, onSuccess = { ... }, onError = { ... });
// AFTER
lifecycleScope.launch {
val result = shareRepository.fetchSharees(remotePath)
if (binding == null) return@launch
if (result) { refreshSharesFromDB(); stopLoadingAnimationAndShowShareContainer() }
else { stopLoadingAnimationAndShowShareContainer(); showError() }
}
```
## Moving DB/IO off the Main Thread
Wrap the blocking DB read in `withContext(Dispatchers.IO)` and hop back to `Main` to touch
adapters/views. This can be a *behaviour improvement* (fewer main-thread stalls) — flag it
to the developer if the Java version was doing DB work on the main thread synchronously,
since timing changes can be observable (e.g. tests that assumed synchronous population).
```kotlin
private suspend fun loadAndPartitionShares(): Pair<List<OCShare>, List<OCShare>> =
withContext(Dispatchers.IO) {
val shares = fileDataStorageManager?.getSharesWithForAFile(file?.remotePath, user?.accountName)
?: emptyList()
val (external, internal) = shares.filter { it.shareType != null }
.partition { it.shareType in externalShareTypes }
internal to external
}
```
## Pitfalls
- Never launch on `GlobalScope` — it outlives the screen and leaks.
- An ad-hoc `CoroutineScope(Dispatchers.Main)` created inside a service/presenter has the
same problem: no lifecycle owner, no cancellation, a leak. Use an injected scope or a
`suspend` function the caller runs on `lifecycleScope` / `viewModelScope`.
- Keep `try/catch` semantics: coroutine cancellation throws `CancellationException`;
rethrow it (don't swallow in a broad `catch (e: Exception)` that logs and continues) or
catch `Exception` only around the real work, not around the whole `launch`.
- Preserve exception-to-UI mapping exactly (same snackbar, same log tag/message).
@@ -1,85 +0,0 @@
<!--
~ Nextcloud - Android Client
~
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
~ SPDX-License-Identifier: AGPL-3.0-or-later
-->
# Retiring Deprecated Android APIs During Conversion
A Java→Kotlin conversion is the right moment to replace deprecated Android APIs the IDE
converter leaves untouched. Each replacement below is behaviour-preserving. Examples are
real conversions (nextcloud/android PRs #16878, #16792).
## `startActivityForResult` / `onActivityResult` → Activity Result API
The request-code + `onActivityResult` protocol is deprecated. Register a launcher at
construction time and receive the result in its callback.
```kotlin
// BEFORE
startActivityForResult(action, SELECT_LOCATION_REQUEST_CODE)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == SELECT_LOCATION_REQUEST_CODE && data != null) { handle(data) }
}
// AFTER
private val folderPickerLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode == Activity.RESULT_OK) {
handle(result.data)
}
}
// launch it:
folderPickerLauncher.launch(intent)
```
Type-safe, no manual request-code bookkeeping, and it survives process death because
registration is declarative. Register during initialization (a field initializer or
`onCreate`/`onViewCreated`) — never inside a click handler, or the registration is lost.
## `onCreateOptionsMenu` / `onOptionsItemSelected` → `MenuProvider`
`setHasOptionsMenu(true)` plus the two menu overrides are deprecated on `Fragment`. Add a
`MenuProvider` bound to the view lifecycle instead.
```kotlin
// AFTER
val menuHost: MenuHost = requireActivity()
menuHost.addMenuProvider(object : MenuProvider {
override fun onCreateMenu(menu: Menu, inflater: MenuInflater) =
inflater.inflate(R.menu.gallery_menu, menu)
override fun onMenuItemSelected(item: MenuItem): Boolean = when (item.itemId) {
R.id.action_select_all -> { selectAll(); true }
else -> false
}
}, viewLifecycleOwner, Lifecycle.State.RESUMED)
```
Passing `viewLifecycleOwner` + `Lifecycle.State.RESUMED` auto-adds and removes the menu as
the view's lifecycle changes — no leak, no manual `setHasOptionsMenu`. (PR #16878)
## `java.util.Observable` — Keep or Migrate?
`java.util.Observable` / `Observer` are deprecated (Java 9+). But a conversion is
behaviour-locked, so **do not** silently swap the notification mechanism — existing Java
observers rely on `setChanged()` / `notifyObservers()`. PR #16792 deliberately KEPT it:
```kotlin
class UploadsStorageManager(...) : Observable() {
fun notifyObserversNow() {
Handler(Looper.getMainLooper()).post {
setChanged()
notifyObservers()
}
}
}
```
Migrating to `StateFlow` / `SharedFlow` changes the observation contract and every call
site — that is a separate, opt-in refactor, not part of a 1:1 conversion. Note the
deprecation, propose the flow migration as a follow-up, and keep the current mechanism
unless the developer scopes the larger change.
@@ -1,115 +0,0 @@
<!--
~ Nextcloud - Android Client
~
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
~ SPDX-License-Identifier: AGPL-3.0-or-later
-->
# Fail Fast: Guard Clauses Over Nested `if`/`else`
The IDE preserves Java's nested-`if` pyramids. Invert them into guard clauses that return
(or throw) early, leaving the happy path at the lowest indentation. Behaviour is
identical — the branches are the same, only the shape changes.
## Precondition Checks → `require` / `requireNotNull`
`requireNotNull` returns the smart-cast non-null value AND throws
`IllegalArgumentException` with the message — exactly matching the Java `if (x == null)
throw new IllegalArgumentException(...)`.
```kotlin
// BEFORE
if (file == null) throw IllegalArgumentException("File may not be null");
if (user == null) throw IllegalArgumentException("Account may not be null");
fileActivity = (FileActivity) getActivity();
if (fileActivity == null) throw IllegalArgumentException("FileActivity may not be null");
// AFTER
fileActivity = activity as? FileActivity
requireNotNull(file) { "File may not be null" }
requireNotNull(user) { "Account may not be null" }
requireNotNull(fileActivity) { "FileActivity may not be null" }
```
Use `require(condition) { msg }` for boolean preconditions:
```kotlin
require(activity is FileActivity) { "Calling activity must be of type FileActivity" }
```
`check`/`checkNotNull` are the `IllegalStateException` equivalents — use them when the Java
threw `IllegalStateException`. Match the original exception type; that is observable
behaviour.
## Early Return Over Nested Success Path
```kotlin
// BEFORE
private void checkShareViaUser() {
if (!MDMConfig.INSTANCE.shareViaUser(requireContext())) {
binding.searchContainer.setVisibility(View.GONE);
}
}
// AFTER
private fun checkShareViaUser() {
if (shareViaUser(requireContext())) return
binding?.searchContainer?.visibility = View.GONE
}
```
## Deeply Nested `if`/`else` → Sequential Guards
The most valuable transformation. A cursor-handling method nested three levels deep
becomes a flat sequence of guard clauses, each handling one failure and returning.
```kotlin
// BEFORE: if (cursor != null) { if (moveToFirst()) { if (columnIndex != -1) {...} else ... } else ... } else ...
// AFTER
private fun handleContactResult(contactUri: Uri) {
val cursor = fileActivity?.contentResolver?.query(contactUri, projection, null, null, null)
if (cursor == null) {
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed)
Log_OC.e(TAG, "Failed to pick email address as Cursor is null.")
return
}
if (!cursor.moveToFirst()) {
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed)
Log_OC.e(TAG, "Failed to pick email address as no Email found.")
return
}
val columnIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS)
if (columnIndex == -1) {
DisplayUtils.showSnackMessage(this, R.string.email_pick_failed)
Log_OC.e(TAG, "Failed to pick email address.")
cursor.close()
return
}
val email = cursor.getString(columnIndex)
// ... happy path at base indentation
cursor.close()
}
```
Watch the cleanup: if the Java relied on falling through to a single `cursor.close()`,
each early return must still close it (or wrap in `use {}`). Missing that changes
behaviour (resource leak) — verify it.
## Nullable-Guard Idioms
```kotlin
val activity = fileActivity ?: return
val clientRepository = activity.clientRepository ?: return
val remotePath = file?.remotePath ?: return
```
Each `?: return` collapses one Java `if (x == null) return;`. Chain them at the top of the
function so the body works with non-null smart-cast locals.
## When NOT to Invert
- Do not turn a genuine two-branch decision (both branches do real work) into a guard if
it obscures the symmetry — a `when`/`if-else` expression is clearer there.
- Do not change the *order* of side-effects while inverting; the snackbar/log calls above
must fire in the same cases as before.
@@ -1,79 +0,0 @@
# Project Conventions (Nextcloud Android)
Apply these during Step 2 so the converted file passes review and the quality gates. They
are enforced by `spotlessKotlinCheck`, `detekt`, `lint`, and `spotbugsGplayDebug`.
## SPDX Header (every new/renamed file)
The IDE keeps the old license block. Replace it with the current template. The year is the
year the Kotlin file is created. New contributions are `AGPL-3.0-or-later`; keep
`OR GPL-2.0-only` only if the original file carried it.
```kotlin
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: <YEAR> Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
```
If the developer wants personal attribution (as in the real conversion), the form
`SPDX-FileCopyrightText: <YEAR> <Name> <email>` is also used — match what the developer
asks for; default to the "Nextcloud GmbH and Nextcloud contributors" line.
## Structural Rules
- **≤300 lines per file.** If decomposition pushes past it, split responsibilities into
separate files/collaborators and tell the developer. A file/class-level
`@Suppress("LargeClass", "TooManyFunctions")` is a last resort for legacy god-classes.
- **≤120 columns per line.**
- **One top-level type per file.** Extract models, states, sealed classes, and listener
interfaces into their own files rather than nesting many types in one.
- **Exactly one trailing newline** at end of file.
## No Magic Numbers / Hardcoded Resources
- Extract literals into named `const val` in a `companion object`
(`MIN_SHOW_ALL_VISIBLE_ITEM_COUNT = 3`, `INTERNAL_LINK_PATH_PRETTY = "/f/"`).
- Strings, colors, dimens come from resources (`R.string.*`, `R.dimen.*`), never inline.
- Only `app/src/main/res/values/strings.xml` may be edited for strings; never touch
`values-*` translation folders.
## Comments & Naming
- No decorative divider comments (`// ==== ====`, `// ---- Title ----`). `// region` /
`// endregion` for IDE folding is allowed and should match the file's existing style.
- Names carry the explanation, not comments. If a name needs a comment to be understood,
rename or decompose instead. Do not add KDoc to a function just because it is new.
- Preserve genuinely informative Javadoc as KDoc (invariant 4); drop noise. A comment
earns its place only for a non-obvious invariant, a platform/server workaround, or an
ordering requirement — and it explains **why**, never **what**.
- Never narrate the conversion itself: no "was a Java thread, now a coroutine", no
"changed from X to Y", no references to the PR, the issue, or this conversation.
Comments describe the code as it stands. That history belongs in the commit message.
- Do not use multiple boolean flags to model state — use an `enum`/sealed class.
## Modern Java Interop
When the file still has Java callers, keep the Java-facing API clean:
`@JvmStatic` for factory/companion functions, `@JvmField` for exposed constants,
`@JvmOverloads` for defaulted params, `@Throws` for checked exceptions.
## Git & Commits (developer-driven)
- Preserve history: the rename `git mv Foo.java Foo.kt` should be a **separate commit**
from the content change so `git blame` follows through.
- Conventional Commits (`refactor(sharing): convert FileDetailSharingFragment to Kotlin`).
- Every AI-assisted commit needs an `Assisted-by: <agent>:<model>` trailer.
- Only the human contributor adds `Signed-off-by` (DCO). You must never add it, and never
open PRs/issues autonomously (AI policy).
## Quality Gate
```bash
./gradlew spotlessKotlinCheck detektGplayDebug lintGplayDebug spotbugsGplayDebug \
jacocoTestGplayDebugUnitTest
```
Fix every finding in the files you changed before declaring done.
@@ -1,107 +0,0 @@
# Behaviour-Locking Tests (Mandatory Step)
A conversion is not done until a test proves behaviour did not change. If the Java class
already had tests, they are your primary safety net — run them and keep them green. If it
had none, you must add a **characterization test** that pins the current behaviour so the
refactor is provably safe.
## Decision Tree
```dot
digraph test_choice {
rankdir=LR;
"What are you locking?" -> "Pure logic (no Android SDK)" [label="fn returns a value"];
"What are you locking?" -> "Component behaviour" [label="Fragment/Activity/DB/View"];
"Pure logic (no Android SDK)" -> "JVM unit test app/src/test/ (JUnit4 + mockito-kotlin)";
"Component behaviour" -> "Robolectric unit test (if project uses it)";
"Component behaviour" -> "Instrumented test app/src/androidTest/ extends base IT class";
}
```
**Prefer the seams you just created.** The idiomatic pass extracts pure functions
(link builders, permission math, partitioning, `isReshareForbidden`) specifically so they
can be unit-tested fast without a device. Test those first; they give the most behaviour
coverage per second.
## 1. JVM Unit Tests — Pure Functions
Location: `app/src/test/`. Fast, no emulator. Command:
`./gradlew jacocoTestGplayDebugUnitTest`.
Mark the function `@VisibleForTesting internal` so the test module can reach it while it
stays out of the public API.
```kotlin
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package com.owncloud.android.ui.fragment
import com.owncloud.android.lib.resources.status.OCCapability
import org.junit.Assert.assertEquals
import org.junit.Test
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
class FileDetailSharingFragmentTest {
@Test
fun `internal link uses pretty path when modRewrite is on`() {
val user = mock<User> { whenever(it.server.uri).thenReturn(URI("https://cloud.example")) }
val file = mock<OCFile> { whenever(it.localId).thenReturn(42L) }
val caps = mock<OCCapability> { whenever(it.modRewriteWorking.isTrue).thenReturn(true) }
val link = FileDetailSharingFragment().createInternalLink(user, file, caps)
assertEquals("https://cloud.example/f/42", link)
}
@Test
fun `internal link falls back to index php path when modRewrite is off`() {
// ... same setup with modRewriteWorking.isTrue == false
// assertEquals("https://cloud.example/index.php/f/42", link)
}
}
```
The point: run this test's logic against **both** the pre-conversion and post-conversion
code paths mentally (or, if the Java is still on disk, literally) and confirm the assertion
holds for both. That is what "behaviour must not change" means concretely.
## 2. Instrumented Tests — Component Behaviour
Location: `app/src/androidTest/`. For Fragment/Activity/DB behaviour that needs the Android
runtime. Extend the project's base test class (`AbstractOnServerIT` when server
communication is required) and follow its conventions (separate test user, etc.).
```bash
./gradlew createGplayDebugCoverageReport -Pcoverage=true \
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.ui.fragment.FileDetailSharingFragmentIT
```
Use `@VisibleForTesting` hooks the original exposed (e.g. a `search(query)` or
`showSharingMenuActionSheet(share)` method) to drive and assert UI state, exactly as the
existing IT suite does. Do not weaken visibility further than the Java original did.
## 3. What to Assert
Lock the observable contract, not the implementation:
- Same return values / thrown exception types for the same inputs (including the
`require`/`requireNotNull` messages if callers depend on them).
- Same Bundle keys, intent extras, and `newInstance` argument wiring.
- Same branch outcomes (e.g. "reshare forbidden when FEDERATED", "show-all button visible
only when > 3 shares").
- For coroutine conversions, assert the end state, and use the project's test dispatcher /
`runTest` so async work is deterministic — never assert on wall-clock timing.
## 4. Guardrails
- Every new test file gets the SPDX header and ends with exactly one trailing newline.
- Do not modify unrelated tests to make yours pass.
- Report actual test output. If a test reveals the conversion changed behaviour, fix the
conversion — do not adjust the test to match the drift.
- If a genuine pre-existing bug is uncovered, surface it to the developer separately; do
not fold a behaviour change into the conversion.
-5
View File
@@ -1,5 +0,0 @@
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
exclude_paths:
- "app/src/main/cpp/**"
+4 -3
View File
@@ -1,10 +1,10 @@
FROM ubuntu:resolute@sha256:2260313b31c8c011cd2eebe728008efac1b3982be73eb71348ea2648d2c0e09b
FROM ubuntu:noble@sha256:80dd3c3b9c6cecb9f1667e9290b3bc61b78c2678c02cbdae5f0fea92cc6734ab
ARG DEBIAN_FRONTEND=noninteractive
ENV ANDROID_HOME=/usr/lib/android-sdk
RUN apt-get update -y
RUN apt-get install -y unzip wget openjdk-21-jdk vim
RUN apt-get install -y unzip wget openjdk-17-jdk vim
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -O /tmp/commandlinetools.zip
RUN cd /tmp && unzip commandlinetools.zip
@@ -16,4 +16,5 @@ RUN mkdir -p "$HOME/.gradle" && \
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > "$HOME/.gradle/gradle.properties" && \
echo "org.gradle.caching=true" >> "$HOME/.gradle/gradle.properties" && \
echo "org.gradle.parallel=true" >> "$HOME/.gradle/gradle.properties" && \
echo "org.gradle.configureondemand=true" >> "$HOME/.gradle/gradle.properties"
echo "org.gradle.configureondemand=true" >> "$HOME/.gradle/gradle.properties" && \
echo "kapt.incremental.apt=true" >> "$HOME/.gradle/gradle.properties"
+188
View File
@@ -0,0 +1,188 @@
---
kind: pipeline
type: docker
name: tests-stable
# SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
steps:
- name: gplay
image: ghcr.io/nextcloud/continuous-integration-android8:4
privileged: true
environment:
LOG_USERNAME:
from_secret: LOG_USERNAME
LOG_PASSWORD:
from_secret: LOG_PASSWORD
GIT_USERNAME:
from_secret: GIT_USERNAME
GITHUB_TOKEN:
from_secret: GIT_TOKEN
commands:
- scripts/checkIfRunDrone.sh $DRONE_PULL_REQUEST || exit 0
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
- ./gradlew assembleGplayDebugAndroidTest
- scripts/wait_for_emulator.sh
- ./gradlew installGplayDebugAndroidTest
- scripts/wait_for_server.sh "server"
- scripts/deleteOldComments.sh "stable" "IT" $DRONE_PULL_REQUEST
- ./gradlew createGplayDebugCoverageReport -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST
services:
- name: server
image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest # also change in updateScreenshots.sh
environment:
EVAL: true
SERVER_VERSION: 'stable29'
commands:
- BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh
- echo 127.0.0.1 server >> /etc/hosts
- apt-get update && apt-get install -y composer
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
- su www-data -c "php /var/www/html/occ group:add users"
- su www-data -c "php /var/www/html/occ group:adduser users user1"
- su www-data -c "php /var/www/html/occ group:adduser users user2"
- su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
- su www-data -c "php /var/www/html/occ app:enable activity"
- su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/"
- su www-data -c "php /var/www/html/occ app:enable text"
- su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
- su www-data -c "git clone --depth 1 -b $SERVER_VERSION https://github.com/nextcloud/photos.git /var/www/html/apps/photos/"
- su www-data -c "cd /var/www/html/apps/photos; composer install --no-dev"
- su www-data -c "php /var/www/html/occ app:enable -f photos"
- /usr/local/bin/run.sh
trigger:
branch:
- master
- stable-*
event:
- push
- pull_request
---
kind: pipeline
type: docker
name: tests-master
steps:
- name: gplay
image: ghcr.io/nextcloud/continuous-integration-android8:3
privileged: true
environment:
LOG_USERNAME:
from_secret: LOG_USERNAME
LOG_PASSWORD:
from_secret: LOG_PASSWORD
GIT_USERNAME:
from_secret: GIT_USERNAME
GITHUB_TOKEN:
from_secret: GIT_TOKEN
commands:
- scripts/checkIfRunDrone.sh $DRONE_PULL_REQUEST || exit 0
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
- scripts/runCombinedTest.sh $DRONE_PULL_REQUEST $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER
services:
- name: server
image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest # also change in updateScreenshots.sh
environment:
EVAL: true
commands:
- /usr/local/bin/initnc.sh
- echo 127.0.0.1 server >> /etc/hosts
- apt-get update && apt-get install -y composer
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
- su www-data -c "php /var/www/html/occ group:add users"
- su www-data -c "php /var/www/html/occ group:adduser users user1"
- su www-data -c "php /var/www/html/occ group:adduser users user2"
- su www-data -c "git clone --depth 1 -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
- su www-data -c "php /var/www/html/occ app:enable activity"
- su www-data -c "git clone --depth 1 -b main https://github.com/nextcloud/text.git /var/www/html/apps/text/"
- su www-data -c "php /var/www/html/occ app:enable text"
- su www-data -c "git clone --depth 1 -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
- su www-data -c "git clone --depth 1 https://github.com/nextcloud/photos.git /var/www/html/apps/photos/"
- su www-data -c "cd /var/www/html/apps/photos; composer install --no-dev"
- su www-data -c "php /var/www/html/occ app:enable -f photos"
- /usr/local/bin/run.sh
trigger:
branch:
- master
- stable-*
event:
- push
- pull_request
---
kind: pipeline
type: docker
name: allScreenshots
steps:
- name: runAllScreenshots
image: ghcr.io/nextcloud/continuous-integration-android8:4
privileged: true
environment:
GIT_USERNAME:
from_secret: GIT_USERNAME
GITHUB_TOKEN:
from_secret: GIT_TOKEN
LOG_USERNAME:
from_secret: LOG_USERNAME
LOG_PASSWORD:
from_secret: LOG_PASSWORD
commands:
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
- sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle
- scripts/wait_for_emulator.sh
- scripts/runAllScreenshotCombinations noCI false
- scripts/screenshotSummary.sh
- name: notify
image: drillster/drone-email
settings:
port: 587
from: [email protected]
recipients_only: true
username:
from_secret: EMAIL_USERNAME
password:
from_secret: EMAIL_PASSWORD
recipients:
from_secret: EMAIL_RECIPIENTS
host:
from_secret: EMAIL_HOST
when:
event:
- push
status:
- failure
branch:
- master
- stable-*
trigger:
event:
- cron
cron:
- allscreenshots
---
kind: secret
name: GIT_TOKEN
data: XIoa9IYq+xQ+N5iln8dlpWv0jV6ROr7HuE24ioUr4uQ8m8SjyH0yognWYLYLqnbTKrFWlFZiEMQTH/sZiWjRFvV1iL0=
---
kind: signature
hmac: f0d3fa25f7f901e8b3deacec52db0d5a81f05f7d4f13af27c633ad712ecdbc4d
...
-3
View File
@@ -4,9 +4,6 @@ contact_links:
- name: 🚨 Report a security or privacy issue
url: https://hackerone.com/nextcloud
about: Report security and privacy related issues privately to the Nextcloud team, so we can coordinate the fix and release without potentially exposing all Nextcloud servers and users in the meantime.
- name: 🚨 报告安全或隐私问题
url: https://hackerone.com/nextcloud
about: 请以私密方式向 Nextcloud 团队报告安全和隐私相关问题,以便我们能够协调修复工作并安排发布计划,避免在此期间可能暴露所有 Nextcloud 服务器和用户的风险。
- name: ❓ Community Support and Help
url: https://help.nextcloud.com/
about: Configuration, webserver/proxy or performance issues and other questions
+1 -16
View File
@@ -8,19 +8,4 @@ Unit tests: https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#uni
Instrumented tests: https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#instrumented-tests
UI tests: https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md#ui-tests
-->
### 🖼️ Screenshots
🏚️ Before | 🏡 After
---|---
B | A
### 🏁 Checklist
- [ ] ⛑️ Tests (unit and/or integration) are included or not needed
- [ ] 🔙 Backport requests are created or not needed: `/backport to stable-xx.x`
- [ ] 📅 Milestone is set
- [ ] 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)
## 🤖 AI (if applicable)
- [ ] The content of this PR was partly or fully generated using AI (N/A)
- [ ] Tests written, or not not needed
+69
View File
@@ -0,0 +1,69 @@
# synced from @nextcloud/android-config
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]>
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
# SPDX-FileCopyrightText: 2023 Josh Richards <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
name: "Analysis"
on:
pull_request:
branches: [ "master", "main", "stable-*" ]
push:
branches: [ "master", "main", "stable-*" ]
permissions:
pull-requests: write
contents: write
concurrency:
group: analysis-wrapper-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
analysis:
runs-on: ubuntu-24.04
steps:
- name: Setup variables
id: get-vars
run: |
if [ -z "$GITHUB_HEAD_REF" ]; then
# push
{
echo "branch=$GITHUB_REF_NAME"
echo "pr=$GITHUB_RUN_ID"
echo "repo=${{ github.repository }}"
} >> "$GITHUB_OUTPUT"
else
# pull request
{
echo "branch=$GITHUB_HEAD_REF"
echo "pr=${{ github.event.pull_request.number }}"
echo "repo=${{ github.event.pull_request.head.repo.full_name }}"
} >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
repository: ${{ steps.get-vars.outputs.repo }}
ref: ${{ steps.get-vars.outputs.branch }}
- name: Set up JDK 17
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: "temurin"
java-version: 17
- name: Install dependencies
run: |
sudo apt install python3-defusedxml
- name: Run analysis wrapper
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p "$HOME/.gradle"
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > "$HOME/.gradle/gradle.properties"
echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties
echo "org.gradle.parallel=true" >> $HOME/.gradle/gradle.properties
echo "org.gradle.configureondemand=true" >> $HOME/.gradle/gradle.properties
echo "kapt.incremental.apt=true" >> $HOME/.gradle/gradle.properties
scripts/analysis/analysis-wrapper.sh ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} "$GITHUB_RUN_NUMBER" ${{ steps.get-vars.outputs.pr }}
+16 -46
View File
@@ -5,7 +5,7 @@ name: "Assemble"
on:
pull_request:
branches: [master, stable-*]
branches: [ master, stable-* ]
# Declare default permissions as read only.
permissions: read-all
@@ -15,54 +15,24 @@ concurrency:
cancel-in-progress: true
jobs:
compile:
runs-on: ubuntu-latest-max
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: "temurin"
java-version: 21
- name: compile
run: |
echo "org.gradle.dependency.verification=lenient" >> gradle.properties
echo "org.gradle.jvmargs=-Xmx10g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" >> gradle.properties
echo "org.gradle.caching=true" >> gradle.properties
echo "org.gradle.parallel=true" >> gradle.properties
echo "org.gradle.configureondemand=true" >> gradle.properties
- uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: Gradle Cache
uses: burrunan/gradle-cache-action@404534c34a2faa40430357a3183522a845b04f3b # v3.0.3
with:
job-id: assemble
arguments: assembleGeneric
flavor:
runs-on: ubuntu-latest
needs: [compile]
strategy:
fail-fast: false
matrix:
flavor: [Generic, Gplay, Huawei]
flavor: [ Generic, Gplay, Huawei ]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: set up JDK 21
uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0
with:
distribution: "temurin"
java-version: 21
- uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: compile
run: |
echo "org.gradle.dependency.verification=lenient" >> gradle.properties
echo "org.gradle.jvmargs=-Xmx10g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" >> gradle.properties
echo "org.gradle.caching=true" >> gradle.properties
echo "org.gradle.parallel=true" >> gradle.properties
echo "org.gradle.configureondemand=true" >> gradle.properties
- uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
- name: Gradle Cache
uses: burrunan/gradle-cache-action@404534c34a2faa40430357a3183522a845b04f3b # v3.0.3
with:
job-id: assemble
arguments: assemble${{ matrix.flavor }}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: set up JDK 17
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: "temurin"
java-version: 17
- name: Build ${{ matrix.flavor }}
run: |
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" >> gradle.properties
echo "org.gradle.caching=true" >> gradle.properties
echo "org.gradle.parallel=true" >> gradle.properties
echo "org.gradle.configureondemand=true" >> gradle.properties
echo "kapt.incremental.apt=true" >> gradle.properties
./gradlew assemble${{ matrix.flavor }}
+40
View File
@@ -0,0 +1,40 @@
# synced from @nextcloud/android-config
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Álvaro Brey <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
name: Auto approve sync
on:
pull_request_target:
branches:
- master
- main
types:
- opened
- reopened
- synchronize
- labeled
concurrency:
group: sync-approve-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
pull-requests: write
jobs:
auto-approve:
name: Auto approve sync
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'sync') && github.actor == 'nextcloud-android-bot' }}
steps:
- name: Disabled on forks
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
run: |
echo 'Can not approve PRs from forks'
exit 1
- uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
+32
View File
@@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
name: Check
on:
pull_request:
branches: [ master, stable-* ]
# Declare default permissions as read only.
permissions: read-all
concurrency:
group: check-kotlin-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
task: [ detekt, spotlessKotlinCheck ]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK 17
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: "temurin"
java-version: 17
- name: Check ${{ matrix.task }}
run: ./gradlew ${{ matrix.task }}
+56
View File
@@ -0,0 +1,56 @@
# synced from @nextcloud/android-config
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023-2024 Andy Scherzinger <[email protected]>
# SPDX-FileCopyrightText: 2022 Tobias Kaminsky <[email protected]>
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
name: "CodeQL"
on:
push:
branches: [ "master", "main", "stable-*" ]
pull_request:
branches: [ "master", "main" ]
schedule:
- cron: '24 18 * * 3'
permissions:
contents: read
jobs:
analyze:
name: Analyze
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- 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@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
languages: ${{ matrix.language }}
- name: Set up JDK 17
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: "temurin"
java-version: 17
- name: Assemble
run: |
mkdir -p "$HOME/.gradle"
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@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
+43
View File
@@ -0,0 +1,43 @@
# synced from @nextcloud/android-config
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
# SPDX-FileCopyrightText: 2022 Tobias Kaminsky <[email protected]>
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
name: "Detect new java files"
on:
pull_request:
branches: [ master, main, stable-* ]
permissions: read-all
concurrency:
group: detect-new-java-files-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
detectNewJavaFiles:
runs-on: ubuntu-latest
steps:
- id: file_changes
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b # v1.2.4
with:
output: ','
- name: Detect new java files
run: |
if [ -z '${{ steps.file_changes.outputs.files_added }}' ]; then
echo "No new files added"
exit 0
fi
new_java=$(echo '${{ steps.file_changes.outputs.files_added }}' | tr ',' '\n' | grep '\.java$' | cat)
if [ -n "$new_java" ]; then
# shellcheck disable=SC2016
printf 'New java files detected:\n```\n%s\n```\n' "$new_java" | tee "$GITHUB_STEP_SUMMARY"
exit 1
else
echo "No new java files detected"
exit 0
fi
+30
View File
@@ -0,0 +1,30 @@
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
name: "Detect wrong settings"
on:
pull_request:
branches: [ master, stable-* ]
# Declare default permissions as read only.
permissions: read-all
concurrency:
group: detect-wrong-settings-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
detectWrongSettings:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK 17
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: "temurin"
java-version: 17
- name: Detect SNAPSHOT
run: scripts/analysis/detectWrongSettings.sh
@@ -0,0 +1,29 @@
# synced from @nextcloud/android-config
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
# SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]>
# SPDX-FileCopyrightText: 2023 Álvaro Brey <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
name: "Validate Gradle Wrapper"
on:
pull_request:
branches: [ master, stable-* ]
push:
branches: [ master, stable-* ]
# Declare default permissions as read only.
permissions: read-all
concurrency:
group: validate-gradle-wrapper-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 # v3.5.0
+50
View File
@@ -0,0 +1,50 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Marcel Klehr <[email protected]>
# SPDX-FileCopyrightText: 2023 Joas Schilling <[email protected]>
# SPDX-FileCopyrightText: 2023 Daniel Kesselberg <[email protected]>
# SPDX-FileCopyrightText: 2023 Florian Steffens <[email protected]>
# SPDX-License-Identifier: MIT
name: 'Ask for feedback on PRs'
on:
schedule:
- cron: '30 1 * * *'
jobs:
pr-feedback:
runs-on: ubuntu-latest
steps:
- name: The get-github-handles-from-website action
uses: marcelklehr/get-github-handles-from-website-action@06b2239db0a48fe1484ba0bfd966a3ab81a08308 # v1.0.1
id: scrape
with:
website: 'https://nextcloud.com/team/'
- name: Get blocklist
id: blocklist
run: |
blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -)
echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT"
- uses: marcelklehr/pr-feedback-action@1883b38a033fb16f576875e0cf45f98b857655c4
with:
feedback-message: |
Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.
We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.
Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6
Thank you for contributing to Nextcloud and we hope to hear from you soon!
(If you believe you should not receive this message, you can add yourself to the [blocklist](https://github.com/nextcloud/.github/blob/master/non-community-usernames.txt).)
days-before-feedback: 14
start-date: '2024-04-30'
exempt-authors: '${{ steps.blocklist.outputs.blocklist }},${{ steps.scrape.outputs.users }}'
exempt-bots: true
+53
View File
@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
name: "QA"
on:
pull_request:
branches: [ master, stable-* ]
permissions:
pull-requests: write
contents: read
concurrency:
group: qa-build-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
qa:
runs-on: ubuntu-latest
steps:
- name: Check if secrets are available
run: echo "ok=${{ secrets.KS_PASS != '' }}" >> "$GITHUB_OUTPUT"
id: check-secrets
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
- name: set up JDK 17
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
with:
distribution: "temurin"
java-version: 17
- name: Build QA
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
env:
KS_PASS: ${{ secrets.KS_PASS }}
KEY_PASS: ${{ secrets.KEY_PASS }}
LOG_USERNAME: ${{ secrets.LOG_USERNAME }}
LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p $HOME/.gradle
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > $HOME/.gradle/gradle.properties
echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties
echo "org.gradle.parallel=true" >> $HOME/.gradle/gradle.properties
echo "org.gradle.configureondemand=true" >> $HOME/.gradle/gradle.properties
echo "kapt.incremental.apt=true" >> $HOME/.gradle/gradle.properties
sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" app/build.gradle
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" app/build.gradle
./gradlew assembleQaDebug
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks app/build/outputs/apk/qa/debug/qa-debug-*.apk
scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD ${{github.event.number}} ${{github.event.number}} $GITHUB_TOKEN
@@ -0,0 +1,58 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
#
# SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Auto approve renovate PRs
on:
pull_request_target:
branches:
- main
- master
- stable*
permissions:
contents: read
concurrency:
group: renovate-approve-merge-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
auto-approve-merge:
if: github.actor == 'renovate[bot]'
runs-on: ubuntu-latest
permissions:
# for hmarr/auto-approve-action to approve PRs
pull-requests: write
# for alexwilson/enable-github-automerge-action to approve PRs
contents: write
steps:
- name: Disabled on forks
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
run: |
echo 'Can not approve PRs from forks'
exit 1
- uses: mdecoleman/pr-branch-name@55795d86b4566d300d237883103f052125cc7508 # v3.0.0
id: branchname
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# GitHub actions bot approve
- uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0
if: startsWith(steps.branchname.outputs.branch, 'renovate/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Enable GitHub auto merge
- name: Auto merge
uses: alexwilson/enable-github-automerge-action@main
if: startsWith(steps.branchname.outputs.branch, 'renovate/')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
+22
View File
@@ -0,0 +1,22 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. <https://fsfe.org>
#
# SPDX-License-Identifier: CC0-1.0
name: REUSE Compliance Check
on: [pull_request]
jobs:
reuse-compliance-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5.0.0
+47
View File
@@ -0,0 +1,47 @@
# synced from @nextcloud/android-config
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
name: Scorecard supply-chain security
on:
branch_protection_rule:
schedule:
- cron: '32 23 * * 4'
push:
branches: [ "main", "master" ]
# Declare default permissions as read only.
permissions: read-all
concurrency:
group: scorecard-supply-chain-security-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
steps:
- name: "Checkout code"
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: "Run analysis"
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
publish_results: false
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
sarif_file: results.sarif
+110
View File
@@ -0,0 +1,110 @@
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
name: "Screenshot Test"
on:
pull_request:
branches: [ master, stable-* ]
permissions:
contents: read
pull-requests: write
concurrency:
group: screenshot-test-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
screenshot:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
scheme: [ Light ]
color: [ blue ]
api-level: [ 27 ]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Gradle cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: AVD cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: "temurin"
java-version: 17
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
arch: x86
sdcard-path-or-size: 100M
target: google_apis
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833
script: echo "Generated AVD snapshot for caching."
- name: Configure gradle daemon
run: |
mkdir -p $HOME/.gradle
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > $HOME/.gradle/gradle.properties
echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties
echo "org.gradle.parallel=true" >> $HOME/.gradle/gradle.properties
echo "org.gradle.configureondemand=true" >> $HOME/.gradle/gradle.properties
echo "kapt.incremental.apt=true" >> $HOME/.gradle/gradle.properties
- name: Build gplay
run: ./gradlew assembleGplayDebug
- name: Delete old comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ always() }}
run: scripts/deleteOldComments.sh "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
- name: Run screenshot tests
env:
SHOT_TEST: "true"
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
arch: x86
sdcard-path-or-size: 100M
target: google_apis
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833
script: ./gradlew uninstallAll gplayDebugExecuteScreenshotTests -Dorg.gradle.jvmargs="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.nio.channels=ALL-UNNAMED --add-exports java.base/sun.nio.ch=ALL-UNNAMED" -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
- name: upload failing results
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
- name: Archive Espresso results
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
if: ${{ always() }}
with:
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
path: app/build/reports
retention-days: 4
+35
View File
@@ -0,0 +1,35 @@
# synced from @nextcloud/android-config
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]>
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later
name: 'Close stale issues'
on:
schedule:
- cron: '0 0 * * *'
# Declare default permissions as read only.
permissions: read-all
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
with:
days-before-stale: 28
days-before-close: 14
days-before-pr-close: -1
only-labels: 'bug,needs info'
exempt-issue-labels: 'no-stale'
stale-issue-message: >-
This bug report did not receive an update in the last 4 weeks.
Please take a look again and update the issue with new details,
otherwise the issue will be automatically closed in 2 weeks. Thank you!
exempt-all-pr-milestones: true
labels-to-remove-when-unstale: 'needs info'
+55
View File
@@ -0,0 +1,55 @@
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
name: Unit tests
on:
pull_request:
branches: [ master, stable-* ]
push:
branches: [ master, stable-* ]
permissions:
contents: read
pull-requests: write
concurrency:
group: unit-tests-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK 17
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4.6.0
with:
distribution: "temurin"
java-version: 17
- name: Delete old comments
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ always() }}
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
- name: Run unit tests with coverage
uses: gradle/gradle-build-action@ac2d340dc04d9e1113182899e983b5400c17cda1 # v3.5.0
with:
arguments: jacocoTestGplayDebugUnitTest
- name: Upload failing results
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
- name: Upload coverage to codecov
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit
fail_ci_if_error: true
- name: Upload jacoco artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: test-results
path: app/build/reports/tests/testGplayDebugUnitTest/
-37
View File
@@ -22,32 +22,9 @@ target/
local.properties
tests/local.properties
# Signing & secrets
*.jks
*.keystore
keystore.properties
release.properties
google-services.json
GoogleService-Info.plist
*.p12
*.pem
secrets.properties
.env
.env.*
# Windows
Thumbs.db
desktop.ini
# Mac .DS_Store files
.DS_Store
# Linux/editor temp files
*~
*.swp
*.swo
.vscode/
# Proguard README
proguard-project.txt
tests/proguard-project.txt
@@ -62,20 +39,6 @@ build
fastlane/Fastfile
*.hprof
# NDK / C++
*.so
obj/
*.o
*.a
.cxx/
# Testing & coverage
.kotlin/
*.lcov
test-results/
jacoco/
*.exec
# fastlane specific
**/fastlane/report.xml
+25 -1
View File
@@ -2,11 +2,35 @@
<code_scheme name="Project" version="173">
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value />
</option>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
<emptyLine />
<package name="junit" withSubpackages="true" static="false" />
<emptyLine />
<package name="net" withSubpackages="true" static="false" />
<emptyLine />
<package name="org" withSubpackages="true" static="false" />
<emptyLine />
<package name="java" withSubpackages="true" static="false" />
<emptyLine />
<package name="javax" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="false" />
<emptyLine />
<package name="" withSubpackages="true" static="true" />
<emptyLine />
</value>
</option>
<option name="RIGHT_MARGIN" value="120" />
<JavaCodeStyleSettings>
<option name="IMPORT_LAYOUT_TABLE">
<value>
<package name="" withSubpackages="true" static="false" module="true" />
<package name="android" withSubpackages="true" static="false" />
<emptyLine />
<package name="com" withSubpackages="true" static="false" />
+1 -38
View File
@@ -4,36 +4,7 @@
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.nio.channels.FileChannel,position,okhttp3.Call,execute" />
</inspection_tool>
<inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
</inspection_tool>
<inspection_tool class="KotlinUnusedImport" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="LongLine" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
@@ -42,10 +13,6 @@
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
@@ -70,14 +37,10 @@
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewParameterProviderOnFirstParameter" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="composableFile" value="true" />
<option name="previewFile" value="true" />
</inspection_tool>
<inspection_tool class="RedundantSemicolon" enabled="true" level="ERROR" enabled_by_default="true" />
</profile>
</component>
</component>
-218
View File
@@ -1,218 +0,0 @@
<!--
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
# Agents.md
This file provides guidance to all AI agents (Claude, Codex, Gemini, etc.) working with code in this repository.
You are an experienced engineer specialized on Java, Kotlin and familiar with the platform-specific details of Android.
## Your Role
- You implement features and fix bugs.
- Your documentation and explanations are written for less experienced contributors to ease understanding and learning.
- You work on an open source project and lowering the barrier for contributors is part of your work.
## Project Overview
The Nextcloud Android Client is a application to synchronize files from Nextcloud Server with your Android device.
Java, Kotlin, XML, Jetpack Compose are the key technologies used for building the app.
## Project Structure: AI Agent Handling Guidelines
- `./app/src/main/java/com/owncloud/android/` Legacy components (Activities, datamodel, operations)
- `./app/src/main/java/com/nextcloud/` Modern components (client APIs, DI, repositories, UI with Compose)
- `./app/src/main/java/com/nextcloud/utils/extensions/` Extension functions for common types
- `./app/src/main/java/com/nextcloud/ui/` Jetpack Compose UI components and screens
- `./app/src/main/java/com/nextcloud/client/di/` Dependency injection configuration (Dagger 2)
- `./app/src/main/java/com/nextcloud/client/assistant/` AI features (Assistant screen, chat, conversations, translations)
- `./app/src/test/` Unit tests (small, isolated tests without Android SDK)
- `./app/src/androidTest/` Instrumented tests (require Android SDK)
- `./app/src/main/res/values/` Translations. Only update `./app/src/main/res/values/strings.xml`. Do not modify any other translation files or folders. Ignore all `values-*` directories (e.g., `values-es`, `values-fr`).
- `./.claude/skills/` Reusable agent skills. Each subdirectory is one skill with a `SKILL.md` entry point plus `references/` and `assets/`.
## Agent Skills
Project-specific skills live in `./.claude/skills/<skill-name>/`. Load a skill when the task matches its trigger.
- **`android-java-to-kotlin`** (`./.claude/skills/android-java-to-kotlin/SKILL.md`) — Completes a Java-to-Kotlin conversion in this Android app. Use it when finishing a conversion, when the user mentions "java to kotlin", "j2k", "convert java", or "make it idiomatic", or when a freshly IDE-converted `.kt` file needs cleanup. The workflow is two-person: the developer first runs the Android Studio converter (`Code > Convert Java File to Kotlin File`), then the agent drives the idiomatic second pass — fail-fast control flow, function decomposition, `lifecycleScope`/coroutines instead of Java threads, modern Android APIs, and project conventions (SPDX headers, no magic numbers, `@JvmStatic`). The conversion must preserve behaviour, and the agent must write a behaviour-locking test before declaring it done.
## General Guidance
Every new file needs to get a SPDX header in the first rows according to this template.
The year in the first line must be replaced with the year when the file is created (for example, 2026 for files first added in 2026).
The commenting signs need to be used depending on the file type.
New contributions use AGPL-3.0-or-later license. Files may also have `OR GPL-2.0-only` in the license if they originated from GPL-licensed code.
```plaintext
SPDX-FileCopyrightText: <YEAR> Nextcloud GmbH and Nextcloud contributors
SPDX-License-Identifier: AGPL-3.0-or-later
```
Kotlin/Java:
```kotlin
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: <year> Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
```
XML:
```xml
<!--
~ Nextcloud - Android Client
~
~ SPDX-FileCopyrightText: <year> Nextcloud GmbH and Nextcloud contributors
~ SPDX-License-Identifier: AGPL-3.0-or-later
-->
```
Avoid creating source files that implement multiple types; instead, place each type in its own dedicated source file.
## Design
- Follow Material Design 3 guidelines
- In addition to any Material Design wording guidelines, follow the Nextcloud wording guidelines at https://docs.nextcloud.com/server/latest/developer_manual/design/foundations.html#wording
- Ensure the app works in both light and dark theme
- Ensure the app works with different server primary colors by using the colorTheme of viewThemeUtils
## Architecture & Patterns
### Jetpack Compose
Modern UI is built with Jetpack Compose (Material 3). Key directories:
- `com.nextcloud.ui.composeActivity` - Activities hosting Compose content
- `com.nextcloud.ui.composeComponents` - Reusable Compose components
- `com.nextcloud.client.assistant` - Compose-based Assistant screens and features
Use `StateFlow` and `MutableStateFlow` in ViewModels for state management. Collect state in Compose functions with `collectAsState()`.
### Dependency Injection
Uses Dagger 2 for major Android components (`Activity`, `Fragment`, `Service`, `BroadcastReceiver`, `ContentProvider`). Manual constructor injection for other components.
### Extension Functions
The `com.nextcloud.utils.extensions` package contains helper extensions organized by type (e.g., `FileExtensions.kt`, `StringExtensions.kt`, `ViewExtensions.kt`). Create focused extension files rather than putting multiple types in one file.
## Testing
### Unit Tests (`./app/src/test/`)
- Small, isolated tests without Android SDK
- Use Mockito with `mockito-kotlin` for easier mocking
- Recommended command: `./gradlew jacocoTestGplayDebugUnitTest`
- Tests use JUnit 4 with `@Test`, `@Before`, `@After` annotations
### Instrumented Tests (`./app/src/androidTest/`)
- Tests requiring Android SDK (Activities, Fragments, database access)
- Use Espresso for UI testing
- Tests should inherit from `AbstractOnServerIT` if they need server communication
- Always create a separate test user on test server to avoid data interference
- Run with: `./gradlew createGplayDebugCoverageReport -Pcoverage=true`
- Run specific test class: `./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=<fully.qualified.ClassName>`
- Run one test method: `./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=<fully.qualified.ClassName>#methodName`
### Screenshot Tests (Shot)
- Enabled via `SHOT_TEST=true` environment variable
- Use: `scripts/androidScreenshotTest` to check, `scripts/updateScreenshots.sh` to regenerate
- CI renders shadows differently; 0.5% tolerance is configured
## Code Quality Tools
All code is validated with the following tools. Fix findings in modified files:
- **lint** - Android linting (configured in `app/lint.xml`)
- **spotbugsGplayDebug** - Bug detection for Gplay variant
- **detekt** - Kotlin code analysis (configured in `app/detekt.yml`)
- **spotlessKotlinCheck** - Code formatting with ktlint
Run all checks with: `./gradlew check`
## Nextcloud Contribution Policy
All contributions generated or assisted by this agent must fully comply with:
- **[AI Contribution Policy](https://github.com/nextcloud/.github/blob/master/AI_POLICY.md)** - the primary reference for AI-specific rules, covering disclosure, author accountability, communication, security, licensing, code quality, and autonomous agent behavior.
- **[Contribution Guidelines](https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md)** - covering testing requirements, the Developer Certificate of Origin (DCO), license headers, conventional commits, and translations. These apply in full to all contributions regardless of how they were produced.
### What this agent must always do
- Add an `Assisted-by: AGENT_NAME:MODEL_VERSION` git trailer to every commit containing AI-assisted content.
- Ensure every pull request includes a disclosure of AI tool use in the PR description.
- Produce focused, scoped pull requests that address exactly one concern. Do not touch unrelated files or introduce incidental refactors.
- Verify all dependencies against actual package registries before suggesting them. Do not use hallucinated or unverified package names.
- Explicitly inform the contributor when any action they are about to take, or have taken, would violate the AI Contribution Policy or the Contribution Guidelines. Do not silently proceed. State which rule is at risk and what the contributor should do instead.
- Warn the contributor if a pull request is growing too large. A PR approaching several thousand lines of changed code is a signal that it should be split into smaller, focused PRs. Suggest a logical split before the PR is opened, not after.
- Recommend opening a ticket for discussion before starting implementation whenever a feature or change is sufficiently complex - for example when it touches multiple subsystems, requires architectural decisions, or the right approach is not yet clear. A ticket allows maintainers and the contributor to align on direction before code is written, avoiding wasted effort on a PR that may be rejected or require fundamental rework.
### What this agent must never do
- Open issues, submit pull requests, post review comments, or send security reports autonomously. Every contribution must be reviewed and submitted by a human.
- Add `Signed-off-by` tags to commits. Only the human contributor can certify the Developer Certificate of Origin.
- Generate or submit security reports without independent human verification. Report verified vulnerabilities via [HackerOne](https://hackerone.com/nextcloud), not as GitHub issues.
- Write PR descriptions, review comments, or issue reports on behalf of the contributor. These must be in the contributor's own words.
- Fully automate the resolution of issues labeled [`good first issue`](https://github.com/issues?q=org%3Anextcloud+label%3A%22good+first+issue%22) or similar beginner-friendly labels.
- Submit code that has not been reviewed and cleaned up by the contributor. Dead code, redundant logic, excessive comments, and unrelated changes must be removed before submission.
## Commit and Pull Request Guidelines
### Commits
- All commits must be signed off (`git commit -s`) per the Developer Certificate of Origin (DCO). All PRs target `master`. Backports use `/backport to stable-X.Y` in a PR comment.
- Commit messages must follow the [Conventional Commits v1.0.0 specification](https://www.conventionalcommits.org/en/v1.0.0/#specification) — e.g. `feat(chat): add voice message playback`, `fix(call): handle MCU disconnect gracefully`.
- Every commit made with AI assistance must include an `Assisted-by: AGENT_NAME:MODEL_VERSION` git trailer identifying the coding agent and model used:
```
Assisted-by: ClaudeCode:claude-sonnet-4-6
Assisted-by: Copilot:claude-sonnet-4-6
```
General pattern: `Assisted-by: <coding-agent>:<model-version>`
### Pull Requests
- Include a short summary of what changed. *Example:* `fix: prevent crash on empty todo title`.
- **Pull Request**: When the agent creates a PR, it should include a description summarizing the changes and why they were made. If a GitHub issue exists, reference it (e.g., “Closes #123”).
## Code Style
- Do not exceed 300 lines of code per file.
- Line length: **120 characters**
- Standard Android Studio formatter with EditorConfig.
- Kotlin preferred for new code; legacy Java still present.
- Every new file must end with exactly one empty trailing line (no more, no less).
- Create models, states in different files instead of doing it one single file.
- Do not use magic numbers.
- Apply fail fast principle instead of using nested if-else statements.
- Do not use multiple boolean flags to determine states instead use enums or sealed classes.
- Use modern Java for Java classes. Optionals, virtual threads, records, streams if necessary.
- Avoid hardcoded strings, colors, dimensions. Use resources.
- Run lint, spotbugsGplayDebug, detekt, spotlessKotlinCheck and fix findings inside the files that have been changed.
## Comments
Names carry the explanation, not comments. A function or variable whose purpose is not obvious from its
name is a naming problem or a decomposition problem — rename it or split it, do not describe it in a comment.
Assume the reader knows Kotlin, Java and the Android framework.
Write a comment only when the code cannot carry the information itself: a non-obvious invariant, a workaround
for a platform or server bug, an ordering requirement, or a decision whose alternatives look equally valid and
are not. When you do write one, explain **why**, never **what**.
Never write:
- Comments that restate the code (`// increase the counter` above `counter++`).
- KDoc/Javadoc added to a function just because the function is new.
- Narration of the change or its history: "changed from X to Y", "previously this failed", "this is not a
permanent failure so we now retry", "fixes the crash reported in the issue". Comments describe the code as
it is today. A reader six months from now has no access to the issue, the PR discussion, or the conversation
that produced the change — that context belongs in the commit message and the PR description.
- Decorative section-divider comments of any kind (e.g. `// ── Title ───`, `// ------`, `// ======`).
`// region` / `// endregion` for IDE folding is allowed where the file already uses it.
Existing comments that are still accurate stay. Delete the ones the change makes wrong or obsolete.
-92
View File
@@ -1,95 +1,3 @@
## 3.33.0 (September 10, 2025)
- Migrate to Glide 4
- Performance improvements
- Fix gallery image scaling
- Bugfixes
Minimum: NC 18 Server, Android 8.1 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/112
## 3.32.3 (August 21, 2025)
- Bugfixes
Minimum: NC 18 Server, Android 8.0 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/114
## 3.32.2 (July 18, 2025)
- Resolved image blurriness issue.
- Fixed crash occurring in the conflict resolution dialog.
- Addressed crash in the upload finish receiver event handler.
Minimum: NC 18 Server, Android 8.0 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/115
## 3.32.1 (July 14, 2025)
- Bug fixes.
Minimum: NC 18 Server, Android 8.0 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/113
## 3.32.0 (July 2, 2025)
- Minimum supported Android version is 8.0.
- Scrolling performance has been increased in the media tab.
- Multi-select feature added to the media tab.
- Custom share permissions have been added.
- Bug fixes.
Minimum: NC 18 Server, Android 8.0 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/107
## 3.31.4 (June 3, 2025)
- Add missing auto migration
Minimum: NC 18 Server, Android 7.1 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/110
## 3.31.3 (May 28, 2025)
- fix simple sign up
- bugfixes
- update translations
Minimum: NC 18 Server, Android 7.1 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/110
## 3.31.2 (May 20, 2025)
- bring back MANAGE_EXTERNAL_STORAGE permission
Minimum: NC 18 Server, Android 7.1 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/108
## 3.31.1 (April 3, 2025)
- Various bug fixes and performance enhancements
Minimum: NC 18 Server, Android 7.1 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/108
## 3.31.0 (February 25, 2025)
- New share layout
- Various bug fixes and performance enhancements
Minimum: NC 18 Server, Android 7.1 Nougat
For a full list, please see https://github.com/nextcloud/android/milestone/100
## 3.30.7 (January 6, 2025)
- Fix crash of auto upload settings
-1
View File
@@ -1 +0,0 @@
@AGENTS.md
+10 -39
View File
@@ -14,7 +14,7 @@
1. [Contributing to Source Code](#contributing-to-source-code)
1. [Developing process](#developing-process)
1. [Branching model](#branching-model)
1. [Formatter setup](#formatter-setup)
1. [Android Studio formatter setup](#android-studio-formatter-setup)
1. [Build variants](#build-variants)
1. [Git hooks](#git-hooks)
1. [Contribution process](#contribution-process)
@@ -107,22 +107,12 @@ We are all about quality while not sacrificing speed so we use a very pragmatic
* Hot fixes not relevant for an upcoming feature release but the latest release can target the bug fix branch directly
### Formatter setup
### Android Studio formatter setup
Our formatter setup is rather simple:
* Standard Android Studio
* Line length 120 characters (Settings->Editor->Code Style->Right margin(columns): 120; also set by EditorConfig
* Line length 120 characters (Settings->Editor->Code Style->Right margin(columns): 120)
* Auto optimize imports (Settings->Editor->Auto Import->Optimize imports on the fly)
You can fix Check / check (spotlessKotlinCheck) via following commands:
```bash
./gradlew spotlessApply
./gradlew detekt
./gradlew spotlessCheck
./gradlew spotlessKotlinCheck
```
See section [Git hooks](#git-hooks) to have these run automatically with your commits.
### Build variants
There are three build variants
@@ -132,7 +122,7 @@ There are three build variants
### Git hooks
We provide git hooks to make development process easier for both the developer and the reviewers.
They are stored in [/scripts/hooks](/scripts/hooks) and can be installed with:
To install them, just run:
```bash
./gradlew installGitHooks
@@ -224,44 +214,25 @@ Source code of app:
- small, isolated tests, with no need of Android SDK
- code coverage can be directly shown via right click on test and select "Run Test with Coverage"
```bash
./gradlew jacocoTestGplayDebugUnitTest
```
#### Instrumented tests
- tests to see larger code working in correct way
- tests that require parts of Android SDK
- best to avoid server communication, see https://github.com/nextcloud/android/pull/3624
- run all tests ```./gradlew createGplayDebugCoverageReport -Pcoverage=true```
- run selective test class: ```./gradlew createGplayDebugCoverageReport -Pcoverage=true
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerContentProviderClientIT```
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest```
- run multiple test classes:
- separate by ","
- ```./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerContentProviderClientIT,com.nextcloud.client.FileDisplayActivityIT```
- ```./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest,com.nextcloud.client.FileDisplayActivityIT```
- run one test in class: ```./gradlew createGplayDebugCoverageReport -Pcoverage=true
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerContentProviderClientIT#saveFile```
-Pandroid.testInstrumentationRunnerArguments.class=com.owncloud.android.datamodel.FileDataStorageManagerTest#saveNewFile```
- JaCoCo results are shown as html: firefox ./build/reports/coverage/gplay/debug/index.html
#### Instrumented tests with server communication
It is best to avoid server communication, see https://github.com/nextcloud/android/pull/3624.
But if a test requires a server, this is how it is done:
- Have a Nextcloud service reachable by your test device. This can be an existing server in the internet or a locally deployed one
as per the [server developer documentation](https://docs.nextcloud.com/server/latest/developer_manual/getting_started/devenv.html)
- Create a separate(!) test user on that server, otherwise the tests will infer with productive data.
- In `gradle.properties`, enter the URL, user name and password via the `NC_TEST_SERVER_...` attributes.
If you want to prevent an accidental commit of those, you can also store them in `~/.gradle/gradle.properties`.
- Your test class should inherit from `AbstractOnServerIT`, e.g.: `public class DownloadIT extends AbstractOnServerIT { ...`
Note that this will automatically delete all files after each test run, so you absolutely NEED a separate test user as mentioned above.
- All preconditions of your test regarding server data, e.g. existing files, need to be established by your test itself.
As a reference, see how `DownloadIT` first uploads the files it later tests the download with.
- Clean up these preconditions again, also in the failure case, using one or multiple `@After` methods in your test class.
#### UI tests
We use [shot](https://github.com/Karumi/Shot) for taking screenshots and compare them.
To exclude the shot dependency from normal builds, the dependency needs to be activated via an environment variable `SHOT_TEST`.
For convenience, this and other prerequisites are encapsulated in utility scripts, so it is advised to use them
- check screenshots: ```scripts/androidScreenshotTest ```
- check the script for a detailed documentation of the parameters
We use [shot](https://github.com/Karumi/Shot) for taking screenshots and compare them
- check screenshots: ```./gradlew gplayDebugExecuteScreenshotTests ```
- update/generate new screenshots: ```scripts/updateScreenshots.sh ```
- in this script are samples how to only execute a given class/test
- this will fire up docker & emulator to ensure that screenshots look the same
+107 -140
View File
@@ -1,231 +1,200 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.8)
abbrev (0.1.2)
addressable (2.9.0)
public_suffix (>= 2.0.2, < 8.0)
CFPropertyList (3.0.7)
base64
nkf
rexml
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.4.0)
aws-partitions (1.1281.0)
aws-sdk-core (3.254.1)
aws-eventstream (1.3.0)
aws-partitions (1.1021.0)
aws-sdk-core (3.214.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
base64
bigdecimal
jmespath (~> 1, >= 1.6.1)
logger
aws-sdk-kms (1.130.0)
aws-sdk-core (~> 3, >= 3.254.0)
aws-sdk-kms (1.96.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.229.0)
aws-sdk-core (~> 3, >= 3.254.1)
aws-sdk-s3 (1.176.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.12.1)
aws-sigv4 (1.10.1)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (3.3.1)
cgi (0.4.2)
base64 (0.2.0)
cgi (0.4.1)
claide (1.1.0)
colored (1.2)
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
csv (3.3.6)
declarative (0.0.20)
digest-crc (0.7.0)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20240107)
dotenv (2.8.1)
emoji_regex (3.2.3)
erb (6.0.7)
excon (0.112.0)
faraday (2.14.3)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-cookie_jar (0.0.8)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.7)
faraday (>= 0.8.0)
http-cookie (>= 1.0.0)
faraday-follow_redirects (0.5.0)
faraday (>= 1, < 3)
faraday-multipart (1.2.0)
multipart-post (~> 2.0)
faraday-net_http (2.1.0)
faraday-retry (2.4.0)
faraday (~> 2.0)
fastimage (2.4.1)
fastlane (2.238.0)
CFPropertyList (>= 2.3, < 5.0.0)
abbrev (~> 0.1)
addressable (>= 2.9.0, < 3.0.0)
http-cookie (~> 1.0.0)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.226.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.197)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
base64 (~> 0.2)
benchmark (>= 0.1.0)
bundler (>= 2.4.0, < 5.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored (~> 1.2)
commander (~> 4.6)
csv (~> 3.3)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
excon (>= 0.71.0, < 2.0.0)
faraday (~> 2.7)
faraday-cookie_jar (~> 0.0.8)
faraday-follow_redirects (~> 0.3)
faraday-multipart (~> 1.0)
faraday-retry (~> 2.0)
excon (>= 0.71.0, < 1.0.0)
faraday (~> 1.0)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
fastlane-sirp (>= 1.1.0)
fastlane-sirp (>= 1.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-env (>= 1.6.0, < 2.3.0)
google-cloud-env (>= 1.6.0, < 2.0.0)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
http-cookie (~> 1.0.5)
irb (>= 1.8)
json (< 3.0.0)
jwt (>= 2.10.3, < 4)
logger (>= 1.6, < 2.0)
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multi_json (~> 1.12)
multipart-post (>= 2.0.0, < 3.0.0)
mutex_m (~> 0.3)
naturally (~> 2.2)
nkf (~> 0.2)
optparse (>= 0.1.1, < 1.0.0)
ostruct (>= 0.1.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.5)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 4)
terminal-table (~> 3)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.4.1)
xcpretty (~> 0.4.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-huawei_appgallery_connect (1.0.31)
cgi
fastlane-sirp (1.1.0)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.106.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-core (0.18.0)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 1.9)
httpclient (>= 2.8.3, < 3.a)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
mutex_m
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
google-apis-iamcredentials_v1 (0.28.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-playcustomapp_v1 (0.18.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-storage_v1 (0.66.0)
google-apis-core (>= 0.15.0, < 2.a)
google-cloud-core (1.9.0)
rexml
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.31.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.7.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.2.2)
base64 (~> 0.2)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.7.0)
google-cloud-storage (1.62.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.4.0)
google-cloud-storage (1.47.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-core (>= 0.18, < 2)
google-apis-iamcredentials_v1 (~> 0.18)
google-apis-storage_v1 (>= 0.42)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.31.0)
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
google-logging-utils (0.2.0)
googleauth (1.17.3)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.2)
google-logging-utils (~> 0.1)
jwt (>= 1.4, < 4.0)
googleauth (1.8.1)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
pstore (~> 0.1)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.9.0)
mutex_m
io-console (0.9.2)
irb (1.18.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.21.2)
jwt (2.10.3)
json (2.9.0)
jwt (2.9.3)
base64
logger (1.7.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
multi_json (1.21.1)
multi_json (1.15.0)
multipart-post (2.4.1)
mutex_m (0.3.0)
nanaimo (0.4.0)
naturally (2.3.0)
nkf (0.3.0)
optparse (0.8.1)
naturally (2.2.1)
nkf (0.2.0)
optparse (0.6.0)
os (1.1.4)
ostruct (0.6.3)
plist (3.7.2)
pp (0.6.4)
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
pstore (0.2.1)
public_suffix (6.0.2)
rake (13.4.2)
rbs (4.1.3)
logger
prism (>= 1.6.0)
tsort
rdoc (8.0.0)
erb
prism (>= 1.6.0)
rbs (>= 4.0.0)
tsort
reline (0.7.0)
io-console (~> 0.5)
plist (3.7.1)
public_suffix (6.0.1)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.8.0)
rexml (3.4.4)
retriable (3.1.2)
rexml (3.3.9)
rouge (3.28.0)
rubyzip (2.4.1)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.5)
signet (0.22.0)
signet (0.19.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 4.0)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.10)
CFPropertyList
naturally
sysrandom (1.0.5)
terminal-notifier (2.0.0)
terminal-table (4.0.0)
unicode-display_width (>= 1.1.1, < 4)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
trailblazer-option (0.1.2)
tsort (0.2.0)
tty-cursor (0.7.1)
tty-screen (0.8.2)
tty-spinner (0.9.3)
@@ -233,16 +202,14 @@ GEM
uber (0.1.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.28.1)
xcodeproj (1.27.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
base64
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
nkf
rexml (>= 3.3.6, < 4.0)
xcpretty (0.4.1)
xcpretty (0.4.0)
rouge (~> 3.28.0)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
-49
View File
@@ -1,49 +0,0 @@
Trademark policy
April 2023
You may not violate others’ intellectual property rights, including copyright and trademark.
A trademark is a word, logo, phrase, or device that distinguishes a trademark holder’s good or service in the marketplace. Trademark law may prevent others from using a trademark in an unauthorized or confusing manner.
What is in violation of this policy?
Using another’s trademark in a way that may mislead or confuse people about your affiliation may be a violation of our trademark policy.
What is not a violation of this policy?
Referencing another’s trademark is not automatically a violation of X's trademark policy. Examples of non-violations include:
* using a trademark in a way that is outside the scope of the trademark registration e.g., in a different territory, or a different class of goods or services than that identified in the registration; and
* using a trademark in a nominative or other fair use manner. For more information, see our Misleading and deceptive identities policy (https://help.twitter.com/en/rules-and-policies/twitter-impersonation-and-deceptive-identities-policy.html).
Who can report violations of this policy?
X only investigates requests that are submitted by the trademark holder or their authorized representative e.g., a legal representative or other representative for a brand.
How can I report violations of this policy?
You can submit a trademark report through our trademark report form (https://help.twitter.com/forms/trademark). Please provide all the information requested in the form. If you submit an incomplete report, we’ll need to follow up about the missing information. Please note that this will result in a delay in processing your report.
Note: We may provide the account holder with your name and other information included in the copy of the report.
What happens if you violate this policy?
If we determine that you violated our trademark policy, we may suspend your account. Depending on the type of violation, we may give you an opportunity to comply with our policies. In other instances, an account may be permanently suspended upon first review. If you believe that your account was suspended in error, you can submit an appeal (https://help.twitter.com/forms/general?subtopic=suspended).
Additional resources
Learn more about our range of enforcement options (https://help.twitter.com/rules-and-policies/enforcement-options) and our approach to policy development and enforcement (https://help.twitter.com/rules-and-policies/enforcement-philosophy).
Legal disclaimer
By using the X trademarks and resources on this site, you agree to follow the X Trademark Guidelines in our Brand Guidelines — as well as our Terms of Service and all other X rules and policies. If you have any questions, contact us at [email protected].
A copy can be found at https://about.x.com/en/who-we-are/brand-toolkit and https://help.twitter.com/en/rules-and-policies/x-trademark-policy
+2 -6
View File
@@ -4,7 +4,7 @@
-->
# [Nextcloud](https://nextcloud.com) Android app :iphone:
[![REUSE status](https://api.reuse.software/badge/github.com/nextcloud/android)](https://api.reuse.software/info/github.com/nextcloud/android) [![Build Status](https://drone.nextcloud.com/api/badges/nextcloud/android/status.svg)](https://drone.nextcloud.com/nextcloud/android) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/fb4cf26336774ee3a5c9adfe829c41aa)](https://app.codacy.com/gh/nextcloud/android/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [![Releases](https://img.shields.io/github/release/nextcloud/android.svg)](https://github.com/nextcloud/android/releases/latest)
[![REUSE status](https://api.reuse.software/badge/github.com/nextcloud/android)](https://api.reuse.software/info/github.com/nextcloud/android) [![Build Status](https://drone.nextcloud.com/api/badges/nextcloud/android/status.svg)](https://drone.nextcloud.com/nextcloud/android) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/80401cb343854343b4d94acbfb72d3ec)](https://www.codacy.com/app/Nextcloud/android?utm_source=github.com\&utm_medium=referral\&utm_content=nextcloud/android\&utm_campaign=Badge_Grade) [![Releases](https://img.shields.io/github/release/nextcloud/android.svg)](https://github.com/nextcloud/android/releases/latest)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png"
alt="Download from Google Play"
@@ -12,11 +12,8 @@ height="80">](https://play.google.com/store/apps/details?id=com.nextcloud.client
[<img src="https://f-droid.org/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/packages/com.nextcloud.client/)
[<img src="https://github.com/user-attachments/assets/713d71c5-3dec-4ec4-a3f2-8d28d025a9c6"
alt="Get it with Obtainium"
height="80">](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22com.nextcloud.client%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fnextcloud%2Fandroid%22%2C%22author%22%3A%22nextcloud%22%2C%22name%22%3A%22Nextcloud%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22includePrereleases%5C%22%3Afalse%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22filterReleaseNotesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22sortMethodChoice%5C%22%3A%5C%22date%5C%22%2C%5C%22useLatestAssetDateAsReleaseDate%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%2C%5C%22trackOnly%5C%22%3Afalse%2C%5C%22versionExtractionRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22matchGroupToUse%5C%22%3A%5C%22%5C%22%2C%5C%22versionDetection%5C%22%3Atrue%2C%5C%22releaseDateAsVersion%5C%22%3Afalse%2C%5C%22useVersionCodeAsOSVersion%5C%22%3Afalse%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Enextcloud.*%5C%22%2C%5C%22invertAPKFilter%5C%22%3Afalse%2C%5C%22autoApkFilterByArch%5C%22%3Atrue%2C%5C%22appName%5C%22%3A%5C%22%5C%22%2C%5C%22appAuthor%5C%22%3A%5C%22%5C%22%2C%5C%22shizukuPretendToBeGooglePlay%5C%22%3Afalse%2C%5C%22allowInsecure%5C%22%3Afalse%2C%5C%22exemptFromBackgroundUpdates%5C%22%3Afalse%2C%5C%22skipUpdateNotifications%5C%22%3Afalse%2C%5C%22about%5C%22%3A%5C%22Nextcloud%20ist%20eine%20Cloudanwendung%2C%20die%20selbst%20gehostet%20werden%20kann.%5C%22%2C%5C%22refreshBeforeDownload%5C%22%3Atrue%7D%22%2C%22overrideSource%22%3Anull%7D)
Signing certificate fingerprint to [verify](https://developer.android.com/studio/command-line/apksigner#usage-verify) the APK using the official Android documentation.
Signing certificate fingerprint to [verify](https://developer.android.com/studio/command-line/apksigner#usage-verify) the APK:
- APK with "gplay" name, found [here](https://github.com/nextcloud/android/releases) or distributed via Google Play Store
- APK with "nextcloud", found [here](https://github.com/nextcloud/android/releases)
- not suitable for Fdroid downloads, as Fdroid is signing it on their own
@@ -48,7 +45,6 @@ If you want to [contribute](https://nextcloud.com/contribute/) to the Nextcloud
* reporting problems / suggesting enhancements by [opening new issues](https://github.com/nextcloud/android/issues/new/choose)
* implementing proposed bug fixes and enhancement ideas by submitting PRs (associated with a corresponding issue preferably)
* reviewing [pull requests](https://github.com/nextcloud/android/pulls) and providing feedback on code, implementation, and functionality
* Add [automated tests](CONTRIBUTING.md#testing) for existing functionality
* installing and testing [pull request builds](https://github.com/nextcloud/android/pulls), [daily/dev builds](https://github.com/nextcloud/android#development-version-hammer), or [RCs/release candidate builds](https://github.com/nextcloud/android/releases)
* enhancing Admin, User, or Developer [documentation](https://github.com/nextcloud/documentation/)
* hitting hard on the latest stable release by testing fundamental features and evaluating the user experience
+4 -10
View File
@@ -30,19 +30,13 @@ SPDX-FileCopyrightText = "2015-2016 ownCloud Inc."
SPDX-License-Identifier = "GPL-2.0-only"
[[annotations]]
path = ["CLAUDE.md", "app/libs/local-maven/**/*.aar", "app/libs/local-maven/**/*.pom"]
path = ["app/src/**/res/mipmap-**dpi/ic_launcher.png", "app/src/**/ic_launcher-web.png", "src/generic/fastlane/metadata/android/en-US/images/icon.png", "src/versionDev/fastlane/metadata/android/en-US/images/icon.png", "app/src/main/ic_launcher-web-round.png"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2026 Nextcloud GmbH and Nextcloud contributors"
SPDX-License-Identifier = "AGPL-3.0-or-later"
[[annotations]]
path = ["app/src/**/res/mipmap-**dpi/ic_launcher.png", "app/src/**/ic_launcher-web.png", "src/**/fastlane/metadata/en-US/images/*.png", "src/generic/fastlane/metadata/android/en-US/images/icon.png", "src/versionDev/fastlane/metadata/android/en-US/images/icon.png", "app/src/main/ic_launcher-web-round.png"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2017-2025 Nextcloud GmbH <https://nextcloud.com/trademarks/>"
SPDX-FileCopyrightText = "2017-2024 Nextcloud GmbH <https://nextcloud.com/trademarks/>"
SPDX-License-Identifier = "LicenseRef-NextcloudTrademarks"
[[annotations]]
path = [".idea/**", "app/schemas/com.nextcloud.client.database.NextcloudDatabase/**.json", "app/screenshots/generic/debug/**.png", "app/src/main/res/values-**/strings.xml", "src/**/fastlane/metadata/**/*.txt", "src/versionDev/fastlane/metadata/android/**/changelogs/**.txt", "app/src/androidTest/assets/**", "app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker", "app/src/**/google-services.json", "app/src/main/res/drawable-**dpi/checker_16_16.png", "app/src/main/res/raw/encryption_key_words.txt", "app/src/main/resources/ical4j.properties", "app/src/main/res/drawable-**dpi/apk.png", "app/src/main/res/drawable-**dpi/fdroid.png", "app/src/main/res/drawable-**dpi/playstore.png", "app/src/main/res/drawable-**dpi/background.png", "app/src/main/res/drawable-**dpi/background_nc18.png"]
path = [".idea/**", "app/schemas/com.nextcloud.client.database.NextcloudDatabase/**.json", "app/screenshots/gplay/debug/**.png", "app/src/main/res/values-**/strings.xml", "src/**/fastlane/metadata/android/**/**.txt", "src/versionDev/fastlane/metadata/android/**/changelogs/**.txt", "app/src/androidTest/assets/**", "app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker", "app/src/**/google-services.json", "app/src/main/res/drawable-**dpi/checker_16_16.png", "app/src/main/res/raw/encryption_key_words.txt", "app/src/main/resources/ical4j.properties", "app/src/main/res/drawable-**dpi/apk.png", "app/src/main/res/drawable-**dpi/fdroid.png", "app/src/main/res/drawable-**dpi/playstore.png", "app/src/main/res/drawable-**dpi/background.png", "app/src/main/res/drawable-**dpi/background_nc18.png"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2016-2025 Nextcloud GmbH and Nextcloud contributors"
SPDX-FileCopyrightText = "2016-2024 Nextcloud GmbH and Nextcloud contributors"
SPDX-License-Identifier = "AGPL-3.0-or-later"
-120
View File
@@ -1,120 +0,0 @@
<!--
~ SPDX-FileCopyrightText: 2025 Saeed <[email protected]>
~ SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
-->
# تطبيق [Nextcloud](https://nextcloud.com)لأجهزة أندرويد 📱
[![حالة REUSE](https://api.reuse.software/badge/github.com/nextcloud/android)](https://api.reuse.software/info/github.com/nextcloud/android)
[![حالة البناء](https://drone.nextcloud.com/api/badges/nextcloud/android/status.svg)](https://drone.nextcloud.com/nextcloud/android)
[![تقييم Codacy](https://app.codacy.com/project/badge/Grade/fb4cf26336774ee3a5c9adfe829c41aa)](https://app.codacy.com/gh/nextcloud/android/dashboard)
[![الإصدارات](https://img.shields.io/github/release/nextcloud/android.svg)](https://github.com/nextcloud/android/releases/latest)
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" alt="تحميل من Google Play" height="80">](https://play.google.com/store/apps/details?id=com.nextcloud.client)
[<img src="https://f-droid.org/badge/get-it-on.png" alt="احصل عليه من F-Droid" height="80">](https://f-droid.org/packages/com.nextcloud.client/)
## التحقق من توقيع التطبيق 🔐
للتأكد من صحة ملف APK:
- ملف APK باسم "gplay" متوفر [هنا](https://github.com/nextcloud/android/releases) أو عبر متجر Google Play
- ملف APK باسم "nextcloud" متوفر [هنا](https://github.com/nextcloud/android/releases)
- غير مناسب لتحميلات F-Droid، لأن F-Droid يقوم بتوقيعه بنفسه
```plaintext
SHA-256: fb009522f65e25802261b67b10a45fd70e610031976f40b28a649e152ded0373
SHA-1: 74aa1702e714941be481e1f7ce4a8f779c19dcea
```
**تطبيق Nextcloud لأندرويد يتيح لك إدارة بياناتك بسهولة على خادم Nextcloud الخاص بك.**
## الحصول على الدعم 🆘
إذا واجهت مشكلة أو لديك سؤال، يمكنك زيارة [منتدى الدعم](https://help.nextcloud.com/c/clients/android).
إذا اكتشفت خطأ أو لديك اقتراح لتحسين التطبيق، يمكنك [فتح قضية جديدة على GitHub](https://github.com/nextcloud/android/issues).
إذا لم تكن متأكدًا ما إذا كانت المشكلة ناتجة عن التطبيق أو الإعدادات أو الخادم، فابدأ بالسؤال في المنتدى، ثم عد إلى GitHub إذا لزم الأمر.
> ملاحظة: هذا المستودع خاص بتطبيق أندرويد فقط. إذا كانت المشكلة في الخادم، يرجى التواصل مع [فريق خادم Nextcloud](https://github.com/nextcloud/server).
## كيف تساهم في المشروع 🚀
هناك العديد من الطرق للمساهمة، سواء كنت مبرمجًا أو لا:
- مساعدة المستخدمين في المنتدى: https://help.nextcloud.com
- ترجمة التطبيق عبر [Transifex](https://app.transifex.com/nextcloud/nextcloud/android/)
- الإبلاغ عن المشاكل أو تقديم اقتراحات عبر [GitHub Issues](https://github.com/nextcloud/android/issues/new/choose)
- تنفيذ إصلاحات أو تحسينات عبر Pull Requests
- مراجعة [طلبات الدمج](https://github.com/nextcloud/android/pulls)
- اختبار النسخ التجريبية أو اليومية أو المرشحة للإصدار
- تحسين [التوثيق](https://github.com/nextcloud/documentation/)
- اختبار الميزات الأساسية في آخر إصدار مستقر
- تعلم كيفية جمع سجلات الأخطاء (logcat) لتقديم تقارير دقيقة
## إرشادات المساهمة والترخيص 📜
- الترخيص: [GPLv2](https://github.com/nextcloud/android/blob/master/LICENSE.txt)
- جميع المساهمات بعد 16 يونيو 2016 تعتبر مرخصة تحت AGPLv3 أو أي إصدار لاحق
- لا حاجة لتوقيع اتفاقية مساهم (CLA)
- يُفضل إضافة السطر التالي في رأس الملف عند إجراء تغييرات كبيرة:
```plaintext
SPDX-FileCopyrightText: <السنة> <اسمك> <بريدك الإلكتروني>
```
يرجى قراءة [مدونة السلوك](https://nextcloud.com/community/code-of-conduct/) لضمان بيئة تعاون إيجابية.
راجع أيضًا [إرشادات المساهمة](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md).
## ابدأ بالمساهمة 🔧
- اقرأ [SETUP.md](https://github.com/nextcloud/android/blob/master/SETUP.md) و[CONTRIBUTING.md](https://github.com/nextcloud/android/blob/master/CONTRIBUTING.md)
- قم بعمل fork للمستودع وابدأ بإرسال Pull Requests إلى فرع master
- يمكنك البدء بمراجعة [طلبات الدمج](https://github.com/nextcloud/android/pulls) أو العمل على [القضايا المبتدئة](https://github.com/nextcloud/android/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
## جمع سجلات الأخطاء (logcat) 🔍
### على لينكس:
- فعّل USB-Debugging على هاتفك
- افتح الطرفية وأدخل:
```bash
adb logcat --pid=$(adb shell pidof -s 'com.nextcloud.client') > logcatOutput.txt
```
> تأكد من تثبيت [adb](https://developer.android.com/studio/releases/platform-tools.html)
### على ويندوز:
- حمّل [Minimal ADB and Fastboot](https://forum.xda-developers.com/t/tool-minimal-adb-and-fastboot-2-9-18.2317790/#post-42407269)
- فعّل USB-Debugging
- افتح البرنامج وأدخل:
```bash
adb shell pidof -s 'com.nextcloud.client'
```
- استخدم الناتج كـ `<processID>` في الأمر التالي:
```bash
adb logcat --pid=<processID> > "%USERPROFILE%\Downloads\logcatOutput.txt"
```
### على الجهاز (مع صلاحيات root):
```bash
su
logcat -d --pid $(pidof -s com.nextcloud.client) -f /sdcard/logcatOutput.txt
```
أو استخدم تطبيقات مثل [CatLog](https://play.google.com/store/apps/details?id=com.nolanlawson.logcat) أو [aLogcat](https://play.google.com/store/apps/details?id=org.jtb.alogcat)
## النسخة التطويرية 🛠️
- [تحميل مباشر للـ APK](https://download.nextcloud.com/android/dev/latest.apk)
- [F-Droid النسخة التجريبية](https://f-droid.org/en/packages/com.nextcloud.android.beta/)
## المشاكل المعروفة والأسئلة الشائعة
### الإشعارات الفورية لا تعمل في نسخ F-Droid
بسبب اعتمادها على خدمات Google Play، لا تعمل الإشعارات الفورية في نسخ F-Droid حاليًا.
+1 -2
View File
@@ -1,4 +1,3 @@
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
/build
/.cxx
/build
+510
View File
@@ -0,0 +1,510 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
* SPDX-FileCopyrightText: 2024 Tobias Kaminsky <[email protected]>
* SPDX-FileCopyrightText: 2024 Andy Scherzinger <[email protected]>
* SPDX-FileCopyrightText: 2022 Álvaro Brey Vilas <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import org.gradle.internal.jvm.Jvm
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:$androidPluginVersion"
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.27'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.7"
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
classpath 'com.karumi:shot:6.1.0'
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
}
}
plugins {
id "org.jetbrains.kotlin.plugin.compose" version "2.1.0"
id "com.diffplug.spotless" version "6.25.0"
id "org.jetbrains.kotlin.kapt" version "2.1.0"
id 'com.google.devtools.ksp' version '2.1.0-1.0.29' apply false
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply from: "$rootProject.projectDir/jacoco.gradle"
apply plugin: 'com.github.spotbugs'
apply plugin: 'io.gitlab.arturbosch.detekt'
// needed to make renovate run without shot, as shot requires Android SDK
// https://github.com/pedrovgs/Shot/issues/300
if (shotTest) {
apply plugin: 'shot'
}
apply plugin: 'com.google.devtools.ksp'
println "Gradle uses Java ${Jvm.current()}"
configurations {
configureEach {
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
// check for updates every build
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
}
}
}
configurations.configureEach {
resolutionStrategy.eachDependency {
if (requested.group == "org.checkerframework" && requested.name != "checker-compat-qual") {
useVersion(checkerVersion)
because("https://github.com/google/ExoPlayer/issues/10007")
}
}
}
// semantic versioning for version code
def versionMajor = 3
def versionMinor = 30
def versionPatch = 0
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
def ndkEnv = new HashMap<String, String>()
file("$project.rootDir/ndk.env").readLines().each() {
def (key, value) = it.tokenize('=')
ndkEnv.put(key, value)
}
def perfAnalysis = project.hasProperty('perfAnalysis')
android {
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
ndkVersion "${ndkEnv.get("NDK_VERSION")}"
namespace 'com.owncloud.android'
testNamespace "${namespace}.test"
androidResources {
generateLocaleConfig = true
}
defaultConfig {
applicationId "com.nextcloud.client"
minSdkVersion 24
targetSdkVersion 35
compileSdk 35
buildConfigField 'boolean', 'CI', ciBuild.toString()
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
// arguments to be passed to functional tests
if (shotTest) {
testInstrumentationRunner "com.karumi.shot.ShotTestRunner"
} else {
testInstrumentationRunner "com.nextcloud.client.TestRunner"
}
testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
testInstrumentationRunnerArguments disableAnalytics: 'true'
versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
if (versionBuild > 89) {
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
} else if (versionBuild > 50) {
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
} else {
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
}
// adapt structure from Eclipse to Gradle/Android Studio expectations;
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
flavorDimensions += "default"
buildTypes {
debug {
testCoverageEnabled(project.hasProperty('coverage'))
resConfigs "xxxhdpi"
}
}
buildFeatures {
buildConfig = true
}
productFlavors {
// used for f-droid
generic {
applicationId 'com.nextcloud.client'
dimension "default"
}
gplay {
applicationId 'com.nextcloud.client'
dimension "default"
}
huawei {
applicationId 'com.nextcloud.client'
dimension "default"
}
versionDev {
applicationId "com.nextcloud.android.beta"
dimension "default"
versionCode 20220322
versionName "20220322"
}
qa {
applicationId "com.nextcloud.android.qa"
dimension "default"
versionCode 1
versionName "1"
}
}
testOptions {
unitTests.returnDefaultValues = true
animationsDisabled true
}
}
// adapt structure from Eclipse to Gradle/Android Studio expectations;
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
packagingOptions {
resources {
excludes += 'META-INF/LICENSE*'
excludes += 'META-INF/versions/9/OSGI-INF/MANIFEST*'
pickFirst 'MANIFEST.MF' // workaround for duplicated manifest on some dependencies
}
}
tasks.register("checkstyle", Checkstyle) {
configFile = file("${rootProject.projectDir}/checkstyle.xml")
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
source 'src'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
}
tasks.register("pmd", Pmd) {
ruleSetFiles = files("${project.rootDir}/ruleset.xml")
ignoreFailures = true // should continue checking
ruleSets = []
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml {
destination = file("$project.buildDir/reports/pmd/pmd.xml")
}
html {
destination = file("$project.buildDir/reports/pmd/pmd.html")
}
}
}
check.dependsOn 'checkstyle', 'spotbugsGplayDebug', 'pmd', 'lint', 'spotlessKotlinCheck', 'detekt'
buildFeatures {
dataBinding true
viewBinding true
aidl true
compose = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
lint {
abortOnError false
checkGeneratedSources true
disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities', 'GoogleAppIndexingWarning', 'MissingDefaultResource', 'InvalidPeriodicWorkRequestInterval', 'StringFormatInvalid', 'MissingQuantity'
htmlOutput file("$project.buildDir/reports/lint/lint.html")
htmlReport true
}
sourceSets {
// Adds exported schema location as test app assets.
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
kapt {
useBuildCache true
}
}
dependencies {
implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
}
// Jetpack Compose
implementation(platform("androidx.compose:compose-bom:2024.12.01"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.material3:material3")
debugImplementation("androidx.compose.ui:ui-tooling")
implementation("androidx.compose.ui:ui-tooling-preview")
compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
// remove after entire switch to lib v2
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5' // remove after entire switch to lib v2
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.jakewharton:disklrucache:2.0.2'
implementation "androidx.appcompat:appcompat:$appCompatVersion"
implementation 'androidx.webkit:webkit:1.12.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.7'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7"
implementation "androidx.lifecycle:lifecycle-service:2.8.7"
implementation "androidx.work:work-runtime:$workRuntime"
implementation "androidx.work:work-runtime-ktx:$workRuntime"
implementation "androidx.fragment:fragment-ktx:1.8.5"
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
implementation 'commons-io:commons-io:2.18.0'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.12.1'
implementation 'org.lukhnos:nnio:0.3.1'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.79'
implementation 'com.google.code.gson:gson:2.11.0'
implementation 'com.github.nextcloud-deps:sectioned-recyclerview:0.6.1'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.29'
implementation 'com.github.nextcloud-deps:qrcodescanner:0.1.2.4' // 'com.github.blikoon:QRCodeScanner:0.1.2'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation('com.github.bumptech.glide:glide:3.8.0') {
exclude group: "com.android.support"
}
implementation 'com.caverock:androidsvg:1.4'
implementation 'androidx.annotation:annotation:1.9.1'
implementation 'com.vanniktech:emoji-google:0.21.0'
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
// document scanner not available on FDroid (generic) due to OpenCV binaries
gplayImplementation project(':appscan')
huaweiImplementation project(':appscan')
qaImplementation project(':appscan')
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.13.0'
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.6.8'
implementation "com.google.dagger:dagger:$daggerVersion"
implementation "com.google.dagger:dagger-android:$daggerVersion"
implementation "com.google.dagger:dagger-android-support:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
implementation 'org.conscrypt:conscrypt-android:2.5.3'
implementation "androidx.media3:media3-ui:$androidxMediaVersion"
implementation "androidx.media3:media3-session:$androidxMediaVersion"
implementation "androidx.media3:media3-exoplayer:$androidxMediaVersion"
implementation "androidx.media3:media3-datasource-okhttp:$androidxMediaVersion"
implementation 'me.zhanghai.android.fastscroll:library:1.3.0'
// Shimmer animation
implementation 'io.github.elye:loaderviewlibrary:3.0.0'
// dependencies for markdown rendering
implementation "io.noties.markwon:core:$markwonVersion"
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
implementation "io.noties.markwon:ext-tables:$markwonVersion"
implementation "io.noties.markwon:ext-tasklist:$markwonVersion"
implementation "io.noties.markwon:html:$markwonVersion"
implementation "io.noties.markwon:syntax-highlight:$markwonVersion"
implementation "io.noties:prism4j:$prismVersion"
kapt "io.noties:prism4j-bundler:$prismVersion"
// dependencies for image cropping and rotation
implementation 'com.vanniktech:android-image-cropper:4.6.0'
implementation 'org.osmdroid:osmdroid-android:6.1.20'
implementation('org.mnode.ical4j:ical4j:3.0.0') {
['org.apache.commons', 'commons-logging'].each {
exclude group: "$it"
}
}
if (perfAnalysis) {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
}
// dependencies for local unit tests
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "androidx.test:core:$androidxTestVersion"
testImplementation 'org.json:json:20240303'
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation 'androidx.arch.core:core-testing:2.2.0'
testImplementation "io.mockk:mockk:$mockkVersion"
testImplementation "io.mockk:mockk-android:$mockkVersion"
// dependencies for instrumented tests
// JUnit4 Rules
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation "androidx.test:rules:$androidxTestVersion"
// Android JUnit Runner
androidTestImplementation "androidx.test:runner:1.6.2"
androidTestUtil "androidx.test:orchestrator:1.5.1"
androidTestImplementation "androidx.test:core-ktx:$androidxTestVersion"
// Espresso
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
// Mocking support
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
androidTestImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
androidTestImplementation("org.mockito:mockito-android:$mockitoVersion")
androidTestImplementation "io.mockk:mockk-android:$mockkVersion"
androidTestImplementation 'androidx.arch.core:core-testing:2.2.0'
androidTestImplementation "com.facebook.testing.screenshot:core:0.15.0"
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
// androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.github.stateless4j:stateless4j:2.6.0"
// upon each update first test: new registration, receive push
gplayImplementation "com.google.firebase:firebase-messaging:24.1.0"
gplayImplementation 'com.google.android.gms:play-services-base:18.5.0'
gplayImplementation 'com.google.android.play:review-ktx:2.0.2'
implementation 'com.github.nextcloud.android-common:ui:0.24.0'
implementation "androidx.room:room-runtime:$roomVersion"
ksp "androidx.room:room-compiler:$roomVersion"
androidTestImplementation "androidx.room:room-testing:$roomVersion"
implementation "io.coil-kt:coil:2.7.0"
// splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
implementation 'androidx.core:core-splashscreen:1.0.1'
}
configurations.configureEach {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
force 'org.objenesis:objenesis:3.4'
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "$jacoco_version"
}
}
}
}
tasks.withType(Test).configureEach {
// increased logging for tests
testLogging {
events "passed", "skipped", "failed"
}
}
android.applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output -> outputFileName = "${output.baseName}-${variant.versionCode}.apk"
}
}
spotless {
kotlin {
target "**/*.kt"
ktlint()
}
}
detekt {
config.setFrom("detekt.yml")
}
if (shotTest) {
shot {
showOnlyFailingTestsInReports = ciBuild
// CI environment renders some shadows slightly different from local VMs
// Add a 0.5% tolerance to account for that
tolerance = ciBuild ? 0.1 : 0
}
}
jacoco {
toolVersion = "$jacoco_version"
}
spotbugs {
ignoreFailures = true // should continue checking
effort = Effort.MAX
reportLevel = Confidence.valueOf('MEDIUM')
}
tasks.withType(SpotBugsTask){task ->
String variantNameCap = task.name.replace("spotbugs", "")
String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
dependsOn "compile${variantNameCap}Sources"
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/compile${variantNameCap}JavaWithJavac/classes/")
excludeFilter = file("${project.rootDir}/scripts/analysis/spotbugs-filter.xml")
reports {
xml {
required = true
}
html {
required = true
outputLocation = file("$project.buildDir/reports/spotbugs/spotbugs.html")
stylesheet = 'fancy.xsl'
}
}
}
ksp {
arg('room.schemaLocation', "$projectDir/schemas")
}
-550
View File
@@ -1,550 +0,0 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
* SPDX-FileCopyrightText: 2025 Jimly Asshiddiqy <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@file:Suppress("UnstableApiUsage", "DEPRECATION")
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import com.karumi.shot.ShotExtension
import org.gradle.internal.jvm.Jvm
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.FileInputStream
import java.util.Properties
val shotTest = System.getenv("SHOT_TEST") == "true"
val ciBuild = System.getenv("CI") == "true"
val perfAnalysis = project.hasProperty("perfAnalysis")
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.spotless)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.spotbugs)
alias(libs.plugins.detekt)
// needed to make renovate run without shot, as shot requires Android SDK
// https://github.com/pedrovgs/Shot/issues/300
if (System.getenv("SHOT_TEST") == "true") alias(libs.plugins.shot)
id("checkstyle")
id("pmd")
}
apply(from = "${rootProject.projectDir}/jacoco.gradle.kts")
println("Gradle uses Java ${Jvm.current()}")
configurations.configureEach {
// via prism4j, already using annotations explicitly
exclude(group = "org.jetbrains", module = "annotations-java5")
resolutionStrategy {
eachDependency {
when (requested.group) {
"org.checkerframework" if requested.name != "checker-compat-qual" -> {
useVersion(libs.versions.checker.get())
because("https://github.com/google/ExoPlayer/issues/10007")
}
"org.jacoco" -> {
useVersion(libs.versions.jacoco.get())
}
"commons-logging" if requested.name == "commons-logging" -> {
useTarget(libs.slfj)
}
"org.hamcrest" -> {
useVersion("2.2")
because(
"Align hamcrest on compile and runtime. 1.3 (via junit) exposes fixed-arity " +
"anyOf/allOf overloads that 2.2 (via androidx.test) removed, causing NoSuchMethodError."
)
}
}
}
}
}
// semantic versioning for version code
val versionMajor = 35
val versionMinor = 0
val versionPatch = 0
val versionBuild = 50 // 0-50=Alpha / 51-98=RC / 90-99=stable
val ndkEnv = buildMap {
file("${project.rootDir}/ndk.env").readLines().forEach {
val (key, value) = it.split("=")
put(key, value)
}
}
val configProps = Properties().apply {
val file = rootProject.file("gradle.properties")
if (file.exists()) load(FileInputStream(file))
}
val ncTestServerUsername = configProps["NC_TEST_SERVER_USERNAME"]
val ncTestServerPassword = configProps["NC_TEST_SERVER_PASSWORD"]
val ncTestServerBaseUrl = configProps["NC_TEST_SERVER_BASEURL"]
android {
// install this NDK version and CMake to produce smaller APKs. Build will still work if not installed
ndkVersion = "${ndkEnv["NDK_VERSION"]}"
externalNativeBuild {
cmake {
version = "${ndkEnv["CMAKE_VERSION"]}"
path = file("src/main/cpp/CMakeLists.txt")
}
}
namespace = "com.owncloud.android"
testNamespace = "${namespace}.test"
androidResources.generateLocaleConfig = true
defaultConfig {
testInstrumentationRunnerArguments += mapOf(
"TEST_SERVER_URL" to ncTestServerBaseUrl.toString(),
"TEST_SERVER_USERNAME" to ncTestServerUsername.toString(),
"TEST_SERVER_PASSWORD" to ncTestServerPassword.toString(),
"disableAnalytics" to "true"
)
applicationId = "com.nextcloud.client"
minSdk = 28
targetSdk = 36
compileSdk = 37
ndk {
abiFilters += listOf("arm64-v8a", "x86_64")
}
buildConfigField("boolean", "CI", ciBuild.toString())
buildConfigField("boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString())
// arguments to be passed to functional tests
testInstrumentationRunner = if (shotTest) "com.karumi.shot.ShotTestRunner"
else "com.nextcloud.client.TestRunner"
versionCode = versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
versionName = when {
versionBuild > 89 -> "${versionMajor}.${versionMinor}.${versionPatch}"
versionBuild > 50 -> "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
else -> "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
}
// adapt structure from Eclipse to Gradle/Android Studio expectations;
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
flavorDimensions += "default"
buildTypes {
release {
buildConfigField("String", "NC_TEST_SERVER_DATA_STRING", "\"\"")
}
debug {
enableUnitTestCoverage = project.hasProperty("coverage")
enableAndroidTestCoverage = project.hasProperty("coverage")
resConfigs("xxxhdpi")
}
}
productFlavors {
// used for f-droid
register("generic") {
applicationId = "com.nextcloud.client"
dimension = "default"
}
register("gplay") {
applicationId = "com.nextcloud.client"
dimension = "default"
}
register("huawei") {
applicationId = "com.nextcloud.client"
dimension = "default"
}
register("versionDev") {
applicationId = "com.nextcloud.android.beta"
dimension = "default"
versionCode = 20220322
versionName = "20220322"
}
register("qa") {
applicationId = "com.nextcloud.android.qa"
dimension = "default"
versionCode = 1
versionName = "1"
}
}
}
testOptions {
unitTests.isReturnDefaultValues = true
animationsDisabled = true
}
// adapt structure from Eclipse to Gradle/Android Studio expectations;
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
packaging.resources {
excludes.addAll(listOf("META-INF/LICENSE*", "META-INF/versions/9/OSGI-INF/MANIFEST*"))
pickFirsts.add("MANIFEST.MF") // workaround for duplicated manifest on some dependencies
}
buildFeatures {
buildConfig = true
dataBinding = true
viewBinding = true
aidl = true
compose = true
prefab = true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
lint {
abortOnError = true
warningsAsErrors = true
checkGeneratedSources = true
disable.addAll(
listOf(
"MissingTranslation",
"GradleDependency",
"VectorPath",
"IconMissingDensityFolder",
"IconDensities",
"GoogleAppIndexingWarning",
"MissingDefaultResource",
"InvalidPeriodicWorkRequestInterval",
"StringFormatInvalid",
"MissingQuantity",
"IconXmlAndPng",
"SelectedPhotoAccess",
"UnsafeIntentLaunch",
"OldTargetApi",
"AndroidGradlePluginVersion"
)
)
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
htmlReport = true
}
sourceSets {
// Adds exported schema location as test app assets.
getByName("androidTest") {
assets.srcDirs(files("$projectDir/schemas"))
}
}
}
ksp.arg("room.schemaLocation", "$projectDir/schemas")
// Configure KSP for test variants
ksp.arg("dagger.moduleName", project.name)
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
spotless.kotlin {
target("**/*.kt")
ktlint()
}
detekt.config.setFrom("detekt.yml")
if (shotTest) configure<ShotExtension> {
showOnlyFailingTestsInReports = ciBuild
// CI environment renders some shadows slightly different from local VMs
// Add a 0.5% tolerance to account for that
tolerance = if (ciBuild) 0.1 else 0.0
}
spotbugs {
ignoreFailures = true // should continue checking
effort = Effort.MAX
reportLevel = Confidence.valueOf("MEDIUM")
}
tasks.register<Checkstyle>("checkstyle") {
description = "Runs Checkstyle static analysis on the Java sources to enforce the project's coding style."
configFile = file("${rootProject.projectDir}/checkstyle.xml")
setConfigProperties(
"checkstyleSuppressionsPath" to file("${rootProject.rootDir}/suppressions.xml").absolutePath
)
source("src")
include("**/*.java")
exclude("**/gen/**")
classpath = files()
}
tasks.register<Pmd>("pmd") {
description = "Runs PMD static analysis on the Java sources to detect common programming flaws and bad practices."
ruleSetFiles = files("${rootProject.rootDir}/ruleset.xml")
ignoreFailures = true // should continue checking
ruleSets = emptyList()
source("src")
include("**/*.java")
exclude("**/gen/**")
reports {
xml.outputLocation.set(layout.buildDirectory.file("reports/pmd/pmd.xml").get().asFile)
html.outputLocation.set(layout.buildDirectory.file("reports/pmd/pmd.html").get().asFile)
}
}
tasks.withType<SpotBugsTask>().configureEach {
val variantNameCap = name.replace("spotbugs", "")
val variantName = variantNameCap.substring(0, 1).lowercase() + variantNameCap.substring(1)
dependsOn("compile${variantNameCap}Sources")
classes = fileTree(
layout.buildDirectory.get().asFile.toString() +
"/intermediates/javac/${variantName}/compile${variantNameCap}JavaWithJavac/classes/"
)
excludeFilter.set(file("${project.rootDir}/scripts/analysis/spotbugs-filter.xml"))
reports.create("xml") {
required.set(true)
}
reports.create("html") {
required.set(true)
outputLocation.set(layout.buildDirectory.file("reports/spotbugs/spotbugs.html"))
setStylesheet("fancy.xsl")
}
}
// Run the compiler as a separate process
tasks.withType<JavaCompile>().configureEach {
options.isFork = true
// Enable Incremental Compilation
options.isIncremental = true
}
tasks.withType<Test>().configureEach {
// Run tests in parallel
maxParallelForks = maxOf(1, Runtime.getRuntime().availableProcessors().div(2))
// increased logging for tests
testLogging.events("passed", "skipped", "failed")
}
tasks.named("check").configure {
dependsOn("checkstyle", "spotbugsGplayDebug", "pmd", "lint", "spotlessKotlinCheck", "detekt")
}
val kspConfiguration = "ksp"
val kspAndroidTestConfiguration = "kspAndroidTest"
val gplayImplementationConfiguration = "gplayImplementation"
val huaweiImplementationConfiguration = "huaweiImplementation"
val qaImplementationConfiguration = "qaImplementation"
val appScanConfigurations = listOf(
gplayImplementationConfiguration,
huaweiImplementationConfiguration,
qaImplementationConfiguration
)
dependencies {
// region Nextcloud library
implementation(libs.android.library) {
exclude(group = "org.ogce", module = "xpp3") // unused in Android and brings wrong Junit version
}
// endregion
// region Splash Screen
implementation(libs.splashscreen)
// endregion
// region Jetpack Compose
implementation(platform(libs.compose.bom))
implementation(libs.material.icons.core)
implementation(libs.compose.ui)
implementation(libs.compose.ui.graphics)
implementation(libs.compose.material3)
implementation(libs.compose.activity)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.foundation)
debugImplementation(libs.compose.ui.tooling)
// endregion
// region Media3
implementation(libs.bundles.media3)
// endregion
// region Room
implementation(libs.room.runtime)
ksp(libs.room.compiler)
androidTestImplementation(libs.room.testing)
// endregion
// region Espresso
androidTestImplementation(libs.bundles.espresso)
// endregion
// region Glide
implementation(libs.glide)
ksp(libs.ksp)
// endregion
// region UI
implementation(libs.bundles.ui)
implementation(libs.browser)
// endregion
// region Worker
implementation(libs.work.runtime)
implementation(libs.work.runtime.ktx)
// endregion
// region Lifecycle
implementation(libs.lifecycle.viewmodel.ktx)
implementation(libs.lifecycle.service)
implementation(libs.lifecycle.runtime.ktx)
// endregion
// region JUnit
androidTestImplementation(libs.junit)
androidTestImplementation(libs.rules)
androidTestImplementation(libs.runner)
androidTestUtil(libs.orchestrator)
androidTestImplementation(libs.test.core)
androidTestImplementation(libs.core.ktx)
androidTestImplementation(libs.core.testing)
// endregion
testImplementation(libs.kotlinx.coroutines.test)
// region other libraries
compileOnly(libs.org.jbundle.util.osgi.wrapped.org.apache.http.client)
implementation(libs.commons.httpclient.commons.httpclient) // remove after entire switch to lib v2
implementation(libs.jackrabbit.webdav) // remove after entire switch to lib v2
implementation(libs.constraintlayout)
implementation(libs.legacy.support.v4)
implementation(libs.material)
implementation(libs.disklrucache)
implementation(libs.juniversalchardet) // need this version for Android <7
compileOnly(libs.annotations)
implementation(libs.commons.io)
implementation(libs.eventbus)
implementation(libs.ez.vcard)
implementation(libs.nnio)
implementation(libs.bcpkix.jdk18on)
implementation(libs.gson)
implementation(libs.sectioned.recyclerview)
implementation(libs.photoview)
implementation(libs.android.gif.drawable)
implementation(libs.qrcodescanner) // "com.github.blikoon:QRCodeScanner:0.1.2"
implementation(libs.flexbox)
implementation(libs.androidsvg)
implementation(libs.annotation)
implementation(libs.emoji.google)
// endregion
// region AppScan, document scanner not available on FDroid (generic) due to OpenCV binaries
// To enable the feature for another variant, add its "<variant>Implementation" here.
appScanConfigurations.forEach { configuration ->
add(configuration, project(":appscan"))
}
// endregion
// region SpotBugs
spotbugsPlugins(libs.findsecbugs.plugin)
spotbugsPlugins(libs.fb.contrib)
// endregion
// region Dagger
implementation(libs.dagger)
implementation(libs.dagger.android)
implementation(libs.dagger.android.support)
ksp(libs.dagger.processor)
listOf(kspConfiguration, kspAndroidTestConfiguration).forEach { configuration ->
add(configuration, libs.dagger.compiler)
}
// endregion
// region Crypto
implementation(libs.conscrypt.android)
implementation(libs.android.openssl)
// endregion
// region Library
implementation(libs.library)
// endregion
// region Shimmer
implementation(libs.loaderviewlibrary)
// endregion
// region Markdown rendering
implementation(libs.bundles.markdown.rendering)
// endregion
// region Image cropping / rotation
implementation(libs.android.image.cropper)
// endregion
// region Maps
implementation(libs.osmdroid.android)
// endregion
// region iCal4j
implementation(libs.ical4j) {
exclude(group = "commons-logging")
}
// endregion
// region LeakCanary
if (perfAnalysis) debugImplementation(libs.leakcanary)
// endregion
// region Local Unit Test
testImplementation(libs.bundles.unit.test)
// endregion
// region Mocking support
androidTestImplementation(libs.bundles.mocking)
// endregion
// region UIAutomator
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
// androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0"
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
// androidTestImplementation("com.android.support:support-annotations:${supportLibraryVersion}"
androidTestImplementation(libs.screengrab)
// endregion
// region Kotlin
implementation(libs.kotlin.stdlib)
// endregion
// region Stateless
implementation(libs.stateless4j)
// endregion
// region Google Play dependencies, upon each update first test: new registration, receive push
add(gplayImplementationConfiguration, libs.bundles.gplay)
// endregion
// region common
implementation(libs.ui)
implementation(libs.common.core)
// endregion
// region Image loading
implementation(libs.coil)
// endregion
// kotlinx.serialization
implementation(libs.kotlinx.serialization.json)
}
+4 -9
View File
@@ -22,9 +22,8 @@
<issue id="UnusedResources">
<ignore regexp="store_short_desc|store_full_desc|store_short_dev_desc|store_full_dev_desc" />
<ignore
regexp="screenshot_01_gridView|screenshot_02_listView|screenshot_03_drawer|screenshot_04_accounts|screenshot_05_autoUpload|screenshot_06_davdroid" />
<ignore path="**/drawable/zdc_*.xml" />
<ignore path="**/drawable/iconclose.xml" />
regexp="screenshot_01_gridView|screenshot_02_listView|screenshot_03_drawer|screenshot_04_accounts|screenshot_05_autoUpload|screenshot_06_davdroid"/>
<ignore path="**/raw/encryption_key_words.txt" />
</issue>
<issue id="ImpliedQuantity">
@@ -38,8 +37,8 @@
<issue id="UnusedQuantity">
<ignore path="**/values-**/strings.xml" />
</issue>
<issue id="PluralsCandidate">
<issue id="StringFormatCount">
<ignore path="**/values-**/strings.xml" />
</issue>
@@ -85,8 +84,4 @@
<ignore path="**/jetified-firebase-installations**/**/lint.jar" />
<ignore path="**/appcompat-1.**/**/lint.jar" />
</issue>
<issue id="Aligned16KB">
<ignore path="**/arm64-v8a/libmockkjvmtiagent.so" />
</issue>
</lint>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Loaded 100 of 2443 files, more files were not shown because too many files have changed in this diff. Show more