Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86dfc9f550 | ||
|
|
9313545eb3 |
No files matched your search
@@ -1,11 +1,9 @@
|
||||
# synced from @nextcloud/android-config
|
||||
|
||||
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023 Josh Richards <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2025 Marcel Hibbe <[email protected]>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
name: "Analysis"
|
||||
@@ -26,14 +24,9 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Disabled on forks
|
||||
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
|
||||
run: |
|
||||
echo 'Can not analyze PRs from forks'
|
||||
exit 1
|
||||
- name: Setup variables # zizmor: ignore[template-injection]
|
||||
- name: Setup variables
|
||||
id: get-vars
|
||||
run: |
|
||||
if [ -z "$GITHUB_HEAD_REF" ]; then
|
||||
@@ -53,11 +46,10 @@ jobs:
|
||||
fi
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
@@ -69,11 +61,9 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
{
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g"
|
||||
echo "org.gradle.caching=true"
|
||||
echo "org.gradle.parallel=true"
|
||||
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 }}"
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" > "$HOME/.gradle/gradle.properties"
|
||||
echo "org.gradle.caching=true" >> $HOME/.gradle/gradle.properties
|
||||
echo "org.gradle.parallel=true" >> $HOME/.gradle/gradle.properties
|
||||
echo "org.gradle.configureondemand=true" >> $HOME/.gradle/gradle.properties
|
||||
echo "kapt.incremental.apt=true" >> $HOME/.gradle/gradle.properties
|
||||
scripts/analysis/analysis-wrapper.sh ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} "$GITHUB_RUN_NUMBER" ${{ steps.get-vars.outputs.pr }}
|
||||
@@ -28,7 +28,6 @@ jobs:
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
- uses: gradle/actions/wrapper-validation@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||
- name: Build ${{ matrix.flavor }}
|
||||
run: |
|
||||
echo "org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" >> gradle.properties
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
name: Auto approve sync
|
||||
on:
|
||||
pull_request_target: # zizmor: ignore[dangerous-triggers]
|
||||
pull_request_target:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# SPDX-FileCopyrightText: 2023-2024 Andy Scherzinger <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2022 Tobias Kaminsky <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2022 Álvaro Brey <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2025 Marcel Hibbe <[email protected]>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
name: "CodeQL"
|
||||
@@ -23,7 +22,7 @@ permissions:
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
@@ -35,19 +34,16 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set Swap Space
|
||||
if: runner.environment == 'github-hosted'
|
||||
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
|
||||
uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 17
|
||||
@@ -57,4 +53,4 @@ jobs:
|
||||
echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
|
||||
uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
|
||||
@@ -0,0 +1,29 @@
|
||||
# synced from @nextcloud/android-config
|
||||
|
||||
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-FileCopyrightText: 2023 Andy Scherzinger <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023 Tobias Kaminsky <[email protected]>
|
||||
# SPDX-FileCopyrightText: 2023 Álvaro Brey <[email protected]>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
name: "Validate Gradle Wrapper"
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
concurrency:
|
||||
group: validate-gradle-wrapper-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
validation:
|
||||
name: "Validation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: gradle/wrapper-validation-action@f9c9c575b8b21b6485636a91ffecd10e558c62f6 # v3.5.0
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -)
|
||||
echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: nextcloud/pr-feedback-action@1883b38a033fb16f576875e0cf45f98b857655c4 # main
|
||||
- uses: marcelklehr/pr-feedback-action@1883b38a033fb16f576875e0cf45f98b857655c4
|
||||
with:
|
||||
feedback-message: |
|
||||
Hello there,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
name: Auto approve renovate PRs
|
||||
|
||||
on:
|
||||
pull_request_target: # zizmor: ignore[dangerous-triggers]
|
||||
pull_request_target:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
@@ -24,7 +24,7 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
auto-approve-merge:
|
||||
if: github.event.pull_request.user.login == 'renovate[bot]'
|
||||
if: github.actor == 'renovate[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# for hmarr/auto-approve-action to approve PRs
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
|
||||
# Enable GitHub auto merge
|
||||
- name: Auto merge
|
||||
uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # v2.0.0
|
||||
uses: alexwilson/enable-github-automerge-action@main
|
||||
if: startsWith(steps.branchname.outputs.branch, 'renovate/')
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -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@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
|
||||
uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -28,14 +28,14 @@ jobs:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
- name: AVD cache
|
||||
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
|
||||
uses: actions/cache@0c907a75c2c80ebcb7f088228285e798b750cf8f # v4.2.1
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
|
||||
- name: create AVD and generate snapshot for caching
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
|
||||
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
- name: Run screenshot tests
|
||||
env:
|
||||
SHOT_TEST: "true"
|
||||
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
|
||||
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
@@ -102,7 +102,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@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
if: ${{ always() }}
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}}
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0
|
||||
- name: Run unit tests with coverage
|
||||
run: ./gradlew jacocoTestGplayDebugUnitTest
|
||||
- name: Upload failing results
|
||||
@@ -42,14 +42,14 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
|
||||
- name: Upload coverage to codecov
|
||||
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
|
||||
uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
fail_ci_if_error: true
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/tests/testGplayDebugUnitTest/
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.20
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.20
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.20
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.20
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.20
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.20
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #2 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
Problems may have occurred during auto-selection of GC. The preferred GC is Parallel GC.
|
||||
If the problems persist, try adding the JVM option to the Kotlin daemon JVM arguments: -XX:-UseParallelGC.
|
||||
GC auto-selection logic is disabled temporary for the next daemon startup.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
kotlin version: 2.0.21
|
||||
error message: The daemon has terminated unexpectedly on startup attempt #1 with error code: 0. The daemon process output:
|
||||
1. Kotlin compile daemon is ready
|
||||
|
||||
@@ -9,22 +9,21 @@ GEM
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.3.2)
|
||||
aws-partitions (1.1066.0)
|
||||
aws-sdk-core (3.220.1)
|
||||
aws-eventstream (1.3.0)
|
||||
aws-partitions (1.1021.0)
|
||||
aws-sdk-core (3.214.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
aws-sdk-kms (1.99.0)
|
||||
aws-sdk-core (~> 3, >= 3.216.0)
|
||||
aws-sdk-kms (1.96.0)
|
||||
aws-sdk-core (~> 3, >= 3.210.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.182.0)
|
||||
aws-sdk-core (~> 3, >= 3.216.0)
|
||||
aws-sdk-s3 (1.176.0)
|
||||
aws-sdk-core (~> 3, >= 3.210.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.11.0)
|
||||
aws-sigv4 (1.10.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
base64 (0.2.0)
|
||||
@@ -35,7 +34,7 @@ GEM
|
||||
commander (4.6.0)
|
||||
highline (~> 2.0.0)
|
||||
declarative (0.0.20)
|
||||
digest-crc (0.7.0)
|
||||
digest-crc (0.6.5)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
domain_name (0.6.20240107)
|
||||
dotenv (2.8.1)
|
||||
@@ -60,8 +59,8 @@ GEM
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.1.0)
|
||||
multipart-post (~> 2.0)
|
||||
faraday-multipart (1.0.4)
|
||||
multipart-post (~> 2)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
@@ -69,8 +68,8 @@ GEM
|
||||
faraday-retry (1.0.3)
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.4.0)
|
||||
fastlane (2.227.0)
|
||||
fastimage (2.3.1)
|
||||
fastlane (2.226.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
@@ -133,12 +132,12 @@ GEM
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
google-apis-storage_v1 (0.31.0)
|
||||
google-apis-core (>= 0.11.0, < 2.a)
|
||||
google-cloud-core (1.8.0)
|
||||
google-cloud-core (1.7.1)
|
||||
google-cloud-env (>= 1.0, < 3.a)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (1.6.0)
|
||||
faraday (>= 0.17.3, < 3.0)
|
||||
google-cloud-errors (1.5.0)
|
||||
google-cloud-errors (1.4.0)
|
||||
google-cloud-storage (1.47.0)
|
||||
addressable (~> 2.8)
|
||||
digest-crc (~> 0.4)
|
||||
@@ -156,23 +155,21 @@ GEM
|
||||
highline (2.0.3)
|
||||
http-cookie (1.0.8)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
httpclient (2.8.3)
|
||||
jmespath (1.6.2)
|
||||
json (2.10.2)
|
||||
jwt (2.10.1)
|
||||
json (2.9.0)
|
||||
jwt (2.9.3)
|
||||
base64
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
naturally (2.2.1)
|
||||
nkf (0.2.0)
|
||||
optparse (0.6.0)
|
||||
os (1.1.4)
|
||||
plist (3.7.2)
|
||||
plist (3.7.1)
|
||||
public_suffix (6.0.1)
|
||||
rake (13.2.1)
|
||||
representable (3.2.0)
|
||||
@@ -180,10 +177,10 @@ GEM
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (3.1.2)
|
||||
rexml (3.4.1)
|
||||
rexml (3.3.9)
|
||||
rouge (3.28.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
rubyzip (2.3.2)
|
||||
security (0.1.5)
|
||||
signet (0.19.0)
|
||||
addressable (~> 2.8)
|
||||
|
||||
@@ -16,11 +16,11 @@ import org.gradle.internal.jvm.Jvm
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:$androidPluginVersion"
|
||||
classpath libs.spotbugs.gradle.plugin
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:6.1.5'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.8"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.7"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath "com.karumi:shot:6.1.0"
|
||||
classpath 'com.karumi:shot:6.1.0'
|
||||
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
|
||||
@@ -28,39 +28,39 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
id "org.jetbrains.kotlin.plugin.compose" version "2.1.10"
|
||||
id "com.diffplug.spotless" version "6.25.0"
|
||||
id "org.jetbrains.kotlin.kapt" version "2.1.20"
|
||||
id "com.google.devtools.ksp" version "2.1.20-1.0.32" apply false
|
||||
id "org.jetbrains.kotlin.kapt" version "2.1.10"
|
||||
id 'com.google.devtools.ksp' version '2.1.10-1.0.30' apply false
|
||||
}
|
||||
|
||||
apply plugin: "com.android.application"
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: "kotlin-android"
|
||||
apply plugin: "kotlin-parcelize"
|
||||
apply plugin: "checkstyle"
|
||||
apply plugin: "pmd"
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'pmd'
|
||||
apply from: "$rootProject.projectDir/jacoco.gradle"
|
||||
apply plugin: "com.github.spotbugs"
|
||||
apply plugin: "io.gitlab.arturbosch.detekt"
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
apply plugin: 'io.gitlab.arturbosch.detekt'
|
||||
|
||||
// needed to make renovate run without shot, as shot requires Android SDK
|
||||
// https://github.com/pedrovgs/Shot/issues/300
|
||||
if (shotTest) {
|
||||
apply plugin: "shot"
|
||||
apply plugin: 'shot'
|
||||
}
|
||||
apply plugin: "com.google.devtools.ksp"
|
||||
apply plugin: 'com.google.devtools.ksp'
|
||||
|
||||
|
||||
println "Gradle uses Java ${Jvm.current()}"
|
||||
|
||||
configurations {
|
||||
configureEach {
|
||||
exclude group: "org.jetbrains", module: "annotations-java5" // via prism4j, already using annotations explicitly
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
|
||||
|
||||
// check for updates every build
|
||||
resolutionStrategy {
|
||||
cacheChangingModulesFor 0, "seconds"
|
||||
cacheChangingModulesFor 0, 'seconds'
|
||||
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
|
||||
}
|
||||
}
|
||||
@@ -85,18 +85,18 @@ def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
def ndkEnv = new HashMap<String, String>()
|
||||
file("$project.rootDir/ndk.env").readLines().each() {
|
||||
def (key, value) = it.tokenize("=")
|
||||
def (key, value) = it.tokenize('=')
|
||||
ndkEnv.put(key, value)
|
||||
}
|
||||
|
||||
def perfAnalysis = project.hasProperty("perfAnalysis")
|
||||
def perfAnalysis = project.hasProperty('perfAnalysis')
|
||||
|
||||
android {
|
||||
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
|
||||
ndkVersion "${ndkEnv.get("NDK_VERSION")}"
|
||||
|
||||
|
||||
namespace "com.owncloud.android"
|
||||
namespace 'com.owncloud.android'
|
||||
testNamespace "${namespace}.test"
|
||||
|
||||
androidResources {
|
||||
@@ -109,8 +109,8 @@ android {
|
||||
targetSdkVersion 35
|
||||
compileSdk 35
|
||||
|
||||
buildConfigField "boolean", "CI", ciBuild.toString()
|
||||
buildConfigField "boolean", "RUNTIME_PERF_ANALYSIS", perfAnalysis.toString()
|
||||
buildConfigField 'boolean', 'CI', ciBuild.toString()
|
||||
buildConfigField 'boolean', 'RUNTIME_PERF_ANALYSIS', perfAnalysis.toString()
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@@ -127,7 +127,7 @@ android {
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
|
||||
testInstrumentationRunnerArguments disableAnalytics: "true"
|
||||
testInstrumentationRunnerArguments disableAnalytics: 'true'
|
||||
|
||||
versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
|
||||
@@ -146,7 +146,7 @@ android {
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
testCoverageEnabled(project.hasProperty("coverage"))
|
||||
testCoverageEnabled(project.hasProperty('coverage'))
|
||||
resConfigs "xxxhdpi"
|
||||
}
|
||||
}
|
||||
@@ -158,25 +158,25 @@ android {
|
||||
productFlavors {
|
||||
// used for f-droid
|
||||
generic {
|
||||
applicationId "com.nextcloud.client"
|
||||
applicationId 'com.nextcloud.client'
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
gplay {
|
||||
applicationId "com.nextcloud.client"
|
||||
applicationId 'com.nextcloud.client'
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
huawei {
|
||||
applicationId "com.nextcloud.client"
|
||||
applicationId 'com.nextcloud.client'
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20250412
|
||||
versionName "20250412"
|
||||
versionCode 20220322
|
||||
versionName "20220322"
|
||||
}
|
||||
|
||||
qa {
|
||||
@@ -197,18 +197,18 @@ android {
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += "META-INF/LICENSE*"
|
||||
excludes += "META-INF/versions/9/OSGI-INF/MANIFEST*"
|
||||
pickFirst "MANIFEST.MF" // workaround for duplicated manifest on some dependencies
|
||||
excludes += 'META-INF/LICENSE*'
|
||||
excludes += 'META-INF/versions/9/OSGI-INF/MANIFEST*'
|
||||
pickFirst 'MANIFEST.MF' // workaround for duplicated manifest on some dependencies
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkstyle", Checkstyle) {
|
||||
configFile = file("${rootProject.projectDir}/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
|
||||
source "src"
|
||||
include "**/*.java"
|
||||
exclude "**/gen/**"
|
||||
source 'src'
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
classpath = files()
|
||||
}
|
||||
|
||||
@@ -217,9 +217,9 @@ android {
|
||||
ignoreFailures = true // should continue checking
|
||||
ruleSets = []
|
||||
|
||||
source "src"
|
||||
include "**/*.java"
|
||||
exclude "**/gen/**"
|
||||
source 'src'
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
|
||||
reports {
|
||||
xml {
|
||||
@@ -231,7 +231,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn "checkstyle", "spotbugsGplayDebug", "pmd", "lint", "spotlessKotlinCheck", "detekt"
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebug', 'pmd', 'lint', 'spotlessKotlinCheck', 'detekt'
|
||||
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
@@ -252,7 +252,7 @@ android {
|
||||
lint {
|
||||
abortOnError false
|
||||
checkGeneratedSources true
|
||||
disable "MissingTranslation", "GradleDependency", "VectorPath", "IconMissingDensityFolder", "IconDensities", "GoogleAppIndexingWarning", "MissingDefaultResource", "InvalidPeriodicWorkRequestInterval", "StringFormatInvalid", "MissingQuantity"
|
||||
disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities', 'GoogleAppIndexingWarning', 'MissingDefaultResource', 'InvalidPeriodicWorkRequestInterval', 'StringFormatInvalid', 'MissingQuantity'
|
||||
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
||||
htmlReport true
|
||||
}
|
||||
@@ -269,62 +269,62 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: "org.ogce", module: "xpp3" // unused in Android and brings wrong Junit version
|
||||
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
|
||||
}
|
||||
|
||||
// Jetpack Compose
|
||||
implementation(platform(libs.androidx.compose.bom))
|
||||
implementation(libs.androidx.ui)
|
||||
implementation(libs.androidx.ui.graphics)
|
||||
implementation(libs.material3)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
implementation(libs.androidx.ui.tooling.preview)
|
||||
implementation(platform("androidx.compose:compose-bom:2025.02.00"))
|
||||
implementation("androidx.compose.ui:ui")
|
||||
implementation("androidx.compose.ui:ui-graphics")
|
||||
implementation("androidx.compose.material3:material3")
|
||||
debugImplementation("androidx.compose.ui:ui-tooling")
|
||||
implementation("androidx.compose.ui:ui-tooling-preview")
|
||||
|
||||
compileOnly "org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2"
|
||||
compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
|
||||
// remove after entire switch to lib v2
|
||||
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
implementation "org.apache.jackrabbit:jackrabbit-webdav:2.13.5" // remove after entire switch to lib v2
|
||||
implementation "androidx.constraintlayout:constraintlayout:2.2.1"
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
implementation "com.google.android.material:material:1.12.0"
|
||||
implementation "com.jakewharton:disklrucache:2.0.2"
|
||||
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5' // remove after entire switch to lib v2
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.12.0'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation "androidx.appcompat:appcompat:$appCompatVersion"
|
||||
implementation "androidx.webkit:webkit:1.12.1"
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation "androidx.exifinterface:exifinterface:1.4.0"
|
||||
implementation 'androidx.webkit:webkit:1.12.1'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.3.7'
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7"
|
||||
implementation "androidx.lifecycle:lifecycle-service:2.8.7"
|
||||
implementation "androidx.work:work-runtime:$workRuntime"
|
||||
implementation "androidx.work:work-runtime-ktx:$workRuntime"
|
||||
implementation "androidx.fragment:fragment-ktx:1.8.6"
|
||||
implementation "com.github.albfernandez:juniversalchardet:2.0.3" // need this version for Android <7
|
||||
compileOnly "com.google.code.findbugs:annotations:3.0.1u2"
|
||||
implementation "commons-io:commons-io:2.18.0"
|
||||
implementation "org.greenrobot:eventbus:3.3.1"
|
||||
implementation "com.googlecode.ez-vcard:ez-vcard:0.12.1"
|
||||
implementation "org.lukhnos:nnio:0.3.1"
|
||||
implementation "org.bouncycastle:bcpkix-jdk18on:1.80"
|
||||
implementation "com.google.code.gson:gson:2.12.1"
|
||||
implementation "com.github.nextcloud-deps:sectioned-recyclerview:0.6.1"
|
||||
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
||||
implementation "pl.droidsonroids.gif:android-gif-drawable:1.2.29"
|
||||
implementation "com.github.nextcloud-deps:qrcodescanner:0.1.2.4" // "com.github.blikoon:QRCodeScanner:0.1.2"
|
||||
implementation "com.google.android.flexbox:flexbox:3.0.0"
|
||||
implementation("com.github.bumptech.glide:glide:3.8.0") {
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
|
||||
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
|
||||
implementation 'commons-io:commons-io:2.18.0'
|
||||
implementation 'org.greenrobot:eventbus:3.3.1'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.12.1'
|
||||
implementation 'org.lukhnos:nnio:0.3.1'
|
||||
implementation 'org.bouncycastle:bcpkix-jdk18on:1.80'
|
||||
implementation 'com.google.code.gson:gson:2.12.1'
|
||||
implementation 'com.github.nextcloud-deps:sectioned-recyclerview:0.6.1'
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.29'
|
||||
implementation 'com.github.nextcloud-deps:qrcodescanner:0.1.2.4' // 'com.github.blikoon:QRCodeScanner:0.1.2'
|
||||
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
||||
implementation('com.github.bumptech.glide:glide:3.8.0') {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
implementation "com.caverock:androidsvg:1.4"
|
||||
implementation "androidx.annotation:annotation:1.9.1"
|
||||
implementation "com.vanniktech:emoji-google:0.21.0"
|
||||
implementation 'com.caverock:androidsvg:1.4'
|
||||
implementation 'androidx.annotation:annotation:1.9.1'
|
||||
implementation 'com.vanniktech:emoji-google:0.21.0'
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
|
||||
|
||||
// document scanner not available on FDroid (generic) due to OpenCV binaries
|
||||
gplayImplementation project(":appscan")
|
||||
huaweiImplementation project(":appscan")
|
||||
qaImplementation project(":appscan")
|
||||
gplayImplementation project(':appscan')
|
||||
huaweiImplementation project(':appscan')
|
||||
qaImplementation project(':appscan')
|
||||
|
||||
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:1.13.0"
|
||||
spotbugsPlugins "com.mebigfatguy.fb-contrib:fb-contrib:7.6.9"
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.13.0'
|
||||
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.6.9'
|
||||
|
||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||
implementation "com.google.dagger:dagger-android:$daggerVersion"
|
||||
@@ -332,17 +332,17 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
implementation "org.conscrypt:conscrypt-android:2.5.3"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.5.3'
|
||||
|
||||
implementation "androidx.media3:media3-ui:$androidxMediaVersion"
|
||||
implementation "androidx.media3:media3-session:$androidxMediaVersion"
|
||||
implementation "androidx.media3:media3-exoplayer:$androidxMediaVersion"
|
||||
implementation "androidx.media3:media3-datasource-okhttp:$androidxMediaVersion"
|
||||
|
||||
implementation "me.zhanghai.android.fastscroll:library:1.3.0"
|
||||
implementation 'me.zhanghai.android.fastscroll:library:1.3.0'
|
||||
|
||||
// Shimmer animation
|
||||
implementation "io.github.elye:loaderviewlibrary:3.0.0"
|
||||
implementation 'io.github.elye:loaderviewlibrary:3.0.0'
|
||||
|
||||
// dependencies for markdown rendering
|
||||
implementation "io.noties.markwon:core:$markwonVersion"
|
||||
@@ -356,33 +356,33 @@ dependencies {
|
||||
kapt "io.noties:prism4j-bundler:$prismVersion"
|
||||
|
||||
// dependencies for image cropping and rotation
|
||||
implementation "com.vanniktech:android-image-cropper:4.6.0"
|
||||
implementation 'com.vanniktech:android-image-cropper:4.6.0'
|
||||
|
||||
implementation "org.osmdroid:osmdroid-android:6.1.20"
|
||||
implementation 'org.osmdroid:osmdroid-android:6.1.20'
|
||||
|
||||
implementation("org.mnode.ical4j:ical4j:3.0.0") {
|
||||
["org.apache.commons", "commons-logging"].each {
|
||||
implementation('org.mnode.ical4j:ical4j:3.0.0') {
|
||||
['org.apache.commons', 'commons-logging'].each {
|
||||
exclude group: "$it"
|
||||
}
|
||||
}
|
||||
|
||||
if (perfAnalysis) {
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:2.14"
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
|
||||
}
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation "junit:junit:4.13.2"
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
testImplementation "androidx.test:core:$androidxTestVersion"
|
||||
testImplementation "org.json:json:20250107"
|
||||
testImplementation 'org.json:json:20250107'
|
||||
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||
testImplementation 'androidx.arch.core:core-testing:2.2.0'
|
||||
testImplementation "io.mockk:mockk:$mockkVersion"
|
||||
testImplementation "io.mockk:mockk-android:$mockkVersion"
|
||||
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
androidTestImplementation "androidx.test.ext:junit:1.2.1"
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
|
||||
androidTestImplementation "androidx.test:rules:$androidxTestVersion"
|
||||
// Android JUnit Runner
|
||||
androidTestImplementation "androidx.test:runner:1.6.2"
|
||||
@@ -398,29 +398,29 @@ dependencies {
|
||||
androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
|
||||
|
||||
// Mocking support
|
||||
androidTestImplementation "com.github.tmurakami:dexopener:2.0.5" // required to allow mocking on API 27 and older
|
||||
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
|
||||
androidTestImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
androidTestImplementation("org.mockito:mockito-android:$mockitoVersion")
|
||||
androidTestImplementation "io.mockk:mockk-android:$mockkVersion"
|
||||
androidTestImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||
androidTestImplementation 'androidx.arch.core:core-testing:2.2.0'
|
||||
androidTestImplementation "com.facebook.testing.screenshot:core:0.15.0"
|
||||
|
||||
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
|
||||
// androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"
|
||||
// androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation "tools.fastlane:screengrab:2.1.1"
|
||||
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
|
||||
// upon each update first test: new registration, receive push
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:24.1.0"
|
||||
gplayImplementation "com.google.android.gms:play-services-base:18.5.0"
|
||||
gplayImplementation "com.google.android.play:review-ktx:2.0.2"
|
||||
gplayImplementation 'com.google.android.gms:play-services-base:18.5.0'
|
||||
gplayImplementation 'com.google.android.play:review-ktx:2.0.2'
|
||||
|
||||
implementation "com.github.nextcloud.android-common:ui:$androidCommonLibraryVersion"
|
||||
implementation 'com.github.nextcloud.android-common:ui:0.24.0'
|
||||
|
||||
implementation "androidx.room:room-runtime:$roomVersion"
|
||||
ksp "androidx.room:room-compiler:$roomVersion"
|
||||
@@ -429,15 +429,15 @@ dependencies {
|
||||
implementation "io.coil-kt:coil:2.7.0"
|
||||
|
||||
// splash screen dependency ref: https://developer.android.com/develop/ui/views/launch/splash-screen/migrate
|
||||
implementation libs.androidx.core.splashscreen
|
||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||
}
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy {
|
||||
cacheChangingModulesFor 0, "seconds"
|
||||
force "org.objenesis:objenesis:3.4"
|
||||
cacheChangingModulesFor 0, 'seconds'
|
||||
force 'org.objenesis:objenesis:3.4'
|
||||
eachDependency { details ->
|
||||
if ("org.jacoco" == details.requested.group) {
|
||||
if ('org.jacoco' == details.requested.group) {
|
||||
details.useVersion "$jacoco_version"
|
||||
}
|
||||
}
|
||||
@@ -483,7 +483,7 @@ jacoco {
|
||||
spotbugs {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = Effort.MAX
|
||||
reportLevel = Confidence.valueOf("MEDIUM")
|
||||
reportLevel = Confidence.valueOf('MEDIUM')
|
||||
}
|
||||
|
||||
tasks.withType(SpotBugsTask){task ->
|
||||
@@ -500,11 +500,11 @@ tasks.withType(SpotBugsTask){task ->
|
||||
html {
|
||||
required = true
|
||||
outputLocation = file("$project.buildDir/reports/spotbugs/spotbugs.html")
|
||||
stylesheet = "fancy.xsl"
|
||||
stylesheet = 'fancy.xsl'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksp {
|
||||
arg("room.schemaLocation", "$projectDir/schemas")
|
||||
arg('room.schemaLocation', "$projectDir/schemas")
|
||||
}
|
||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
package com.nextcloud.client.jobs
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Observer
|
||||
@@ -20,19 +19,13 @@ import androidx.work.WorkInfo
|
||||
import androidx.work.WorkManager
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.utils.extensions.toByteArray
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Suite
|
||||
import org.mockito.ArgumentMatcher
|
||||
@@ -44,8 +37,6 @@ import org.mockito.kotlin.eq
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.Date
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.CountDownLatch
|
||||
@@ -91,11 +82,9 @@ class BackgroundJobManagerTest {
|
||||
internal lateinit var workManager: WorkManager
|
||||
internal lateinit var clock: Clock
|
||||
internal lateinit var backgroundJobManager: BackgroundJobManagerImpl
|
||||
internal lateinit var context: Context
|
||||
|
||||
@Before
|
||||
fun setUpFixture() {
|
||||
context = mock()
|
||||
user = mock()
|
||||
whenever(user.accountName).thenReturn(USER_ACCOUNT_NAME)
|
||||
workManager = mock()
|
||||
@@ -313,36 +302,16 @@ class BackgroundJobManagerTest {
|
||||
private lateinit var jobInfo: LiveData<JobInfo?>
|
||||
private lateinit var request: OneTimeWorkRequest
|
||||
|
||||
@get:Rule
|
||||
var folder: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
var selectedContactsFile: File? = null
|
||||
try {
|
||||
selectedContactsFile = folder.newFile("hashset_cache.txt")
|
||||
} catch (_: IOException) {
|
||||
Log_OC.e("ImmediateContactsImport", "error creating temporary test file in ")
|
||||
fail("hashset_cache cannot be found")
|
||||
}
|
||||
|
||||
if (selectedContactsFile == null) {
|
||||
fail("hashset_cache cannot be found")
|
||||
}
|
||||
|
||||
val requestCaptor: KArgumentCaptor<OneTimeWorkRequest> = argumentCaptor()
|
||||
workInfo = MutableLiveData()
|
||||
whenever(workManager.getWorkInfoByIdLiveData(any())).thenReturn(workInfo)
|
||||
|
||||
val selectedContacts = intArrayOf(1, 2, 3)
|
||||
val contractsAsByteArray = selectedContacts.toByteArray()
|
||||
FileUtils.writeByteArrayToFile(selectedContactsFile, contractsAsByteArray)
|
||||
|
||||
jobInfo = backgroundJobManager.startImmediateContactsImport(
|
||||
contactsAccountName = "name",
|
||||
contactsAccountType = "type",
|
||||
vCardFilePath = "/path/to/vcard/file",
|
||||
selectedContactsFilePath = selectedContactsFile!!.absolutePath
|
||||
selectedContacts = intArrayOf(1, 2, 3)
|
||||
)
|
||||
verify(workManager).enqueueUniqueWork(
|
||||
any(),
|
||||
|
||||
@@ -13,26 +13,21 @@ import com.nextcloud.client.core.ClockImpl
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl
|
||||
import com.nextcloud.test.RetryTestRule
|
||||
import com.nextcloud.utils.extensions.toByteArray
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.DownloadFileOperation
|
||||
import ezvcard.Ezvcard
|
||||
import ezvcard.VCard
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
|
||||
class ContactsBackupIT : AbstractOnServerIT() {
|
||||
private val workManager = WorkManager.getInstance(targetContext)
|
||||
@@ -48,38 +43,14 @@ class ContactsBackupIT : AbstractOnServerIT() {
|
||||
@get:Rule
|
||||
val retryTestRule = RetryTestRule() // flaky test
|
||||
|
||||
@get:Rule
|
||||
var folder: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
private val vcard: String = "vcard.vcf"
|
||||
private var selectedContactsFile: File? = null
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
try {
|
||||
selectedContactsFile = folder.newFile("hashset_cache.txt")
|
||||
} catch (_: IOException) {
|
||||
Log_OC.e("ContactsBackupIT", "error creating temporary test file in ")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun importExport() {
|
||||
val intArray = intArrayOf(0)
|
||||
if (selectedContactsFile == null) {
|
||||
fail("hashset_cache cannot be found")
|
||||
}
|
||||
|
||||
val contractsAsByteArray = intArray.toByteArray()
|
||||
FileUtils.writeByteArrayToFile(selectedContactsFile, contractsAsByteArray)
|
||||
|
||||
// import file to local contacts
|
||||
backgroundJobManager.startImmediateContactsImport(
|
||||
null,
|
||||
null,
|
||||
getFile(vcard).absolutePath,
|
||||
selectedContactsFile!!.absolutePath
|
||||
)
|
||||
backgroundJobManager.startImmediateContactsImport(null, null, getFile(vcard).absolutePath, intArray)
|
||||
longSleep()
|
||||
|
||||
// export contact
|
||||
@@ -115,7 +86,7 @@ class ContactsBackupIT : AbstractOnServerIT() {
|
||||
fail("ocFile.storagePath cannot be null")
|
||||
}
|
||||
|
||||
assertTrue(DownloadFileOperation(user, ocFile, targetContext).execute(client).isSuccess)
|
||||
assertTrue(DownloadFileOperation(user, ocFile, AbstractIT.targetContext).execute(client).isSuccess)
|
||||
|
||||
val file = ocFile?.storagePath?.let { File(it) }
|
||||
if (file == null) {
|
||||
|
||||
@@ -9,7 +9,6 @@ package com.nextcloud.utils
|
||||
|
||||
import com.nextcloud.utils.autoRename.AutoRename
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.datamodel.e2e.v2.decrypted.DecryptedFile
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import org.junit.Before
|
||||
@@ -123,25 +122,25 @@ class AutoRenameTests : AbstractOnServerIT() {
|
||||
|
||||
@Test
|
||||
fun testMiddleInvalidFolderChar() {
|
||||
val folderPath = "abc/def/kg$forbiddenFilenameCharacter/lmo/pp/"
|
||||
val result = AutoRename.rename(folderPath, capability)
|
||||
val expectedFolderName = "abc/def/kg_/lmo/pp/"
|
||||
val folderPath = "abc/def/kg$forbiddenFilenameCharacter/lmo/pp"
|
||||
val result = AutoRename.rename(folderPath, capability, true)
|
||||
val expectedFolderName = "abc/def/kg_/lmo/pp"
|
||||
assert(result == expectedFolderName) { "Expected $expectedFolderName but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testEndInvalidFolderChar() {
|
||||
val folderPath = "abc/def/kg/lmo/pp$forbiddenFilenameCharacter/"
|
||||
val result = AutoRename.rename(folderPath, capability)
|
||||
val expectedFolderName = "abc/def/kg/lmo/pp_/"
|
||||
val folderPath = "abc/def/kg/lmo/pp$forbiddenFilenameCharacter"
|
||||
val result = AutoRename.rename(folderPath, capability, true)
|
||||
val expectedFolderName = "abc/def/kg/lmo/pp_"
|
||||
assert(result == expectedFolderName) { "Expected $expectedFolderName but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStartInvalidFolderChar() {
|
||||
val folderPath = "${forbiddenFilenameCharacter}abc/def/kg/lmo/pp/"
|
||||
val result = AutoRename.rename(folderPath, capability)
|
||||
val expectedFolderName = "_abc/def/kg/lmo/pp/"
|
||||
val folderPath = "${forbiddenFilenameCharacter}abc/def/kg/lmo/pp"
|
||||
val result = AutoRename.rename(folderPath, capability, true)
|
||||
val expectedFolderName = "_abc/def/kg/lmo/pp"
|
||||
assert(result == expectedFolderName) { "Expected $expectedFolderName but got $result" }
|
||||
}
|
||||
|
||||
@@ -156,16 +155,16 @@ class AutoRenameTests : AbstractOnServerIT() {
|
||||
@Test
|
||||
fun testStartsWithPathSeparator() {
|
||||
val folderPath = "/abc/def/kg/lmo/pp$forbiddenFilenameCharacter/file.txt/"
|
||||
val result = AutoRename.rename(folderPath, capability)
|
||||
val result = AutoRename.rename(folderPath, capability, true)
|
||||
val expectedFolderName = "/abc/def/kg/lmo/pp_/file.txt/"
|
||||
assert(result == expectedFolderName) { "Expected $expectedFolderName but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStartsWithPathSeparatorAndValidFilepath() {
|
||||
val folderPath = "/COm02/2569.webp/"
|
||||
val result = AutoRename.rename(folderPath, capability)
|
||||
val expectedFolderName = "/COm02/2569.webp/"
|
||||
val folderPath = "/COm02/2569.webp"
|
||||
val result = AutoRename.rename(folderPath, capability, true)
|
||||
val expectedFolderName = "/COm02/2569.webp"
|
||||
assert(result == expectedFolderName) { "Expected $expectedFolderName but got $result" }
|
||||
}
|
||||
|
||||
@@ -176,58 +175,4 @@ class AutoRenameTests : AbstractOnServerIT() {
|
||||
val expectedFilename = "_file.txt"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRenameExtensionForFolder() {
|
||||
val filename = "/Pictures/@User/SubDir/08.16.07 Ka Yel/"
|
||||
val result = AutoRename.rename(filename, capability)
|
||||
assert(result == filename) { "Expected $filename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRenameExtensionForFile() {
|
||||
val filename = "/Pictures/@User/SubDir/08.16.07 Ka Yel.TXT"
|
||||
val result = AutoRename.rename(filename, capability)
|
||||
val expectedFilename = "/Pictures/@User/SubDir/08.16.07 Ka Yel.txt"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testE2EEFile() {
|
||||
val decryptedFile = DecryptedFile(
|
||||
authenticationTag = "HQlWBdm+gYC5kZwWnqXR1Q==",
|
||||
filename = "a:a.jpg",
|
||||
nonce = "sigyys8SfPZSScDJ860vYw==",
|
||||
mimetype = "image/jpeg",
|
||||
key = "sigyys8SfPZSScDJ860vYw=="
|
||||
)
|
||||
|
||||
val result = AutoRename.rename(decryptedFile.filename, capability)
|
||||
val expectedFilename = "a_a.jpg"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRemovingLeadingWhitespace() {
|
||||
val filename = " readme.txt"
|
||||
val result = AutoRename.rename(filename, capability)
|
||||
val expectedFilename = "readme.txt"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRemovingTrailingWhitespace() {
|
||||
val filename = "readme.txt "
|
||||
val result = AutoRename.rename(filename, capability)
|
||||
val expectedFilename = "readme.txt"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRemovingTrailingAndLeadingWhitespace() {
|
||||
val filename = " readme.txt "
|
||||
val result = AutoRename.rename(filename, capability)
|
||||
val expectedFilename = "readme.txt"
|
||||
assert(result == expectedFilename) { "Expected $expectedFilename but got $result" }
|
||||
}
|
||||
}
|
||||
@@ -528,8 +528,11 @@ public abstract class AbstractIT {
|
||||
}
|
||||
|
||||
protected static User getUser(Account account) {
|
||||
Optional<User> optionalUser = UserAccountManagerImpl.fromContext(targetContext).getUser(account.name);
|
||||
return optionalUser.orElseThrow(IllegalAccessError::new);
|
||||
User optionalUser = UserAccountManagerImpl.fromContext(targetContext).getUser(account.name);
|
||||
if (optionalUser == null) {
|
||||
throw new IllegalAccessError("User not found");
|
||||
}
|
||||
return optionalUser;
|
||||
}
|
||||
|
||||
protected static Account createAccount(String name) {
|
||||
|
||||
@@ -95,8 +95,11 @@ public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
|
||||
Optional<User> optionalUser = userAccountManager.getUser(account.name);
|
||||
user = optionalUser.orElseThrow(IllegalAccessError::new);
|
||||
User optionalUser = userAccountManager.getUser(account.name);
|
||||
if (optionalUser == null) {
|
||||
throw new IllegalAccessError("User not found");
|
||||
}
|
||||
user = optionalUser;
|
||||
|
||||
client = OwnCloudClientFactory.createOwnCloudClient(account, targetContext);
|
||||
nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user, targetContext);
|
||||
|
||||
@@ -77,7 +77,11 @@ public class UploadStorageManagerTest extends AbstractIT {
|
||||
}
|
||||
|
||||
final UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
user2 = userAccountManager.getUser("[email protected]").orElseThrow(ActivityNotFoundException::new);
|
||||
User user = userAccountManager.getUser("[email protected]");
|
||||
if (user == null) {
|
||||
throw new ActivityNotFoundException("Activity not found");
|
||||
}
|
||||
user2 = user;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,7 +10,6 @@ package com.owncloud.android.ui.activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.utils.extensions.FileDataStorageManagerExtensionsKt;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -65,14 +64,13 @@ public class ConflictsResolveActivityIT extends AbstractIT {
|
||||
|
||||
ConflictsResolveActivity sut = activityRule.launchActivity(intent);
|
||||
|
||||
ConflictsResolveDialog dialog = ConflictsResolveDialog.newInstance(
|
||||
FileDataStorageManagerExtensionsKt.getDecryptedPath(storageManager, existingFile),
|
||||
targetContext,
|
||||
newFile,
|
||||
existingFile,
|
||||
UserAccountManagerImpl
|
||||
.fromContext(targetContext)
|
||||
.getUser());
|
||||
ConflictsResolveDialog dialog = ConflictsResolveDialog.newInstance(targetContext,
|
||||
newFile,
|
||||
existingFile,
|
||||
UserAccountManagerImpl
|
||||
.fromContext(targetContext)
|
||||
.getUser()
|
||||
);
|
||||
dialog.showDialog(sut);
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
|
||||
@@ -72,7 +72,11 @@ public class DrawerActivityIT extends AbstractIT {
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
|
||||
|
||||
account1 = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
user1 = userAccountManager.getUser(account1.name).orElseThrow(IllegalAccessError::new);
|
||||
User user = userAccountManager.getUser(account1.name);
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("User not found");
|
||||
}
|
||||
user1 = user;
|
||||
|
||||
loginName = "user2";
|
||||
password = "user2";
|
||||
@@ -96,7 +100,7 @@ public class DrawerActivityIT extends AbstractIT {
|
||||
|
||||
sut.setUser(user1);
|
||||
|
||||
assertEquals(account1, sut.getUser().get().toPlatformAccount());
|
||||
assertEquals(account1, sut.getUser().toPlatformAccount());
|
||||
|
||||
onView(withId(R.id.switch_account_button)).perform(click());
|
||||
|
||||
@@ -104,7 +108,7 @@ public class DrawerActivityIT extends AbstractIT {
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
assertEquals(account2, sut.getUser().get().toPlatformAccount());
|
||||
assertEquals(account2, sut.getUser().toPlatformAccount());
|
||||
|
||||
onView(withId(R.id.switch_account_button)).perform(click());
|
||||
onView(withText(account1.name)).perform(click());
|
||||
|
||||
@@ -234,7 +234,10 @@ public class DialogFragmentIT extends AbstractIT {
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_OC_BASE_URL, SERVER_URL);
|
||||
accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, "test");
|
||||
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password");
|
||||
User newUser = userAccountManager.getUser(newAccount.name).orElseThrow(RuntimeException::new);
|
||||
User newUser = userAccountManager.getUser(newAccount.name);
|
||||
if (newUser == null) {
|
||||
throw new RuntimeException("User not found");
|
||||
}
|
||||
userAccountManager.setCurrentOwnCloudAccount(newAccount.name);
|
||||
|
||||
Account newAccount2 = new Account("[email protected]", MainApp.getAccountType(targetContext));
|
||||
@@ -313,7 +316,11 @@ public class DialogFragmentIT extends AbstractIT {
|
||||
|
||||
FileDisplayActivity fda = getFileDisplayActivity();
|
||||
UserAccountManager userAccountManager = fda.getUserAccountManager();
|
||||
User newUser = userAccountManager.getUser(newAccount.name).get();
|
||||
User newUser = userAccountManager.getUser(newAccount.name);
|
||||
if (newUser == null) {
|
||||
throw new RuntimeException("User not found");
|
||||
}
|
||||
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(newUser,
|
||||
targetContext.getContentResolver());
|
||||
|
||||
|
||||
@@ -288,6 +288,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(isDisplayed()))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
@@ -415,6 +416,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(isDisplayed()))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
@@ -529,6 +531,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(not(isDisplayed())))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(not(isDisplayed())))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
@@ -654,6 +657,7 @@ class FileDetailSharingFragmentIT : AbstractIT() {
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_new_email)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_send_link)).check(matches(not(isDisplayed())))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_unshare)).check(matches(isDisplayed()))
|
||||
onView(ViewMatchers.withId(R.id.menu_share_add_another_link)).check(matches(not(isDisplayed())))
|
||||
|
||||
// click event
|
||||
onView(ViewMatchers.withId(R.id.menu_share_advanced_permissions)).perform(ViewActions.click())
|
||||
|
||||
@@ -39,15 +39,22 @@ class UriUploaderIT : AbstractIT() {
|
||||
}
|
||||
|
||||
private fun testPrivatePath(activity: TestActivity, path: String) {
|
||||
|
||||
val user = activity.user
|
||||
if (user == null) {
|
||||
throw RuntimeException("User not found")
|
||||
}
|
||||
|
||||
val sut = UriUploader(
|
||||
activity,
|
||||
listOf(Uri.parse(path)),
|
||||
"",
|
||||
activity.user.orElseThrow(::RuntimeException),
|
||||
user,
|
||||
FileUploadWorker.LOCAL_BEHAVIOUR_MOVE,
|
||||
false,
|
||||
null
|
||||
)
|
||||
|
||||
val uploadResult = sut.uploadUris()
|
||||
Assert.assertEquals(
|
||||
"Wrong result code",
|
||||
|
||||
@@ -124,7 +124,7 @@ class TestActivity :
|
||||
|
||||
override fun getStorageManager(): FileDataStorageManager {
|
||||
if (!this::storage.isInitialized) {
|
||||
storage = FileDataStorageManager(user.get(), contentResolver)
|
||||
storage = FileDataStorageManager(user, contentResolver)
|
||||
|
||||
if (!storage.capabilityExistsForAccount(account.name)) {
|
||||
val ocCapability = OCCapability()
|
||||
|
||||
@@ -67,8 +67,8 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
* @param accountName Account name of the requested user
|
||||
* @return User or empty optional if user does not exist.
|
||||
*/
|
||||
@NonNull
|
||||
Optional<User> getUser(CharSequence accountName);
|
||||
|
||||
User getUser(CharSequence accountName);
|
||||
|
||||
|
||||
User getAnonymousUser();
|
||||
|
||||
@@ -293,11 +293,13 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Optional<User> getUser(CharSequence accountName) {
|
||||
public User getUser(CharSequence accountName) {
|
||||
Account account = getAccountByName(accountName.toString());
|
||||
User user = createUserFromAccount(account);
|
||||
return Optional.ofNullable(user);
|
||||
if (user == null) {
|
||||
throw new RuntimeException("User not found");
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,16 +80,11 @@ class AssistantViewModel(
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val taskTypesResult = repository.getTaskTypes()
|
||||
|
||||
if (taskTypesResult == null) {
|
||||
if (taskTypesResult.isNullOrEmpty()) {
|
||||
updateSnackbarMessage(R.string.assistant_screen_task_types_error_state_message)
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (taskTypesResult.isEmpty()) {
|
||||
updateSnackbarMessage(R.string.assistant_screen_task_list_empty_message)
|
||||
return@launch
|
||||
}
|
||||
|
||||
_taskTypes.update {
|
||||
taskTypesResult
|
||||
}
|
||||
|
||||
@@ -262,6 +262,11 @@ private fun EmptyTaskList(
|
||||
taskTypes: List<TaskTypeData>?,
|
||||
viewModel: AssistantViewModel
|
||||
) {
|
||||
val text = stringResource(
|
||||
id = R.string.assistant_screen_no_task_available_text,
|
||||
selectedTaskType?.name ?: ""
|
||||
)
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
@@ -275,11 +280,7 @@ private fun EmptyTaskList(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
|
||||
CenterText(
|
||||
text = stringResource(
|
||||
id = R.string.assistant_screen_create_a_new_task_from_bottom_right_text
|
||||
)
|
||||
)
|
||||
CenterText(text = text)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,15 +20,14 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.nextcloud.client.assistant.extensions.getModifiedAtRepresentation
|
||||
import com.nextcloud.client.assistant.extensions.getStatusIcon
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInput
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskOutput
|
||||
@@ -36,7 +35,7 @@ import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Composable
|
||||
fun TaskStatusView(task: Task, capability: OCCapability) {
|
||||
fun TaskStatusView(task: Task, foregroundColor: Color, capability: OCCapability) {
|
||||
val context = LocalContext.current
|
||||
|
||||
Row(
|
||||
@@ -51,13 +50,13 @@ fun TaskStatusView(task: Task, capability: OCCapability) {
|
||||
Image(
|
||||
painter = painterResource(id = iconId),
|
||||
modifier = Modifier.size(16.dp),
|
||||
colorFilter = ColorFilter.tint(color = colorResource(R.color.text_color)),
|
||||
colorFilter = ColorFilter.tint(foregroundColor),
|
||||
contentDescription = "status icon"
|
||||
)
|
||||
|
||||
description?.let {
|
||||
Spacer(modifier = Modifier.width(6.dp))
|
||||
Text(text = description, color = colorResource(R.color.text_color))
|
||||
Text(text = description, color = foregroundColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,6 +141,7 @@ private fun TaskStatusViewPreview() {
|
||||
items(tasks) {
|
||||
TaskStatusView(
|
||||
it,
|
||||
foregroundColor = Color.White,
|
||||
OCCapability().apply {
|
||||
versionMayor = 30
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -39,7 +40,6 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.nextcloud.client.assistant.taskDetail.TaskDetailBottomSheet
|
||||
import com.nextcloud.utils.extensions.truncateWithEllipsis
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInput
|
||||
@@ -56,7 +56,7 @@ fun TaskView(task: Task, capability: OCCapability, showTaskActions: () -> Unit)
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(color = colorResource(R.color.task_container))
|
||||
.background(colorResource(R.color.primary))
|
||||
.clickable {
|
||||
showTaskDetailBottomSheet = true
|
||||
}
|
||||
@@ -66,11 +66,10 @@ fun TaskView(task: Task, capability: OCCapability, showTaskActions: () -> Unit)
|
||||
|
||||
task.input?.input?.let {
|
||||
Text(
|
||||
text = it.truncateWithEllipsis(30),
|
||||
color = colorResource(R.color.text_color),
|
||||
text = it,
|
||||
color = Color.White,
|
||||
fontSize = 18.sp,
|
||||
textAlign = TextAlign.Left,
|
||||
maxLines = 1,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.width(300.dp)
|
||||
)
|
||||
@@ -79,10 +78,16 @@ fun TaskView(task: Task, capability: OCCapability, showTaskActions: () -> Unit)
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
task.output?.output?.let {
|
||||
val output = if (it.length >= 100) {
|
||||
it.take(100) + "..."
|
||||
} else {
|
||||
it
|
||||
}
|
||||
|
||||
Text(
|
||||
text = it.truncateWithEllipsis(100),
|
||||
text = output,
|
||||
fontSize = 18.sp,
|
||||
color = colorResource(R.color.text_color),
|
||||
color = Color.White,
|
||||
textAlign = TextAlign.Left,
|
||||
modifier = Modifier
|
||||
.animateContentSize(
|
||||
@@ -94,10 +99,10 @@ fun TaskView(task: Task, capability: OCCapability, showTaskActions: () -> Unit)
|
||||
)
|
||||
}
|
||||
|
||||
TaskStatusView(task, capability)
|
||||
TaskStatusView(task, foregroundColor = Color.White, capability)
|
||||
|
||||
if (showTaskDetailBottomSheet) {
|
||||
TaskDetailBottomSheet(task, showTaskActions = {
|
||||
TaskDetailBottomSheet(task, capability, showTaskActions = {
|
||||
showTaskDetailBottomSheet = false
|
||||
showTaskActions()
|
||||
}) {
|
||||
@@ -113,7 +118,7 @@ fun TaskView(task: Task, capability: OCCapability, showTaskActions: () -> Unit)
|
||||
Icon(
|
||||
imageVector = Icons.Filled.MoreVert,
|
||||
contentDescription = "More button",
|
||||
tint = colorResource(R.color.text_color)
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
|
||||
package com.nextcloud.client.assistant.taskDetail
|
||||
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
@@ -17,35 +19,44 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.nextcloud.client.assistant.task.TaskStatusView
|
||||
import com.nextcloud.utils.extensions.getRandomString
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInput
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskOutput
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun TaskDetailBottomSheet(task: Task, showTaskActions: () -> Unit, dismiss: () -> Unit) {
|
||||
fun TaskDetailBottomSheet(task: Task, capability: OCCapability, showTaskActions: () -> Unit, dismiss: () -> Unit) {
|
||||
var showInput by remember { mutableStateOf(true) }
|
||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||
|
||||
ModalBottomSheet(
|
||||
@@ -73,56 +84,88 @@ fun TaskDetailBottomSheet(task: Task, showTaskActions: () -> Unit, dismiss: () -
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(
|
||||
color = colorResource(id = R.color.light_grey),
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
)
|
||||
) {
|
||||
TextInputSelectButton(
|
||||
Modifier.weight(1f),
|
||||
R.string.assistant_task_detail_screen_input_button_title,
|
||||
showInput,
|
||||
onClick = {
|
||||
showInput = true
|
||||
}
|
||||
)
|
||||
|
||||
TextInputSelectButton(
|
||||
Modifier.weight(1f),
|
||||
R.string.assistant_task_detail_screen_output_button_title,
|
||||
!showInput,
|
||||
onClick = {
|
||||
showInput = false
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
InputOutputCard(task)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(
|
||||
color = MaterialTheme.colorScheme.secondaryContainer,
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
)
|
||||
.padding(16.dp)
|
||||
) {
|
||||
Text(
|
||||
text = if (showInput) {
|
||||
task.input?.input ?: ""
|
||||
} else {
|
||||
task.output?.output ?: stringResource(R.string.assistant_screen_task_output_empty_text)
|
||||
},
|
||||
fontSize = 12.sp,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
modifier = Modifier
|
||||
.animateContentSize(
|
||||
animationSpec = spring(
|
||||
dampingRatio = Spring.DampingRatioLowBouncy,
|
||||
stiffness = Spring.StiffnessLow
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
TaskStatusView(task, foregroundColor = colorResource(R.color.text_color), capability)
|
||||
|
||||
Spacer(modifier = Modifier.height(32.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun InputOutputCard(task: Task) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(Color.Transparent, shape = RoundedCornerShape(8.dp))
|
||||
private fun TextInputSelectButton(modifier: Modifier, titleId: Int, highlightCondition: Boolean, onClick: () -> Unit) {
|
||||
Button(
|
||||
onClick = onClick,
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
colors = if (highlightCondition) {
|
||||
ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary)
|
||||
} else {
|
||||
ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.secondary)
|
||||
},
|
||||
modifier = modifier
|
||||
.widthIn(min = 0.dp, max = 200.dp)
|
||||
.padding(horizontal = 4.dp)
|
||||
) {
|
||||
TitleDescriptionBox(
|
||||
title = stringResource(R.string.assistant_task_detail_screen_input_button_title),
|
||||
description = task.input?.input ?: ""
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
TitleDescriptionBox(
|
||||
title = stringResource(R.string.assistant_task_detail_screen_output_button_title),
|
||||
description = task.output?.output ?: stringResource(R.string.assistant_screen_task_output_empty_text)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TitleDescriptionBox(title: String, description: String?) {
|
||||
Text(
|
||||
text = title,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 16.sp,
|
||||
color = colorResource(R.color.text_color)
|
||||
)
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 8.dp)
|
||||
.background(color = colorResource(R.color.task_container), RoundedCornerShape(8.dp))
|
||||
.padding(12.dp)
|
||||
) {
|
||||
Text(
|
||||
text = description ?: "",
|
||||
color = colorResource(R.color.text_color)
|
||||
)
|
||||
Text(text = stringResource(id = titleId), color = MaterialTheme.colorScheme.surface)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +188,9 @@ private fun TaskDetailScreenPreview() {
|
||||
1707692337,
|
||||
1707692337
|
||||
),
|
||||
OCCapability().apply {
|
||||
versionMayor = 30
|
||||
},
|
||||
showTaskActions = {
|
||||
}
|
||||
) {
|
||||
|
||||
@@ -69,9 +69,7 @@ import com.owncloud.android.db.ProviderMeta
|
||||
AutoMigration(from = 82, to = 83),
|
||||
AutoMigration(from = 83, to = 84),
|
||||
AutoMigration(from = 84, to = 85, spec = DatabaseMigrationUtil.DeleteColumnSpec::class),
|
||||
AutoMigration(from = 85, to = 86, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
AutoMigration(from = 86, to = 87, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class),
|
||||
AutoMigration(from = 87, to = 88, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class)
|
||||
AutoMigration(from = 85, to = 86, spec = DatabaseMigrationUtil.ResetCapabilitiesPostMigration::class)
|
||||
],
|
||||
exportSchema = true
|
||||
)
|
||||
|
||||
@@ -136,9 +136,5 @@ data class CapabilityEntity(
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT_DEFAULT)
|
||||
val filesDownloadLimitDefault: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_RECOMMENDATION)
|
||||
val recommendation: Int?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_NOTES_FOLDER_PATH)
|
||||
val notesFolderPath: String?,
|
||||
@ColumnInfo(name = ProviderTableMeta.CAPABILITIES_DEFAULT_PERMISSIONS)
|
||||
val defaultPermissions: Int?
|
||||
val recommendation: Int?
|
||||
)
|
||||
@@ -54,7 +54,7 @@ class GeneratePdfFromImagesWork(
|
||||
}
|
||||
|
||||
val user = userAccountManager.getUser(accountName)
|
||||
require(user.isPresent && user.get() !is AnonymousUser) { "Invalid or not found user" }
|
||||
require(user!= null && user !is AnonymousUser) { "Invalid or not found user" }
|
||||
|
||||
logger.d(
|
||||
TAG,
|
||||
@@ -66,7 +66,7 @@ class GeneratePdfFromImagesWork(
|
||||
val result = generatePdfUseCase.execute(inputPaths, outputFilePath)
|
||||
notificationManager.cancel(notificationId)
|
||||
if (result) {
|
||||
uploadFile(user.get(), uploadFolder, outputFilePath)
|
||||
uploadFile(user, uploadFolder, outputFilePath)
|
||||
cleanupImages(inputPaths)
|
||||
} else {
|
||||
logger.w(TAG, "PDF generation failed")
|
||||
|
||||
@@ -16,7 +16,6 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -52,9 +51,9 @@ class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
||||
private val executionLogRow = view.findViewById<View>(R.id.etm_background_execution_logs_row)
|
||||
val executionTimesRow = view.findViewById<View>(R.id.etm_background_execution_times_row)
|
||||
|
||||
var progressEnabled: Boolean = progressRow.isVisible
|
||||
var progressEnabled: Boolean = progressRow.visibility == View.VISIBLE
|
||||
get() {
|
||||
return progressRow.isVisible
|
||||
return progressRow.visibility == View.VISIBLE
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -65,9 +64,9 @@ class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
||||
}
|
||||
}
|
||||
|
||||
var logsEnabled: Boolean = executionLogRow.isVisible
|
||||
var logsEnabled: Boolean = executionLogRow.visibility == View.VISIBLE
|
||||
get() {
|
||||
return executionLogRow.isVisible
|
||||
return executionLogRow.visibility == View.VISIBLE
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
@@ -166,13 +165,11 @@ class EtmBackgroundJobsFragment : EtmBaseFragment(), Injectable {
|
||||
return view
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
inflater.inflate(R.menu.fragment_etm_background_jobs, menu)
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.etm_background_jobs_cancel -> {
|
||||
|
||||
@@ -15,7 +15,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@@ -47,9 +46,9 @@ class EtmFileTransferFragment : EtmBaseFragment() {
|
||||
val progress = view.findViewById<TextView>(R.id.etm_transfer_progress)
|
||||
private val progressRow = view.findViewById<View>(R.id.etm_transfer_progress_row)
|
||||
|
||||
var progressEnabled: Boolean = progressRow.isVisible
|
||||
var progressEnabled: Boolean = progressRow.visibility == View.VISIBLE
|
||||
get() {
|
||||
return progressRow.isVisible
|
||||
return progressRow.visibility == View.VISIBLE
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
@@ -75,13 +75,13 @@ class AccountRemovalWork(
|
||||
return Result.failure()
|
||||
}
|
||||
val optionalUser = userAccountManager.getUser(accountName)
|
||||
if (!optionalUser.isPresent) {
|
||||
if (optionalUser == null) {
|
||||
// trying to delete non-existing user
|
||||
return Result.failure()
|
||||
}
|
||||
val remoteWipe = inputData.getBoolean(REMOTE_WIPE, false)
|
||||
val arbitraryDataProvider: ArbitraryDataProvider = ArbitraryDataProviderImpl(context)
|
||||
val user = optionalUser.get()
|
||||
val user = optionalUser
|
||||
backgroundJobManager.cancelPeriodicContactsBackup(user)
|
||||
val userRemoved = userAccountManager.removeUser(user)
|
||||
val storageManager = FileDataStorageManager(user, context.contentResolver)
|
||||
|
||||
@@ -95,7 +95,7 @@ interface BackgroundJobManager {
|
||||
* @param contactsAccountName Target contacts account name; null for local contacts
|
||||
* @param contactsAccountType Target contacts account type; null for local contacts
|
||||
* @param vCardFilePath Path to file containing all contact entries
|
||||
* @param selectedContactsFilePath File path of list of contact indices to import from [vCardFilePath] file
|
||||
* @param selectedContacts List of contact indices to import from [vCardFilePath] file
|
||||
*
|
||||
* @return Job info with current status; status is null if job does not exist
|
||||
*/
|
||||
@@ -103,7 +103,7 @@ interface BackgroundJobManager {
|
||||
contactsAccountName: String?,
|
||||
contactsAccountType: String?,
|
||||
vCardFilePath: String,
|
||||
selectedContactsFilePath: String
|
||||
selectedContacts: IntArray
|
||||
): LiveData<JobInfo?>
|
||||
|
||||
/**
|
||||
|
||||
@@ -308,13 +308,13 @@ internal class BackgroundJobManagerImpl(
|
||||
contactsAccountName: String?,
|
||||
contactsAccountType: String?,
|
||||
vCardFilePath: String,
|
||||
selectedContactsFilePath: String
|
||||
selectedContacts: IntArray
|
||||
): LiveData<JobInfo?> {
|
||||
val data = Data.Builder()
|
||||
.putString(ContactsImportWork.ACCOUNT_NAME, contactsAccountName)
|
||||
.putString(ContactsImportWork.ACCOUNT_TYPE, contactsAccountType)
|
||||
.putString(ContactsImportWork.VCARD_FILE_PATH, vCardFilePath)
|
||||
.putString(ContactsImportWork.SELECTED_CONTACTS_FILE_PATH, selectedContactsFilePath)
|
||||
.putIntArray(ContactsImportWork.SELECTED_CONTACTS_INDICES, selectedContacts)
|
||||
.build()
|
||||
|
||||
val constraints = Constraints.Builder()
|
||||
@@ -631,9 +631,7 @@ internal class BackgroundJobManagerImpl(
|
||||
.setInputData(data)
|
||||
.build()
|
||||
|
||||
// Since for each file new FileDownloadWorker going to be scheduled,
|
||||
// better to use ExistingWorkPolicy.KEEP policy.
|
||||
workManager.enqueueUniqueWork(tag, ExistingWorkPolicy.KEEP, request)
|
||||
workManager.enqueueUniqueWork(tag, ExistingWorkPolicy.REPLACE, request)
|
||||
}
|
||||
|
||||
override fun getFileUploads(user: User): LiveData<List<JobInfo>> {
|
||||
|
||||
@@ -37,7 +37,7 @@ class CalendarBackupWork(
|
||||
override fun doWork(): Result {
|
||||
val accountName = inputData.getString(ACCOUNT) ?: ""
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (!optionalUser.isPresent || TextUtils.isEmpty(accountName)) {
|
||||
if (optionalUser == null || TextUtils.isEmpty(accountName)) {
|
||||
// no account provided
|
||||
Log_OC.d(TAG, "User not present")
|
||||
return Result.failure()
|
||||
@@ -53,7 +53,7 @@ class CalendarBackupWork(
|
||||
applicationContext,
|
||||
calendar,
|
||||
preferences,
|
||||
optionalUser.get()
|
||||
optionalUser
|
||||
).start()
|
||||
}
|
||||
|
||||
|
||||
@@ -73,10 +73,10 @@ class ContactsBackupWork(
|
||||
return Result.failure()
|
||||
}
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (!optionalUser.isPresent) {
|
||||
if (optionalUser == null) {
|
||||
return Result.failure()
|
||||
}
|
||||
val user = optionalUser.get()
|
||||
val user = optionalUser
|
||||
val lastExecution = arbitraryDataProvider.getLongValue(
|
||||
user,
|
||||
ContactsPreferenceActivity.PREFERENCE_CONTACTS_LAST_BACKUP
|
||||
|
||||
@@ -16,16 +16,12 @@ import android.provider.ContactsContract
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.logger.Logger
|
||||
import com.nextcloud.utils.extensions.toIntArray
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.VCardComparator
|
||||
import ezvcard.Ezvcard
|
||||
import ezvcard.VCard
|
||||
import org.apache.commons.io.FileUtils
|
||||
import third_parties.ezvcard_android.ContactOperations
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.util.Collections
|
||||
@@ -43,27 +39,15 @@ class ContactsImportWork(
|
||||
const val ACCOUNT_TYPE = "account_type"
|
||||
const val ACCOUNT_NAME = "account_name"
|
||||
const val VCARD_FILE_PATH = "vcard_file_path"
|
||||
const val SELECTED_CONTACTS_FILE_PATH = "selected_contacts_file_path"
|
||||
const val SELECTED_CONTACTS_INDICES = "selected_contacts_indices"
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod", "NestedBlockDepth", "LongMethod", "ReturnCount") // legacy code
|
||||
@Suppress("ComplexMethod", "NestedBlockDepth") // legacy code
|
||||
override fun doWork(): Result {
|
||||
val vCardFilePath = inputData.getString(VCARD_FILE_PATH) ?: ""
|
||||
val contactsAccountName = inputData.getString(ACCOUNT_NAME)
|
||||
val contactsAccountType = inputData.getString(ACCOUNT_TYPE)
|
||||
val selectedContactsFilePath = inputData.getString(SELECTED_CONTACTS_FILE_PATH)
|
||||
if (selectedContactsFilePath == null) {
|
||||
Log_OC.d(TAG, "selectedContactsFilePath is null")
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
val selectedContactsFile = File(selectedContactsFilePath)
|
||||
if (!selectedContactsFile.exists()) {
|
||||
Log_OC.d(TAG, "selectedContactsFile not exists")
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
val selectedContactsIndices = readCheckedContractsFromFile(selectedContactsFile)
|
||||
val selectedContactsIndices = inputData.getIntArray(SELECTED_CONTACTS_INDICES) ?: IntArray(0)
|
||||
|
||||
val inputStream = BufferedInputStream(FileInputStream(vCardFilePath))
|
||||
val vCards = ArrayList<VCard>()
|
||||
@@ -95,21 +79,16 @@ class ContactsImportWork(
|
||||
cursor.moveToNext()
|
||||
}
|
||||
}
|
||||
|
||||
for (contactIndex in selectedContactsIndices) {
|
||||
try {
|
||||
val vCard = vCards[contactIndex]
|
||||
if (BackupListFragment.getDisplayName(vCard).isEmpty()) {
|
||||
if (!ownContactMap.containsKey(vCard)) {
|
||||
operations.insertContact(vCard)
|
||||
} else {
|
||||
operations.updateContact(vCard, ownContactMap[vCard])
|
||||
}
|
||||
val vCard = vCards[contactIndex]
|
||||
if (BackupListFragment.getDisplayName(vCard).isEmpty()) {
|
||||
if (!ownContactMap.containsKey(vCard)) {
|
||||
operations.insertContact(vCard)
|
||||
} else {
|
||||
operations.insertContact(vCard) // Insert All the contacts without name
|
||||
operations.updateContact(vCard, ownContactMap[vCard])
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
Log_OC.e(TAG, "skipping contactIndex: $contactIndex due to: $t")
|
||||
} else {
|
||||
operations.insertContact(vCard) // Insert All the contacts without name
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -124,22 +103,9 @@ class ContactsImportWork(
|
||||
logger.e(TAG, "Error closing vCard stream", e)
|
||||
}
|
||||
|
||||
Log_OC.d(TAG, "ContractsImportWork successfully completed")
|
||||
selectedContactsFile.delete()
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
fun readCheckedContractsFromFile(file: File): IntArray {
|
||||
return try {
|
||||
val fileData = FileUtils.readFileToByteArray(file)
|
||||
fileData.toIntArray()
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(TAG, "Exception readCheckedContractsFromFile: $e")
|
||||
intArrayOf()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getContactFromCursor(cursor: Cursor): VCard? {
|
||||
val lookupKey = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.LOOKUP_KEY))
|
||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey)
|
||||
|
||||
@@ -101,8 +101,8 @@ class FilesSyncWork(
|
||||
}
|
||||
|
||||
val user = userAccountManager.getUser(syncedFolder.account)
|
||||
if (user.isPresent) {
|
||||
backgroundJobManager.startFilesUploadJob(user.get())
|
||||
if (user != null) {
|
||||
backgroundJobManager.startFilesUploadJob(user)
|
||||
}
|
||||
|
||||
// Get changed files from ContentObserverWork (only images and videos) or by scanning filesystem
|
||||
@@ -232,11 +232,11 @@ class FilesSyncWork(
|
||||
val accountName = syncedFolder.account
|
||||
|
||||
val optionalUser = userAccountManager.getUser(accountName)
|
||||
if (!optionalUser.isPresent) {
|
||||
if (optionalUser == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val user = optionalUser.get()
|
||||
val user = optionalUser
|
||||
val arbitraryDataProvider = if (lightVersion) {
|
||||
ArbitraryDataProviderImpl(context)
|
||||
} else {
|
||||
|
||||
@@ -107,7 +107,7 @@ class NotificationWork constructor(
|
||||
notificationManager.cancelAll()
|
||||
} else {
|
||||
val user = accountManager.getUser(signatureVerification.account?.name)
|
||||
.orElseThrow { RuntimeException() }
|
||||
?: throw RuntimeException("User not found or invalid")
|
||||
fetchCompleteNotification(user, decryptedPushMessage)
|
||||
}
|
||||
}
|
||||
@@ -231,11 +231,11 @@ class NotificationWork constructor(
|
||||
@Suppress("TooGenericExceptionCaught") // legacy code
|
||||
private fun fetchCompleteNotification(account: User, decryptedPushMessage: DecryptedPushMessage) {
|
||||
val optionalUser = accountManager.getUser(account.accountName)
|
||||
if (!optionalUser.isPresent) {
|
||||
if (optionalUser == null) {
|
||||
Log_OC.e(this, "Account may not be null")
|
||||
return
|
||||
}
|
||||
val user = optionalUser.get()
|
||||
val user = optionalUser
|
||||
try {
|
||||
val client = OwnCloudClientFactory.createNextcloudClient(user, context)
|
||||
val result = GetNotificationRemoteOperation(decryptedPushMessage.nid)
|
||||
@@ -283,8 +283,8 @@ class NotificationWork constructor(
|
||||
cancel(context, numericNotificationId)
|
||||
try {
|
||||
val optionalUser = accountManager.getUser(accountName)
|
||||
if (optionalUser.isPresent) {
|
||||
val user = optionalUser.get()
|
||||
if (optionalUser != null) {
|
||||
val user = optionalUser
|
||||
val client = OwnCloudClientManagerFactory.getDefaultSingleton()
|
||||
.getClientFor(user.toOwnCloudAccount(), context)
|
||||
val nextcloudClient = OwnCloudClientFactory.createNextcloudClient(user, context)
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.jobs.clipboard
|
||||
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
|
||||
class ClipboardClearWorker(
|
||||
private val context: Context,
|
||||
params: WorkerParameters
|
||||
) : Worker(context, params) {
|
||||
private val tag = ClipboardClearWorker::class.java.name
|
||||
|
||||
companion object {
|
||||
const val CLIPBOARD_TEXT = "clipboard_text"
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught", "ReturnCount")
|
||||
override fun doWork(): Result {
|
||||
try {
|
||||
val clipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val currentClip = clipboardManager.primaryClip ?: return Result.success()
|
||||
val clipboardText = currentClip.getItemAt(0).text?.toString() ?: return Result.success()
|
||||
val copiedText = inputData.getString(CLIPBOARD_TEXT)
|
||||
if (copiedText != clipboardText) {
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
clipboardManager.clearPrimaryClip()
|
||||
} else {
|
||||
val newEmptyClip = ClipData.newPlainText("EmptyClipContent", "")
|
||||
clipboardManager.setPrimaryClip(newEmptyClip)
|
||||
}
|
||||
|
||||
return Result.success()
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(tag, "Error in clipboard clear worker", e)
|
||||
return Result.retry()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.nextcloud.client.jobs.notification.WorkerNotificationManager
|
||||
import com.nextcloud.utils.numberFormatter.NumberFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.operations.DownloadFileOperation
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
@@ -26,8 +25,17 @@ class DownloadNotificationManager(
|
||||
) : WorkerNotificationManager(id, context, viewThemeUtils, R.string.downloader_download_in_progress_ticker) {
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun prepareForStart(operation: DownloadFileOperation) {
|
||||
currentOperationTitle = File(operation.savePath).name
|
||||
fun prepareForStart(operation: DownloadFileOperation, currentDownloadIndex: Int, totalDownloadSize: Int) {
|
||||
currentOperationTitle = if (totalDownloadSize > 1) {
|
||||
String.format(
|
||||
context.getString(R.string.downloader_notification_manager_download_text),
|
||||
currentDownloadIndex,
|
||||
totalDownloadSize,
|
||||
File(operation.savePath).name
|
||||
)
|
||||
} else {
|
||||
File(operation.savePath).name
|
||||
}
|
||||
|
||||
notificationBuilder.run {
|
||||
setContentTitle(currentOperationTitle)
|
||||
@@ -47,8 +55,7 @@ class DownloadNotificationManager(
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun updateDownloadProgress(percent: Int, totalToTransfer: Long) {
|
||||
val progressText = NumberFormatter.getPercentageText(percent)
|
||||
setProgress(percent, progressText, totalToTransfer < 0)
|
||||
setProgress(percent, R.string.downloader_notification_manager_in_progress_text, totalToTransfer < 0)
|
||||
showNotification()
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ import android.util.Pair
|
||||
import androidx.core.util.component1
|
||||
import androidx.core.util.component2
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.ForegroundInfo
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
@@ -39,10 +38,10 @@ import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.operations.DownloadFileOperation
|
||||
import com.owncloud.android.operations.DownloadType
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import java.security.SecureRandom
|
||||
import java.util.AbstractList
|
||||
import java.util.Optional
|
||||
import java.util.Vector
|
||||
import kotlin.random.Random
|
||||
|
||||
@Suppress("LongParameterList", "TooManyFunctions")
|
||||
class FileDownloadWorker(
|
||||
@@ -51,7 +50,7 @@ class FileDownloadWorker(
|
||||
private var localBroadcastManager: LocalBroadcastManager,
|
||||
private val context: Context,
|
||||
params: WorkerParameters
|
||||
) : CoroutineWorker(context, params), OnAccountsUpdateListener, OnDatatransferProgressListener {
|
||||
) : Worker(context, params), OnAccountsUpdateListener, OnDatatransferProgressListener {
|
||||
|
||||
companion object {
|
||||
private val TAG = FileDownloadWorker::class.java.simpleName
|
||||
@@ -75,6 +74,7 @@ class FileDownloadWorker(
|
||||
const val ACTIVITY_NAME = "ACTIVITY_NAME"
|
||||
const val PACKAGE_NAME = "PACKAGE_NAME"
|
||||
const val CONFLICT_UPLOAD_ID = "CONFLICT_UPLOAD_ID"
|
||||
|
||||
const val EXTRA_DOWNLOAD_RESULT = "EXTRA_DOWNLOAD_RESULT"
|
||||
const val EXTRA_REMOTE_PATH = "EXTRA_REMOTE_PATH"
|
||||
const val EXTRA_LINKED_TO_PATH = "EXTRA_LINKED_TO_PATH"
|
||||
@@ -96,7 +96,7 @@ class FileDownloadWorker(
|
||||
|
||||
private val intents = FileDownloadIntents(context)
|
||||
private var notificationManager = DownloadNotificationManager(
|
||||
Random.nextInt(),
|
||||
SecureRandom().nextInt(),
|
||||
context,
|
||||
viewThemeUtils
|
||||
)
|
||||
@@ -104,27 +104,28 @@ class FileDownloadWorker(
|
||||
private var downloadProgressListener = FileDownloadProgressListener()
|
||||
|
||||
private var user: User? = null
|
||||
private var currentUser = Optional.empty<User>()
|
||||
private var currentUser: User? = null
|
||||
|
||||
private var currentUserFileStorageManager: FileDataStorageManager? = null
|
||||
private var fileDataStorageManager: FileDataStorageManager? = null
|
||||
|
||||
private var downloadError: FileDownloadError? = null
|
||||
|
||||
@Suppress("TooGenericExceptionCaught", "ReturnCount")
|
||||
override suspend fun doWork(): Result {
|
||||
val foregroundInfo = createWorkerForegroundInfo()
|
||||
setForeground(foregroundInfo)
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
override fun doWork(): Result {
|
||||
return try {
|
||||
setUser()
|
||||
val remotePath = inputData.keyValueMap[FILE_REMOTE_PATH] as String? ?: return Result.failure()
|
||||
val ocFile = fileDataStorageManager?.getFileByEncryptedRemotePath(remotePath) ?: return Result.failure()
|
||||
val requestDownloads = getRequestDownloads(ocFile)
|
||||
val requestDownloads = getRequestDownloads()
|
||||
addAccountUpdateListener()
|
||||
|
||||
requestDownloads.forEach {
|
||||
downloadFile(it)
|
||||
val foregroundInfo = ForegroundServiceHelper.createWorkerForegroundInfo(
|
||||
notificationManager.getId(),
|
||||
notificationManager.getNotification(),
|
||||
ForegroundServiceType.DataSync
|
||||
)
|
||||
setForegroundAsync(foregroundInfo)
|
||||
|
||||
requestDownloads.forEachIndexed { currentDownloadIndex, requestedDownload ->
|
||||
downloadFile(requestedDownload, currentDownloadIndex, requestDownloads.size)
|
||||
}
|
||||
|
||||
downloadError?.let {
|
||||
@@ -132,25 +133,26 @@ class FileDownloadWorker(
|
||||
notificationManager.dismissNotification()
|
||||
}
|
||||
|
||||
setIdleWorkerState()
|
||||
|
||||
Log_OC.e(TAG, "FilesDownloadWorker successfully completed")
|
||||
Result.success()
|
||||
} catch (t: Throwable) {
|
||||
notificationManager.dismissNotification()
|
||||
notificationManager.showNewNotification(context.getString(R.string.downloader_unexpected_error))
|
||||
Log_OC.e(TAG, "Error caught at FilesDownloadWorker(): " + t.localizedMessage)
|
||||
Result.failure()
|
||||
} finally {
|
||||
Log_OC.e(TAG, "FilesDownloadWorker cleanup")
|
||||
notificationManager.dismissNotification()
|
||||
setIdleWorkerState()
|
||||
Result.failure()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createWorkerForegroundInfo(): ForegroundInfo {
|
||||
return ForegroundServiceHelper.createWorkerForegroundInfo(
|
||||
notificationManager.getId(),
|
||||
notificationManager.getNotification(),
|
||||
ForegroundServiceType.DataSync
|
||||
)
|
||||
override fun onStopped() {
|
||||
Log_OC.e(TAG, "FilesDownloadWorker stopped")
|
||||
|
||||
notificationManager.dismissNotification()
|
||||
setIdleWorkerState()
|
||||
|
||||
super.onStopped()
|
||||
}
|
||||
|
||||
private fun setWorkerState(user: User?) {
|
||||
@@ -165,8 +167,9 @@ class FileDownloadWorker(
|
||||
pendingDownloads.remove(accountName)
|
||||
}
|
||||
|
||||
private fun getRequestDownloads(ocFile: OCFile): AbstractList<String> {
|
||||
val files = getFiles(ocFile)
|
||||
private fun getRequestDownloads(): AbstractList<String> {
|
||||
setUser()
|
||||
val files = getFiles()
|
||||
val downloadType = getDownloadType()
|
||||
|
||||
conflictUploadId = inputData.keyValueMap[CONFLICT_UPLOAD_ID] as Long?
|
||||
@@ -215,11 +218,14 @@ class FileDownloadWorker(
|
||||
|
||||
private fun setUser() {
|
||||
val accountName = inputData.keyValueMap[ACCOUNT_NAME] as String
|
||||
user = accountManager.getUser(accountName).get()
|
||||
user = accountManager.getUser(accountName)
|
||||
fileDataStorageManager = FileDataStorageManager(user, context.contentResolver)
|
||||
}
|
||||
|
||||
private fun getFiles(file: OCFile): List<OCFile> {
|
||||
private fun getFiles(): List<OCFile> {
|
||||
val remotePath = inputData.keyValueMap[FILE_REMOTE_PATH] as String?
|
||||
val file = fileDataStorageManager?.getFileByEncryptedRemotePath(remotePath) ?: return listOf()
|
||||
|
||||
return if (file.isFolder) {
|
||||
fileDataStorageManager?.getAllFilesRecursivelyInsideFolder(file) ?: listOf()
|
||||
} else {
|
||||
@@ -246,7 +252,7 @@ class FileDownloadWorker(
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught", "DEPRECATION")
|
||||
private fun downloadFile(downloadKey: String) {
|
||||
private fun downloadFile(downloadKey: String, currentDownloadIndex: Int, totalDownloadSize: Int) {
|
||||
currentDownload = pendingDownloads.get(downloadKey)
|
||||
|
||||
if (currentDownload == null) {
|
||||
@@ -263,8 +269,9 @@ class FileDownloadWorker(
|
||||
}
|
||||
|
||||
lastPercent = 0
|
||||
|
||||
notificationManager.run {
|
||||
prepareForStart(currentDownload!!)
|
||||
prepareForStart(currentDownload!!, currentDownloadIndex + 1, totalDownloadSize)
|
||||
setContentIntent(intents.detailsIntent(currentDownload!!), PendingIntent.FLAG_IMMUTABLE)
|
||||
}
|
||||
|
||||
@@ -294,9 +301,9 @@ class FileDownloadWorker(
|
||||
val currentDownloadUser = accountManager.getUser(currentDownloadAccount?.name)
|
||||
if (currentUser != currentDownloadUser) {
|
||||
currentUser = currentDownloadUser
|
||||
currentUserFileStorageManager = FileDataStorageManager(currentUser.get(), context.contentResolver)
|
||||
currentUserFileStorageManager = FileDataStorageManager(currentUser, context.contentResolver)
|
||||
}
|
||||
return currentDownloadUser.get().toOwnCloudAccount()
|
||||
return currentDownloadUser.toOwnCloudAccount()
|
||||
}
|
||||
|
||||
private fun getCurrentFile(): OCFile? {
|
||||
|
||||
@@ -51,14 +51,16 @@ open class WorkerNotificationManager(
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun setProgress(percent: Int, progressText: String?, indeterminate: Boolean) {
|
||||
fun setProgress(percent: Int, progressTextId: Int, indeterminate: Boolean) {
|
||||
val progressText = String.format(
|
||||
context.getString(progressTextId),
|
||||
percent
|
||||
)
|
||||
|
||||
notificationBuilder.run {
|
||||
setProgress(100, percent, indeterminate)
|
||||
setContentTitle(currentOperationTitle)
|
||||
|
||||
progressText?.let {
|
||||
setContentText(progressText)
|
||||
}
|
||||
setContentText(progressText)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class FileUploadHelper {
|
||||
val connectivity = connectivityService.connectivity
|
||||
val batteryStatus = powerManagementService.battery
|
||||
val accountNames = accountManager.accounts.filter { account ->
|
||||
accountManager.getUser(account.name).isPresent
|
||||
accountManager.getUser(account.name) != null
|
||||
}.map { account ->
|
||||
account.name
|
||||
}.toHashSet()
|
||||
@@ -185,8 +185,8 @@ class FileUploadHelper {
|
||||
|
||||
accountNames.forEach { accountName ->
|
||||
val user = accountManager.getUser(accountName)
|
||||
if (user.isPresent) {
|
||||
backgroundJobManager.startFilesUploadJob(user.get())
|
||||
if (user != null) {
|
||||
backgroundJobManager.startFilesUploadJob(user)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ class FileUploadHelper {
|
||||
|
||||
fun removeFileUpload(remotePath: String, accountName: String) {
|
||||
try {
|
||||
val user = accountManager.getUser(accountName).get()
|
||||
val user = accountManager.getUser(accountName)
|
||||
|
||||
// need to update now table in mUploadsStorageManager,
|
||||
// since the operation will not get to be run by FileUploader#uploadFile
|
||||
@@ -252,7 +252,7 @@ class FileUploadHelper {
|
||||
}
|
||||
|
||||
try {
|
||||
val user = accountManager.getUser(accountName).get()
|
||||
val user = accountManager.getUser(accountName)
|
||||
cancelAndRestartUploadJob(user)
|
||||
} catch (e: NoSuchElementException) {
|
||||
Log_OC.e(TAG, "Error restarting upload job because user does not exist!")
|
||||
@@ -426,7 +426,7 @@ class FileUploadHelper {
|
||||
|
||||
fun cancel(accountName: String) {
|
||||
uploadsStorageManager.removeUploads(accountName)
|
||||
cancelAndRestartUploadJob(accountManager.getUser(accountName).get())
|
||||
cancelAndRestartUploadJob(accountManager.getUser(accountName))
|
||||
}
|
||||
|
||||
fun addUploadTransferProgressListener(listener: OnDatatransferProgressListener, targetKey: String) {
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.nextcloud.client.jobs.upload
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.provider.Settings
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.work.Worker
|
||||
import androidx.work.WorkerParameters
|
||||
@@ -147,6 +148,7 @@ class FileUploadWorker(
|
||||
}
|
||||
|
||||
if (canExitEarly()) {
|
||||
Log_OC.d(TAG, "Airplane mode is enabled or no internet connection, stopping worker.")
|
||||
notificationManager.showConnectionErrorNotification()
|
||||
return Result.failure()
|
||||
}
|
||||
@@ -169,23 +171,27 @@ class FileUploadWorker(
|
||||
private fun canExitEarly(): Boolean {
|
||||
val result = !connectivityService.isConnected ||
|
||||
connectivityService.isInternetWalled ||
|
||||
isStopped
|
||||
isStopped ||
|
||||
isAirplaneModeEnabled()
|
||||
|
||||
if (result) {
|
||||
Log_OC.d(TAG, "No internet connection, stopping worker.")
|
||||
} else {
|
||||
if (!result) {
|
||||
notificationManager.dismissErrorNotification()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun isAirplaneModeEnabled(): Boolean {
|
||||
return Settings.Global.getInt(context.contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0
|
||||
}
|
||||
|
||||
@Suppress("NestedBlockDepth")
|
||||
private fun uploadFiles(totalUploadSize: Int, uploadsPerPage: List<OCUpload>, accountName: String) {
|
||||
val user = userAccountManager.getUser(accountName)
|
||||
setWorkerState(user.get(), uploadsPerPage)
|
||||
setWorkerState(user, uploadsPerPage)
|
||||
|
||||
if (canExitEarly()) {
|
||||
Log_OC.d(TAG, "Airplane mode is enabled or no internet connection, stopping worker.")
|
||||
notificationManager.showConnectionErrorNotification()
|
||||
return
|
||||
}
|
||||
@@ -197,8 +203,8 @@ class FileUploadWorker(
|
||||
return@uploads
|
||||
}
|
||||
|
||||
if (user.isPresent) {
|
||||
val uploadFileOperation = createUploadFileOperation(upload, user.get())
|
||||
if (user != null) {
|
||||
val uploadFileOperation = createUploadFileOperation(upload, user)
|
||||
|
||||
currentUploadFileOperation = uploadFileOperation
|
||||
|
||||
@@ -210,7 +216,7 @@ class FileUploadWorker(
|
||||
totalUploadSize = totalUploadSize
|
||||
)
|
||||
|
||||
val result = upload(uploadFileOperation, user.get())
|
||||
val result = upload(uploadFileOperation, user)
|
||||
|
||||
if (result.isSuccess) {
|
||||
currentUploadIndex += 1
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import com.nextcloud.client.jobs.notification.WorkerNotificationManager
|
||||
import com.nextcloud.utils.extensions.isFileSpecificError
|
||||
import com.nextcloud.utils.numberFormatter.NumberFormatter
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.operations.UploadFileOperation
|
||||
@@ -44,7 +43,10 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
|
||||
uploadFileOperation.fileName
|
||||
}
|
||||
|
||||
val progressText = NumberFormatter.getPercentageText(0)
|
||||
val progressText = String.format(
|
||||
context.getString(R.string.upload_notification_manager_upload_in_progress_text),
|
||||
0
|
||||
)
|
||||
|
||||
notificationBuilder.run {
|
||||
setProgress(100, 0, false)
|
||||
@@ -69,8 +71,7 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun updateUploadProgress(percent: Int, currentOperation: UploadFileOperation?) {
|
||||
val progressText = NumberFormatter.getPercentageText(percent)
|
||||
setProgress(percent, progressText, false)
|
||||
setProgress(percent, R.string.upload_notification_manager_upload_in_progress_text, false)
|
||||
showNotification()
|
||||
dismissOldErrorNotification(currentOperation)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package com.nextcloud.client.migrations
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import java.util.TreeSet
|
||||
|
||||
class MigrationsDb(private val migrationsDb: SharedPreferences) {
|
||||
@@ -40,12 +39,12 @@ class MigrationsDb(private val migrationsDb: SharedPreferences) {
|
||||
addAll(oldApplied)
|
||||
addAll(migrations.map { it.toString() })
|
||||
}
|
||||
migrationsDb.edit { putStringSet(DB_KEY_APPLIED_MIGRATIONS, newApplied) }
|
||||
migrationsDb.edit().putStringSet(DB_KEY_APPLIED_MIGRATIONS, newApplied).apply()
|
||||
}
|
||||
|
||||
var lastMigratedVersion: Int
|
||||
set(value) {
|
||||
migrationsDb.edit { putInt(DB_KEY_LAST_MIGRATED_VERSION, value) }
|
||||
migrationsDb.edit().putInt(DB_KEY_LAST_MIGRATED_VERSION, value).apply()
|
||||
}
|
||||
get() {
|
||||
return migrationsDb.getInt(DB_KEY_LAST_MIGRATED_VERSION, NO_LAST_MIGRATED_VERSION)
|
||||
@@ -57,17 +56,17 @@ class MigrationsDb(private val migrationsDb: SharedPreferences) {
|
||||
|
||||
fun setFailed(id: Int, error: String) {
|
||||
migrationsDb
|
||||
.edit {
|
||||
putBoolean(DB_KEY_FAILED, true)
|
||||
.putString(DB_KEY_FAILED_MIGRATION_ERROR_MESSAGE, error)
|
||||
.putInt(DB_KEY_FAILED_MIGRATION_ID, id)
|
||||
}
|
||||
.edit()
|
||||
.putBoolean(DB_KEY_FAILED, true)
|
||||
.putString(DB_KEY_FAILED_MIGRATION_ERROR_MESSAGE, error)
|
||||
.putInt(DB_KEY_FAILED_MIGRATION_ID, id)
|
||||
.apply()
|
||||
}
|
||||
|
||||
fun clearMigrations() {
|
||||
migrationsDb.edit {
|
||||
putStringSet(DB_KEY_APPLIED_MIGRATIONS, emptySet())
|
||||
.putInt(DB_KEY_LAST_MIGRATED_VERSION, 0)
|
||||
}
|
||||
migrationsDb.edit()
|
||||
.putStringSet(DB_KEY_APPLIED_MIGRATIONS, emptySet())
|
||||
.putInt(DB_KEY_LAST_MIGRATED_VERSION, 0)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,8 @@ class SessionMixin(
|
||||
private set
|
||||
|
||||
val capabilities: OCCapability?
|
||||
get() = getUser()
|
||||
.map { CapabilityUtils.getCapability(it, activity) }
|
||||
.orElse(null)
|
||||
get() = getUser()?.let { CapabilityUtils.getCapability(it, activity) }
|
||||
|
||||
|
||||
fun setAccount(account: Account) {
|
||||
val validAccount = (accountManager.setCurrentOwnCloudAccount(account.name))
|
||||
@@ -51,9 +50,9 @@ class SessionMixin(
|
||||
setAccount(user.toPlatformAccount())
|
||||
}
|
||||
|
||||
fun getUser(): Optional<User> {
|
||||
fun getUser(): User? {
|
||||
return if (currentAccount.isAnonymous(activity)) {
|
||||
Optional.empty()
|
||||
null
|
||||
} else {
|
||||
accountManager.getUser(currentAccount.name)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import android.net.Uri
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import android.widget.RemoteViewsService
|
||||
import androidx.core.net.toUri
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.model.StreamEncoder
|
||||
@@ -85,7 +84,7 @@ class StackRemoteViewsFactory(
|
||||
|
||||
widgetConfiguration = widgetRepository.getWidget(appWidgetId)
|
||||
|
||||
if (!widgetConfiguration.user.isPresent) {
|
||||
if (widgetConfiguration.user == null) {
|
||||
// TODO show error
|
||||
Log_OC.e(this, "No user found!")
|
||||
}
|
||||
@@ -96,12 +95,12 @@ class StackRemoteViewsFactory(
|
||||
override fun onDataSetChanged() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
try {
|
||||
if (!widgetConfiguration.user.isPresent) {
|
||||
if (widgetConfiguration.user == null) {
|
||||
Log_OC.w(TAG, "User not present for widget update")
|
||||
return@launch
|
||||
}
|
||||
|
||||
val client = clientFactory.createNextcloudClient(widgetConfiguration.user.get())
|
||||
val client = clientFactory.createNextcloudClient(widgetConfiguration.user)
|
||||
val result = DashboardGetWidgetItemsRemoteOperation(widgetConfiguration.widgetId, LIMIT_SIZE)
|
||||
.execute(client)
|
||||
widgetItems = if (result.isSuccess) {
|
||||
@@ -142,7 +141,7 @@ class StackRemoteViewsFactory(
|
||||
|
||||
private fun createLoadMoreView(): RemoteViews {
|
||||
return RemoteViews(context.packageName, R.layout.widget_item_load_more).apply {
|
||||
val clickIntent = Intent(Intent.ACTION_VIEW, widgetConfiguration.moreButton?.link?.toUri())
|
||||
val clickIntent = Intent(Intent.ACTION_VIEW, Uri.parse(widgetConfiguration.moreButton?.link))
|
||||
setTextViewText(R.id.load_more, widgetConfiguration.moreButton?.text)
|
||||
setOnClickFillInIntent(R.id.load_more_container, clickIntent)
|
||||
}
|
||||
@@ -166,7 +165,7 @@ class StackRemoteViewsFactory(
|
||||
updateTexts(widgetItem, this)
|
||||
|
||||
if (widgetItem.link.isNotEmpty()) {
|
||||
val clickIntent = Intent(Intent.ACTION_VIEW, widgetItem.link.toUri())
|
||||
val clickIntent = Intent(Intent.ACTION_VIEW, Uri.parse(widgetItem.link))
|
||||
setOnClickFillInIntent(R.id.text_container, clickIntent)
|
||||
}
|
||||
}
|
||||
@@ -174,7 +173,7 @@ class StackRemoteViewsFactory(
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
private fun loadIcon(widgetItem: DashboardWidgetItem, remoteViews: RemoteViews) {
|
||||
val isIconSVG = widgetItem.iconUrl.toUri().encodedPath!!.endsWith(".svg")
|
||||
val isIconSVG = Uri.parse(widgetItem.iconUrl).encodedPath!!.endsWith(".svg")
|
||||
val source: FutureTarget<Bitmap> = if (isIconSVG) {
|
||||
loadSVGIcon(widgetItem)
|
||||
} else {
|
||||
@@ -208,13 +207,13 @@ class StackRemoteViewsFactory(
|
||||
.cacheDecoder(FileToStreamDecoder(SvgOrImageDecoder()))
|
||||
.decoder(SvgOrImageDecoder())
|
||||
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
||||
.load(widgetItem.iconUrl.toUri())
|
||||
.load(Uri.parse(widgetItem.iconUrl))
|
||||
.into(SVG_SIZE, SVG_SIZE)
|
||||
}
|
||||
|
||||
private fun loadBitmapIcon(widgetItem: DashboardWidgetItem): FutureTarget<Bitmap> {
|
||||
return Glide.with(context)
|
||||
.using(CustomGlideStreamLoader(widgetConfiguration.user.get(), clientFactory))
|
||||
.using(CustomGlideStreamLoader(widgetConfiguration.user, clientFactory))
|
||||
.load(widgetItem.iconUrl)
|
||||
.asBitmap()
|
||||
.into(SVG_SIZE, SVG_SIZE)
|
||||
|
||||
@@ -16,7 +16,6 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import androidx.core.net.toUri
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.model.StreamEncoder
|
||||
@@ -51,7 +50,7 @@ class DashboardWidgetUpdater @Inject constructor(
|
||||
) {
|
||||
val intent = Intent(context, DashboardWidgetService::class.java).apply {
|
||||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
|
||||
data = toUri(Intent.URI_INTENT_SCHEME).toUri()
|
||||
data = Uri.parse(toUri(Intent.URI_INTENT_SCHEME))
|
||||
}
|
||||
|
||||
val views = RemoteViews(context.packageName, R.layout.dashboard_widget).apply {
|
||||
@@ -131,7 +130,7 @@ class DashboardWidgetUpdater @Inject constructor(
|
||||
val intent = Intent(context, DashboardWidgetProvider::class.java).apply {
|
||||
setPackage(context.packageName)
|
||||
action = DashboardWidgetProvider.OPEN_INTENT
|
||||
data = addButton.link.toUri()
|
||||
data = Uri.parse(addButton.link)
|
||||
}
|
||||
|
||||
return PendingIntent.getBroadcast(
|
||||
@@ -178,7 +177,7 @@ class DashboardWidgetUpdater @Inject constructor(
|
||||
.cacheDecoder(FileToStreamDecoder(SvgOrImageDecoder()))
|
||||
.decoder(SvgOrImageDecoder())
|
||||
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
|
||||
.load(iconUrl.toUri())
|
||||
.load(Uri.parse(iconUrl))
|
||||
.into(iconTarget)
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ data class WidgetConfiguration(
|
||||
val title: String,
|
||||
val iconUrl: String,
|
||||
val roundIcon: Boolean,
|
||||
val user: Optional<User>,
|
||||
val user: User?,
|
||||
val addButton: DashboardButton?,
|
||||
val moreButton: DashboardButton?
|
||||
)
|
||||
@@ -8,7 +8,6 @@
|
||||
package com.nextcloud.client.widget
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.nextcloud.android.lib.resources.dashboard.DashBoardButtonType
|
||||
import com.nextcloud.android.lib.resources.dashboard.DashboardButton
|
||||
import com.nextcloud.android.lib.resources.dashboard.DashboardWidget
|
||||
@@ -22,52 +21,52 @@ class WidgetRepository @Inject constructor(
|
||||
val preferences: SharedPreferences
|
||||
) {
|
||||
fun saveWidget(widgetId: Int, widget: DashboardWidget, user: User) {
|
||||
preferences
|
||||
.edit {
|
||||
putString(PREF__WIDGET_ID + widgetId, widget.id)
|
||||
.putString(PREF__WIDGET_TITLE + widgetId, widget.title)
|
||||
.putString(PREF__WIDGET_ICON + widgetId, widget.iconUrl)
|
||||
.putBoolean(PREF__WIDGET_ROUND_ICON + widgetId, widget.roundIcons)
|
||||
.putString(PREF__WIDGET_USER + widgetId, user.accountName)
|
||||
val buttonList = widget.buttons
|
||||
if (!buttonList.isNullOrEmpty()) {
|
||||
for (button in buttonList) {
|
||||
if (button.type == DashBoardButtonType.NEW) {
|
||||
this
|
||||
.putString(PREF__WIDGET_ADD_BUTTON_TYPE + widgetId, button.type.toString())
|
||||
.putString(PREF__WIDGET_ADD_BUTTON_URL + widgetId, button.link)
|
||||
.putString(PREF__WIDGET_ADD_BUTTON_TEXT + widgetId, button.text)
|
||||
}
|
||||
if (button.type == DashBoardButtonType.MORE) {
|
||||
this
|
||||
.putString(PREF__WIDGET_MORE_BUTTON_TYPE + widgetId, button.type.toString())
|
||||
.putString(PREF__WIDGET_MORE_BUTTON_URL + widgetId, button.link)
|
||||
.putString(PREF__WIDGET_MORE_BUTTON_TEXT + widgetId, button.text)
|
||||
}
|
||||
}
|
||||
val editor: SharedPreferences.Editor = preferences
|
||||
.edit()
|
||||
.putString(PREF__WIDGET_ID + widgetId, widget.id)
|
||||
.putString(PREF__WIDGET_TITLE + widgetId, widget.title)
|
||||
.putString(PREF__WIDGET_ICON + widgetId, widget.iconUrl)
|
||||
.putBoolean(PREF__WIDGET_ROUND_ICON + widgetId, widget.roundIcons)
|
||||
.putString(PREF__WIDGET_USER + widgetId, user.accountName)
|
||||
val buttonList = widget.buttons
|
||||
if (buttonList != null && buttonList.isNotEmpty()) {
|
||||
for (button in buttonList) {
|
||||
if (button.type == DashBoardButtonType.NEW) {
|
||||
editor
|
||||
.putString(PREF__WIDGET_ADD_BUTTON_TYPE + widgetId, button.type.toString())
|
||||
.putString(PREF__WIDGET_ADD_BUTTON_URL + widgetId, button.link)
|
||||
.putString(PREF__WIDGET_ADD_BUTTON_TEXT + widgetId, button.text)
|
||||
}
|
||||
if (button.type == DashBoardButtonType.MORE) {
|
||||
editor
|
||||
.putString(PREF__WIDGET_MORE_BUTTON_TYPE + widgetId, button.type.toString())
|
||||
.putString(PREF__WIDGET_MORE_BUTTON_URL + widgetId, button.link)
|
||||
.putString(PREF__WIDGET_MORE_BUTTON_TEXT + widgetId, button.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
fun deleteWidget(widgetId: Int) {
|
||||
preferences
|
||||
.edit {
|
||||
remove(PREF__WIDGET_ID + widgetId)
|
||||
.remove(PREF__WIDGET_TITLE + widgetId)
|
||||
.remove(PREF__WIDGET_ICON + widgetId)
|
||||
.remove(PREF__WIDGET_ROUND_ICON + widgetId)
|
||||
.remove(PREF__WIDGET_USER + widgetId)
|
||||
.remove(PREF__WIDGET_ADD_BUTTON_TEXT + widgetId)
|
||||
.remove(PREF__WIDGET_ADD_BUTTON_URL + widgetId)
|
||||
.remove(PREF__WIDGET_ADD_BUTTON_TYPE + widgetId)
|
||||
.remove(PREF__WIDGET_MORE_BUTTON_TEXT + widgetId)
|
||||
.remove(PREF__WIDGET_MORE_BUTTON_URL + widgetId)
|
||||
.remove(PREF__WIDGET_MORE_BUTTON_TYPE + widgetId)
|
||||
}
|
||||
.edit()
|
||||
.remove(PREF__WIDGET_ID + widgetId)
|
||||
.remove(PREF__WIDGET_TITLE + widgetId)
|
||||
.remove(PREF__WIDGET_ICON + widgetId)
|
||||
.remove(PREF__WIDGET_ROUND_ICON + widgetId)
|
||||
.remove(PREF__WIDGET_USER + widgetId)
|
||||
.remove(PREF__WIDGET_ADD_BUTTON_TEXT + widgetId)
|
||||
.remove(PREF__WIDGET_ADD_BUTTON_URL + widgetId)
|
||||
.remove(PREF__WIDGET_ADD_BUTTON_TYPE + widgetId)
|
||||
.remove(PREF__WIDGET_MORE_BUTTON_TEXT + widgetId)
|
||||
.remove(PREF__WIDGET_MORE_BUTTON_URL + widgetId)
|
||||
.remove(PREF__WIDGET_MORE_BUTTON_TYPE + widgetId)
|
||||
.apply()
|
||||
}
|
||||
|
||||
fun getWidget(widgetId: Int): WidgetConfiguration {
|
||||
val userOptional: Optional<User> =
|
||||
val userOptional: User? =
|
||||
userAccountManager.getUser(preferences.getString(PREF__WIDGET_USER + widgetId, ""))
|
||||
|
||||
val addButton = createAddButton(widgetId)
|
||||
|
||||
@@ -86,9 +86,8 @@ class ChooseStorageLocationDialogFragment : DialogFragment(), Injectable {
|
||||
|
||||
private fun setupLocationSelection() {
|
||||
updateStorageTypeSelection()
|
||||
val currentStorageLocation = getCurrentStorageLocation() ?: return
|
||||
|
||||
val radioButton = when (currentStorageLocation.storageType) {
|
||||
val radioButton = when (getCurrentStorageLocation().storageType) {
|
||||
StorageType.EXTERNAL -> binding.storageExternalRadio
|
||||
else -> binding.storageInternalRadio
|
||||
}
|
||||
@@ -104,7 +103,7 @@ class ChooseStorageLocationDialogFragment : DialogFragment(), Injectable {
|
||||
}
|
||||
|
||||
val storagePath =
|
||||
storagePoints.find { it.storageType == storageType && it.privacyType == privacyType }?.path
|
||||
storagePoints.firstOrNull { it.storageType == storageType && it.privacyType == privacyType }?.path
|
||||
|
||||
return storagePath?.let {
|
||||
val file = File(it)
|
||||
@@ -137,17 +136,16 @@ class ChooseStorageLocationDialogFragment : DialogFragment(), Injectable {
|
||||
binding.storageExternalRadio.text = getStoragePointLabel(StorageType.EXTERNAL, selectedPrivacyType)
|
||||
}
|
||||
|
||||
private fun getCurrentStorageLocation(): StoragePoint? {
|
||||
private fun getCurrentStorageLocation(): StoragePoint {
|
||||
val appContext = MainApp.getAppContext()
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext)
|
||||
val storagePath = sharedPreferences.getString(AppPreferencesImpl.STORAGE_PATH, appContext.filesDir.absolutePath)
|
||||
return storagePoints.find { it.path == storagePath }
|
||||
return storagePoints.first { it.path == storagePath }
|
||||
}
|
||||
|
||||
private fun notifyResult() {
|
||||
val newPath =
|
||||
storagePoints.find { it.storageType == selectedStorageType && it.privacyType == selectedPrivacyType }
|
||||
?: return
|
||||
storagePoints.first { it.storageType == selectedStorageType && it.privacyType == selectedPrivacyType }
|
||||
|
||||
val resultBundle = Bundle().apply {
|
||||
putString(KEY_RESULT_STORAGE_LOCATION, newPath.path)
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.view.LayoutInflater
|
||||
@@ -18,7 +19,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
import com.nextcloud.client.NominatimClient
|
||||
@@ -356,7 +356,7 @@ class ImageDetailFragment : Fragment(), Injectable {
|
||||
private fun markerOnGestureListener(latitude: Double, longitude: Double) =
|
||||
object : OnItemGestureListener<OverlayItem> {
|
||||
override fun onItemSingleTapUp(index: Int, item: OverlayItem): Boolean {
|
||||
val intent = Intent(Intent.ACTION_VIEW, "geo:0,0?q=$latitude,$longitude".toUri())
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=$latitude,$longitude"))
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, activity, R.string.no_map_app_availble)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.core.graphics.scale
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun Bitmap.allocationKilobyte(): Int = allocationByteCount.div(1024)
|
||||
|
||||
/**
|
||||
* Recursively scales down the Bitmap until its size allocation is within the specified size.
|
||||
*
|
||||
* This function checks if the current Bitmap's size (in kilobytes) is already within
|
||||
* the target size. If not, it scales the Bitmap down by a factor of `1.5` in both width and height
|
||||
* and calls itself recursively until the size condition is met.
|
||||
*
|
||||
* @receiver Bitmap The original Bitmap to be resized.
|
||||
* @param targetKB The target size in kilobytes (KB) that the Bitmap should be reduced to.
|
||||
* @return A scaled-down Bitmap that meets the size allocation requirement.
|
||||
*/
|
||||
@Suppress("MagicNumber")
|
||||
fun Bitmap.scaleUntil(targetKB: Int): Bitmap {
|
||||
if (allocationKilobyte() <= targetKB) {
|
||||
return this
|
||||
}
|
||||
|
||||
// 1.5 is used to gradually scale down while minimizing distortion
|
||||
val scaleRatio = 1.5
|
||||
val width = width.div(scaleRatio).toInt()
|
||||
val height = height.div(scaleRatio).toInt()
|
||||
|
||||
val scaledBitmap = scale(width, height)
|
||||
return scaledBitmap.scaleUntil(targetKB)
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 ZetaTom <70907959+ZetaTom@users.noreply.github.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.net.toUri
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import java.util.Optional
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
object LinkHelper {
|
||||
const val APP_NEXTCLOUD_NOTES = "it.niedermann.owncloud.notes"
|
||||
const val APP_NEXTCLOUD_TALK = "com.nextcloud.talk2"
|
||||
|
||||
/**
|
||||
* Open specified app and, if not installed redirect to corresponding download.
|
||||
*
|
||||
* @param packageName of app to be opened
|
||||
* @param user to pass in intent
|
||||
*/
|
||||
fun openAppOrStore(packageName: String, user: Optional<User>, context: Context) {
|
||||
openAppOrStore(packageName, user.getOrNull(), context)
|
||||
}
|
||||
|
||||
/**
|
||||
* Open specified app and, if not installed redirect to corresponding download.
|
||||
*
|
||||
* @param packageName of app to be opened
|
||||
* @param user to pass in intent
|
||||
*/
|
||||
fun openAppOrStore(packageName: String, user: User?, context: Context) {
|
||||
val intent = context.packageManager.getLaunchIntentForPackage(packageName)
|
||||
if (intent != null) {
|
||||
// app installed - open directly
|
||||
// TODO handle null user?
|
||||
intent.putExtra(FileDisplayActivity.KEY_ACCOUNT, user.hashCode())
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
// app not found - open market (Google Play Store, F-Droid, etc.)
|
||||
openAppStore(packageName, false, context)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open app store page of specified app or search for specified string. Will attempt to open browser when no app
|
||||
* store is available.
|
||||
*
|
||||
* @param string packageName or url-encoded search string
|
||||
* @param search false -> show app corresponding to packageName; true -> open search for string
|
||||
*/
|
||||
fun openAppStore(string: String, search: Boolean = false, context: Context) {
|
||||
var suffix = (if (search) "search?q=" else "details?id=") + string
|
||||
val intent = Intent(Intent.ACTION_VIEW, "market://$suffix".toUri())
|
||||
try {
|
||||
context.startActivity(intent)
|
||||
} catch (activityNotFoundException1: ActivityNotFoundException) {
|
||||
// all is lost: open google play store web page for app
|
||||
if (!search) {
|
||||
suffix = "apps/$suffix"
|
||||
}
|
||||
intent.setData("https://play.google.com/store/$suffix".toUri())
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,12 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.core.content.pm.ShortcutInfoCompat
|
||||
import androidx.core.content.pm.ShortcutManagerCompat
|
||||
import androidx.core.graphics.createBitmap
|
||||
import androidx.core.graphics.drawable.IconCompat
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
@@ -98,8 +97,8 @@ class ShortcutUtil @Inject constructor(private val mContext: Context) {
|
||||
private fun bitmapToAdaptiveBitmap(orig: Bitmap): Bitmap {
|
||||
val adaptiveIconSize = mContext.resources.getDimensionPixelSize(R.dimen.adaptive_icon_size)
|
||||
val adaptiveIconOuterSides = mContext.resources.getDimensionPixelSize(R.dimen.adaptive_icon_padding)
|
||||
val drawable: Drawable = orig.toDrawable(mContext.resources)
|
||||
val bitmap = createBitmap(adaptiveIconSize, adaptiveIconSize)
|
||||
val drawable: Drawable = BitmapDrawable(mContext.resources, orig)
|
||||
val bitmap = Bitmap.createBitmap(adaptiveIconSize, adaptiveIconSize, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(bitmap)
|
||||
drawable.setBounds(
|
||||
adaptiveIconOuterSides,
|
||||
|
||||
@@ -14,26 +14,24 @@ import com.nextcloud.utils.extensions.shouldRemoveNonPrintableUnicodeCharactersA
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import org.apache.commons.io.FilenameUtils
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object AutoRename {
|
||||
private const val REPLACEMENT = "_"
|
||||
|
||||
@Suppress("NestedBlockDepth")
|
||||
fun rename(filename: String, capability: OCCapability): String {
|
||||
fun rename(filename: String, capability: OCCapability, isFolderPath: Boolean = false): String {
|
||||
if (!capability.version.isNewerOrEqual(NextcloudVersion.nextcloud_30)) {
|
||||
return filename
|
||||
}
|
||||
|
||||
val isFolder = filename.endsWith(OCFile.PATH_SEPARATOR)
|
||||
val pathSegments = filename.split(OCFile.PATH_SEPARATOR).toMutableList()
|
||||
|
||||
capability.run {
|
||||
if (forbiddenFilenameCharactersJson != null) {
|
||||
var forbiddenFilenameCharacters = capability.forbiddenFilenameCharacters()
|
||||
|
||||
if (isFolder) {
|
||||
if (isFolderPath) {
|
||||
forbiddenFilenameCharacters = forbiddenFilenameCharacters.filter { it != OCFile.PATH_SEPARATOR }
|
||||
}
|
||||
|
||||
@@ -72,27 +70,32 @@ object AutoRename {
|
||||
replaceFileExtensions(forbiddenExtension, segment)
|
||||
}
|
||||
}
|
||||
|
||||
pathSegments.replaceAll { segment ->
|
||||
lowercaseFileExtension(segment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val filenameWithExtension = pathSegments.joinToString(OCFile.PATH_SEPARATOR)
|
||||
val result = if (isFolder) filenameWithExtension else lowercaseFileExtension(filenameWithExtension)
|
||||
|
||||
val result = pathSegments.joinToString(OCFile.PATH_SEPARATOR)
|
||||
return if (capability.shouldRemoveNonPrintableUnicodeCharactersAndConvertToUTF8()) {
|
||||
val utf8Result = convertToUTF8(result)
|
||||
removeNonPrintableUnicodeCharacters(utf8Result)
|
||||
} else {
|
||||
result
|
||||
}.trim()
|
||||
}
|
||||
}
|
||||
|
||||
private fun lowercaseFileExtension(filename: String): String {
|
||||
val extension = FilenameUtils.getExtension(filename).lowercase()
|
||||
val filenameWithoutExtension = FilenameUtils.removeExtension(filename)
|
||||
return if (extension.isNotEmpty()) {
|
||||
filenameWithoutExtension + StringConstants.DOT + extension
|
||||
private fun lowercaseFileExtension(input: String): String {
|
||||
val lastDotIndex = input.lastIndexOf('.')
|
||||
|
||||
return if (lastDotIndex > 0) {
|
||||
val base = input.substring(0, lastDotIndex)
|
||||
val extension = input.substring(lastDotIndex + 1).lowercase() // Convert extension to lowercase
|
||||
|
||||
"$base.$extension"
|
||||
} else {
|
||||
filenameWithoutExtension
|
||||
input
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
|
||||
fun FileDataStorageManager.getDecryptedPath(file: OCFile): String {
|
||||
val paths = mutableListOf<String>()
|
||||
var entity = fileDao.getFileByEncryptedRemotePath(file.remotePath, user.accountName)
|
||||
|
||||
while (entity != null) {
|
||||
entity.name?.takeIf { it.isNotEmpty() }?.let {
|
||||
paths.add(it.removePrefix(OCFile.PATH_SEPARATOR))
|
||||
}
|
||||
entity = entity.parent?.let { fileDao.getFileById(it) } ?: break
|
||||
}
|
||||
|
||||
return paths
|
||||
.reversed()
|
||||
.joinToString(OCFile.PATH_SEPARATOR)
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.Lifecycle
|
||||
|
||||
inline fun <reified T : Any> Fragment.typedActivity(): T? {
|
||||
return if (isAdded && activity != null && activity is T) {
|
||||
@@ -28,6 +27,3 @@ fun <T : Any> Fragment.getTypedActivity(type: Class<T>): T? {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun Fragment.isDialogFragmentReady() =
|
||||
isAdded && !isStateSaved && activity?.lifecycle?.currentState?.isAtLeast(Lifecycle.State.RESUMED) == true
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun IntArray.toByteArray(): ByteArray {
|
||||
val byteBuffer = ByteBuffer.allocate(this.size * 4)
|
||||
val intBuffer = byteBuffer.asIntBuffer()
|
||||
intBuffer.put(this)
|
||||
return byteBuffer.array()
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun ByteArray.toIntArray(): IntArray {
|
||||
val intBuffer = ByteBuffer.wrap(this).asIntBuffer()
|
||||
val intArray = IntArray(this.size / 4)
|
||||
intBuffer.get(intArray)
|
||||
return intArray
|
||||
}
|
||||
@@ -25,13 +25,10 @@ fun String.removeFileExtension(): String {
|
||||
}
|
||||
}
|
||||
|
||||
fun String.truncateWithEllipsis(limit: Int) = take(limit) + if (length > limit) StringConstants.THREE_DOT else ""
|
||||
|
||||
object StringConstants {
|
||||
const val SLASH = "/"
|
||||
const val DOT = "."
|
||||
const val SPACE = " "
|
||||
const val THREE_DOT = "..."
|
||||
}
|
||||
|
||||
fun String.getContentOfPublicKey(): String {
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem
|
||||
import java.io.File
|
||||
|
||||
fun List<SyncedFolderDisplayItem>.filterEnabledOrWithoutEnabledParent(): List<SyncedFolderDisplayItem> {
|
||||
return filter { it.isEnabled || !hasEnabledParent(it.localPath) }
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
fun List<SyncedFolder>.hasEnabledParent(localPath: String?): Boolean {
|
||||
localPath ?: return false
|
||||
|
||||
val localFile = File(localPath).takeIf { it.exists() } ?: return false
|
||||
val parent = localFile.parentFile ?: return false
|
||||
|
||||
return any { it.isEnabled && File(it.localPath).exists() && File(it.localPath) == parent } ||
|
||||
hasEnabledParent(parent.absolutePath)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.extensions
|
||||
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.updatePadding
|
||||
|
||||
fun Window?.setNoLimitLayout() {
|
||||
val flag = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
this?.setFlags(flag, flag)
|
||||
}
|
||||
|
||||
fun Window?.addSystemBarPaddings() {
|
||||
if (this == null) {
|
||||
return
|
||||
}
|
||||
|
||||
ViewCompat.setOnApplyWindowInsetsListener(decorView) { v: View, insets: WindowInsetsCompat ->
|
||||
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
|
||||
v.updatePadding(
|
||||
left = bars.left,
|
||||
top = bars.top,
|
||||
right = bars.right,
|
||||
bottom = bars.bottom
|
||||
)
|
||||
|
||||
WindowInsetsCompat.CONSUMED
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.numberFormatter
|
||||
|
||||
import java.text.NumberFormat
|
||||
import java.util.Locale
|
||||
|
||||
object NumberFormatter {
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun getPercentageText(percent: Int): String {
|
||||
val formatter = NumberFormat.getPercentInstance(Locale.getDefault())
|
||||
formatter.maximumFractionDigits = 0
|
||||
return formatter.format(percent / 100.0)
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class LauncherActivity : BaseActivity() {
|
||||
|
||||
private fun scheduleSplashScreen() {
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
if (user.isPresent) {
|
||||
if (user != null) {
|
||||
if (MDMConfig.enforceProtection(this) && appPreferences.lockPreference == SettingsActivity.LOCK_NONE) {
|
||||
startActivity(Intent(this, SettingsActivity::class.java))
|
||||
} else {
|
||||
|
||||
@@ -327,54 +327,53 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
initServerPreFragment(savedInstanceState);
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleEventObserver);
|
||||
}
|
||||
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(lifecycleEventObserver);
|
||||
}
|
||||
|
||||
private void showEnforcedServers() {
|
||||
showAuthStatus();
|
||||
accountSetupBinding.hostUrlFrame.setVisibility(View.GONE);
|
||||
accountSetupBinding.hostUrlInputHelperText.setVisibility(View.GONE);
|
||||
accountSetupBinding.scanQr.setVisibility(View.GONE);
|
||||
accountSetupBinding.serversSpinner.setVisibility(View.VISIBLE);
|
||||
|
||||
private void showEnforcedServers() {
|
||||
showAuthStatus();
|
||||
accountSetupBinding.hostUrlFrame.setVisibility(View.GONE);
|
||||
accountSetupBinding.hostUrlInputHelperText.setVisibility(View.GONE);
|
||||
accountSetupBinding.scanQr.setVisibility(View.GONE);
|
||||
accountSetupBinding.serversSpinner.setVisibility(View.VISIBLE);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.enforced_servers_spinner);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.enforced_servers_spinner);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
ArrayList<String> servers = new ArrayList<>();
|
||||
servers.add("");
|
||||
adapter.add(getString(R.string.please_select_a_server));
|
||||
|
||||
ArrayList<String> servers = new ArrayList<>();
|
||||
servers.add("");
|
||||
adapter.add(getString(R.string.please_select_a_server));
|
||||
ArrayList<EnforcedServer> t = new Gson().fromJson(getString(R.string.enforce_servers),
|
||||
new TypeToken<ArrayList<EnforcedServer>>() {
|
||||
}
|
||||
.getType());
|
||||
|
||||
ArrayList<EnforcedServer> t = new Gson().fromJson(getString(R.string.enforce_servers),
|
||||
new TypeToken<ArrayList<EnforcedServer>>() {
|
||||
}
|
||||
.getType());
|
||||
for (EnforcedServer e : t) {
|
||||
adapter.add(e.getName());
|
||||
servers.add(e.getUrl());
|
||||
}
|
||||
|
||||
for (EnforcedServer e : t) {
|
||||
adapter.add(e.getName());
|
||||
servers.add(e.getUrl());
|
||||
}
|
||||
accountSetupBinding.serversSpinner.setAdapter(adapter);
|
||||
accountSetupBinding.serversSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
|
||||
|
||||
accountSetupBinding.serversSpinner.setAdapter(adapter);
|
||||
accountSetupBinding.serversSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
String url = servers.get(position);
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
String url = servers.get(position);
|
||||
|
||||
if (URLUtil.isValidUrl(url)) {
|
||||
accountSetupBinding.hostUrlInput.setText(url);
|
||||
checkOcServer();
|
||||
if (URLUtil.isValidUrl(url)) {
|
||||
accountSetupBinding.hostUrlInput.setText(url);
|
||||
checkOcServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> {
|
||||
if (event == Lifecycle.Event.ON_START && token != null) {
|
||||
@@ -1205,12 +1204,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private void getUserCapabilitiesAndFinish() {
|
||||
final Handler handler = new Handler();
|
||||
final Optional<User> user = accountManager.getUser(mAccount.name);
|
||||
final User user = accountManager.getUser(mAccount.name);
|
||||
|
||||
if (user.isPresent()) {
|
||||
if (user != null) {
|
||||
Executors.newSingleThreadExecutor().execute(() -> {
|
||||
try {
|
||||
final FileDataStorageManager storageManager = new FileDataStorageManager(user.get(), getContentResolver());
|
||||
final FileDataStorageManager storageManager = new FileDataStorageManager(user, getContentResolver());
|
||||
new GetCapabilitiesOperation(storageManager).execute(MainApp.getAppContext());
|
||||
handler.post(this::endSuccess);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -13,8 +13,8 @@ package com.owncloud.android.authentication
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.AsyncTask
|
||||
import androidx.core.net.toUri
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.OwnCloudClientFactory
|
||||
import com.owncloud.android.lib.common.OwnCloudCredentials
|
||||
@@ -46,7 +46,7 @@ class AuthenticatorAsyncTask(activity: Activity) : AsyncTask<Any?, Void?, Remote
|
||||
val context = mWeakContext.get()
|
||||
|
||||
// Client
|
||||
val uri = url.toUri()
|
||||
val uri = Uri.parse(url)
|
||||
val nextcloudClient = OwnCloudClientFactory.createNextcloudClient(
|
||||
uri,
|
||||
credentials.username,
|
||||
|
||||
@@ -108,7 +108,7 @@ public class FileDataStorageManager {
|
||||
private final User user;
|
||||
|
||||
public final OfflineOperationDao offlineOperationDao = NextcloudDatabase.getInstance(MainApp.getAppContext()).offlineOperationDao();
|
||||
public final FileDao fileDao = NextcloudDatabase.getInstance(MainApp.getAppContext()).fileDao();
|
||||
private final FileDao fileDao = NextcloudDatabase.getInstance(MainApp.getAppContext()).fileDao();
|
||||
private final Gson gson = new Gson();
|
||||
public final OfflineOperationsRepositoryType offlineOperationsRepository;
|
||||
|
||||
@@ -2315,10 +2315,6 @@ public class FileDataStorageManager {
|
||||
|
||||
contentValues.put(ProviderTableMeta.CAPABILITIES_RECOMMENDATION, capability.getRecommendations().getValue());
|
||||
|
||||
contentValues.put(ProviderTableMeta.CAPABILITIES_NOTES_FOLDER_PATH, capability.getNotesFolderPath());
|
||||
|
||||
contentValues.put(ProviderTableMeta.CAPABILITIES_DEFAULT_PERMISSIONS, capability.getDefaultPermissions());
|
||||
|
||||
return contentValues;
|
||||
}
|
||||
|
||||
@@ -2494,12 +2490,7 @@ public class FileDataStorageManager {
|
||||
capability.setForbiddenFilenameBaseNamesJson(getString(cursor, ProviderTableMeta.CAPABILITIES_FORBIDDEN_FORBIDDEN_FILENAME_BASE_NAMES));
|
||||
capability.setFilesDownloadLimit(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT));
|
||||
capability.setFilesDownloadLimitDefault(getInt(cursor, ProviderTableMeta.CAPABILITIES_FILES_DOWNLOAD_LIMIT_DEFAULT));
|
||||
|
||||
capability.setRecommendations(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_RECOMMENDATION));
|
||||
|
||||
capability.setNotesFolderPath(getString(cursor, ProviderTableMeta.CAPABILITIES_NOTES_FOLDER_PATH));
|
||||
|
||||
capability.setDefaultPermissions(getInt(cursor, ProviderTableMeta.CAPABILITIES_DEFAULT_PERMISSIONS));
|
||||
}
|
||||
|
||||
return capability;
|
||||
|
||||
@@ -762,7 +762,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
}
|
||||
|
||||
public boolean isShared() {
|
||||
return isSharedViaLink() || isSharedWithSharee() || isSharedWithMe() || !sharees.isEmpty();
|
||||
return isSharedViaLink() || isSharedWithSharee() || isSharedWithMe();
|
||||
}
|
||||
|
||||
public String getPermissions() {
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Tobias Kaminsky <tobias.kaminsky@nextcloud.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datamodel
|
||||
|
||||
enum class SharesType {
|
||||
INTERNAL,
|
||||
EXTERNAL
|
||||
}
|
||||
@@ -36,7 +36,6 @@ import android.widget.ImageView;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.utils.BitmapExtensionsKt;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
@@ -100,7 +99,6 @@ public final class ThumbnailsCacheManager {
|
||||
private static final CompressFormat mCompressFormat = CompressFormat.JPEG;
|
||||
private static final int mCompressQuality = 70;
|
||||
private static OwnCloudClient mClient;
|
||||
private static final int THUMBNAIL_SIZE_IN_KB = 512;
|
||||
|
||||
public static final Bitmap mDefaultImg = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(),
|
||||
R.drawable.file_image);
|
||||
@@ -204,27 +202,9 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
public static void addBitmapToCache(String key, Bitmap bitmap) {
|
||||
synchronized (mThumbnailsDiskCacheLock) {
|
||||
if (mThumbnailCache == null) {
|
||||
return;
|
||||
if (mThumbnailCache != null) {
|
||||
mThumbnailCache.put(key, bitmap);
|
||||
}
|
||||
|
||||
// Check if the bitmap is already cached
|
||||
Bitmap cachedBitmap = mThumbnailCache.getBitmap(key);
|
||||
if (cachedBitmap == null) {
|
||||
cachedBitmap = mThumbnailCache.getScaledBitmap(key, bitmap.getWidth(), bitmap.getHeight());
|
||||
}
|
||||
|
||||
if (cachedBitmap != null && BitmapExtensionsKt.allocationKilobyte(cachedBitmap) <= THUMBNAIL_SIZE_IN_KB) {
|
||||
Log_OC.d(TAG, "Cached version is already within size limits, no need to scale: " + key);
|
||||
return;
|
||||
}
|
||||
|
||||
if (BitmapExtensionsKt.allocationKilobyte(bitmap) > THUMBNAIL_SIZE_IN_KB) {
|
||||
Log_OC.d(TAG, "Scaling bitmap before caching: " + key);
|
||||
bitmap = BitmapExtensionsKt.scaleUntil(bitmap, THUMBNAIL_SIZE_IN_KB);
|
||||
}
|
||||
|
||||
mThumbnailCache.put(key, bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,10 +273,14 @@ public final class ThumbnailsCacheManager {
|
||||
this.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public void setListener(GalleryListener listener) {
|
||||
public void setListener(GalleryImageGenerationTask.GalleryListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public String getImageKey() {
|
||||
return imageKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap doInBackground(Object... params) {
|
||||
Bitmap thumbnail;
|
||||
@@ -358,29 +342,11 @@ public final class ThumbnailsCacheManager {
|
||||
storageManager.saveFile(file);
|
||||
}
|
||||
|
||||
Bitmap result = thumbnail;
|
||||
if (MimeTypeUtil.isVideo(file)) {
|
||||
result = ThumbnailsCacheManager.addVideoOverlay(thumbnail, MainApp.getAppContext());
|
||||
return ThumbnailsCacheManager.addVideoOverlay(thumbnail, MainApp.getAppContext());
|
||||
} else {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
if (BitmapExtensionsKt.allocationKilobyte(thumbnail) > THUMBNAIL_SIZE_IN_KB) {
|
||||
result = getScaledThumbnailAfterSave(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Bitmap getScaledThumbnailAfterSave(Bitmap thumbnail) {
|
||||
Bitmap result = BitmapExtensionsKt.scaleUntil(thumbnail, THUMBNAIL_SIZE_IN_KB);
|
||||
|
||||
synchronized (mThumbnailsDiskCacheLock) {
|
||||
if (mThumbnailCache != null) {
|
||||
Log_OC.d(TAG, "Scaling bitmap before caching: " + imageKey);
|
||||
mThumbnailCache.put(imageKey, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Bitmap bitmap) {
|
||||
@@ -704,7 +670,8 @@ public final class ThumbnailsCacheManager {
|
||||
int pxH;
|
||||
pxW = pxH = getThumbnailDimension();
|
||||
|
||||
if (file instanceof OCFile ocFile) {
|
||||
if (file instanceof OCFile) {
|
||||
OCFile ocFile = (OCFile) file;
|
||||
if (ocFile.isDown()) {
|
||||
Bitmap bitmap;
|
||||
if (MimeTypeUtil.isVideo(ocFile)) {
|
||||
@@ -1184,7 +1151,8 @@ public final class ThumbnailsCacheManager {
|
||||
public static ThumbnailGenerationTask getBitmapWorkerTask(ImageView imageView) {
|
||||
if (imageView != null) {
|
||||
final Drawable drawable = imageView.getDrawable();
|
||||
if (drawable instanceof AsyncThumbnailDrawable asyncDrawable) {
|
||||
if (drawable instanceof AsyncThumbnailDrawable) {
|
||||
final AsyncThumbnailDrawable asyncDrawable = (AsyncThumbnailDrawable) drawable;
|
||||
return asyncDrawable.getBitmapWorkerTask();
|
||||
}
|
||||
}
|
||||
@@ -1194,7 +1162,8 @@ public final class ThumbnailsCacheManager {
|
||||
private static ResizedImageGenerationTask getResizedImageGenerationWorkerTask(ImageView imageView) {
|
||||
if (imageView != null) {
|
||||
final Drawable drawable = imageView.getDrawable();
|
||||
if (drawable instanceof AsyncResizedImageDrawable asyncDrawable) {
|
||||
if (drawable instanceof AsyncResizedImageDrawable) {
|
||||
final AsyncResizedImageDrawable asyncDrawable = (AsyncResizedImageDrawable) drawable;
|
||||
return asyncDrawable.getBitmapWorkerTask();
|
||||
}
|
||||
}
|
||||
@@ -1204,7 +1173,8 @@ public final class ThumbnailsCacheManager {
|
||||
private static GalleryImageGenerationTask getGalleryImageGenerationTask(ImageView imageView) {
|
||||
if (imageView != null) {
|
||||
final Drawable drawable = imageView.getDrawable();
|
||||
if (drawable instanceof AsyncGalleryImageDrawable asyncDrawable) {
|
||||
if (drawable instanceof AsyncGalleryImageDrawable) {
|
||||
final AsyncGalleryImageDrawable asyncDrawable = (AsyncGalleryImageDrawable) drawable;
|
||||
return asyncDrawable.getBitmapWorkerTask();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ public class UploadsStorageManager extends Observable {
|
||||
|
||||
String remotePath = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_REMOTE_PATH));
|
||||
if (capability != null) {
|
||||
remotePath = AutoRename.INSTANCE.rename(remotePath, capability);
|
||||
remotePath = AutoRename.INSTANCE.rename(remotePath, capability,true);
|
||||
}
|
||||
|
||||
String accountName = c.getString(c.getColumnIndexOrThrow(ProviderTableMeta.UPLOADS_ACCOUNT_NAME));
|
||||
|
||||
@@ -44,7 +44,7 @@ abstract class AbstractCommandLineStoragePoint extends AbstractStoragePointProvi
|
||||
|
||||
process.waitFor();
|
||||
final InputStream is = process.getInputStream();
|
||||
final byte[] buffer = new byte[1024];
|
||||
final byte buffer[] = new byte[1024];
|
||||
while (is.read(buffer) != -1) {
|
||||
s.append(new String(buffer, "UTF8"));
|
||||
}
|
||||
|
||||