Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d8a530e68 | ||
|
|
940fe90556 | ||
|
|
a8ea93dd14 | ||
|
|
54e57dc146 | ||
|
|
62d58d0a36 | ||
|
|
03453c787a | ||
|
|
91efa194c1 | ||
|
|
454f7c6b96 | ||
|
|
b2b80c031b | ||
|
|
d5d64b6f38 | ||
|
|
c0c094c30e | ||
|
|
0649f787b8 | ||
|
|
6cf85b290d | ||
|
|
55cffc80d1 | ||
|
|
51eb6e8620 | ||
|
|
8ef80aa105 | ||
|
|
06820a21fd | ||
|
|
fb1469aeea | ||
|
|
6297742f01 | ||
|
|
a6dc89a8e5 | ||
|
|
7adadbb53c | ||
|
|
9cff9725fc | ||
|
|
a753f4ef03 | ||
|
|
02f23f326d | ||
|
|
3b3d23ff0a | ||
|
|
43c4876ef3 | ||
|
|
cd488d38f1 | ||
|
|
8d4ed0a862 | ||
|
|
b950be1f7d | ||
|
|
ac208945e8 | ||
|
|
8a9a9ec66d | ||
|
|
27be297146 | ||
|
|
db85ebba94 | ||
|
|
84d1ffa546 | ||
|
|
04a0ce1e71 | ||
|
|
96ee2ee661 | ||
|
|
805ec3e61a | ||
|
|
d33d5a20fd | ||
|
|
f34fff62a8 | ||
|
|
73a18fbf6e | ||
|
|
be79e3cf37 | ||
|
|
b897f09683 | ||
|
|
ea4222a1ae | ||
|
|
09b95951c5 | ||
|
|
d374d87c24 | ||
|
|
4b0adb1bae | ||
|
|
12312393b2 | ||
|
|
20ec696c99 | ||
|
|
d6f6f36d52 | ||
|
|
362a8286a6 | ||
|
|
5627e92619 | ||
|
|
aac4a0cd67 | ||
|
|
323fd34680 | ||
|
|
1924041e4b | ||
|
|
bac992254c | ||
|
|
0ae42c892c | ||
|
|
520d17bb8b | ||
|
|
4be4974c7e | ||
|
|
1b021a9eb9 | ||
|
|
ad5769c98c | ||
|
|
36062f7502 | ||
|
|
76ab52499d | ||
|
|
3c97b4b619 | ||
|
|
f0b77e5751 | ||
|
|
26aef8e462 | ||
|
|
d34d3b419a | ||
|
|
ba7a2192f3 | ||
|
|
0cd5f1b9f4 | ||
|
|
49ad952544 | ||
|
|
81ce812d86 | ||
|
|
3eb3079757 | ||
|
|
f079f030cf | ||
|
|
f50d9f8451 | ||
|
|
6d40f25f29 | ||
|
|
2cd2e29b86 | ||
|
|
db30142ad3 | ||
|
|
f8ad9ae413 | ||
|
|
d90083fc07 | ||
|
|
46ccddcef4 | ||
|
|
a902fb6f84 | ||
|
|
a88b03a0c8 | ||
|
|
68b2535481 | ||
|
|
356db04aa8 | ||
|
|
fd2435379a | ||
|
|
f5ecaf91d1 | ||
|
|
353afb119c | ||
|
|
b8cf8dade8 | ||
|
|
123cf4ad65 | ||
|
|
9a2cbcbba4 | ||
|
|
13e061e7d7 | ||
|
|
7a2c735795 | ||
|
|
2bb8c91965 | ||
|
|
f4546d1ceb | ||
|
|
ddb96e7b17 | ||
|
|
e33e801bd8 | ||
|
|
1ea61c6fe6 | ||
|
|
2560d1be3c | ||
|
|
b58749d459 | ||
|
|
2bd8fb4240 | ||
|
|
9463d2e668 | ||
|
|
7e31a71ba0 | ||
|
|
85dcbe542e | ||
|
|
8c2fc3ee87 | ||
|
|
3148d94262 | ||
|
|
21ed337184 | ||
|
|
caf89f7908 | ||
|
|
4ff54bb48b | ||
|
|
bdd1daa10e | ||
|
|
e023cedd7f | ||
|
|
3ff35d46e6 | ||
|
|
56584c06e6 | ||
|
|
42c28dce70 | ||
|
|
e2c3091fc0 | ||
|
|
17828cb3b4 | ||
|
|
f627f3d976 | ||
|
|
6bd7d808f4 | ||
|
|
74e17ee7c6 | ||
|
|
75cb8a767c | ||
|
|
349a045b46 | ||
|
|
0a802b51da | ||
|
|
c81c1c83aa | ||
|
|
87ed56f4d9 | ||
|
|
bc44b2c524 | ||
|
|
73bb12f78a | ||
|
|
011d6c3ceb | ||
|
|
236925de99 | ||
|
|
a2d2c1a3c7 | ||
|
|
d79b20dbc5 | ||
|
|
98177e3eb3 | ||
|
|
c20c3e4066 | ||
|
|
23dd1f30f1 | ||
|
|
176fb24d5b | ||
|
|
7073746309 | ||
|
|
6eff01d735 | ||
|
|
79fc8c61d9 | ||
|
|
f93e65872a | ||
|
|
3879d90eec | ||
|
|
21a432dc9e | ||
|
|
c850d14fc0 | ||
|
|
7f00cd6e46 | ||
|
|
3b80d4dc1f | ||
|
|
323fdda409 | ||
|
|
f572176e4c | ||
|
|
68b2665b09 | ||
|
|
d61a8f3444 | ||
|
|
b3b3376c5b | ||
|
|
dd4a69d58c | ||
|
|
85b5bf6875 | ||
|
|
bd139f1afb | ||
|
|
d45e12c2b8 | ||
|
|
828bef6af7 | ||
|
|
1095fd540d | ||
|
|
cae58daa4c | ||
|
|
93b236ff7c | ||
|
|
de0bcbb279 | ||
|
|
98075eba14 | ||
|
|
042c3758ac | ||
|
|
14aac48b90 | ||
|
|
0ad80b89cc | ||
|
|
7759475728 | ||
|
|
4086ad36b3 | ||
|
|
0c189a77b4 | ||
|
|
7cc0d53cff | ||
|
|
0b08f95361 | ||
|
|
4da8fc27e4 | ||
|
|
f17cb72f99 | ||
|
|
c944203d93 | ||
|
|
d1a3b415d8 | ||
|
|
9e29b5cbc4 | ||
|
|
ca72520d54 | ||
|
|
8610bc7ba3 | ||
|
|
fb12a65949 | ||
|
|
997e4c736c | ||
|
|
eddbe5ef28 | ||
|
|
a785135b1b | ||
|
|
ff3833c62f | ||
|
|
0def0a8af8 | ||
|
|
97d71d0383 | ||
|
|
bb82017448 | ||
|
|
e4a20d1f48 | ||
|
|
3ab5f6ea0a | ||
|
|
75e828cf54 | ||
|
|
0e03400486 | ||
|
|
9a899ce3dc | ||
|
|
68b4b6fe56 | ||
|
|
914319c940 | ||
|
|
66b500b9dc | ||
|
|
3930633272 | ||
|
|
58b34c3ee4 | ||
|
|
df887ce4f2 | ||
|
|
7ed1b84375 | ||
|
|
e47f97b07e | ||
|
|
a9608108ac | ||
|
|
bce8866961 | ||
|
|
a9473d6158 | ||
|
|
31dda2e0fb | ||
|
|
ce6bb70415 | ||
|
|
b4dc084d65 | ||
|
|
c8cf7bbfe7 | ||
|
|
075e91d9ba | ||
|
|
f57aa2037b | ||
|
|
2154e4d3ea | ||
|
|
3c69ae92bb | ||
|
|
e67fc70451 | ||
|
|
930d3e61fd | ||
|
|
cf932e69e7 | ||
|
|
7fb9b97e8d | ||
|
|
5e924a5c4f | ||
|
|
abc9f14555 | ||
|
|
7817a3b8d5 | ||
|
|
86ee9dff69 | ||
|
|
7c6bce5617 | ||
|
|
f2ff5482e9 | ||
|
|
f8f46e62b9 | ||
|
|
d97edf023d | ||
|
|
ace6b49786 | ||
|
|
df7e70a3f1 | ||
|
|
b84149ac7c | ||
|
|
69234dec5f | ||
|
|
9d68af7caf | ||
|
|
d781583c6c | ||
|
|
568988d891 | ||
|
|
d33a3ce9e4 | ||
|
|
9827612010 | ||
|
|
ba369f22ab | ||
|
|
bf1657facb | ||
|
|
5b8d11f738 | ||
|
|
0736d01f01 | ||
|
|
dc15edb6f6 | ||
|
|
b324f0d784 | ||
|
|
c84d09f006 | ||
|
|
84d7aa5406 | ||
|
|
77507f9c9b | ||
|
|
cd895ad2cf | ||
|
|
7285ddc4cb | ||
|
|
d9811e1f34 | ||
|
|
1666224219 | ||
|
|
9a94cb1e12 | ||
|
|
2dc9ec212a | ||
|
|
70c605fd78 | ||
|
|
d931d37e91 | ||
|
|
4b8bb8a707 | ||
|
|
ca751d0f71 | ||
|
|
3753ef361c | ||
|
|
a1901ca3e8 | ||
|
|
95046c4b5d | ||
|
|
23a72722d3 | ||
|
|
2e593a034b | ||
|
|
154755af9b | ||
|
|
b8bb261234 | ||
|
|
6a527a6e87 | ||
|
|
17b695728e | ||
|
|
fb5de078f7 | ||
|
|
d013464320 | ||
|
|
3aad1fc376 | ||
|
|
8f641e8aa2 | ||
|
|
f522446d13 | ||
|
|
0c5a9fd155 | ||
|
|
e481382c28 | ||
|
|
f65b99a265 | ||
|
|
ea27e54d26 | ||
|
|
f6298f7904 | ||
|
|
6c858840cb | ||
|
|
646f857890 | ||
|
|
4cf9b68fab | ||
|
|
c18bf9983e | ||
|
|
5cfa23c14b | ||
|
|
042b6aa38a | ||
|
|
ae0840e5aa | ||
|
|
d91d2996ab | ||
|
|
bfccee5d15 | ||
|
|
eeee70f472 | ||
|
|
380585ea52 | ||
|
|
efd6d88124 | ||
|
|
a9bc999574 | ||
|
|
edac6e2870 | ||
|
|
d63d22d066 | ||
|
|
abf14b52cf | ||
|
|
354047fdce | ||
|
|
321a97acf7 | ||
|
|
5cadf81c43 | ||
|
|
98575bc8ca | ||
|
|
d7dbef4085 | ||
|
|
6d1b14785c | ||
|
|
138d3a03a9 | ||
|
|
e7e2ab8a96 | ||
|
|
769816978a | ||
|
|
886400b5e0 | ||
|
|
b70eeaae3a | ||
|
|
ad13f544ee | ||
|
|
a64986e2e3 | ||
|
|
3e2eba34a5 | ||
|
|
0af297735c | ||
|
|
e8e18609e5 | ||
|
|
e8acc254b8 | ||
|
|
3597fb0a53 | ||
|
|
eccd9205bd | ||
|
|
76d9bbfba3 | ||
|
|
3975839d53 | ||
|
|
d6f32eb5ce | ||
|
|
d9b8b3baf8 | ||
|
|
e82fb2c6da | ||
|
|
080736af30 | ||
|
|
934953506f | ||
|
|
91520971cd | ||
|
|
ec98c5db52 | ||
|
|
3b5d9ddabf | ||
|
|
12ce7c2837 | ||
|
|
1a9014ee3b | ||
|
|
2a4316a298 | ||
|
|
d8811c97a1 | ||
|
|
db196c68a4 | ||
|
|
ad5b443489 | ||
|
|
7d2f0fa017 | ||
|
|
55c9811db6 | ||
|
|
91c46090e8 | ||
|
|
05bd775171 | ||
|
|
d2f670369f | ||
|
|
d4d18307b7 | ||
|
|
a860761144 | ||
|
|
785767ae70 | ||
|
|
900145da05 |
No files matched your search
@@ -20,25 +20,21 @@ steps:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g app/src/main/res/values/setup.xml
|
||||
- sed -i s"#server#server#" gradle.properties
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- ./gradlew assembleGplayDebugAndroidTest
|
||||
- scripts/wait_for_emulator.sh
|
||||
- scripts/deleteOldComments.sh "stable" "Unit" $DRONE_PULL_REQUEST $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- scripts/deleteOldComments.sh "stable" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_TOKEN
|
||||
- ./gradlew combinedTestReport
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: ghcr.io/nextcloud/continuous-integration-server:latest # also change in updateScreenshots.sh
|
||||
environment:
|
||||
EVAL: true
|
||||
SERVER_VERSION: 'stable24'
|
||||
commands:
|
||||
- BRANCH='stable23' /usr/local/bin/initnc.sh
|
||||
- BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
|
||||
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
|
||||
@@ -47,11 +43,11 @@ services:
|
||||
- su www-data -c "php /var/www/html/occ group:add users"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user1"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user2"
|
||||
- su www-data -c "git clone -b stable23 https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
|
||||
- su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable activity"
|
||||
- su www-data -c "git clone -b stable23 https://github.com/nextcloud/text.git /var/www/html/apps/text/"
|
||||
- su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable text"
|
||||
- su www-data -c "git clone -b stable23 https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/"
|
||||
- su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
|
||||
@@ -36,10 +36,13 @@ jobs:
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python3 -m pip install defusedxml
|
||||
- name: Run analysis wrapper
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
auto-approve:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: hmarr/auto-approve-action@v2.1.0
|
||||
- uses: hmarr/auto-approve-action@v2.2.1
|
||||
if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
|
||||
with:
|
||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
@@ -10,11 +10,11 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
task: [ detekt, ktlint ]
|
||||
task: [ detekt, ktlintCheck ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Add reaction on start
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
@@ -32,12 +32,12 @@ jobs:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
- name: Automatic Rebase
|
||||
uses: cirrus-actions/rebase@1.5
|
||||
uses: cirrus-actions/rebase@1.6
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
- name: Add reaction on failure
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
if: failure()
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
name: "Detect new java files"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
jobs:
|
||||
detectNewJavaFiles:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: trilom/[email protected]
|
||||
- uses: actions/checkout@v2
|
||||
- name: Detect new java files
|
||||
run: scripts/analysis/detectNewJavaFiles.sh
|
||||
@@ -1,26 +1,27 @@
|
||||
name: "QA"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
jobs:
|
||||
qa:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check if secrets are available
|
||||
run: echo "::set-output name=ok::${{ secrets.KS_PASS != '' }}"
|
||||
id: check-secrets
|
||||
- uses: actions/checkout@v3
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
- name: set up JDK 11
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
- name: Install NDK and cmake
|
||||
run: |
|
||||
source ndk.env
|
||||
/usr/local/lib/android/sdk/tools/bin/sdkmanager "ndk;${NDK_VERSION}" "cmake;${CMAKE_VERSION}"
|
||||
- name: Build QA
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
env:
|
||||
KS_PASS: ${{ secrets.KS_PASS }}
|
||||
KEY_PASS: ${{ secrets.KEY_PASS }}
|
||||
|
||||
@@ -17,14 +17,14 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
- name: AVD cache
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- uses: actions/setup-java@v2
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
name: Unit tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
- name: Delete old comments
|
||||
if: ${{ always() }}
|
||||
run: scripts/deleteOldComments.sh "test" "Unit" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run unit tests with coverage
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: jacocoTestGplayDebugUnitTest
|
||||
- name: Upload failing results
|
||||
if: ${{ failure() }}
|
||||
run:
|
||||
scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Upload coverage to codecov
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
fail_ci_if_error: true
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/tests/testGplayDebugUnitTest/
|
||||
@@ -1,6 +1,7 @@
|
||||
# built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
*.aab
|
||||
|
||||
# files for the dex VM
|
||||
*.dex
|
||||
@@ -49,4 +50,7 @@ fastlane/Fastfile
|
||||
**/fastlane/test_output
|
||||
/fastlane/vendor/
|
||||
/.bundle/
|
||||
/fastlane/.bundle/
|
||||
/fastlane/.bundle
|
||||
|
||||
# python
|
||||
**/__pycache__/
|
||||
@@ -1,3 +1,22 @@
|
||||
## 3.20.1 (May 6th, 2022)
|
||||
|
||||
- Several minor bugfixes
|
||||
|
||||
Minimum: NC 16 Server, Android 6.0 Marshmallow
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/67
|
||||
## 3.20.0 (May 3rd, 2022)
|
||||
|
||||
- Built-in PDF viewer
|
||||
- Built-in document scanner
|
||||
- Better choices for storage permissions
|
||||
- File locking support
|
||||
- Better UI for media gallery
|
||||
- Many bugfixes and improvements
|
||||
|
||||
Minimum: NC 16 Server, Android 6.0 Marshmallow
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/64
|
||||
## 3.19.1 (March 10, 2022)
|
||||
|
||||
- Minor fixes and improvements
|
||||
|
||||
@@ -8,20 +8,20 @@ GEM
|
||||
artifactory (3.0.15)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.2.0)
|
||||
aws-partitions (1.549.0)
|
||||
aws-sdk-core (3.125.5)
|
||||
aws-partitions (1.582.0)
|
||||
aws-sdk-core (3.130.2)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.525.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.53.0)
|
||||
aws-sdk-core (~> 3, >= 3.125.0)
|
||||
aws-sdk-kms (1.56.0)
|
||||
aws-sdk-core (~> 3, >= 3.127.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.111.2)
|
||||
aws-sdk-core (~> 3, >= 3.125.0)
|
||||
aws-sdk-s3 (1.113.2)
|
||||
aws-sdk-core (~> 3, >= 3.127.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.4)
|
||||
aws-sigv4 (1.4.0)
|
||||
aws-sigv4 (1.5.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
claide (1.1.0)
|
||||
@@ -36,8 +36,8 @@ GEM
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.7.6)
|
||||
emoji_regex (3.2.3)
|
||||
excon (0.90.0)
|
||||
faraday (1.9.3)
|
||||
excon (0.92.3)
|
||||
faraday (1.10.0)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
@@ -66,7 +66,7 @@ GEM
|
||||
faraday_middleware (1.2.0)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.2.6)
|
||||
fastlane (2.201.1)
|
||||
fastlane (2.205.2)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
@@ -105,9 +105,9 @@ GEM
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.3.0)
|
||||
xcpretty-travis-formatter (>= 0.0.3)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.18)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.19)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.15.0)
|
||||
google-apis-androidpublisher_v3 (0.19.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-core (0.4.2)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
@@ -122,15 +122,15 @@ GEM
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-playcustomapp_v1 (0.7.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-storage_v1 (0.11.0)
|
||||
google-apis-storage_v1 (0.13.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-cloud-core (1.6.0)
|
||||
google-cloud-env (~> 1.0)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (1.5.0)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
google-cloud-env (1.6.0)
|
||||
faraday (>= 0.17.3, < 3.0)
|
||||
google-cloud-errors (1.2.0)
|
||||
google-cloud-storage (1.36.0)
|
||||
google-cloud-storage (1.36.2)
|
||||
addressable (~> 2.8)
|
||||
digest-crc (~> 0.4)
|
||||
google-apis-iamcredentials_v1 (~> 0.1)
|
||||
@@ -138,8 +138,8 @@ GEM
|
||||
google-cloud-core (~> 1.6)
|
||||
googleauth (>= 0.16.2, < 2.a)
|
||||
mini_mime (~> 1.0)
|
||||
googleauth (1.1.0)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
googleauth (1.1.3)
|
||||
faraday (>= 0.17.3, < 3.a)
|
||||
jwt (>= 1.4, < 3.0)
|
||||
memoist (~> 0.16)
|
||||
multi_json (~> 1.11)
|
||||
@@ -149,7 +149,7 @@ GEM
|
||||
http-cookie (1.0.4)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.8.3)
|
||||
jmespath (1.5.0)
|
||||
jmespath (1.6.1)
|
||||
json (2.6.1)
|
||||
jwt (2.3.0)
|
||||
memoist (0.16.2)
|
||||
@@ -162,7 +162,7 @@ GEM
|
||||
optparse (0.1.1)
|
||||
os (1.1.4)
|
||||
plist (3.6.0)
|
||||
public_suffix (4.0.6)
|
||||
public_suffix (4.0.7)
|
||||
rake (13.0.6)
|
||||
representable (3.1.1)
|
||||
declarative (< 0.1.0)
|
||||
@@ -174,9 +174,9 @@ GEM
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.3.2)
|
||||
security (0.1.3)
|
||||
signet (0.16.0)
|
||||
signet (0.16.1)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
faraday (>= 0.17.5, < 3.0)
|
||||
jwt (>= 1.5, < 3.0)
|
||||
multi_json (~> 1.10)
|
||||
simctl (1.6.8)
|
||||
@@ -193,7 +193,7 @@ GEM
|
||||
uber (0.1.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.8)
|
||||
unf_ext (0.0.8.1)
|
||||
unicode-display_width (1.8.0)
|
||||
webrick (1.7.0)
|
||||
word_wrap (1.0.0)
|
||||
|
||||
@@ -89,22 +89,15 @@ The app is currently equipped to be built with three flavours:
|
||||
#### 1. Direct usage of library project
|
||||
|
||||
This is handy if one wants to make changes both to files app and library:
|
||||
- In the repository root: `ln -s [path to library clone] nextcloud-android-library`
|
||||
|
||||
- Add the following to `settings.gradle`:
|
||||
```groovy
|
||||
include ':nextcloud-android-library'
|
||||
```
|
||||
- In `app/build.gradle`, replace the following:
|
||||
```groovy
|
||||
implementation ("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: 'org.ogce', module: 'xpp3'
|
||||
includeBuild('[path to library clone]') {
|
||||
dependencySubstitution {
|
||||
substitute module('com.github.nextcloud:android-library') using project(':library')
|
||||
}
|
||||
}
|
||||
```
|
||||
with:
|
||||
``` groovy
|
||||
implementation project(':nextcloud-android-library')
|
||||
```
|
||||
|
||||
- Sync project with gradle files
|
||||
|
||||
Now every change in library can be directly used in files app.
|
||||
|
||||
@@ -3,16 +3,17 @@ import org.gradle.internal.jvm.Jvm
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
classpath 'com.android.tools.build:gradle:7.1.3'
|
||||
classpath 'com.hiya:jacoco-android:0.2'
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.6'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.20.0"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:5.13.0'
|
||||
classpath 'com.karumi:shot:5.14.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"
|
||||
classpath "org.jlleitschuh.gradle:ktlint-gradle:10.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +28,11 @@ apply plugin: 'com.hiya.jacoco-android'
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
apply plugin: 'io.gitlab.arturbosch.detekt'
|
||||
apply plugin: 'shot'
|
||||
apply plugin: "org.jlleitschuh.gradle.ktlint"
|
||||
|
||||
println "Gradle uses Java ${Jvm.current()}"
|
||||
|
||||
configurations {
|
||||
ktlint
|
||||
|
||||
all {
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
|
||||
|
||||
@@ -54,24 +54,24 @@ configurations.configureEach {
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://plugins.gradle.org/m2/'
|
||||
}
|
||||
}
|
||||
|
||||
// semantic versioning for version code
|
||||
def versionMajor = 3
|
||||
def versionMinor = 20
|
||||
def versionMinor = 21
|
||||
def versionPatch = 0
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
|
||||
def ndkEnv = new HashMap<String, String>()
|
||||
file("$project.rootDir/ndk.env").readLines().each() {
|
||||
def (key, value) = it.tokenize('=')
|
||||
ndkEnv.put(key, value)
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
compileSdkVersion 31
|
||||
// install this NDK version and Cmake to produce smaller APKs. Build will still work if not installed
|
||||
ndkVersion "${ndkEnv.get("NDK_VERSION")}"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 23
|
||||
@@ -129,8 +129,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20200129
|
||||
versionName "20200129"
|
||||
versionCode 20220322
|
||||
versionName "20220322"
|
||||
}
|
||||
|
||||
qa {
|
||||
@@ -185,7 +185,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebug', 'pmd', 'lint', 'ktlintCheck', 'detekt'
|
||||
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
@@ -219,7 +219,7 @@ dependencies {
|
||||
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5' // remove after entire switch to lib v2
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'com.google.android.material:material:1.6.0'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.webkit:webkit:1.4.0'
|
||||
@@ -241,20 +241,24 @@ dependencies {
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'
|
||||
implementation 'com.github.tobiaskaminsky:qrcodescanner:0.1.2.4' // 'com.github.blikoon:QRCodeScanner:0.1.2'
|
||||
implementation 'com.google.android:flexbox:2.0.1'
|
||||
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.3.0'
|
||||
implementation 'com.vanniktech:emoji-google:0.8.0'
|
||||
implementation 'com.vanniktech:emoji-google:0.9.0'
|
||||
|
||||
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido:$fidoVersion"
|
||||
implementation "com.github.cotechde.hwsecurity:hwsecurity-fido2:$fidoVersion"
|
||||
|
||||
implementation 'com.github.zynkware:Document-Scanning-Android-SDK:1.0.1'
|
||||
// document scanner not available on FDroid (generic) due to OpenCV binaries
|
||||
gplayImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
|
||||
huaweiImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
|
||||
qaImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
|
||||
versionDevImplementation "com.github.zynkware:Document-Scanning-Android-SDK:$documentScannerVersion"
|
||||
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
|
||||
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
|
||||
|
||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||
@@ -263,14 +267,15 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.44.0"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.5.2'
|
||||
|
||||
implementation "com.google.android.exoplayer:exoplayer:$exoplayerVersion"
|
||||
implementation "com.google.android.exoplayer:extension-okhttp:$exoplayerVersion"
|
||||
|
||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.8'
|
||||
|
||||
// Shimmer animation
|
||||
implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0'
|
||||
implementation 'io.github.elye:loaderviewlibrary:3.0.0'
|
||||
|
||||
// dependencies for markdown rendering
|
||||
implementation "io.noties.markwon:core:$markwonVersion"
|
||||
@@ -289,8 +294,8 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ciBuild) {
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
|
||||
if (project.hasProperty("leakCanary")) {
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
||||
}
|
||||
|
||||
// dependencies for local unit tests
|
||||
@@ -300,7 +305,7 @@ dependencies {
|
||||
testImplementation "org.powermock:powermock-core:$powermockVersion"
|
||||
testImplementation "org.powermock:powermock-module-junit4:$powermockVersion"
|
||||
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
|
||||
testImplementation 'org.json:json:20211205'
|
||||
testImplementation 'org.json:json:20220320'
|
||||
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
testImplementation 'androidx.arch.core:core-testing:2.1.0'
|
||||
testImplementation "io.mockk:mockk:$mockkVersion"
|
||||
@@ -313,12 +318,14 @@ dependencies {
|
||||
// Android JUnit Runner
|
||||
androidTestImplementation "androidx.test:runner:$androidxTestVersion"
|
||||
androidTestUtil "androidx.test:orchestrator:$androidxTestVersion"
|
||||
androidTestImplementation "androidx.test:core-ktx:$androidxTestVersion"
|
||||
|
||||
// Espresso core
|
||||
// Espresso
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
|
||||
|
||||
// Mocking support
|
||||
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
|
||||
@@ -339,12 +346,11 @@ dependencies {
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
androidTestImplementation('androidx.test.espresso:espresso-intents:3.4.0')
|
||||
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
|
||||
// upon each update first test: new registration, receive push
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:20.1.3"
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:23.0.4"
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
@@ -373,38 +379,6 @@ android.applicationVariants.all { variant ->
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("combinedTestReport", JacocoReport) {
|
||||
|
||||
jacocoClasspath = configurations['jacocoAnt']
|
||||
|
||||
reports {
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
csv.enabled false
|
||||
}
|
||||
|
||||
additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
classDirectories.setFrom files(subprojects.sourceSets.main.output)
|
||||
executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
|
||||
task ktlint(type: JavaExec, group: "verification") {
|
||||
description = "Check Kotlin code style."
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
classpath = configurations.ktlint
|
||||
args "--reporter=plain", "--reporter=plain,output=${buildDir}/ktlint.txt,${projectDir}/src/**/*.kt"
|
||||
}
|
||||
|
||||
task ktlintFormat(type: JavaExec, group: "formatting") {
|
||||
description = "Fix Kotlin code style deviations."
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
classpath = configurations.ktlint
|
||||
args "-F", "${projectDir}/src/**/*.kt"
|
||||
}
|
||||
|
||||
task installGitHooks(type: Copy, group: "development") {
|
||||
description = "Install git hooks"
|
||||
from("${project.rootDir}/scripts/hooks") {
|
||||
@@ -448,10 +422,13 @@ tasks.withType(SpotBugsTask){task ->
|
||||
excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
|
||||
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
|
||||
reports {
|
||||
xml.enabled = false
|
||||
xml {
|
||||
required = true
|
||||
}
|
||||
html {
|
||||
enabled = true
|
||||
destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
|
||||
required = true
|
||||
outputLocation = file("$project.buildDir/reports/spotbugs/spotbugs.html")
|
||||
stylesheet = 'fancy.xsl'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
build:
|
||||
maxIssues: 11
|
||||
maxIssues: 3
|
||||
weights:
|
||||
# complexity: 2
|
||||
# LongParameterList: 1
|
||||
@@ -69,7 +69,8 @@ complexity:
|
||||
excludes: ['**/androidTest/**']
|
||||
LongParameterList:
|
||||
active: true
|
||||
threshold: 6
|
||||
functionThreshold: 6
|
||||
constructorThreshold: 6
|
||||
ignoreDefaultParameters: false
|
||||
MethodOverloading:
|
||||
active: false
|
||||
@@ -174,72 +175,6 @@ exceptions:
|
||||
- Throwable
|
||||
- RuntimeException
|
||||
|
||||
formatting:
|
||||
active: true
|
||||
android: false
|
||||
ChainWrapping:
|
||||
active: true
|
||||
CommentSpacing:
|
||||
active: true
|
||||
Filename:
|
||||
active: true
|
||||
FinalNewline:
|
||||
active: true
|
||||
ImportOrdering:
|
||||
active: false
|
||||
Indentation:
|
||||
active: true
|
||||
indentSize: 4
|
||||
continuationIndentSize: 4
|
||||
MaximumLineLength:
|
||||
active: true
|
||||
maxLineLength: 120
|
||||
ModifierOrdering:
|
||||
active: true
|
||||
NoBlankLineBeforeRbrace:
|
||||
active: true
|
||||
NoConsecutiveBlankLines:
|
||||
active: true
|
||||
NoEmptyClassBody:
|
||||
active: true
|
||||
NoLineBreakAfterElse:
|
||||
active: true
|
||||
NoLineBreakBeforeAssignment:
|
||||
active: true
|
||||
NoMultipleSpaces:
|
||||
active: true
|
||||
NoSemicolons:
|
||||
active: true
|
||||
NoTrailingSpaces:
|
||||
active: true
|
||||
NoUnitReturn:
|
||||
active: true
|
||||
NoUnusedImports:
|
||||
active: true
|
||||
NoWildcardImports:
|
||||
active: true
|
||||
PackageName:
|
||||
active: true
|
||||
ParameterListWrapping:
|
||||
active: true
|
||||
indentSize: 4
|
||||
SpacingAroundColon:
|
||||
active: true
|
||||
SpacingAroundComma:
|
||||
active: true
|
||||
SpacingAroundCurly:
|
||||
active: true
|
||||
SpacingAroundKeyword:
|
||||
active: true
|
||||
SpacingAroundOperators:
|
||||
active: true
|
||||
SpacingAroundParens:
|
||||
active: true
|
||||
SpacingAroundRangeOperator:
|
||||
active: true
|
||||
StringTemplate:
|
||||
active: true
|
||||
|
||||
naming:
|
||||
active: true
|
||||
ClassNaming:
|
||||
@@ -267,7 +202,9 @@ naming:
|
||||
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
|
||||
excludeClassPattern: '$^'
|
||||
ignoreOverridden: true
|
||||
excludes: "**/*Test.kt"
|
||||
excludes:
|
||||
- "**/*Test.kt"
|
||||
- "**/*IT.kt"
|
||||
FunctionParameterNaming:
|
||||
active: true
|
||||
parameterPattern: '[a-z][A-Za-z0-9]*'
|
||||
@@ -333,7 +270,7 @@ potential-bugs:
|
||||
active: false
|
||||
LateinitUsage:
|
||||
active: false
|
||||
excludeAnnotatedProperties: ""
|
||||
ignoreAnnotated: []
|
||||
ignoreOnClassesPattern: ""
|
||||
UnconditionalJumpStatementInLoop:
|
||||
active: false
|
||||
@@ -389,7 +326,9 @@ style:
|
||||
ignoreAnnotation: false
|
||||
ignoreNamedArgument: true
|
||||
ignoreEnums: false
|
||||
excludes: "**/*Test.kt"
|
||||
excludes:
|
||||
- "**/*Test.kt"
|
||||
- "**/*IT.kt"
|
||||
MandatoryBracesIfStatements:
|
||||
active: false
|
||||
MaxLineLength:
|
||||
@@ -439,10 +378,11 @@ style:
|
||||
active: false
|
||||
UnderscoresInNumericLiterals:
|
||||
active: false
|
||||
acceptableDecimalLength: 5
|
||||
acceptableLength: 5
|
||||
UnnecessaryAbstractClass:
|
||||
active: false
|
||||
excludeAnnotatedClasses: "dagger.Module"
|
||||
ignoreAnnotated:
|
||||
- "dagger.Module"
|
||||
UnnecessaryApply:
|
||||
active: false
|
||||
UnnecessaryInheritance:
|
||||
@@ -462,7 +402,7 @@ style:
|
||||
allowedNames: "(_|ignored|expected|serialVersionUID)"
|
||||
UseDataClass:
|
||||
active: false
|
||||
excludeAnnotatedClasses: ""
|
||||
ignoreAnnotated: []
|
||||
UtilityClassWithPublicConstructor:
|
||||
active: false
|
||||
VarCouldBeVal:
|
||||
|
||||
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 28 KiB |
@@ -185,12 +185,15 @@ class ActivitiesActivityIT : AbstractIT() {
|
||||
fun error() {
|
||||
val sut: ActivitiesActivity = activityRule.launchActivity(null)
|
||||
|
||||
shortSleep()
|
||||
|
||||
sut.runOnUiThread {
|
||||
sut.showEmptyContent("Error", "Error! Please try again later!")
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
|
||||
@@ -53,19 +53,21 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
val sut = activityRule.launchActivity(null)
|
||||
sut.listOfFilesFragment!!.setFabEnabled(false)
|
||||
|
||||
shortSleep()
|
||||
sut.runOnUiThread {
|
||||
sut.listOfFilesFragment!!.setFabEnabled(false)
|
||||
sut.resetScrolling()
|
||||
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
|
||||
sut.listOfFilesFragment!!.isLoading = false
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @ScreenshotTest
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showMediaThenAllFiles() {
|
||||
val fileDisplayActivity = activityRule.launchActivity(null)
|
||||
val sut = fileDisplayActivity.listOfFilesFragment
|
||||
@@ -103,13 +105,16 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
fun drawer() {
|
||||
val sut = activityRule.launchActivity(null)
|
||||
Espresso.onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
sut.listOfFilesFragment!!.setFabEnabled(false)
|
||||
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
|
||||
sut.listOfFilesFragment!!.isLoading = false
|
||||
|
||||
shortSleep()
|
||||
sut.runOnUiThread {
|
||||
sut.hideInfoBox()
|
||||
sut.resetScrolling()
|
||||
sut.listOfFilesFragment!!.setFabEnabled(false)
|
||||
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
|
||||
sut.listOfFilesFragment!!.isLoading = false
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.Manifest
|
||||
import android.os.Build
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.utils.PermissionUtil
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
import org.junit.runners.model.Statement
|
||||
@@ -35,8 +35,7 @@ class GrantStoragePermissionRule private constructor() {
|
||||
@JvmStatic
|
||||
fun grant(): TestRule = when {
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.R -> GrantPermissionRule.grant(
|
||||
PermissionUtil
|
||||
.getExternalStoragePermission()
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
else -> GrantManageExternalStoragePermissionRule()
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.mockito.kotlin.eq
|
||||
import org.mockito.kotlin.verify
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ContentResolverHelperTest {
|
||||
class ContentResolverHelperIT {
|
||||
|
||||
companion object {
|
||||
private val URI = Uri.parse("http://foo.bar")
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.files
|
||||
|
||||
import android.view.Menu
|
||||
import androidx.appcompat.view.menu.MenuBuilder
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.nextcloud.client.TestActivity
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.files.services.FileDownloader
|
||||
import com.owncloud.android.files.services.FileUploader
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType
|
||||
import com.owncloud.android.lib.resources.status.CapabilityBooleanType
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.services.OperationsService
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class FileMenuFilterIT : AbstractIT() {
|
||||
|
||||
@MockK
|
||||
private lateinit var mockComponentsGetter: ComponentsGetter
|
||||
|
||||
@MockK
|
||||
private lateinit var mockStorageManager: FileDataStorageManager
|
||||
|
||||
@MockK
|
||||
private lateinit var mockFileUploaderBinder: FileUploader.FileUploaderBinder
|
||||
|
||||
@MockK
|
||||
private lateinit var mockFileDownloaderBinder: FileDownloader.FileDownloaderBinder
|
||||
|
||||
@MockK
|
||||
private lateinit var mockOperationsServiceBinder: OperationsService.OperationsServiceBinder
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockKAnnotations.init(this)
|
||||
every { mockFileUploaderBinder.isUploading(any(), any()) } returns false
|
||||
every { mockComponentsGetter.fileUploaderBinder } returns mockFileUploaderBinder
|
||||
every { mockFileDownloaderBinder.isDownloading(any(), any()) } returns false
|
||||
every { mockComponentsGetter.fileDownloaderBinder } returns mockFileDownloaderBinder
|
||||
every { mockOperationsServiceBinder.isSynchronizing(any(), any()) } returns false
|
||||
every { mockComponentsGetter.operationsServiceBinder } returns mockOperationsServiceBinder
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filter_noLockingCapability_lockItemsInvisible() {
|
||||
val capability = OCCapability().apply {
|
||||
endToEndEncryption = CapabilityBooleanType.UNKNOWN
|
||||
}
|
||||
|
||||
val file = OCFile("/foo.md")
|
||||
|
||||
testLockingVisibilities(
|
||||
capability,
|
||||
file,
|
||||
ExpectedLockVisibilities(lockFile = false, unlockFile = false, lockedBy = false, lockedUntil = false)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filter_lockingCapability_fileUnlocked_lockVisible() {
|
||||
val capability = OCCapability().apply {
|
||||
endToEndEncryption = CapabilityBooleanType.UNKNOWN
|
||||
filesLockingVersion = "1.0"
|
||||
}
|
||||
|
||||
val file = OCFile("/foo.md")
|
||||
|
||||
testLockingVisibilities(
|
||||
capability,
|
||||
file,
|
||||
ExpectedLockVisibilities(lockFile = true, unlockFile = false, lockedBy = false, lockedUntil = false)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filter_lockingCapability_fileLocked_lockedByAndProps() {
|
||||
val capability = OCCapability().apply {
|
||||
endToEndEncryption = CapabilityBooleanType.UNKNOWN
|
||||
filesLockingVersion = "1.0"
|
||||
}
|
||||
|
||||
val file = OCFile("/foo.md").apply {
|
||||
isLocked = true
|
||||
lockType = FileLockType.MANUAL
|
||||
lockOwnerId = user.accountName.split("@")[0]
|
||||
lockOwnerDisplayName = "TEST"
|
||||
lockTimestamp = 1000 // irrelevant
|
||||
lockTimeout = 1000 // irrelevant
|
||||
}
|
||||
|
||||
testLockingVisibilities(
|
||||
capability,
|
||||
file,
|
||||
ExpectedLockVisibilities(lockFile = false, unlockFile = true, lockedBy = true, lockedUntil = true)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun filter_lockingCapability_fileLockedByOthers_lockedByAndProps() {
|
||||
val capability = OCCapability().apply {
|
||||
endToEndEncryption = CapabilityBooleanType.UNKNOWN
|
||||
filesLockingVersion = "1.0"
|
||||
}
|
||||
|
||||
val file = OCFile("/foo.md").apply {
|
||||
isLocked = true
|
||||
lockType = FileLockType.MANUAL
|
||||
lockOwnerId = "A_DIFFERENT_USER"
|
||||
lockOwnerDisplayName = "A_DIFFERENT_USER"
|
||||
lockTimestamp = 1000 // irrelevant
|
||||
lockTimeout = 1000 // irrelevant
|
||||
}
|
||||
testLockingVisibilities(
|
||||
capability,
|
||||
file,
|
||||
ExpectedLockVisibilities(lockFile = false, unlockFile = false, lockedBy = true, lockedUntil = true)
|
||||
)
|
||||
}
|
||||
|
||||
private data class ExpectedLockVisibilities(
|
||||
val lockFile: Boolean,
|
||||
val unlockFile: Boolean,
|
||||
val lockedBy: Boolean,
|
||||
val lockedUntil: Boolean
|
||||
)
|
||||
|
||||
private fun configureCapability(capability: OCCapability) {
|
||||
every { mockStorageManager.getCapability(any<User>()) } returns capability
|
||||
every { mockStorageManager.getCapability(any<String>()) } returns capability
|
||||
every { mockComponentsGetter.storageManager } returns mockStorageManager
|
||||
}
|
||||
|
||||
private fun getMenu(activity: TestActivity): Menu {
|
||||
val inflater = activity.menuInflater
|
||||
val menu = MenuBuilder(activity)
|
||||
inflater.inflate(R.menu.item_file, menu)
|
||||
return menu
|
||||
}
|
||||
|
||||
private fun testLockingVisibilities(
|
||||
capability: OCCapability,
|
||||
file: OCFile,
|
||||
expectedLockVisibilities: ExpectedLockVisibilities
|
||||
) {
|
||||
configureCapability(capability)
|
||||
|
||||
launchActivity<TestActivity>().use {
|
||||
it.onActivity { activity ->
|
||||
val menu = getMenu(activity)
|
||||
|
||||
val sut = FileMenuFilter(file, mockComponentsGetter, activity, true, user)
|
||||
|
||||
sut.filter(menu, false)
|
||||
|
||||
Assert.assertEquals(
|
||||
expectedLockVisibilities.lockFile,
|
||||
menu.findItem(R.id.action_lock_file).isVisible
|
||||
)
|
||||
Assert.assertEquals(
|
||||
expectedLockVisibilities.unlockFile,
|
||||
menu.findItem(R.id.action_unlock_file).isVisible
|
||||
)
|
||||
Assert.assertEquals(
|
||||
expectedLockVisibilities.lockedBy,
|
||||
menu.findItem(R.id.action_locked_by).isVisible
|
||||
)
|
||||
Assert.assertEquals(
|
||||
expectedLockVisibilities.lockedUntil,
|
||||
menu.findItem(R.id.action_locked_until).isVisible
|
||||
)
|
||||
|
||||
// locked by and until should always be disabled, they're not real actions
|
||||
Assert.assertFalse(menu.findItem(R.id.action_locked_by).isEnabled)
|
||||
Assert.assertFalse(menu.findItem(R.id.action_locked_until).isEnabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class DocumentsStorageProviderIT : AbstractOnServerIT() {
|
||||
private val authority = context.getString(R.string.document_provider_authority)
|
||||
|
||||
private val rootFileId = storageManager.getFileByEncryptedRemotePath(ROOT_PATH).fileId
|
||||
private val documentId = "${user.hashCode()}${DOCUMENTID_SEPARATOR}$rootFileId"
|
||||
private val documentId = "${DocumentsStorageProvider.rootIdForUser(user)}${DOCUMENTID_SEPARATOR}$rootFileId"
|
||||
private val uri = DocumentsContract.buildTreeDocumentUri(authority, documentId)
|
||||
private val rootDir get() = DocumentFile.fromTreeUri(context, uri)!!
|
||||
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.nextcloud.client.GrantStoragePermissionRule;
|
||||
import com.nextcloud.client.RetryTestRule;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestRule;
|
||||
|
||||
import androidx.test.core.app.ActivityScenario;
|
||||
import androidx.test.espresso.web.webdriver.DriverAtoms;
|
||||
import androidx.test.espresso.web.webdriver.Locator;
|
||||
import androidx.test.filters.LargeTest;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.action.ViewActions.typeText;
|
||||
import static androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.web.sugar.Web.onWebView;
|
||||
import static androidx.test.espresso.web.webdriver.DriverAtoms.findElement;
|
||||
import static androidx.test.espresso.web.webdriver.DriverAtoms.webClick;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
@LargeTest
|
||||
public class LoginIT extends AbstractIT {
|
||||
@Rule
|
||||
public final TestRule permissionRule = GrantStoragePermissionRule.grant();
|
||||
@Rule
|
||||
public RetryTestRule retryTestRule = new RetryTestRule();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
tearDown();
|
||||
|
||||
ActivityScenario.launch(AuthenticatorActivity.class);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
|
||||
if (accountManager.getAccounts().length > 0) {
|
||||
accountManager.removeAllAccounts();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void login() throws InterruptedException {
|
||||
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
|
||||
|
||||
String baseUrl = arguments.getString("TEST_SERVER_URL");
|
||||
String loginName = arguments.getString("TEST_SERVER_USERNAME");
|
||||
String password = arguments.getString("TEST_SERVER_PASSWORD");
|
||||
|
||||
onView(withId(R.id.login)).perform(click());
|
||||
onView(withId(R.id.host_url_input)).perform(typeText(baseUrl));
|
||||
onView(withId(R.id.host_url_input)).perform(typeTextIntoFocusedView("\n"));
|
||||
|
||||
Thread.sleep(3000);
|
||||
|
||||
onWebView().forceJavascriptEnabled();
|
||||
|
||||
// click on login
|
||||
onWebView()
|
||||
.withElement(findElement(Locator.XPATH, "//p[@id='redirect-link']/a"))
|
||||
.perform(webClick());
|
||||
|
||||
// username
|
||||
onWebView()
|
||||
.withElement(findElement(Locator.XPATH, "//input[@id='user']"))
|
||||
.perform(DriverAtoms.webKeys(loginName));
|
||||
|
||||
// password
|
||||
onWebView()
|
||||
.withElement(findElement(Locator.XPATH, "//input[@id='password']"))
|
||||
.perform(DriverAtoms.webKeys(password));
|
||||
|
||||
// click login
|
||||
onWebView()
|
||||
.withElement(findElement(Locator.XPATH, "//input[@id='submit-form']"))
|
||||
.perform(webClick());
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
// grant access
|
||||
onWebView()
|
||||
.withElement(findElement(Locator.XPATH, "//input[@type='submit']"))
|
||||
.perform(webClick());
|
||||
|
||||
Thread.sleep(5 * 1000);
|
||||
|
||||
// check for account
|
||||
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
|
||||
assertEquals(1, accountManager.getAccounts().length);
|
||||
|
||||
Account account = accountManager.getAccounts()[0];
|
||||
|
||||
// account.name is loginName@baseUrl (without protocol)
|
||||
assertEquals(loginName, account.name.split("@")[0]);
|
||||
assertEquals(baseUrl.split("//")[1], account.name.split("@")[1]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.ui
|
||||
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.web.sugar.Web
|
||||
import androidx.test.espresso.web.webdriver.DriverAtoms
|
||||
import androidx.test.espresso.web.webdriver.Locator
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.nextcloud.client.GrantStoragePermissionRule
|
||||
import com.nextcloud.client.RetryTestRule
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity
|
||||
import org.junit.AfterClass
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@LargeTest
|
||||
class LoginIT : AbstractIT() {
|
||||
@get:Rule
|
||||
val permissionRule = GrantStoragePermissionRule.grant()
|
||||
|
||||
@get:Rule
|
||||
var retryTestRule = RetryTestRule()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
tearDown()
|
||||
ActivityScenario.launch(AuthenticatorActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(InterruptedException::class)
|
||||
@Suppress("MagicNumber")
|
||||
fun login() {
|
||||
val arguments = InstrumentationRegistry.getArguments()
|
||||
val baseUrl = arguments.getString("TEST_SERVER_URL")!!
|
||||
val loginName = arguments.getString("TEST_SERVER_USERNAME")!!
|
||||
val password = arguments.getString("TEST_SERVER_PASSWORD")!!
|
||||
Espresso.onView(ViewMatchers.withId(R.id.login)).perform(ViewActions.click())
|
||||
Espresso.onView(ViewMatchers.withId(R.id.host_url_input)).perform(ViewActions.typeText(baseUrl))
|
||||
Espresso.onView(ViewMatchers.withId(R.id.host_url_input)).perform(ViewActions.typeTextIntoFocusedView("\n"))
|
||||
Thread.sleep(3000)
|
||||
Web.onWebView().forceJavascriptEnabled()
|
||||
|
||||
// click on login
|
||||
Web.onWebView()
|
||||
.withElement(DriverAtoms.findElement(Locator.XPATH, "//p[@id='redirect-link']/a"))
|
||||
.perform(DriverAtoms.webClick())
|
||||
|
||||
// username
|
||||
Web.onWebView()
|
||||
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@id='user']"))
|
||||
.perform(DriverAtoms.webKeys(loginName))
|
||||
|
||||
// password
|
||||
Web.onWebView()
|
||||
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@id='password']"))
|
||||
.perform(DriverAtoms.webKeys(password))
|
||||
|
||||
// click login
|
||||
Web.onWebView()
|
||||
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@type='submit']"))
|
||||
.perform(DriverAtoms.webClick())
|
||||
Thread.sleep(2000)
|
||||
|
||||
// grant access
|
||||
Web.onWebView()
|
||||
.withElement(DriverAtoms.findElement(Locator.XPATH, "//input[@type='submit']"))
|
||||
.perform(DriverAtoms.webClick())
|
||||
Thread.sleep((5 * 1000).toLong())
|
||||
|
||||
// check for account
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val accountManager: UserAccountManager = UserAccountManagerImpl.fromContext(targetContext)
|
||||
Assert.assertEquals(1, accountManager.accounts.size.toLong())
|
||||
val account = accountManager.accounts[0]
|
||||
|
||||
// account.name is loginName@baseUrl (without protocol)
|
||||
Assert.assertEquals(loginName, account.name.split("@".toRegex()).toTypedArray()[0])
|
||||
Assert.assertEquals(
|
||||
baseUrl.split("//".toRegex()).toTypedArray()[1],
|
||||
account.name.split("@".toRegex()).toTypedArray()[1]
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@AfterClass
|
||||
fun tearDown() {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val accountManager: UserAccountManager = UserAccountManagerImpl.fromContext(targetContext)
|
||||
if (accountManager.accounts.isNotEmpty()) {
|
||||
accountManager.removeAllAccounts()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,8 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
sut.runOnUiThread { sut.binding.txt0.clearFocus() }
|
||||
Espresso.closeSoftKeyboard()
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
@@ -55,6 +57,8 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
sut.runOnUiThread { sut.binding.txt0.clearFocus() }
|
||||
Espresso.closeSoftKeyboard()
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
@@ -68,6 +72,8 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
sut.runOnUiThread { sut.binding.txt0.clearFocus() }
|
||||
Espresso.closeSoftKeyboard()
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
@@ -21,20 +21,84 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.nextcloud.client.GrantStoragePermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class UploadFilesActivityIT : AbstractIT() {
|
||||
@get:Rule
|
||||
var activityRule = IntentsTestRule(UploadFilesActivity::class.java, true, false)
|
||||
|
||||
@get:Rule
|
||||
var permissionRule = GrantStoragePermissionRule.grant()
|
||||
|
||||
private val directories = listOf("A", "B", "C", "D")
|
||||
.map { File("${FileStorageUtils.getTemporalPath(account.name)}${File.separator}$it") }
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
directories.forEach { it.mkdirs() }
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
directories.forEach { it.deleteRecursively() }
|
||||
}
|
||||
|
||||
@Test
|
||||
// @ScreenshotTest // TODO re-enable and make sure that folder content on emulator is the same on all devices
|
||||
@ScreenshotTest
|
||||
fun noneSelected() {
|
||||
val sut: UploadFilesActivity = activityRule.launchActivity(null)
|
||||
|
||||
sut.runOnUiThread {
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
waitForIdleSync()
|
||||
shortSleep()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun localFolderPickerMode() {
|
||||
val sut: UploadFilesActivity = activityRule.launchActivity(
|
||||
Intent().apply {
|
||||
putExtra(
|
||||
UploadFilesActivity.KEY_LOCAL_FOLDER_PICKER_MODE,
|
||||
true
|
||||
)
|
||||
putExtra(
|
||||
UploadFilesActivity.REQUEST_CODE_KEY,
|
||||
FileDisplayActivity.REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
sut.runOnUiThread {
|
||||
sut.fileListFragment.setFiles(
|
||||
directories
|
||||
)
|
||||
}
|
||||
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,11 @@ import com.owncloud.android.lib.resources.users.Status;
|
||||
import com.owncloud.android.lib.resources.users.StatusType;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
@@ -390,18 +391,17 @@ public class DialogFragmentIT extends AbstractIT {
|
||||
capability.setRichDocuments(CapabilityBooleanType.TRUE);
|
||||
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.TRUE);
|
||||
capability.setRichDocumentsTemplatesAvailable(CapabilityBooleanType.TRUE);
|
||||
capability.setAccountName(user.getAccountName());
|
||||
|
||||
OCFileListBottomSheetDialog sut = new OCFileListBottomSheetDialog(fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile);
|
||||
CapabilityUtils.updateCapability(capability);
|
||||
|
||||
fda.runOnUiThread(sut::show);
|
||||
OCFileListBottomSheetDialogFragment sut = new OCFileListBottomSheetDialogFragment(fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile);
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
screenshot(sut.getWindow().getDecorView());
|
||||
showDialog(fda, sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -436,7 +436,9 @@ public class DialogFragmentIT extends AbstractIT {
|
||||
|
||||
ProfileBottomSheetDialog sut = new ProfileBottomSheetDialog(fda,
|
||||
user,
|
||||
hoverCard);
|
||||
hoverCard,
|
||||
fda.themeColorUtils,
|
||||
fda.themeDrawableUtils);
|
||||
|
||||
fda.runOnUiThread(sut::show);
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import android.view.Window
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import androidx.test.internal.runner.junit4.statement.UiThreadStatement.runOnUiThread
|
||||
import com.nextcloud.client.TestActivity
|
||||
@@ -29,7 +28,6 @@ import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.Objects
|
||||
|
||||
class SetupEncryptionDialogFragmentIT : AbstractIT() {
|
||||
@get:Rule
|
||||
@@ -69,7 +67,7 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() {
|
||||
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(Objects.requireNonNull<Window>(sut.requireDialog().window).decorView)
|
||||
screenshot(sut.requireDialog().window!!.decorView)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,8 +85,9 @@ class SetupEncryptionDialogFragmentIT : AbstractIT() {
|
||||
sut.errorSavingKeys()
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(Objects.requireNonNull<Window>(sut.requireDialog().window).decorView)
|
||||
screenshot(sut.requireDialog().window!!.decorView)
|
||||
}
|
||||
}
|
||||
@@ -123,8 +123,8 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
"files",
|
||||
"1",
|
||||
"/text.txt",
|
||||
null,
|
||||
null
|
||||
emptyList(),
|
||||
RichElement()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ class TrashbinActivityIT : AbstractIT() {
|
||||
sut.runOnUiThread { sut.loadFolder() }
|
||||
|
||||
shortSleep()
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<!--
|
||||
~ Nextcloud Android client application
|
||||
~
|
||||
~ @author Álvaro Brey Vilas
|
||||
~ Copyright (C) 2022 Álvaro Brey Vilas
|
||||
~ Copyright (C) 2022 Nextcloud GmbH
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".ui.activity.AppScanActivity"
|
||||
tools:node="remove" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2022 Tobias Kaminsky
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.app.Activity
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
|
||||
class AppScanActivity {
|
||||
// stub
|
||||
companion object {
|
||||
private val TAG = AppScanActivity::class.simpleName
|
||||
|
||||
@JvmStatic
|
||||
val enabled: Boolean = false
|
||||
|
||||
@JvmStatic
|
||||
fun scanFromCamera(activity: Activity, requestcode: Int) {
|
||||
// stub
|
||||
Log_OC.w(TAG, "scanFromCamera called in stub implementation")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Bundle
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.PermissionUtil
|
||||
import com.zynksoftware.documentscanner.ScanActivity
|
||||
import com.zynksoftware.documentscanner.model.DocumentScannerErrorModel
|
||||
import com.zynksoftware.documentscanner.model.ScannerResults
|
||||
import com.zynksoftware.documentscanner.ui.DocumentScanner
|
||||
|
||||
@Suppress("unused")
|
||||
class AppScanActivity : ScanActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
addFragmentContentLayout()
|
||||
}
|
||||
|
||||
override fun onError(error: DocumentScannerErrorModel) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.error_starting_scan_doc)
|
||||
}
|
||||
|
||||
override fun onSuccess(scannerResults: ScannerResults) {
|
||||
val intent = Intent()
|
||||
|
||||
intent.putExtra(
|
||||
"file",
|
||||
scannerResults.transformedImageFile?.absolutePath ?: scannerResults.croppedImageFile?.absolutePath
|
||||
)
|
||||
|
||||
setResult(Activity.RESULT_OK, intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onClose() {
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val enabled: Boolean = true
|
||||
|
||||
@JvmStatic
|
||||
fun scanFromCamera(activity: Activity, requestCode: Int) {
|
||||
val configuration = DocumentScanner.Configuration()
|
||||
configuration.imageType = Bitmap.CompressFormat.PNG
|
||||
DocumentScanner.init(activity, configuration)
|
||||
val scanIntent = Intent(activity, AppScanActivity::class.java)
|
||||
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
||||
activity.startActivityForResult(scanIntent, requestCode)
|
||||
} else {
|
||||
PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_SCAN_DOCUMENT)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,38 +15,32 @@
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <http:></http:>//www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.utils
|
||||
|
||||
package com.owncloud.android.utils;
|
||||
import android.app.Activity
|
||||
import android.util.Log
|
||||
import com.google.android.gms.common.ConnectionResult
|
||||
import com.google.android.gms.common.GoogleApiAvailability
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
object GooglePlayUtils {
|
||||
private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
|
||||
private const val TAG = "GooglePlayUtils"
|
||||
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
|
||||
public final class GooglePlayUtils {
|
||||
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
|
||||
private static final String TAG = "GooglePlayUtils";
|
||||
|
||||
private GooglePlayUtils() {
|
||||
}
|
||||
|
||||
public static boolean checkPlayServices(Activity activity) {
|
||||
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
|
||||
int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
|
||||
@JvmStatic
|
||||
fun checkPlayServices(activity: Activity): Boolean {
|
||||
val apiAvailability = GoogleApiAvailability.getInstance()
|
||||
val resultCode = apiAvailability.isGooglePlayServicesAvailable(activity)
|
||||
if (resultCode != ConnectionResult.SUCCESS) {
|
||||
if (apiAvailability.isUserResolvableError(resultCode)) {
|
||||
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)
|
||||
.show();
|
||||
apiAvailability.getErrorDialog(activity, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST)?.show()
|
||||
} else {
|
||||
Log.i(TAG, "This device is not supported.");
|
||||
activity.finish();
|
||||
Log.i(TAG, "This device is not supported.")
|
||||
activity.finish()
|
||||
}
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2021 Nextcloud
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* Activity providing information about ways to participate in the app's development.
|
||||
*/
|
||||
class HuaweiCommunityActivity : CommunityActivity() {
|
||||
override fun setupContent() {
|
||||
super.setupContent()
|
||||
binding.communityReleaseCandidatePlaystore.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,38 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2022 Tobias Kaminsky
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.Manifest
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Bundle
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.PermissionUtil
|
||||
import com.zynksoftware.documentscanner.ScanActivity
|
||||
import com.zynksoftware.documentscanner.model.DocumentScannerErrorModel
|
||||
import com.zynksoftware.documentscanner.model.ScannerResults
|
||||
import com.zynksoftware.documentscanner.ui.DocumentScanner
|
||||
|
||||
class AppScanActivity : ScanActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -56,4 +59,22 @@ class AppScanActivity : ScanActivity() {
|
||||
override fun onClose() {
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
val enabled: Boolean = true
|
||||
|
||||
@JvmStatic
|
||||
fun scanFromCamera(activity: Activity, requestCode: Int) {
|
||||
val configuration = DocumentScanner.Configuration()
|
||||
configuration.imageType = Bitmap.CompressFormat.PNG
|
||||
DocumentScanner.init(activity, configuration)
|
||||
val scanIntent = Intent(activity, AppScanActivity::class.java)
|
||||
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
||||
activity.startActivityForResult(scanIntent, requestCode)
|
||||
} else {
|
||||
PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_SCAN_DOCUMENT)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* Activity providing information about ways to participate in the app's development.
|
||||
*/
|
||||
class HuaweiCommunityActivity : CommunityActivity() {
|
||||
override fun setupContent() {
|
||||
super.setupContent()
|
||||
binding.communityReleaseCandidatePlaystore.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,12 @@
|
||||
<uses-permission android:name="android.permission.READ_CALENDAR" />
|
||||
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
|
||||
|
||||
<!-- Used for document scanning, but lib declares it as required, which it's not -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera2"
|
||||
android:required="false"
|
||||
tools:node="replace" />
|
||||
|
||||
<!-- WRITE_EXTERNAL_STORAGE may be enabled or disabled by the user after installation in
|
||||
API >= 23; the app needs to handle this -->
|
||||
<uses-permission
|
||||
@@ -35,6 +41,8 @@
|
||||
<uses-permission
|
||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.android.files
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType
|
||||
|
||||
object FileLockingHelper {
|
||||
/**
|
||||
* Checks whether the given `userId` can unlock the [OCFile].
|
||||
*/
|
||||
@JvmStatic
|
||||
fun canUserUnlockFile(userId: String, file: OCFile): Boolean {
|
||||
if (!file.isLocked || file.lockOwnerId == null || file.lockType != FileLockType.MANUAL) {
|
||||
return false
|
||||
}
|
||||
return file.lockOwnerId == userId
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.android.files
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Typeface
|
||||
import android.os.Build
|
||||
import android.text.style.StyleSpan
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.nextcloud.utils.TimeConstants
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
|
||||
/**
|
||||
* Customizes a Menu to show locking information
|
||||
*/
|
||||
class FileLockingMenuCustomization(val context: Context) {
|
||||
fun customizeMenu(menu: Menu, file: OCFile) {
|
||||
if (file.isLocked) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
menu.findItem(R.id.action_locked_by).title = getLockedByText(file)
|
||||
showLockedUntil(menu, file)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLockedByText(file: OCFile): CharSequence {
|
||||
val username = file.lockOwnerDisplayName ?: file.lockOwnerId
|
||||
val resource = when (file.lockType) {
|
||||
FileLockType.COLLABORATIVE -> R.string.locked_by_app
|
||||
else -> R.string.locked_by
|
||||
}
|
||||
return DisplayUtils.createTextWithSpan(
|
||||
context.getString(resource, username),
|
||||
username,
|
||||
StyleSpan(Typeface.BOLD)
|
||||
)
|
||||
}
|
||||
|
||||
private fun showLockedUntil(menu: Menu, file: OCFile) {
|
||||
val lockedUntil: MenuItem = menu.findItem(R.id.action_locked_until)
|
||||
if (file.lockTimestamp == 0L || file.lockTimeout == 0L) {
|
||||
lockedUntil.isVisible = false
|
||||
} else {
|
||||
lockedUntil.title =
|
||||
context.getString(R.string.lock_expiration_info, getExpirationRelativeText(file))
|
||||
lockedUntil.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun getExpirationRelativeText(file: OCFile): CharSequence? {
|
||||
val expirationTimestamp = (file.lockTimestamp + file.lockTimeout) * TimeConstants.MILLIS_PER_SECOND
|
||||
return DisplayUtils.getRelativeTimestamp(context, expirationTimestamp, true)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.android.files
|
||||
|
||||
import android.content.Context
|
||||
import android.view.ContextThemeWrapper
|
||||
import android.view.View
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import com.owncloud.android.R
|
||||
|
||||
/**
|
||||
* This is a [PopupMenu] with grayed out disabled elements
|
||||
*/
|
||||
class ThemedPopupMenu(
|
||||
context: Context,
|
||||
anchor: View
|
||||
) : PopupMenu(wrapContext(context), anchor) {
|
||||
|
||||
companion object {
|
||||
private fun wrapContext(context: Context): Context =
|
||||
ContextThemeWrapper(context, R.style.Nextcloud_Widget_PopupMenu)
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ import com.nextcloud.client.network.NetworkModule;
|
||||
import com.nextcloud.client.onboarding.OnboardingModule;
|
||||
import com.nextcloud.client.preferences.PreferencesModule;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.media.MediaControlView;
|
||||
import com.owncloud.android.ui.ThemeableSwitchPreference;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@@ -47,13 +49,18 @@ import dagger.android.support.AndroidSupportInjectionModule;
|
||||
OnboardingModule.class,
|
||||
ViewModelModule.class,
|
||||
JobsModule.class,
|
||||
IntegrationsModule.class
|
||||
IntegrationsModule.class,
|
||||
ThemeModule.class
|
||||
})
|
||||
@Singleton
|
||||
public interface AppComponent {
|
||||
|
||||
void inject(MainApp app);
|
||||
|
||||
void inject(MediaControlView mediaControlView);
|
||||
|
||||
void inject(ThemeableSwitchPreference switchPreference);
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
@BindsInstance
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.owncloud.android.ui.activities.data.activities.RemoteActivitiesReposi
|
||||
import com.owncloud.android.ui.activities.data.files.FilesRepository;
|
||||
import com.owncloud.android.ui.activities.data.files.FilesServiceApiImpl;
|
||||
import com.owncloud.android.ui.activities.data.files.RemoteFilesRepository;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
@@ -81,7 +82,7 @@ class AppModule {
|
||||
|
||||
@Provides
|
||||
AccountManager accountManager(Application application) {
|
||||
return (AccountManager)application.getSystemService(Context.ACCOUNT_SERVICE);
|
||||
return (AccountManager) application.getSystemService(Context.ACCOUNT_SERVICE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -108,7 +109,7 @@ class AppModule {
|
||||
UserAccountManager userAccountManager(
|
||||
Context context,
|
||||
AccountManager accountManager
|
||||
) {
|
||||
) {
|
||||
return new UserAccountManagerImpl(context, accountManager);
|
||||
}
|
||||
|
||||
@@ -165,7 +166,7 @@ class AppModule {
|
||||
@Singleton
|
||||
Logger logger(Context context, Clock clock) {
|
||||
File logDir = new File(context.getFilesDir(), "logs");
|
||||
FileLogHandler handler = new FileLogHandler(logDir, "log.txt", 1024*1024);
|
||||
FileLogHandler handler = new FileLogHandler(logDir, "log.txt", 1024 * 1024);
|
||||
LoggerImpl logger = new LoggerImpl(clock, handler, new Handler(), 1000);
|
||||
logger.start();
|
||||
return logger;
|
||||
@@ -174,7 +175,7 @@ class AppModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
LogsRepository logsRepository(Logger logger) {
|
||||
return (LogsRepository)logger;
|
||||
return (LogsRepository) logger;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -194,12 +195,12 @@ class AppModule {
|
||||
|
||||
@Provides
|
||||
NotificationManager notificationManager(Context context) {
|
||||
return (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
return (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
AudioManager audioManager(Context context) {
|
||||
return (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
|
||||
return (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@@ -226,8 +227,13 @@ class AppModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
AppNotificationManager notificationsManager(Context context, NotificationManager platformNotificationsManager) {
|
||||
return new AppNotificationManagerImpl(context, context.getResources(), platformNotificationsManager);
|
||||
AppNotificationManager notificationsManager(Context context,
|
||||
NotificationManager platformNotificationsManager,
|
||||
ThemeColorUtils themeColorUtils) {
|
||||
return new AppNotificationManagerImpl(context,
|
||||
context.getResources(),
|
||||
platformNotificationsManager,
|
||||
themeColorUtils);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
||||
@@ -24,11 +24,14 @@ import com.nextcloud.client.etm.EtmActivity;
|
||||
import com.nextcloud.client.files.downloader.FileTransferService;
|
||||
import com.nextcloud.client.jobs.NotificationWork;
|
||||
import com.nextcloud.client.logger.ui.LogsActivity;
|
||||
import com.nextcloud.client.logger.ui.LogsViewModel;
|
||||
import com.nextcloud.client.media.PlayerService;
|
||||
import com.nextcloud.client.migrations.Migrations;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.nextcloud.client.onboarding.WhatsNewActivity;
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment;
|
||||
import com.nextcloud.ui.SetStatusDialogFragment;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.authentication.DeepLinkLoginActivity;
|
||||
import com.owncloud.android.files.BootupBroadcastReceiver;
|
||||
@@ -50,6 +53,7 @@ import com.owncloud.android.ui.activity.CopyToClipboardActivity;
|
||||
import com.owncloud.android.ui.activity.DrawerActivity;
|
||||
import com.owncloud.android.ui.activity.ErrorsWhileCopyingHandlerActivity;
|
||||
import com.owncloud.android.ui.activity.ExternalSiteWebView;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.activity.FilePickerActivity;
|
||||
import com.owncloud.android.ui.activity.FolderPickerActivity;
|
||||
@@ -65,85 +69,187 @@ import com.owncloud.android.ui.activity.ShareActivity;
|
||||
import com.owncloud.android.ui.activity.SsoGrantPermissionActivity;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
import com.owncloud.android.ui.activity.TextEditorWebView;
|
||||
import com.owncloud.android.ui.activity.ToolbarActivity;
|
||||
import com.owncloud.android.ui.activity.UploadFilesActivity;
|
||||
import com.owncloud.android.ui.activity.UploadListActivity;
|
||||
import com.owncloud.android.ui.activity.UserInfoActivity;
|
||||
import com.owncloud.android.ui.dialog.AccountRemovalConfirmationDialog;
|
||||
import com.owncloud.android.ui.dialog.ChooseRichDocumentsTemplateDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.ChooseTemplateDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
|
||||
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.ExpirationDatePickerDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
|
||||
import com.owncloud.android.ui.dialog.LoadingDialog;
|
||||
import com.owncloud.android.ui.dialog.LocalStoragePathPickerDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.MultipleAccountsDialog;
|
||||
import com.owncloud.android.ui.dialog.NoteDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.RenamePublicShareDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SendShareDialog;
|
||||
import com.owncloud.android.ui.dialog.SetupEncryptionDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SortingOrderDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.StoragePermissionDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.ExtendedListFragment;
|
||||
import com.owncloud.android.ui.fragment.FeatureFragment;
|
||||
import com.owncloud.android.ui.fragment.FileDetailActivitiesFragment;
|
||||
import com.owncloud.android.ui.fragment.FileDetailFragment;
|
||||
import com.owncloud.android.ui.fragment.FileDetailSharingFragment;
|
||||
import com.owncloud.android.ui.fragment.GalleryFragment;
|
||||
import com.owncloud.android.ui.fragment.LocalFileListFragment;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.ui.fragment.SharedListFragment;
|
||||
import com.owncloud.android.ui.fragment.UnifiedSearchFragment;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.BackupFragment;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment;
|
||||
import com.owncloud.android.ui.preview.FileDownloadFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewImageActivity;
|
||||
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewMediaFragment;
|
||||
import com.owncloud.android.ui.preview.pdf.PreviewPdfFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewTextFileFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewTextFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewTextStringFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewVideoActivity;
|
||||
import com.owncloud.android.ui.preview.pdf.PreviewPdfFragment;
|
||||
import com.owncloud.android.ui.trashbin.TrashbinActivity;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.android.ContributesAndroidInjector;
|
||||
|
||||
/**
|
||||
* Register classes that require dependency injection. This class is used by Dagger compiler
|
||||
* only.
|
||||
* Register classes that require dependency injection. This class is used by Dagger compiler only.
|
||||
*/
|
||||
@Module
|
||||
abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector abstract ActivitiesActivity activitiesActivity();
|
||||
@ContributesAndroidInjector abstract AuthenticatorActivity authenticatorActivity();
|
||||
@ContributesAndroidInjector abstract BaseActivity baseActivity();
|
||||
@ContributesAndroidInjector abstract ConflictsResolveActivity conflictsResolveActivity();
|
||||
@ContributesAndroidInjector abstract ContactsPreferenceActivity contactsPreferenceActivity();
|
||||
@ContributesAndroidInjector abstract CopyToClipboardActivity copyToClipboardActivity();
|
||||
@ContributesAndroidInjector abstract DeepLinkLoginActivity deepLinkLoginActivity();
|
||||
@ContributesAndroidInjector abstract DrawerActivity drawerActivity();
|
||||
@ContributesAndroidInjector abstract ErrorsWhileCopyingHandlerActivity errorsWhileCopyingHandlerActivity();
|
||||
@ContributesAndroidInjector abstract ExternalSiteWebView externalSiteWebView();
|
||||
@ContributesAndroidInjector abstract FileDisplayActivity fileDisplayActivity();
|
||||
@ContributesAndroidInjector abstract FilePickerActivity filePickerActivity();
|
||||
@ContributesAndroidInjector abstract FirstRunActivity firstRunActivity();
|
||||
@ContributesAndroidInjector abstract FolderPickerActivity folderPickerActivity();
|
||||
@ContributesAndroidInjector abstract LogsActivity logsActivity();
|
||||
@ContributesAndroidInjector abstract ManageAccountsActivity manageAccountsActivity();
|
||||
@ContributesAndroidInjector abstract ManageSpaceActivity manageSpaceActivity();
|
||||
@ContributesAndroidInjector abstract NotificationsActivity notificationsActivity();
|
||||
@ContributesAndroidInjector abstract CommunityActivity participateActivity();
|
||||
@ContributesAndroidInjector abstract PassCodeActivity passCodeActivity();
|
||||
@ContributesAndroidInjector abstract PreviewImageActivity previewImageActivity();
|
||||
@ContributesAndroidInjector abstract PreviewVideoActivity previewVideoActivity();
|
||||
@ContributesAndroidInjector abstract ReceiveExternalFilesActivity receiveExternalFilesActivity();
|
||||
@ContributesAndroidInjector abstract RequestCredentialsActivity requestCredentialsActivity();
|
||||
@ContributesAndroidInjector abstract SettingsActivity settingsActivity();
|
||||
@ContributesAndroidInjector abstract ShareActivity shareActivity();
|
||||
@ContributesAndroidInjector abstract SsoGrantPermissionActivity ssoGrantPermissionActivity();
|
||||
@ContributesAndroidInjector abstract SyncedFoldersActivity syncedFoldersActivity();
|
||||
@ContributesAndroidInjector abstract TrashbinActivity trashbinActivity();
|
||||
@ContributesAndroidInjector abstract UploadFilesActivity uploadFilesActivity();
|
||||
@ContributesAndroidInjector abstract UploadListActivity uploadListActivity();
|
||||
@ContributesAndroidInjector abstract UserInfoActivity userInfoActivity();
|
||||
@ContributesAndroidInjector abstract WhatsNewActivity whatsNewActivity();
|
||||
@ContributesAndroidInjector abstract EtmActivity etmActivity();
|
||||
@ContributesAndroidInjector
|
||||
abstract ActivitiesActivity activitiesActivity();
|
||||
|
||||
@ContributesAndroidInjector abstract RichDocumentsEditorWebView richDocumentsWebView();
|
||||
@ContributesAndroidInjector abstract TextEditorWebView textEditorWebView();
|
||||
@ContributesAndroidInjector
|
||||
abstract AuthenticatorActivity authenticatorActivity();
|
||||
|
||||
@ContributesAndroidInjector abstract ExtendedListFragment extendedListFragment();
|
||||
@ContributesAndroidInjector abstract FileDetailFragment fileDetailFragment();
|
||||
@ContributesAndroidInjector abstract LocalFileListFragment localFileListFragment();
|
||||
@ContributesAndroidInjector abstract OCFileListFragment ocFileListFragment();
|
||||
@ContributesAndroidInjector abstract FileDetailActivitiesFragment fileDetailActivitiesFragment();
|
||||
@ContributesAndroidInjector
|
||||
abstract BaseActivity baseActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ConflictsResolveActivity conflictsResolveActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ContactsPreferenceActivity contactsPreferenceActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract CopyToClipboardActivity copyToClipboardActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract DeepLinkLoginActivity deepLinkLoginActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract DrawerActivity drawerActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ErrorsWhileCopyingHandlerActivity errorsWhileCopyingHandlerActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ExternalSiteWebView externalSiteWebView();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileDisplayActivity fileDisplayActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FilePickerActivity filePickerActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FirstRunActivity firstRunActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FolderPickerActivity folderPickerActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract LogsActivity logsActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ManageAccountsActivity manageAccountsActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ManageSpaceActivity manageSpaceActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract NotificationsActivity notificationsActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract CommunityActivity participateActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PassCodeActivity passCodeActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PreviewImageActivity previewImageActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PreviewVideoActivity previewVideoActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ReceiveExternalFilesActivity receiveExternalFilesActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract RequestCredentialsActivity requestCredentialsActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SettingsActivity settingsActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ShareActivity shareActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SsoGrantPermissionActivity ssoGrantPermissionActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SyncedFoldersActivity syncedFoldersActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract TrashbinActivity trashbinActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract UploadFilesActivity uploadFilesActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract UploadListActivity uploadListActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract UserInfoActivity userInfoActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract WhatsNewActivity whatsNewActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract EtmActivity etmActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract RichDocumentsEditorWebView richDocumentsWebView();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract TextEditorWebView textEditorWebView();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ExtendedListFragment extendedListFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileDetailFragment fileDetailFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract LocalFileListFragment localFileListFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract OCFileListFragment ocFileListFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileDetailActivitiesFragment fileDetailActivitiesFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileDetailSharingFragment fileDetailSharingFragment();
|
||||
@@ -178,8 +284,11 @@ abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector
|
||||
abstract SetStatusDialogFragment setStatusDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector abstract PreviewTextFileFragment previewTextFileFragment();
|
||||
@ContributesAndroidInjector abstract PreviewTextStringFragment previewTextStringFragment();
|
||||
@ContributesAndroidInjector
|
||||
abstract PreviewTextFileFragment previewTextFileFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PreviewTextStringFragment previewTextStringFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract UnifiedSearchFragment searchFragment();
|
||||
@@ -199,20 +308,126 @@ abstract class ComponentsModule {
|
||||
@ContributesAndroidInjector
|
||||
abstract FileDownloader fileDownloader();
|
||||
|
||||
@ContributesAndroidInjector abstract BootupBroadcastReceiver bootupBroadcastReceiver();
|
||||
@ContributesAndroidInjector abstract NotificationWork.NotificationReceiver notificationWorkBroadcastReceiver();
|
||||
@ContributesAndroidInjector
|
||||
abstract BootupBroadcastReceiver bootupBroadcastReceiver();
|
||||
|
||||
@ContributesAndroidInjector abstract FileContentProvider fileContentProvider();
|
||||
@ContributesAndroidInjector abstract UsersAndGroupsSearchProvider usersAndGroupsSearchProvider();
|
||||
@ContributesAndroidInjector abstract DiskLruImageCacheFileProvider diskLruImageCacheFileProvider();
|
||||
@ContributesAndroidInjector abstract DocumentsStorageProvider documentsStorageProvider();
|
||||
|
||||
@ContributesAndroidInjector abstract AccountManagerService accountManagerService();
|
||||
@ContributesAndroidInjector abstract OperationsService operationsService();
|
||||
@ContributesAndroidInjector abstract PlayerService playerService();
|
||||
@ContributesAndroidInjector abstract FileTransferService fileDownloaderService();
|
||||
@ContributesAndroidInjector abstract FileSyncService fileSyncService();
|
||||
@ContributesAndroidInjector
|
||||
abstract NotificationWork.NotificationReceiver notificationWorkBroadcastReceiver();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileContentProvider fileContentProvider();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract UsersAndGroupsSearchProvider usersAndGroupsSearchProvider();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract DiskLruImageCacheFileProvider diskLruImageCacheFileProvider();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract DocumentsStorageProvider documentsStorageProvider();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract AccountManagerService accountManagerService();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract OperationsService operationsService();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PlayerService playerService();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileTransferService fileDownloaderService();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileSyncService fileSyncService();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PreviewPdfFragment previewPDFFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SharedListFragment sharedFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FeatureFragment featureFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract IndeterminateProgressDialog indeterminateProgressDialog();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SortingOrderDialogFragment sortingOrderDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ConfirmationDialogFragment confirmationDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ConflictsResolveDialog conflictsResolveDialog();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract CreateFolderDialogFragment createFolderDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ExpirationDatePickerDialogFragment expirationDatePickerDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileActivity fileActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract FileDownloadFragment fileDownloadFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract LoadingDialog loadingDialog();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract LocalStoragePathPickerDialogFragment localStoragePathPickerDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract LogsViewModel logsViewModel();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract MainApp mainApp();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract Migrations migrations();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract NoteDialogFragment noteDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract NotificationWork notificationWork();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract OCFileListBottomSheetDialog ocFileListBottomSheetDialog();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract RemoveFilesDialogFragment removeFilesDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract RenamePublicShareDialogFragment renamePublicShareDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SendShareDialog sendShareDialog();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SetupEncryptionDialogFragment setupEncryptionDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SharePasswordDialogFragment sharePasswordDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SyncedFolderPreferencesDialogFragment syncedFolderPreferencesDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract ToolbarActivity toolbarActivity();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract StoragePermissionDialogFragment storagePermissionDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract OCFileListBottomSheetDialogFragment ocfileListBottomSheetDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract RenameFileDialogFragment renameFileDialogFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SyncFileNotEnoughSpaceDialogFragment syncFileNotEnoughSpaceDialogFragment();
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2022 Tobias Kaminsky
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.di
|
||||
|
||||
import android.content.Context
|
||||
import javax.inject.Singleton
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils
|
||||
import com.owncloud.android.utils.theme.ThemeFabUtils
|
||||
import com.owncloud.android.utils.theme.ThemeLayoutUtils
|
||||
import com.owncloud.android.utils.theme.ThemeTextInputUtils
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils
|
||||
import com.owncloud.android.utils.theme.ThemeMenuUtils
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
|
||||
import com.owncloud.android.utils.theme.ThemeTextUtils
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils
|
||||
import com.owncloud.android.utils.theme.ThemeBarUtils
|
||||
import com.owncloud.android.utils.theme.ThemeCheckableUtils
|
||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils
|
||||
import com.owncloud.android.utils.theme.ThemeUtils
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Module
|
||||
internal class ThemeModule {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeColorUtils(): ThemeColorUtils {
|
||||
return ThemeColorUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeFabUtils(themeColorUtils: ThemeColorUtils?, themeDrawableUtils: ThemeDrawableUtils?): ThemeFabUtils {
|
||||
return ThemeFabUtils(themeColorUtils, themeDrawableUtils)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeLayoutUtils(themeColorUtils: ThemeColorUtils?): ThemeLayoutUtils {
|
||||
return ThemeLayoutUtils(themeColorUtils)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeToolbarUtils(
|
||||
themeColorUtils: ThemeColorUtils?,
|
||||
themeDrawableUtils: ThemeDrawableUtils?,
|
||||
themeTextInputUtils: ThemeTextInputUtils?
|
||||
): ThemeToolbarUtils {
|
||||
return ThemeToolbarUtils(themeColorUtils, themeDrawableUtils, themeTextInputUtils)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeDrawableUtils(context: Context?): ThemeDrawableUtils {
|
||||
return ThemeDrawableUtils(context)
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeUtils(): ThemeUtils {
|
||||
return ThemeUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeMenuUtils(): ThemeMenuUtils {
|
||||
return ThemeMenuUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeSnackbarUtils(): ThemeSnackbarUtils {
|
||||
return ThemeSnackbarUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeTextUtils(): ThemeTextUtils {
|
||||
return ThemeTextUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeButtonUtils(): ThemeButtonUtils {
|
||||
return ThemeButtonUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeBarUtils(): ThemeBarUtils {
|
||||
return ThemeBarUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeTextInputUtils(): ThemeTextInputUtils {
|
||||
return ThemeTextInputUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeCheckableUtils(): ThemeCheckableUtils {
|
||||
return ThemeCheckableUtils()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun themeAvatarUtils(): ThemeAvatarUtils {
|
||||
return ThemeAvatarUtils()
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,6 @@ import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.PushUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.io.File
|
||||
import java.util.ArrayList
|
||||
|
||||
/**
|
||||
* Removes account and all local files
|
||||
@@ -150,6 +149,9 @@ class AccountRemovalWork(
|
||||
deleteAppPasswordRemoteOperation.execute(optionNextcloudClient.get())
|
||||
}
|
||||
|
||||
// delete cached OwncloudClient
|
||||
OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(user.toOwnCloudAccount())
|
||||
|
||||
if (userRemoved) {
|
||||
eventBus.post(AccountRemovedEvent())
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Provider
|
||||
@@ -63,7 +66,10 @@ class BackgroundJobFactory @Inject constructor(
|
||||
private val connectivityService: ConnectivityService,
|
||||
private val notificationManager: NotificationManager,
|
||||
private val eventBus: EventBus,
|
||||
private val deckApi: DeckApi
|
||||
private val deckApi: DeckApi,
|
||||
private val themeColorUtils: ThemeColorUtils,
|
||||
private val themeSnackbarUtils: ThemeSnackbarUtils,
|
||||
private val themeButtonUtils: ThemeButtonUtils
|
||||
) : WorkerFactory() {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@@ -192,7 +198,10 @@ class BackgroundJobFactory @Inject constructor(
|
||||
contentResolver,
|
||||
accountManager,
|
||||
preferences,
|
||||
clock
|
||||
clock,
|
||||
themeColorUtils,
|
||||
themeSnackbarUtils,
|
||||
themeButtonUtils
|
||||
)
|
||||
}
|
||||
|
||||
@@ -202,7 +211,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
params,
|
||||
notificationManager,
|
||||
accountManager,
|
||||
deckApi
|
||||
deckApi,
|
||||
themeColorUtils
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +55,9 @@ import com.owncloud.android.ui.activity.ManageAccountsActivity.PENDING_FOR_REMOV
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils
|
||||
import com.owncloud.android.utils.SyncedFolderUtils
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
||||
import java.util.ArrayList
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils
|
||||
import java.util.Random
|
||||
|
||||
@Suppress("LongParameterList") // dependencies injection
|
||||
@@ -67,7 +68,10 @@ class MediaFoldersDetectionWork constructor(
|
||||
private val contentResolver: ContentResolver,
|
||||
private val userAccountManager: UserAccountManager,
|
||||
private val preferences: AppPreferences,
|
||||
private val clock: Clock
|
||||
private val clock: Clock,
|
||||
private val themeColorUtils: ThemeColorUtils,
|
||||
private val themeSnackbarUtils: ThemeSnackbarUtils,
|
||||
private val themeButtonUtils: ThemeButtonUtils
|
||||
) : Worker(context, params) {
|
||||
|
||||
companion object {
|
||||
@@ -88,8 +92,20 @@ class MediaFoldersDetectionWork constructor(
|
||||
val syncedFolderProvider = SyncedFolderProvider(contentResolver, preferences, clock)
|
||||
val gson = Gson()
|
||||
val mediaFoldersModel: MediaFoldersModel
|
||||
val imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1, null, true)
|
||||
val videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null, true)
|
||||
val imageMediaFolders = MediaProvider.getImageFolders(
|
||||
contentResolver,
|
||||
1,
|
||||
null,
|
||||
true,
|
||||
themeSnackbarUtils
|
||||
)
|
||||
val videoMediaFolders = MediaProvider.getVideoFolders(
|
||||
contentResolver,
|
||||
1,
|
||||
null,
|
||||
true,
|
||||
themeSnackbarUtils
|
||||
)
|
||||
val imageMediaFolderPaths: MutableList<String> = ArrayList()
|
||||
val videoMediaFolderPaths: MutableList<String> = ArrayList()
|
||||
for (imageMediaFolder in imageMediaFolders) {
|
||||
@@ -206,7 +222,7 @@ class MediaFoldersDetectionWork constructor(
|
||||
)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
|
||||
.setColor(ThemeColorUtils.primaryColor(context))
|
||||
.setColor(themeColorUtils.primaryColor(context))
|
||||
.setSubText(user.accountName)
|
||||
.setContentTitle(contentTitle)
|
||||
.setContentText(subtitle)
|
||||
|
||||
@@ -70,12 +70,14 @@ import java.security.SecureRandom
|
||||
import javax.crypto.Cipher
|
||||
import javax.inject.Inject
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
class NotificationWork constructor(
|
||||
private val context: Context,
|
||||
params: WorkerParameters,
|
||||
private val notificationManager: NotificationManager,
|
||||
private val accountManager: UserAccountManager,
|
||||
private val deckApi: DeckApi
|
||||
private val deckApi: DeckApi,
|
||||
private val themeColorUtils: ThemeColorUtils
|
||||
) : Worker(context, params) {
|
||||
|
||||
companion object {
|
||||
@@ -167,7 +169,7 @@ class NotificationWork constructor(
|
||||
val notificationBuilder = NotificationCompat.Builder(context, NotificationUtils.NOTIFICATION_CHANNEL_PUSH)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
|
||||
.setColor(ThemeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
|
||||
.setColor(themeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
|
||||
.setShowWhen(true)
|
||||
.setSubText(user.accountName)
|
||||
.setContentTitle(notification.getSubject())
|
||||
@@ -222,7 +224,7 @@ class NotificationWork constructor(
|
||||
NotificationCompat.Builder(context, NotificationUtils.NOTIFICATION_CHANNEL_PUSH)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(context.resources, R.drawable.notification_icon))
|
||||
.setColor(ThemeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
|
||||
.setColor(themeColorUtils.primaryColor(user.toPlatformAccount(), false, context))
|
||||
.setShowWhen(true)
|
||||
.setSubText(user.accountName)
|
||||
.setContentTitle(context.getString(R.string.new_notification))
|
||||
|
||||
@@ -34,13 +34,14 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.LogsActivityBinding
|
||||
import com.owncloud.android.ui.activity.ToolbarActivity
|
||||
import com.owncloud.android.utils.theme.ThemeBarUtils
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils
|
||||
import javax.inject.Inject
|
||||
|
||||
class LogsActivity : ToolbarActivity() {
|
||||
|
||||
@Inject
|
||||
protected lateinit var viewModelFactory: ViewModelFactory
|
||||
@Inject
|
||||
protected lateinit var themeBarUtils: ThemeBarUtils
|
||||
private lateinit var vm: LogsViewModel
|
||||
private lateinit var binding: LogsActivityBinding
|
||||
private lateinit var logsAdapter: LogsAdapter
|
||||
@@ -65,7 +66,7 @@ class LogsActivity : ToolbarActivity() {
|
||||
}
|
||||
|
||||
findViewById<ProgressBar>(R.id.logs_loading_progress).apply {
|
||||
ThemeBarUtils.themeProgressBar(context, this)
|
||||
themeBarUtils.themeProgressBar(context, this, themeColorUtils)
|
||||
}
|
||||
|
||||
logsAdapter = LogsAdapter(this)
|
||||
@@ -79,9 +80,9 @@ class LogsActivity : ToolbarActivity() {
|
||||
|
||||
setupToolbar()
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.apply { ThemeToolbarUtils.setColoredTitle(this, getString(R.string.logs_title), baseContext) }
|
||||
supportActionBar?.apply { themeToolbarUtils.setColoredTitle(this, getString(R.string.logs_title), baseContext) }
|
||||
|
||||
ThemeToolbarUtils.tintBackButton(supportActionBar, baseContext)
|
||||
themeToolbarUtils.tintBackButton(supportActionBar, baseContext)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
@@ -89,7 +90,7 @@ class LogsActivity : ToolbarActivity() {
|
||||
(menu.findItem(R.id.action_search).actionView as SearchView).apply {
|
||||
setOnQueryTextListener(searchBoxListener)
|
||||
|
||||
ThemeToolbarUtils.themeSearchView(this, context)
|
||||
themeToolbarUtils.themeSearchView(this, context)
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
@@ -89,6 +89,9 @@ class PlayerService : Service() {
|
||||
@Inject
|
||||
protected lateinit var clientFactory: ClientFactory
|
||||
|
||||
@Inject
|
||||
protected lateinit var themeColorUtils: ThemeColorUtils
|
||||
|
||||
private lateinit var player: Player
|
||||
private lateinit var notificationBuilder: NotificationCompat.Builder
|
||||
private var isRunning = false
|
||||
@@ -98,7 +101,7 @@ class PlayerService : Service() {
|
||||
AndroidInjection.inject(this)
|
||||
player = Player(applicationContext, clientFactory, playerListener, audioManager)
|
||||
notificationBuilder = NotificationCompat.Builder(this)
|
||||
notificationBuilder.color = ThemeColorUtils.primaryColor(this)
|
||||
notificationBuilder.color = themeColorUtils.primaryColor(this)
|
||||
|
||||
val stop = Intent(this, PlayerService::class.java)
|
||||
stop.action = ACTION_STOP
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.nextcloud.java.util.Optional
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.ui.activity.BaseActivity
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils
|
||||
|
||||
/**
|
||||
* Session mixin collects all account / user handling logic currently
|
||||
@@ -53,8 +54,10 @@ class SessionMixin constructor(
|
||||
private set
|
||||
var storageManager: FileDataStorageManager? = null
|
||||
private set
|
||||
var capabilities: OCCapability? = null
|
||||
private set
|
||||
val capabilities: OCCapability?
|
||||
get() = getUser()
|
||||
.map { CapabilityUtils.getCapability(it, activity) }
|
||||
.orElse(null)
|
||||
|
||||
fun setAccount(account: Account?) {
|
||||
val validAccount = account != null && accountManager.setCurrentOwnCloudAccount(account.name)
|
||||
@@ -67,7 +70,6 @@ class SessionMixin constructor(
|
||||
currentAccount?.let {
|
||||
val storageManager = FileDataStorageManager(getUser().get(), contentResolver)
|
||||
this.storageManager = storageManager
|
||||
this.capabilities = storageManager.getCapability(it.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ import javax.inject.Inject
|
||||
class AppNotificationManagerImpl @Inject constructor(
|
||||
private val context: Context,
|
||||
private val resources: Resources,
|
||||
private val platformNotificationsManager: NotificationManager
|
||||
private val platformNotificationsManager: NotificationManager,
|
||||
private val themeColorUtils: ThemeColorUtils
|
||||
) : AppNotificationManager {
|
||||
|
||||
companion object {
|
||||
@@ -31,7 +32,7 @@ class AppNotificationManagerImpl @Inject constructor(
|
||||
}
|
||||
|
||||
private fun builder(channelId: String): NotificationCompat.Builder {
|
||||
val color = ThemeColorUtils.primaryColor(context, true)
|
||||
val color = themeColorUtils.primaryColor(context, true)
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationCompat.Builder(context, channelId).setColor(color)
|
||||
} else {
|
||||
|
||||
@@ -56,6 +56,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
|
||||
@Inject AppPreferences preferences;
|
||||
@Inject AppInfo appInfo;
|
||||
@Inject OnboardingService onboarding;
|
||||
@Inject ThemeButtonUtils themeButtonUtils;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -85,7 +86,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
|
||||
mPager.addOnPageChangeListener(this);
|
||||
|
||||
mForwardFinishButton = findViewById(R.id.forward);
|
||||
ThemeButtonUtils.colorImageButton(mForwardFinishButton, fontColor);
|
||||
themeButtonUtils.colorImageButton(mForwardFinishButton, fontColor);
|
||||
|
||||
mForwardFinishButton.setOnClickListener(view -> {
|
||||
if (mProgress.hasNextStep()) {
|
||||
|
||||
@@ -373,4 +373,8 @@ public interface AppPreferences {
|
||||
void setPdfZoomTipShownCount(int count);
|
||||
|
||||
int getPdfZoomTipShownCount();
|
||||
|
||||
boolean isStoragePermissionRequested();
|
||||
|
||||
void setStoragePermissionRequested(boolean value);
|
||||
}
|
||||
@@ -97,6 +97,8 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
|
||||
private static final String PREF__PDF_ZOOM_TIP_SHOWN = "pdf_zoom_tip_shown";
|
||||
|
||||
private static final String PREF__STORAGE_PERMISSION_REQUESTED = "storage_permission_requested";
|
||||
|
||||
private final Context context;
|
||||
private final SharedPreferences preferences;
|
||||
private final CurrentAccountProvider currentAccountProvider;
|
||||
@@ -696,6 +698,16 @@ public final class AppPreferencesImpl implements AppPreferences {
|
||||
return preferences.getInt(PREF__PDF_ZOOM_TIP_SHOWN, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStoragePermissionRequested() {
|
||||
return preferences.getBoolean(PREF__STORAGE_PERMISSION_REQUESTED, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoragePermissionRequested(boolean value) {
|
||||
preferences.edit().putBoolean(PREF__STORAGE_PERMISSION_REQUESTED, value).apply();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public int computeBruteForceDelay(int count) {
|
||||
return (int) Math.min(count / 3d, 10);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Nextcloud Android Library is available under MIT license
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.utils
|
||||
|
||||
import org.apache.commons.codec.binary.Hex
|
||||
import java.security.MessageDigest
|
||||
|
||||
object HashUtil {
|
||||
private const val ALGORITHM_MD5 = "MD5"
|
||||
|
||||
@JvmStatic
|
||||
fun md5Hash(input: String): String {
|
||||
val digest = MessageDigest.getInstance(ALGORITHM_MD5)
|
||||
.digest(input.toByteArray())
|
||||
return String(Hex.encodeHex(digest))
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,6 @@ import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils
|
||||
import java.util.ArrayList
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val ARG_CURRENT_USER_PARAM = "currentUser"
|
||||
@@ -73,6 +72,12 @@ class ChooseAccountDialogFragment :
|
||||
@Inject
|
||||
lateinit var clientFactory: ClientFactory
|
||||
|
||||
@Inject
|
||||
lateinit var themeColorUtils: ThemeColorUtils
|
||||
|
||||
@Inject
|
||||
lateinit var themeDrawableUtils: ThemeDrawableUtils
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
@@ -112,9 +117,9 @@ class ChooseAccountDialogFragment :
|
||||
binding.currentAccount.account.text = user.accountName
|
||||
|
||||
// Defining user right indicator
|
||||
val icon = ThemeDrawableUtils.tintDrawable(
|
||||
val icon = themeDrawableUtils.tintDrawable(
|
||||
ContextCompat.getDrawable(requireContext(), R.drawable.ic_check_circle),
|
||||
ThemeColorUtils.primaryColor(requireContext(), true)
|
||||
themeColorUtils.primaryColor(requireContext(), true)
|
||||
)
|
||||
binding.currentAccount.accountMenu.setImageDrawable(icon)
|
||||
|
||||
@@ -125,7 +130,9 @@ class ChooseAccountDialogFragment :
|
||||
getAccountListItems(),
|
||||
this,
|
||||
false,
|
||||
false
|
||||
false,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils
|
||||
)
|
||||
|
||||
binding.accountsList.adapter = adapter
|
||||
|
||||
@@ -59,7 +59,6 @@ import com.owncloud.android.utils.theme.ThemeTextInputUtils
|
||||
import com.vanniktech.emoji.EmojiManager
|
||||
import com.vanniktech.emoji.EmojiPopup
|
||||
import com.vanniktech.emoji.google.GoogleEmojiProvider
|
||||
import java.util.ArrayList
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
@@ -82,6 +81,9 @@ private const val LAST_HOUR_OF_DAY = 23
|
||||
private const val LAST_MINUTE_OF_HOUR = 59
|
||||
private const val LAST_SECOND_OF_MINUTE = 59
|
||||
|
||||
private const val CLEAR_AT_TYPE_PERIOD = "period"
|
||||
private const val CLEAR_AT_TYPE_END_OF = "end-of"
|
||||
|
||||
class SetStatusDialogFragment :
|
||||
DialogFragment(),
|
||||
PredefinedStatusClickListener,
|
||||
@@ -107,6 +109,15 @@ class SetStatusDialogFragment :
|
||||
@Inject
|
||||
lateinit var clientFactory: ClientFactory
|
||||
|
||||
@Inject
|
||||
lateinit var themeColorUtils: ThemeColorUtils
|
||||
|
||||
@Inject
|
||||
lateinit var themeButtonUtils: ThemeButtonUtils
|
||||
|
||||
@Inject
|
||||
lateinit var themeTextInputUtils: ThemeTextInputUtils
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
@@ -139,26 +150,7 @@ class SetStatusDialogFragment :
|
||||
accountManager = (activity as BaseActivity).userAccountManager
|
||||
|
||||
currentStatus?.let {
|
||||
binding.emoji.setText(it.icon)
|
||||
binding.customStatusInput.text?.clear()
|
||||
binding.customStatusInput.setText(it.message)
|
||||
visualizeStatus(it.status)
|
||||
|
||||
if (it.clearAt > 0) {
|
||||
binding.clearStatusAfterSpinner.visibility = View.GONE
|
||||
binding.remainingClearTime.apply {
|
||||
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message)
|
||||
visibility = View.VISIBLE
|
||||
text = DisplayUtils.getRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true)
|
||||
.toString()
|
||||
.decapitalize(Locale.getDefault())
|
||||
setOnClickListener {
|
||||
visibility = View.GONE
|
||||
binding.clearStatusAfterSpinner.visibility = View.VISIBLE
|
||||
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message_after)
|
||||
}
|
||||
}
|
||||
}
|
||||
updateCurrentStatusViews(it)
|
||||
}
|
||||
|
||||
adapter = PredefinedStatusListAdapter(this, requireContext())
|
||||
@@ -175,7 +167,7 @@ class SetStatusDialogFragment :
|
||||
|
||||
binding.clearStatus.setOnClickListener { clearStatus() }
|
||||
binding.setStatus.setOnClickListener { setStatusMessage() }
|
||||
binding.emoji.setOnClickListener { openEmojiPopup() }
|
||||
binding.emoji.setOnClickListener { popup.show() }
|
||||
|
||||
popup = EmojiPopup.Builder
|
||||
.fromRootView(view)
|
||||
@@ -212,92 +204,93 @@ class SetStatusDialogFragment :
|
||||
}
|
||||
}
|
||||
|
||||
binding.clearStatus.setTextColor(ThemeColorUtils.primaryColor(context, true))
|
||||
ThemeButtonUtils.colorPrimaryButton(binding.setStatus, context)
|
||||
ThemeTextInputUtils.colorTextInput(
|
||||
binding.clearStatus.setTextColor(themeColorUtils.primaryColor(context, true))
|
||||
themeButtonUtils.colorPrimaryButton(binding.setStatus, context, themeColorUtils)
|
||||
themeTextInputUtils.colorTextInput(
|
||||
binding.customStatusInputContainer,
|
||||
binding.customStatusInput,
|
||||
ThemeColorUtils.primaryColor(activity)
|
||||
themeColorUtils.primaryColor(activity)
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("ComplexMethod")
|
||||
private fun setClearStatusAfterValue(item: Int) {
|
||||
when (item) {
|
||||
POS_DONT_CLEAR -> {
|
||||
// don't clear
|
||||
clearAt = null
|
||||
}
|
||||
private fun updateCurrentStatusViews(it: Status) {
|
||||
binding.emoji.setText(it.icon)
|
||||
binding.customStatusInput.text?.clear()
|
||||
binding.customStatusInput.setText(it.message)
|
||||
visualizeStatus(it.status)
|
||||
|
||||
if (it.clearAt > 0) {
|
||||
binding.clearStatusAfterSpinner.visibility = View.GONE
|
||||
binding.remainingClearTime.apply {
|
||||
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message)
|
||||
visibility = View.VISIBLE
|
||||
text = DisplayUtils.getRelativeTimestamp(context, it.clearAt * ONE_SECOND_IN_MILLIS, true)
|
||||
.toString()
|
||||
.replaceFirstChar { it.lowercase(Locale.getDefault()) }
|
||||
setOnClickListener {
|
||||
visibility = View.GONE
|
||||
binding.clearStatusAfterSpinner.visibility = View.VISIBLE
|
||||
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message_after)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setClearStatusAfterValue(item: Int) {
|
||||
clearAt = when (item) {
|
||||
POS_DONT_CLEAR -> null // don't clear
|
||||
POS_HALF_AN_HOUR -> {
|
||||
// 30 minutes
|
||||
clearAt = System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + THIRTY_MINUTES * ONE_MINUTE_IN_SECONDS
|
||||
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + THIRTY_MINUTES * ONE_MINUTE_IN_SECONDS
|
||||
}
|
||||
|
||||
POS_AN_HOUR -> {
|
||||
// one hour
|
||||
clearAt =
|
||||
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
|
||||
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
|
||||
}
|
||||
|
||||
POS_FOUR_HOURS -> {
|
||||
// four hours
|
||||
clearAt =
|
||||
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS
|
||||
+FOUR_HOURS * ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
|
||||
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS +
|
||||
FOUR_HOURS * ONE_MINUTE_IN_SECONDS * ONE_MINUTE_IN_SECONDS
|
||||
}
|
||||
|
||||
POS_TODAY -> {
|
||||
// today
|
||||
val date = Calendar.getInstance().apply {
|
||||
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
|
||||
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
|
||||
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
|
||||
}
|
||||
clearAt = date.timeInMillis / ONE_SECOND_IN_MILLIS
|
||||
val date = getLastSecondOfToday()
|
||||
dateToSeconds(date)
|
||||
}
|
||||
|
||||
POS_END_OF_WEEK -> {
|
||||
// end of week
|
||||
val date = Calendar.getInstance().apply {
|
||||
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
|
||||
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
|
||||
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
|
||||
}
|
||||
|
||||
val date = getLastSecondOfToday()
|
||||
while (date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
|
||||
date.add(Calendar.DAY_OF_YEAR, 1)
|
||||
}
|
||||
|
||||
clearAt = date.timeInMillis / ONE_SECOND_IN_MILLIS
|
||||
dateToSeconds(date)
|
||||
}
|
||||
else -> clearAt
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
private fun clearAtToUnixTime(clearAt: ClearAt?): Long {
|
||||
if (clearAt != null) {
|
||||
if (clearAt.type.equals("period")) {
|
||||
return System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + clearAt.time.toLong()
|
||||
} else if (clearAt.type.equals("end-of")) {
|
||||
if (clearAt.time.equals("day")) {
|
||||
val date = Calendar.getInstance().apply {
|
||||
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
|
||||
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
|
||||
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
|
||||
}
|
||||
return date.timeInMillis / ONE_SECOND_IN_MILLIS
|
||||
}
|
||||
}
|
||||
private fun clearAtToUnixTime(clearAt: ClearAt?): Long = when {
|
||||
clearAt?.type == CLEAR_AT_TYPE_PERIOD -> {
|
||||
System.currentTimeMillis() / ONE_SECOND_IN_MILLIS + clearAt.time.toLong()
|
||||
}
|
||||
|
||||
return -1
|
||||
clearAt?.type == CLEAR_AT_TYPE_END_OF && clearAt.time == "day" -> {
|
||||
val date = getLastSecondOfToday()
|
||||
dateToSeconds(date)
|
||||
}
|
||||
else -> -1
|
||||
}
|
||||
|
||||
private fun openEmojiPopup() {
|
||||
popup.show()
|
||||
private fun getLastSecondOfToday(): Calendar {
|
||||
val date = Calendar.getInstance().apply {
|
||||
set(Calendar.HOUR_OF_DAY, LAST_HOUR_OF_DAY)
|
||||
set(Calendar.MINUTE, LAST_MINUTE_OF_HOUR)
|
||||
set(Calendar.SECOND, LAST_SECOND_OF_MINUTE)
|
||||
}
|
||||
return date
|
||||
}
|
||||
|
||||
private fun dateToSeconds(date: Calendar) = date.timeInMillis / ONE_SECOND_IN_MILLIS
|
||||
|
||||
private fun clearStatus() {
|
||||
asyncRunner.postQuickTask(
|
||||
ClearStatusTask(accountManager.currentOwnCloudAccount?.savedAccount, context),
|
||||
@@ -327,19 +320,19 @@ class SetStatusDialogFragment :
|
||||
when (statusType) {
|
||||
StatusType.ONLINE -> {
|
||||
clearTopStatus()
|
||||
binding.onlineStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
|
||||
binding.onlineStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
|
||||
}
|
||||
StatusType.AWAY -> {
|
||||
clearTopStatus()
|
||||
binding.awayStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
|
||||
binding.awayStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
|
||||
}
|
||||
StatusType.DND -> {
|
||||
clearTopStatus()
|
||||
binding.dndStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
|
||||
binding.dndStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
|
||||
}
|
||||
StatusType.INVISIBLE -> {
|
||||
clearTopStatus()
|
||||
binding.invisibleStatus.setBackgroundColor(ThemeColorUtils.primaryColor(context))
|
||||
binding.invisibleStatus.setBackgroundColor(themeColorUtils.primaryColor(context))
|
||||
}
|
||||
else -> clearTopStatus()
|
||||
}
|
||||
@@ -417,28 +410,35 @@ class SetStatusDialogFragment :
|
||||
binding.clearStatusAfterSpinner.visibility = View.VISIBLE
|
||||
binding.clearStatusMessageTextView.text = getString(R.string.clear_status_message_after)
|
||||
|
||||
if (predefinedStatus.clearAt == null) {
|
||||
val clearAt = predefinedStatus.clearAt
|
||||
if (clearAt == null) {
|
||||
binding.clearStatusAfterSpinner.setSelection(0)
|
||||
} else {
|
||||
val clearAt = predefinedStatus.clearAt!!
|
||||
if (clearAt.type.equals("period")) {
|
||||
when (clearAt.time) {
|
||||
"1800" -> binding.clearStatusAfterSpinner.setSelection(POS_HALF_AN_HOUR)
|
||||
"3600" -> binding.clearStatusAfterSpinner.setSelection(POS_AN_HOUR)
|
||||
"14400" -> binding.clearStatusAfterSpinner.setSelection(POS_FOUR_HOURS)
|
||||
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
|
||||
}
|
||||
} else if (clearAt.type.equals("end-of")) {
|
||||
when (clearAt.time) {
|
||||
"day" -> binding.clearStatusAfterSpinner.setSelection(POS_TODAY)
|
||||
"week" -> binding.clearStatusAfterSpinner.setSelection(POS_END_OF_WEEK)
|
||||
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
|
||||
}
|
||||
when (clearAt.type) {
|
||||
CLEAR_AT_TYPE_PERIOD -> updateClearAtViewsForPeriod(clearAt)
|
||||
CLEAR_AT_TYPE_END_OF -> updateClearAtViewsForEndOf(clearAt)
|
||||
}
|
||||
}
|
||||
setClearStatusAfterValue(binding.clearStatusAfterSpinner.selectedItemPosition)
|
||||
}
|
||||
|
||||
private fun updateClearAtViewsForPeriod(clearAt: ClearAt) {
|
||||
when (clearAt.time) {
|
||||
"1800" -> binding.clearStatusAfterSpinner.setSelection(POS_HALF_AN_HOUR)
|
||||
"3600" -> binding.clearStatusAfterSpinner.setSelection(POS_AN_HOUR)
|
||||
"14400" -> binding.clearStatusAfterSpinner.setSelection(POS_FOUR_HOURS)
|
||||
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateClearAtViewsForEndOf(clearAt: ClearAt) {
|
||||
when (clearAt.time) {
|
||||
"day" -> binding.clearStatusAfterSpinner.setSelection(POS_TODAY)
|
||||
"week" -> binding.clearStatusAfterSpinner.setSelection(POS_END_OF_WEEK)
|
||||
else -> binding.clearStatusAfterSpinner.setSelection(POS_DONT_CLEAR)
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
fun setPredefinedStatus(predefinedStatus: ArrayList<PredefinedStatus>) {
|
||||
adapter.list = predefinedStatus
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils
|
||||
|
||||
object TimeConstants {
|
||||
const val MILLIS_PER_SECOND = 1000
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Nextcloud Android Library is available under MIT license
|
||||
*
|
||||
* @author Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.nextcloud.utils.view
|
||||
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
|
||||
object FastScroll {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
fun applyFastScroll(recyclerView: RecyclerView, viewHelper: FastScroller.ViewHelper? = null) {
|
||||
val builder = FastScrollerBuilder(recyclerView).useMd2Style()
|
||||
if (viewHelper != null) {
|
||||
builder.setViewHelper(viewHelper)
|
||||
}
|
||||
builder.build()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun fixAppBarForFastScroll(appBarLayout: AppBarLayout, content: ViewGroup) {
|
||||
val contentLayoutInitialPaddingBottom = content.paddingBottom
|
||||
appBarLayout.addOnOffsetChangedListener(
|
||||
AppBarLayout.OnOffsetChangedListener { _, offset ->
|
||||
content.setPadding(
|
||||
content.paddingLeft,
|
||||
content.paddingTop,
|
||||
content.paddingRight,
|
||||
contentLayoutInitialPaddingBottom + appBarLayout.totalScrollRange + offset
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import com.nextcloud.client.appinfo.AppInfo;
|
||||
import com.nextcloud.client.core.Clock;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.di.ActivityInjector;
|
||||
import com.nextcloud.client.di.AppComponent;
|
||||
import com.nextcloud.client.di.DaggerAppComponent;
|
||||
import com.nextcloud.client.errorhandling.ExceptionHandler;
|
||||
import com.nextcloud.client.jobs.BackgroundJobManager;
|
||||
@@ -77,6 +78,7 @@ import com.owncloud.android.utils.FilesSyncHelper;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
import com.owncloud.android.utils.ReceiversHelper;
|
||||
import com.owncloud.android.utils.SecurityUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@@ -172,9 +174,13 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
@Inject
|
||||
PassCodeManager passCodeManager;
|
||||
|
||||
@Inject ThemeSnackbarUtils themeSnackbarUtils;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean mBound;
|
||||
|
||||
private static AppComponent appComponent;
|
||||
|
||||
/**
|
||||
* Temporary hack
|
||||
*/
|
||||
@@ -223,16 +229,13 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
super.attachBaseContext(base);
|
||||
|
||||
initGlobalContext(this);
|
||||
DaggerAppComponent.builder()
|
||||
.application(this)
|
||||
.build()
|
||||
.inject(this);
|
||||
initDagger();
|
||||
|
||||
// we don't want to handle crashes occurring inside crash reporter activity/process;
|
||||
// let the platform deal with those
|
||||
final boolean isCrashReportingProcess = getAppProcessName().endsWith(":crash");
|
||||
|
||||
if (!isCrashReportingProcess) {
|
||||
if (!isCrashReportingProcess && !appInfo.isDebugBuild()) {
|
||||
Thread.UncaughtExceptionHandler defaultPlatformHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
final ExceptionHandler crashReporter = new ExceptionHandler(this,
|
||||
defaultPlatformHandler);
|
||||
@@ -240,6 +243,29 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}
|
||||
}
|
||||
|
||||
private void initDagger() {
|
||||
appComponent = DaggerAppComponent.builder()
|
||||
.application(this)
|
||||
.build();
|
||||
|
||||
appComponent.inject(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>USE SPARINGLY!</b> This should only be used for injection of Theme classes in custom Views, and they need to
|
||||
* be added as methods in the {@link AppComponent} itself.
|
||||
* <p>
|
||||
* Once we adopt Hilt this won't be necessary either, as View is a supported target in Hilt.
|
||||
*
|
||||
* @return the {@link AppComponent} for this app
|
||||
*/
|
||||
public static AppComponent getAppComponent() {
|
||||
if (appComponent == null) {
|
||||
throw new IllegalStateException("Dagger not initialized!");
|
||||
}
|
||||
return appComponent;
|
||||
}
|
||||
|
||||
@SuppressFBWarnings("ST")
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -290,7 +316,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
connectivityService,
|
||||
powerManagementService,
|
||||
backgroundJobManager,
|
||||
clock);
|
||||
clock,
|
||||
themeSnackbarUtils);
|
||||
initContactsBackup(accountManager, backgroundJobManager);
|
||||
notificationChannels();
|
||||
|
||||
@@ -448,7 +475,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
final ConnectivityService connectivityService,
|
||||
final PowerManagementService powerManagementService,
|
||||
final BackgroundJobManager backgroundJobManager,
|
||||
final Clock clock
|
||||
final Clock clock,
|
||||
final ThemeSnackbarUtils themeSnackbarUtils
|
||||
) {
|
||||
updateToAutoUpload();
|
||||
cleanOldEntries(clock);
|
||||
@@ -456,7 +484,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
|
||||
if (getAppContext() != null) {
|
||||
if (PermissionUtil.checkExternalStoragePermission(getAppContext())) {
|
||||
splitOutAutoUploadEntries(clock);
|
||||
splitOutAutoUploadEntries(clock, themeSnackbarUtils);
|
||||
} else {
|
||||
preferences.setAutoUploadSplitEntriesEnabled(true);
|
||||
}
|
||||
@@ -678,7 +706,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
}
|
||||
}
|
||||
|
||||
private static void splitOutAutoUploadEntries(Clock clock) {
|
||||
private static void splitOutAutoUploadEntries(Clock clock,
|
||||
ThemeSnackbarUtils themeSnackbarUtils) {
|
||||
Context context = getAppContext();
|
||||
AppPreferences preferences = AppPreferencesImpl.fromContext(context);
|
||||
if (!preferences.isAutoUploadSplitEntriesEnabled()) {
|
||||
@@ -689,8 +718,16 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver, preferences, clock);
|
||||
|
||||
final List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1, null, true);
|
||||
final List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null, true);
|
||||
final List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver,
|
||||
1,
|
||||
null,
|
||||
true,
|
||||
themeSnackbarUtils);
|
||||
final List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver,
|
||||
1,
|
||||
null,
|
||||
true,
|
||||
themeSnackbarUtils);
|
||||
|
||||
ArrayList<Long> idsToDelete = new ArrayList<>();
|
||||
List<SyncedFolder> syncedFolders = syncedFolderProvider.getSyncedFolders();
|
||||
|
||||
@@ -143,6 +143,8 @@ import de.cotech.hw.fido2.WebViewWebauthnBridge;
|
||||
import de.cotech.hw.fido2.ui.WebauthnDialogOptions;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
import static com.owncloud.android.utils.PermissionUtil.PERMISSIONS_CAMERA;
|
||||
|
||||
/**
|
||||
* This Activity is used to add an ownCloud account to the App
|
||||
*/
|
||||
@@ -231,6 +233,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
@Inject OnboardingService onboarding;
|
||||
@Inject DeviceInfo deviceInfo;
|
||||
@Inject PassCodeManager passCodeManager;
|
||||
@Inject ThemeToolbarUtils themeToolbarUtils;
|
||||
@Inject ThemeDrawableUtils themeDrawableUtils;
|
||||
|
||||
private boolean onlyAdd = false;
|
||||
@SuppressLint("ResourceAsColor") @ColorInt
|
||||
private int primaryColor = R.color.primary;
|
||||
@@ -434,7 +439,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
accountSetupWebviewBinding.loginWebviewProgressBar.setVisibility(View.GONE);
|
||||
accountSetupWebviewBinding.loginWebview.setVisibility(View.VISIBLE);
|
||||
|
||||
ThemeToolbarUtils.colorStatusBar(AuthenticatorActivity.this, primaryColor);
|
||||
themeToolbarUtils.colorStatusBar(AuthenticatorActivity.this, primaryColor);
|
||||
getWindow().setNavigationBarColor(primaryColor);
|
||||
}
|
||||
|
||||
@@ -524,7 +529,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
if (deviceInfo.hasCamera(this)) {
|
||||
accountSetupBinding.scanQr.setOnClickListener(v -> onScan());
|
||||
ThemeDrawableUtils.tintDrawable(accountSetupBinding.scanQr.getDrawable(),
|
||||
themeDrawableUtils.tintDrawable(accountSetupBinding.scanQr.getDrawable(),
|
||||
getResources().getColor(R.color.login_text_color));
|
||||
} else {
|
||||
accountSetupBinding.scanQr.setVisibility(View.GONE);
|
||||
@@ -1298,7 +1303,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (PermissionUtil.checkSelfPermission(this, Manifest.permission.CAMERA)) {
|
||||
startQRScanner();
|
||||
} else {
|
||||
PermissionUtil.requestCameraPermission(this);
|
||||
PermissionUtil.requestCameraPermission(this, PERMISSIONS_CAMERA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,16 @@ import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nextcloud.client.di.Injectable;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
|
||||
public class DeepLinkLoginActivity extends AuthenticatorActivity {
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DeepLinkLoginActivity extends AuthenticatorActivity implements Injectable {
|
||||
@Inject
|
||||
public ThemeColorUtils themeColorUtils;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -29,7 +35,7 @@ public class DeepLinkLoginActivity extends AuthenticatorActivity {
|
||||
LoginUrlInfo loginUrlInfo = parseLoginDataUrl(prefix, data.toString());
|
||||
|
||||
TextView loginText = findViewById(R.id.loginInfo);
|
||||
loginText.setTextColor(ThemeColorUtils.fontColor(this));
|
||||
loginText.setTextColor(themeColorUtils.fontColor(this));
|
||||
loginText.setText(String.format("Login with %1$s to %2$s", loginUrlInfo.username,
|
||||
loginUrlInfo.serverAddress));
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
@@ -70,6 +71,7 @@ import java.util.Set;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
|
||||
public class FileDataStorageManager {
|
||||
@@ -83,9 +85,9 @@ public class FileDataStorageManager {
|
||||
public static final int ROOT_PARENT_ID = 0;
|
||||
public static final String NULL_STRING = "null";
|
||||
|
||||
private ContentResolver contentResolver;
|
||||
private ContentProviderClient contentProviderClient;
|
||||
private User user;
|
||||
private final ContentResolver contentResolver;
|
||||
private final ContentProviderClient contentProviderClient;
|
||||
private final User user;
|
||||
|
||||
public FileDataStorageManager(User user, ContentResolver contentResolver) {
|
||||
this.contentProviderClient = null;
|
||||
@@ -208,44 +210,10 @@ public class FileDataStorageManager {
|
||||
|
||||
public boolean saveFile(OCFile ocFile) {
|
||||
boolean overridden = false;
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, ocFile.getModificationTimestamp());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
|
||||
ocFile.getModificationTimestampAtLastSyncForData()
|
||||
);
|
||||
cv.put(ProviderTableMeta.FILE_CREATION, ocFile.getCreationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, ocFile.getFileLength());
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, ocFile.getMimeType());
|
||||
cv.put(ProviderTableMeta.FILE_NAME, ocFile.getFileName());
|
||||
cv.put(ProviderTableMeta.FILE_ENCRYPTED_NAME, ocFile.getEncryptedFileName());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, ocFile.getParentId());
|
||||
cv.put(ProviderTableMeta.FILE_PATH, ocFile.getRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, ocFile.getDecryptedRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, ocFile.isEncrypted());
|
||||
if (!ocFile.isFolder()) {
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, ocFile.getStoragePath());
|
||||
final ContentValues cv = createContentValuesForFile(ocFile);
|
||||
if (ocFile.isFolder()) {
|
||||
cv.remove(ProviderTableMeta.FILE_STORAGE_PATH);
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, ocFile.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, ocFile.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, ocFile.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, ocFile.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, ocFile.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, ocFile.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, ocFile.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, ocFile.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, ocFile.isUpdateThumbnailNeeded());
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, ocFile.isDownloading());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, ocFile.getEtagInConflict());
|
||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, ocFile.getUnreadCommentsCount());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_ID, ocFile.getOwnerId());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, ocFile.getOwnerDisplayName());
|
||||
cv.put(ProviderTableMeta.FILE_NOTE, ocFile.getNote());
|
||||
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(ocFile.getSharees()));
|
||||
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, ocFile.getRichWorkspace());
|
||||
cv.put(ProviderTableMeta.FILE_HAS_PREVIEW, ocFile.isPreviewAvailable() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, ocFile.isFavorite());
|
||||
|
||||
boolean sameRemotePath = fileExists(ocFile.getRemotePath());
|
||||
if (sameRemotePath ||
|
||||
@@ -369,7 +337,8 @@ public class FileDataStorageManager {
|
||||
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
for (OCFile ocFile : updatedFiles) {
|
||||
ContentValues contentValues = createContentValueForFile(ocFile, folder);
|
||||
ContentValues contentValues = createContentValuesForFile(ocFile);
|
||||
contentValues.put(ProviderTableMeta.FILE_PARENT, folder.getFileId());
|
||||
|
||||
if (fileExists(ocFile.getFileId()) || fileExists(ocFile.getRemotePath())) {
|
||||
long fileId;
|
||||
@@ -423,7 +392,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
|
||||
// update metadata of folder
|
||||
ContentValues contentValues = createContentValueForFile(folder);
|
||||
ContentValues contentValues = createContentValuesForFolder(folder);
|
||||
|
||||
operations.add(ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI)
|
||||
.withValues(contentValues)
|
||||
@@ -467,76 +436,76 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
private ContentValues createContentValueForFile(OCFile folder) {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, folder.getModificationTimestamp());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
|
||||
folder.getModificationTimestampAtLastSyncForData()
|
||||
);
|
||||
cv.put(ProviderTableMeta.FILE_CREATION, folder.getCreationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, 0);
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, folder.getMimeType());
|
||||
cv.put(ProviderTableMeta.FILE_NAME, folder.getFileName());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, folder.getParentId());
|
||||
cv.put(ProviderTableMeta.FILE_PATH, folder.getRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, folder.getDecryptedRemotePath());
|
||||
/**
|
||||
* Returns a {@link ContentValues} filled with values that are common to both files and folders
|
||||
* @see #createContentValuesForFile(OCFile)
|
||||
* @see #createContentValuesForFolder(OCFile)
|
||||
*/
|
||||
private ContentValues createContentValuesBase(OCFile fileOrFolder) {
|
||||
final ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, fileOrFolder.getModificationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, fileOrFolder.getModificationTimestampAtLastSyncForData());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, fileOrFolder.getParentId());
|
||||
cv.put(ProviderTableMeta.FILE_CREATION, fileOrFolder.getCreationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, fileOrFolder.getMimeType());
|
||||
cv.put(ProviderTableMeta.FILE_NAME, fileOrFolder.getFileName());
|
||||
cv.put(ProviderTableMeta.FILE_PATH, fileOrFolder.getRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, fileOrFolder.getDecryptedRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, folder.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, folder.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, folder.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, folder.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, folder.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, folder.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, folder.getUnreadCommentsCount());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_ID, folder.getOwnerId());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, folder.getOwnerDisplayName());
|
||||
cv.put(ProviderTableMeta.FILE_NOTE, folder.getNote());
|
||||
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(folder.getSharees()));
|
||||
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, folder.getRichWorkspace());
|
||||
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, fileOrFolder.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, fileOrFolder.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, fileOrFolder.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, fileOrFolder.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, fileOrFolder.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, fileOrFolder.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, fileOrFolder.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, fileOrFolder.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, fileOrFolder.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, fileOrFolder.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, fileOrFolder.getUnreadCommentsCount());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_ID, fileOrFolder.getOwnerId());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, fileOrFolder.getOwnerDisplayName());
|
||||
cv.put(ProviderTableMeta.FILE_NOTE, fileOrFolder.getNote());
|
||||
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(fileOrFolder.getSharees()));
|
||||
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, fileOrFolder.getRichWorkspace());
|
||||
return cv;
|
||||
}
|
||||
|
||||
private ContentValues createContentValueForFile(OCFile file, OCFile folder) {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, file.getModificationTimestampAtLastSyncForData());
|
||||
cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
|
||||
/**
|
||||
* Returns a {@link ContentValues} filled with values for a folder
|
||||
* @see #createContentValuesForFile(OCFile)
|
||||
* @see #createContentValuesBase(OCFile)
|
||||
*/
|
||||
private ContentValues createContentValuesForFolder(OCFile folder) {
|
||||
final ContentValues cv = createContentValuesBase(folder);
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, 0);
|
||||
return cv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link ContentValues} filled with values for a file
|
||||
* @see #createContentValuesForFolder(OCFile)
|
||||
* @see #createContentValuesBase(OCFile)
|
||||
*/
|
||||
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
|
||||
private ContentValues createContentValuesForFile(OCFile file) {
|
||||
final ContentValues cv = createContentValuesBase(file);
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimeType());
|
||||
cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
|
||||
cv.put(ProviderTableMeta.FILE_ENCRYPTED_NAME, file.getEncryptedFileName());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, folder.getFileId());
|
||||
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, file.getDecryptedRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, file.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded());
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, file.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_MOUNT_TYPE, file.getMountType().ordinal());
|
||||
cv.put(ProviderTableMeta.FILE_HAS_PREVIEW, file.isPreviewAvailable() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_UNREAD_COMMENTS_COUNT, file.getUnreadCommentsCount());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_ID, file.getOwnerId());
|
||||
cv.put(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME, file.getOwnerDisplayName());
|
||||
cv.put(ProviderTableMeta.FILE_NOTE, file.getNote());
|
||||
cv.put(ProviderTableMeta.FILE_SHAREES, new Gson().toJson(file.getSharees()));
|
||||
cv.put(ProviderTableMeta.FILE_RICH_WORKSPACE, file.getRichWorkspace());
|
||||
cv.put(ProviderTableMeta.FILE_LOCKED, file.isLocked());
|
||||
final FileLockType lockType = file.getLockType();
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TYPE, lockType != null ? lockType.getValue() : -1);
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_OWNER, file.getLockOwnerId());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME, file.getLockOwnerDisplayName());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_OWNER_EDITOR, file.getLockOwnerEditor());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TIMESTAMP, file.getLockTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TIMEOUT, file.getLockTimeout());
|
||||
cv.put(ProviderTableMeta.FILE_LOCK_TOKEN, file.getLockToken());
|
||||
|
||||
return cv;
|
||||
}
|
||||
@@ -1030,6 +999,16 @@ public class FileDataStorageManager {
|
||||
ocFile.setOwnerDisplayName(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_OWNER_DISPLAY_NAME)));
|
||||
ocFile.setNote(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_NOTE)));
|
||||
ocFile.setRichWorkspace(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_RICH_WORKSPACE)));
|
||||
ocFile.setLocked(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCKED)) == 1);
|
||||
final int lockTypeInt = cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TYPE));
|
||||
ocFile.setLockType(lockTypeInt != -1 ? FileLockType.fromValue(lockTypeInt) : null);
|
||||
ocFile.setLockOwnerId(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_OWNER)));
|
||||
ocFile.setLockOwnerDisplayName(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME)));
|
||||
ocFile.setLockOwnerEditor(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_OWNER_EDITOR)));
|
||||
ocFile.setLockTimestamp(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TIMESTAMP)));
|
||||
ocFile.setLockTimeout(cursor.getInt(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TIMEOUT)));
|
||||
ocFile.setLockToken(cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_LOCK_TOKEN)));
|
||||
|
||||
|
||||
String sharees = cursor.getString(cursor.getColumnIndexOrThrow(ProviderTableMeta.FILE_SHAREES));
|
||||
|
||||
@@ -1192,12 +1171,12 @@ public class FileDataStorageManager {
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
|
||||
|
||||
if (!ShareType.PUBLIC_LINK.equals(type)) {
|
||||
if (ShareType.PUBLIC_LINK != type) {
|
||||
selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?";
|
||||
}
|
||||
|
||||
String[] selectionArgs;
|
||||
if (ShareType.PUBLIC_LINK.equals(type)) {
|
||||
if (ShareType.PUBLIC_LINK == type) {
|
||||
selectionArgs = new String[]{
|
||||
path,
|
||||
Integer.toString(type.getValue()),
|
||||
@@ -1424,86 +1403,6 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSharedFiles(Collection<OCFile> sharedFiles) {
|
||||
resetShareFlagsInAllFiles();
|
||||
|
||||
if (sharedFiles != null) {
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>(sharedFiles.size());
|
||||
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
for (OCFile file : sharedFiles) {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
|
||||
file.getModificationTimestampAtLastSyncForData()
|
||||
);
|
||||
cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
|
||||
cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimeType());
|
||||
cv.put(ProviderTableMeta.FILE_NAME, file.getFileName());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId());
|
||||
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
|
||||
if (!file.isFolder()) {
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
|
||||
file.getLastSyncDateForData()
|
||||
);
|
||||
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_ON_SERVER, file.getEtagOnServer());
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
|
||||
|
||||
boolean existsByPath = fileExists(file.getRemotePath());
|
||||
if (existsByPath || fileExists(file.getFileId())) {
|
||||
// updating an existing file
|
||||
operations.add(
|
||||
ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
|
||||
withValues(cv).
|
||||
withSelection(ProviderTableMeta._ID + "=?",
|
||||
new String[]{String.valueOf(file.getFileId())})
|
||||
.build());
|
||||
|
||||
} else {
|
||||
// adding a new file
|
||||
operations.add(
|
||||
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI).
|
||||
withValues(cv).
|
||||
build()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// apply operations in batch
|
||||
if (operations.size() > 0) {
|
||||
@SuppressWarnings("unused")
|
||||
ContentProviderResult[] results = null;
|
||||
Log_OC.d(TAG, String.format(Locale.ENGLISH, SENDING_TO_FILECONTENTPROVIDER_MSG, operations.size()));
|
||||
try {
|
||||
if (getContentResolver() != null) {
|
||||
results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||
} else {
|
||||
results = getContentProviderClient().applyBatch(operations);
|
||||
}
|
||||
|
||||
} catch (OperationApplicationException | RemoteException e) {
|
||||
Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void removeShare(OCShare share) {
|
||||
Uri contentUriShare = ProviderTableMeta.CONTENT_URI_SHARE;
|
||||
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND +
|
||||
@@ -2075,6 +1974,8 @@ public class FileDataStorageManager {
|
||||
contentValues.put(ProviderTableMeta.CAPABILITIES_USER_STATUS, capability.getUserStatus().getValue());
|
||||
contentValues.put(ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI,
|
||||
capability.getUserStatusSupportsEmoji().getValue());
|
||||
contentValues.put(ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION,
|
||||
capability.getFilesLockingVersion());
|
||||
|
||||
return contentValues;
|
||||
}
|
||||
@@ -2224,6 +2125,8 @@ public class FileDataStorageManager {
|
||||
capability.setUserStatus(getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS));
|
||||
capability.setUserStatusSupportsEmoji(
|
||||
getBoolean(cursor, ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI));
|
||||
capability.setFilesLockingVersion(
|
||||
getString(cursor, ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION));
|
||||
}
|
||||
return capability;
|
||||
}
|
||||
@@ -2258,22 +2161,6 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveVirtual(VirtualFolderType type, OCFile file) {
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.VIRTUAL_TYPE, type.toString());
|
||||
cv.put(ProviderTableMeta.VIRTUAL_OCFILE_ID, file.getFileId());
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().insert(ProviderTableMeta.CONTENT_URI_VIRTUAL, cv);
|
||||
} else {
|
||||
try {
|
||||
getContentProviderClient().insert(ProviderTableMeta.CONTENT_URI_VIRTUAL, cv);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<OCFile> getAllGalleryItems() {
|
||||
return getGalleryItems(0, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2022 Tobias Kaminsky
|
||||
* Copyright (C) 2022 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datamodel
|
||||
|
||||
data class GalleryItems(val date: Long, val files: List<OCFile>)
|
||||
@@ -21,17 +21,16 @@
|
||||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -42,6 +41,8 @@ import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* Media queries to gain access to media lists for the device.
|
||||
*/
|
||||
@@ -71,10 +72,13 @@ public final class MediaProvider {
|
||||
* @param itemLimit the number of media items (usually images) to be returned per media folder.
|
||||
* @return list with media folders
|
||||
*/
|
||||
public static List<MediaFolder> getImageFolders(ContentResolver contentResolver, int itemLimit,
|
||||
@Nullable final Activity activity, boolean getWithoutActivity) {
|
||||
public static List<MediaFolder> getImageFolders(ContentResolver contentResolver,
|
||||
int itemLimit,
|
||||
@Nullable final AppCompatActivity activity,
|
||||
boolean getWithoutActivity,
|
||||
ThemeSnackbarUtils themeSnackbarUtils) {
|
||||
// check permissions
|
||||
checkPermissions(activity);
|
||||
checkPermissions(activity, themeSnackbarUtils);
|
||||
|
||||
// query media/image folders
|
||||
Cursor cursorFolders = null;
|
||||
@@ -171,31 +175,21 @@ public final class MediaProvider {
|
||||
return filePath != null && filePath.lastIndexOf('/') > 0 && new File(filePath).exists();
|
||||
}
|
||||
|
||||
private static void checkPermissions(@Nullable Activity activity) {
|
||||
private static void checkPermissions(@Nullable AppCompatActivity activity,
|
||||
ThemeSnackbarUtils themeSnackbarUtils) {
|
||||
if (activity != null &&
|
||||
!PermissionUtil.checkExternalStoragePermission(activity.getApplicationContext())) {
|
||||
// Check if we should show an explanation
|
||||
if (PermissionUtil
|
||||
.shouldShowRequestPermissionRationale(activity, PermissionUtil.getExternalStoragePermission())) {
|
||||
// Show explanation to the user and then request permission
|
||||
Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.ListLayout),
|
||||
R.string.permission_storage_access, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(R.string.common_ok, v -> PermissionUtil.requestExternalStoragePermission(activity));
|
||||
|
||||
ThemeSnackbarUtils.colorSnackbar(activity.getApplicationContext(), snackbar);
|
||||
|
||||
snackbar.show();
|
||||
} else {
|
||||
// No explanation needed, request the permission.
|
||||
PermissionUtil.requestExternalStoragePermission(activity);
|
||||
}
|
||||
PermissionUtil.requestExternalStoragePermission(activity, themeSnackbarUtils, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<MediaFolder> getVideoFolders(ContentResolver contentResolver, int itemLimit,
|
||||
@Nullable final Activity activity, boolean getWithoutActivity) {
|
||||
public static List<MediaFolder> getVideoFolders(ContentResolver contentResolver,
|
||||
int itemLimit,
|
||||
@Nullable final AppCompatActivity activity,
|
||||
boolean getWithoutActivity,
|
||||
ThemeSnackbarUtils themeSnackbarUtils) {
|
||||
// check permissions
|
||||
checkPermissions(activity);
|
||||
checkPermissions(activity, themeSnackbarUtils);
|
||||
|
||||
// query media/image folders
|
||||
Cursor cursorFolders = null;
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.network.WebdavEntry;
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.model.FileLockType;
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
@@ -68,6 +69,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* synchronization of THE CONTENTS of this file.
|
||||
*/
|
||||
private long modificationTimestampAtLastSyncForData;
|
||||
private long firstShareTimestamp; // UNIX timestamp of the first share time
|
||||
private String remotePath;
|
||||
private String decryptedRemotePath;
|
||||
private String localPath;
|
||||
@@ -94,10 +96,23 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
String note;
|
||||
private List<ShareeUser> sharees;
|
||||
private String richWorkspace;
|
||||
private boolean locked;
|
||||
@Nullable
|
||||
private FileLockType lockType;
|
||||
@Nullable
|
||||
private String lockOwnerId;
|
||||
@Nullable
|
||||
private String lockOwnerDisplayName;
|
||||
@Nullable
|
||||
private String lockOwnerEditor;
|
||||
private long lockTimestamp;
|
||||
private long lockTimeout;
|
||||
@Nullable
|
||||
private String lockToken;
|
||||
|
||||
/**
|
||||
* URI to the local path of the file contents, if stored in the device; cached after first call
|
||||
* to {@link #getStorageUri()}
|
||||
* URI to the local path of the file contents, if stored in the device; cached after first call to {@link
|
||||
* #getStorageUri()}
|
||||
*/
|
||||
private Uri localUri;
|
||||
|
||||
@@ -160,6 +175,15 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
mountType = (WebdavEntry.MountType) source.readSerializable();
|
||||
richWorkspace = source.readString();
|
||||
previewAvailable = source.readInt() == 1;
|
||||
firstShareTimestamp = source.readLong();
|
||||
locked = source.readInt() == 1;
|
||||
lockType = FileLockType.fromValue(source.readInt());
|
||||
lockOwnerId = source.readString();
|
||||
lockOwnerDisplayName = source.readString();
|
||||
lockOwnerEditor = source.readString();
|
||||
lockTimestamp = source.readLong();
|
||||
lockTimeout = source.readLong();
|
||||
lockToken = source.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,6 +217,15 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
dest.writeSerializable(mountType);
|
||||
dest.writeString(richWorkspace);
|
||||
dest.writeInt(previewAvailable ? 1 : 0);
|
||||
dest.writeLong(firstShareTimestamp);
|
||||
dest.writeInt(locked ? 1 : 0);
|
||||
dest.writeInt(lockType != null ? lockType.getValue() : -1);
|
||||
dest.writeString(lockOwnerId);
|
||||
dest.writeString(lockOwnerDisplayName);
|
||||
dest.writeString(lockOwnerEditor);
|
||||
dest.writeLong(lockTimestamp);
|
||||
dest.writeLong(lockTimeout);
|
||||
dest.writeString(lockToken);
|
||||
}
|
||||
|
||||
public void setDecryptedRemotePath(String path) {
|
||||
@@ -455,6 +488,15 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
encrypted = false;
|
||||
mountType = WebdavEntry.MountType.INTERNAL;
|
||||
richWorkspace = "";
|
||||
firstShareTimestamp = 0;
|
||||
locked = false;
|
||||
lockType = null;
|
||||
lockOwnerId = null;
|
||||
lockOwnerDisplayName = null;
|
||||
lockOwnerEditor = null;
|
||||
lockTimestamp = 0;
|
||||
lockTimeout = 0;
|
||||
lockToken = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -819,4 +861,81 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
public void setRichWorkspace(String richWorkspace) {
|
||||
this.richWorkspace = richWorkspace;
|
||||
}
|
||||
|
||||
public long getFirstShareTimestamp() {
|
||||
return firstShareTimestamp;
|
||||
}
|
||||
|
||||
public void setFirstShareTimestamp(long firstShareTimestamp) {
|
||||
this.firstShareTimestamp = firstShareTimestamp;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FileLockType getLockType() {
|
||||
return lockType;
|
||||
}
|
||||
|
||||
public void setLockType(@Nullable FileLockType lockType) {
|
||||
this.lockType = lockType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLockOwnerId() {
|
||||
return lockOwnerId;
|
||||
}
|
||||
|
||||
public void setLockOwnerId(@Nullable String lockOwnerId) {
|
||||
this.lockOwnerId = lockOwnerId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLockOwnerDisplayName() {
|
||||
return lockOwnerDisplayName;
|
||||
}
|
||||
|
||||
public void setLockOwnerDisplayName(@Nullable String lockOwnerDisplayName) {
|
||||
this.lockOwnerDisplayName = lockOwnerDisplayName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLockOwnerEditor() {
|
||||
return lockOwnerEditor;
|
||||
}
|
||||
|
||||
public void setLockOwnerEditor(@Nullable String lockOwnerEditor) {
|
||||
this.lockOwnerEditor = lockOwnerEditor;
|
||||
}
|
||||
|
||||
public long getLockTimestamp() {
|
||||
return lockTimestamp;
|
||||
}
|
||||
|
||||
public void setLockTimestamp(long lockTimestamp) {
|
||||
this.lockTimestamp = lockTimestamp;
|
||||
}
|
||||
|
||||
public long getLockTimeout() {
|
||||
return lockTimeout;
|
||||
}
|
||||
|
||||
public void setLockTimeout(long lockTimeout) {
|
||||
this.lockTimeout = lockTimeout;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getLockToken() {
|
||||
return lockToken;
|
||||
}
|
||||
|
||||
public void setLockToken(@Nullable String lockToken) {
|
||||
this.lockToken = lockToken;
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,8 @@ import com.owncloud.android.utils.BitmapUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
@@ -251,14 +253,14 @@ public final class ThumbnailsCacheManager {
|
||||
}
|
||||
|
||||
public static class ResizedImageGenerationTask extends AsyncTask<Object, Void, Bitmap> {
|
||||
private FileFragment fileFragment;
|
||||
private FileDataStorageManager storageManager;
|
||||
private User user;
|
||||
private WeakReference<ImageView> imageViewReference;
|
||||
private WeakReference<FrameLayout> frameLayoutReference;
|
||||
private final FileFragment fileFragment;
|
||||
private final FileDataStorageManager storageManager;
|
||||
private final User user;
|
||||
private final WeakReference<ImageView> imageViewReference;
|
||||
private final WeakReference<FrameLayout> frameLayoutReference;
|
||||
private OCFile file;
|
||||
private ConnectivityService connectivityService;
|
||||
private int backgroundColor;
|
||||
private final ConnectivityService connectivityService;
|
||||
private final int backgroundColor;
|
||||
|
||||
|
||||
public ResizedImageGenerationTask(FileFragment fileFragment,
|
||||
@@ -416,8 +418,8 @@ public final class ThumbnailsCacheManager {
|
||||
}
|
||||
|
||||
public static class ThumbnailGenerationTaskObject {
|
||||
private Object file;
|
||||
private String imageKey;
|
||||
private final Object file;
|
||||
private final String imageKey;
|
||||
|
||||
public ThumbnailGenerationTaskObject(Object file, String imageKey) {
|
||||
this.file = file;
|
||||
@@ -462,19 +464,27 @@ public final class ThumbnailsCacheManager {
|
||||
mAsyncTasks = asyncTasks;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
|
||||
User user, List<ThumbnailGenerationTask> asyncTasks,
|
||||
boolean gridViewEnabled)
|
||||
public ThumbnailGenerationTask(ImageView imageView,
|
||||
FileDataStorageManager storageManager,
|
||||
User user,
|
||||
List<ThumbnailGenerationTask> asyncTasks,
|
||||
boolean gridViewEnabled,
|
||||
String imageKey)
|
||||
throws IllegalArgumentException {
|
||||
this(imageView, storageManager, user, asyncTasks);
|
||||
this.gridViewEnabled = gridViewEnabled;
|
||||
mImageKey = imageKey;
|
||||
}
|
||||
|
||||
public GetMethod getGetMethod() {
|
||||
return getMethod;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, User user){
|
||||
public String getImageKey() {
|
||||
return mImageKey;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(FileDataStorageManager storageManager, User user) {
|
||||
if (storageManager == null) {
|
||||
throw new IllegalArgumentException("storageManager must not be NULL");
|
||||
}
|
||||
@@ -730,15 +740,23 @@ public final class ThumbnailsCacheManager {
|
||||
private static final int IMAGE_KEY_PARAMS_LENGTH = 2;
|
||||
|
||||
private enum Type {IMAGE, VIDEO}
|
||||
|
||||
private final WeakReference<ImageView> mImageViewReference;
|
||||
private File mFile;
|
||||
private String mImageKey;
|
||||
private Context mContext;
|
||||
private final Context mContext;
|
||||
private final ThemeColorUtils themeColorUtils;
|
||||
private final ThemeDrawableUtils themeDrawableUtils;
|
||||
|
||||
public MediaThumbnailGenerationTask(ImageView imageView, Context context) {
|
||||
public MediaThumbnailGenerationTask(ImageView imageView,
|
||||
Context context,
|
||||
ThemeColorUtils themeColorUtils,
|
||||
ThemeDrawableUtils themeDrawableUtils) {
|
||||
// Use a WeakReference to ensure the ImageView can be garbage collected
|
||||
mImageViewReference = new WeakReference<>(imageView);
|
||||
mContext = context;
|
||||
this.themeColorUtils = themeColorUtils;
|
||||
this.themeDrawableUtils = themeDrawableUtils;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -785,13 +803,18 @@ public final class ThumbnailsCacheManager {
|
||||
} else {
|
||||
if (mFile != null) {
|
||||
if (mFile.isDirectory()) {
|
||||
imageView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(mContext));
|
||||
imageView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(mContext,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils));
|
||||
} else {
|
||||
if (MimeTypeUtil.isVideo(mFile)) {
|
||||
imageView.setImageBitmap(ThumbnailsCacheManager.mDefaultVideo);
|
||||
} else {
|
||||
imageView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(null, mFile.getName(),
|
||||
mContext));
|
||||
imageView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(null,
|
||||
mFile.getName(),
|
||||
mContext,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -814,7 +837,7 @@ public final class ThumbnailsCacheManager {
|
||||
// Not found in disk cache
|
||||
if (thumbnail == null) {
|
||||
|
||||
if (Type.IMAGE.equals(type)) {
|
||||
if (Type.IMAGE == type) {
|
||||
int px = getThumbnailDimension();
|
||||
|
||||
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getAbsolutePath(), px, px);
|
||||
@@ -822,7 +845,7 @@ public final class ThumbnailsCacheManager {
|
||||
if (bitmap != null) {
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), px, px);
|
||||
}
|
||||
} else if (Type.VIDEO.equals(type)) {
|
||||
} else if (Type.VIDEO == type) {
|
||||
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
|
||||
try {
|
||||
retriever.setDataSource(file.getAbsolutePath());
|
||||
@@ -862,11 +885,11 @@ public final class ThumbnailsCacheManager {
|
||||
private final Object mCallContext;
|
||||
private final Resources mResources;
|
||||
private final float mAvatarRadius;
|
||||
private User user;
|
||||
private String mUserId;
|
||||
private String displayName;
|
||||
private String mServerName;
|
||||
private Context mContext;
|
||||
private final User user;
|
||||
private final String mUserId;
|
||||
private final String displayName;
|
||||
private final String mServerName;
|
||||
private final Context mContext;
|
||||
|
||||
|
||||
public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener,
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ProviderMeta {
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 62;
|
||||
public static final int DB_VERSION = 63;
|
||||
|
||||
private ProviderMeta() {
|
||||
// No instance
|
||||
@@ -117,6 +117,14 @@ public class ProviderMeta {
|
||||
public static final String FILE_NOTE = "note";
|
||||
public static final String FILE_SHAREES = "sharees";
|
||||
public static final String FILE_RICH_WORKSPACE = "rich_workspace";
|
||||
public static final String FILE_LOCKED = "locked";
|
||||
public static final String FILE_LOCK_TYPE = "lock_type";
|
||||
public static final String FILE_LOCK_OWNER = "lock_owner";
|
||||
public static final String FILE_LOCK_OWNER_DISPLAY_NAME = "lock_owner_display_name";
|
||||
public static final String FILE_LOCK_OWNER_EDITOR = "lock_owner_editor";
|
||||
public static final String FILE_LOCK_TIMESTAMP = "lock_timestamp";
|
||||
public static final String FILE_LOCK_TIMEOUT = "lock_timeout";
|
||||
public static final String FILE_LOCK_TOKEN = "lock_token";
|
||||
|
||||
public static final List<String> FILE_ALL_COLUMNS = Collections.unmodifiableList(Arrays.asList(
|
||||
_ID,
|
||||
@@ -153,8 +161,15 @@ public class ProviderMeta {
|
||||
FILE_OWNER_DISPLAY_NAME,
|
||||
FILE_NOTE,
|
||||
FILE_SHAREES,
|
||||
FILE_RICH_WORKSPACE));
|
||||
|
||||
FILE_RICH_WORKSPACE,
|
||||
FILE_LOCKED,
|
||||
FILE_LOCK_TYPE,
|
||||
FILE_LOCK_OWNER,
|
||||
FILE_LOCK_OWNER_DISPLAY_NAME,
|
||||
FILE_LOCK_OWNER_EDITOR,
|
||||
FILE_LOCK_TIMESTAMP,
|
||||
FILE_LOCK_TIMEOUT,
|
||||
FILE_LOCK_TOKEN));
|
||||
public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME + " collate nocase asc";
|
||||
|
||||
// Columns of ocshares table
|
||||
@@ -210,6 +225,7 @@ public class ProviderMeta {
|
||||
public static final String CAPABILITIES_FILES_BIGFILECHUNKING = "files_bigfilechunking";
|
||||
public static final String CAPABILITIES_FILES_UNDELETE = "files_undelete";
|
||||
public static final String CAPABILITIES_FILES_VERSIONING = "files_versioning";
|
||||
public static final String CAPABILITIES_FILES_LOCKING_VERSION = "files_locking_version";
|
||||
public static final String CAPABILITIES_EXTERNAL_LINKS = "external_links";
|
||||
public static final String CAPABILITIES_SERVER_NAME = "server_name";
|
||||
public static final String CAPABILITIES_SERVER_COLOR = "server_color";
|
||||
|
||||
@@ -36,6 +36,9 @@ import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -57,12 +60,13 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
|
||||
@Inject PowerManagementService powerManagementService;
|
||||
@Inject BackgroundJobManager backgroundJobManager;
|
||||
@Inject Clock clock;
|
||||
@Inject ThemeSnackbarUtils themeSnackbarUtils;
|
||||
|
||||
/**
|
||||
* Receives broadcast intent reporting that the system was just boot up.
|
||||
**
|
||||
* @param context The context where the receiver is running.
|
||||
* @param intent The intent received.
|
||||
* Receives broadcast intent reporting that the system was just boot up. *
|
||||
*
|
||||
* @param context The context where the receiver is running.
|
||||
* @param intent The intent received.
|
||||
*/
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -75,7 +79,8 @@ public class BootupBroadcastReceiver extends BroadcastReceiver {
|
||||
connectivityService,
|
||||
powerManagementService,
|
||||
backgroundJobManager,
|
||||
clock);
|
||||
clock,
|
||||
themeSnackbarUtils);
|
||||
MainApp.initContactsBackup(accountManager, backgroundJobManager);
|
||||
} else {
|
||||
Log_OC.d(TAG, "Getting wrong intent: " + intent.getAction());
|
||||
|
||||
@@ -21,12 +21,14 @@
|
||||
|
||||
package com.owncloud.android.files;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.nextcloud.android.files.FileLockingHelper;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
@@ -58,12 +60,13 @@ public class FileMenuFilter {
|
||||
private static final int SINGLE_SELECT_ITEMS = 1;
|
||||
public static final String SEND_OFF = "off";
|
||||
|
||||
private int numberOfAllFiles;
|
||||
private Collection<OCFile> files;
|
||||
private ComponentsGetter componentsGetter;
|
||||
private Context context;
|
||||
private boolean overflowMenu;
|
||||
private User user;
|
||||
private final int numberOfAllFiles;
|
||||
private final Collection<OCFile> files;
|
||||
private final ComponentsGetter componentsGetter;
|
||||
private final Context context;
|
||||
private final boolean overflowMenu;
|
||||
private final User user;
|
||||
private final String userId;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -88,6 +91,10 @@ public class FileMenuFilter {
|
||||
this.context = context;
|
||||
this.overflowMenu = overflowMenu;
|
||||
this.user = user;
|
||||
userId = AccountManager
|
||||
.get(context)
|
||||
.getUserData(this.user.toPlatformAccount(),
|
||||
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,11 +132,23 @@ public class FileMenuFilter {
|
||||
filter(toShow, toHide, inSingleFileFragment);
|
||||
|
||||
for (int i : toShow) {
|
||||
showMenuItem(menu.findItem(i));
|
||||
final MenuItem item = menu.findItem(i);
|
||||
if (item != null) {
|
||||
showMenuItem(item);
|
||||
} else {
|
||||
// group
|
||||
menu.setGroupVisible(i, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : toHide) {
|
||||
hideMenuItem(menu.findItem(i));
|
||||
final MenuItem item = menu.findItem(i);
|
||||
if (item != null) {
|
||||
hideMenuItem(item);
|
||||
} else {
|
||||
// group
|
||||
menu.setGroupVisible(i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,11 +200,13 @@ public class FileMenuFilter {
|
||||
boolean synchronizing = anyFileSynchronizing();
|
||||
OCCapability capability = componentsGetter.getStorageManager().getCapability(user.getAccountName());
|
||||
boolean endToEndEncryptionEnabled = capability.getEndToEndEncryption().isTrue();
|
||||
boolean fileLockingEnabled = capability.getFilesLockingVersion() != null;
|
||||
|
||||
filterEdit(toShow, toHide, capability);
|
||||
filterDownload(toShow, toHide, synchronizing);
|
||||
filterRename(toShow, toHide, synchronizing);
|
||||
filterMoveCopy(toShow, toHide, synchronizing);
|
||||
filterCopy(toShow, toHide, synchronizing);
|
||||
filterMove(toShow, toHide, synchronizing);
|
||||
filterRemove(toShow, toHide, synchronizing);
|
||||
filterSelectAll(toShow, toHide, inSingleFileFragment);
|
||||
filterDeselectAll(toShow, toHide, inSingleFileFragment);
|
||||
@@ -201,6 +222,9 @@ public class FileMenuFilter {
|
||||
filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled);
|
||||
filterSetPictureAs(toShow, toHide);
|
||||
filterStream(toShow, toHide);
|
||||
filterLock(toShow, toHide, fileLockingEnabled);
|
||||
filterUnlock(toShow, toHide, fileLockingEnabled);
|
||||
filterLockInfo(toShow, toHide, fileLockingEnabled);
|
||||
}
|
||||
|
||||
private void filterShareFile(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
|
||||
@@ -252,9 +276,48 @@ public class FileMenuFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterLock(List<Integer> toShow, List<Integer> toHide, boolean fileLockingEnabled) {
|
||||
if (files.isEmpty() || !isSingleSelection() || !fileLockingEnabled) {
|
||||
toHide.add(R.id.action_lock_file);
|
||||
} else {
|
||||
OCFile file = files.iterator().next();
|
||||
if (file.isLocked() || file.isFolder()) {
|
||||
toHide.add(R.id.action_lock_file);
|
||||
} else {
|
||||
toShow.add(R.id.action_lock_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void filterUnlock(List<Integer> toShow, List<Integer> toHide, boolean fileLockingEnabled) {
|
||||
if (files.isEmpty() || !isSingleSelection() || !fileLockingEnabled) {
|
||||
toHide.add(R.id.action_unlock_file);
|
||||
} else {
|
||||
OCFile file = files.iterator().next();
|
||||
if (FileLockingHelper.canUserUnlockFile(userId, file)) {
|
||||
toShow.add(R.id.action_unlock_file);
|
||||
} else {
|
||||
toHide.add(R.id.action_unlock_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void filterLockInfo(List<Integer> toShow, List<Integer> toHide, boolean fileLockingEnabled) {
|
||||
if (files.isEmpty() || !isSingleSelection() || !fileLockingEnabled) {
|
||||
toHide.add(R.id.menu_group_lock_info);
|
||||
} else {
|
||||
OCFile file = files.iterator().next();
|
||||
if (file.isLocked()) {
|
||||
toShow.add(R.id.menu_group_lock_info);
|
||||
} else {
|
||||
toHide.add(R.id.menu_group_lock_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void filterEncrypt(List<Integer> toShow, List<Integer> toHide, boolean endToEndEncryptionEnabled) {
|
||||
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || isEncryptedFolder()
|
||||
|| !endToEndEncryptionEnabled) {
|
||||
|| !endToEndEncryptionEnabled) {
|
||||
toHide.add(R.id.action_encrypted);
|
||||
} else {
|
||||
toShow.add(R.id.action_encrypted);
|
||||
@@ -391,25 +454,32 @@ public class FileMenuFilter {
|
||||
}
|
||||
|
||||
private void filterRemove(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (files.isEmpty() || synchronizing || containsEncryptedFolder()) {
|
||||
if (files.isEmpty() || synchronizing || containsEncryptedFolder() || containsLockedFile()) {
|
||||
toHide.add(R.id.action_remove_file);
|
||||
} else {
|
||||
toShow.add(R.id.action_remove_file);
|
||||
}
|
||||
}
|
||||
|
||||
private void filterMoveCopy(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
|
||||
private void filterMove(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
|
||||
toHide.add(R.id.action_move);
|
||||
toHide.add(R.id.action_copy);
|
||||
} else {
|
||||
toShow.add(R.id.action_move);
|
||||
}
|
||||
}
|
||||
|
||||
private void filterCopy(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
|
||||
toHide.add(R.id.action_copy);
|
||||
} else {
|
||||
toShow.add(R.id.action_copy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void filterRename(Collection<Integer> toShow, Collection<Integer> toHide, boolean synchronizing) {
|
||||
if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) {
|
||||
if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) {
|
||||
toHide.add(R.id.action_rename_file);
|
||||
} else {
|
||||
toShow.add(R.id.action_rename_file);
|
||||
@@ -528,6 +598,15 @@ public class FileMenuFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean containsLockedFile() {
|
||||
for (OCFile file : files) {
|
||||
if (file.isLocked()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean containsEncryptedFolder() {
|
||||
for (OCFile file : files) {
|
||||
if (file.isFolder() && file.isEncrypted()) {
|
||||
|
||||
@@ -125,6 +125,7 @@ public class FileDownloader extends Service
|
||||
@Inject UserAccountManager accountManager;
|
||||
@Inject UploadsStorageManager uploadsStorageManager;
|
||||
@Inject LocalBroadcastManager localBroadcastManager;
|
||||
@Inject ThemeColorUtils themeColorUtils;
|
||||
|
||||
public static String getDownloadAddedMessage() {
|
||||
return FileDownloader.class.getName() + DOWNLOAD_ADDED_MESSAGE;
|
||||
@@ -150,11 +151,11 @@ public class FileDownloader extends Service
|
||||
mBinder = new FileDownloaderBinder();
|
||||
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setContentTitle(
|
||||
getApplicationContext().getResources().getString(R.string.app_name))
|
||||
.setContentText(getApplicationContext().getResources().getString(R.string.foreground_service_download))
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
|
||||
.setColor(ThemeColorUtils.primaryColor(getApplicationContext(), true));
|
||||
getApplicationContext().getResources().getString(R.string.app_name))
|
||||
.setContentText(getApplicationContext().getResources().getString(R.string.foreground_service_download))
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
|
||||
.setColor(themeColorUtils.primaryColor(getApplicationContext(), true));
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
|
||||
@@ -314,20 +315,13 @@ public class FileDownloader extends Service
|
||||
|
||||
/**
|
||||
* Cancels all the downloads for an account
|
||||
*
|
||||
* @param account ownCloud account.
|
||||
*/
|
||||
public void cancel(Account account) {
|
||||
Log_OC.d(TAG, "Account= " + account.name);
|
||||
|
||||
if (mCurrentDownload != null) {
|
||||
Log_OC.d(TAG, "Current Download Account= " + mCurrentDownload.getAccount().name);
|
||||
if (mCurrentDownload.getAccount().name.equals(account.name)) {
|
||||
mCurrentDownload.cancel();
|
||||
}
|
||||
public void cancel(String accountName) {
|
||||
if (mCurrentDownload != null && mCurrentDownload.getUser().nameEquals(accountName)) {
|
||||
mCurrentDownload.cancel();
|
||||
}
|
||||
// Cancel pending downloads
|
||||
cancelDownloadsForAccount(account);
|
||||
cancelPendingDownloads(accountName);
|
||||
}
|
||||
|
||||
public void clearListeners() {
|
||||
@@ -491,15 +485,10 @@ public class FileDownloader extends Service
|
||||
|
||||
/// notify result
|
||||
notifyDownloadResult(mCurrentDownload, downloadResult);
|
||||
|
||||
sendBroadcastDownloadFinished(mCurrentDownload, downloadResult, removeResult.second);
|
||||
}
|
||||
|
||||
} else {
|
||||
// Cancel the transfer
|
||||
Log_OC.d(TAG, "Account " + mCurrentDownload.getAccount() + " doesn't exist");
|
||||
cancelDownloadsForAccount(mCurrentDownload.getAccount());
|
||||
|
||||
cancelPendingDownloads(mCurrentDownload.getUser().getAccountName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,17 +539,17 @@ public class FileDownloader extends Service
|
||||
private void notifyDownloadStart(DownloadFileOperation download) {
|
||||
/// create status notification with a progress bar
|
||||
mLastPercent = 0;
|
||||
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this);
|
||||
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this, themeColorUtils);
|
||||
mNotificationBuilder
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setTicker(getString(R.string.downloader_download_in_progress_ticker))
|
||||
.setContentTitle(getString(R.string.downloader_download_in_progress_ticker))
|
||||
.setOngoing(true)
|
||||
.setProgress(100, 0, download.getSize() < 0)
|
||||
.setContentText(
|
||||
String.format(getString(R.string.downloader_download_in_progress_content), 0,
|
||||
new File(download.getSavePath()).getName())
|
||||
);
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setTicker(getString(R.string.downloader_download_in_progress_ticker))
|
||||
.setContentTitle(getString(R.string.downloader_download_in_progress_ticker))
|
||||
.setOngoing(true)
|
||||
.setProgress(100, 0, download.getSize() < 0)
|
||||
.setContentText(
|
||||
String.format(getString(R.string.downloader_download_in_progress_content), 0,
|
||||
new File(download.getSavePath()).getName())
|
||||
);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
|
||||
@@ -640,7 +629,7 @@ public class FileDownloader extends Service
|
||||
int tickerId = downloadResult.isSuccess() ?
|
||||
R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
|
||||
|
||||
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(downloadResult.getCode());
|
||||
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED == downloadResult.getCode();
|
||||
tickerId = needsToUpdateCredentials ?
|
||||
R.string.downloader_download_failed_credentials_error : tickerId;
|
||||
|
||||
@@ -741,13 +730,7 @@ public class FileDownloader extends Service
|
||||
localBroadcastManager.sendBroadcast(added);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove downloads of an account
|
||||
*
|
||||
* @param account Downloads account to remove
|
||||
*/
|
||||
private void cancelDownloadsForAccount(Account account) {
|
||||
// Cancel pending downloads
|
||||
mPendingDownloads.remove(account.name);
|
||||
private void cancelPendingDownloads(String accountName) {
|
||||
mPendingDownloads.remove(accountName);
|
||||
}
|
||||
}
|
||||
@@ -194,6 +194,7 @@ public class FileUploader extends Service
|
||||
@Inject ConnectivityService connectivityService;
|
||||
@Inject PowerManagementService powerManagementService;
|
||||
@Inject LocalBroadcastManager localBroadcastManager;
|
||||
@Inject ThemeColorUtils themeColorUtils;
|
||||
|
||||
private IndexedForest<UploadFileOperation> mPendingUploads = new IndexedForest<>();
|
||||
|
||||
@@ -234,7 +235,7 @@ public class FileUploader extends Service
|
||||
.setContentText(getApplicationContext().getResources().getString(R.string.foreground_service_upload))
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_icon))
|
||||
.setColor(ThemeColorUtils.primaryColor(getApplicationContext(), true));
|
||||
.setColor(themeColorUtils.primaryColor(getApplicationContext(), true));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD);
|
||||
@@ -602,7 +603,7 @@ public class FileUploader extends Service
|
||||
if (!accountManager.exists(mCurrentUpload.getAccount())) {
|
||||
Log_OC.w(TAG, "Account " + mCurrentUpload.getAccount().name +
|
||||
" does not exist anymore -> cancelling all its uploads");
|
||||
cancelUploadsForAccount(mCurrentUpload.getAccount());
|
||||
cancelPendingUploads(mCurrentUpload.getUser().getAccountName());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -700,7 +701,7 @@ public class FileUploader extends Service
|
||||
private void notifyUploadStart(UploadFileOperation upload) {
|
||||
// / create status notification with a progress bar
|
||||
mLastPercent = 0;
|
||||
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this);
|
||||
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this, themeColorUtils);
|
||||
mNotificationBuilder
|
||||
.setOngoing(true)
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
@@ -709,7 +710,7 @@ public class FileUploader extends Service
|
||||
.setProgress(100, 0, false)
|
||||
.setContentText(
|
||||
String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName())
|
||||
);
|
||||
);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_UPLOAD);
|
||||
@@ -778,11 +779,11 @@ public class FileUploader extends Service
|
||||
// Only notify if the upload fails
|
||||
if (!uploadResult.isCancelled() &&
|
||||
!uploadResult.isSuccess() &&
|
||||
!ResultCode.LOCAL_FILE_NOT_FOUND.equals(uploadResult.getCode()) &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_WIFI) &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_CHARGING) &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_IN_POWER_SAVE_MODE) &&
|
||||
!uploadResult.getCode().equals(ResultCode.LOCK_FAILED)) {
|
||||
ResultCode.LOCAL_FILE_NOT_FOUND != uploadResult.getCode() &&
|
||||
uploadResult.getCode() != ResultCode.DELAYED_FOR_WIFI &&
|
||||
uploadResult.getCode() != ResultCode.DELAYED_FOR_CHARGING &&
|
||||
uploadResult.getCode() != ResultCode.DELAYED_IN_POWER_SAVE_MODE &&
|
||||
uploadResult.getCode() != ResultCode.LOCK_FAILED) {
|
||||
|
||||
int tickerId = R.string.uploader_upload_failed_ticker;
|
||||
|
||||
@@ -827,7 +828,7 @@ public class FileUploader extends Service
|
||||
));
|
||||
} else {
|
||||
Intent intent;
|
||||
if (uploadResult.getCode().equals(ResultCode.SYNC_CONFLICT)) {
|
||||
if (uploadResult.getCode() == ResultCode.SYNC_CONFLICT) {
|
||||
intent = ConflictsResolveActivity.createIntent(upload.getFile(),
|
||||
upload.getUser(),
|
||||
upload.getOCUploadId(),
|
||||
@@ -917,16 +918,15 @@ public class FileUploader extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove and 'forgets' pending uploads of an account.
|
||||
* Remove and 'forgets' pending uploads of a user.
|
||||
*
|
||||
* @param account Account which uploads will be cancelled
|
||||
* @param accountName User which uploads will be cancelled
|
||||
*/
|
||||
private void cancelUploadsForAccount(Account account) {
|
||||
mPendingUploads.remove(account.name);
|
||||
mUploadsStorageManager.removeUploads(account.name);
|
||||
private void cancelPendingUploads(String accountName) {
|
||||
mPendingUploads.remove(accountName);
|
||||
mUploadsStorageManager.removeUploads(accountName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Upload a new file
|
||||
*/
|
||||
@@ -1187,22 +1187,21 @@ public class FileUploader extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels all the uploads for an account.
|
||||
* Cancels all the uploads for a user, both running and pending.
|
||||
*
|
||||
* @param account ownCloud account.
|
||||
* @param user Nextcloud user
|
||||
*/
|
||||
public void cancel(Account account) {
|
||||
Log_OC.d(TAG, "Account= " + account.name);
|
||||
|
||||
if (mCurrentUpload != null) {
|
||||
Log_OC.d(TAG, "Current Upload Account= " + mCurrentUpload.getAccount().name);
|
||||
if (mCurrentUpload.getAccount().name.equals(account.name)) {
|
||||
mCurrentUpload.cancel(ResultCode.CANCELLED);
|
||||
}
|
||||
public void cancel(User user) {
|
||||
if (mCurrentUpload != null && mCurrentUpload.getUser().nameEquals(user)) {
|
||||
mCurrentUpload.cancel(ResultCode.CANCELLED);
|
||||
}
|
||||
cancelPendingUploads(user.getAccountName());
|
||||
}
|
||||
|
||||
// Cancel pending uploads
|
||||
cancelUploadsForAccount(account);
|
||||
public void cancel(String accountName) {
|
||||
if (mCurrentUpload != null && mCurrentUpload.getUser().nameEquals(accountName)) {
|
||||
mCurrentUpload.cancel(ResultCode.CANCELLED);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearListeners() {
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.widget.SeekBar;
|
||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.theme.ThemeBarUtils;
|
||||
@@ -46,6 +47,8 @@ import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import java.util.Formatter;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
||||
/**
|
||||
* View containing controls for a {@link MediaPlayer}.
|
||||
@@ -59,7 +62,7 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
||||
private static final int SHOW_PROGRESS = 1;
|
||||
|
||||
private MediaPlayerControl playerControl;
|
||||
private View root;
|
||||
private final View root;
|
||||
private ProgressBar progressBar;
|
||||
private TextView endTime;
|
||||
private TextView currentTime;
|
||||
@@ -68,12 +71,21 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
||||
private ImageButton forwardButton;
|
||||
private ImageButton rewindButton;
|
||||
|
||||
public MediaControlView(Context context, AttributeSet attrs) {
|
||||
@Inject
|
||||
ThemeColorUtils themeColorUtils;
|
||||
@Inject
|
||||
ThemeBarUtils themeBarUtils;
|
||||
|
||||
|
||||
public MediaControlView(Context context,
|
||||
AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
MainApp.getAppComponent().inject(this);
|
||||
|
||||
FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
);
|
||||
LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
root = inflate.inflate(R.layout.media_control, null);
|
||||
@@ -125,10 +137,10 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
||||
if (progressBar != null) {
|
||||
if (progressBar instanceof SeekBar) {
|
||||
SeekBar seeker = (SeekBar) progressBar;
|
||||
ThemeBarUtils.colorHorizontalSeekBar(seeker, getContext());
|
||||
themeBarUtils.colorHorizontalSeekBar(seeker, getContext(), themeColorUtils);
|
||||
seeker.setOnSeekBarChangeListener(this);
|
||||
} else {
|
||||
ThemeBarUtils.colorHorizontalProgressBar(progressBar, ThemeColorUtils.primaryAccentColor(getContext()));
|
||||
themeBarUtils.colorHorizontalProgressBar(progressBar, themeColorUtils.primaryAccentColor(getContext()));
|
||||
}
|
||||
progressBar.setMax(1000);
|
||||
}
|
||||
@@ -161,7 +173,7 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On
|
||||
}
|
||||
}
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
private final Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == SHOW_PROGRESS) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||
|
||||
/**
|
||||
* Get and save capabilities from the server
|
||||
@@ -53,6 +54,9 @@ public class GetCapabilitiesOperation extends SyncOperation {
|
||||
|
||||
// Save the capabilities into database
|
||||
storageManager.saveCapabilities(capability);
|
||||
|
||||
// update cached entry
|
||||
CapabilityUtils.updateCapability(capability);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -699,7 +699,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
for (Object obj : result.getData()) {
|
||||
share = (OCShare) obj;
|
||||
|
||||
if (!ShareType.NO_SHARED.equals(share.getShareType())) {
|
||||
if (ShareType.NO_SHARED != share.getShareType()) {
|
||||
shares.add(share);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ public class UnshareOperation extends SyncOperation {
|
||||
if (result.isSuccess()) {
|
||||
Log_OC.d(TAG, "Share id = " + share.getRemoteId() + " deleted");
|
||||
|
||||
if (ShareType.PUBLIC_LINK.equals(share.getShareType())) {
|
||||
if (ShareType.PUBLIC_LINK == share.getShareType()) {
|
||||
file.setSharedViaLink(false);
|
||||
} else if (ShareType.USER.equals(share.getShareType()) || ShareType.GROUP.equals(share.getShareType())
|
||||
|| ShareType.FEDERATED.equals(share.getShareType())) {
|
||||
} else if (ShareType.USER == share.getShareType() || ShareType.GROUP == share.getShareType()
|
||||
|| ShareType.FEDERATED == share.getShareType()) {
|
||||
// Check if it is the last share
|
||||
List<OCShare> sharesWith = getStorageManager().
|
||||
getSharesWithForAFile(remotePath,
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.os.ParcelFileDescriptor;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.DocumentsProvider;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
@@ -48,6 +47,7 @@ import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.files.downloader.DownloadTask;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.utils.HashUtil;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
@@ -82,7 +82,9 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -113,7 +115,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
@VisibleForTesting
|
||||
static final String DOCUMENTID_SEPARATOR = "/";
|
||||
private static final int DOCUMENTID_PARTS = 2;
|
||||
private final SparseArray<FileDataStorageManager> rootIdToStorageManager = new SparseArray<>();
|
||||
private final Map<String, FileDataStorageManager> rootIdToStorageManager = new HashMap<>();
|
||||
|
||||
private final Executor executor = Executors.newCachedThreadPool();
|
||||
|
||||
@@ -132,8 +134,8 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
}
|
||||
|
||||
final RootCursor result = new RootCursor(projection);
|
||||
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
|
||||
result.addRoot(new Document(rootIdToStorageManager.valueAt(i), ROOT_PATH), getContext());
|
||||
for(FileDataStorageManager manager: rootIdToStorageManager.values()) {
|
||||
result.addRoot(new Document(manager, ROOT_PATH), getContext());
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -678,14 +680,12 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
}
|
||||
|
||||
private FileDataStorageManager getStorageManager(String rootId) {
|
||||
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
|
||||
FileDataStorageManager storageManager = rootIdToStorageManager.valueAt(i);
|
||||
if (storageManager.getUser().nameEquals(rootId)) {
|
||||
return storageManager;
|
||||
}
|
||||
}
|
||||
return rootIdToStorageManager.get(rootId);
|
||||
}
|
||||
|
||||
return null;
|
||||
@VisibleForTesting
|
||||
public static String rootIdForUser(User user) {
|
||||
return HashUtil.md5Hash(user.getAccountName());
|
||||
}
|
||||
|
||||
private void initiateStorageMap() {
|
||||
@@ -696,7 +696,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
|
||||
for (User user : accountManager.getAllUsers()) {
|
||||
final FileDataStorageManager storageManager = new FileDataStorageManager(user, contentResolver);
|
||||
rootIdToStorageManager.put(user.hashCode(), storageManager);
|
||||
rootIdToStorageManager.put(rootIdForUser(user), storageManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
throw new FileNotFoundException("Invalid documentID " + documentId + "!");
|
||||
}
|
||||
|
||||
FileDataStorageManager storageManager = rootIdToStorageManager.get(Integer.parseInt(separated[0]));
|
||||
FileDataStorageManager storageManager = rootIdToStorageManager.get(separated[0]);
|
||||
if (storageManager == null) {
|
||||
throw new FileNotFoundException("No storage manager associated for " + documentId + "!");
|
||||
}
|
||||
@@ -803,9 +803,9 @@ public class DocumentsStorageProvider extends DocumentsProvider {
|
||||
}
|
||||
|
||||
public String getDocumentId() {
|
||||
for(int i = 0; i < rootIdToStorageManager.size(); i++) {
|
||||
if (Objects.equals(storageManager, rootIdToStorageManager.valueAt(i))) {
|
||||
return rootIdToStorageManager.keyAt(i) + DOCUMENTID_SEPARATOR + fileId;
|
||||
for(String key: rootIdToStorageManager.keySet()) {
|
||||
if (Objects.equals(storageManager, rootIdToStorageManager.get(key))) {
|
||||
return key + DOCUMENTID_SEPARATOR + fileId;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -753,7 +753,15 @@ public class FileContentProvider extends ContentProvider {
|
||||
+ ProviderTableMeta.FILE_OWNER_DISPLAY_NAME + TEXT
|
||||
+ ProviderTableMeta.FILE_NOTE + TEXT
|
||||
+ ProviderTableMeta.FILE_SHAREES + TEXT
|
||||
+ ProviderTableMeta.FILE_RICH_WORKSPACE + " TEXT);"
|
||||
+ ProviderTableMeta.FILE_RICH_WORKSPACE + TEXT
|
||||
+ ProviderTableMeta.FILE_LOCKED + INTEGER // boolean
|
||||
+ ProviderTableMeta.FILE_LOCK_TYPE + INTEGER
|
||||
+ ProviderTableMeta.FILE_LOCK_OWNER + TEXT
|
||||
+ ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME + TEXT
|
||||
+ ProviderTableMeta.FILE_LOCK_OWNER_EDITOR + TEXT
|
||||
+ ProviderTableMeta.FILE_LOCK_TIMESTAMP + INTEGER
|
||||
+ ProviderTableMeta.FILE_LOCK_TIMEOUT + INTEGER
|
||||
+ ProviderTableMeta.FILE_LOCK_TOKEN + " TEXT );"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -829,7 +837,8 @@ public class FileContentProvider extends ContentProvider {
|
||||
+ ProviderTableMeta.CAPABILITIES_DIRECT_EDITING_ETAG + TEXT
|
||||
+ ProviderTableMeta.CAPABILITIES_USER_STATUS + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_USER_STATUS_SUPPORTS_EMOJI + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_ETAG + " TEXT );");
|
||||
+ ProviderTableMeta.CAPABILITIES_ETAG + TEXT
|
||||
+ ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION + " TEXT );");
|
||||
}
|
||||
|
||||
private void createUploadsTable(SQLiteDatabase db) {
|
||||
@@ -2454,6 +2463,39 @@ public class FileContentProvider extends ContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion < 63 && newVersion >= 63) {
|
||||
Log_OC.i(SQL, "Adding file locking columns");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
// locking capabilities
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME + ADD_COLUMN + ProviderTableMeta.CAPABILITIES_FILES_LOCKING_VERSION + " TEXT ");
|
||||
// force refresh
|
||||
db.execSQL("UPDATE capabilities SET etag = '' WHERE 1=1");
|
||||
// locking properties
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCKED + " INTEGER "); // boolean
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TYPE + " INTEGER ");
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_OWNER + " TEXT ");
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_OWNER_DISPLAY_NAME + " TEXT ");
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_OWNER_EDITOR + " TEXT ");
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TIMESTAMP + " INTEGER ");
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TIMEOUT + " INTEGER ");
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_LOCK_TOKEN + " TEXT ");
|
||||
db.execSQL("UPDATE " + ProviderTableMeta.FILE_TABLE_NAME + " SET " + ProviderTableMeta.FILE_ETAG + " = '' WHERE 1=1");
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
@@ -106,35 +106,49 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
/** Counter of conflicts found between local and remote files */
|
||||
private int mConflictsFound;
|
||||
|
||||
/** Counter of failed operations in synchronization of kept-in-sync files */
|
||||
/**
|
||||
* Counter of failed operations in synchronization of kept-in-sync files
|
||||
*/
|
||||
private int mFailsInFavouritesFound;
|
||||
|
||||
/** Map of remote and local paths to files that where locally stored in a location out
|
||||
* of the ownCloud folder and couldn't be copied automatically into it */
|
||||
/**
|
||||
* Map of remote and local paths to files that where locally stored in a location out of the ownCloud folder and
|
||||
* couldn't be copied automatically into it
|
||||
*/
|
||||
private Map<String, String> mForgottenLocalFiles;
|
||||
|
||||
/** {@link SyncResult} instance to return to the system when the synchronization finish */
|
||||
/**
|
||||
* {@link SyncResult} instance to return to the system when the synchronization finish
|
||||
*/
|
||||
private SyncResult mSyncResult;
|
||||
|
||||
private final ThemeColorUtils themeColorUtils;
|
||||
|
||||
/**
|
||||
* Creates a {@link FileSyncAdapter}
|
||||
*
|
||||
* <p>
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public FileSyncAdapter(Context context, boolean autoInitialize, UserAccountManager userAccountManager) {
|
||||
public FileSyncAdapter(Context context,
|
||||
boolean autoInitialize,
|
||||
UserAccountManager userAccountManager,
|
||||
ThemeColorUtils themeColorUtils) {
|
||||
super(context, autoInitialize, userAccountManager);
|
||||
this.themeColorUtils = themeColorUtils;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link FileSyncAdapter}
|
||||
*
|
||||
* <p>
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public FileSyncAdapter(Context context,
|
||||
boolean autoInitialize,
|
||||
boolean allowParallelSyncs,
|
||||
UserAccountManager userAccountManager) {
|
||||
UserAccountManager userAccountManager,
|
||||
ThemeColorUtils themeColorUtils) {
|
||||
super(context, autoInitialize, allowParallelSyncs, userAccountManager);
|
||||
this.themeColorUtils = themeColorUtils;
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +306,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
|
||||
} else if (result.getCode() != ResultCode.FILE_NOT_FOUND) {
|
||||
// in failures, the statistics for the global result are updated
|
||||
if (RemoteOperationResult.ResultCode.UNAUTHORIZED.equals(result.getCode())) {
|
||||
if (ResultCode.UNAUTHORIZED == result.getCode()) {
|
||||
mSyncResult.stats.numAuthExceptions++;
|
||||
|
||||
} else if (result.getException() instanceof DavException) {
|
||||
@@ -321,10 +335,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
private boolean isFinisher(RemoteOperationResult failedResult) {
|
||||
if (failedResult != null) {
|
||||
RemoteOperationResult.ResultCode code = failedResult.getCode();
|
||||
return code.equals(RemoteOperationResult.ResultCode.SSL_ERROR)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.BAD_OC_VERSION)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
|
||||
return code == ResultCode.SSL_ERROR
|
||||
|| code == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED
|
||||
|| code == ResultCode.BAD_OC_VERSION
|
||||
|| code == ResultCode.INSTANCE_NOT_CONFIGURED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -391,7 +405,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
private void notifyFailedSynchronization() {
|
||||
NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
|
||||
boolean needsToUpdateCredentials = mLastFailedResult != null
|
||||
&& ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode());
|
||||
&& ResultCode.UNAUTHORIZED == mLastFailedResult.getCode();
|
||||
if (needsToUpdateCredentials) {
|
||||
// let the user update credentials with one click
|
||||
Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
|
||||
@@ -510,7 +524,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
private NotificationCompat.Builder createNotificationBuilder() {
|
||||
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getContext());
|
||||
notificationBuilder.setSmallIcon(R.drawable.notification_icon).setAutoCancel(true);
|
||||
notificationBuilder.setColor(ThemeColorUtils.primaryColor(getContext(), true));
|
||||
notificationBuilder.setColor(themeColorUtils.primaryColor(getContext(), true));
|
||||
return notificationBuilder;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -43,6 +44,7 @@ public class FileSyncService extends Service {
|
||||
private static final Object syncAdapterLock = new Object();
|
||||
|
||||
@Inject UserAccountManager userAccountManager;
|
||||
@Inject ThemeColorUtils themeColorUtils;
|
||||
|
||||
/*
|
||||
* {@inheritDoc}
|
||||
@@ -52,7 +54,7 @@ public class FileSyncService extends Service {
|
||||
AndroidInjection.inject(this);
|
||||
synchronized (syncAdapterLock) {
|
||||
if (syncAdapter == null) {
|
||||
syncAdapter = new FileSyncAdapter(getApplicationContext(), true, userAccountManager);
|
||||
syncAdapter = new FileSyncAdapter(getApplicationContext(), true, userAccountManager, themeColorUtils);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeAvatarUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -83,7 +84,11 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
|
||||
DrawableCompat.setTint(borderDrawable, ContextCompat.getColor(context, R.color.bg_default));
|
||||
}
|
||||
|
||||
public void setAvatars(@NonNull User user, @NonNull List<ShareeUser> sharees) {
|
||||
public void setAvatars(@NonNull User user,
|
||||
@NonNull List<ShareeUser> sharees,
|
||||
ThemeColorUtils themeColorUtils,
|
||||
ThemeDrawableUtils themeDrawableUtils,
|
||||
ThemeAvatarUtils themeAvatarUtils) {
|
||||
@NonNull Context context = getContext();
|
||||
removeAllViews();
|
||||
RelativeLayout.LayoutParams avatarLayoutParams;
|
||||
@@ -109,7 +114,7 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
|
||||
|
||||
if (avatarCount == 0 && sharees.size() > MAX_AVATAR_COUNT) {
|
||||
avatar.setImageResource(R.drawable.ic_people);
|
||||
ThemeDrawableUtils.setIconColor(avatar.getDrawable());
|
||||
themeDrawableUtils.setIconColor(avatar.getDrawable());
|
||||
} else {
|
||||
sharee = sharees.get(avatarCount);
|
||||
switch (sharee.getShareType()) {
|
||||
@@ -117,10 +122,15 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
|
||||
case EMAIL:
|
||||
case ROOM:
|
||||
case CIRCLE:
|
||||
ThemeAvatarUtils.createAvatar(sharee.getShareType(), avatar, context);
|
||||
themeAvatarUtils.createAvatar(sharee.getShareType(), avatar, context, themeColorUtils);
|
||||
break;
|
||||
case FEDERATED:
|
||||
showFederatedShareAvatar(context, sharee.getUserId(), avatarRadius, resources, avatar);
|
||||
showFederatedShareAvatar(context,
|
||||
sharee.getUserId(),
|
||||
avatarRadius,
|
||||
resources,
|
||||
avatar,
|
||||
themeDrawableUtils);
|
||||
break;
|
||||
default:
|
||||
avatar.setTag(sharee);
|
||||
@@ -148,7 +158,8 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
|
||||
String user,
|
||||
float avatarRadius,
|
||||
Resources resources,
|
||||
ImageView avatar) {
|
||||
ImageView avatar,
|
||||
ThemeDrawableUtils themeDrawableUtils) {
|
||||
// maybe federated share
|
||||
String[] split = user.split("@");
|
||||
String userId = split[0];
|
||||
@@ -162,7 +173,7 @@ public class AvatarGroupLayout extends RelativeLayout implements DisplayUtils.Av
|
||||
placeholder = TextDrawable.createAvatarByUserId(userId, avatarRadius);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
|
||||
placeholder = ThemeDrawableUtils.tintDrawable(ResourcesCompat.getDrawable(resources,
|
||||
placeholder = themeDrawableUtils.tintDrawable(ResourcesCompat.getDrawable(resources,
|
||||
R.drawable.account_circle_white,
|
||||
null),
|
||||
R.color.black);
|
||||
|
||||
@@ -29,8 +29,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* Extends RecyclerView to show a custom view if no data is available
|
||||
* Inspired by http://alexzh.com/tutorials/how-to-setemptyview-to-recyclerview
|
||||
* Extends RecyclerView to show a custom view if no data is available Inspired by http://alexzh.com/tutorials/how-to-setemptyview-to-recyclerview
|
||||
*/
|
||||
public class EmptyRecyclerView extends RecyclerView {
|
||||
private View mEmptyView;
|
||||
|
||||
@@ -29,29 +29,36 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
|
||||
|
||||
/**
|
||||
* Themeable switch preference
|
||||
* TODO Migrate to androidx
|
||||
* Themeable switch preference TODO Migrate to androidx
|
||||
*/
|
||||
public class ThemeableSwitchPreference extends SwitchPreference {
|
||||
@Inject
|
||||
ThemeColorUtils themeColorUtils;
|
||||
|
||||
public ThemeableSwitchPreference(Context context) {
|
||||
super(context);
|
||||
MainApp.getAppComponent().inject(this);
|
||||
}
|
||||
|
||||
public ThemeableSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
MainApp.getAppComponent().inject(this);
|
||||
}
|
||||
|
||||
public ThemeableSwitchPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
MainApp.getAppComponent().inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,19 +81,19 @@ public class ThemeableSwitchPreference extends SwitchPreference {
|
||||
Switch switchView = (Switch) child;
|
||||
|
||||
if(thumbColorStateList == null && trackColorStateList == null) {
|
||||
int thumbColor = ThemeColorUtils.primaryAccentColor(getContext());
|
||||
if (ThemeColorUtils.darkTheme(getContext()) &&
|
||||
int thumbColor = themeColorUtils.primaryAccentColor(getContext());
|
||||
if (themeColorUtils.darkTheme(getContext()) &&
|
||||
AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES) {
|
||||
thumbColor = Color.WHITE;
|
||||
}
|
||||
int trackColor = Color.argb(77, Color.red(thumbColor), Color.green(thumbColor), Color.blue(thumbColor));
|
||||
int trackColorUnchecked = getContext().getResources().getColor(R.color.switch_track_color_unchecked);
|
||||
thumbColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{thumbColor, getContext().getResources().getColor(R.color.switch_thumb_color_unchecked)});
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{thumbColor, getContext().getResources().getColor(R.color.switch_thumb_color_unchecked)});
|
||||
trackColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked},
|
||||
new int[]{}},
|
||||
new int[][]{new int[]{android.R.attr.state_checked},
|
||||
new int[]{}},
|
||||
new int[]{trackColor, trackColorUnchecked});
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.owncloud.android.ui.interfaces.ActivityListInterface;
|
||||
import com.owncloud.android.ui.preview.PreviewImageActivity;
|
||||
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeLayoutUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -85,7 +84,7 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
|
||||
// setup toolbar
|
||||
setupToolbar();
|
||||
|
||||
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
|
||||
themeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
|
||||
|
||||
// setup drawer
|
||||
setupDrawer(R.id.nav_activity);
|
||||
@@ -114,7 +113,9 @@ public class ActivitiesActivity extends DrawerActivity implements ActivityListIn
|
||||
getUserAccountManager(),
|
||||
this,
|
||||
clientFactory,
|
||||
false);
|
||||
false,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils);
|
||||
binding.list.setAdapter(adapter);
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
|
||||
@@ -31,8 +31,6 @@ import com.google.android.material.button.MaterialButton;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.CommunityLayoutBinding;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
|
||||
/**
|
||||
* Activity providing information about ways to participate in the app's development.
|
||||
@@ -66,7 +64,7 @@ public class CommunityActivity extends DrawerActivity {
|
||||
contributeForumView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
contributeForumView.setText(Html.fromHtml(getString(R.string.community_contribute_forum_text) + " " +
|
||||
getString(R.string.community_contribute_forum_text_link,
|
||||
ThemeColorUtils.primaryColorToHexString(this),
|
||||
themeColorUtils.primaryColorToHexString(this),
|
||||
getString(R.string.help_link),
|
||||
getString(R.string.community_contribute_forum_forum))));
|
||||
|
||||
@@ -74,7 +72,7 @@ public class CommunityActivity extends DrawerActivity {
|
||||
contributeTranslationView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
contributeTranslationView.setText(Html.fromHtml(
|
||||
getString(R.string.community_contribute_translate_link,
|
||||
ThemeColorUtils.primaryColorToHexString(this),
|
||||
themeColorUtils.primaryColorToHexString(this),
|
||||
getString(R.string.translation_link),
|
||||
getString(R.string.community_contribute_translate_translate)) + " " +
|
||||
getString(R.string.community_contribute_translate_text)));
|
||||
@@ -84,11 +82,11 @@ public class CommunityActivity extends DrawerActivity {
|
||||
contributeGithubView.setText(Html.fromHtml(
|
||||
getString(R.string.community_contribute_github_text,
|
||||
getString(R.string.community_contribute_github_text_link,
|
||||
ThemeColorUtils.primaryColorToHexString(this),
|
||||
themeColorUtils.primaryColorToHexString(this),
|
||||
getString(R.string.contributing_link)))));
|
||||
|
||||
MaterialButton reportButton = binding.communityTestingReport;
|
||||
ThemeButtonUtils.colorPrimaryButton(reportButton, this);
|
||||
themeButtonUtils.colorPrimaryButton(reportButton, this, themeColorUtils);
|
||||
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
|
||||
|
||||
binding.communityBetaFdroid.setOnClickListener(
|
||||
|
||||
@@ -79,7 +79,6 @@ import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.PassCodeManager;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.ExternalLinksProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.ExternalLink;
|
||||
import com.owncloud.android.lib.common.ExternalLinkType;
|
||||
@@ -102,6 +101,7 @@ import com.owncloud.android.ui.events.SearchEvent;
|
||||
import com.owncloud.android.ui.fragment.FileDetailsSharingProcessFragment;
|
||||
import com.owncloud.android.ui.fragment.GalleryFragment;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.ui.fragment.SharedListFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewTextStringFragment;
|
||||
import com.owncloud.android.ui.trashbin.TrashbinActivity;
|
||||
import com.owncloud.android.utils.BitmapUtils;
|
||||
@@ -112,9 +112,8 @@ import com.owncloud.android.utils.svg.MenuSimpleTarget;
|
||||
import com.owncloud.android.utils.svg.SVGorImage;
|
||||
import com.owncloud.android.utils.svg.SvgOrImageBitmapTranscoder;
|
||||
import com.owncloud.android.utils.svg.SvgOrImageDecoder;
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeBarUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeMenuUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@@ -211,6 +210,12 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
@Inject
|
||||
ClientFactory clientFactory;
|
||||
|
||||
@Inject
|
||||
ThemeMenuUtils themeMenuUtils;
|
||||
|
||||
@Inject
|
||||
ThemeBarUtils themeBarUtils;
|
||||
|
||||
/**
|
||||
* Initializes the drawer, its content and highlights the menu item with the given id. This method needs to be
|
||||
* called after the content view has been set.
|
||||
@@ -283,8 +288,8 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
R.drawable.ic_arrow_back,
|
||||
null);
|
||||
mDrawerToggle.setHomeAsUpIndicator(
|
||||
ThemeDrawableUtils.tintDrawable(backArrow, ThemeColorUtils.appBarPrimaryFontColor(this)));
|
||||
mDrawerToggle.getDrawerArrowDrawable().setColor(ThemeColorUtils.appBarPrimaryFontColor(this));
|
||||
themeDrawableUtils.tintDrawable(backArrow, themeColorUtils.appBarPrimaryFontColor(this)));
|
||||
mDrawerToggle.getDrawerArrowDrawable().setColor(themeColorUtils.appBarPrimaryFontColor(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,20 +300,20 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
mQuotaProgressBar = (ProgressBar) findQuotaViewById(R.id.drawer_quota_ProgressBar);
|
||||
mQuotaTextPercentage = (TextView) findQuotaViewById(R.id.drawer_quota_percentage);
|
||||
mQuotaTextLink = (TextView) findQuotaViewById(R.id.drawer_quota_link);
|
||||
ThemeBarUtils.colorProgressBar(mQuotaProgressBar, ThemeColorUtils.primaryColor(this));
|
||||
themeBarUtils.colorProgressBar(mQuotaProgressBar, themeColorUtils.primaryColor(this));
|
||||
}
|
||||
|
||||
public void updateHeader() {
|
||||
if (getAccount() != null &&
|
||||
getStorageManager().getCapability(getAccount().name).getServerBackground() != null) {
|
||||
getCapabilities().getServerBackground() != null) {
|
||||
|
||||
OCCapability capability = getStorageManager().getCapability(getAccount().name);
|
||||
OCCapability capability = getCapabilities();
|
||||
String logo = capability.getServerLogo();
|
||||
int primaryColor = ThemeColorUtils.primaryColor(getAccount(), false, this);
|
||||
int primaryColor = themeColorUtils.primaryColor(getAccount(), false, this);
|
||||
|
||||
// set background to primary color
|
||||
LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view);
|
||||
drawerHeader.setBackgroundColor(ThemeColorUtils.unchangedPrimaryColor(getAccount(), this));
|
||||
drawerHeader.setBackgroundColor(themeColorUtils.unchangedPrimaryColor(getAccount(), this));
|
||||
|
||||
if (!TextUtils.isEmpty(logo) && URLUtil.isValidUrl(logo)) {
|
||||
// background image
|
||||
@@ -369,7 +374,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
TextView serverName = mNavigationViewHeader.findViewById(R.id.drawer_header_server_name);
|
||||
serverName.setText(name);
|
||||
serverName.setTextColor(ThemeColorUtils.unchangedFontColor(this));
|
||||
serverName.setTextColor(themeColorUtils.unchangedFontColor(this));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -378,7 +383,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
* setup drawer header, basically the logo color
|
||||
*/
|
||||
private void setupDrawerHeader(FrameLayout drawerHeader) {
|
||||
drawerHeader.setBackgroundColor(ThemeColorUtils.primaryColor(getAccount(), true, this));
|
||||
drawerHeader.setBackgroundColor(themeColorUtils.primaryColor(getAccount(), true, this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,9 +408,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
}
|
||||
|
||||
private void filterDrawerMenu(final Menu menu, @NonNull final User user) {
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(user,
|
||||
getContentResolver());
|
||||
OCCapability capability = storageManager.getCapability(user.getAccountName());
|
||||
OCCapability capability = getCapabilities();
|
||||
|
||||
DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources());
|
||||
DrawerMenuUtil.filterTrashbinMenuItem(menu, capability);
|
||||
@@ -433,6 +436,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
if (itemId == R.id.nav_all_files) {
|
||||
if (this instanceof FileDisplayActivity &&
|
||||
!(((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) &&
|
||||
!(((FileDisplayActivity) this).getLeftFragment() instanceof SharedListFragment) &&
|
||||
!(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) {
|
||||
showFiles(false);
|
||||
((FileDisplayActivity) this).browseToRoot();
|
||||
@@ -472,8 +476,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
UserInfoActivity.openAccountRemovalConfirmationDialog(optionalUser.get(), getSupportFragmentManager());
|
||||
}
|
||||
} else if (itemId == R.id.nav_shared) {
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER),
|
||||
menuItem.getItemId());
|
||||
startSharedSearch(menuItem);
|
||||
} else if (itemId == R.id.nav_recently_modified) {
|
||||
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH),
|
||||
menuItem.getItemId());
|
||||
@@ -521,6 +524,13 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void startSharedSearch(MenuItem menuItem) {
|
||||
SearchEvent searchEvent = new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER);
|
||||
MainApp.showOnlyFilesOnDevice(false);
|
||||
|
||||
launchActivityForSearch(searchEvent, menuItem.getItemId());
|
||||
}
|
||||
|
||||
private void startPhotoSearch(MenuItem menuItem) {
|
||||
SearchEvent searchEvent = new SearchEvent("image/%", SearchRemoteOperation.SearchType.PHOTO_SEARCH);
|
||||
MainApp.showOnlyFilesOnDevice(false);
|
||||
@@ -530,7 +540,8 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
private void handleSearchEvents(SearchEvent searchEvent, int menuItemId) {
|
||||
if (this instanceof FileDisplayActivity) {
|
||||
if (((FileDisplayActivity) this).getLeftFragment() instanceof GalleryFragment) {
|
||||
final Fragment leftFragment = ((FileDisplayActivity) this).getLeftFragment();
|
||||
if (leftFragment instanceof GalleryFragment || leftFragment instanceof SharedListFragment) {
|
||||
launchActivityForSearch(searchEvent, menuItemId);
|
||||
} else {
|
||||
EventBus.getDefault().post(searchEvent);
|
||||
@@ -684,7 +695,9 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
mQuotaProgressBar.setProgress(relative);
|
||||
|
||||
ThemeBarUtils.colorProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this, relative));
|
||||
themeBarUtils.colorProgressBar(mQuotaProgressBar, DisplayUtils.getRelativeInfoColor(this,
|
||||
relative,
|
||||
themeColorUtils));
|
||||
|
||||
updateQuotaLink();
|
||||
showQuota(true);
|
||||
@@ -772,7 +785,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
mCheckedMenuItem = menuItemId;
|
||||
MenuItem currentItem = mNavigationView.getMenu().findItem(menuItemId);
|
||||
int drawerColor = getResources().getColor(R.color.drawer_text_color);
|
||||
int activeColor = ThemeColorUtils.primaryColor(null, true, true, this);
|
||||
int activeColor = themeColorUtils.primaryColor(null, true, true, this);
|
||||
|
||||
currentItem.setChecked(true);
|
||||
|
||||
@@ -781,11 +794,11 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
MenuItem menuItem = mNavigationView.getMenu().getItem(i);
|
||||
if (menuItem.getIcon() != null) {
|
||||
if (menuItem == currentItem) {
|
||||
ThemeDrawableUtils.tintDrawable(currentItem.getIcon(), activeColor);
|
||||
ThemeMenuUtils.tintMenuItemText(currentItem, activeColor);
|
||||
themeDrawableUtils.tintDrawable(currentItem.getIcon(), activeColor);
|
||||
themeMenuUtils.tintMenuItemText(currentItem, activeColor);
|
||||
} else {
|
||||
ThemeDrawableUtils.tintDrawable(menuItem.getIcon(), drawerColor);
|
||||
ThemeMenuUtils.tintMenuItemText(menuItem, drawerColor);
|
||||
themeDrawableUtils.tintDrawable(menuItem.getIcon(), drawerColor);
|
||||
themeMenuUtils.tintMenuItemText(menuItem, drawerColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -905,7 +918,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
|
||||
if (menuItem != null) {
|
||||
if (drawable != null) {
|
||||
menuItem.setIcon(ThemeDrawableUtils.tintDrawable(drawable, greyColor));
|
||||
menuItem.setIcon(themeDrawableUtils.tintDrawable(drawable, greyColor));
|
||||
} else {
|
||||
menuItem.setIcon(R.drawable.ic_link);
|
||||
}
|
||||
@@ -1136,8 +1149,8 @@ public abstract class DrawerActivity extends ToolbarActivity
|
||||
}
|
||||
|
||||
User user = accountManager.getUser();
|
||||
String name = user.getAccountName();
|
||||
if (getStorageManager() != null && getStorageManager().getCapability(name).getExternalLinks().isTrue()) {
|
||||
if (getStorageManager() != null && CapabilityUtils.getCapability(user, this)
|
||||
.getExternalLinks().isTrue()) {
|
||||
|
||||
int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL,
|
||||
FileActivity.APP_OPENED_COUNT);
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
||||
|
||||
public abstract class EditorWebView extends ExternalSiteWebView {
|
||||
protected Snackbar loadingSnackbar;
|
||||
@@ -79,7 +78,7 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
||||
R.string.timeout_richDocuments, Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(R.string.common_back, v -> closeView());
|
||||
|
||||
ThemeSnackbarUtils.colorSnackbar(getApplicationContext(), snackbar);
|
||||
themeSnackbarUtils.colorSnackbar(getApplicationContext(), snackbar);
|
||||
setLoadingSnackbar(snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
@@ -158,7 +157,9 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
||||
file.isSharedViaLink(),
|
||||
file.isEncrypted(),
|
||||
file.getMountType(),
|
||||
this));
|
||||
this,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils));
|
||||
} else {
|
||||
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
|
||||
// Thumbnail in cache?
|
||||
@@ -181,7 +182,9 @@ public abstract class EditorWebView extends ExternalSiteWebView {
|
||||
Drawable icon = MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
||||
file.getFileName(),
|
||||
user,
|
||||
getApplicationContext());
|
||||
getApplicationContext(),
|
||||
themeColorUtils,
|
||||
themeDrawableUtils);
|
||||
binding.thumbnail.setImageDrawable(icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.owncloud.android.databinding.ExternalsiteWebviewBinding;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.NextcloudWebViewClient;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -203,7 +202,7 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
private void setupActionBar(String title) {
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
ThemeToolbarUtils.setColoredTitle(actionBar, title, this);
|
||||
themeToolbarUtils.setColoredTitle(actionBar, title, this);
|
||||
|
||||
if (showSidebar) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
@@ -93,7 +93,6 @@ import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.FilesSyncHelper;
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
@@ -172,6 +171,9 @@ public abstract class FileActivity extends DrawerActivity
|
||||
@Inject
|
||||
BackgroundJobManager backgroundJobManager;
|
||||
|
||||
@Inject
|
||||
ThemeSnackbarUtils themeSnackbarUtils;
|
||||
|
||||
@Override
|
||||
public void showFiles(boolean onDeviceOnly) {
|
||||
// must be specialized in subclasses
|
||||
@@ -200,9 +202,11 @@ public abstract class FileActivity extends DrawerActivity
|
||||
mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
|
||||
mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION);
|
||||
mFileOperationsHelper.setOpIdWaitingFor(
|
||||
savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)
|
||||
);
|
||||
ThemeToolbarUtils.setColoredTitle(getSupportActionBar(), savedInstanceState.getString(KEY_ACTION_BAR_TITLE), this);
|
||||
savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)
|
||||
);
|
||||
themeToolbarUtils.setColoredTitle(getSupportActionBar(),
|
||||
savedInstanceState.getString(KEY_ACTION_BAR_TITLE),
|
||||
this);
|
||||
} else {
|
||||
User user = getIntent().getParcelableExtra(FileActivity.EXTRA_USER);
|
||||
mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
|
||||
@@ -348,27 +352,27 @@ public abstract class FileActivity extends DrawerActivity
|
||||
if (!result.isSuccess() && (
|
||||
result.getCode() == ResultCode.UNAUTHORIZED ||
|
||||
(result.isException() && result.getException() instanceof AuthenticatorException)
|
||||
)) {
|
||||
)) {
|
||||
|
||||
requestCredentialsUpdate(this);
|
||||
|
||||
if (result.getCode() == ResultCode.UNAUTHORIZED) {
|
||||
DisplayUtils.showSnackMessage(
|
||||
this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
);
|
||||
this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources())
|
||||
);
|
||||
}
|
||||
|
||||
} else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED.equals(result.getCode())) {
|
||||
} else if (!result.isSuccess() && ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == result.getCode()) {
|
||||
|
||||
showUntrustedCertDialog(result);
|
||||
|
||||
} else if (operation == null ||
|
||||
operation instanceof CreateShareWithShareeOperation ||
|
||||
operation instanceof UnshareOperation ||
|
||||
operation instanceof SynchronizeFolderOperation ||
|
||||
operation instanceof UpdateShareViaLinkOperation ||
|
||||
operation instanceof UpdateSharePermissionsOperation
|
||||
) {
|
||||
operation instanceof CreateShareWithShareeOperation ||
|
||||
operation instanceof UnshareOperation ||
|
||||
operation instanceof SynchronizeFolderOperation ||
|
||||
operation instanceof UpdateShareViaLinkOperation ||
|
||||
operation instanceof UpdateSharePermissionsOperation
|
||||
) {
|
||||
if (result.isSuccess()) {
|
||||
updateFileFromDB();
|
||||
|
||||
@@ -692,12 +696,15 @@ public abstract class FileActivity extends DrawerActivity
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyAndShareFileLink(FileActivity activity, OCFile file, String link) {
|
||||
public static void copyAndShareFileLink(FileActivity activity,
|
||||
OCFile file,
|
||||
String link,
|
||||
ThemeSnackbarUtils themeSnackbarUtils) {
|
||||
ClipboardUtil.copyToClipboard(activity, link, false);
|
||||
Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), R.string.clipboard_text_copied,
|
||||
Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.share, v -> showShareLinkDialog(activity, file, link));
|
||||
ThemeSnackbarUtils.colorSnackbar(activity, snackbar);
|
||||
themeSnackbarUtils.colorSnackbar(activity, snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
@@ -743,7 +750,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (sharingFragment != null) {
|
||||
sharingFragment.onUpdateShareInformation(result, getFile());
|
||||
sharingFragment.onUpdateShareInformation(result);
|
||||
}
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.note_could_not_sent);
|
||||
@@ -757,7 +764,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
if (result.isSuccess()) {
|
||||
updateFileFromDB();
|
||||
if (sharingFragment != null) {
|
||||
sharingFragment.onUpdateShareInformation(result, getFile());
|
||||
sharingFragment.onUpdateShareInformation(result);
|
||||
}
|
||||
} else if (sharingFragment != null && sharingFragment.getView() != null) {
|
||||
if (TextUtils.isEmpty(result.getMessage())) {
|
||||
@@ -766,7 +773,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
snackbar = Snackbar.make(sharingFragment.getView(), result.getMessage(), Snackbar.LENGTH_LONG);
|
||||
}
|
||||
|
||||
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
|
||||
themeSnackbarUtils.colorSnackbar(this, snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
@@ -791,7 +798,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
}
|
||||
}
|
||||
|
||||
copyAndShareFileLink(this, file, link);
|
||||
copyAndShareFileLink(this, file, link, themeSnackbarUtils);
|
||||
|
||||
if (sharingFragment != null) {
|
||||
sharingFragment.onUpdateShareInformation(result, file);
|
||||
@@ -821,7 +828,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
operation,
|
||||
getResources()),
|
||||
Snackbar.LENGTH_LONG);
|
||||
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
|
||||
themeSnackbarUtils.colorSnackbar(this, snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
@@ -877,10 +884,11 @@ public abstract class FileActivity extends DrawerActivity
|
||||
|
||||
/**
|
||||
* open the new sharing process fragment to create the share
|
||||
*
|
||||
* @param shareeName
|
||||
* @param shareType
|
||||
*/
|
||||
private void doShareWith(String shareeName, ShareType shareType) {
|
||||
protected void doShareWith(String shareeName, ShareType shareType) {
|
||||
FileDetailFragment fragment = getFileDetailFragment();
|
||||
if (fragment != null) {
|
||||
fragment.initiateSharingProcess(shareeName, shareType);
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.utils.IntentUtil;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.nextcloud.utils.view.FastScroll;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.databinding.FilesBinding;
|
||||
@@ -100,6 +101,7 @@ import com.owncloud.android.ui.fragment.FileFragment;
|
||||
import com.owncloud.android.ui.fragment.GalleryFragment;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.ui.fragment.SearchType;
|
||||
import com.owncloud.android.ui.fragment.SharedListFragment;
|
||||
import com.owncloud.android.ui.fragment.TaskRetainerFragment;
|
||||
import com.owncloud.android.ui.fragment.UnifiedSearchFragment;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
@@ -120,9 +122,6 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
import com.owncloud.android.utils.PushUtils;
|
||||
import com.owncloud.android.utils.StringUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
@@ -136,9 +135,9 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.view.MenuItemCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -267,6 +266,9 @@ public class FileDisplayActivity extends FileActivity
|
||||
mSwitchAccountButton.setOnClickListener(v -> showManageAccountsDialog());
|
||||
|
||||
|
||||
FastScroll.fixAppBarForFastScroll(binding.appbar.appbar, binding.rootLayout);
|
||||
|
||||
|
||||
// Init Fragment without UI to retain AsyncTask across configuration changes
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
TaskRetainerFragment taskRetainerFragment =
|
||||
@@ -304,7 +306,8 @@ public class FileDisplayActivity extends FileActivity
|
||||
.create();
|
||||
|
||||
alertDialog.show();
|
||||
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
|
||||
themeButtonUtils.themeBorderlessButton(themeColorUtils,
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
|
||||
} catch (WindowManager.BadTokenException e) {
|
||||
Log_OC.e(TAG, "Error showing wrong storage info, so skipping it: " + e.getMessage());
|
||||
}
|
||||
@@ -316,22 +319,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
super.onPostCreate(savedInstanceState);
|
||||
|
||||
|
||||
if (!PermissionUtil.checkExternalStoragePermission(this)) {
|
||||
// Check if we should show an explanation
|
||||
if (PermissionUtil.shouldShowRequestPermissionRationale(this,
|
||||
PermissionUtil.getExternalStoragePermission())) {
|
||||
// Show explanation to the user and then request permission
|
||||
Snackbar snackbar = Snackbar.make(binding.rootLayout,
|
||||
R.string.permission_storage_access,
|
||||
Snackbar.LENGTH_INDEFINITE)
|
||||
.setAction(R.string.common_ok, v -> PermissionUtil.requestExternalStoragePermission(this));
|
||||
ThemeSnackbarUtils.colorSnackbar(this, snackbar);
|
||||
snackbar.show();
|
||||
} else {
|
||||
// No explanation needed, request the permission.
|
||||
PermissionUtil.requestExternalStoragePermission(this);
|
||||
}
|
||||
}
|
||||
PermissionUtil.requestExternalStoragePermission(this, themeSnackbarUtils);
|
||||
|
||||
if (getIntent().getParcelableExtra(OCFileListFragment.SEARCH_EVENT) != null) {
|
||||
switchToSearchFragment(savedInstanceState);
|
||||
@@ -399,7 +387,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
switch (requestCode) {
|
||||
case PermissionUtil.PERMISSIONS_EXTERNAL_STORAGE: {
|
||||
case PermissionUtil.PERMISSIONS_EXTERNAL_STORAGE:
|
||||
// If request is cancelled, result arrays are empty.
|
||||
if (grantResults.length > 0
|
||||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
@@ -407,24 +395,25 @@ public class FileDisplayActivity extends FileActivity
|
||||
EventBus.getDefault().post(new TokenPushEvent());
|
||||
syncAndUpdateFolder(true);
|
||||
// toggle on is save since this is the only scenario this code gets accessed
|
||||
} else {
|
||||
// permission denied --> do nothing
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case PermissionUtil.PERMISSIONS_CAMERA: {
|
||||
break;
|
||||
case PermissionUtil.PERMISSIONS_SCAN_DOCUMENT:
|
||||
// If request is cancelled, result arrays are empty.
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// permission was granted
|
||||
AppScanActivity.scanFromCamera(
|
||||
this,
|
||||
FileDisplayActivity.REQUEST_CODE__UPLOAD_SCAN_DOC_FROM_CAMERA);
|
||||
}
|
||||
break;
|
||||
case PermissionUtil.PERMISSIONS_CAMERA:
|
||||
// If request is cancelled, result arrays are empty.
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// permission was granted
|
||||
getFileOperationsHelper()
|
||||
.uploadFromCamera(this, FileDisplayActivity.REQUEST_CODE__UPLOAD_FROM_CAMERA);
|
||||
} else {
|
||||
// permission denied
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
@@ -498,7 +487,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
SearchEvent searchEvent = intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT);
|
||||
if (searchEvent != null) {
|
||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH.equals(searchEvent.getSearchType())) {
|
||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == searchEvent.getSearchType()) {
|
||||
Log_OC.d(this, "Switch to photo search fragment");
|
||||
|
||||
GalleryFragment photoFragment = new GalleryFragment();
|
||||
@@ -506,6 +495,13 @@ public class FileDisplayActivity extends FileActivity
|
||||
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
|
||||
photoFragment.setArguments(bundle);
|
||||
setLeftFragment(photoFragment);
|
||||
} else if (searchEvent.getSearchType() == SearchRemoteOperation.SearchType.SHARED_FILTER) {
|
||||
Log_OC.d(this, "Switch to shared fragment");
|
||||
SharedListFragment sharedListFragment = new SharedListFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
|
||||
sharedListFragment.setArguments(bundle);
|
||||
setLeftFragment(sharedListFragment);
|
||||
} else {
|
||||
Log_OC.d(this, "Switch to oc file search fragment");
|
||||
|
||||
@@ -520,6 +516,8 @@ public class FileDisplayActivity extends FileActivity
|
||||
Log_OC.d(this, "Switch to oc file fragment");
|
||||
|
||||
setLeftFragment(new OCFileListFragment());
|
||||
getSupportFragmentManager().executePendingTransactions();
|
||||
browseToRoot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +536,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
|
||||
transaction.commit();
|
||||
|
||||
if (fragment instanceof UnifiedSearchFragment) {
|
||||
if (fragment instanceof UnifiedSearchFragment || fragment instanceof PreviewMediaFragment) {
|
||||
showSortListGroup(false);
|
||||
} else {
|
||||
showSortListGroup(true);
|
||||
@@ -566,8 +564,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
protected void resetTitleBarAndScrolling() {
|
||||
updateActionBarTitleAndHomeButton(null);
|
||||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) findViewById(R.id.root_layout).getLayoutParams();
|
||||
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
||||
resetScrolling();
|
||||
}
|
||||
|
||||
public void updateListOfFilesFragment(boolean fromSearch) {
|
||||
@@ -661,7 +658,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
searchView.setIconified(false);
|
||||
});
|
||||
|
||||
ThemeToolbarUtils.themeSearchView(searchView, this);
|
||||
themeToolbarUtils.themeSearchView(searchView, this);
|
||||
|
||||
// populate list of menu items to show/hide when drawer is opened/closed
|
||||
mDrawerMenuItemstoShowHideList = new ArrayList<>(1);
|
||||
@@ -856,6 +853,8 @@ public class FileDisplayActivity extends FileActivity
|
||||
},
|
||||
DELAY_TO_REQUEST_OPERATIONS_LATER
|
||||
);
|
||||
} else if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) {
|
||||
syncAndUpdateFolder(true);
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
@@ -1041,8 +1040,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
createMinFragments(null);
|
||||
} else {
|
||||
// pop back
|
||||
((CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams())
|
||||
.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
||||
resetScrolling();
|
||||
hideSearchView(getCurrentDir());
|
||||
showSortListGroup(true);
|
||||
super.onBackPressed();
|
||||
@@ -1097,7 +1095,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
OCFileListFragment ocFileListFragment = (OCFileListFragment) leftFragment;
|
||||
|
||||
ocFileListFragment.setLoading(mSyncInProgress);
|
||||
syncAndUpdateFolder(false);
|
||||
syncAndUpdateFolder(false, true);
|
||||
|
||||
OCFile startFile = null;
|
||||
if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
|
||||
@@ -1286,16 +1284,25 @@ public class FileDisplayActivity extends FileActivity
|
||||
DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
|
||||
|
||||
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
|
||||
|
||||
|
||||
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
|
||||
if (ocFileListFragment != null) {
|
||||
ocFileListFragment.setLoading(mSyncInProgress);
|
||||
if (!mSyncInProgress && !ocFileListFragment.isLoading()) {
|
||||
// update scrolling when load finishes
|
||||
if (ocFileListFragment.isEmpty()) {
|
||||
lockScrolling();
|
||||
} else {
|
||||
resetScrolling();
|
||||
}
|
||||
}
|
||||
}
|
||||
setBackgroundText();
|
||||
}
|
||||
}
|
||||
|
||||
if (synchResult != null && synchResult.getCode().equals(
|
||||
RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
|
||||
if (synchResult != null && synchResult.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {
|
||||
mLastSslUntrustedServerResult = synchResult;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
@@ -1313,7 +1320,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
}
|
||||
|
||||
private boolean checkForRemoteOperationError(RemoteOperationResult syncResult) {
|
||||
return ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) ||
|
||||
return ResultCode.UNAUTHORIZED == syncResult.getCode() ||
|
||||
(syncResult.isException() && syncResult.getException()
|
||||
instanceof AuthenticatorException);
|
||||
}
|
||||
@@ -1491,6 +1498,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
public void browseToRoot() {
|
||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||
if (listOfFiles != null) { // should never be null, indeed
|
||||
MainApp.showOnlyFilesOnDevice(false);
|
||||
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
|
||||
listOfFiles.listDirectory(root, MainApp.isOnlyOnDevice(), false);
|
||||
setFile(listOfFiles.getCurrentFile());
|
||||
@@ -1527,7 +1535,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
public void showDetails(OCFile file, int activeTab) {
|
||||
User currentUser = getUser().orElseThrow(RuntimeException::new);
|
||||
|
||||
resetHeaderScrollingState();
|
||||
resetScrolling();
|
||||
|
||||
Fragment detailFragment = FileDetailFragment.newInstance(file, currentUser, activeTab);
|
||||
setLeftFragment(detailFragment);
|
||||
@@ -1536,14 +1544,26 @@ public class FileDisplayActivity extends FileActivity
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(false);
|
||||
}
|
||||
|
||||
private void resetHeaderScrollingState() {
|
||||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) findViewById(R.id.root_layout).getLayoutParams();
|
||||
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
||||
AppBarLayout appBarLayout = findViewById(R.id.appbar);
|
||||
/**
|
||||
* Prevents content scrolling and toolbar collapse
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void lockScrolling() {
|
||||
binding.appbar.appbar.setExpanded(true, false);
|
||||
final AppBarLayout.LayoutParams appbarParams = (AppBarLayout.LayoutParams) binding.appbar.toolbarFrame.getLayoutParams();
|
||||
appbarParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
|
||||
binding.appbar.toolbarFrame.setLayoutParams(appbarParams);
|
||||
}
|
||||
|
||||
if (appBarLayout != null) {
|
||||
appBarLayout.setExpanded(true);
|
||||
}
|
||||
/**
|
||||
* Resets content scrolling and toolbar collapse
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void resetScrolling() {
|
||||
AppBarLayout.LayoutParams appbarParams = (AppBarLayout.LayoutParams) binding.appbar.toolbarFrame.getLayoutParams();
|
||||
appbarParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
|
||||
binding.appbar.toolbarFrame.setLayoutParams(appbarParams);
|
||||
binding.appbar.appbar.setExpanded(true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2098,10 +2118,9 @@ public class FileDisplayActivity extends FileActivity
|
||||
return; // not reachable under normal conditions
|
||||
}
|
||||
if (showPreview && file.isDown() && !file.isDownloading() || streamMedia) {
|
||||
showSortListGroup(false);
|
||||
configureToolbarForMediaPreview(file);
|
||||
Fragment mediaFragment = PreviewMediaFragment.newInstance(file, user.get(), startPlaybackPosition, autoplay);
|
||||
setLeftFragment(mediaFragment);
|
||||
configureToolbarForMediaPreview(file);
|
||||
} else {
|
||||
Intent previewIntent = new Intent();
|
||||
previewIntent.putExtra(EXTRA_FILE, file);
|
||||
@@ -2116,7 +2135,7 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
public void configureToolbarForMediaPreview(OCFile file) {
|
||||
showSortListGroup(false);
|
||||
((CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams()).setBehavior(null);
|
||||
lockScrolling();
|
||||
super.updateActionBarTitleAndHomeButton(file);
|
||||
}
|
||||
|
||||
@@ -2243,11 +2262,15 @@ public class FileDisplayActivity extends FileActivity
|
||||
}
|
||||
|
||||
private void syncAndUpdateFolder(boolean ignoreETag) {
|
||||
syncAndUpdateFolder(ignoreETag, false);
|
||||
}
|
||||
|
||||
private void syncAndUpdateFolder(boolean ignoreETag, boolean ignoreFocus) {
|
||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||
if (listOfFiles != null && !listOfFiles.isSearchFragment()) {
|
||||
OCFile folder = listOfFiles.getCurrentFile();
|
||||
if (folder != null) {
|
||||
startSyncFolderOperation(folder, ignoreETag);
|
||||
startSyncFolderOperation(folder, ignoreETag, ignoreFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2268,8 +2291,10 @@ public class FileDisplayActivity extends FileActivity
|
||||
public void onMessageEvent(final SearchEvent event) {
|
||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.getSearchType()) {
|
||||
Log_OC.d(this, "Switch to photo search fragment");
|
||||
|
||||
setLeftFragment(new GalleryFragment());
|
||||
} else if (event.getSearchType() == SearchRemoteOperation.SearchType.SHARED_FILTER) {
|
||||
Log_OC.d(this, "Switch to Shared fragment");
|
||||
setLeftFragment(new SharedListFragment());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,6 @@ import com.owncloud.android.utils.DataHolderUtil;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.FileSortOrder;
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -133,11 +129,11 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
mDoNotEnterEncryptedFolder = true;
|
||||
break;
|
||||
default:
|
||||
caption = ThemeUtils.getDefaultDisplayNameForRootFolder(this);
|
||||
caption = themeUtils.getDefaultDisplayNameForRootFolder(this);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
caption = ThemeUtils.getDefaultDisplayNameForRootFolder(this);
|
||||
caption = themeUtils.getDefaultDisplayNameForRootFolder(this);
|
||||
}
|
||||
|
||||
if (getIntent().getParcelableExtra(EXTRA_CURRENT_FOLDER) != null) {
|
||||
@@ -385,9 +381,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
actionBar.setDisplayHomeAsUpEnabled(!atRoot);
|
||||
actionBar.setHomeButtonEnabled(!atRoot);
|
||||
|
||||
ThemeToolbarUtils.tintBackButton(actionBar, this);
|
||||
themeToolbarUtils.tintBackButton(actionBar, this);
|
||||
|
||||
ThemeToolbarUtils.setColoredTitle(getSupportActionBar(), atRoot ? caption : currentDir.getFileName(), this);
|
||||
themeToolbarUtils.setColoredTitle(getSupportActionBar(), atRoot ? caption : currentDir.getFileName(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,15 +395,15 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
mChooseBtn = findViewById(R.id.folder_picker_btn_choose);
|
||||
|
||||
if (mChooseBtn != null) {
|
||||
ThemeButtonUtils.colorPrimaryButton(mChooseBtn, this);
|
||||
themeButtonUtils.colorPrimaryButton(mChooseBtn, this, themeColorUtils);
|
||||
mChooseBtn.setOnClickListener(this);
|
||||
}
|
||||
|
||||
if (mCancelBtn != null) {
|
||||
if (this instanceof FilePickerActivity) {
|
||||
ThemeButtonUtils.colorPrimaryButton(mCancelBtn, this);
|
||||
themeButtonUtils.colorPrimaryButton(mCancelBtn, this, themeColorUtils);
|
||||
} else {
|
||||
mCancelBtn.setTextColor(ThemeColorUtils.primaryColor(this, true));
|
||||
mCancelBtn.setTextColor(themeColorUtils.primaryColor(this, true));
|
||||
}
|
||||
mCancelBtn.setOnClickListener(this);
|
||||
}
|
||||
@@ -520,11 +516,10 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
/// TODO refactor and make common
|
||||
syncResult != null && !syncResult.isSuccess()) {
|
||||
|
||||
if (ResultCode.UNAUTHORIZED.equals(syncResult.getCode()) || (syncResult.isException()
|
||||
if (ResultCode.UNAUTHORIZED == syncResult.getCode() || (syncResult.isException()
|
||||
&& syncResult.getException() instanceof AuthenticatorException)) {
|
||||
requestCredentialsUpdate(context);
|
||||
} else if (RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED
|
||||
.equals(syncResult.getCode())) {
|
||||
} else if (ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED == syncResult.getCode()) {
|
||||
showUntrustedCertDialog(syncResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
@@ -58,7 +59,6 @@ import com.owncloud.android.ui.adapter.UserListItem;
|
||||
import com.owncloud.android.ui.dialog.AccountRemovalConfirmationDialog;
|
||||
import com.owncloud.android.ui.events.AccountRemovedEvent;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
|
||||
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
@@ -135,7 +135,7 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
||||
|
||||
// set title Action bar
|
||||
updateActionBarTitleAndHomeButtonByString(getResources().getString(R.string.prefs_manage_accounts));
|
||||
ThemeToolbarUtils.tintBackButton(actionBar, this);
|
||||
themeToolbarUtils.tintBackButton(actionBar, this);
|
||||
|
||||
List<User> users = accountManager.getAllUsers();
|
||||
originalUsers = toAccountNames(users);
|
||||
@@ -153,7 +153,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
||||
accountManager,
|
||||
getUserListItems(),
|
||||
this,
|
||||
multipleAccountsSupported, true);
|
||||
multipleAccountsSupported,
|
||||
true,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils);
|
||||
|
||||
recyclerView.setAdapter(userListAdapter);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
@@ -180,11 +183,18 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, hasAccountListChanged());
|
||||
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, hasCurrentAccountChanged());
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
if (accountManager.getAllUsers().size() > 0) {
|
||||
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, hasAccountListChanged());
|
||||
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, hasCurrentAccountChanged());
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
|
||||
super.onBackPressed();
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
final Intent intent = new Intent(this, AuthenticatorActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,7 +308,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
||||
accountManager,
|
||||
getUserListItems(),
|
||||
this,
|
||||
multipleAccountsSupported, false);
|
||||
multipleAccountsSupported,
|
||||
false,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils);
|
||||
recyclerView.setAdapter(userListAdapter);
|
||||
runOnUiThread(() -> userListAdapter.notifyDataSetChanged());
|
||||
} catch (OperationCanceledException e) {
|
||||
@@ -322,23 +335,23 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
||||
public void run(AccountManagerFuture<Boolean> future) {
|
||||
if (future.isDone()) {
|
||||
// after remove account
|
||||
Account account = new Account(accountName, MainApp.getAccountType(this));
|
||||
if (!accountManager.exists(account)) {
|
||||
Optional<User> user = accountManager.getUser(accountName);
|
||||
if (!user.isPresent()) {
|
||||
// Cancel transfers of the removed account
|
||||
if (mUploaderBinder != null) {
|
||||
mUploaderBinder.cancel(account);
|
||||
mUploaderBinder.cancel(accountName);
|
||||
}
|
||||
if (mDownloaderBinder != null) {
|
||||
mDownloaderBinder.cancel(account);
|
||||
mDownloaderBinder.cancel(accountName);
|
||||
}
|
||||
}
|
||||
|
||||
User user = getUserAccountManager().getUser();
|
||||
if (user.isAnonymous()) {
|
||||
User currentUser = getUserAccountManager().getUser();
|
||||
if (currentUser.isAnonymous()) {
|
||||
String accountName = "";
|
||||
Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType(this));
|
||||
if (accounts.length != 0) {
|
||||
accountName = accounts[0].name;
|
||||
List<User> users = accountManager.getAllUsers();
|
||||
if (users.size() > 0) {
|
||||
accountName = users.get(0).getAccountName();
|
||||
}
|
||||
accountManager.setCurrentOwnCloudAccount(accountName);
|
||||
}
|
||||
@@ -349,7 +362,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
||||
accountManager,
|
||||
userListItemArray,
|
||||
this,
|
||||
multipleAccountsSupported, false);
|
||||
multipleAccountsSupported,
|
||||
false,
|
||||
themeColorUtils,
|
||||
themeDrawableUtils);
|
||||
recyclerView.setAdapter(userListAdapter);
|
||||
} else {
|
||||
onBackPressed();
|
||||
@@ -418,10 +434,10 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap
|
||||
|
||||
// Cancel transfers
|
||||
if (mUploaderBinder != null) {
|
||||
mUploaderBinder.cancel(user.toPlatformAccount());
|
||||
mUploaderBinder.cancel(user);
|
||||
}
|
||||
if (mDownloaderBinder != null) {
|
||||
mDownloaderBinder.cancel(user.toPlatformAccount());
|
||||
mDownloaderBinder.cancel(user.getAccountName());
|
||||
}
|
||||
|
||||
backgroundJobManager.startAccountRemovalJob(user.getAccountName(), false);
|
||||
|
||||
@@ -49,7 +49,6 @@ import com.owncloud.android.ui.asynctasks.DeleteAllNotificationsTask;
|
||||
import com.owncloud.android.ui.notifications.NotificationsContract;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.PushUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeLayoutUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -101,8 +100,8 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
|
||||
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_notifications));
|
||||
|
||||
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
|
||||
ThemeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingEmpty);
|
||||
themeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingList);
|
||||
themeLayoutUtils.colorSwipeRefreshLayout(this, binding.swipeContainingEmpty);
|
||||
|
||||
// setup drawer
|
||||
setupDrawer(R.id.nav_notifications);
|
||||
@@ -259,7 +258,7 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
|
||||
private void initializeAdapter() {
|
||||
initializeClient();
|
||||
if (adapter == null) {
|
||||
adapter = new NotificationListAdapter(client, this);
|
||||
adapter = new NotificationListAdapter(client, this, themeColorUtils, themeButtonUtils);
|
||||
binding.list.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||