Compare commits
232
Commits
dev-20260410
...
fix/ci
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d99e601a09 | ||
|
|
85c047ee85 | ||
|
|
650d5dd182 | ||
|
|
452955422a | ||
|
|
0d577ec6b7 | ||
|
|
5fc0d91297 | ||
|
|
4a1e7a8223 | ||
|
|
e0e6fdcbcc | ||
|
|
1fed1f5f2f | ||
|
|
3d516d0eab | ||
|
|
b4050dd064 | ||
|
|
af0ddce6dc | ||
|
|
19989c09ee | ||
|
|
28d1186cdc | ||
|
|
ba538498b3 | ||
|
|
0f04e2fec1 | ||
|
|
2b28c35522 | ||
|
|
9d2e4a4777 | ||
|
|
5835e58471 | ||
|
|
6ec3e0b6ad | ||
|
|
98e6d4a660 | ||
|
|
2ab8907369 | ||
|
|
b5f872c3e3 | ||
|
|
febeae7674 | ||
|
|
44737c27eb | ||
|
|
f4a0ae095e | ||
|
|
6e6713367d | ||
|
|
08b8441c6e | ||
|
|
aa8ee87e34 | ||
|
|
af91398346 | ||
|
|
03f654e5eb | ||
|
|
cc5313648c | ||
|
|
81132d47be | ||
|
|
7fa65aed9d | ||
|
|
a23d55c926 | ||
|
|
776aa3b664 | ||
|
|
65b495c4fb | ||
|
|
42e262101f | ||
|
|
5c655f9b9c | ||
|
|
9ddf9a9604 | ||
|
|
31ce3c656c | ||
|
|
65711ffdfe | ||
|
|
aee38c95f2 | ||
|
|
7da42ea18b | ||
|
|
f079809fcc | ||
|
|
bd2681193c | ||
|
|
5055086f16 | ||
|
|
78bd8ba61a | ||
|
|
01344144e7 | ||
|
|
51a52f051c | ||
|
|
f32a12f26a | ||
|
|
3d7474b2e6 | ||
|
|
54549a00be | ||
|
|
3b4ede2d81 | ||
|
|
3a5bb79386 | ||
|
|
e82b817cb7 | ||
|
|
1ceb30e621 | ||
|
|
c80f1f389b | ||
|
|
b716c74d97 | ||
|
|
671412cc47 | ||
|
|
908a0dda0e | ||
|
|
cef0c69d29 | ||
|
|
1048746b95 | ||
|
|
1d76e45a13 | ||
|
|
f81404b43d | ||
|
|
f536eee932 | ||
|
|
13d40d696a | ||
|
|
6a4885a334 | ||
|
|
39abf4855f | ||
|
|
f7c9d882a7 | ||
|
|
b434283998 | ||
|
|
1b328b50a2 | ||
|
|
f4775b7e2c | ||
|
|
ba388474fd | ||
|
|
b62f0154dd | ||
|
|
f925ba469b | ||
|
|
5b65d106c8 | ||
|
|
0a06757693 | ||
|
|
8d416a6205 | ||
|
|
ac26ffdc45 | ||
|
|
2f700545a8 | ||
|
|
58299f630d | ||
|
|
f85607c355 | ||
|
|
f6ce330d03 | ||
|
|
710ad4b3d2 | ||
|
|
f094cd8bc9 | ||
|
|
bf7bb83a56 | ||
|
|
fe2618adb3 | ||
|
|
25e0726cd3 | ||
|
|
2807326f6c | ||
|
|
41fcf0c648 | ||
|
|
26449e24c7 | ||
|
|
201e6b3d37 | ||
|
|
3ba783e099 | ||
|
|
2eca9791f7 | ||
|
|
cb17d792d0 | ||
|
|
f57d9fcd1f | ||
|
|
239c4e02ae | ||
|
|
2dba050852 | ||
|
|
27424fa517 | ||
|
|
abe4481956 | ||
|
|
2d2377e5ba | ||
|
|
ebeb5f0705 | ||
|
|
4bccad2714 | ||
|
|
36c63b8a0c | ||
|
|
5c6f59c7cf | ||
|
|
f779a6c2d9 | ||
|
|
c33328e6ef | ||
|
|
f142e66e7d | ||
|
|
6089dd0946 | ||
|
|
e3c8b64e9c | ||
|
|
2c237ea3b0 | ||
|
|
504fb1863b | ||
|
|
f6616ecb38 | ||
|
|
a6a541ff5e | ||
|
|
0a91cb51b7 | ||
|
|
9121a07a10 | ||
|
|
d8c62d4ff9 | ||
|
|
84ed04ad96 | ||
|
|
530f2e607e | ||
|
|
8c278c1171 | ||
|
|
dfcd7f4311 | ||
|
|
d8d06f2546 | ||
|
|
09f41024a8 | ||
|
|
1c88f94dbc | ||
|
|
177d4c06d8 | ||
|
|
1899ca7ed1 | ||
|
|
ee02b00710 | ||
|
|
04dea791bb | ||
|
|
650144fdcc | ||
|
|
4f130835a8 | ||
|
|
2d9aa7fa96 | ||
|
|
f856950058 | ||
|
|
616c1c84e7 | ||
|
|
4e035ceed4 | ||
|
|
17271d8ad2 | ||
|
|
ba809dc646 | ||
|
|
7ab30f08d5 | ||
|
|
2b2d4c18d9 | ||
|
|
f92f514046 | ||
|
|
fc145e1e22 | ||
|
|
329e4ff23f | ||
|
|
f3e90cf07c | ||
|
|
bf9ada5efe | ||
|
|
fa10867938 | ||
|
|
8c86b6a92b | ||
|
|
6e7d615a71 | ||
|
|
8595e4cf8d | ||
|
|
37eca1a5d5 | ||
|
|
562e799d94 | ||
|
|
ae89d1616d | ||
|
|
cea31587ba | ||
|
|
3b90fb18d2 | ||
|
|
a66f4d640e | ||
|
|
3c52e2cef1 | ||
|
|
d818169785 | ||
|
|
3dfb266d73 | ||
|
|
6667a9987e | ||
|
|
faec92aff6 | ||
|
|
945bf3b098 | ||
|
|
73cf745aa3 | ||
|
|
bb4c135bc3 | ||
|
|
a7cd586a0f | ||
|
|
328102d660 | ||
|
|
4d94b8164a | ||
|
|
8a1fc07362 | ||
|
|
6d193c3fb0 | ||
|
|
2928d18aa6 | ||
|
|
10079e53e4 | ||
|
|
057a8938b3 | ||
|
|
f49ebb29e1 | ||
|
|
fa67776a18 | ||
|
|
f9c69cc96e | ||
|
|
624b0ab7a0 | ||
|
|
b6e98972a7 | ||
|
|
7109bf2016 | ||
|
|
1e5ad690d2 | ||
|
|
4e58422797 | ||
|
|
d2037fa81a | ||
|
|
7f4a56c8e2 | ||
|
|
ae88b69489 | ||
|
|
6491900c1e | ||
|
|
e9744a88c5 | ||
|
|
191f1fb9cc | ||
|
|
e0fe3d0eca | ||
|
|
ab724ab84d | ||
|
|
a1d185040b | ||
|
|
3152e355d4 | ||
|
|
b56e48525a | ||
|
|
c85964ae79 | ||
|
|
ca0edea70c | ||
|
|
61e3f48875 | ||
|
|
d62f966042 | ||
|
|
6707e04d5c | ||
|
|
bf9d6cf9c0 | ||
|
|
699380e546 | ||
|
|
e37b4e98e9 | ||
|
|
75820ac66f | ||
|
|
8b7dc1c512 | ||
|
|
cbbb4ebeff | ||
|
|
5149c5ee99 | ||
|
|
f521a020c0 | ||
|
|
99bd48144b | ||
|
|
e46acb004a | ||
|
|
5f9756987d | ||
|
|
ac7d90ae61 | ||
|
|
f210498da7 | ||
|
|
df58beff81 | ||
|
|
867f54d6df | ||
|
|
2f1ea4998a | ||
|
|
721ce87815 | ||
|
|
e89f3a102f | ||
|
|
937317eac7 | ||
|
|
d9d81f9876 | ||
|
|
2cbf1ea3e4 | ||
|
|
d085e852c9 | ||
|
|
dc9727a4d0 | ||
|
|
f62c7e459d | ||
|
|
fa0ebc2223 | ||
|
|
4301bf78e7 | ||
|
|
25911dcdab | ||
|
|
1de358fd63 | ||
|
|
7f44e91d97 | ||
|
|
8a5ded985e | ||
|
|
b808845bfd | ||
|
|
16486bf7b3 | ||
|
|
66ce69e2ac | ||
|
|
4917913178 | ||
|
|
6d88aa1b1f | ||
|
|
da3f26206b | ||
|
|
98ab726e48 | ||
|
|
bea0aa2b0c |
No files matched your search
@@ -1,4 +1,4 @@
|
||||
FROM ubuntu:noble@sha256:186072bba1b2f436cbb91ef2567abca677337cfc786c86e107d25b7072feef0c
|
||||
FROM ubuntu:resolute@sha256:5e275723f82c67e387ba9e3c24baa0abdcb268917f276a0561c97bef9450d0b4
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV ANDROID_HOME=/usr/lib/android-sdk
|
||||
@@ -16,5 +16,4 @@ 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"
|
||||
echo "org.gradle.configureondemand=true" >> "$HOME/.gradle/gradle.properties"
|
||||
@@ -72,6 +72,5 @@ jobs:
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
|
||||
echo "org.gradle.configureondemand=true"
|
||||
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 }}"
|
||||
@@ -35,5 +35,4 @@ jobs:
|
||||
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 }}
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
|
||||
uses: github/codeql-action/init@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 21
|
||||
@@ -57,4 +57,4 @@ jobs:
|
||||
echo "org.gradle.jvmargs=-Xmx3g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew --no-daemon assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
|
||||
uses: github/codeql-action/analyze@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
echo "org.gradle.jvmargs=-Xmx3g -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"
|
||||
echo "org.gradle.caching=true; org.gradle.parallel=true; 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"
|
||||
|
||||
@@ -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@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
|
||||
uses: github/codeql-action/upload-sarif@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -28,14 +28,14 @@ jobs:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
- name: AVD cache
|
||||
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
|
||||
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
@@ -73,7 +73,6 @@ jobs:
|
||||
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 generic flavor
|
||||
run: ./gradlew assembleGenericDebug
|
||||
@@ -102,7 +101,7 @@ jobs:
|
||||
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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/jacoco/jacocoTestGplayDebugUnitTestReport/html/
|
||||
@@ -67,6 +67,7 @@ fastlane/Fastfile
|
||||
obj/
|
||||
*.o
|
||||
*.a
|
||||
.cxx/
|
||||
|
||||
# Testing & coverage
|
||||
.kotlin/
|
||||
|
||||
@@ -1,42 +1,49 @@
|
||||
<!--
|
||||
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
- SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
# Agents.md
|
||||
<!--
|
||||
- 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' main package of the project.
|
||||
'.app/src/main/java/com/nextcloud/utils/extensions' package used for creating extensions.
|
||||
'./app/src/main/res/values' used for 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).
|
||||
|
||||
## 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.
|
||||
|
||||
```plaintext
|
||||
SPDX-FileCopyrightText: <YEAR> Nextcloud GmbH and Nextcloud contributors
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
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`).
|
||||
|
||||
## 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
|
||||
/*
|
||||
@@ -55,9 +62,9 @@ XML:
|
||||
~ 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.
|
||||
```
|
||||
|
||||
Avoid creating source files that implement multiple types; instead, place each type in its own dedicated source file.
|
||||
|
||||
## Design
|
||||
|
||||
@@ -65,7 +72,58 @@ Avoid creating source files that implement multiple types; instead, place each t
|
||||
- In addition to any Material Design wording guidelines, follow the Nextcloud wording guidelines at https://docs.nextcloud.com/server/latest/developer_manual/design/foundations.html#wording
|
||||
- Ensure the app works in both light and dark theme
|
||||
- Ensure the app works with different server primary colors by using the colorTheme of viewThemeUtils
|
||||
|
||||
|
||||
## Architecture & Patterns
|
||||
|
||||
### Jetpack Compose
|
||||
|
||||
Modern UI is built with Jetpack Compose (Material 3). Key directories:
|
||||
- `com.nextcloud.ui.composeActivity` - Activities hosting Compose content
|
||||
- `com.nextcloud.ui.composeComponents` - Reusable Compose components
|
||||
- `com.nextcloud.client.assistant` - Compose-based Assistant screens and features
|
||||
|
||||
Use `StateFlow` and `MutableStateFlow` in ViewModels for state management. Collect state in Compose functions with `collectAsState()`.
|
||||
|
||||
### Dependency Injection
|
||||
|
||||
Uses Dagger 2 for major Android components (`Activity`, `Fragment`, `Service`, `BroadcastReceiver`, `ContentProvider`). Manual constructor injection for other components.
|
||||
|
||||
### Extension Functions
|
||||
|
||||
The `com.nextcloud.utils.extensions` package contains helper extensions organized by type (e.g., `FileExtensions.kt`, `StringExtensions.kt`, `ViewExtensions.kt`). Create focused extension files rather than putting multiple types in one file.
|
||||
|
||||
## Testing
|
||||
|
||||
### Unit Tests (`./app/src/test/`)
|
||||
- Small, isolated tests without Android SDK
|
||||
- Use Mockito with `mockito-kotlin` for easier mocking
|
||||
- Recommended command: `./gradlew jacocoTestGplayDebugUnitTest`
|
||||
- Tests use JUnit 4 with `@Test`, `@Before`, `@After` annotations
|
||||
|
||||
### Instrumented Tests (`./app/src/androidTest/`)
|
||||
- Tests requiring Android SDK (Activities, Fragments, database access)
|
||||
- Use Espresso for UI testing
|
||||
- Tests should inherit from `AbstractOnServerIT` if they need server communication
|
||||
- Always create a separate test user on test server to avoid data interference
|
||||
- Run with: `./gradlew createGplayDebugCoverageReport -Pcoverage=true`
|
||||
- Run specific test class: `./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=<fully.qualified.ClassName>`
|
||||
- Run one test method: `./gradlew createGplayDebugCoverageReport -Pcoverage=true -Pandroid.testInstrumentationRunnerArguments.class=<fully.qualified.ClassName>#methodName`
|
||||
|
||||
### Screenshot Tests (Shot)
|
||||
- Enabled via `SHOT_TEST=true` environment variable
|
||||
- Use: `scripts/androidScreenshotTest` to check, `scripts/updateScreenshots.sh` to regenerate
|
||||
- CI renders shadows differently; 0.5% tolerance is configured
|
||||
|
||||
## Code Quality Tools
|
||||
|
||||
All code is validated with the following tools. Fix findings in modified files:
|
||||
- **lint** - Android linting (configured in `app/lint.xml`)
|
||||
- **spotbugsGplayDebug** - Bug detection for Gplay variant
|
||||
- **detekt** - Kotlin code analysis (configured in `app/detekt.yml`)
|
||||
- **spotlessKotlinCheck** - Code formatting with ktlint
|
||||
|
||||
Run all checks with: `./gradlew check`
|
||||
|
||||
## Commit and Pull Request Guidelines
|
||||
|
||||
### Commits
|
||||
@@ -90,25 +148,25 @@ Avoid creating source files that implement multiple types; instead, place each t
|
||||
```
|
||||
|
||||
Pattern with roles: `AI-assistant: <coding-agent> <agent-version> (<role>: <model-name> <model-version>, <role>: <model-name> <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 line of code per file.
|
||||
|
||||
- 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.
|
||||
- Do not use decorative section-divider comments of any kind (e.g. `// ── Title ───`, `// ------`, `// ======`).
|
||||
- Every new file must end with exactly one empty trailing line (no more, no less).
|
||||
- Do not add comments, documentation for every function you created instead make it self explanatory as much as possible.
|
||||
- Create models, states in different files instead of doing it one single file.
|
||||
- Do not use magic number.
|
||||
- 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.
|
||||
- Every new file must end with exactly one empty trailing line (no more, no less).
|
||||
- Do not add comments, documentation for every function you created instead make it self explanatory as much as possible.
|
||||
- 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.
|
||||
+7
-9
@@ -8,8 +8,8 @@ GEM
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1234.0)
|
||||
aws-sdk-core (3.244.0)
|
||||
aws-partitions (1.1241.0)
|
||||
aws-sdk-core (3.246.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
@@ -20,7 +20,7 @@ GEM
|
||||
aws-sdk-kms (1.123.0)
|
||||
aws-sdk-core (~> 3, >= 3.244.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.218.0)
|
||||
aws-sdk-s3 (1.220.0)
|
||||
aws-sdk-core (~> 3, >= 3.244.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
@@ -119,8 +119,7 @@ GEM
|
||||
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.31)
|
||||
cgi
|
||||
fastlane-sirp (1.0.0)
|
||||
sysrandom (~> 1.0)
|
||||
fastlane-sirp (1.1.0)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.54.0)
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
@@ -164,13 +163,13 @@ GEM
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
jmespath (1.6.2)
|
||||
json (2.19.3)
|
||||
json (2.19.4)
|
||||
jwt (2.10.2)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.19.1)
|
||||
multi_json (1.20.1)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
@@ -179,7 +178,7 @@ GEM
|
||||
os (1.1.4)
|
||||
plist (3.7.2)
|
||||
public_suffix (6.0.2)
|
||||
rake (13.3.1)
|
||||
rake (13.4.2)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
@@ -198,7 +197,6 @@ GEM
|
||||
simctl (1.6.10)
|
||||
CFPropertyList
|
||||
naturally
|
||||
sysrandom (1.0.5)
|
||||
terminal-notifier (2.0.0)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
/build
|
||||
/build
|
||||
/.cxx
|
||||
+13
-15
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
@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
|
||||
@@ -24,11 +23,9 @@ 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
|
||||
@@ -63,7 +60,7 @@ configurations.configureEach {
|
||||
|
||||
// semantic versioning for version code
|
||||
val versionMajor = 33
|
||||
val versionMinor = 1
|
||||
val versionMinor = 2
|
||||
val versionPatch = 0
|
||||
val versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
@@ -84,8 +81,13 @@ 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"]}"
|
||||
}
|
||||
}
|
||||
|
||||
namespace = "com.owncloud.android"
|
||||
testNamespace = "${namespace}.test"
|
||||
@@ -104,6 +106,10 @@ android {
|
||||
targetSdk = 36
|
||||
compileSdk = 36
|
||||
|
||||
ndk {
|
||||
abiFilters += listOf("arm64-v8a", "x86_64", "x86")
|
||||
}
|
||||
|
||||
buildConfigField("boolean", "CI", ciBuild.toString())
|
||||
buildConfigField("boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString())
|
||||
|
||||
@@ -168,12 +174,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
applicationVariants.configureEach {
|
||||
outputs.configureEach {
|
||||
if (this is ApkVariantOutputImpl) this.outputFileName = "${this.baseName}-${this.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.isReturnDefaultValues = true
|
||||
animationsDisabled = true
|
||||
@@ -217,7 +217,8 @@ android {
|
||||
"MissingQuantity",
|
||||
"IconXmlAndPng",
|
||||
"SelectedPhotoAccess",
|
||||
"UnsafeIntentLaunch"
|
||||
"UnsafeIntentLaunch",
|
||||
"OldTargetApi"
|
||||
)
|
||||
)
|
||||
htmlOutput = layout.buildDirectory.file("reports/lint/lint.html").get().asFile
|
||||
@@ -233,8 +234,6 @@ android {
|
||||
|
||||
}
|
||||
|
||||
kapt.useBuildCache = true
|
||||
|
||||
ksp.arg("room.schemaLocation", "$projectDir/schemas")
|
||||
|
||||
// Configure KSP for test variants
|
||||
@@ -457,7 +456,6 @@ dependencies {
|
||||
|
||||
// region Markdown rendering
|
||||
implementation(libs.bundles.markdown.rendering)
|
||||
kapt(libs.prism4j.bundler)
|
||||
// endregion
|
||||
|
||||
// region Image cropping / rotation
|
||||
|
||||
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.
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.
@@ -69,6 +69,12 @@ class BitmapDecodeTests {
|
||||
assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testToFileWhenPathIsNullShouldReturnNull() {
|
||||
val result = null.toFile()
|
||||
assertNull(result)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testToFileWhenFileDoesNotExistShouldReturnNull() {
|
||||
val nonExistentPath = tempDir.resolve("does_not_exist.jpg")
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import com.nextcloud.utils.extensions.webDavParentPath
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class WebDavParentPathTests {
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenCorrectParentShouldReturnOneLevelAbove() {
|
||||
assertEquals("/Photos/Vacation/", "/Photos/Vacation/beach.jpg".webDavParentPath())
|
||||
assertEquals("/work/docs/", "/work/docs/notes.txt".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenDeepNestingShouldReturnDirectParent() {
|
||||
assertEquals("/a/b/c/d/", "/a/b/c/d/e.txt".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenRootFileShouldReturnRoot() {
|
||||
assertEquals("/", "/image.png".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenSlashShouldReturnRoot() {
|
||||
assertEquals("/", "/".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenEmptyStringShouldReturnRoot() {
|
||||
assertEquals("/", "".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenOnlySlashesShouldReturnRoot() {
|
||||
assertEquals("/", "///".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenRelativePathShouldReturnOneLevelAbove() {
|
||||
assertEquals("Documents/", "Documents/file.pdf".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenSingleWordPathShouldReturnRoot() {
|
||||
assertEquals("/", "readme.md".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenTrailingSlashShouldReturnOneLevelAbove() {
|
||||
assertEquals("/Photos/", "/Photos/Vacation/".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenMultipleTrailingSlashesShouldReturnOneLevelAbove() {
|
||||
assertEquals("/Photos/", "/Photos/Vacation///".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenEncodedSpacesShouldPreserveEncoding() {
|
||||
assertEquals("/My%20Photos/", "/My%20Photos/beach%20photo.jpg".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenEncodedSpecialCharsShouldPreserveEncoding() {
|
||||
assertEquals("/files/%23reports/", "/files/%23reports/q1%262.pdf".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenUnicodeCharsShouldReturnOneLevelAbove() {
|
||||
assertEquals("/照片/假期/", "/照片/假期/海滩.jpg".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenSingleCharFileAtRootShouldReturnRoot() {
|
||||
assertEquals("/", "/a".webDavParentPath())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testWebDavParentPathWhenGivenSingleCharDirShouldReturnOneLevelAbove() {
|
||||
assertEquals("/a/", "/a/b".webDavParentPath())
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public abstract class AbstractIT {
|
||||
|
||||
@Before
|
||||
public void enableAccessibilityChecks() {
|
||||
androidx.test.espresso.accessibility.AccessibilityChecks.enable().setRunChecksFromRootView(true);
|
||||
androidx.test.espresso.accessibility.AccessibilityChecks.enable().setRunChecksFromRootView(false);
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*/
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
@@ -97,12 +95,7 @@ public class DownloadIT extends AbstractOnServerIT {
|
||||
assertTrue(new File(file1.getStoragePath()).exists());
|
||||
assertTrue(new File(file2.getStoragePath()).exists());
|
||||
|
||||
// test against hardcoded path to make sure that it is correct
|
||||
assertEquals("/storage/emulated/0/Android/media/"+targetContext.getPackageName()+"/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty.txt",
|
||||
file1.getStoragePath());
|
||||
assertEquals("/storage/emulated/0/Android/media/"+targetContext.getPackageName()+"/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty2.txt",
|
||||
file2.getStoragePath());
|
||||
assertEquals(FileStorageUtils.getDefaultSavePathFor(account.name, file1), file1.getStoragePath());
|
||||
assertEquals(FileStorageUtils.getDefaultSavePathFor(account.name, file2), file2.getStoragePath());
|
||||
}
|
||||
}
|
||||
+12
-5
@@ -32,10 +32,12 @@ import com.owncloud.android.operations.UploadFileOperation
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.junit.MockitoRule
|
||||
import java.io.File
|
||||
import java.util.Random
|
||||
import java.util.UUID
|
||||
@@ -47,6 +49,9 @@ import java.util.function.Supplier
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@SmallTest
|
||||
class UploadStorageManagerTest : AbstractIT() {
|
||||
@get:Rule
|
||||
val mockitoRule: MockitoRule = MockitoJUnit.rule()
|
||||
|
||||
private lateinit var uploadsStorageManager: UploadsStorageManager
|
||||
|
||||
@Mock
|
||||
@@ -58,8 +63,6 @@ class UploadStorageManagerTest : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
|
||||
val instrumentationCtx = ApplicationProvider.getApplicationContext<Context>()
|
||||
val contentResolver = instrumentationCtx.contentResolver
|
||||
uploadsStorageManager = UploadsStorageManager(currentAccountProvider, contentResolver)
|
||||
@@ -233,7 +236,11 @@ class UploadStorageManagerTest : AbstractIT() {
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
deleteAllUploads()
|
||||
userAccountManager.removeUser(user2)
|
||||
if (::uploadsStorageManager.isInitialized) {
|
||||
deleteAllUploads()
|
||||
}
|
||||
if (::userAccountManager.isInitialized && ::user2.isInitialized) {
|
||||
userAccountManager.removeUser(user2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.notifications.models.Action
|
||||
import com.owncloud.android.lib.resources.notifications.models.Notification
|
||||
import com.owncloud.android.lib.resources.notifications.models.RichObject
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Test
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
class NotificationsActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.NotificationsActivityIT"
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.populateList(ArrayList())
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@SuppressWarnings("MagicNumber")
|
||||
fun showNotifications() {
|
||||
val date = GregorianCalendar()
|
||||
date.set(2005, 4, 17, 10, 35, 30) // random date
|
||||
|
||||
val notifications = ArrayList<Notification>()
|
||||
notifications.add(
|
||||
Notification(
|
||||
1,
|
||||
"files",
|
||||
"user",
|
||||
date.time,
|
||||
"objectType",
|
||||
"objectId",
|
||||
"App recommendation: Tasks",
|
||||
"SubjectRich",
|
||||
HashMap<String, RichObject>(),
|
||||
"Sync tasks from various devices with your Nextcloud and edit them online.",
|
||||
"MessageRich",
|
||||
HashMap<String, RichObject>(),
|
||||
"link",
|
||||
"icon",
|
||||
ArrayList<Action>()
|
||||
)
|
||||
)
|
||||
|
||||
val actions = ArrayList<Action>().apply {
|
||||
add(Action("Send usage", "link", "url", true))
|
||||
add(Action("Not now", "link", "url", false))
|
||||
}
|
||||
|
||||
notifications.add(
|
||||
Notification(
|
||||
1,
|
||||
"files",
|
||||
"user",
|
||||
date.time,
|
||||
"objectType",
|
||||
"objectId",
|
||||
"Help improve Nextcloud",
|
||||
"SubjectRich",
|
||||
HashMap<String, RichObject>(),
|
||||
"Do you want to help us to improve Nextcloud" +
|
||||
" by providing some anonymize data about your setup and usage?",
|
||||
"MessageRich",
|
||||
HashMap<String, RichObject>(),
|
||||
"link",
|
||||
"icon",
|
||||
actions
|
||||
)
|
||||
)
|
||||
|
||||
val moreAction = ArrayList<Action>().apply {
|
||||
add(Action("Send usage", "link", "url", true))
|
||||
add(Action("Not now", "link", "url", false))
|
||||
add(Action("third action", "link", "url", false))
|
||||
add(Action("Delay", "link", "url", false))
|
||||
}
|
||||
|
||||
notifications.add(
|
||||
Notification(
|
||||
2,
|
||||
"files",
|
||||
"user",
|
||||
date.time,
|
||||
"objectType",
|
||||
"objectId",
|
||||
"Help improve Nextcloud",
|
||||
"SubjectRich",
|
||||
HashMap<String, RichObject>(),
|
||||
"Do you want to help us to improve Nextcloud by providing some anonymize data about your setup and " +
|
||||
"usage?",
|
||||
"MessageRich",
|
||||
HashMap<String, RichObject>(),
|
||||
"link",
|
||||
"icon",
|
||||
moreAction
|
||||
)
|
||||
)
|
||||
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.populateList(notifications)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotifications", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.setEmptyContent("Error", "Error! Please try again later!")
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,8 +142,8 @@ class GalleryFragmentIT : AbstractIT() {
|
||||
.perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(pos, longClickAllThumbnailsInRow()))
|
||||
}
|
||||
|
||||
val checked = galleryFragment.commonAdapter.getCheckedItems()
|
||||
assertEquals(imageCount, checked.size)
|
||||
val checked = galleryFragment.commonAdapter?.getCheckedItems()
|
||||
assertEquals(imageCount, checked?.size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.notifications.models.Action
|
||||
import com.owncloud.android.lib.resources.notifications.models.Notification
|
||||
import com.owncloud.android.ui.fragment.notifications.NotificationsFragment
|
||||
import com.owncloud.android.ui.fragment.notifications.model.NotificationsUIState
|
||||
import com.owncloud.android.ui.navigation.NavigatorActivity
|
||||
import com.owncloud.android.ui.navigation.NavigatorScreen
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestRule
|
||||
import java.util.Date
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
class NotificationsFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.notifications.NotificationsFragmentIT"
|
||||
|
||||
@get:Rule
|
||||
var storagePermissionRules: TestRule = grant()
|
||||
|
||||
private fun buildDate(): Date = GregorianCalendar().apply {
|
||||
set(2005, 4, 17, 10, 35, 30)
|
||||
}.time
|
||||
|
||||
private fun buildNotificationNoActions(): Notification = Notification(
|
||||
1,
|
||||
"files",
|
||||
"user",
|
||||
buildDate(),
|
||||
"objectType",
|
||||
"objectId",
|
||||
"App recommendation: Tasks",
|
||||
"SubjectRich",
|
||||
HashMap(),
|
||||
"Sync tasks from various devices with your Nextcloud and edit them online.",
|
||||
"MessageRich",
|
||||
HashMap(),
|
||||
"link",
|
||||
"icon",
|
||||
ArrayList()
|
||||
)
|
||||
|
||||
private fun buildNotificationTwoActions(): Notification {
|
||||
val actions = ArrayList<Action>().apply {
|
||||
add(Action("Send usage", "link", "url", true))
|
||||
add(Action("Not now", "link", "url", false))
|
||||
}
|
||||
|
||||
return Notification(
|
||||
2,
|
||||
"files",
|
||||
"user",
|
||||
buildDate(),
|
||||
"objectType",
|
||||
"objectId",
|
||||
"Help improve Nextcloud",
|
||||
"SubjectRich",
|
||||
HashMap(),
|
||||
"Do you want to help us to improve Nextcloud by providing some anonymize data about your setup and usage?",
|
||||
"MessageRich",
|
||||
HashMap(),
|
||||
"link",
|
||||
"icon",
|
||||
actions
|
||||
)
|
||||
}
|
||||
|
||||
private fun buildNotificationManyActions(): Notification {
|
||||
val actions = ArrayList<Action>().apply {
|
||||
add(Action("Send usage", "link", "url", true))
|
||||
add(Action("Not now", "link", "url", false))
|
||||
add(Action("Third action", "link", "url", false))
|
||||
add(Action("Delay", "link", "url", false))
|
||||
}
|
||||
|
||||
return Notification(
|
||||
3,
|
||||
"files",
|
||||
"user",
|
||||
buildDate(),
|
||||
"objectType",
|
||||
"objectId",
|
||||
"Help improve Nextcloud",
|
||||
"SubjectRich",
|
||||
HashMap(),
|
||||
"Do you want to help us to improve Nextcloud by providing some anonymize data about your setup" +
|
||||
" and usage?",
|
||||
"MessageRich",
|
||||
HashMap(),
|
||||
"link",
|
||||
"icon",
|
||||
actions
|
||||
)
|
||||
}
|
||||
|
||||
fun buildMockNotifications(): ArrayList<Notification> = ArrayList<Notification>().apply {
|
||||
add(buildNotificationNoActions())
|
||||
add(buildNotificationTwoActions())
|
||||
add(buildNotificationManyActions())
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun findFragment(sut: NavigatorActivity): NotificationsFragment? {
|
||||
val allFragments = sut.supportFragmentManager.fragments
|
||||
for (f in allFragments) {
|
||||
if (f is NotificationsFragment) return f
|
||||
val child = f.childFragmentManager.fragments.filterIsInstance<NotificationsFragment>().firstOrNull()
|
||||
if (child != null) return child
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun launchFragment(name: String, block: NotificationsFragment.() -> Unit) {
|
||||
val intent = NavigatorActivity.intent(targetContext, NavigatorScreen.Notifications)
|
||||
.putExtra(NotificationsFragment.EXTRA_INIT_FOR_TESTING, true)
|
||||
|
||||
ActivityScenario.launch<NavigatorActivity>(intent).use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
val fragment = findFragment(sut)
|
||||
?: throw IllegalStateException("NotificationsFragment not found in NavigatorActivity!")
|
||||
fragment.block()
|
||||
}
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + name, "")
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchFragment("empty") { initForTesting(NotificationsUIState.Empty) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showNotifications() {
|
||||
launchFragment("showNotifications") {
|
||||
initForTesting(NotificationsUIState.Loaded(buildMockNotifications()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchFragment("error") {
|
||||
initForTesting(NotificationsUIState.Error("Error! Please try again later!"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.trashbin
|
||||
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Intent
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Test
|
||||
|
||||
class TrashbinActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.trashbin.TrashbinActivityIT"
|
||||
|
||||
enum class TestCase {
|
||||
ERROR,
|
||||
EMPTY,
|
||||
FILES
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun files() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "files", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun loading() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showInitialLoading()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun normalUser() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "normalUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun differentUser() {
|
||||
val temp = Account("differentUser@https://nextcloud.localhost", MainApp.getAccountType(targetContext))
|
||||
|
||||
AccountManager.get(targetContext).apply {
|
||||
addAccountExplicitly(temp, "password", null)
|
||||
setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, "https://nextcloud.localhost")
|
||||
setUserData(temp, AccountUtils.Constants.KEY_USER_ID, "differentUser")
|
||||
}
|
||||
|
||||
val intent = Intent(targetContext, TrashbinActivity::class.java).apply {
|
||||
putExtra(Intent.EXTRA_USER, "differentUser@https://nextcloud.localhost")
|
||||
}
|
||||
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "differentUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.owncloud.android.ui.trashbin
|
||||
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.ui.navigation.NavigatorActivity
|
||||
import com.owncloud.android.ui.navigation.NavigatorScreen
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Test
|
||||
|
||||
class TrashbinFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.trashbin.TrashbinFragmentIT"
|
||||
|
||||
enum class TestCase {
|
||||
ERROR,
|
||||
EMPTY,
|
||||
FILES
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun findFragment(sut: NavigatorActivity): TrashbinFragment? {
|
||||
val allFragments = sut.supportFragmentManager.fragments
|
||||
for (f in allFragments) {
|
||||
if (f is TrashbinFragment) return f
|
||||
val child = f.childFragmentManager.fragments.filterIsInstance<TrashbinFragment>().firstOrNull()
|
||||
if (child != null) return child
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun launchFragment(name: String, block: TrashbinFragment.() -> Unit) {
|
||||
val intent = NavigatorActivity.intent(targetContext, NavigatorScreen.Trashbin)
|
||||
|
||||
ActivityScenario.launch<NavigatorActivity>(intent).use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
val fragment = findFragment(sut)
|
||||
?: throw IllegalStateException("TrashbinFragment not found in NavigatorActivity!")
|
||||
fragment.block()
|
||||
}
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + name, "")
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchFragment("error") {
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
||||
trashbinPresenter = TrashbinPresenter(trashbinRepository, this)
|
||||
loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun files() {
|
||||
launchFragment("files") {
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
trashbinPresenter = TrashbinPresenter(trashbinRepository, this)
|
||||
loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchFragment("empty") {
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
trashbinPresenter = TrashbinPresenter(trashbinRepository, this)
|
||||
loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun loading() {
|
||||
launchFragment("loading") {
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
trashbinPresenter = TrashbinPresenter(trashbinRepository, this)
|
||||
showInitialLoading()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun normalUser() {
|
||||
launchFragment("normalUser") {
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
trashbinPresenter = TrashbinPresenter(trashbinRepository, this)
|
||||
showUser()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun differentUser() {
|
||||
val temp = Account("differentUser@https://nextcloud.localhost", MainApp.getAccountType(targetContext))
|
||||
|
||||
AccountManager.get(targetContext).apply {
|
||||
addAccountExplicitly(temp, "password", null)
|
||||
setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, "https://nextcloud.localhost")
|
||||
setUserData(temp, AccountUtils.Constants.KEY_USER_ID, "differentUser")
|
||||
}
|
||||
|
||||
launchFragment("differentUser") {
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
trashbinPresenter = TrashbinPresenter(trashbinRepository, this)
|
||||
showUser()
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -11,7 +11,7 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import com.owncloud.android.ui.trashbin.TrashbinRepository.LoadFolderCallback
|
||||
|
||||
class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase) : TrashbinRepository {
|
||||
class TrashbinLocalRepository(private val testCase: TrashbinFragmentIT.TestCase) : TrashbinRepository {
|
||||
override fun emptyTrashbin(callback: TrashbinRepository.OperationCallback?) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
@@ -27,9 +27,9 @@ class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase)
|
||||
@Suppress("MagicNumber")
|
||||
override fun getFolder(remotePath: String?, callback: LoadFolderCallback?) {
|
||||
when (testCase) {
|
||||
TrashbinActivityIT.TestCase.ERROR -> callback?.onError(R.string.trashbin_loading_failed)
|
||||
TrashbinFragmentIT.TestCase.ERROR -> callback?.onError(R.string.trashbin_loading_failed)
|
||||
|
||||
TrashbinActivityIT.TestCase.FILES -> {
|
||||
TrashbinFragmentIT.TestCase.FILES -> {
|
||||
val files = ArrayList<TrashbinFile>()
|
||||
files.add(
|
||||
TrashbinFile(
|
||||
@@ -71,7 +71,7 @@ class TrashbinLocalRepository(private val testCase: TrashbinActivityIT.TestCase)
|
||||
callback?.onSuccess(files)
|
||||
}
|
||||
|
||||
TrashbinActivityIT.TestCase.EMPTY -> callback?.onSuccess(ArrayList<TrashbinFile>())
|
||||
TrashbinFragmentIT.TestCase.EMPTY -> callback?.onSuccess(ArrayList<TrashbinFile>())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,9 +282,6 @@
|
||||
<activity
|
||||
android:name=".ui.activity.UserInfoActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.activity.NotificationsActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.activity.SyncedFoldersActivity"
|
||||
android:exported="false" />
|
||||
@@ -595,10 +592,6 @@
|
||||
<activity
|
||||
android:name=".ui.activity.UploadListActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.trashbin.TrashbinActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name="com.nextcloud.client.onboarding.WhatsNewActivity"
|
||||
android:theme="@style/Theme.ownCloud.noActionBar.Login" />
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.core.ClockImpl
|
||||
import com.nextcloud.client.database.dao.ArbitraryDataDao
|
||||
import com.nextcloud.client.database.dao.AssistantDao
|
||||
import com.nextcloud.client.database.dao.CapabilityDao
|
||||
import com.nextcloud.client.database.dao.FileDao
|
||||
import com.nextcloud.client.database.dao.FileSystemDao
|
||||
import com.nextcloud.client.database.dao.OfflineOperationDao
|
||||
@@ -39,6 +40,7 @@ import com.nextcloud.client.database.entity.VirtualEntity
|
||||
import com.nextcloud.client.database.migrations.DatabaseMigrationUtil
|
||||
import com.nextcloud.client.database.migrations.MIGRATION_88_89
|
||||
import com.nextcloud.client.database.migrations.MIGRATION_97_98
|
||||
import com.nextcloud.client.database.migrations.MIGRATION_99_100
|
||||
import com.nextcloud.client.database.migrations.Migration67to68
|
||||
import com.nextcloud.client.database.migrations.RoomMigration
|
||||
import com.nextcloud.client.database.migrations.addLegacyMigrations
|
||||
@@ -96,6 +98,7 @@ import com.owncloud.android.db.ProviderMeta
|
||||
AutoMigration(from = 96, to = 97, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
// manual migration used for 97 to 98
|
||||
AutoMigration(from = 98, to = 99)
|
||||
// manual migration used for 99 to 100
|
||||
],
|
||||
exportSchema = true
|
||||
)
|
||||
@@ -112,6 +115,7 @@ abstract class NextcloudDatabase : RoomDatabase() {
|
||||
abstract fun syncedFolderDao(): SyncedFolderDao
|
||||
abstract fun assistantDao(): AssistantDao
|
||||
abstract fun shareDao(): ShareDao
|
||||
abstract fun capabilityDao(): CapabilityDao
|
||||
|
||||
companion object {
|
||||
const val FIRST_ROOM_DB_VERSION = 65
|
||||
@@ -134,6 +138,7 @@ abstract class NextcloudDatabase : RoomDatabase() {
|
||||
.addMigrations(Migration67to68())
|
||||
.addMigrations(MIGRATION_88_89)
|
||||
.addMigrations(MIGRATION_97_98)
|
||||
.addMigrations(MIGRATION_99_100)
|
||||
.build()
|
||||
}
|
||||
return instance!!
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.CapabilityEntity
|
||||
|
||||
@Dao
|
||||
interface CapabilityDao {
|
||||
|
||||
@Query("SELECT * FROM capabilities WHERE account = :accountName LIMIT 1")
|
||||
suspend fun getByAccountName(accountName: String): CapabilityEntity?
|
||||
}
|
||||
@@ -11,6 +11,9 @@ import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
|
||||
import com.owncloud.android.lib.resources.status.E2EVersion
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
|
||||
@Entity(tableName = ProviderTableMeta.CAPABILITIES_TABLE_NAME)
|
||||
data class CapabilityEntity(
|
||||
@@ -124,13 +127,13 @@ data class CapabilityEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_SECURITY_GUARD)
|
||||
val securityGuard: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAME_CHARACTERS)
|
||||
val forbiddenFileNameCharacters: Int?,
|
||||
val forbiddenFileNameCharacters: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FORBIDDEN_FILENAMES)
|
||||
val forbiddenFileNames: Int?,
|
||||
val forbiddenFileNames: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FORBIDDEN_FORBIDDEN_FILENAME_EXTENSIONS)
|
||||
val forbiddenFileNameExtensions: Int?,
|
||||
val forbiddenFileNameExtensions: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FORBIDDEN_FORBIDDEN_FILENAME_BASE_NAMES)
|
||||
val forbiddenFilenameBaseNames: Int?,
|
||||
val forbiddenFilenameBaseNames: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT)
|
||||
val filesDownloadLimit: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT_DEFAULT)
|
||||
@@ -150,3 +153,85 @@ data class CapabilityEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_CLIENT_INTEGRATION_JSON)
|
||||
val clientIntegrationJson: String?
|
||||
)
|
||||
|
||||
@Suppress("LongMethod", "ReturnCount")
|
||||
fun CapabilityEntity?.toOCCapability(): OCCapability {
|
||||
val capability = OCCapability()
|
||||
if (this == null) return capability
|
||||
val id = this.id ?: return capability
|
||||
|
||||
fun intToBoolean(value: Int?): CapabilityBooleanType =
|
||||
value?.let { CapabilityBooleanType.fromValue(it) } ?: CapabilityBooleanType.UNKNOWN
|
||||
|
||||
capability.id = id.toLong()
|
||||
capability.accountName = this.accountName
|
||||
capability.versionMayor = this.versionMajor ?: 0
|
||||
capability.versionMinor = this.versionMinor ?: 0
|
||||
capability.versionMicro = this.versionMicro ?: 0
|
||||
capability.versionString = this.versionString
|
||||
capability.versionEdition = this.versionEditor
|
||||
capability.extendedSupport = intToBoolean(this.extendedSupport)
|
||||
capability.corePollInterval = this.corePollinterval ?: 0
|
||||
capability.filesSharingApiEnabled = intToBoolean(this.sharingApiEnabled)
|
||||
capability.filesSharingPublicEnabled = intToBoolean(this.sharingPublicEnabled)
|
||||
capability.filesSharingPublicPasswordEnforced = intToBoolean(this.sharingPublicPasswordEnforced)
|
||||
capability.filesSharingPublicAskForOptionalPassword = intToBoolean(this.sharingPublicAskForOptionalPassword)
|
||||
capability.filesSharingPublicExpireDateEnabled = intToBoolean(this.sharingPublicExpireDateEnabled)
|
||||
capability.filesSharingPublicExpireDateDays = this.sharingPublicExpireDateDays ?: 0
|
||||
capability.filesSharingPublicExpireDateEnforced = intToBoolean(this.sharingPublicExpireDateEnforced)
|
||||
capability.filesSharingPublicSendMail = intToBoolean(this.sharingPublicSendMail)
|
||||
capability.filesSharingPublicUpload = intToBoolean(this.sharingPublicUpload)
|
||||
capability.filesSharingUserSendMail = intToBoolean(this.sharingUserSendMail)
|
||||
capability.filesSharingResharing = intToBoolean(this.sharingResharing)
|
||||
capability.filesSharingFederationOutgoing = intToBoolean(this.sharingFederationOutgoing)
|
||||
capability.filesSharingFederationIncoming = intToBoolean(this.sharingFederationIncoming)
|
||||
capability.filesBigFileChunking = intToBoolean(this.filesBigfilechunking)
|
||||
capability.filesUndelete = intToBoolean(this.filesUndelete)
|
||||
capability.filesVersioning = intToBoolean(this.filesVersioning)
|
||||
capability.externalLinks = intToBoolean(this.externalLinks)
|
||||
capability.serverName = this.serverName
|
||||
capability.serverColor = this.serverColor
|
||||
capability.serverTextColor = this.serverTextColor
|
||||
capability.serverElementColor = this.serverElementColor
|
||||
capability.serverSlogan = this.serverSlogan
|
||||
capability.serverLogo = this.serverLogo
|
||||
capability.serverBackground = this.serverBackgroundUrl
|
||||
capability.endToEndEncryption = intToBoolean(this.endToEndEncryption)
|
||||
capability.endToEndEncryptionKeysExist = intToBoolean(this.endToEndEncryptionKeysExist)
|
||||
capability.endToEndEncryptionApiVersion = this.endToEndEncryptionApiVersion?.let {
|
||||
E2EVersion.fromValue(it)
|
||||
} ?: E2EVersion.UNKNOWN
|
||||
capability.serverBackgroundDefault = intToBoolean(this.serverBackgroundDefault)
|
||||
capability.serverBackgroundPlain = intToBoolean(this.serverBackgroundPlain)
|
||||
capability.activity = intToBoolean(this.activity)
|
||||
capability.richDocuments = intToBoolean(this.richdocument)
|
||||
capability.richDocumentsDirectEditing = intToBoolean(this.richdocumentDirectEditing)
|
||||
capability.richDocumentsTemplatesAvailable = intToBoolean(this.richdocumentTemplates)
|
||||
capability.richDocumentsMimeTypeList = this.richdocumentMimetypeList?.split(",") ?: emptyList()
|
||||
capability.richDocumentsOptionalMimeTypeList = this.richdocumentOptionalMimetypeList?.split(",") ?: emptyList()
|
||||
capability.richDocumentsProductName = this.richdocumentProductName
|
||||
capability.directEditingEtag = this.directEditingEtag
|
||||
capability.etag = this.etag
|
||||
capability.userStatus = intToBoolean(this.userStatus)
|
||||
capability.userStatusSupportsEmoji = intToBoolean(this.userStatusSupportsEmoji)
|
||||
capability.userStatusSupportsBusy = intToBoolean(this.userStatusSupportsBusy)
|
||||
capability.filesLockingVersion = this.filesLockingVersion
|
||||
capability.assistant = intToBoolean(this.assistant)
|
||||
capability.groupfolders = intToBoolean(this.groupfolders)
|
||||
capability.dropAccount = intToBoolean(this.dropAccount)
|
||||
capability.securityGuard = intToBoolean(this.securityGuard)
|
||||
capability.forbiddenFilenameCharactersJson = this.forbiddenFileNameCharacters
|
||||
capability.forbiddenFilenamesJson = this.forbiddenFileNames
|
||||
capability.forbiddenFilenameExtensionJson = this.forbiddenFileNameExtensions
|
||||
capability.forbiddenFilenameBaseNamesJson = this.forbiddenFilenameBaseNames
|
||||
capability.isWCFEnabled = intToBoolean(this.isWCFEnabled)
|
||||
capability.filesDownloadLimit = intToBoolean(this.filesDownloadLimit)
|
||||
capability.filesDownloadLimitDefault = this.filesDownloadLimitDefault ?: 0
|
||||
capability.recommendations = intToBoolean(this.recommendation)
|
||||
capability.notesFolderPath = this.notesFolderPath
|
||||
capability.defaultPermissions = this.defaultPermissions ?: 0
|
||||
capability.hasValidSubscription = intToBoolean(this.hasValidSubscription)
|
||||
capability.clientIntegrationJson = this.clientIntegrationJson
|
||||
|
||||
return capability
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.database.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
@Suppress("MagicNumber", "LongMethod")
|
||||
val MIGRATION_99_100 = object : Migration(99, 100) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL("DROP TABLE IF EXISTS capabilities")
|
||||
|
||||
db.execSQL(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS capabilities (
|
||||
_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
account TEXT,
|
||||
version_mayor INTEGER,
|
||||
version_minor INTEGER,
|
||||
version_micro INTEGER,
|
||||
version_string TEXT,
|
||||
version_edition TEXT,
|
||||
extended_support INTEGER,
|
||||
core_pollinterval INTEGER,
|
||||
sharing_api_enabled INTEGER,
|
||||
sharing_public_enabled INTEGER,
|
||||
sharing_public_password_enforced INTEGER,
|
||||
sharing_public_ask_for_optional_password INTEGER,
|
||||
sharing_public_expire_date_enabled INTEGER,
|
||||
sharing_public_expire_date_days INTEGER,
|
||||
sharing_public_expire_date_enforced INTEGER,
|
||||
sharing_public_send_mail INTEGER,
|
||||
sharing_public_upload INTEGER,
|
||||
sharing_user_send_mail INTEGER,
|
||||
sharing_resharing INTEGER,
|
||||
sharing_federation_outgoing INTEGER,
|
||||
sharing_federation_incoming INTEGER,
|
||||
files_bigfilechunking INTEGER,
|
||||
files_undelete INTEGER,
|
||||
files_versioning INTEGER,
|
||||
files_locking_version TEXT,
|
||||
external_links INTEGER,
|
||||
server_name TEXT,
|
||||
server_color TEXT,
|
||||
server_text_color TEXT,
|
||||
server_element_color TEXT,
|
||||
background_url TEXT,
|
||||
server_slogan TEXT,
|
||||
server_logo TEXT,
|
||||
background_default INTEGER,
|
||||
background_plain INTEGER,
|
||||
end_to_end_encryption INTEGER,
|
||||
end_to_end_encryption_keys_exist INTEGER,
|
||||
end_to_end_encryption_api_version TEXT,
|
||||
activity INTEGER,
|
||||
richdocument INTEGER,
|
||||
recommendation INTEGER,
|
||||
richdocument_mimetype_list TEXT,
|
||||
richdocument_optional_mimetype_list TEXT,
|
||||
richdocument_direct_editing INTEGER,
|
||||
richdocument_direct_templates INTEGER,
|
||||
richdocument_product_name TEXT,
|
||||
direct_editing_etag TEXT,
|
||||
etag TEXT,
|
||||
user_status INTEGER,
|
||||
user_status_supports_emoji INTEGER,
|
||||
user_status_supports_busy INTEGER,
|
||||
assistant INTEGER,
|
||||
groupfolders INTEGER,
|
||||
drop_account INTEGER,
|
||||
security_guard INTEGER,
|
||||
forbidden_filename_characters TEXT,
|
||||
forbidden_filenames TEXT,
|
||||
forbidden_filename_extensions TEXT,
|
||||
forbidden_filename_basenames TEXT,
|
||||
windows_compatible_filenames INTEGER,
|
||||
files_download_limit INTEGER,
|
||||
files_download_limit_default INTEGER,
|
||||
notes_folder_path TEXT,
|
||||
default_permissions INTEGER,
|
||||
has_valid_subscription INTEGER,
|
||||
client_integration_json TEXT
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,6 @@ import com.owncloud.android.ui.activity.FolderPickerActivity;
|
||||
import com.owncloud.android.ui.activity.InternalTwoWaySyncActivity;
|
||||
import com.owncloud.android.ui.activity.ManageAccountsActivity;
|
||||
import com.owncloud.android.ui.activity.ManageSpaceActivity;
|
||||
import com.owncloud.android.ui.activity.NotificationsActivity;
|
||||
import com.owncloud.android.ui.activity.PassCodeActivity;
|
||||
import com.owncloud.android.ui.activity.ReceiveExternalFilesActivity;
|
||||
import com.owncloud.android.ui.activity.RequestCredentialsActivity;
|
||||
@@ -118,6 +117,7 @@ import com.owncloud.android.ui.fragment.UnifiedSearchFragment;
|
||||
import com.owncloud.android.ui.fragment.community.CommunityFragment;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.BackupFragment;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment;
|
||||
import com.owncloud.android.ui.fragment.notifications.NotificationsFragment;
|
||||
import com.owncloud.android.ui.navigation.NavigatorActivity;
|
||||
import com.owncloud.android.ui.preview.FileDownloadFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewBitmapActivity;
|
||||
@@ -129,7 +129,7 @@ import com.owncloud.android.ui.preview.PreviewTextFileFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewTextFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewTextStringFragment;
|
||||
import com.owncloud.android.ui.preview.pdf.PreviewPdfFragment;
|
||||
import com.owncloud.android.ui.trashbin.TrashbinActivity;
|
||||
import com.owncloud.android.ui.trashbin.TrashbinFragment;
|
||||
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
@@ -141,9 +141,15 @@ import dagger.android.ContributesAndroidInjector;
|
||||
*/
|
||||
@Module
|
||||
abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector
|
||||
abstract TrashbinFragment trashbinFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ActivitiesFragment activitiesFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract NotificationsFragment notificationFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract AuthenticatorActivity authenticatorActivity();
|
||||
|
||||
@@ -192,9 +198,6 @@ abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector
|
||||
abstract ManageSpaceActivity manageSpaceActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract NotificationsActivity notificationsActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ComposeActivity composeActivity();
|
||||
|
||||
@@ -225,9 +228,6 @@ abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector
|
||||
abstract SyncedFoldersActivity syncedFoldersActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract TrashbinActivity trashbinActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract TrashbinFileActionsBottomSheet trashbinFileActionsBottomSheet();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.operations.factory.UploadFileOperationFactory
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
@@ -66,7 +67,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
private val localBroadcastManager: Provider<LocalBroadcastManager>,
|
||||
private val generatePdfUseCase: GeneratePDFUseCase,
|
||||
private val syncedFolderProvider: SyncedFolderProvider,
|
||||
private val database: NextcloudDatabase
|
||||
private val database: NextcloudDatabase,
|
||||
private val uploadFileOperationFactory: UploadFileOperationFactory
|
||||
) : WorkerFactory() {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@@ -247,6 +249,7 @@ class BackgroundJobFactory @Inject constructor(
|
||||
FileSystemRepository(dao = database.fileSystemDao(), uploadsStorageManager, context),
|
||||
syncedFolderProvider,
|
||||
context,
|
||||
uploadFileOperationFactory,
|
||||
params
|
||||
)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import com.owncloud.android.lib.resources.notifications.DeleteNotificationRemote
|
||||
import com.owncloud.android.lib.resources.notifications.GetNotificationRemoteOperation
|
||||
import com.owncloud.android.lib.resources.notifications.models.Notification
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.activity.NotificationsActivity
|
||||
import com.owncloud.android.ui.navigation.NavigatorActivity
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.PushUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
@@ -137,7 +137,7 @@ class NotificationWork constructor(
|
||||
} else {
|
||||
val intent: Intent
|
||||
if (file == null) {
|
||||
intent = Intent(context, NotificationsActivity::class.java)
|
||||
intent = Intent(context, NavigatorActivity::class.java)
|
||||
} else {
|
||||
intent = Intent(context, FileDisplayActivity::class.java)
|
||||
intent.action = Intent.ACTION_VIEW
|
||||
|
||||
@@ -72,8 +72,14 @@ class OfflineSyncWork(
|
||||
if (files != null) {
|
||||
for (file in files) {
|
||||
val ocFile = storageManager.getFileByLocalPath(file.path)
|
||||
val remotePath = ocFile?.remotePath
|
||||
if (remotePath == null) {
|
||||
Log_OC.w(TAG, "remote path is null can't sync")
|
||||
continue
|
||||
}
|
||||
|
||||
val synchronizeFileOperation = SynchronizeFileOperation(
|
||||
ocFile?.remotePath,
|
||||
remotePath,
|
||||
user,
|
||||
true,
|
||||
context,
|
||||
|
||||
@@ -8,11 +8,17 @@
|
||||
package com.nextcloud.client.jobs.gallery
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Point
|
||||
import android.media.ThumbnailUtils
|
||||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import android.util.Size
|
||||
import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.utils.allocationKilobyte
|
||||
import com.nextcloud.utils.extensions.isPNG
|
||||
import com.nextcloud.utils.extensions.toFile
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
@@ -20,6 +26,7 @@ import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -29,15 +36,12 @@ import kotlinx.coroutines.withContext
|
||||
import java.util.Collections
|
||||
import java.util.WeakHashMap
|
||||
|
||||
@Suppress("DEPRECATION", "TooGenericExceptionCaught", "ReturnCount")
|
||||
class GalleryImageGenerationJob(private val user: User, private val storageManager: FileDataStorageManager) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "GalleryImageGenerationJob"
|
||||
private val semaphore = Semaphore(
|
||||
maxOf(
|
||||
3,
|
||||
Runtime.getRuntime().availableProcessors() / 2
|
||||
)
|
||||
)
|
||||
private val semaphore = Semaphore(maxOf(3, Runtime.getRuntime().availableProcessors() / 2))
|
||||
private val activeJobs = Collections.synchronizedMap(WeakHashMap<ImageView, Job>())
|
||||
|
||||
fun cancelAllActiveJobs() {
|
||||
@@ -83,57 +87,114 @@ class GalleryImageGenerationJob(private val user: User, private val storageManag
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
suspend fun run(file: OCFile, imageView: ImageView, listener: GalleryImageGenerationListener) {
|
||||
try {
|
||||
var newImage = false
|
||||
|
||||
if (file.remoteId == null && !file.isPreviewAvailable) {
|
||||
Log_OC.e(TAG, "file has no remoteId and no preview")
|
||||
withContext(Dispatchers.Main) {
|
||||
listener.onError()
|
||||
}
|
||||
withContext(Dispatchers.Main) { listener.onError() }
|
||||
return
|
||||
}
|
||||
|
||||
val bitmap: Bitmap? = getBitmap(file, onThumbnailGeneration = {
|
||||
newImage = true
|
||||
})
|
||||
var newImage = false
|
||||
val bitmap: Bitmap? = getBitmap(file, onNewThumbnail = { newImage = true })
|
||||
|
||||
if (bitmap == null) {
|
||||
withContext(Dispatchers.Main) {
|
||||
listener.onError()
|
||||
}
|
||||
withContext(Dispatchers.Main) { listener.onError() }
|
||||
return
|
||||
}
|
||||
|
||||
setThumbnail(bitmap, file, imageView, newImage, listener)
|
||||
} catch (_: Exception) {
|
||||
withContext(Dispatchers.Main) {
|
||||
listener.onError()
|
||||
}
|
||||
withContext(Dispatchers.Main) { listener.onError() }
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getBitmap(file: OCFile, onThumbnailGeneration: () -> Unit): Bitmap? =
|
||||
withContext(Dispatchers.IO) {
|
||||
val key = file.remoteId
|
||||
val cachedThumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + file.remoteId
|
||||
)
|
||||
if (cachedThumbnail != null && !file.isUpdateThumbnailNeeded) {
|
||||
Log_OC.d(TAG, "cached thumbnail is used for: ${file.fileName}")
|
||||
return@withContext getThumbnailFromCache(file, cachedThumbnail, key)
|
||||
}
|
||||
private suspend fun getBitmap(file: OCFile, onNewThumbnail: () -> Unit): Bitmap? = withContext(Dispatchers.IO) {
|
||||
val cacheKey = ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + file.remoteId
|
||||
|
||||
Log_OC.d(TAG, "generating new thumbnail for: ${file.fileName}")
|
||||
|
||||
onThumbnailGeneration()
|
||||
semaphore.withPermit {
|
||||
return@withContext getThumbnailFromServerAndAddToCache(file, cachedThumbnail)
|
||||
}
|
||||
val cached = ThumbnailsCacheManager.getBitmapFromDiskCache(cacheKey)
|
||||
if (cached != null && !file.isUpdateThumbnailNeeded) {
|
||||
return@withContext applyVideoOverlayIfNeeded(file, cached)
|
||||
}
|
||||
|
||||
onNewThumbnail()
|
||||
|
||||
val local = decodeLocalThumbnail(file)
|
||||
if (local != null) {
|
||||
ThumbnailsCacheManager.addBitmapToCache(cacheKey, local)
|
||||
return@withContext applyVideoOverlayIfNeeded(file, local)
|
||||
}
|
||||
|
||||
val remote = semaphore.withPermit { fetchFromServer(file) }
|
||||
if (remote != null) {
|
||||
return@withContext applyVideoOverlayIfNeeded(file, remote)
|
||||
}
|
||||
|
||||
null
|
||||
}
|
||||
|
||||
private fun decodeLocalThumbnail(file: OCFile): Bitmap? = if (MimeTypeUtil.isVideo(file)) {
|
||||
createVideoThumbnail(file.storagePath)
|
||||
} else {
|
||||
createImageThumbnail(file)
|
||||
}
|
||||
|
||||
private fun createImageThumbnail(file: OCFile): Bitmap? {
|
||||
val wm = MainApp.getAppContext().getSystemService(android.content.Context.WINDOW_SERVICE) as WindowManager
|
||||
val p = Point()
|
||||
wm.defaultDisplay.getSize(p)
|
||||
|
||||
val pxW = p.x
|
||||
val pxH = p.y
|
||||
|
||||
val cacheKey = ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE + file.remoteId
|
||||
|
||||
var bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.storagePath, pxW, pxH) ?: return null
|
||||
|
||||
if (file.isPNG()) {
|
||||
bitmap = ThumbnailsCacheManager.handlePNG(bitmap, pxW, pxH)
|
||||
}
|
||||
|
||||
val thumbnail = ThumbnailsCacheManager.addThumbnailToCache(cacheKey, bitmap, file.storagePath, pxW, pxH)
|
||||
file.isUpdateThumbnailNeeded = false
|
||||
|
||||
return thumbnail
|
||||
}
|
||||
|
||||
private fun createVideoThumbnail(storagePath: String): Bitmap? {
|
||||
val ioFile = storagePath.toFile() ?: return null
|
||||
val size = ThumbnailsCacheManager.getThumbnailDimension()
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
try {
|
||||
ThumbnailUtils.createVideoThumbnail(ioFile, Size(size, size), null)
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "Failed to create video thumbnail from local file: ${e.message}")
|
||||
null
|
||||
}
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
ThumbnailUtils.createVideoThumbnail(storagePath, MediaStore.Images.Thumbnails.MINI_KIND)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun fetchFromServer(file: OCFile): Bitmap? = try {
|
||||
val client = withContext(Dispatchers.IO) {
|
||||
OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(user.toOwnCloudAccount(), MainApp.getAppContext())
|
||||
}
|
||||
ThumbnailsCacheManager.setClient(client)
|
||||
ThumbnailsCacheManager.doResizedImageInBackground(file, storageManager)
|
||||
} catch (t: Throwable) {
|
||||
Log_OC.e(TAG, "Server fetch failed for $file", t)
|
||||
null
|
||||
}
|
||||
|
||||
private fun applyVideoOverlayIfNeeded(file: OCFile, bitmap: Bitmap): Bitmap = if (MimeTypeUtil.isVideo(file)) {
|
||||
ThumbnailsCacheManager.addVideoOverlay(bitmap, MainApp.getAppContext())
|
||||
} else {
|
||||
bitmap
|
||||
}
|
||||
|
||||
private suspend fun setThumbnail(
|
||||
bitmap: Bitmap,
|
||||
file: OCFile,
|
||||
@@ -146,16 +207,11 @@ class GalleryImageGenerationJob(private val user: User, private val storageManag
|
||||
if (imageView.tag.toString() == tagId) {
|
||||
if (file.isPNG()) {
|
||||
imageView.setBackgroundColor(
|
||||
ContextCompat.getColor(
|
||||
MainApp.getAppContext(),
|
||||
R.color.bg_default
|
||||
)
|
||||
ContextCompat.getColor(MainApp.getAppContext(), R.color.bg_default)
|
||||
)
|
||||
}
|
||||
|
||||
if (newImage) {
|
||||
listener.onNewGalleryImage()
|
||||
}
|
||||
if (newImage) listener.onNewGalleryImage()
|
||||
|
||||
if (imageView.isAttachedToWindow) {
|
||||
imageView.setImageBitmap(bitmap)
|
||||
@@ -165,40 +221,4 @@ class GalleryImageGenerationJob(private val user: User, private val storageManag
|
||||
|
||||
listener.onSuccess()
|
||||
}
|
||||
|
||||
private fun getThumbnailFromCache(file: OCFile, thumbnail: Bitmap, key: String): Bitmap {
|
||||
var result = thumbnail
|
||||
if (MimeTypeUtil.isVideo(file)) {
|
||||
result = ThumbnailsCacheManager.addVideoOverlay(thumbnail, MainApp.getAppContext())
|
||||
}
|
||||
|
||||
if (thumbnail.allocationKilobyte() > ThumbnailsCacheManager.THUMBNAIL_SIZE_IN_KB) {
|
||||
result = ThumbnailsCacheManager.getScaledThumbnailAfterSave(result, key)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION", "TooGenericExceptionCaught")
|
||||
private suspend fun getThumbnailFromServerAndAddToCache(file: OCFile, thumbnail: Bitmap?): Bitmap? {
|
||||
var thumbnail = thumbnail
|
||||
try {
|
||||
val client = withContext(Dispatchers.IO) {
|
||||
OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(
|
||||
user.toOwnCloudAccount(),
|
||||
MainApp.getAppContext()
|
||||
)
|
||||
}
|
||||
ThumbnailsCacheManager.setClient(client)
|
||||
thumbnail = ThumbnailsCacheManager.doResizedImageInBackground(file, storageManager)
|
||||
|
||||
if (MimeTypeUtil.isVideo(file) && thumbnail != null) {
|
||||
thumbnail = ThumbnailsCacheManager.addVideoOverlay(thumbnail, MainApp.getAppContext())
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
Log_OC.e(TAG, "Generation of gallery image for $file failed", t)
|
||||
}
|
||||
|
||||
return thumbnail
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,9 @@ import com.nextcloud.client.network.ConnectivityService
|
||||
import com.nextcloud.client.notifications.AppWideNotificationManager
|
||||
import com.nextcloud.utils.extensions.checkWCFRestrictions
|
||||
import com.nextcloud.utils.extensions.getUploadIds
|
||||
import com.nextcloud.utils.extensions.isAnonymous
|
||||
import com.nextcloud.utils.extensions.isLastResultConflictError
|
||||
import com.nextcloud.utils.extensions.isSame
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
@@ -36,6 +38,7 @@ import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.db.UploadResult
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory
|
||||
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
@@ -45,8 +48,9 @@ import com.owncloud.android.lib.resources.files.model.ServerFileInterface
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.operations.RemoveFileOperation
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.ui.adapter.uploadList.helper.ConflictHandlingResult
|
||||
import com.owncloud.android.ui.adapter.uploadList.helper.UploadListAdapterActionHandler
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -167,25 +171,36 @@ class FileUploadHelper {
|
||||
}
|
||||
|
||||
@Suppress("ComplexCondition")
|
||||
private fun retryUploads(
|
||||
private suspend fun retryUploads(
|
||||
uploadsStorageManager: UploadsStorageManager,
|
||||
connectivityService: ConnectivityService,
|
||||
accountManager: UserAccountManager,
|
||||
powerManagementService: PowerManagementService,
|
||||
uploads: List<OCUpload>
|
||||
): Boolean {
|
||||
): Boolean = withContext(Dispatchers.IO) {
|
||||
var showNotExistMessage = false
|
||||
var showSyncConflictNotification = false
|
||||
var conflictHandlingResult: ConflictHandlingResult? = null
|
||||
val isOnline = checkConnectivity(connectivityService)
|
||||
val connectivity = connectivityService.connectivity
|
||||
val batteryStatus = powerManagementService.battery
|
||||
|
||||
val uploadsToRetry = mutableListOf<Long>()
|
||||
|
||||
val currentAccount = accountManager.currentAccount
|
||||
val context = MainApp.getAppContext()
|
||||
var ownCloudClient: OwnCloudClient? = null
|
||||
if (!currentAccount.isAnonymous(context)) {
|
||||
ownCloudClient =
|
||||
OwnCloudClientFactory.createOwnCloudClient(accountManager.currentAccount, MainApp.getAppContext())
|
||||
}
|
||||
val uploadActionHandler = UploadListAdapterActionHandler()
|
||||
|
||||
for (upload in uploads) {
|
||||
if (upload.isLastResultConflictError()) {
|
||||
Log_OC.d(TAG, "retry upload skipped, sync conflict: ${upload.remotePath}")
|
||||
showSyncConflictNotification = true
|
||||
ownCloudClient?.let {
|
||||
conflictHandlingResult =
|
||||
uploadActionHandler.handleConflict(upload, ownCloudClient, uploadsStorageManager)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -226,11 +241,12 @@ class FileUploadHelper {
|
||||
)
|
||||
}
|
||||
|
||||
if (showSyncConflictNotification) {
|
||||
if (conflictHandlingResult is ConflictHandlingResult.ShowConflictResolveDialog) {
|
||||
Log_OC.d(TAG, "retry upload skipped, sync conflict: ${conflictHandlingResult.file.remotePath}")
|
||||
AppWideNotificationManager.showSyncConflictNotification(MainApp.getAppContext())
|
||||
}
|
||||
|
||||
return showNotExistMessage
|
||||
return@withContext showNotExistMessage
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
@@ -563,25 +579,17 @@ class FileUploadHelper {
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber", "ReturnCount", "ComplexCondition")
|
||||
fun isSameFileOnRemote(user: User?, localFile: File?, remotePath: String?, context: Context?): Boolean {
|
||||
if (user == null || localFile == null || remotePath == null || context == null) {
|
||||
fun isSameFileOnRemote(user: User?, localPath: String?, remotePath: String?, context: Context?): Boolean {
|
||||
if (user == null || localPath == null || remotePath == null || context == null) {
|
||||
Log_OC.e(TAG, "cannot compare remote and local file")
|
||||
return false
|
||||
}
|
||||
|
||||
// Compare remote file to local file
|
||||
val localLastModifiedTimestamp = localFile.lastModified() / 1000 // remote file timestamp in milli not micro sec
|
||||
val localCreationTimestamp = FileUtil.getCreationTimestamp(localFile)
|
||||
val localSize: Long = localFile.length()
|
||||
|
||||
val operation = ReadFileRemoteOperation(remotePath)
|
||||
val result: RemoteOperationResult<*> = operation.execute(user, context)
|
||||
if (result.isSuccess) {
|
||||
val remoteFile = result.data[0] as RemoteFile
|
||||
return remoteFile.size == localSize &&
|
||||
localCreationTimestamp != null &&
|
||||
localCreationTimestamp == remoteFile.creationTimestamp &&
|
||||
remoteFile.modifiedTimestamp == localLastModifiedTimestamp * 1000
|
||||
return remoteFile.isSame(localPath)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -648,7 +656,6 @@ class FileUploadHelper {
|
||||
files: List<OCFile>,
|
||||
accountName: String
|
||||
): Pair<List<SyncedFolderEntity>, List<OCFile>> {
|
||||
|
||||
val autoUploadFolders = mutableListOf<SyncedFolderEntity>()
|
||||
val nonAutoUploadFiles = mutableListOf<OCFile>()
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.nextcloud.utils.extensions.getPercent
|
||||
import com.nextcloud.utils.extensions.toFile
|
||||
import com.nextcloud.utils.extensions.updateStatus
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.ForegroundServiceType
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
@@ -44,6 +43,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.operations.factory.UploadFileOperationFactory
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -66,6 +66,7 @@ class FileUploadWorker(
|
||||
val filesystemRepository: FileSystemRepository,
|
||||
val syncedFolderProvider: SyncedFolderProvider,
|
||||
val context: Context,
|
||||
val uploadFileOperationFactory: UploadFileOperationFactory,
|
||||
params: WorkerParameters
|
||||
) : CoroutineWorker(context, params),
|
||||
OnDatatransferProgressListener {
|
||||
@@ -270,7 +271,7 @@ class FileUploadWorker(
|
||||
}
|
||||
|
||||
fileUploadEventBroadcaster.sendUploadEnqueued(context)
|
||||
val operation = createUploadFileOperation(upload, user)
|
||||
val operation = uploadFileOperationFactory.create(context, upload, this@FileUploadWorker)
|
||||
activeOperations[upload.uploadId] = operation
|
||||
|
||||
val currentIndex = (index + 1)
|
||||
@@ -299,6 +300,7 @@ class FileUploadWorker(
|
||||
return@withContext Result.success()
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
suspend fun isBelongToAnySyncedFolder(
|
||||
upload: OCUpload,
|
||||
syncFolderHelper: SyncFolderHelper,
|
||||
@@ -348,24 +350,6 @@ class FileUploadWorker(
|
||||
return result
|
||||
}
|
||||
|
||||
private fun createUploadFileOperation(upload: OCUpload, user: User): UploadFileOperation = UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityService,
|
||||
powerManagementService,
|
||||
user,
|
||||
null,
|
||||
upload,
|
||||
upload.nameCollisionPolicy,
|
||||
upload.localAction,
|
||||
context,
|
||||
upload.isUseWifiOnly,
|
||||
upload.isWhileChargingOnly,
|
||||
true,
|
||||
FileDataStorageManager(user, context.contentResolver)
|
||||
).apply {
|
||||
addDataTransferProgressListener(this@FileUploadWorker)
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught", "DEPRECATION")
|
||||
private suspend fun upload(
|
||||
upload: OCUpload,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.nextcloud.client.jobs.utils
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationManager
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -28,11 +29,15 @@ import com.owncloud.android.ui.activity.ConflictsResolveActivity
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
|
||||
object UploadErrorNotificationManager {
|
||||
private const val TAG = "UploadErrorNotificationManager"
|
||||
|
||||
fun dismissConflictResolveNotification(context: Context, id: Long) {
|
||||
val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
manager.cancel(id.toInt())
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the result of an upload operation and manages error notifications.
|
||||
* * It filters out successful or silent results and handles [ResultCode.SYNC_CONFLICT], [ResultCode.CONFLICT]
|
||||
@@ -76,7 +81,7 @@ object UploadErrorNotificationManager {
|
||||
val isSameFile = withContext(Dispatchers.IO) {
|
||||
FileUploadHelper.instance().isSameFileOnRemote(
|
||||
operation.user,
|
||||
File(operation.storagePath),
|
||||
operation.storagePath,
|
||||
operation.remotePath,
|
||||
context
|
||||
)
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.nextcloud.ui.fileactions
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.PictureDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
@@ -81,48 +82,60 @@ class ClientIntegration(
|
||||
}
|
||||
text.text = endpoint.name
|
||||
|
||||
if (endpoint.icon != null) {
|
||||
sheet.lifecycleScope.launch(Dispatchers.IO) {
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getNextcloudClientFor(user.toOwnCloudAccount(), context)
|
||||
sheet.lifecycleScope.launch(Dispatchers.IO) {
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getNextcloudClientFor(user.toOwnCloudAccount(), context)
|
||||
|
||||
val drawable =
|
||||
GlideHelper.getDrawable(context, client, client.baseUri.toString() + endpoint.icon)
|
||||
?.mutate()
|
||||
val rawDrawable = if (endpoint.icon != null) {
|
||||
GlideHelper.getDrawable(context, client, client.baseUri.toString() + endpoint.icon)?.mutate()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val px = DisplayUtils.convertDpToPixel(
|
||||
context.resources.getDimension(R.dimen.iconized_single_line_item_icon_size),
|
||||
context
|
||||
)
|
||||
val returnedBitmap =
|
||||
createBitmap(drawable?.intrinsicWidth ?: px, drawable?.intrinsicHeight ?: px)
|
||||
val tintableDrawable = prepareDrawableForTinting(rawDrawable) ?: getDefaultIconDrawable()
|
||||
|
||||
val canvas = Canvas(returnedBitmap)
|
||||
canvas.drawPicture((drawable as PictureDrawable).picture)
|
||||
|
||||
val d = returnedBitmap.toDrawable(context.resources)
|
||||
|
||||
val tintedDrawable = viewThemeUtils.platform.tintDrawable(
|
||||
context,
|
||||
d
|
||||
)
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
icon.setImageDrawable(tintedDrawable)
|
||||
withContext(Dispatchers.Main) {
|
||||
tintableDrawable?.let {
|
||||
val tinted = viewThemeUtils.platform.tintDrawable(context, it)
|
||||
icon.setImageDrawable(tinted)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val tintedDrawable = viewThemeUtils.platform.tintDrawable(
|
||||
context,
|
||||
AppCompatResources.getDrawable(context, R.drawable.ic_activity)!!
|
||||
)
|
||||
|
||||
icon.setImageDrawable(tintedDrawable)
|
||||
}
|
||||
}
|
||||
|
||||
return itemBinding.root
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun prepareDrawableForTinting(drawable: Drawable?): Drawable? {
|
||||
if (drawable == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (drawable is PictureDrawable) {
|
||||
val defaultSize = DisplayUtils.convertDpToPixel(
|
||||
context.resources.getDimension(R.dimen.iconized_single_line_item_icon_size),
|
||||
context
|
||||
).toInt().coerceAtLeast(1)
|
||||
|
||||
val width = if (drawable.intrinsicWidth > 0) drawable.intrinsicWidth else defaultSize
|
||||
val height = if (drawable.intrinsicHeight > 0) drawable.intrinsicHeight else defaultSize
|
||||
|
||||
val safeWidth = width.coerceAtLeast(1)
|
||||
val safeHeight = height.coerceAtLeast(1)
|
||||
|
||||
val bitmap = createBitmap(safeWidth, safeHeight)
|
||||
val canvas = Canvas(bitmap)
|
||||
canvas.drawPicture(drawable.picture)
|
||||
|
||||
return bitmap.toDrawable(context.resources)
|
||||
}
|
||||
|
||||
return drawable
|
||||
}
|
||||
|
||||
private fun getDefaultIconDrawable(): Drawable? = AppCompatResources.getDrawable(context, R.drawable.ic_activity)
|
||||
|
||||
private fun requestClientIntegration(endpoint: Endpoint, fileId: String, filePath: String) {
|
||||
sheet.lifecycleScope.launch(Dispatchers.IO) {
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
|
||||
@@ -124,8 +124,6 @@ enum class FileAction(
|
||||
R.id.action_lock_file,
|
||||
R.id.action_unlock_file,
|
||||
R.id.action_edit,
|
||||
R.id.action_favorite,
|
||||
R.id.action_unset_favorite,
|
||||
R.id.action_see_details,
|
||||
R.id.action_move_or_copy,
|
||||
R.id.action_stream_media,
|
||||
|
||||
@@ -18,6 +18,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.os.BundleCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isEmpty
|
||||
import androidx.core.view.isVisible
|
||||
@@ -102,7 +103,9 @@ class FileActionsBottomSheet :
|
||||
|
||||
viewModel.load(requireArguments(), componentsGetter)
|
||||
|
||||
endpoints = arguments?.getParcelableArrayList(FileActionsViewModel.ARG_ENDPOINTS)
|
||||
endpoints = arguments?.let { bundle ->
|
||||
BundleCompat.getParcelableArrayList(bundle, FileActionsViewModel.ARG_ENDPOINTS, Endpoint::class.java)
|
||||
} ?: mutableListOf()
|
||||
|
||||
val bottomSheetDialog = dialog as BottomSheetDialog
|
||||
bottomSheetDialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
@@ -368,7 +371,7 @@ class FileActionsBottomSheet :
|
||||
FileActionsViewModel.ARG_FILES to ArrayList<OCFile>(files),
|
||||
FileActionsViewModel.ARG_IS_OVERFLOW to isOverflow,
|
||||
FileActionsViewModel.ARG_IN_SINGLE_FILE_FRAGMENT to inSingleFileFragment,
|
||||
FileActionsViewModel.ARG_ENDPOINTS to endpoints
|
||||
FileActionsViewModel.ARG_ENDPOINTS to java.util.ArrayList(endpoints)
|
||||
)
|
||||
additionalToHide?.let {
|
||||
argsBundle.putIntArray(FileActionsViewModel.ARG_ADDITIONAL_FILTER, additionalToHide.toIntArray())
|
||||
|
||||
@@ -9,7 +9,7 @@ package com.nextcloud.utils
|
||||
import com.owncloud.android.BuildConfig
|
||||
|
||||
object BuildHelper {
|
||||
const val GPLAY: String = "gplay"
|
||||
fun isFlavourGPlay(): Boolean = BuildConfig.FLAVOR == "gplay"
|
||||
|
||||
fun isFlavourGPlay(): Boolean = GPLAY == BuildConfig.FLAVOR
|
||||
fun isHuaweiFlavor(): Boolean = BuildConfig.FLAVOR == "huawei"
|
||||
}
|
||||
@@ -11,7 +11,8 @@ import android.graphics.drawable.BitmapDrawable
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.nextcloud.utils.extensions.getBitmapSize
|
||||
import com.nextcloud.utils.extensions.getExifSize
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -41,8 +42,8 @@ object OCFileUtils {
|
||||
// Local file
|
||||
val path = ocFile.storagePath
|
||||
if (!path.isNullOrEmpty() && ocFile.exists()) {
|
||||
getExifSize(path)?.let { return it }
|
||||
getBitmapSize(path)?.let { return it }
|
||||
path.getExifSize()?.let { return it }
|
||||
path.getBitmapSize()?.let { return it }
|
||||
}
|
||||
|
||||
// 3 Fallback
|
||||
@@ -55,41 +56,6 @@ object OCFileUtils {
|
||||
return fallbackPair
|
||||
}
|
||||
|
||||
private fun getExifSize(path: String): Pair<Int, Int>? = try {
|
||||
val exif = ExifInterface(path)
|
||||
var w = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0)
|
||||
var h = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0)
|
||||
|
||||
val orientation = exif.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION,
|
||||
ExifInterface.ORIENTATION_NORMAL
|
||||
)
|
||||
if (orientation == ExifInterface.ORIENTATION_ROTATE_90 ||
|
||||
orientation == ExifInterface.ORIENTATION_ROTATE_270
|
||||
) {
|
||||
val tmp = w
|
||||
w = h
|
||||
h = tmp
|
||||
}
|
||||
|
||||
Log_OC.d(TAG, "Using exif imageDimension: $w x $h")
|
||||
if (w > 0 && h > 0) w to h else null
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
private fun getBitmapSize(path: String): Pair<Int, Int>? = try {
|
||||
val options = android.graphics.BitmapFactory.Options().apply { inJustDecodeBounds = true }
|
||||
android.graphics.BitmapFactory.decodeFile(path, options)
|
||||
val w = options.outWidth
|
||||
val h = options.outHeight
|
||||
|
||||
Log_OC.d(TAG, "Using bitmap factory imageDimension: $w x $h")
|
||||
if (w > 0 && h > 0) w to h else null
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
fun getMediaPlaceholder(file: OCFile, imageDimension: Pair<Int, Int>): BitmapDrawable {
|
||||
val context = MainApp.getAppContext()
|
||||
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import com.nextcloud.client.database.entity.toOCCapability
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.OCShare
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -48,3 +50,6 @@ fun FileDataStorageManager.getNonEncryptedSubfolders(id: Long, accountName: Stri
|
||||
fileDao.getNonEncryptedSubfolders(id, accountName).map {
|
||||
createFileInstance(it)
|
||||
}
|
||||
|
||||
suspend fun FileDataStorageManager.getCapabilitiesByAccountName(accountName: String): OCCapability =
|
||||
capabilityDao.getByAccountName(accountName).toOCCapability()
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
@@ -36,7 +37,7 @@ fun Path.toLocalPath(): String = toAbsolutePath().toString()
|
||||
* @return [File] instance if the file exists, or `null` if the path is null, empty, or non-existent.
|
||||
*/
|
||||
@Suppress("ReturnCount")
|
||||
fun String.toFile(): File? {
|
||||
fun String?.toFile(): File? {
|
||||
if (isNullOrEmpty()) {
|
||||
Log_OC.w(TAG, "given path is null or empty: $this")
|
||||
return null
|
||||
@@ -50,3 +51,38 @@ fun String.toFile(): File? {
|
||||
|
||||
return file
|
||||
}
|
||||
|
||||
fun String.getExifSize(): Pair<Int, Int>? = try {
|
||||
val exif = ExifInterface(this)
|
||||
var w = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0)
|
||||
var h = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0)
|
||||
|
||||
val orientation = exif.getAttributeInt(
|
||||
ExifInterface.TAG_ORIENTATION,
|
||||
ExifInterface.ORIENTATION_NORMAL
|
||||
)
|
||||
if (orientation == ExifInterface.ORIENTATION_ROTATE_90 ||
|
||||
orientation == ExifInterface.ORIENTATION_ROTATE_270
|
||||
) {
|
||||
val tmp = w
|
||||
w = h
|
||||
h = tmp
|
||||
}
|
||||
|
||||
Log_OC.d(TAG, "Using exif imageDimension: $w x $h")
|
||||
if (w > 0 && h > 0) w to h else null
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
fun String.getBitmapSize(): Pair<Int, Int>? = try {
|
||||
val options = android.graphics.BitmapFactory.Options().apply { inJustDecodeBounds = true }
|
||||
android.graphics.BitmapFactory.decodeFile(this, options)
|
||||
val w = options.outWidth
|
||||
val h = options.outHeight
|
||||
|
||||
Log_OC.d(TAG, "Using bitmap factory imageDimension: $w x $h")
|
||||
if (w > 0 && h > 0) w to h else null
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2026 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import com.nextcloud.utils.TimeConstants
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile
|
||||
import com.owncloud.android.utils.FileUtil
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
|
||||
fun RemoteFile.isSame(path: String?): Boolean {
|
||||
val localFile = path?.toFile() ?: return false
|
||||
|
||||
// remote file timestamp in millisecond not microsecond
|
||||
val localLastModifiedTimestamp = localFile.lastModified() / TimeConstants.MILLIS_PER_SECOND
|
||||
val localCreationTimestamp = FileUtil.getCreationTimestamp(localFile)
|
||||
val localSize: Long = localFile.length()
|
||||
|
||||
return size == localSize &&
|
||||
localCreationTimestamp != null &&
|
||||
localCreationTimestamp == creationTimestamp &&
|
||||
modifiedTimestamp == localLastModifiedTimestamp * TimeConstants.MILLIS_PER_SECOND &&
|
||||
this.areImageDimensionsSame(path)
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun RemoteFile.areImageDimensionsSame(path: String): Boolean {
|
||||
if (!MimeTypeUtil.isImage(mimeType)) {
|
||||
// can't compare it's not image
|
||||
return true
|
||||
}
|
||||
|
||||
val localFileImageDimension = path.getExifSize() ?: path.getBitmapSize()
|
||||
if (localFileImageDimension == null) {
|
||||
// can't compare local file image dimension is not determined
|
||||
return true
|
||||
}
|
||||
|
||||
return localFileImageDimension.first.toFloat() == imageDimension?.width &&
|
||||
localFileImageDimension.second.toFloat() == imageDimension?.height
|
||||
}
|
||||
@@ -25,6 +25,13 @@ fun String.removeFileExtension(): String {
|
||||
}
|
||||
}
|
||||
|
||||
fun String.webDavParentPath(): String {
|
||||
val normalized = this.trimEnd('/')
|
||||
if (normalized.isEmpty()) return "/"
|
||||
val parent = normalized.substringBeforeLast('/', "")
|
||||
return if (parent.isEmpty()) "/" else "$parent/"
|
||||
}
|
||||
|
||||
@Suppress("ComplexCondition")
|
||||
fun String?.eTagChanged(eTagOnServer: String?): Boolean {
|
||||
if (this == null || this.isEmpty() || eTagOnServer == null || eTagOnServer.isEmpty()) {
|
||||
|
||||
@@ -94,7 +94,7 @@ fun UploadResult.getFailedStatusText(context: Context): String = when (this) {
|
||||
|
||||
UploadResult.OLD_ANDROID_API -> context.getString(R.string.upload_old_android)
|
||||
|
||||
UploadResult.SYNC_CONFLICT -> context.getString(R.string.upload_sync_conflict)
|
||||
UploadResult.SYNC_CONFLICT -> context.getString(R.string.upload_sync_conflict_check)
|
||||
|
||||
UploadResult.CANNOT_CREATE_FILE -> context.getString(R.string.upload_cannot_create_file)
|
||||
|
||||
|
||||
@@ -17,15 +17,12 @@ import com.nextcloud.utils.fileNameValidator.FileNameValidator.isFileHidden
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
|
||||
/**
|
||||
* A TextWatcher which wraps around [FileNameValidator]
|
||||
*/
|
||||
@Suppress("LongParameterList")
|
||||
class FileNameTextWatcher(
|
||||
private val previousFileName: String?,
|
||||
private val context: Context,
|
||||
private val capabilitiesProvider: () -> OCCapability,
|
||||
private val existingFileNamesProvider: () -> Set<String>?,
|
||||
private val existingFileNamesProvider: () -> Set<String>,
|
||||
private val onValidationError: Consumer<String>,
|
||||
private val onValidationWarning: Consumer<String>,
|
||||
private val onValidationSuccess: Runnable
|
||||
|
||||
@@ -34,20 +34,19 @@ object FileNameValidator {
|
||||
* @return An error message if the filename is invalid, null otherwise.
|
||||
*/
|
||||
@Suppress("ReturnCount", "NestedBlockDepth")
|
||||
@JvmOverloads
|
||||
fun checkFileName(
|
||||
filename: String,
|
||||
capability: OCCapability,
|
||||
context: Context,
|
||||
existingFileNames: Set<String>? = null
|
||||
existingFileNames: Set<String> = setOf()
|
||||
): String? {
|
||||
if (filename.isBlank()) {
|
||||
return context.getString(R.string.filename_empty)
|
||||
}
|
||||
|
||||
existingFileNames?.let {
|
||||
if (isFileNameAlreadyExist(filename, existingFileNames)) {
|
||||
return context.getString(R.string.file_already_exists)
|
||||
}
|
||||
if (isFileNameAlreadyExist(filename, existingFileNames)) {
|
||||
return context.getString(R.string.file_already_exists)
|
||||
}
|
||||
|
||||
if (!capability.checkWCFRestrictions()) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.google.gson.JsonSyntaxException;
|
||||
import com.nextcloud.android.lib.resources.files.FileDownloadLimit;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.database.NextcloudDatabase;
|
||||
import com.nextcloud.client.database.dao.CapabilityDao;
|
||||
import com.nextcloud.client.database.dao.FileDao;
|
||||
import com.nextcloud.client.database.dao.OfflineOperationDao;
|
||||
import com.nextcloud.client.database.dao.RecommendedFileDao;
|
||||
@@ -112,6 +113,7 @@ public class FileDataStorageManager {
|
||||
public final OfflineOperationDao offlineOperationDao = NextcloudDatabase.getInstance(MainApp.getAppContext()).offlineOperationDao();
|
||||
public final FileDao fileDao = NextcloudDatabase.getInstance(MainApp.getAppContext()).fileDao();
|
||||
public final ShareDao shareDao = NextcloudDatabase.getInstance(MainApp.getAppContext()).shareDao();
|
||||
public final CapabilityDao capabilityDao = NextcloudDatabase.instance().capabilityDao();
|
||||
|
||||
private final Gson gson = new Gson();
|
||||
public final OfflineOperationsRepositoryType offlineOperationsRepository;
|
||||
@@ -358,8 +360,12 @@ public class FileDataStorageManager {
|
||||
offlineOperationsRepository.updateNextOperations(entity);
|
||||
}
|
||||
|
||||
private @Nullable
|
||||
OCFile getFileByPath(String type, String path) {
|
||||
@Nullable
|
||||
private OCFile getFileByPath(String type, String path) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final boolean shouldUseEncryptedPath = ProviderTableMeta.FILE_PATH.equals(type);
|
||||
FileEntity fileEntity = shouldUseEncryptedPath ?
|
||||
fileDao.getFileByEncryptedRemotePath(path, user.getAccountName()) :
|
||||
@@ -934,13 +940,13 @@ public class FileDataStorageManager {
|
||||
String expectedPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), ocFile);
|
||||
if (!localPath.equalsIgnoreCase(expectedPath)) {
|
||||
Log_OC.w(TAG, "removeLocalCopyIfNeeded: Path mismatch! Expected " + expectedPath
|
||||
+ " but found " + localPath + ". Skipping deletion to prevent data loss.");
|
||||
+ " but found " + localPath + ". Deleting from actual local path.");
|
||||
}
|
||||
|
||||
Log_OC.d(TAG, "removeLocalCopyIfNeeded: deleting local file -> " + localPath);
|
||||
boolean success = false;
|
||||
try {
|
||||
success = new File(expectedPath).delete();
|
||||
success = new File(localPath).delete();
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "removeLocalCopyIfNeeded: deletion error: ", e);
|
||||
}
|
||||
|
||||
@@ -187,6 +187,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
/**
|
||||
* Add thumbnail to cache
|
||||
*
|
||||
* @param imageKey: thumb key
|
||||
* @param bitmap: image for extracting thumbnail
|
||||
* @param path: image path
|
||||
@@ -194,7 +195,7 @@ public final class ThumbnailsCacheManager {
|
||||
* @param pxH: thumbnail height in pixel
|
||||
* @return Bitmap
|
||||
*/
|
||||
private static Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path, int pxW, int pxH){
|
||||
public static Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path, int pxW, int pxH) {
|
||||
|
||||
Bitmap thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
|
||||
|
||||
@@ -1092,10 +1093,12 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
c.drawBitmap(thumbnail, 0, 0, null);
|
||||
|
||||
float left = (thumbnail.getWidth() - px) / 2f;
|
||||
float top = (thumbnail.getHeight() - px) / 2f;
|
||||
|
||||
Paint p = new Paint();
|
||||
p.setAlpha(230);
|
||||
|
||||
c.drawBitmap(resizedPlayButton, px, px, p);
|
||||
c.drawBitmap(resizedPlayButton, left, top, p);
|
||||
|
||||
return resultBitmap;
|
||||
}
|
||||
@@ -1140,7 +1143,7 @@ public final class ThumbnailsCacheManager {
|
||||
/**
|
||||
* adapted from <a href="https://stackoverflow.com/a/8113368">...</a>
|
||||
*/
|
||||
private static Bitmap handlePNG(Bitmap source, int newWidth, int newHeight) {
|
||||
public static Bitmap handlePNG(Bitmap source, int newWidth, int newHeight) {
|
||||
Bitmap softwareBitmap = source.copy(Bitmap.Config.ARGB_8888, false);
|
||||
|
||||
int sourceWidth = source.getWidth();
|
||||
@@ -1296,7 +1299,7 @@ public final class ThumbnailsCacheManager {
|
||||
Log_OC.d(TAG, "resized image generated");
|
||||
}
|
||||
} else {
|
||||
Log_OC.e(TAG, "cannot generate thumbnail not supported file type, status: " + status);
|
||||
Log_OC.e(TAG, "cannot generate thumbnail not supported file type, status: " + status + " file: " + file.getRemotePath());
|
||||
mClient.exhaustResponse(getMethod.getResponseBodyAsStream());
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils
|
||||
import java.io.File
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.Observable
|
||||
@@ -485,7 +484,7 @@ class UploadsStorageManager(
|
||||
} else if (code.isConflict()) {
|
||||
val isSame = FileUploadHelper().isSameFileOnRemote(
|
||||
upload.user,
|
||||
File(upload.storagePath),
|
||||
upload.storagePath,
|
||||
upload.remotePath,
|
||||
upload.context
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ProviderMeta {
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 99;
|
||||
public static final int DB_VERSION = 100;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
|
||||
@@ -18,7 +18,9 @@ import android.text.TextUtils;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.nextcloud.utils.extensions.ContextExtensionsKt;
|
||||
import com.nextcloud.utils.extensions.OwnCloudClientExtensionsKt;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProviderImpl;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -42,7 +44,6 @@ import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -205,7 +206,8 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
dataTransferListeners.forEach(downloadOperation::addDatatransferProgressListener);
|
||||
}
|
||||
|
||||
result = downloadOperation.execute(client);
|
||||
NextcloudClient nextcloudClient = OwnCloudClientExtensionsKt.toNextcloudClient(client, operationContext);
|
||||
result = downloadOperation.execute(nextcloudClient);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1298,13 +1298,8 @@ public class UploadFileOperation extends SyncOperation {
|
||||
// check if its real SYNC_CONFLICT
|
||||
boolean isSameFileOnRemote = false;
|
||||
if (mFile != null) {
|
||||
String localPath = mFile.getStoragePath();
|
||||
|
||||
if (localPath != null) {
|
||||
File localFile = new File(localPath);
|
||||
isSameFileOnRemote = FileUploadHelper.Companion.instance()
|
||||
.isSameFileOnRemote(user, localFile, mRemotePath, mContext);
|
||||
}
|
||||
isSameFileOnRemote = FileUploadHelper.Companion.instance()
|
||||
.isSameFileOnRemote(user, mFile.getStoragePath(), mRemotePath, mContext);
|
||||
}
|
||||
|
||||
if (isSameFileOnRemote) {
|
||||
|
||||
Loaded 100 of 275 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user