Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99632b39df | ||
|
|
7103b5590a | ||
|
|
06962348ca |
No files matched your search
@@ -1,179 +0,0 @@
|
||||
---
|
||||
name: android-activity-to-navigator-fragment
|
||||
description: >
|
||||
Use when converting a standalone Activity (usually a DrawerActivity or FileActivity
|
||||
subclass such as a drawer destination) into a Fragment hosted by NavigatorActivity, when
|
||||
the user mentions "navigator", "NavigatorActivity", "NavigatorScreen", "convert activity
|
||||
to fragment", "move screen into the new navigation", or names a drawer screen that still
|
||||
has its own Activity. Covers registering the NavigatorScreen, building the fragment and
|
||||
its layout, decoupling collaborators from the old Activity type, rewiring every entry
|
||||
point (drawer, PendingIntents, broadcast receivers, deep links), DI and manifest cleanup,
|
||||
and migrating the instrumented screenshot 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"
|
||||
---
|
||||
|
||||
# Activity → NavigatorActivity Fragment Conversion
|
||||
|
||||
Historically every drawer destination was its own `DrawerActivity` subclass, each with its
|
||||
own toolbar, `DrawerLayout` and back handling. `NavigatorActivity` replaces them with **one
|
||||
host Activity** that owns the toolbar and drawer, and swaps **fragments** for the
|
||||
destinations. Converted so far: Community (#16652), Activities (#16753), Notifications
|
||||
(#16800), Trashbin (#16879), Upload list.
|
||||
|
||||
Read `references/ARCHITECTURE.md` once before the first conversion. It explains how
|
||||
`Navigator`, `NavigatorScreen`, `NavigatorActivity` and `DrawerActivity.pushFragment` work
|
||||
together.
|
||||
|
||||
## The Prime Directive: Behaviour Must Not Change
|
||||
|
||||
The screen must look and behave exactly as before from every entry point: drawer item,
|
||||
notification tap, notification action, deep link, rotation, back press, drawer toggle and
|
||||
menu actions. This is a structural refactor. If you find a bug, report it instead of
|
||||
fixing it in the same change.
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 0: Inventory (do not edit yet)
|
||||
|
||||
1. Read the whole Activity, its layout and its menu.
|
||||
2. `git grep -n "<ActivityName>"` across `app/src`, including `AndroidManifest.xml`,
|
||||
`ComponentsModule.java`, KDoc links, `androidTest` and screenshot file names. Every hit is
|
||||
either an **entry point** you must rewire or a **reference** you must update.
|
||||
3. List what the Activity takes from its **base class**. This is the step most likely to go
|
||||
wrong. `NavigatorActivity` is a `DrawerActivity`, **not** a `FileActivity`. Anything from
|
||||
`FileActivity` (`fileOperationsHelper`, `OperationsService` binding,
|
||||
`onRemoteOperationFinish`, `requestCredentialsUpdate`, `showLoadingDialog`,
|
||||
`connectivityService` field, `backgroundJobManager` field, `EXTRA_FILE`/`EXTRA_USER`
|
||||
handling in `onCreate`) does not exist in the host. See `references/HOST-CAPABILITIES.md`.
|
||||
4. List the intent extras the Activity, or its base class, reads. Each one must keep working
|
||||
when it arrives on the `NavigatorActivity` intent.
|
||||
5. Note any `onActivityResult`, `BroadcastReceiver`, `OnBackPressedCallback`,
|
||||
`onOptionsItemSelected`, `ActionMode` or drawer listeners. Each one needs a fragment
|
||||
equivalent (see `references/ACTIVITY-TO-FRAGMENT-MAPPING.md`).
|
||||
|
||||
If a collaborator needs a capability the host does not have, **stop and ask the
|
||||
developer** whether to (a) move the flow into the fragment and extract the shared pieces
|
||||
into a helper used by both places, or (b) change the host. Option (a) is the default. It
|
||||
was chosen for the upload list's credential check (`CredentialsUpdateHelper`).
|
||||
|
||||
### Step 1: Register the screen in `NavigatorScreen`
|
||||
|
||||
Add the screen in all **five** places in `ui/navigation/NavigatorScreen.kt`. The `when`
|
||||
expressions are exhaustive, so the compiler catches a missing branch, except in `fromTag`:
|
||||
|
||||
1. `@Parcelize object X : NavigatorScreen(X_TAG[, hasDrawer = false])`
|
||||
2. `private const val X_TAG = "X"` in the companion
|
||||
3. `fromTag`: `X_TAG -> X` (**not compiler-checked**; missing it breaks restoring after rotation)
|
||||
4. `menuItemId()`: the drawer item id, or `-1` for screens outside the drawer
|
||||
5. `actionBarStyle()`: `ActionBarStyle.Plain to R.string.<existing title>`
|
||||
6. `toFragment()`: `X -> XFragment()`
|
||||
|
||||
Use `hasDrawer = false` for screens with a back arrow instead of a hamburger (Notifications).
|
||||
|
||||
### Step 2: Fragment layout
|
||||
|
||||
Copy the Activity layout to `fragment_<name>.xml` and strip the shell. The host already
|
||||
provides it:
|
||||
|
||||
- remove the root `DrawerLayout`, the `<include layout="@layout/toolbar_standard"/>` and the
|
||||
`<include layout="@layout/drawer"/>`;
|
||||
- remove `layout_below="@id/appbar"`. The host's `FragmentContainerView` already sits below
|
||||
the app bar;
|
||||
- keep every view id the code or tests use, so the generated binding properties match;
|
||||
- keep the original SPDX copyright lines and add a line for the current year (derived file).
|
||||
|
||||
Delete the old layout once nothing references it.
|
||||
|
||||
### Step 3: Write the fragment
|
||||
|
||||
Follow `references/ACTIVITY-TO-FRAGMENT-MAPPING.md`. The essentials:
|
||||
|
||||
- `class XFragment : Fragment()`, with `@Inject lateinit var` dependencies. Injection is done
|
||||
by `NavigatorActivity.onAttachFragment`, so `Injectable` is optional.
|
||||
- Nullable binding: `private var binding: FragmentXBinding? = null`. Set it to `null` in
|
||||
`onDestroyView`. Use `val binding = binding ?: return` in every function that touches views
|
||||
(#16783 fixed a crash after a configuration change caused by `_binding!!`).
|
||||
- Host access: `getTypedActivity(NavigatorActivity::class.java)` (or `DrawerActivity` /
|
||||
`BaseActivity` when that is all you need) for `user`, `storageManager`, `clientRepository`,
|
||||
`setUser`, `setDrawerIndicatorEnabled`, `startActionMode`.
|
||||
- Menu: `requireActivity().addMenuProvider(provider, viewLifecycleOwner, Lifecycle.State.RESUMED)`.
|
||||
Do **not** handle `android.R.id.home`. The host does that.
|
||||
- Back press: implement `NavigatorOnBackPressListener` only if the screen has internal
|
||||
navigation (Trashbin folders).
|
||||
- Remove `getMenuItemId()`, `setupDrawer()`, `setupToolbar()`, `highlightNavigationViewItem()`
|
||||
and title setup. `NavigatorScreen` + `NavigatorActivity.setupActionBar` handle all of these.
|
||||
- Keep files under 300 lines. Extract cohesive flows (conflict handling, credential checks,
|
||||
the menu provider) into their own classes in the fragment's package.
|
||||
|
||||
### Step 4: Decouple collaborators from the old Activity
|
||||
|
||||
Adapters, helpers and listeners typed as `XActivity` or `FileActivity` must take the
|
||||
narrowest type that has what they use. Usually that is `DrawerActivity`, `BaseActivity`,
|
||||
`NavigatorActivity` or a plain `Context`. Calls to capabilities the host lacks become
|
||||
callbacks on the click or listener interface, implemented by the fragment
|
||||
(e.g. `UploadListItemOnClick.onCredentialErrorClick(user)`).
|
||||
|
||||
### Step 5: Rewire every entry point
|
||||
|
||||
**Always** build the intent with `NavigatorActivity.intent(context, NavigatorScreen.X)`.
|
||||
`NavigatorActivity.onCreate` calls `requireNotNull` on the screen extra, so a bare
|
||||
`Intent(context, NavigatorActivity::class.java)` crashes (#17193).
|
||||
|
||||
| Old call site | New call site |
|
||||
|---|---|
|
||||
| `DrawerActivity.onNavigationItemClicked`: `startActivity(X.class, FLAG_ACTIVITY_CLEAR_TOP)` | `pushFragment(NavigatorScreen.X.INSTANCE)` |
|
||||
| Buttons in other DrawerActivities: `startActivity(X::class.java)` | `pushFragment(NavigatorScreen.X)` |
|
||||
| `handleDeepLink`: `startActivity(X.class)` | `pushFragment(NavigatorScreen.X.INSTANCE)` |
|
||||
| `PendingIntent` / `BroadcastReceiver` / Worker: `Intent(context, X::class.java)` | `NavigatorActivity.intent(context, NavigatorScreen.X).apply { flags = … }` |
|
||||
| `X.createIntent(...)` factory | inline `NavigatorActivity.intent(...)` + only the extras the fragment reads |
|
||||
|
||||
Keep the original flags (`FLAG_ACTIVITY_NEW_TASK`, `FLAG_ACTIVITY_CLEAR_TOP`, …). Extras the
|
||||
old base class consumed (e.g. `FileActivity.EXTRA_USER` → `setUser`) must now be read by the
|
||||
fragment from `activity?.intent`, once, when `savedInstanceState == null`.
|
||||
|
||||
### Step 6: DI, manifest, cleanup
|
||||
|
||||
- `ComponentsModule.java`: remove `abstract XActivity xActivity();` and add
|
||||
`@ContributesAndroidInjector abstract XFragment xFragment();`. Without this, injection
|
||||
fails at runtime.
|
||||
- `AndroidManifest.xml`: remove the `<activity>` entry.
|
||||
- Delete the Activity, update KDoc/Javadoc `[link]`s that pointed at it, and remove now-unused
|
||||
imports in files you edited.
|
||||
|
||||
### Step 7: Migrate the instrumented test
|
||||
|
||||
Rename `XActivityIT` to `XFragmentIT` and launch through the host:
|
||||
|
||||
```kotlin
|
||||
val intent = NavigatorActivity.intent(targetContext, NavigatorScreen.X)
|
||||
ActivityScenario.launch<NavigatorActivity>(intent).use { scenario -> … }
|
||||
```
|
||||
|
||||
To call into the fragment, find it with `sut.supportFragmentManager.fragments.filterIsInstance<XFragment>()`
|
||||
(see `TrashbinFragmentIT.launchFragment`). **Rename the reference screenshots with `git mv`**
|
||||
(`app/screenshots/generic/debug/<pkg>.XActivityIT_*.png` → `XFragmentIT_*.png`) so the
|
||||
screenshot test compares against the existing images instead of failing.
|
||||
|
||||
### Step 8: Verify
|
||||
|
||||
1. `./gradlew :app:compileGplayDebugKotlin :app:compileGplayDebugJavaWithJavac :app:compileGplayDebugAndroidTestKotlin`
|
||||
2. `./gradlew spotlessKotlinCheck detekt lintGplayDebug spotbugsGplayDebug`, then fix findings
|
||||
in every file you touched.
|
||||
3. `git grep -n "<ActivityName>\|<old_layout_name>"` returns nothing.
|
||||
4. Manual checklist (hand it to the developer if you cannot run the app): open from the
|
||||
drawer, from every notification or PendingIntent, from the deep link; rotate on the
|
||||
screen; switch to another drawer destination and press back; toggle the drawer with the
|
||||
hamburger; use every menu action; check light and dark themes.
|
||||
|
||||
## References
|
||||
|
||||
- `references/ARCHITECTURE.md`: how the navigator works.
|
||||
- `references/ACTIVITY-TO-FRAGMENT-MAPPING.md`: Activity API → fragment equivalent.
|
||||
- `references/HOST-CAPABILITIES.md`: what `NavigatorActivity` provides and what it does not.
|
||||
- `references/PITFALLS.md`: bugs that the earlier conversions ran into.
|
||||
- `assets/worked-example.md`: the upload list conversion, step by step.
|
||||
@@ -1,81 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Worked Example: `UploadListActivity` → `UploadListFragment`
|
||||
|
||||
This conversion was the hardest one so far, because the Activity extended `FileActivity`.
|
||||
|
||||
## Inventory findings
|
||||
|
||||
- Base class `FileActivity`. The adapter called `activity.fileOperationsHelper.checkCurrentCredentials(user)`
|
||||
for uploads that failed with `CREDENTIAL_ERROR`. The result came back through
|
||||
`onRemoteOperationFinish` → `requestCredentialsUpdate` → `CheckRemoteWipeTask` →
|
||||
`performCredentialsUpdate` → `startActivityForResult(AuthenticatorActivity)` →
|
||||
`onActivityResult` → `FilesSyncHelper.restartUploadsIfNeeded`.
|
||||
- Entry points: drawer `nav_uploads`, `FileUploaderIntents.openUploadListIntent` (upload
|
||||
notifications, with `EXTRA_USER`), `AppWideNotificationManager.getUploadListPendingIntent`,
|
||||
`SyncConflictNotificationBroadcastReceiver`.
|
||||
- `EXTRA_USER` was consumed by `FileActivity.onCreate` → `setUser`. `EXTRA_FILE` was
|
||||
ignored (the Activity set `file = null`).
|
||||
- Menu: global pause/resume toggle. A `LocalBroadcastManager` receiver for upload events.
|
||||
`UploadWarningCard` registered in `onCreate` and unregistered in `onDestroy`.
|
||||
|
||||
## Decisions
|
||||
|
||||
- Host stays a `DrawerActivity`. The credential flow moves into the
|
||||
fragment.
|
||||
- To avoid copying `FileActivity` logic, `ui/helpers/CredentialsUpdateHelper.kt` was
|
||||
extracted. `FileActivity.performCredentialsUpdate`, `CheckRemoteWipeTask` and the fragment
|
||||
all use it.
|
||||
|
||||
## Resulting files
|
||||
|
||||
| File | Role |
|
||||
|---|---|
|
||||
| `ui/fragment/uploadList/UploadListFragment.kt` | lifecycle, list setup, receiver, warning card, `EXTRA_USER` |
|
||||
| `ui/fragment/uploadList/UploadListMenuProvider.kt` | global pause toggle |
|
||||
| `ui/fragment/uploadList/UploadListConflictHandler.kt` | sync-conflict check and retry |
|
||||
| `ui/fragment/uploadList/UploadListCredentialsHandler.kt` | check credentials → remote wipe → re-login |
|
||||
| `ui/helpers/CredentialsUpdateHelper.kt` | credential steps shared with `FileActivity` |
|
||||
| `res/layout/fragment_upload_list.xml` | old layout without `DrawerLayout`/toolbar/drawer |
|
||||
|
||||
## Collaborator changes
|
||||
|
||||
- `UploadListAdapter(activity: FileActivity)` → `DrawerActivity`.
|
||||
`fileOperationsHelper.checkCurrentCredentials(user)` → `itemOnClick.onCredentialErrorClick(user)`.
|
||||
- `UploadListAdapterHelper(activity: FileActivity)` → `DrawerActivity`;
|
||||
`activity.accountManager` → `activity.userAccountManager`.
|
||||
- `UploadListItemOnClick` gained `onCredentialErrorClick(user: User)`.
|
||||
|
||||
## Entry point changes
|
||||
|
||||
```kotlin
|
||||
// FileUploaderIntents
|
||||
val intent = NavigatorActivity.intent(context, NavigatorScreen.UploadList).apply {
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
putExtra(FileActivity.EXTRA_USER, operation?.user)
|
||||
}
|
||||
|
||||
// AppWideNotificationManager, SyncConflictNotificationBroadcastReceiver
|
||||
val intent = NavigatorActivity.intent(context, NavigatorScreen.UploadList).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
```
|
||||
|
||||
```java
|
||||
// DrawerActivity.onNavigationItemClicked
|
||||
} else if (itemId == R.id.nav_uploads) {
|
||||
resetOnlyPersonalAndOnDevice();
|
||||
pushFragment(NavigatorScreen.UploadList.INSTANCE);
|
||||
```
|
||||
|
||||
## Cleanup
|
||||
|
||||
- `ComponentsModule`: `uploadListActivity()` removed, `uploadListFragment()` added.
|
||||
- Manifest entry removed. `UploadListActivity.kt` and `upload_list_layout.xml` deleted.
|
||||
- `FileUploadEventBroadcaster` KDoc links updated.
|
||||
- `UploadListActivityActivityIT` → `UploadListFragmentIT`, with screenshots `git mv`'d.
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Activity API → Navigator Fragment Equivalent
|
||||
|
||||
| In the Activity | In the fragment |
|
||||
|---|---|
|
||||
| `class X : DrawerActivity()` / `FileActivity()` | `class XFragment : Fragment()` |
|
||||
| `onCreate`: `setContentView(binding.root)` | `onCreateView`: `binding = FragmentXBinding.inflate(inflater, container, false)` |
|
||||
| View setup in `onCreate` | `onViewCreated` |
|
||||
| Non-view setup in `onCreate` (intent extras, config) | `onCreate` (guard extras with `savedInstanceState == null`) |
|
||||
| `onDestroy` cleanup tied to views/receivers registered in `onCreate` | `onDestroyView` |
|
||||
| `onStart`/`onStop`/`onResume` | same callbacks on the fragment |
|
||||
| `setupToolbar()`, `updateActionBarTitleAndHomeButtonByString`, `setupDrawer(menuItemId)` | delete; `NavigatorScreen.actionBarStyle()` + host |
|
||||
| `getMenuItemId()`, `highlightNavigationViewItem()` | delete; `NavigatorScreen.menuItemId()` + host |
|
||||
| `onCreateOptionsMenu` / `onOptionsItemSelected` | `MenuProvider` added with `viewLifecycleOwner, Lifecycle.State.RESUMED`; return `false` for ids you do not own |
|
||||
| `android.R.id.home` → toggle drawer | delete; the host handles it |
|
||||
| `OnBackPressedCallback` for internal navigation | `NavigatorOnBackPressListener` |
|
||||
| `mDrawerToggle.isDrawerIndicatorEnabled = x` | `navigatorActivity?.setDrawerIndicatorEnabled(x)` |
|
||||
| `addDrawerListener(l)` | `activity?.findViewById<DrawerLayout>(R.id.drawer_layout)?.addDrawerListener(l)` |
|
||||
| `startActionMode(cb)` | `navigatorActivity?.startActionMode(cb)` |
|
||||
| `findViewById(R.id.sort_button)` (toolbar views) | `activity?.findViewById(...)`; the toolbar belongs to the host |
|
||||
| `supportFragmentManager` for dialogs | `childFragmentManager`, or `requireActivity().supportFragmentManager` when the dialog calls back into the activity |
|
||||
| `this` as `Context` | `requireContext()` (inside callbacks: capture before launching) |
|
||||
| `this` as `Activity` (snackbars, PopupMenu, adapters) | `requireActivity()` / typed host |
|
||||
| `lifecycleScope` | `lifecycleScope` (fragment lifetime; survives while on back stack) or `viewLifecycleOwner.lifecycleScope` (view work only) |
|
||||
| `user`, `storageManager`, `clientRepository`, `capabilities` | `navigatorActivity?.user`, `.storageManager`, `.clientRepository`, `.capabilities` |
|
||||
| `setUser(user)` | `navigatorActivity?.setUser(user)` (`BaseActivity.setUser` is public) |
|
||||
| `startActivityForResult` + `onActivityResult` | `registerForActivityResult(StartActivityForResult())` as a fragment property |
|
||||
| `finish()` | `activity?.finish()` |
|
||||
| `DisplayUtils.showSnackMessage(this, …)` | `DisplayUtils.showSnackMessage(requireView(), …)` / `SnackbarUtil.show(this, …)` |
|
||||
| inner `BroadcastReceiver` class | `private val receiver = object : BroadcastReceiver() { … }`, avoids an extra type in the file |
|
||||
| `@Inject var x: T? = null` with `@JvmField` | `@Inject lateinit var x: T` |
|
||||
| Activity fields inherited from the base (`viewThemeUtils`, `preferences`, `connectivityService`, `accountManager`, `backgroundJobManager`) | `@Inject lateinit var` them in the fragment |
|
||||
|
||||
## Dialog listener lookups
|
||||
|
||||
Dialogs that cast `activity as Listener` break when the listener is now a fragment.
|
||||
Trashbin fixed `SortingOrderDialogFragment` with this fallback chain:
|
||||
|
||||
```kotlin
|
||||
val listener = parentFragment as? OnSortingOrderListener
|
||||
?: activity as? OnSortingOrderListener
|
||||
?: requireActivity().supportFragmentManager.fragments
|
||||
.firstOrNull { it is OnSortingOrderListener } as? OnSortingOrderListener
|
||||
```
|
||||
|
||||
Check every dialog the screen opens for the same pattern.
|
||||
@@ -1,89 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Navigator Architecture
|
||||
|
||||
All classes live in `app/src/main/java/com/owncloud/android/ui/navigation/`.
|
||||
|
||||
```
|
||||
NavigatorActivity (DrawerActivity) activity_navigator.xml
|
||||
├─ toolbar_standard (appbar) DrawerLayout
|
||||
├─ FragmentContainerView ◄── Navigator ──► ├─ CoordinatorLayout
|
||||
└─ drawer │ ├─ appbar
|
||||
│ └─ fragment_container_view
|
||||
└─ drawer
|
||||
```
|
||||
|
||||
## `NavigatorScreen`: the destination registry
|
||||
|
||||
A `sealed class NavigatorScreen(val tag: String, val hasDrawer: Boolean = true) : Parcelable`.
|
||||
Each destination is a `@Parcelize object`, so it can travel in an `Intent` extra and is
|
||||
compared by identity in `when`.
|
||||
|
||||
| Member | Purpose |
|
||||
|---|---|
|
||||
| `tag` | Used as the fragment back-stack entry name. Must be unique |
|
||||
| `hasDrawer` | `true`: hamburger + unlocked drawer. `false`: back arrow + `LOCK_MODE_LOCKED_CLOSED` |
|
||||
| `fromTag(tag)` | Turns a back-stack entry name back into a screen. Used after configuration changes |
|
||||
| `menuItemId()` | Drawer item to highlight (`-1` for none) |
|
||||
| `actionBarStyle()` | `ActionBarStyle.Plain` → `setupToolbar()`, `Search` → `setupHomeSearchToolbarWithSortAndListButtons()`, plus title res |
|
||||
| `toFragment()` | Creates a fresh fragment instance |
|
||||
|
||||
## `Navigator`: the fragment stack
|
||||
|
||||
- `push(screen)`: ignores the call if a fragment with that tag already exists. Otherwise it
|
||||
does `replace(container, screen.toFragment())` + `addToBackStack(screen.tag)`.
|
||||
- `pop()`: `popBackStack()` and returns the new top screen.
|
||||
- `getTopScreen()`: reads the name of the last back-stack entry and maps it with `fromTag`.
|
||||
This keeps working after process death or rotation, because the `FragmentManager`
|
||||
restores the back stack. The in-memory `stack` does not survive that.
|
||||
|
||||
## `NavigatorActivity`: the host
|
||||
|
||||
- `onCreate`: inflates `ActivityNavigatorBinding`, then `requireNotNull`s the
|
||||
`EXTRA_SCREEN` extra. It either `push`es the screen (first launch) or restores the action
|
||||
bar from `getTopScreen()` (re-creation).
|
||||
- `onAttachFragment`: `AndroidSupportInjection.inject(fragment)` for **every** attached
|
||||
fragment. This is why converted fragments need a `@ContributesAndroidInjector` entry in
|
||||
`ComponentsModule`, even when they do not implement `Injectable`.
|
||||
- `setupActionBar(screen)`: toolbar style, title, drawer or back arrow, drawer lock mode.
|
||||
Called on every `push`/`pop`.
|
||||
- Back press (`OnBackPressedCallback`): close the drawer → let the top
|
||||
`NavigatorOnBackPressListener` intercept → `finish()` if only one entry is left → `pop()`.
|
||||
- Home button (`onOptionsItemSelected(android.R.id.home)`): listener intercept → back if
|
||||
`!hasDrawer` → toggle the drawer otherwise.
|
||||
- `getMenuItemId()` / `onResume`: highlight the drawer item of the top screen.
|
||||
- `NavigatorActivity.intent(context, screen)`: the **only** correct way to build a launch
|
||||
intent.
|
||||
|
||||
## `DrawerActivity.pushFragment(screen)`
|
||||
|
||||
```java
|
||||
public void pushFragment(NavigatorScreen screen) {
|
||||
if (this instanceof NavigatorActivity navigatorActivity) {
|
||||
navigatorActivity.push(screen); // already in the navigator: swap fragment
|
||||
} else {
|
||||
startActivity(NavigatorActivity.Companion.intent(this, screen)); // e.g. from FileDisplayActivity
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Drawer item clicks call this, so moving between converted screens swaps fragments
|
||||
inside a single `NavigatorActivity` instead of starting a new Activity each time.
|
||||
|
||||
## `NavigatorOnBackPressListener`
|
||||
|
||||
```kotlin
|
||||
interface NavigatorOnBackPressListener {
|
||||
fun canInterceptBackPress(): Boolean
|
||||
fun interceptBackPress()
|
||||
}
|
||||
```
|
||||
|
||||
Implement it in a fragment that has its own navigation inside the screen. For example,
|
||||
`TrashbinFragment` goes up one folder while `trashbinPresenter.isRoot == false`. The host
|
||||
checks it for both the system back gesture and the toolbar home button.
|
||||
@@ -1,44 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# What `NavigatorActivity` Provides
|
||||
|
||||
`NavigatorActivity` extends `DrawerActivity → ToolbarActivity → BaseActivity`. It does
|
||||
**not** extend `FileActivity`. Decided to keep it that way: making every
|
||||
navigator screen a `FileActivity` would bind `OperationsService` for all of them and show
|
||||
`FileActivity`'s offline info box on screens that never had one.
|
||||
|
||||
## Available from the host
|
||||
|
||||
- `BaseActivity`: `user`, `setUser(user)`, `capabilities`, `storageManager`,
|
||||
`clientRepository`, `userAccountManager`, `account`.
|
||||
- `ToolbarActivity`: toolbar setup, `showInfoBox`/`hideInfoBox` (only called by
|
||||
`FileActivity`), sort and grid toolbar buttons (`R.id.sort_button`,
|
||||
`R.id.switch_grid_view_button`).
|
||||
- `DrawerActivity`: `appPreferences`, `openDrawer`/`closeDrawer`/`isDrawerOpen`,
|
||||
`setDrawerIndicatorEnabled`, `pushFragment`, `fetchExternalLinks`.
|
||||
|
||||
## Not available: `FileActivity`-only features
|
||||
|
||||
| `FileActivity` feature | How to replace it in a fragment |
|
||||
|---|---|
|
||||
| `fileOperationsHelper.*` (queues operations on `OperationsService`) | Run the `RemoteOperation`/`SyncOperation` directly in `lifecycleScope` on `Dispatchers.IO` with a client for the right user |
|
||||
| `onRemoteOperationFinish(op, result)` override | Handle the result inline after the coroutine returns |
|
||||
| `requestCredentialsUpdate(account)` → `CheckRemoteWipeTask` → `performCredentialsUpdate` | `CredentialsUpdateHelper` (`isRemoteWipeRequested`, `invalidateCredentials`, `createUpdateCredentialsIntent`) + `registerForActivityResult` |
|
||||
| `onActivityResult(REQUEST_CODE__UPDATE_CREDENTIALS, RESULT_OK)` | the `ActivityResultLauncher` callback |
|
||||
| `showLoadingDialog` / `dismissLoadingDialog` | `LoadingDialog.newInstance(msg).show(childFragmentManager, TAG)` and `dismissAllowingStateLoss()` |
|
||||
| `EXTRA_USER` → `setUser` in `onCreate` | fragment reads `activity?.intent` and calls `navigatorActivity?.setUser` |
|
||||
| `EXTRA_FILE` → `file` | read it in the fragment if it is used, otherwise drop it from the callers |
|
||||
| `connectivityService`, `backgroundJobManager`, `accountManager` fields | `@Inject lateinit var` in the fragment |
|
||||
|
||||
## De-duplication rule
|
||||
|
||||
When a fragment needs logic that a base Activity implements privately, **do not copy it**.
|
||||
Extract the reusable steps into a Kotlin helper (e.g. `ui/helpers/CredentialsUpdateHelper.kt`).
|
||||
Have the original Activity code call the helper too, so there is one implementation.
|
||||
Only the orchestration specific to the fragment (coroutines, result launcher, dialog) should
|
||||
live in the fragment's package.
|
||||
@@ -1,71 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Pitfalls Found in Earlier Conversions
|
||||
|
||||
## Bare intents crash the host (#17193)
|
||||
|
||||
`NotificationWork` was changed to `Intent(context, NavigatorActivity::class.java)` without
|
||||
a screen. `NavigatorActivity.onCreate` calls `requireNotNull` on `EXTRA_SCREEN`, so tapping
|
||||
the notification crashed. Always use `NavigatorActivity.intent(context, NavigatorScreen.X)`.
|
||||
Check **every** `PendingIntent`, `BroadcastReceiver`, Worker and notification manager that
|
||||
referenced the old Activity.
|
||||
|
||||
## `binding!!` after a configuration change (#16783)
|
||||
|
||||
The `_binding!!` / `val binding get() = _binding!!` pattern crashed when a callback
|
||||
(presenter, coroutine, receiver) fired after `onDestroyView`. Use a nullable
|
||||
`private var binding` and `val binding = binding ?: return` in each function.
|
||||
|
||||
## Screen not restored after rotation (#16783)
|
||||
|
||||
`NavigatorActivity` only re-applies the action bar and drawer highlight if
|
||||
`NavigatorScreen.fromTag` knows the tag. `fromTag` is not an exhaustive `when` over the
|
||||
sealed class, so the compiler does not catch a missing entry.
|
||||
|
||||
## Dependency injection
|
||||
|
||||
`NavigatorActivity.onAttachFragment` injects every fragment. That only works if
|
||||
`ComponentsModule` has a `@ContributesAndroidInjector abstract XFragment xFragment();`.
|
||||
Without it you get an `IllegalArgumentException: No injector factory bound` at runtime, not at
|
||||
compile time. `addFragmentOnAttachListener` / lifecycle callbacks did not behave the same,
|
||||
which is why the deprecated `onAttachFragment` is used.
|
||||
|
||||
## Toolbar views belong to the host
|
||||
|
||||
Sort and grid buttons, the info box and the search bar live in the host's `toolbar_standard`.
|
||||
Reach them with `activity?.findViewById`. Set their visibility explicitly, because the
|
||||
previous screen may have changed it.
|
||||
|
||||
## Dialog callbacks
|
||||
|
||||
Dialogs that do `activity as Listener` silently stop working when the listener is now a
|
||||
fragment (see the `SortingOrderDialogFragment` fix in `ACTIVITY-TO-FRAGMENT-MAPPING.md`).
|
||||
|
||||
## Lifecycle scope choice
|
||||
|
||||
Long-running work started by the user (retrying an upload, executing an action) should use
|
||||
the fragment's `lifecycleScope`. That keeps it running while the fragment sits on the back
|
||||
stack with its view destroyed. Only pure view work should use
|
||||
`viewLifecycleOwner.lifecycleScope`. Always null-check the binding when the work returns.
|
||||
|
||||
## Receivers and registrations
|
||||
|
||||
Anything registered in the Activity's `onCreate` and released in `onDestroy` (e.g.
|
||||
`UploadWarningCard.register/unregister`) must move to `onViewCreated`/`onDestroyView`.
|
||||
Otherwise it leaks across back-stack transitions or registers twice.
|
||||
|
||||
## Screenshot tests
|
||||
|
||||
Renaming `XActivityIT` → `XFragmentIT` changes the screenshot names. `git mv` the PNGs in
|
||||
`app/screenshots/generic/debug/` to match, or CI reports missing references.
|
||||
|
||||
## File size and type rules
|
||||
|
||||
`AGENTS.md` caps files at 300 lines and wants one type per file. Activities converted to
|
||||
fragments often exceed 300 lines. Split cohesive flows (menu provider, conflict handler,
|
||||
credentials handler) into separate classes in the fragment's package.
|
||||
@@ -1,135 +0,0 @@
|
||||
---
|
||||
name: android-eventbus-to-workmanager-flow
|
||||
description: >
|
||||
Use when replacing a GreenRobot EventBus event that a WorkManager worker posts (progress,
|
||||
state, completion) with WorkManager's own observation APIs, consumed through a ViewModel
|
||||
Flow; when the user mentions "event bus", "EventBus", "EventBusFactory", "@Subscribe",
|
||||
"worker progress", "setProgress", "observe worker", "getWorkInfosForUniqueWorkFlow" or
|
||||
"listen to the worker through the viewmodel". Covers publishing progress from the worker,
|
||||
building the ViewModel Flow keyed by the work name, DI registration, collecting the Flow
|
||||
from Kotlin or legacy Java fragments/activities, and deleting the event classes.
|
||||
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"
|
||||
---
|
||||
|
||||
# EventBus → WorkManager Flow via ViewModel
|
||||
|
||||
Workers used to tell the UI what they were doing by posting GreenRobot EventBus events
|
||||
(`EventBusFactory.downloadProgressEventBus.post(FileDownloadProgressEvent(percent))`). That
|
||||
has three problems: the event is global (every subscriber gets every worker's events,
|
||||
whatever file it is about), it is lost when nobody is registered, and the subscriber has to
|
||||
register and unregister by hand in `onStart`/`onStop`.
|
||||
|
||||
WorkManager already stores each worker's state and progress and exposes them as `Flow`s. The
|
||||
UI asks WorkManager about **one specific piece of work**, through a ViewModel, and collects
|
||||
the Flow with the lifecycle. Official guide:
|
||||
https://developer.android.com/develop/background-work/background-tasks/persistent/how-to/observe
|
||||
|
||||
Converted so far: `FileDownloadProgressEvent` → `FileDetailFragmentViewModel.downloadProgress`
|
||||
(see `assets/worked-example.md`). The earlier `FileDisplayActivityViewModel.observeOfflineWorker`
|
||||
is the simplest form of the same pattern (state only, Kotlin consumer).
|
||||
|
||||
## The Prime Directive: Behaviour Must Not Change
|
||||
|
||||
The screen must show the same thing at the same moments as before. The only intended
|
||||
differences are the ones the global bus got wrong: a screen now only reacts to the work it is
|
||||
about. Write them down for the PR description. If you find an unrelated bug, report it
|
||||
instead of fixing it in the same change.
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 0: Inventory (do not edit yet)
|
||||
|
||||
1. `git grep -n "<EventName>"` across `app/src`. List every **poster** (usually a worker) and
|
||||
every **subscriber** (`@Subscribe fun on…(event: <EventName>)`).
|
||||
2. If the event lives on a dedicated bus (`EventBusFactory.<x>EventBus`), also grep for the
|
||||
bus. When it has no other users, delete it together with the event.
|
||||
3. For each poster, find how its work is enqueued in `BackgroundJobManagerImpl`: the
|
||||
**unique work name** (`enqueueUniqueWork(name, …)`) and the **tags** (`oneTimeRequestBuilder`
|
||||
adds `formatNameTag`, `formatClassTag`, `formatUserTag`, plus any custom tag). The UI
|
||||
must be able to rebuild exactly one of these from what it already knows (user, file id…).
|
||||
4. List what each event field carries and what the subscriber does with it. Decide whether
|
||||
it is **progress** (while running → `setProgress`), a **result** (at the end →
|
||||
`Result.success(outputData)`), or only **state** (`WorkInfo.state`, nothing to publish).
|
||||
5. Look for older parallel mechanisms the subscriber also uses for the same purpose (bound
|
||||
listeners, `LocalBroadcastManager`). If you can prove one is dead (e.g. a field that is
|
||||
only ever set to `null`), remove it with all its plumbing, including test doubles in
|
||||
`app/src/debug` and mocks in `androidTest`. Otherwise leave it and mention it in the summary.
|
||||
|
||||
### Step 1: Make the work addressable
|
||||
|
||||
If the unique work name / tag builder is `private` in `BackgroundJobManagerImpl`, move it
|
||||
into the `companion object` next to `formatNameTag`/`formatClassTag` as a public
|
||||
`format…Tag(...)` function, and have the enqueue and cancel call sites use it. The UI and
|
||||
the scheduler must build the name with the same function, never with a copied string.
|
||||
|
||||
### Step 2: Publish from the worker
|
||||
|
||||
- Add the `Data` key as a `const val` in the worker's `companion object`
|
||||
(`const val PROGRESS_PERCENT = "PROGRESS_PERCENT"`).
|
||||
- From a `suspend` context call `setProgress(workDataOf(KEY to value))`. From a non-suspend
|
||||
callback (e.g. `OnDatatransferProgressListener.onTransferProgress`) call
|
||||
`setProgressAsync(...)`.
|
||||
- **Throttle it.** WorkManager writes progress to its database. Publish only when the value
|
||||
changed, and reuse an existing throttle (the notification update interval) when the
|
||||
worker has one.
|
||||
- Results go in `Result.success(workDataOf(...))` and are read from `WorkInfo.outputData`.
|
||||
- Delete the `post(...)` call and the event imports.
|
||||
|
||||
### Step 3: ViewModel
|
||||
|
||||
One ViewModel per screen, in a package next to the screen
|
||||
(`ui/fragment/<screen>/<Screen>FragmentViewModel.kt`, mirroring
|
||||
`ui/activity/filedisplayactivity/FileDisplayActivityViewModel.kt`). Template:
|
||||
`references/VIEWMODEL-TEMPLATE.md`.
|
||||
|
||||
- Constructor-inject `WorkManager` (`@Inject constructor(private val workManager: WorkManager)`).
|
||||
- Hold the work name the screen is interested in a `MutableStateFlow<String?>`. A setter
|
||||
function (`observeDownloadProgress(user, file)`) builds it with the Step 1 function.
|
||||
- Expose a **cold** `Flow<T>`: `filterNotNull()` → `flatMapLatest { getWorkInfosForUniqueWorkFlow(it) }`
|
||||
→ map the `WorkInfo` list to the UI value → `distinctUntilChanged()`. Use
|
||||
`getWorkInfoByIdFlow(id)` when you have the request id, `getWorkInfosByTagFlow(tag)` when
|
||||
the work is not unique.
|
||||
- Progress is only present while `state == RUNNING`. It is empty after the work finishes, so
|
||||
filter on `RUNNING` and drop missing keys (`progress.keyValueMap[KEY] as? Int`).
|
||||
- Register it in `di/ViewModelModule.kt` with `@Binds @IntoMap @ViewModelKey(X::class)`.
|
||||
Without this, `ViewModelFactory` throws at runtime.
|
||||
|
||||
### Step 4: Consumer
|
||||
|
||||
- Get the ViewModel from `ViewModelFactory`: Kotlin `by viewModels { vmFactory }`, Java
|
||||
`new ViewModelProvider(this, vmFactory).get(X.class)` in `onCreate`. Injection of
|
||||
`Injectable` fragments happens before `onAttach`, so `vmFactory` is ready in `onCreate`.
|
||||
- Tell the ViewModel what to watch where the screen learns its subject (`onViewCreated`,
|
||||
and every public "show this other file" method such as `updateFileDetails(file, user)`).
|
||||
- Collect with the **view** lifecycle in fragments:
|
||||
- Kotlin: `viewLifecycleOwner.lifecycleScope.launch { viewLifecycleOwner.repeatOnLifecycle(STARTED) { vm.flow.collect { … } } }`
|
||||
- Java: `LifecycleOwnerExtensionsKt.collectWhenStarted(getViewLifecycleOwner(), viewModel.getX(), this::onX);`
|
||||
(`utils/extensions/LifecycleOwnerExtensions.kt`). Do not switch to `LiveData` for Java
|
||||
callers. See `references/PITFALLS.md` for why.
|
||||
- Turn the old `@Subscribe public void onX(Event e)` into `private void onX(T value)`. Keep
|
||||
its body unchanged apart from reading the value directly.
|
||||
- Remove the `register`/`unregister` lines for the bus. Keep `EventBus.getDefault()` registration
|
||||
if the class still has other `@Subscribe` methods.
|
||||
|
||||
### Step 5: Delete and verify
|
||||
|
||||
1. Delete the event class (and the dedicated bus if it has no users left).
|
||||
2. `git grep -n "<EventName>\|<busName>"` returns nothing.
|
||||
3. `./gradlew :app:compileGplayDebugJavaWithJavac spotlessKotlinCheck detekt`, then
|
||||
`lintGplayDebug spotbugsGplayDebug`. Fix findings in every file you touched.
|
||||
4. Manual check (hand it to the developer if you cannot run the app): start the work and
|
||||
open the screen, so the value shows up; open the screen first, then start the work; rotate
|
||||
while it runs; leave the screen for more than 5 s, let the work finish, come back (no stale
|
||||
value); open the screen for a *different* subject while work runs for another one (it must
|
||||
not react).
|
||||
|
||||
## References
|
||||
|
||||
- `references/VIEWMODEL-TEMPLATE.md`: ViewModel, worker and consumer snippets.
|
||||
- `references/PITFALLS.md`: what went wrong or nearly went wrong.
|
||||
- `assets/worked-example.md`: `FileDownloadProgressEvent` → `FileDetailFragmentViewModel`.
|
||||
@@ -1,56 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Worked Example: `FileDownloadProgressEvent` → `FileDetailFragmentViewModel`
|
||||
|
||||
## Inventory findings
|
||||
|
||||
- Event: `ui/events/FileDownloadProgressEvent(percent: Int)` on a dedicated bus,
|
||||
`ui/events/EventBusFactory.downloadProgressEventBus`. Neither had other users.
|
||||
- Poster: `FileDownloadWorker.onTransferProgress`, on every transfer chunk, unthrottled, with
|
||||
no file information.
|
||||
- Subscriber: `FileDetailFragment` (Java). It registered the bus in `onStart`, unregistered
|
||||
it in `onStop`, and `@Subscribe(threadMode = MAIN) onDownloadProgress` showed the progress
|
||||
block with the "downloading" text and the percent.
|
||||
- Enqueue: `BackgroundJobManagerImpl.startFileDownloadJob` →
|
||||
`enqueueUniqueWork(startFileDownloadJobTag(accountName, fileId), KEEP, request)`, and the
|
||||
same string as a tag. The builder was `private`.
|
||||
- Parallel mechanism: `containerActivity.getFileDownloadProgressListener()` /
|
||||
`FileDownloadWorker.FileDownloadProgressListener`. The field in `FileActivity` is never
|
||||
assigned, so it is always `null`, which is why the bus was added (commit `37df0dca9d`).
|
||||
Removed in the same change, since the ViewModel replaces it.
|
||||
- Folders use `FolderDownloadWorker`, which never posted the event.
|
||||
|
||||
## Changes
|
||||
|
||||
| File | Change |
|
||||
|---|---|
|
||||
| `jobs/BackgroundJobManagerImpl.kt` | `startFileDownloadJobTag` → public companion `formatFileDownloadTag`, used by start and cancel |
|
||||
| `jobs/download/FileDownloadWorker.kt` | `PROGRESS_PERCENT` key; `setProgressAsync(workDataOf(PROGRESS_PERCENT to percent))` inside the notification throttle; bus post removed |
|
||||
| `ui/fragment/filedetail/FileDetailFragmentViewModel.kt` | new; `downloadProgress: Flow<Int>` keyed by `formatFileDownloadTag` |
|
||||
| `di/ViewModelModule.kt` | `@Binds @IntoMap @ViewModelKey(FileDetailFragmentViewModel::class)` |
|
||||
| `utils/extensions/LifecycleOwnerExtensions.kt` | new; `collectWhenStarted(flow, Consumer)` for Java consumers |
|
||||
| `ui/fragment/FileDetailFragment.java` | `ViewModelFactory` inject, VM in `onCreate`, `observeDownloadProgress` in `onViewCreated` and `updateFileDetails(file, user)`, `collectWhenStarted` on the view lifecycle, `@Subscribe` → `private void onDownloadProgress(int)`, bus register/unregister removed |
|
||||
| `ui/events/FileDownloadProgressEvent.kt`, `ui/events/EventBusFactory.kt` | deleted |
|
||||
| `FileDownloadWorker.FileDownloadProgressListener` and its plumbing | deleted: inner class, worker field, `ComponentsGetter.getFileDownloadProgressListener()`, `FileActivity` field and getter, the two `= null` assignments in `FileDisplayActivity`, the download branches of `FileDetailFragment.listenForTransferProgress`/`leaveTransferProgress`, the `TestActivity` override and the `FileMenuFilterIT` mock |
|
||||
|
||||
## Intended behaviour differences
|
||||
|
||||
- Progress is shown only for the file the details screen is about, not for whichever file is
|
||||
downloading.
|
||||
- The UI updates at the notification throttle (750 ms) instead of on every chunk.
|
||||
|
||||
## Decisions
|
||||
|
||||
- **Cold `Flow` + `collectWhenStarted`, not `LiveData`.** `LiveData` replayed a stale
|
||||
percent after a finish that happened while the view was stopped (see `PITFALLS.md`).
|
||||
- **The ViewModel is created in `onCreate`, not `onViewCreated`.** The activity can call
|
||||
`updateFileDetails(file, user)` before the view exists, and the ViewModel must survive view
|
||||
re-creation from the back stack.
|
||||
- **The finished state is still handled by the existing broadcast path.**
|
||||
`FileDisplayActivity` calls `updateFileDetails(false, true)` on `ACTION_DOWNLOAD_COMPLETED`.
|
||||
Moving that to `WorkInfo.State.SUCCEEDED` is a possible follow-up, not part of this change.
|
||||
@@ -1,67 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Pitfalls
|
||||
|
||||
## `LiveData` replays a stale value
|
||||
|
||||
The first draft exposed `asLiveData()` so the Java fragment could `observe(...)`. `LiveData`
|
||||
keeps its last value and stops collecting upstream 5 s after the last observer goes away. If
|
||||
the download finishes during those 5 s, the cached value is the last running percent, and
|
||||
the next observer gets it right away. The progress block is shown again for a download that
|
||||
has already finished. A cold `Flow` collected with `repeatOnLifecycle` asks WorkManager again
|
||||
on every start and only gets the current state. Use `collectWhenStarted` from Java instead
|
||||
of `LiveData`.
|
||||
|
||||
## Progress disappears when the work finishes
|
||||
|
||||
`WorkInfo.progress` is empty as soon as the state leaves `RUNNING`. Do not read progress
|
||||
from `SUCCEEDED`/`FAILED` infos, and do not treat the missing key as `0`. Use `mapNotNull`
|
||||
and let the existing "finished" path (broadcast, `updateFileDetails(false, true)`) hide the
|
||||
UI, as it did before. Put final values in `Result.success(outputData)` if the UI needs them.
|
||||
|
||||
## Every `setProgress` is a database write
|
||||
|
||||
WorkManager persists progress. Calling it on every transfer chunk writes to the database
|
||||
hundreds of times per file. Publish only on change and inside the worker's existing
|
||||
throttle (`minProgressUpdateInterval`).
|
||||
|
||||
## Unique work name vs tag
|
||||
|
||||
`getWorkInfosForUniqueWorkFlow(name)` matches the `enqueueUniqueWork` name.
|
||||
`getWorkInfosByTagFlow(tag)` matches `addTag`. In `startFileDownloadJob` the same string
|
||||
is used for both, but that is not true for every job. Check the enqueue call. Never build the
|
||||
string by hand in the ViewModel. Make the builder public in the
|
||||
`BackgroundJobManagerImpl` companion.
|
||||
|
||||
## The bus was global; the Flow is not
|
||||
|
||||
`FileDownloadProgressEvent` reached `FileDetailFragment` for **any** running download, so
|
||||
the details of file A could show the progress of file B. The ViewModel is keyed by
|
||||
account + file id, so it only reacts to its own file. This is the intended change; mention it
|
||||
in the PR. Check which worker really runs for each subject: folders are downloaded by
|
||||
`FolderDownloadWorker`, not `FileDownloadWorker`, and never posted the event.
|
||||
|
||||
## The subject can change without a new view
|
||||
|
||||
`FileDetailFragment.updateFileDetails(OCFile, User)` swaps the file on a live fragment. Call
|
||||
`viewModel.observeX(...)` there too. Thanks to `flatMapLatest`, the old work's Flow is
|
||||
cancelled automatically. Guard with `viewModel != null` because the activity can call it on a
|
||||
fragment that has not reached `onCreate` yet.
|
||||
|
||||
## Missing ViewModel binding
|
||||
|
||||
Forgetting `@Binds @IntoMap @ViewModelKey(X::class)` in `ViewModelModule` compiles, but
|
||||
`ViewModelFactory` throws `IllegalArgumentException` when the screen opens.
|
||||
|
||||
## Keep other `@Subscribe` methods registered
|
||||
|
||||
`FileDetailFragment` still receives `FavoriteEvent` on `EventBus.getDefault()`. Remove only
|
||||
the registration for the bus you are replacing. Removing the default registration silently
|
||||
stops the remaining events. The other way round fails too: if the last `@Subscribe` method
|
||||
goes away but `register(this)` stays, EventBus throws `EventBusException` ("has no public
|
||||
methods with the @Subscribe annotation") when the screen starts.
|
||||
@@ -1,126 +0,0 @@
|
||||
<!--
|
||||
~ Nextcloud - Android Client
|
||||
~
|
||||
~ SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
~ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
# Templates
|
||||
|
||||
## Worker
|
||||
|
||||
```kotlin
|
||||
companion object {
|
||||
const val PROGRESS_PERCENT = "PROGRESS_PERCENT"
|
||||
}
|
||||
|
||||
// suspend context
|
||||
setProgress(workDataOf(PROGRESS_PERCENT to percent))
|
||||
|
||||
// non-suspend callback, inside the existing throttle
|
||||
if (percent != lastPercent && (currentTime - lastUpdateTime) >= minProgressUpdateInterval) {
|
||||
notificationManager.updateDownloadProgress(percent, totalToTransfer)
|
||||
setProgressAsync(workDataOf(PROGRESS_PERCENT to percent))
|
||||
lastUpdateTime = currentTime
|
||||
}
|
||||
```
|
||||
|
||||
## Work name (BackgroundJobManagerImpl companion)
|
||||
|
||||
```kotlin
|
||||
fun formatFileDownloadTag(accountName: String, fileId: Long): String =
|
||||
JOB_FOLDER_DOWNLOAD + accountName + fileId
|
||||
```
|
||||
|
||||
Use it in `startXJob` (`enqueueUniqueWork(tag, …)`), in `cancelXJob`, and in the ViewModel.
|
||||
|
||||
## ViewModel
|
||||
|
||||
```kotlin
|
||||
class FileDetailFragmentViewModel @Inject constructor(private val workManager: WorkManager) : ViewModel() {
|
||||
|
||||
private val downloadWorkName = MutableStateFlow<String?>(null)
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
val downloadProgress: Flow<Int> = downloadWorkName
|
||||
.filterNotNull()
|
||||
.flatMapLatest { workManager.getWorkInfosForUniqueWorkFlow(it) }
|
||||
.mapNotNull { workInfos -> workInfos.firstOrNull { it.state == WorkInfo.State.RUNNING }?.downloadPercent() }
|
||||
.distinctUntilChanged()
|
||||
|
||||
fun observeDownloadProgress(user: User, file: OCFile) {
|
||||
downloadWorkName.value = BackgroundJobManagerImpl.formatFileDownloadTag(user.accountName, file.fileId)
|
||||
}
|
||||
|
||||
private fun WorkInfo.downloadPercent(): Int? = progress.keyValueMap[FileDownloadWorker.PROGRESS_PERCENT] as? Int
|
||||
}
|
||||
```
|
||||
|
||||
State-only variant (no progress published), from `FileDisplayActivityViewModel`:
|
||||
|
||||
```kotlin
|
||||
suspend fun observeOfflineWorker(onComplete: () -> Unit) {
|
||||
workManager
|
||||
.getWorkInfosByTagFlow(BackgroundJobManagerImpl.formatClassTag(OfflineOperationsWorker::class))
|
||||
.collect { workInfos ->
|
||||
if (workInfos.any { it.state == WorkInfo.State.SUCCEEDED }) {
|
||||
onComplete()
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Prefer exposing a `Flow` property over a `suspend fun` with a callback: the consumer decides
|
||||
the lifecycle, and Java can collect it through `collectWhenStarted`.
|
||||
|
||||
## DI (`di/ViewModelModule.kt`)
|
||||
|
||||
```kotlin
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ViewModelKey(FileDetailFragmentViewModel::class)
|
||||
abstract fun fileDetailFragmentViewModel(vm: FileDetailFragmentViewModel): ViewModel
|
||||
```
|
||||
|
||||
## Kotlin consumer (fragment)
|
||||
|
||||
```kotlin
|
||||
@Inject lateinit var vmFactory: ViewModelFactory
|
||||
private val viewModel by viewModels<FileDetailFragmentViewModel> { vmFactory }
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
viewModel.observeDownloadProgress(user, file)
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.downloadProgress.collect(::onDownloadProgress)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Java consumer (fragment)
|
||||
|
||||
```java
|
||||
@Inject ViewModelFactory vmFactory;
|
||||
private FileDetailFragmentViewModel viewModel;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
viewModel = new ViewModelProvider(this, vmFactory).get(FileDetailFragmentViewModel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
viewModel.observeDownloadProgress(user, getFile());
|
||||
LifecycleOwnerExtensionsKt.collectWhenStarted(getViewLifecycleOwner(),
|
||||
viewModel.getDownloadProgress(),
|
||||
this::onDownloadProgress);
|
||||
}
|
||||
|
||||
private void onDownloadProgress(int percent) { … }
|
||||
```
|
||||
|
||||
`collectWhenStarted` (`utils/extensions/LifecycleOwnerExtensions.kt`) wraps
|
||||
`lifecycleScope.launch { repeatOnLifecycle(STARTED) { flow.collect(collector::accept) } }`
|
||||
and takes an `androidx.core.util.Consumer`, so a Java method reference fits.
|
||||
@@ -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.
|
||||
@@ -1,10 +1,10 @@
|
||||
FROM ubuntu:resolute@sha256:6a06111c3b0a8600feadb270aec771dc239bf407b25625f93f44ab00e11f4d3c
|
||||
FROM ubuntu:noble@sha256:c35e29c9450151419d9448b0fd75374fec4fff364a27f176fb458d472dfc9e54
|
||||
|
||||
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"
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
---
|
||||
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-android16:latest
|
||||
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: 'stable30'
|
||||
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"
|
||||
- su www-data -c "php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool"
|
||||
- /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-android16:latest
|
||||
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"
|
||||
- su www-data -c "php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool"
|
||||
- /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-android16:latest
|
||||
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.kts
|
||||
- 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: d52e0df1af49c1b30e42a877655c6699914130adf3a3b881db46a70b90356c3a
|
||||
|
||||
...
|
||||
@@ -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
|
||||
@@ -1,2 +1,2 @@
|
||||
SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -1,179 +0,0 @@
|
||||
# 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: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: AI Policy
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
branches: [master, main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
# Required to add the "AI assisted" label via `gh pr edit --add-label`
|
||||
pull-requests: write
|
||||
# Required to create the "AI assisted" label via the REST labels endpoint
|
||||
# (labels are an issues-scoped resource in the GitHub API)
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: ai-policy-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check-ai-trailers:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Collect PR commit messages
|
||||
id: collect
|
||||
env:
|
||||
BASE_REF: ${{ github.base_ref }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git fetch origin "${BASE_REF}"
|
||||
MERGE_BASE=$(git merge-base "origin/${BASE_REF}" HEAD)
|
||||
git log --format="%B" "${MERGE_BASE}..HEAD" > /tmp/pr_commits.txt
|
||||
echo "--- PR commit messages ---"
|
||||
cat /tmp/pr_commits.txt
|
||||
echo "--------------------------"
|
||||
|
||||
- name: Define shared agent detection patterns
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# Email addresses known to be used by coding agents.
|
||||
# These should never appear in Signed-off-by because the DCO can only be attested by a human.
|
||||
EMAIL_PATTERN="copilot@github\.com\
|
||||
|noreply@anthropic\.com\
|
||||
|devin@cognition\.ai\
|
||||
|devin@cognition-labs\.com\
|
||||
|aider@aider\.chat\
|
||||
|noreply@aider\.chat\
|
||||
|codex@openai\.com\
|
||||
|cursor@anysphere\.com\
|
||||
|windsurf@codeium\.com\
|
||||
|codeium@codeium\.com\
|
||||
|amazon-q@amazon\.com\
|
||||
|codewhisperer@amazon\.com\
|
||||
|gemini-code-assist@google\.com\
|
||||
|openhands@all-hands\.dev\
|
||||
|swe-agent@princeton\.edu"
|
||||
|
||||
# Strip embedded whitespace (used above only for readability)
|
||||
EMAIL_PATTERN=$(echo "$EMAIL_PATTERN" | tr -d ' \n')
|
||||
echo "AGENT_EMAIL_PATTERN=${EMAIL_PATTERN}" >> "$GITHUB_ENV"
|
||||
|
||||
# Display-name prefixes used by known coding agents (shared by Signed-off-by and Co-Authored-By checks)
|
||||
# shellcheck disable=SC2016
|
||||
echo 'AGENT_NAMES=GitHub Copilot|Claude( [A-Za-z0-9. -]+)?|Devin( AI)?|aider( \(.*\))?|OpenAI Codex|Cursor( AI)?|Windsurf|Amazon Q|CodeWhisperer|Gemini Code Assist|OpenHands|SWE-agent|AutoCodeRover|Tabnine' >> "$GITHUB_ENV"
|
||||
|
||||
- name: Check for AI-assistant / Assisted-by trailers
|
||||
id: ai_trailers
|
||||
run: |
|
||||
set -euo pipefail
|
||||
AI_ASSISTED=false
|
||||
if grep -qiE '^(AI-assistant|Assisted-by):' /tmp/pr_commits.txt; then
|
||||
AI_ASSISTED=true
|
||||
echo "Found AI-assistant/Assisted-by trailer(s):"
|
||||
grep -iE '^(AI-assistant|Assisted-by):' /tmp/pr_commits.txt
|
||||
fi
|
||||
echo "ai_assisted=${AI_ASSISTED}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Check for coding-agent Signed-off-by trailers
|
||||
id: agent_signoff
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
EMAIL_HITS=$(grep -iE "^Signed-off-by:.*<(${AGENT_EMAIL_PATTERN})>" /tmp/pr_commits.txt 2>/dev/null || true)
|
||||
NAME_HITS=$(grep -iE "^Signed-off-by: *(${AGENT_NAMES}) *[<(]" /tmp/pr_commits.txt 2>/dev/null || true)
|
||||
|
||||
AGENT_LINES=$(printf '%s\n%s' "$EMAIL_HITS" "$NAME_HITS" | sort -u | sed '/^[[:space:]]*$/d')
|
||||
|
||||
AGENT_SIGNOFF=false
|
||||
if [ -n "$AGENT_LINES" ]; then
|
||||
AGENT_SIGNOFF=true
|
||||
fi
|
||||
|
||||
echo "agent_signoff=${AGENT_SIGNOFF}" >> "$GITHUB_OUTPUT"
|
||||
{
|
||||
echo "agent_lines<<AGENT_EOF"
|
||||
echo "${AGENT_LINES}"
|
||||
echo "AGENT_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Check for coding-agent Co-Authored-By trailers
|
||||
id: co_authored
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
EMAIL_HITS=$(grep -iE "^Co-Authored-By:.*<(${AGENT_EMAIL_PATTERN})>" /tmp/pr_commits.txt 2>/dev/null || true)
|
||||
NAME_HITS=$(grep -iE "^Co-Authored-By: *(${AGENT_NAMES}) *[<(]" /tmp/pr_commits.txt 2>/dev/null || true)
|
||||
|
||||
CO_AUTHORED=false
|
||||
if [ -n "$EMAIL_HITS" ] || [ -n "$NAME_HITS" ]; then
|
||||
CO_AUTHORED=true
|
||||
echo "Found coding-agent Co-Authored-By trailer(s):"
|
||||
printf '%s\n%s' "$EMAIL_HITS" "$NAME_HITS" | sort -u | sed '/^[[:space:]]*$/d'
|
||||
fi
|
||||
|
||||
echo "co_authored=${CO_AUTHORED}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Create 'AI assisted' label if absent
|
||||
if: steps.ai_trailers.outputs.ai_assisted == 'true' || steps.agent_signoff.outputs.agent_signoff == 'true' || steps.co_authored.outputs.co_authored == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh api "repos/${{ github.repository }}/labels" \
|
||||
--method POST \
|
||||
-f name="AI assisted" \
|
||||
-f color="d93f0b" \
|
||||
-f description="This PR contains AI-assisted commits" \
|
||||
2>/dev/null || true
|
||||
|
||||
- name: Label PR as AI assisted
|
||||
if: steps.ai_trailers.outputs.ai_assisted == 'true' || steps.agent_signoff.outputs.agent_signoff == 'true' || steps.co_authored.outputs.co_authored == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh pr edit "${{ github.event.pull_request.number }}" \
|
||||
--repo "${{ github.repository }}" \
|
||||
--add-label "AI assisted"
|
||||
echo "Added 'AI assisted' label to PR #${{ github.event.pull_request.number }}"
|
||||
|
||||
- name: Fail on coding-agent Signed-off-by
|
||||
if: steps.agent_signoff.outputs.agent_signoff == 'true'
|
||||
env:
|
||||
AGENT_LINES: ${{ steps.agent_signoff.outputs.agent_lines }}
|
||||
AGENTS_MD_URL: https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/AGENTS.md
|
||||
run: |
|
||||
echo "::error title=Coding-agent sign-off detected::A Signed-off-by trailer from a known coding agent was found in one or more commits."
|
||||
echo ""
|
||||
echo "Offending trailer(s):"
|
||||
echo "${AGENT_LINES}"
|
||||
echo ""
|
||||
echo "The 'Signed-off-by' trailer represents the Developer Certificate of Origin (DCO)"
|
||||
echo "and must only be attested by a human contributor."
|
||||
echo "Please amend the affected commit(s) to remove the coding-agent sign-off"
|
||||
echo "and replace it with an 'Assisted-by' trailer, for example:"
|
||||
echo ""
|
||||
echo " Assisted-by: Claude Code:claude-sonnet-4-6"
|
||||
echo ""
|
||||
echo "References:"
|
||||
echo " • AGENTS.md (this repository)"
|
||||
echo " ${AGENTS_MD_URL}"
|
||||
echo " • AI Contribution Policy"
|
||||
echo " https://github.com/nextcloud/.github/blob/master/AI_POLICY.md"
|
||||
echo " • Contribution Guidelines"
|
||||
echo " https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md"
|
||||
exit 1
|
||||
@@ -26,7 +26,8 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest-max
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- name: Disabled on forks
|
||||
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
|
||||
@@ -51,16 +52,16 @@ jobs:
|
||||
echo "repo=${{ github.event.pull_request.head.repo.full_name }}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 25
|
||||
java-version: 17
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install python3-defusedxml
|
||||
@@ -70,7 +71,9 @@ jobs:
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
|
||||
echo "org.gradle.jvmargs=-Xmx5g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g"
|
||||
echo "org.gradle.configureondemand=true"
|
||||
echo "org.gradle.configuration-cache=false"
|
||||
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 }}"
|
||||
@@ -6,8 +6,6 @@ name: "Assemble"
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
@@ -18,34 +16,24 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
flavor:
|
||||
name: flavor (${{ matrix.flavor }})
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- flavor: Generic
|
||||
tasks: assembleGenericDebug
|
||||
- flavor: Gplay
|
||||
tasks: assembleGplayDebug assembleGplayRelease
|
||||
- flavor: Huawei
|
||||
tasks: assembleHuaweiDebug
|
||||
flavor: [ Generic, Gplay, Huawei ]
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
- uses: gradle/actions/wrapper-validation@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
|
||||
java-version: 17
|
||||
- uses: gradle/actions/wrapper-validation@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
||||
- name: Build ${{ matrix.flavor }}
|
||||
run: |
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=768m"
|
||||
echo "kotlin.daemon.jvmargs=-Xmx3g -XX:+UseParallelGC -XX:MaxMetaspaceSize=512m"
|
||||
echo "org.gradle.workers.max=2"
|
||||
} >> gradle.properties
|
||||
./gradlew ${{ matrix.tasks }}
|
||||
|
||||
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 }}
|
||||
@@ -26,7 +26,7 @@ permissions:
|
||||
jobs:
|
||||
auto-approve:
|
||||
name: Auto approve sync
|
||||
runs-on: ubuntu-latest-low
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ contains(github.event.pull_request.labels.*.name, 'sync') && github.actor == 'nextcloud-android-bot' }}
|
||||
steps:
|
||||
- name: Disabled on forks
|
||||
|
||||
@@ -6,8 +6,6 @@ name: Check
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
@@ -24,13 +22,11 @@ jobs:
|
||||
matrix:
|
||||
task: [ detekt, spotlessKotlinCheck, lint ]
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
|
||||
java-version: 17
|
||||
- name: Check ${{ matrix.task }}
|
||||
run: ./gradlew ${{ matrix.task }}
|
||||
@@ -1,7 +1,6 @@
|
||||
# synced from @nextcloud/android-config
|
||||
|
||||
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023-2024 Andy Scherzinger <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2022 Tobias Kaminsky <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
@@ -21,15 +20,10 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: codeql-${{ github.event.pull_request.number || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest-max
|
||||
timeout-minutes: 90
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
@@ -40,7 +34,7 @@ jobs:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set Swap Space
|
||||
@@ -49,18 +43,18 @@ jobs:
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
|
||||
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 25
|
||||
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 --no-daemon assembleDebug
|
||||
./gradlew assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
|
||||
uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
|
||||
@@ -1,86 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Nextcloud Android Library
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if [ $1 = "master" ]; then
|
||||
SERVER_VERSION_MAIN="main"
|
||||
SERVER_VERSION_MASTER="master"
|
||||
else
|
||||
SERVER_VERSION_MAIN=$1
|
||||
SERVER_VERSION_MASTER=$1
|
||||
fi
|
||||
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
|
||||
. ~/.bashrc; nvm install node
|
||||
|
||||
php /var/www/html/occ log:manage --level warning
|
||||
|
||||
OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1
|
||||
OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2
|
||||
OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3
|
||||
OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test@Test' test@test
|
||||
OC_PASS=test php /var/www/html/occ user:add --password-from-env --display-name='Test Spaces' 'test test'
|
||||
php /var/www/html/occ user:setting user2 files quota 1G
|
||||
php /var/www/html/occ group:add users
|
||||
php /var/www/html/occ group:adduser users user1
|
||||
php /var/www/html/occ group:adduser users user2
|
||||
php /var/www/html/occ group:adduser users test
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/activity.git /var/www/html/apps/activity/
|
||||
php /var/www/html/occ app:enable -f activity
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MAIN https://github.com/nextcloud/text.git /var/www/html/apps/text/
|
||||
php /var/www/html/occ app:enable -f text
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/
|
||||
php /var/www/html/occ app:enable -f end_to_end_encryption
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/password_policy.git /var/www/html/apps/password_policy/
|
||||
php /var/www/html/occ app:enable -f password_policy
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/external.git /var/www/html/apps/external/
|
||||
cd /var/www/html/apps/external; composer install --no-dev
|
||||
php /var/www/html/occ app:enable -f external
|
||||
php /var/www/html/occ config:app:set external sites --value="{\"1\":{\"id\":1,\"name\":\"Nextcloud\",\"url\":\"https:\/\/www.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false},\"2\":{\"id\":2,\"name\":\"Forum\",\"url\":\"https:\/\/help.nextcloud.com\",\"lang\":\"\",\"type\":\"link\",\"device\":\"\",\"icon\":\"external.svg\",\"groups\":[],\"redirect\":false}}"
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MAIN https://github.com/nextcloud/files_lock.git /var/www/html/apps/files_lock/
|
||||
php /var/www/html/occ app:enable -f files_lock
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/notifications.git /var/www/html/apps/notifications/
|
||||
cd /var/www/html/apps/notifications; composer install --no-dev
|
||||
php /var/www/html/occ app:enable -f notifications
|
||||
|
||||
if [ $1 = 'stable22' ]; then
|
||||
php /var/www/html/occ notification:generate test test
|
||||
else
|
||||
php /var/www/html/occ notification:generate test -d test
|
||||
fi
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/photos.git /var/www/html/apps/photos/
|
||||
cd /var/www/html/apps/photos; composer install --no-dev
|
||||
php /var/www/html/occ app:enable -f photos
|
||||
|
||||
git clone --depth=1 -b $SERVER_VERSION_MAIN https://github.com/nextcloud/assistant.git /var/www/html/apps/assistant/
|
||||
cd /var/www/html/apps/assistant; . ~/.bashrc; make
|
||||
php /var/www/html/occ app:enable -f assistant
|
||||
|
||||
php /var/www/html/occ app:enable -f testing
|
||||
|
||||
git clone --depth 1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/files_downloadlimit.git /var/www/html/apps/files_downloadlimit/
|
||||
php /var/www/html/occ app:enable -f files_downloadlimit
|
||||
|
||||
git clone --depth 1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/recommendations.git /var/www/html/apps/recommendations/
|
||||
cd /var/www/html/apps/recommendations; composer install --no-dev
|
||||
php /var/www/html/occ app:enable -f recommendations
|
||||
|
||||
git clone --depth 1 -b $SERVER_VERSION_MASTER https://github.com/nextcloud/viewer.git /var/www/html/apps/viewer/
|
||||
php /var/www/html/occ app:enable -f viewer
|
||||
|
||||
php /var/www/html/occ config:system:set ratelimit.protection.enabled --value false --type bool
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Nextcloud Android Library
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
|
||||
apt-get update && apt-get install -y composer
|
||||
mkdir /var/www/.nvm /var/www/.npm
|
||||
mkdir /var/www/.cache/
|
||||
touch /var/www/.bashrc
|
||||
chown -R 33:33 /var/www/.nvm /var/www/.npm /var/www/.bashrc /var/www/.cache
|
||||
|
||||
cd /var/www/html/
|
||||
rm data -rf
|
||||
rm config/config.php
|
||||
su www-data -c "git reset --hard"
|
||||
BRANCH="$1" /usr/local/bin/initnc.sh
|
||||
@@ -20,7 +20,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
detectNewJavaFiles:
|
||||
runs-on: ubuntu-latest-low
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: file_changes
|
||||
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b # v1.2.4
|
||||
|
||||
@@ -17,14 +17,14 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
detectWrongSettings:
|
||||
runs-on: ubuntu-26.04
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
- name: Detect SNAPSHOT
|
||||
run: scripts/analysis/detectWrongSettings.sh
|
||||
@@ -1,101 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: "Garm"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-26.04
|
||||
services:
|
||||
server:
|
||||
image: ${{ matrix.server == 'stable22' && 'ghcr.io/nextcloud/continuous-integration-shallow-server-php8.0:1' || 'ghcr.io/nextcloud/continuous-integration-shallow-server-php8.3:latest' }}
|
||||
options: --name server
|
||||
ports:
|
||||
- 80:80
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
server: [ stable22, stable35, master ]
|
||||
api-level: [ 29 ] # [ 21, 36 ]
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
|
||||
- name: configure server
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install unzip cpu-checker qemu-system-x86 --yes
|
||||
sudo chmod 666 /dev/kvm
|
||||
docker cp .github/workflows/configServer.sh server:/tmp/
|
||||
docker exec server chmod +x /tmp/configServer.sh
|
||||
docker exec server /tmp/configServer.sh ${{ matrix.server }}
|
||||
docker cp .github/workflows/configNC.sh server:/tmp/
|
||||
docker exec server chmod +x /tmp/configNC.sh
|
||||
docker exec --user www-data server /tmp/configNC.sh ${{ matrix.server }}
|
||||
docker exec server /usr/local/bin/run.sh
|
||||
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
|
||||
- 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
|
||||
|
||||
- name: Config gplay
|
||||
run: |
|
||||
sed -i s#http://server#http://10.0.2.2# gradle.properties
|
||||
sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
|
||||
|
||||
- name: wait and ping server
|
||||
run: |
|
||||
while ! curl http://localhost/status.php 2>&1 | grep installed; do
|
||||
echo "wait…"
|
||||
sleep 5
|
||||
done
|
||||
|
||||
- name: gplay
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }}
|
||||
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
cmake: 4.1.2
|
||||
force-avd-creation: false
|
||||
arch: x86_64
|
||||
sdcard-path-or-size: 100M
|
||||
target: google_apis
|
||||
emulator-options: -no-metrics -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833
|
||||
script: scripts/runCombinedTest.sh ${{github.event.number}} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} ${{github.event.number}} ${{ matrix.server }}
|
||||
|
||||
- name: upload failing results
|
||||
if: ${{ failure() }}
|
||||
env:
|
||||
LOG_USERNAME: ${{ secrets.LOG_USERNAME }}
|
||||
LOG_PASSWORD: ${{ secrets.LOG_PASSWORD }}
|
||||
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} ${{ matrix.server }} "IT" ${{github.event.number}}
|
||||
- name: Archive Espresso results
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.server }}-${{ matrix.api-level }}
|
||||
path: app/build/reports
|
||||
retention-days: 4
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
#
|
||||
|
||||
## This file is intended to be sourced by other scripts
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
SPDX-FileCopyrightText: 2019-2025 Nextcloud GmbH and Nextcloud contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
@@ -1,39 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: Lint translation files
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, main, stable-* ]
|
||||
push:
|
||||
branches: [ master, main, stable-* ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-php-cs-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest-low
|
||||
|
||||
name: translations-string-xml
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Check for new lines in translation strings
|
||||
id: counter
|
||||
run: |
|
||||
grep -P '<string name' app/src/main/res/values/strings.xml | grep -vcP '</string>' | grep '^0$'
|
||||
|
||||
- name: Output
|
||||
if: failure()
|
||||
run: |
|
||||
grep -P '<string name' app/src/main/res/values/strings.xml | grep -vP '</string>'
|
||||
@@ -22,7 +22,7 @@ permissions:
|
||||
jobs:
|
||||
pr-feedback:
|
||||
if: ${{ github.repository_owner == 'nextcloud' }}
|
||||
runs-on: ubuntu-latest-low
|
||||
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
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -)
|
||||
echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: nextcloud/pr-feedback-action@4738cf661995d96df3512409ec17c900a4081d33 # main
|
||||
- uses: nextcloud/pr-feedback-action@5227c55be184087d0aef6338bee210d8620b6297 # main
|
||||
with:
|
||||
feedback-message: |
|
||||
Hello there,
|
||||
|
||||
+10
-71
@@ -1,5 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
|
||||
# SPDX-License-Identifier: MIT
|
||||
name: "QA"
|
||||
@@ -18,27 +17,26 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
qa:
|
||||
runs-on: ubuntu-latest-max
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check if secrets are available
|
||||
run: echo "ok=${{ secrets.KS_PASS != '' }}" >> "$GITHUB_OUTPUT"
|
||||
id: check-secrets
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 25
|
||||
java-version: 17
|
||||
|
||||
- name: Build QA
|
||||
id: build-qa
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
KS_PASS: ${{ secrets.KS_PASS }}
|
||||
@@ -48,69 +46,10 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g"
|
||||
echo "org.gradle.caching=true"
|
||||
echo "org.gradle.parallel=true"
|
||||
echo "org.gradle.configureondemand=true"
|
||||
} > "$HOME/.gradle/gradle.properties"
|
||||
[ -e app/build.gradle ] && sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" "app/build.gradle"
|
||||
[ -e app/build.gradle ] && sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" "app/build.gradle"
|
||||
[ -e app/build.gradle.kts ] && sed -i "/qa/,/\}/ s/versionCode .*/versionCode = ${{github.event.number}} /" "app/build.gradle.kts"
|
||||
[ -e app/build.gradle.kts ] && sed -i "/qa/,/\}/ s/versionName .*/versionName = \"${{github.event.number}}\"/" "app/build.gradle.kts"
|
||||
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; org.gradle.parallel=true; org.gradle.configureondemand=true; kapt.incremental.apt=true" >> "$HOME/.gradle/gradle.properties"
|
||||
sed -i "/qa/,/\}/ s/versionCode.*/versionCode = ${{ github.event.number }}/" app/build.gradle.kts
|
||||
sed -i "/qa/,/\}/ s/versionName.*/versionName = \"${{ github.event.number }}\"/" app/build.gradle.kts
|
||||
./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 ".github/workflows/QA_keystore.jks" app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
apk=$(find app/build/outputs/apk/qa/debug -name '*qa-debug*.apk' | head -n1)
|
||||
{
|
||||
echo "apk-path=$apk"
|
||||
echo "apk-name=$(basename "$apk")"
|
||||
echo "apk-size=$(du -h "$apk" | cut -f1)"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Upload APK
|
||||
id: upload-apk
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
|
||||
with:
|
||||
path: app/build/outputs/apk/qa/debug/*qa-debug*.apk
|
||||
retention-days: 7
|
||||
archive: false
|
||||
|
||||
- name: Create QR Code
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
ARTIFACT_URL: ${{ steps.upload-apk.outputs.artifact-url }}
|
||||
run: |
|
||||
sudo apt-get -y install qrencode
|
||||
qrencode -s 8 -o qr.png "$ARTIFACT_URL"
|
||||
|
||||
- name: Upload QR
|
||||
id: upload-qr
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
|
||||
with:
|
||||
path: qr.png
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
archive: false
|
||||
|
||||
- name: Comment PR
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: thollander/actions-comment-pull-request@e4a76dd2b0a3c2027c3fd84147a67c22ee4c90fa
|
||||
with:
|
||||
comment-tag: qa-apk
|
||||
mode: upsert
|
||||
message: |
|
||||
### :iphone: QA build
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Download** | [${{ steps.build-qa.outputs.apk-name }}](${{ steps.upload-apk.outputs.artifact-url }}) |
|
||||
| **QR code** | [Open the QR code for this download](${{ steps.upload-qr.outputs.artifact-url }}) |
|
||||
| **Commit** | ${{ github.event.pull_request.head.sha }} |
|
||||
| **Version** | `${{ github.event.number }}` |
|
||||
| **Available until** | 7 days after this build |
|
||||
|
||||
The QA build installs alongside a released Nextcloud app, so you can keep
|
||||
using your existing install while testing.
|
||||
|
||||
Downloading the file requires a GitHub account, so open this link on the
|
||||
device you want to test on, or transfer the APK to it.
|
||||
.github/workflows/uploadArtifact.sh "$LOG_USERNAME" "$LOG_PASSWORD" "${{github.event.number}}" "${{github.event.number}}" "$GITHUB_TOKEN"
|
||||
@@ -25,7 +25,7 @@ concurrency:
|
||||
jobs:
|
||||
auto-approve-merge:
|
||||
if: github.event.pull_request.user.login == 'renovate[bot]'
|
||||
runs-on: ubuntu-latest-low
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# for hmarr/auto-approve-action to approve PRs
|
||||
pull-requests: write
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-latest-low
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0
|
||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -42,6 +42,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1
|
||||
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -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: [ 28 ]
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
- name: AVD cache
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
~/.android/avd/*
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.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@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.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 assembleGenericDebug
|
||||
|
||||
- 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@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.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 genericDebugExecuteScreenshotTests -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@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
path: app/build/reports
|
||||
retention-days: 4
|
||||
@@ -15,12 +15,12 @@ permissions: read-all
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest-low
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@4391f3da665fdf50b6810c1a66712fb9ba21aa93 # v11.0.0
|
||||
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
|
||||
with:
|
||||
days-before-stale: 28
|
||||
days-before-close: 14
|
||||
|
||||
@@ -22,13 +22,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
|
||||
- name: Delete old comments
|
||||
env:
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@8da46b539cd8fe6ab27ca75128919a18d757604c # v6.4.1
|
||||
uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
||||
|
||||
- name: Run unit tests with coverage
|
||||
run: ./gradlew jacocoTestGplayDebugUnitTest
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
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@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
|
||||
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/jacoco/jacocoTestGplayDebugUnitTestReport/html/
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2019-2022 Tobias Kaminsky <[email protected]>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
#
|
||||
|
||||
#1: LOG_USERNAME
|
||||
|
||||
-38
@@ -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
|
||||
@@ -60,23 +37,8 @@ build
|
||||
/gradle.properties
|
||||
.attach_pid*
|
||||
fastlane/Fastfile
|
||||
fastlane/ruby
|
||||
*.hprof
|
||||
|
||||
# NDK / C++
|
||||
*.so
|
||||
obj/
|
||||
*.o
|
||||
*.a
|
||||
.cxx/
|
||||
|
||||
# Testing & coverage
|
||||
.kotlin/
|
||||
*.lcov
|
||||
test-results/
|
||||
jacoco/
|
||||
*.exec
|
||||
|
||||
# fastlane specific
|
||||
**/fastlane/report.xml
|
||||
|
||||
|
||||
Generated
+25
@@ -2,6 +2,31 @@
|
||||
<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">
|
||||
|
||||
Generated
-1
@@ -33,7 +33,6 @@
|
||||
<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" />
|
||||
|
||||
@@ -1,236 +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.
|
||||
- **`android-activity-to-navigator-fragment`** (`./.claude/skills/android-activity-to-navigator-fragment/SKILL.md`) — Converts a standalone Activity (typically a drawer destination) into a Fragment hosted by `NavigatorActivity`. Use it when the user mentions "navigator", `NavigatorActivity`, `NavigatorScreen`, or "convert activity to fragment". It covers registering the `NavigatorScreen`, the fragment and its layout, decoupling collaborators from `FileActivity`, rewiring every entry point with `NavigatorActivity.intent(...)`, DI and manifest cleanup, and migrating the screenshot test.
|
||||
- **`android-eventbus-to-workmanager-flow`** (`./.claude/skills/android-eventbus-to-workmanager-flow/SKILL.md`) — Replaces an EventBus event posted by a WorkManager worker with WorkManager observation through a ViewModel `Flow`. Use it when the user mentions "event bus", `EventBusFactory`, `@Subscribe`, "worker progress", or "observe worker". It covers publishing with `setProgress`, a ViewModel keyed by the unique work name, `ViewModelModule` registration, collecting from Kotlin or Java (`collectWhenStarted`) and deleting the event. The live example is `FileDetailFragmentViewModel`.
|
||||
|
||||
### Android Skills
|
||||
|
||||
Agent skills for Android development at https://github.com/android/skills (overview: https://developer.android.com/tools/agents/android-skills). Use them when a task matches their trigger and no project-specific skill above covers it. Install one with the Android CLI (`android skills add <skill-name>`) or read its `SKILL.md` directly from the repository. Project-specific skills and the rules in this file take precedence over the official skills.
|
||||
|
||||
- **`r8-analyzer`** (https://github.com/android/skills/tree/main/performance/r8-analyzer) — Analyzes the R8 configuration and keep rules for redundant, overly broad, or library-subsumed rules. Use it when changing the keep rules in `app/src/main/keepRules/` or the `optimization {}` blocks in `app/build.gradle.kts`.
|
||||
|
||||
## 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.
|
||||
|
||||
### Network Clients
|
||||
|
||||
Get `OwnCloudClient` and `NextcloudClient` instances from `ClientRepository` (`com.nextcloud.repository`), never from `ClientFactory`.
|
||||
`ClientFactory` is deprecated and being phased out; do not add new usages of it, and replace it with `ClientRepository` when touching code that still uses it.
|
||||
|
||||
- Inject `ClientRepository` with Dagger (`@Inject lateinit var clientRepository: ClientRepository`); it is bound to `RemoteClientRepository`, which resolves the current user via `UserAccountManager` on every call.
|
||||
- Activities extending `BaseActivity` already expose it via `getClientRepository()`.
|
||||
- Prefer the `suspend` functions `getOwncloudClient()` / `getNextcloudClient()` from a lifecycle-aware scope (`lifecycleScope`, `viewModelScope`); they switch to `Dispatchers.IO` and return `null` on failure, so handle `null` instead of catching exceptions.
|
||||
- Do not construct `RemoteClientRepository` manually.
|
||||
|
||||
### 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.
|
||||
+10
-39
@@ -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
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
# Autogenerated by fastlane
|
||||
#
|
||||
# Ensure this file is checked in to source control!
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "fastlane"
|
||||
gem "abbrev"
|
||||
gem 'fastlane'
|
||||
|
||||
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
|
||||
eval_gemfile(plugins_path) if File.exist?(plugins_path)
|
||||
+109
-147
@@ -3,253 +3,215 @@ GEM
|
||||
specs:
|
||||
CFPropertyList (3.0.8)
|
||||
abbrev (0.1.2)
|
||||
addressable (2.9.0)
|
||||
addressable (2.8.8)
|
||||
public_suffix (>= 2.0.2, < 8.0)
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.4.1)
|
||||
aws-partitions (1.1299.1)
|
||||
aws-sdk-core (3.262.0)
|
||||
aws-eventstream (~> 1, >= 1.4.1)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1201.0)
|
||||
aws-sdk-core (3.241.2)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
bigdecimal
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
logger
|
||||
rexml (~> 3.4, >= 3.4.2)
|
||||
aws-sdk-kms (1.137.0)
|
||||
aws-sdk-core (~> 3, >= 3.262.0)
|
||||
aws-sdk-kms (1.119.0)
|
||||
aws-sdk-core (~> 3, >= 3.241.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.236.0)
|
||||
aws-sdk-core (~> 3, >= 3.262.0)
|
||||
aws-sdk-s3 (1.210.1)
|
||||
aws-sdk-core (~> 3, >= 3.241.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.12.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
base64 (0.3.0)
|
||||
benchmark (0.5.0)
|
||||
bigdecimal (4.1.3)
|
||||
cgi (0.5.2)
|
||||
bigdecimal (3.3.1)
|
||||
cgi (0.4.2)
|
||||
claide (1.1.0)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
highline (~> 2.0.0)
|
||||
csv (3.3.7)
|
||||
csv (3.3.5)
|
||||
declarative (0.0.20)
|
||||
digest-crc (0.7.0)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
domain_name (0.7.20261007)
|
||||
domain_name (0.6.20240107)
|
||||
dotenv (2.8.1)
|
||||
emoji_regex (3.2.3)
|
||||
erb (6.0.7)
|
||||
excon (1.9.0)
|
||||
faraday (2.15.1)
|
||||
faraday-net_http (>= 2.0, < 3.6)
|
||||
json
|
||||
logger
|
||||
excon (0.112.0)
|
||||
faraday (1.8.0)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-cookie_jar (0.0.8)
|
||||
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 (3.5.0)
|
||||
net-http (~> 0.5)
|
||||
faraday-retry (2.4.0)
|
||||
faraday (~> 2.0)
|
||||
fastimage (2.4.3)
|
||||
fastlane (2.241.2)
|
||||
CFPropertyList (>= 2.3, < 5.0.0)
|
||||
abbrev (~> 0.1)
|
||||
addressable (>= 2.9.0, < 3.0.0)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.1)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.4.0)
|
||||
fastlane (2.229.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
abbrev (~> 0.1.2)
|
||||
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)
|
||||
cgi (~> 0.4)
|
||||
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)
|
||||
erb (>= 4.0, < 7.0)
|
||||
excon (>= 1.0.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.99)
|
||||
google-apis-androidpublisher_v3 (~> 0.3)
|
||||
google-apis-playcustomapp_v1 (~> 0.1)
|
||||
google-cloud-env (>= 1.6.0, < 2.5.0)
|
||||
google-cloud-env (>= 1.6.0, < 2.0.0)
|
||||
google-cloud-storage (~> 1.31)
|
||||
highline (~> 2.0)
|
||||
irb (>= 1.8)
|
||||
http-cookie (~> 1.0.5)
|
||||
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)
|
||||
mutex_m (~> 0.3.0)
|
||||
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 (>= 3.4.0, < 4.0.0)
|
||||
security (~> 0.3)
|
||||
rubyzip (>= 2.0.0, < 3.0.0)
|
||||
security (= 0.1.5)
|
||||
simctl (~> 1.6.3)
|
||||
terminal-notifier (>= 3.1.0, < 4.0.0)
|
||||
terminal-table (~> 4)
|
||||
terminal-notifier (>= 2.0.0, < 3.0.0)
|
||||
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-travis-formatter (>= 0.0.3, < 2.0.0)
|
||||
fastlane-sirp (1.1.0)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.31)
|
||||
cgi
|
||||
fastlane-sirp (1.0.0)
|
||||
sysrandom (~> 1.0)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.110.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-apis-core (1.4.0)
|
||||
addressable (~> 2.9)
|
||||
faraday (~> 2.13)
|
||||
faraday-follow_redirects (~> 0.3)
|
||||
googleauth (~> 1.14)
|
||||
mini_mime (~> 1.1)
|
||||
multi_json (~> 1.11)
|
||||
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 (>= 0.16.2, < 2.a)
|
||||
httpclient (>= 2.8.1, < 3.a)
|
||||
mini_mime (~> 1.0)
|
||||
representable (~> 3.0)
|
||||
retriable (>= 3.1, < 5.0)
|
||||
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.70.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-cloud-core (1.9.0)
|
||||
retriable (>= 2.0, < 4.a)
|
||||
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.8.0)
|
||||
google-cloud-env (>= 1.0, < 3.a)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (2.4.1)
|
||||
base64 (~> 0.2)
|
||||
faraday (>= 1.0, < 3.a)
|
||||
google-cloud-errors (1.7.0)
|
||||
google-cloud-storage (1.62.1)
|
||||
google-cloud-env (1.6.0)
|
||||
faraday (>= 0.17.3, < 3.0)
|
||||
google-cloud-errors (1.5.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.1)
|
||||
googleauth (1.17.6)
|
||||
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.1.6)
|
||||
http-cookie (1.0.8)
|
||||
domain_name (~> 0.5)
|
||||
io-console (0.9.5)
|
||||
irb (1.18.0)
|
||||
pp (>= 0.6.0)
|
||||
prism (>= 1.3.0)
|
||||
rdoc (>= 4.0.0)
|
||||
reline (>= 0.4.2)
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
jmespath (1.6.2)
|
||||
json (2.21.2)
|
||||
jwt (3.3.0)
|
||||
json (2.18.0)
|
||||
jwt (2.10.2)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.21.2)
|
||||
multi_json (1.19.1)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
naturally (2.3.0)
|
||||
net-http (0.10.0)
|
||||
net-protocol (>= 0.3.0)
|
||||
uri (>= 0.11.1)
|
||||
net-protocol (0.4.0)
|
||||
timeout
|
||||
nkf (0.3.0)
|
||||
optparse (0.8.1)
|
||||
os (1.1.4)
|
||||
ostruct (0.6.3)
|
||||
plist (3.7.2)
|
||||
pp (0.6.4)
|
||||
prettyprint
|
||||
prettyprint (0.2.1)
|
||||
prism (1.9.0)
|
||||
pstore (0.3.0)
|
||||
public_suffix (7.0.5)
|
||||
rake (13.4.2)
|
||||
rbs (4.2.0)
|
||||
logger
|
||||
prism (>= 1.6.0)
|
||||
tsort
|
||||
rdoc (8.1.0)
|
||||
erb
|
||||
prism (>= 1.6.0)
|
||||
rbs (>= 4.0.0)
|
||||
tsort
|
||||
reline (0.7.0)
|
||||
io-console (~> 0.5)
|
||||
representable (3.3.1)
|
||||
public_suffix (6.0.2)
|
||||
rake (13.3.1)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (4.2.0)
|
||||
retriable (3.1.2)
|
||||
rexml (3.4.4)
|
||||
rouge (3.28.0)
|
||||
rubyzip (3.7.0)
|
||||
security (0.4.0)
|
||||
signet (0.22.1)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
security (0.1.5)
|
||||
signet (0.21.0)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.5, < 3.a)
|
||||
jwt (>= 1.5, < 4.0)
|
||||
multi_json (~> 1.10)
|
||||
simctl (1.6.10)
|
||||
CFPropertyList
|
||||
naturally
|
||||
terminal-notifier (3.1.0)
|
||||
terminal-table (4.0.0)
|
||||
unicode-display_width (>= 1.1.1, < 4)
|
||||
timeout (0.6.1)
|
||||
sysrandom (1.0.5)
|
||||
terminal-notifier (2.0.0)
|
||||
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)
|
||||
tty-cursor (~> 0.7)
|
||||
uber (0.1.0)
|
||||
unicode-display_width (3.3.0)
|
||||
unicode-emoji (~> 4.3)
|
||||
unicode-emoji (4.3.0)
|
||||
uri (1.1.2)
|
||||
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)
|
||||
rouge (~> 3.28.0)
|
||||
@@ -260,8 +222,8 @@ PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
abbrev
|
||||
fastlane
|
||||
fastlane-plugin-huawei_appgallery_connect
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.4
|
||||
@@ -4,7 +4,7 @@
|
||||
-->
|
||||
# [Nextcloud](https://nextcloud.com) Android app :iphone:
|
||||
|
||||
[](https://api.reuse.software/info/github.com/nextcloud/android) [](https://drone.nextcloud.com/nextcloud/android) [](https://github.com/nextcloud/android/releases/latest)
|
||||
[](https://api.reuse.software/info/github.com/nextcloud/android) [](https://drone.nextcloud.com/nextcloud/android) [](https://app.codacy.com/gh/nextcloud/android/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade) [](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"
|
||||
@@ -48,7 +48,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
|
||||
|
||||
@@ -29,12 +29,6 @@ precedence = "aggregate"
|
||||
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"]
|
||||
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"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
[](https://api.reuse.software/info/github.com/nextcloud/android)
|
||||
[](https://drone.nextcloud.com/nextcloud/android)
|
||||
[](https://app.codacy.com/gh/nextcloud/android/dashboard)
|
||||
[](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)
|
||||
|
||||
+1
-2
@@ -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
|
||||
+86
-98
@@ -1,36 +1,34 @@
|
||||
/*
|
||||
* 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.android.build.gradle.internal.api.ApkVariantOutputImpl
|
||||
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")
|
||||
|
||||
val allAbis = listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
|
||||
val localDebugAbis = when (System.getProperty("os.arch")) {
|
||||
"aarch64", "arm64" -> listOf("arm64-v8a")
|
||||
else -> listOf("arm64-v8a", "x86_64")
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
alias(libs.plugins.spotless)
|
||||
alias(libs.plugins.kapt)
|
||||
alias(libs.plugins.ksp)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.kotlin.parcelize)
|
||||
alias(libs.plugins.jetbrains.kotlin.android)
|
||||
alias(libs.plugins.spotbugs)
|
||||
alias(libs.plugins.detekt)
|
||||
// needed to make renovate run without shot, as shot requires Android SDK
|
||||
@@ -48,30 +46,27 @@ configurations.configureEach {
|
||||
exclude(group = "org.jetbrains", module = "annotations-java5")
|
||||
|
||||
resolutionStrategy {
|
||||
force(libs.objenesis)
|
||||
|
||||
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."
|
||||
)
|
||||
}
|
||||
if (requested.group == "org.checkerframework" && requested.name != "checker-compat-qual") {
|
||||
useVersion(libs.versions.checker.get())
|
||||
because("https://github.com/google/ExoPlayer/issues/10007")
|
||||
} else if (requested.group == "org.jacoco") {
|
||||
useVersion(libs.versions.jacoco.get())
|
||||
} else if (requested.group == "commons-logging" && requested.name == "commons-logging") {
|
||||
useTarget(libs.slfj)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// semantic versioning for version code
|
||||
val versionMajor = 3
|
||||
val versionMinor = 36
|
||||
val versionPatch = 0
|
||||
val versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
val ndkEnv = buildMap {
|
||||
file("${project.rootDir}/ndk.env").readLines().forEach {
|
||||
val (key, value) = it.split("=")
|
||||
@@ -79,19 +74,18 @@ val ndkEnv = buildMap {
|
||||
}
|
||||
}
|
||||
|
||||
val ncTestServerUsername = providers.gradleProperty("NC_TEST_SERVER_USERNAME").get()
|
||||
val ncTestServerPassword = providers.gradleProperty("NC_TEST_SERVER_PASSWORD").get()
|
||||
val ncTestServerBaseUrl = providers.gradleProperty("NC_TEST_SERVER_BASEURL").get()
|
||||
val configProps = Properties().apply {
|
||||
val file = rootProject.file(".gradle/config.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
|
||||
// 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"
|
||||
@@ -99,28 +93,36 @@ android {
|
||||
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
|
||||
compileSdk = 37
|
||||
targetSdk = 36
|
||||
// mayor.minor.hotfix.increment (for increment: 01-50=Alpha / 51-89=RC / 90-99=stable)
|
||||
// xx .xxx .xx .xx
|
||||
versionCode = 350010050
|
||||
versionName = "35.1.0 Alpha 51"
|
||||
compileSdk = 36
|
||||
|
||||
buildConfigField("boolean", "CI", ciBuild.toString())
|
||||
buildConfigField("boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString())
|
||||
|
||||
javaCompileOptions.annotationProcessorOptions {
|
||||
arguments += mapOf("room.schemaLocation" to "$projectDir/schemas")
|
||||
}
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
testInstrumentationRunner = if (shotTest) "com.karumi.shot.ShotTestRunner"
|
||||
else "com.nextcloud.client.TestRunner"
|
||||
|
||||
testInstrumentationRunnerArguments += mapOf(
|
||||
"TEST_SERVER_URL" to ncTestServerBaseUrl.toString(),
|
||||
"TEST_SERVER_USERNAME" to ncTestServerUsername.toString(),
|
||||
"TEST_SERVER_PASSWORD" to ncTestServerPassword.toString()
|
||||
)
|
||||
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
|
||||
|
||||
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
|
||||
|
||||
@@ -128,21 +130,18 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
optimization {
|
||||
enable = true
|
||||
}
|
||||
buildConfigField("String", "NC_TEST_SERVER_DATA_STRING", "\"\"")
|
||||
ndk {
|
||||
abiFilters += allAbis
|
||||
}
|
||||
}
|
||||
|
||||
debug {
|
||||
enableUnitTestCoverage = project.hasProperty("coverage")
|
||||
enableAndroidTestCoverage = project.hasProperty("coverage")
|
||||
resConfigs("xxxhdpi")
|
||||
ndk {
|
||||
abiFilters += if (ciBuild) allAbis else localDebugAbis
|
||||
}
|
||||
|
||||
buildConfigField(
|
||||
"String",
|
||||
"NC_TEST_SERVER_DATA_STRING",
|
||||
"\"nc://login/user:${ncTestServerUsername}&password:${ncTestServerPassword}&server:${ncTestServerBaseUrl}\""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +178,12 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
applicationVariants.configureEach {
|
||||
outputs.configureEach {
|
||||
if (this is ApkVariantOutputImpl) this.outputFileName = "${this.baseName}-${this.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.isReturnDefaultValues = true
|
||||
animationsDisabled = true
|
||||
@@ -193,15 +198,15 @@ android {
|
||||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
dataBinding = true
|
||||
viewBinding = true
|
||||
aidl = true
|
||||
compose = true
|
||||
prefab = true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
lint {
|
||||
@@ -222,9 +227,7 @@ android {
|
||||
"MissingQuantity",
|
||||
"IconXmlAndPng",
|
||||
"SelectedPhotoAccess",
|
||||
"UnsafeIntentLaunch",
|
||||
"OldTargetApi",
|
||||
"AndroidGradlePluginVersion"
|
||||
"UnsafeIntentLaunch"
|
||||
)
|
||||
)
|
||||
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
|
||||
@@ -240,12 +243,11 @@ android {
|
||||
|
||||
}
|
||||
|
||||
kapt.useBuildCache = true
|
||||
|
||||
ksp.arg("room.schemaLocation", "$projectDir/schemas")
|
||||
|
||||
// Configure KSP for test variants
|
||||
ksp.arg("dagger.moduleName", project.name)
|
||||
|
||||
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_21)
|
||||
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
|
||||
|
||||
spotless.kotlin {
|
||||
target("**/*.kt")
|
||||
@@ -269,7 +271,6 @@ spotbugs {
|
||||
}
|
||||
|
||||
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
|
||||
@@ -281,7 +282,6 @@ tasks.register<Checkstyle>("checkstyle") {
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -317,7 +317,10 @@ tasks.withType<SpotBugsTask>().configureEach {
|
||||
}
|
||||
}
|
||||
|
||||
// Run the compiler as a separate process
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.isFork = true
|
||||
|
||||
// Enable Incremental Compilation
|
||||
options.isIncremental = true
|
||||
}
|
||||
@@ -334,17 +337,6 @@ 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) {
|
||||
@@ -362,7 +354,6 @@ dependencies {
|
||||
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)
|
||||
@@ -389,7 +380,6 @@ dependencies {
|
||||
|
||||
// region UI
|
||||
implementation(libs.bundles.ui)
|
||||
implementation(libs.browser)
|
||||
// endregion
|
||||
|
||||
// region Worker
|
||||
@@ -399,7 +389,6 @@ dependencies {
|
||||
|
||||
// region Lifecycle
|
||||
implementation(libs.lifecycle.viewmodel.ktx)
|
||||
implementation(libs.lifecycle.process)
|
||||
implementation(libs.lifecycle.service)
|
||||
implementation(libs.lifecycle.runtime.ktx)
|
||||
// endregion
|
||||
@@ -409,14 +398,12 @@ dependencies {
|
||||
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)
|
||||
@@ -428,22 +415,23 @@ dependencies {
|
||||
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"))
|
||||
}
|
||||
"gplayImplementation"(project(":appscan"))
|
||||
"huaweiImplementation"(project(":appscan"))
|
||||
"qaImplementation"(project(":appscan"))
|
||||
// endregion
|
||||
|
||||
// region SpotBugs
|
||||
@@ -455,15 +443,12 @@ dependencies {
|
||||
implementation(libs.dagger)
|
||||
implementation(libs.dagger.android)
|
||||
implementation(libs.dagger.android.support)
|
||||
ksp(libs.dagger.compiler)
|
||||
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
|
||||
@@ -476,6 +461,7 @@ dependencies {
|
||||
|
||||
// region Markdown rendering
|
||||
implementation(libs.bundles.markdown.rendering)
|
||||
kapt(libs.prism4j.bundler)
|
||||
// endregion
|
||||
|
||||
// region Image cropping / rotation
|
||||
@@ -488,7 +474,7 @@ dependencies {
|
||||
|
||||
// region iCal4j
|
||||
implementation(libs.ical4j) {
|
||||
exclude(group = "commons-logging")
|
||||
listOf("org.apache.commons", "commons-logging").forEach { groupName -> exclude(group = groupName) }
|
||||
}
|
||||
// endregion
|
||||
|
||||
@@ -514,16 +500,18 @@ dependencies {
|
||||
|
||||
// region Kotlin
|
||||
implementation(libs.kotlin.stdlib)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
// 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)
|
||||
"gplayImplementation"(libs.bundles.gplay)
|
||||
// endregion
|
||||
|
||||
// region common
|
||||
// region UI
|
||||
implementation(libs.ui)
|
||||
implementation(libs.common.core)
|
||||
// endregion
|
||||
|
||||
// region Image loading
|
||||
|
||||
+10
-10
@@ -53,9 +53,9 @@ complexity:
|
||||
active: false
|
||||
threshold: 10
|
||||
includeStaticDeclarations: false
|
||||
CyclomaticComplexMethod:
|
||||
ComplexMethod:
|
||||
active: true
|
||||
threshold: 15
|
||||
threshold: 10
|
||||
ignoreSingleWhenExpression: false
|
||||
ignoreSimpleWhenEntries: false
|
||||
excludes: ['**/androidTest/**']
|
||||
@@ -67,10 +67,10 @@ complexity:
|
||||
threshold: 600
|
||||
LongMethod:
|
||||
active: true
|
||||
threshold: 120
|
||||
threshold: 60
|
||||
excludes: ['**/androidTest/**']
|
||||
LongParameterList:
|
||||
active: false
|
||||
active: true
|
||||
functionThreshold: 7
|
||||
constructorThreshold: 6
|
||||
ignoreDefaultParameters: false
|
||||
@@ -87,7 +87,7 @@ complexity:
|
||||
excludeStringsWithLessThan5Characters: true
|
||||
ignoreStringsRegex: '$^'
|
||||
TooManyFunctions:
|
||||
active: false
|
||||
active: true
|
||||
thresholdInFiles: 15
|
||||
thresholdInClasses: 15
|
||||
thresholdInInterfaces: 15
|
||||
@@ -158,7 +158,7 @@ exceptions:
|
||||
ThrowingNewInstanceOfSameException:
|
||||
active: false
|
||||
TooGenericExceptionCaught:
|
||||
active: false
|
||||
active: true
|
||||
exceptionNames:
|
||||
- ArrayIndexOutOfBoundsException
|
||||
- Error
|
||||
@@ -170,7 +170,7 @@ exceptions:
|
||||
- Throwable
|
||||
allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
|
||||
TooGenericExceptionThrown:
|
||||
active: false
|
||||
active: true
|
||||
exceptionNames:
|
||||
- Error
|
||||
- Exception
|
||||
@@ -226,7 +226,7 @@ naming:
|
||||
active: true
|
||||
packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$'
|
||||
TopLevelPropertyNaming:
|
||||
active: false
|
||||
active: true
|
||||
constantPattern: '[A-Z][_A-Z0-9]*'
|
||||
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
|
||||
privatePropertyPattern: '(_)?[A-Za-z][A-Za-z0-9]*'
|
||||
@@ -346,7 +346,7 @@ style:
|
||||
NestedClassesVisibility:
|
||||
active: false
|
||||
NewLineAtEndOfFile:
|
||||
active: false
|
||||
active: true
|
||||
NoTabs:
|
||||
active: false
|
||||
OptionalAbstractKeyword:
|
||||
@@ -362,7 +362,7 @@ style:
|
||||
RedundantVisibilityModifierRule:
|
||||
active: false
|
||||
ReturnCount:
|
||||
active: false
|
||||
active: true
|
||||
max: 2
|
||||
excludedFunctions: [equals]
|
||||
excludeLabeled: false
|
||||
|
||||
+1
-10
@@ -15,6 +15,7 @@
|
||||
</issue>
|
||||
<issue id="InvalidPackage">
|
||||
<ignore path="**/freemarker-2.*.*.jar" />
|
||||
<ignore path="**/nnio-0.2.jar"/>
|
||||
<ignore path="**/bcpkix-jdk15on-1.69.jar" />
|
||||
</issue>
|
||||
|
||||
@@ -75,11 +76,6 @@
|
||||
<ignore path="build" />
|
||||
</issue>
|
||||
|
||||
<!-- Dagger factories generated for media3 @UnstableApi types cannot carry an @OptIn annotation. -->
|
||||
<issue id="UnsafeOptInUsageError" severity="error">
|
||||
<ignore path="build" />
|
||||
</issue>
|
||||
|
||||
<issue id="ObsoleteLintCustomCheck" severity="warning">
|
||||
<ignore path="**/fragment-1.2.5/**/lint.jar" />
|
||||
<ignore path="**/work-runtime-2.**/**/lint.jar" />
|
||||
@@ -90,11 +86,6 @@
|
||||
<ignore path="**/appcompat-1.**/**/lint.jar" />
|
||||
</issue>
|
||||
|
||||
<!-- Lint reads abiFilters as source text and cannot resolve allAbis; local debug builds skip x86 on purpose. -->
|
||||
<issue id="ChromeOsAbiSupport">
|
||||
<ignore path="build.gradle.kts" />
|
||||
</issue>
|
||||
|
||||
<issue id="Aligned16KB">
|
||||
<ignore path="**/arm64-v8a/libmockkjvmtiagent.so" />
|
||||
</issue>
|
||||
|
||||
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 renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 1541 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user