Compare commits
171
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb6cc87824 | ||
|
|
97883ff945 | ||
|
|
73f5310dc2 | ||
|
|
a329a0d9d7 | ||
|
|
94d973f54d | ||
|
|
ee88ce3d2d | ||
|
|
c98310cec0 | ||
|
|
de08d130df | ||
|
|
47f6c9ca6f | ||
|
|
46cd070edf | ||
|
|
0efb9c08bf | ||
|
|
5877f5d0e2 | ||
|
|
f50023b070 | ||
|
|
df647c1bed | ||
|
|
b971c05ba1 | ||
|
|
152cb58be8 | ||
|
|
ed718f93a1 | ||
|
|
b6caf3be9d | ||
|
|
a581aa0dc9 | ||
|
|
091f95cc72 | ||
|
|
dfe2eb5f91 | ||
|
|
9a2e3de4f9 | ||
|
|
4a35889c58 | ||
|
|
85638e5837 | ||
|
|
4b4a2fabe1 | ||
|
|
ca9d32c090 | ||
|
|
578c775df8 | ||
|
|
283897e677 | ||
|
|
a523ff88bd | ||
|
|
ffc9cb1c03 | ||
|
|
6ba7f0f387 | ||
|
|
75700a723a | ||
|
|
5c293941ba | ||
|
|
335ee42f0a | ||
|
|
162a2ea912 | ||
|
|
df4470e9c2 | ||
|
|
a0e793aaba | ||
|
|
9d8f954e17 | ||
|
|
6d88d92bb0 | ||
|
|
5831a1af00 | ||
|
|
1b1f389198 | ||
|
|
ed0f58f812 | ||
|
|
0dc7528531 | ||
|
|
6c9bf67a3f | ||
|
|
a8c6c0b439 | ||
|
|
36e009efd9 | ||
|
|
520c0430de | ||
|
|
c297c79408 | ||
|
|
02fc6ffbac | ||
|
|
89fbc6b387 | ||
|
|
13978f6a6d | ||
|
|
7567bf18d4 | ||
|
|
662090c94c | ||
|
|
ddaf3aa54e | ||
|
|
d96069fe6b | ||
|
|
c9a3cda935 | ||
|
|
327d77f164 | ||
|
|
bbf7238c90 | ||
|
|
694392c3a5 | ||
|
|
60e7555609 | ||
|
|
20c33e4547 | ||
|
|
0619deb785 | ||
|
|
fcf2d18bf8 | ||
|
|
7e6f04d2e0 | ||
|
|
7b3a386b45 | ||
|
|
ba49eb35b1 | ||
|
|
4b29f0edc6 | ||
|
|
972ee009d2 | ||
|
|
ba771f4e34 | ||
|
|
f534e9c527 | ||
|
|
dd388ac778 | ||
|
|
55dc58b1af | ||
|
|
08badbe48d | ||
|
|
39b4c43069 | ||
|
|
c29ca194d8 | ||
|
|
d563183ff0 | ||
|
|
5e42046ba0 | ||
|
|
78b7eb02ab | ||
|
|
816cfad14d | ||
|
|
2dc9be66c8 | ||
|
|
7796b21c50 | ||
|
|
a7a15d7f24 | ||
|
|
4bf3958acb | ||
|
|
0784e4328a | ||
|
|
82e6ffe4ec | ||
|
|
86292ac0de | ||
|
|
0a032aec47 | ||
|
|
1122ff6718 | ||
|
|
c9bfcc8211 | ||
|
|
31ff8c3edf | ||
|
|
0ca7eb7173 | ||
|
|
3274a912eb | ||
|
|
016f45f5c2 | ||
|
|
522eab1cbe | ||
|
|
6ea02535fe | ||
|
|
fe9aeed461 | ||
|
|
6e72d3a708 | ||
|
|
0993af94eb | ||
|
|
5689daa9d8 | ||
|
|
39fb0065cc | ||
|
|
2fbc6b1af8 | ||
|
|
cf8b4a16b7 | ||
|
|
1cd0170cec | ||
|
|
0d920bc2bd | ||
|
|
893b7646ff | ||
|
|
3c919b6d0b | ||
|
|
f4a4fee858 | ||
|
|
07e79be92f | ||
|
|
b32a475873 | ||
|
|
625e31b406 | ||
|
|
46b9b0943c | ||
|
|
6ef6c0713a | ||
|
|
e5ebcb12b0 | ||
|
|
79020def18 | ||
|
|
524b858bf7 | ||
|
|
2e0cb9c122 | ||
|
|
ce5b92f9a0 | ||
|
|
9143c26098 | ||
|
|
50b395c70f | ||
|
|
6eeb8c577f | ||
|
|
ce3df85301 | ||
|
|
c2b33600e3 | ||
|
|
f3d2f485e2 | ||
|
|
264e647109 | ||
|
|
ec88e5c720 | ||
|
|
9a564043d9 | ||
|
|
381644b633 | ||
|
|
cc5dcbb746 | ||
|
|
73dae25839 | ||
|
|
a4dfd38792 | ||
|
|
9194a2ca8b | ||
|
|
69fec56b8d | ||
|
|
ffed2e5362 | ||
|
|
8b984c0fdc | ||
|
|
3c20764752 | ||
|
|
5f66d999a3 | ||
|
|
507735cf23 | ||
|
|
afcfdadc1d | ||
|
|
feb22fee7d | ||
|
|
5701e4cae3 | ||
|
|
4a157de7ce | ||
|
|
0673ad6576 | ||
|
|
fe431dc991 | ||
|
|
497d08366f | ||
|
|
d624547cb8 | ||
|
|
186ac9a211 | ||
|
|
f0a6368593 | ||
|
|
79a915e464 | ||
|
|
afe56c70e8 | ||
|
|
a2d1fada39 | ||
|
|
f4b1796d7d | ||
|
|
af939e4815 | ||
|
|
5ebb6f31d1 | ||
|
|
e5708f8f1b | ||
|
|
8091b42062 | ||
|
|
e23df6c8c8 | ||
|
|
179a2d8b1b | ||
|
|
3575a3f929 | ||
|
|
0168c8af49 | ||
|
|
1c83280862 | ||
|
|
408d60116e | ||
|
|
03e4a61c44 | ||
|
|
f342f5d5f6 | ||
|
|
dc1b542613 | ||
|
|
e258fb72ca | ||
|
|
0559390c07 | ||
|
|
10c87b730b | ||
|
|
0edfed62bf | ||
|
|
1a428dc761 | ||
|
|
ea93d93390 | ||
|
|
33d7335912 |
No files matched your search
+1
-6
@@ -20,17 +20,12 @@ 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: "Analysis"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
branches: [ master, stable-* ]
|
||||
@@ -10,31 +10,7 @@ jobs:
|
||||
analysis:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup variables
|
||||
id: get-vars
|
||||
run: |
|
||||
if [ -z "$GITHUB_HEAD_REF" ]; then
|
||||
# push
|
||||
echo "::set-output name=branch::$GITHUB_REF_NAME"
|
||||
echo "::set-output name=pr::$GITHUB_RUN_ID"
|
||||
echo "::set-output name=repo::${{ github.repository }}"
|
||||
else
|
||||
# pull request
|
||||
echo "::set-output name=branch::$GITHUB_HEAD_REF"
|
||||
echo "::set-output name=pr::${{ github.event.pull_request.number }}"
|
||||
echo "::set-output name=repo::${{ github.event.pull_request.head.repo.full_name }}"
|
||||
fi
|
||||
- name: Show variables
|
||||
run: |
|
||||
echo "REPO: ${{ steps.get-vars.outputs.repo }}"
|
||||
echo "BRANCH: ${{ steps.get-vars.outputs.branch }}"
|
||||
echo "PR: ${{ steps.get-vars.outputs.pr }}"
|
||||
echo "RUN NUMBER: $GITHUB_RUN_NUMBER"
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
token: ${{ secrets.GIT_TOKEN }}
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
|
||||
@@ -1,27 +1,31 @@
|
||||
name: "QA"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
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
|
||||
with:
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
- name: set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 11
|
||||
- name: Install NDK and cmake
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
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 }}
|
||||
|
||||
@@ -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@v2
|
||||
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,3 +1,23 @@
|
||||
## 3.20.0 RC2 (April 7, 2022)
|
||||
|
||||
- Built-in PDF viewer
|
||||
- Built-in document scanner
|
||||
- Better choices for storage permissions
|
||||
- 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.20.0 RC1 (March 28, 2022)
|
||||
|
||||
- Built-in PDF viewer
|
||||
- Built-in document scanner
|
||||
- Better choices for storage permissions
|
||||
- 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
|
||||
|
||||
+13
-33
@@ -54,20 +54,11 @@ 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 versionPatch = 0
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
def versionPatch = 2
|
||||
def versionBuild = 90 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
|
||||
def ndkEnv = new HashMap<String, String>()
|
||||
@@ -250,7 +241,7 @@ 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"
|
||||
}
|
||||
@@ -261,7 +252,11 @@ dependencies {
|
||||
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.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
|
||||
@@ -277,8 +272,10 @@ dependencies {
|
||||
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"
|
||||
@@ -297,7 +294,7 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
if (!ciBuild) {
|
||||
if (project.hasProperty("leakCanary")) {
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
|
||||
}
|
||||
|
||||
@@ -321,6 +318,7 @@ dependencies {
|
||||
// Android JUnit Runner
|
||||
androidTestImplementation "androidx.test:runner:$androidxTestVersion"
|
||||
androidTestUtil "androidx.test:orchestrator:$androidxTestVersion"
|
||||
androidTestImplementation "androidx.test:core-ktx:$androidxTestVersion"
|
||||
|
||||
// Espresso
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
||||
@@ -381,24 +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 installGitHooks(type: Copy, group: "development") {
|
||||
description = "Install git hooks"
|
||||
from("${project.rootDir}/scripts/hooks") {
|
||||
|
||||
+6
-2
@@ -267,7 +267,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]*'
|
||||
@@ -389,7 +391,9 @@ style:
|
||||
ignoreAnnotation: false
|
||||
ignoreNamedArgument: true
|
||||
ignoreEnums: false
|
||||
excludes: "**/*Test.kt"
|
||||
excludes:
|
||||
- "**/*Test.kt"
|
||||
- "**/*IT.kt"
|
||||
MandatoryBracesIfStatements:
|
||||
active: false
|
||||
MaxLineLength:
|
||||
|
||||
+2
-3
@@ -23,9 +23,7 @@
|
||||
</issue>
|
||||
|
||||
<issue id="UnusedQuantity">
|
||||
<ignore path="**/values-sk-rSK/strings.xml"/>
|
||||
<ignore path="**/values-cs-rCZ/strings.xml"/>
|
||||
<ignore path="**/values-lt-rLT/strings.xml"/>
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
<issue id="ExtraTranslation">
|
||||
@@ -35,6 +33,7 @@
|
||||
|
||||
<issue id="UnusedResources">
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
<ignore path="**/values/setup.xml" />
|
||||
</issue>
|
||||
|
||||
<issue id="TypographyEllipsis">
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ class UploadFilesActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
waitForIdleSync()
|
||||
shortSleep()
|
||||
|
||||
screenshot(sut)
|
||||
}
|
||||
|
||||
+3
-4
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
<string name="google_app_id" translatable="false">1:829118773643:android:512449826e931d0e</string>
|
||||
<string name="google_crash_reporting_api_key" translatable="false">AIzaSyAWIyOcLafaFp8PFL61h64cy1NNZW2cU_s</string>
|
||||
<string name="google_storage_bucket" translatable="false">nextcloud-a7dea.appspot.com</string>
|
||||
<string name="project_id" translatable="false">nextcloud-a7dea</string>
|
||||
</resources>
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
+27
-6
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,7 @@ 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.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;
|
||||
@@ -215,4 +216,7 @@ abstract class ComponentsModule {
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract PreviewPdfFragment previewPDFFragment();
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract SharedListFragment sharedFragment();
|
||||
}
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import android.app.NotificationManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
@@ -56,6 +57,7 @@ import com.nextcloud.client.onboarding.OnboardingService;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.authentication.PassCodeManager;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.MediaFolder;
|
||||
@@ -343,12 +345,33 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initSecurityKeyManager() {
|
||||
SecurityKeyManager securityKeyManager = SecurityKeyManager.getInstance();
|
||||
SecurityKeyManagerConfig config = new SecurityKeyManagerConfig.Builder()
|
||||
.setEnableDebugLogging(BuildConfig.DEBUG)
|
||||
.build();
|
||||
securityKeyManager.init(this, config);
|
||||
final SecurityKeyManagerConfig.Builder configBuilder = new SecurityKeyManagerConfig.Builder()
|
||||
.setEnableDebugLogging(BuildConfig.DEBUG);
|
||||
|
||||
try {
|
||||
// exclude all activities except AuthenticatorActivity
|
||||
final PackageManager pm = this.getPackageManager();
|
||||
final PackageInfo info = pm.getPackageInfo(this.getPackageName(), PackageManager.GET_ACTIVITIES);
|
||||
final ActivityInfo[] activities = info.activities;
|
||||
for (ActivityInfo activityInfo : activities) {
|
||||
try {
|
||||
final Class<? extends Activity> aClass = (Class<? extends Activity>) Class.forName(activityInfo.name);
|
||||
if (aClass != AuthenticatorActivity.class) {
|
||||
configBuilder.addExcludedActivityClass(aClass);
|
||||
}
|
||||
} catch (ClassNotFoundException | ClassCastException e) {
|
||||
Log_OC.e(TAG, "Couldn't disable activity for security key listener", e);
|
||||
}
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log_OC.e(TAG, "Couldn't disable activities for security key listener", e);
|
||||
}
|
||||
|
||||
|
||||
securityKeyManager.init(this, configBuilder.build());
|
||||
}
|
||||
|
||||
public static void initContactsBackup(UserAccountManager accountManager, BackgroundJobManager backgroundJobManager) {
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
@@ -1298,7 +1300,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (PermissionUtil.checkSelfPermission(this, Manifest.permission.CAMERA)) {
|
||||
startQRScanner();
|
||||
} else {
|
||||
PermissionUtil.requestCameraPermission(this);
|
||||
PermissionUtil.requestCameraPermission(this, PERMISSIONS_CAMERA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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>)
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -462,19 +462,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");
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CommunityActivity extends DrawerActivity {
|
||||
|
||||
MaterialButton reportButton = binding.communityTestingReport;
|
||||
ThemeButtonUtils.colorPrimaryButton(reportButton, this);
|
||||
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
|
||||
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_empty_link));
|
||||
|
||||
binding.communityBetaFdroid.setOnClickListener(
|
||||
l -> DisplayUtils.startLinkIntent(this, R.string.fdroid_beta_link));
|
||||
|
||||
@@ -101,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;
|
||||
@@ -431,6 +432,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();
|
||||
@@ -470,8 +472,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());
|
||||
@@ -519,6 +520,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);
|
||||
@@ -528,7 +536,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);
|
||||
|
||||
@@ -743,7 +743,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 +757,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())) {
|
||||
|
||||
@@ -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;
|
||||
@@ -138,7 +140,6 @@ 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 +268,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 =
|
||||
@@ -394,6 +398,15 @@ public class FileDisplayActivity extends FileActivity
|
||||
// toggle on is save since this is the only scenario this code gets accessed
|
||||
}
|
||||
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) {
|
||||
@@ -475,7 +488,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();
|
||||
@@ -483,6 +496,13 @@ public class FileDisplayActivity extends FileActivity
|
||||
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, searchEvent);
|
||||
photoFragment.setArguments(bundle);
|
||||
setLeftFragment(photoFragment);
|
||||
} else if (searchEvent.getSearchType().equals(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");
|
||||
|
||||
@@ -497,6 +517,8 @@ public class FileDisplayActivity extends FileActivity
|
||||
Log_OC.d(this, "Switch to oc file fragment");
|
||||
|
||||
setLeftFragment(new OCFileListFragment());
|
||||
getSupportFragmentManager().executePendingTransactions();
|
||||
browseToRoot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1478,6 +1500,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());
|
||||
@@ -1516,7 +1539,6 @@ public class FileDisplayActivity extends FileActivity
|
||||
|
||||
resetScrolling();
|
||||
|
||||
setFile(file);
|
||||
Fragment detailFragment = FileDetailFragment.newInstance(file, currentUser, activeTab);
|
||||
setLeftFragment(detailFragment);
|
||||
|
||||
@@ -1529,14 +1551,10 @@ public class FileDisplayActivity extends FileActivity
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void lockScrolling() {
|
||||
final CoordinatorLayout.LayoutParams coordinatorParams = (CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams();
|
||||
coordinatorParams.setBehavior(null);
|
||||
binding.rootLayout.setLayoutParams(coordinatorParams);
|
||||
binding.rootLayout.setNestedScrollingEnabled(false);
|
||||
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);
|
||||
binding.appbar.appbar.setExpanded(true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1544,9 +1562,6 @@ public class FileDisplayActivity extends FileActivity
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void resetScrolling() {
|
||||
final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams();
|
||||
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
||||
binding.rootLayout.setLayoutParams(params);
|
||||
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);
|
||||
@@ -2269,8 +2284,10 @@ public class FileDisplayActivity extends FileActivity
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_on_device));
|
||||
}
|
||||
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
|
||||
if (ocFileListFragment != null) {
|
||||
if (ocFileListFragment != null && !(ocFileListFragment instanceof GalleryFragment) && !(ocFileListFragment instanceof SharedListFragment)) {
|
||||
ocFileListFragment.refreshDirectory();
|
||||
} else {
|
||||
setLeftFragment(new OCFileListFragment());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2278,8 +2295,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -180,11 +181,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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -659,8 +659,7 @@ class SyncedFoldersActivity :
|
||||
)
|
||||
saveOrUpdateSyncedFolder(item)
|
||||
|
||||
// TODO test if notifyItemChanged is sufficient (should improve performance)
|
||||
adapter.notifyDataSetChanged()
|
||||
adapter.notifyItemChanged(adapter.getSectionHeaderIndex(syncedFolder.section))
|
||||
}
|
||||
syncedFolderPreferencesDialogFragment = null
|
||||
if (syncedFolder.isEnabled) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.annotation.SuppressLint;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
@@ -73,11 +72,6 @@ public abstract class ToolbarActivity extends BaseActivity {
|
||||
protected AppCompatSpinner mToolbarSpinner;
|
||||
private boolean isHomeSearchToolbarShow = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toolbar setup that must be called in implementer's {@link #onCreate} after {@link #setContentView} if they want
|
||||
* to use the toolbar.
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
|
||||
interface CommonOCFileListAdapterInterface {
|
||||
fun isMultiSelect(): Boolean
|
||||
fun cancelAllPendingTasks()
|
||||
fun getItemPosition(file: OCFile): Int
|
||||
fun swapDirectory(
|
||||
user: User,
|
||||
directory: OCFile,
|
||||
storageManager: FileDataStorageManager,
|
||||
onlyOnDevice: Boolean,
|
||||
mLimitToMimeType: String
|
||||
)
|
||||
|
||||
fun setHighlightedItem(file: OCFile)
|
||||
fun setSortOrder(mFile: OCFile, sortOrder: FileSortOrder)
|
||||
fun addCheckedFile(file: OCFile)
|
||||
fun isCheckedFile(file: OCFile): Boolean
|
||||
fun getCheckedItems(): Set<OCFile>
|
||||
fun removeCheckedFile(file: OCFile)
|
||||
fun notifyItemChanged(file: OCFile)
|
||||
fun getFilesCount(): Int
|
||||
fun setMultiSelect(boolean: Boolean)
|
||||
fun clearCheckedItems()
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import com.afollestad.sectionedrecyclerview.SectionedRecyclerViewAdapter
|
||||
import com.afollestad.sectionedrecyclerview.SectionedViewHolder
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.databinding.GalleryHeaderBinding
|
||||
import com.owncloud.android.databinding.GridImageBinding
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.GalleryItems
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
|
||||
class GalleryAdapter(
|
||||
val context: Context,
|
||||
user: User,
|
||||
ocFileListFragmentInterface: OCFileListFragmentInterface,
|
||||
preferences: AppPreferences,
|
||||
transferServiceGetter: ComponentsGetter
|
||||
) : SectionedRecyclerViewAdapter<SectionedViewHolder>(), CommonOCFileListAdapterInterface, PopupTextProvider {
|
||||
var files: List<GalleryItems> = mutableListOf()
|
||||
private var ocFileListDelegate: OCFileListDelegate
|
||||
private var storageManager: FileDataStorageManager
|
||||
|
||||
init {
|
||||
storageManager = transferServiceGetter.storageManager
|
||||
|
||||
ocFileListDelegate = OCFileListDelegate(
|
||||
context,
|
||||
ocFileListFragmentInterface,
|
||||
user,
|
||||
storageManager,
|
||||
false,
|
||||
preferences,
|
||||
true,
|
||||
transferServiceGetter,
|
||||
showMetadata = false,
|
||||
showShareAvatar = false
|
||||
)
|
||||
}
|
||||
|
||||
override fun showFooters(): Boolean = false
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SectionedViewHolder {
|
||||
return if (viewType == VIEW_TYPE_HEADER) {
|
||||
GalleryHeaderViewHolder(
|
||||
GalleryHeaderBinding.inflate(
|
||||
LayoutInflater.from(parent.context),
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
} else {
|
||||
GalleryItemViewHolder(
|
||||
GridImageBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(
|
||||
holder: SectionedViewHolder?,
|
||||
section: Int,
|
||||
relativePosition: Int,
|
||||
absolutePosition: Int
|
||||
) {
|
||||
if (holder != null) {
|
||||
val itemViewHolder = holder as GalleryItemViewHolder
|
||||
val ocFile = files[section].files[relativePosition]
|
||||
|
||||
ocFileListDelegate.bindGridViewHolder(itemViewHolder, ocFile)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(section: Int): Int {
|
||||
return files[section].files.size
|
||||
}
|
||||
|
||||
override fun getSectionCount(): Int {
|
||||
return files.size
|
||||
}
|
||||
|
||||
override fun getPopupText(position: Int): String {
|
||||
return DisplayUtils.getDateByPattern(
|
||||
files[getRelativePosition(position).section()].date,
|
||||
context,
|
||||
DisplayUtils.MONTH_YEAR_PATTERN
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindHeaderViewHolder(holder: SectionedViewHolder?, section: Int, expanded: Boolean) {
|
||||
if (holder != null) {
|
||||
val headerViewHolder = holder as GalleryHeaderViewHolder
|
||||
val galleryItem = files[section]
|
||||
|
||||
headerViewHolder.binding.month.text = DisplayUtils.getDateByPattern(
|
||||
galleryItem.date,
|
||||
context,
|
||||
DisplayUtils.MONTH_PATTERN
|
||||
)
|
||||
headerViewHolder.binding.year.text = DisplayUtils.getDateByPattern(
|
||||
galleryItem.date,
|
||||
context, DisplayUtils.YEAR_PATTERN
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBindFooterViewHolder(holder: SectionedViewHolder?, section: Int) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun showAllGalleryItems() {
|
||||
val items = storageManager.allGalleryItems
|
||||
|
||||
files = items
|
||||
.groupBy { firstOfMonth(it.modificationTimestamp) }
|
||||
.map { GalleryItems(it.key, FileStorageUtils.sortOcFolderDescDateModifiedWithoutFavoritesFirst(it.value)) }
|
||||
.sortedBy { it.date }.reversed()
|
||||
|
||||
Handler(Looper.getMainLooper()).post { notifyDataSetChanged() }
|
||||
}
|
||||
|
||||
private fun firstOfMonth(timestamp: Long): Long {
|
||||
val cal = Calendar.getInstance()
|
||||
cal.time = Date(timestamp)
|
||||
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH))
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0)
|
||||
cal.set(Calendar.MINUTE, 0)
|
||||
cal.set(Calendar.SECOND, 0)
|
||||
|
||||
return cal.timeInMillis
|
||||
}
|
||||
|
||||
fun isEmpty(): Boolean {
|
||||
return files.isEmpty()
|
||||
}
|
||||
|
||||
fun getItem(position: Int): OCFile? {
|
||||
val itemCoord = getRelativePosition(position)
|
||||
return files
|
||||
.getOrNull(itemCoord.section())?.files
|
||||
?.getOrNull(itemCoord.relativePos())
|
||||
}
|
||||
|
||||
override fun isMultiSelect(): Boolean {
|
||||
return ocFileListDelegate.isMultiSelect
|
||||
}
|
||||
|
||||
override fun cancelAllPendingTasks() {
|
||||
ocFileListDelegate.cancelAllPendingTasks()
|
||||
}
|
||||
|
||||
override fun getItemPosition(file: OCFile): Int {
|
||||
val item = files.find { it.files.contains(file) }
|
||||
return getAbsolutePosition(files.indexOf(item), item?.files?.indexOf(file) ?: 0)
|
||||
}
|
||||
|
||||
override fun swapDirectory(
|
||||
user: User,
|
||||
directory: OCFile,
|
||||
storageManager: FileDataStorageManager,
|
||||
onlyOnDevice: Boolean,
|
||||
mLimitToMimeType: String
|
||||
) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun setHighlightedItem(file: OCFile) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun setSortOrder(mFile: OCFile, sortOrder: FileSortOrder) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun addCheckedFile(file: OCFile) {
|
||||
ocFileListDelegate.addCheckedFile(file)
|
||||
}
|
||||
|
||||
override fun isCheckedFile(file: OCFile): Boolean {
|
||||
return ocFileListDelegate.isCheckedFile(file)
|
||||
}
|
||||
|
||||
override fun getCheckedItems(): Set<OCFile> {
|
||||
return ocFileListDelegate.checkedItems
|
||||
}
|
||||
|
||||
override fun removeCheckedFile(file: OCFile) {
|
||||
ocFileListDelegate.removeCheckedFile(file)
|
||||
}
|
||||
|
||||
override fun notifyItemChanged(file: OCFile) {
|
||||
notifyItemChanged(getItemPosition(file))
|
||||
}
|
||||
|
||||
override fun getFilesCount(): Int {
|
||||
return files.fold(0) { acc, item -> acc + item.files.size }
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun setMultiSelect(boolean: Boolean) {
|
||||
ocFileListDelegate.isMultiSelect = boolean
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun clearCheckedItems() {
|
||||
ocFileListDelegate.clearCheckedItems()
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
fun addFiles(items: List<GalleryItems>) {
|
||||
files = items
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import com.afollestad.sectionedrecyclerview.SectionedViewHolder
|
||||
import com.owncloud.android.databinding.GalleryHeaderBinding
|
||||
|
||||
class GalleryHeaderViewHolder(val binding: GalleryHeaderBinding) : SectionedViewHolder(binding.root)
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.afollestad.sectionedrecyclerview.SectionedViewHolder
|
||||
import com.elyeproj.loaderviewlibrary.LoaderImageView
|
||||
import com.owncloud.android.databinding.GridImageBinding
|
||||
|
||||
class GalleryItemViewHolder(val binding: GridImageBinding) :
|
||||
SectionedViewHolder(binding.root), ListGridImageViewHolder {
|
||||
override val thumbnail: ImageView
|
||||
get() = binding.thumbnail
|
||||
|
||||
override val shimmerThumbnail: LoaderImageView
|
||||
get() = binding.thumbnailShimmer
|
||||
|
||||
override val favorite: ImageView
|
||||
get() = binding.favoriteAction
|
||||
|
||||
override val localFileIndicator: ImageView
|
||||
get() = binding.localFileIndicator
|
||||
|
||||
override val shared: ImageView
|
||||
get() = binding.sharedIcon
|
||||
|
||||
override val checkbox: ImageView
|
||||
get() = binding.customCheckbox
|
||||
|
||||
override val itemLayout: View
|
||||
get() = binding.ListItemLayout
|
||||
|
||||
override val unreadComments: ImageView
|
||||
get() = binding.unreadComments
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.elyeproj.loaderviewlibrary.LoaderImageView
|
||||
|
||||
interface ListGridImageViewHolder {
|
||||
val thumbnail: ImageView
|
||||
val shimmerThumbnail: LoaderImageView
|
||||
val favorite: ImageView
|
||||
val localFileIndicator: ImageView
|
||||
val shared: ImageView
|
||||
val checkbox: ImageView
|
||||
val itemLayout: View
|
||||
val unreadComments: ImageView
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.widget.TextView
|
||||
|
||||
internal interface ListGridItemViewHolder : ListGridImageViewHolder {
|
||||
val fileName: TextView
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import com.owncloud.android.ui.AvatarGroupLayout
|
||||
|
||||
internal interface ListItemViewHolder : ListGridItemViewHolder {
|
||||
val fileSize: TextView
|
||||
val fileSizeSeparator: View
|
||||
val lastModification: TextView
|
||||
val overflowMenu: ImageView
|
||||
val sharedAvatars: AvatarGroupLayout
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.ThumbnailGenerationTask
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter
|
||||
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils
|
||||
import com.owncloud.android.utils.theme.ThemeDrawableUtils
|
||||
|
||||
@Suppress("LongParameterList", "TooManyFunctions")
|
||||
class OCFileListDelegate(
|
||||
private val context: Context,
|
||||
private val ocFileListFragmentInterface: OCFileListFragmentInterface,
|
||||
private val user: User,
|
||||
private val storageManager: FileDataStorageManager,
|
||||
private val hideItemOptions: Boolean,
|
||||
private val preferences: AppPreferences,
|
||||
private val gridView: Boolean,
|
||||
private val transferServiceGetter: ComponentsGetter,
|
||||
private val showMetadata: Boolean,
|
||||
private var showShareAvatar: Boolean
|
||||
) {
|
||||
private val checkedFiles: MutableSet<OCFile> = HashSet()
|
||||
private var highlightedItem: OCFile? = null
|
||||
var isMultiSelect = false
|
||||
private val asyncTasks: MutableList<ThumbnailGenerationTask> = ArrayList()
|
||||
fun setHighlightedItem(highlightedItem: OCFile?) {
|
||||
this.highlightedItem = highlightedItem
|
||||
}
|
||||
|
||||
fun isCheckedFile(file: OCFile): Boolean {
|
||||
return checkedFiles.contains(file)
|
||||
}
|
||||
|
||||
fun addCheckedFile(file: OCFile) {
|
||||
checkedFiles.add(file)
|
||||
highlightedItem = null
|
||||
}
|
||||
|
||||
fun removeCheckedFile(file: OCFile) {
|
||||
checkedFiles.remove(file)
|
||||
}
|
||||
|
||||
fun addToCheckedFiles(files: List<OCFile>?) {
|
||||
checkedFiles.addAll(files!!)
|
||||
}
|
||||
|
||||
val checkedItems: Set<OCFile>
|
||||
get() = checkedFiles
|
||||
|
||||
fun setCheckedItem(files: Set<OCFile>?) {
|
||||
checkedFiles.clear()
|
||||
checkedFiles.addAll(files!!)
|
||||
}
|
||||
|
||||
fun clearCheckedItems() {
|
||||
checkedFiles.clear()
|
||||
}
|
||||
|
||||
fun bindGridViewHolder(gridViewHolder: ListGridImageViewHolder, file: OCFile) {
|
||||
// thumbnail
|
||||
gridViewHolder.thumbnail.tag = file.fileId
|
||||
DisplayUtils.setThumbnail(
|
||||
file,
|
||||
gridViewHolder.thumbnail,
|
||||
user,
|
||||
storageManager,
|
||||
asyncTasks,
|
||||
gridView,
|
||||
context,
|
||||
gridViewHolder.shimmerThumbnail,
|
||||
preferences
|
||||
)
|
||||
// item layout + click listeners
|
||||
bindGridItemLayout(file, gridViewHolder)
|
||||
|
||||
// unread comments
|
||||
bindUnreadComments(file, gridViewHolder)
|
||||
|
||||
// multiSelect (Checkbox)
|
||||
if (isMultiSelect) {
|
||||
gridViewHolder.checkbox.visibility = View.VISIBLE
|
||||
} else {
|
||||
gridViewHolder.checkbox.visibility = View.GONE
|
||||
}
|
||||
|
||||
// download state
|
||||
gridViewHolder.localFileIndicator.visibility = View.INVISIBLE // default first
|
||||
|
||||
// metadata (downloaded, favorite)
|
||||
bindGridMetadataViews(file, gridViewHolder)
|
||||
|
||||
// shares
|
||||
val shouldHideShare = gridView || hideItemOptions || file.isFolder && !file.canReshare()
|
||||
if (shouldHideShare) {
|
||||
gridViewHolder.shared.visibility = View.GONE
|
||||
} else {
|
||||
showShareIcon(gridViewHolder, file)
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindUnreadComments(file: OCFile, gridViewHolder: ListGridImageViewHolder) {
|
||||
if (file.unreadCommentsCount > 0) {
|
||||
gridViewHolder.unreadComments.visibility = View.VISIBLE
|
||||
gridViewHolder.unreadComments.setOnClickListener {
|
||||
ocFileListFragmentInterface
|
||||
.showActivityDetailView(file)
|
||||
}
|
||||
} else {
|
||||
gridViewHolder.unreadComments.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindGridItemLayout(file: OCFile, gridViewHolder: ListGridImageViewHolder) {
|
||||
if (highlightedItem != null && file.fileId == highlightedItem!!.fileId) {
|
||||
gridViewHolder.itemLayout.setBackgroundColor(
|
||||
context.resources
|
||||
.getColor(R.color.selected_item_background)
|
||||
)
|
||||
} else if (isCheckedFile(file)) {
|
||||
gridViewHolder.itemLayout.setBackgroundColor(
|
||||
context.resources
|
||||
.getColor(R.color.selected_item_background)
|
||||
)
|
||||
gridViewHolder.checkbox.setImageDrawable(
|
||||
ThemeDrawableUtils.tintDrawable(
|
||||
R.drawable.ic_checkbox_marked,
|
||||
ThemeColorUtils.primaryColor(context)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
gridViewHolder.itemLayout.setBackgroundColor(context.resources.getColor(R.color.bg_default))
|
||||
gridViewHolder.checkbox.setImageResource(R.drawable.ic_checkbox_blank_outline)
|
||||
}
|
||||
gridViewHolder.itemLayout.setOnClickListener { ocFileListFragmentInterface.onItemClicked(file) }
|
||||
if (!hideItemOptions) {
|
||||
gridViewHolder.itemLayout.isLongClickable = true
|
||||
gridViewHolder.itemLayout.setOnLongClickListener {
|
||||
ocFileListFragmentInterface.onLongItemClicked(
|
||||
file
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindGridMetadataViews(file: OCFile, gridViewHolder: ListGridImageViewHolder) {
|
||||
if (showMetadata) {
|
||||
showLocalFileIndicator(file, gridViewHolder)
|
||||
gridViewHolder.favorite.visibility = if (file.isFavorite) View.VISIBLE else View.GONE
|
||||
} else {
|
||||
gridViewHolder.localFileIndicator.visibility = View.GONE
|
||||
gridViewHolder.favorite.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun showLocalFileIndicator(file: OCFile, gridViewHolder: ListGridImageViewHolder) {
|
||||
val operationsServiceBinder = transferServiceGetter.operationsServiceBinder
|
||||
val fileDownloaderBinder = transferServiceGetter.fileDownloaderBinder
|
||||
val fileUploaderBinder = transferServiceGetter.fileUploaderBinder
|
||||
when {
|
||||
operationsServiceBinder?.isSynchronizing(user, file) == true ||
|
||||
fileDownloaderBinder?.isDownloading(user, file) == true ||
|
||||
fileUploaderBinder?.isUploading(user, file) == true -> {
|
||||
// synchronizing, downloading or uploading
|
||||
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing)
|
||||
gridViewHolder.localFileIndicator.visibility = View.VISIBLE
|
||||
}
|
||||
file.etagInConflict != null -> {
|
||||
// conflict
|
||||
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synchronizing_error)
|
||||
gridViewHolder.localFileIndicator.visibility = View.VISIBLE
|
||||
}
|
||||
file.isDown -> {
|
||||
// downloaded
|
||||
gridViewHolder.localFileIndicator.setImageResource(R.drawable.ic_synced)
|
||||
gridViewHolder.localFileIndicator.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showShareIcon(gridViewHolder: ListGridImageViewHolder, file: OCFile) {
|
||||
val sharedIconView = gridViewHolder.shared
|
||||
if (gridViewHolder is OCFileListItemViewHolder || file.unreadCommentsCount == 0) {
|
||||
sharedIconView.visibility = View.VISIBLE
|
||||
if (file.isSharedWithSharee || file.isSharedWithMe) {
|
||||
if (showShareAvatar) {
|
||||
sharedIconView.visibility = View.GONE
|
||||
} else {
|
||||
sharedIconView.visibility = View.VISIBLE
|
||||
sharedIconView.setImageResource(R.drawable.shared_via_users)
|
||||
sharedIconView.contentDescription = context.getString(R.string.shared_icon_shared)
|
||||
}
|
||||
} else if (file.isSharedViaLink) {
|
||||
sharedIconView.setImageResource(R.drawable.shared_via_link)
|
||||
sharedIconView.contentDescription = context.getString(R.string.shared_icon_shared_via_link)
|
||||
} else {
|
||||
sharedIconView.setImageResource(R.drawable.ic_unshared)
|
||||
sharedIconView.contentDescription = context.getString(R.string.shared_icon_share)
|
||||
}
|
||||
sharedIconView.setOnClickListener { ocFileListFragmentInterface.onShareIconClick(file) }
|
||||
} else {
|
||||
sharedIconView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelAllPendingTasks() {
|
||||
for (task in asyncTasks) {
|
||||
task.cancel(true)
|
||||
if (task.getMethod != null) {
|
||||
Log_OC.d(TAG, "cancel: abort get method directly")
|
||||
task.getMethod.abort()
|
||||
}
|
||||
}
|
||||
asyncTasks.clear()
|
||||
}
|
||||
|
||||
fun setShowShareAvatar(bool: Boolean) {
|
||||
showShareAvatar = bool
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = OCFileListDelegate::class.java.simpleName
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.owncloud.android.databinding.ListFooterBinding
|
||||
|
||||
internal class OCFileListFooterViewHolder(var binding: ListFooterBinding) : RecyclerView.ViewHolder(
|
||||
binding.root
|
||||
) {
|
||||
val footerText
|
||||
get() = binding.footerText
|
||||
|
||||
val loadingProgressBar
|
||||
get() = binding.loadingProgressBar
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.elyeproj.loaderviewlibrary.LoaderImageView
|
||||
import com.owncloud.android.databinding.GridImageBinding
|
||||
|
||||
internal class OCFileListGridImageViewHolder(var binding: GridImageBinding) :
|
||||
RecyclerView.ViewHolder(
|
||||
binding.root
|
||||
),
|
||||
ListGridImageViewHolder {
|
||||
override val thumbnail: ImageView
|
||||
get() = binding.thumbnail
|
||||
override val shimmerThumbnail: LoaderImageView
|
||||
get() = binding.thumbnailShimmer
|
||||
override val favorite: ImageView
|
||||
get() = binding.favoriteAction
|
||||
override val localFileIndicator: ImageView
|
||||
get() = binding.localFileIndicator
|
||||
override val shared: ImageView
|
||||
get() = binding.sharedIcon
|
||||
override val checkbox: ImageView
|
||||
get() = binding.customCheckbox
|
||||
override val itemLayout: View
|
||||
get() = binding.ListItemLayout
|
||||
override val unreadComments: ImageView
|
||||
get() = binding.unreadComments
|
||||
|
||||
init {
|
||||
binding.favoriteAction.drawable.mutate()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.elyeproj.loaderviewlibrary.LoaderImageView
|
||||
import com.owncloud.android.databinding.GridItemBinding
|
||||
|
||||
internal class OCFileListGridItemViewHolder(var binding: GridItemBinding) :
|
||||
RecyclerView.ViewHolder(
|
||||
binding.root
|
||||
),
|
||||
ListGridItemViewHolder {
|
||||
override val fileName: TextView
|
||||
get() = binding.Filename
|
||||
override val thumbnail: ImageView
|
||||
get() = binding.thumbnail
|
||||
override val shimmerThumbnail: LoaderImageView
|
||||
get() = binding.thumbnailShimmer
|
||||
override val favorite: ImageView
|
||||
get() = binding.favoriteAction
|
||||
override val localFileIndicator: ImageView
|
||||
get() = binding.localFileIndicator
|
||||
override val shared: ImageView
|
||||
get() = binding.sharedIcon
|
||||
override val checkbox: ImageView
|
||||
get() = binding.customCheckbox
|
||||
override val itemLayout: View
|
||||
get() = binding.ListItemLayout
|
||||
override val unreadComments: ImageView
|
||||
get() = binding.unreadComments
|
||||
|
||||
init {
|
||||
binding.favoriteAction.drawable.mutate()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.owncloud.android.databinding.ListHeaderBinding
|
||||
|
||||
internal class OCFileListHeaderViewHolder(var binding: ListHeaderBinding) : RecyclerView.ViewHolder(
|
||||
binding.root
|
||||
) {
|
||||
val headerText
|
||||
get() = binding.headerText
|
||||
|
||||
val headerView
|
||||
get() = binding.headerView
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
* 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.adapter
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.elyeproj.loaderviewlibrary.LoaderImageView
|
||||
import com.owncloud.android.databinding.ListItemBinding
|
||||
import com.owncloud.android.ui.AvatarGroupLayout
|
||||
|
||||
internal class OCFileListItemViewHolder(private var binding: ListItemBinding) :
|
||||
RecyclerView.ViewHolder(
|
||||
binding.root
|
||||
),
|
||||
ListItemViewHolder {
|
||||
override val fileSize: TextView
|
||||
get() = binding.fileSize
|
||||
override val fileSizeSeparator: View
|
||||
get() = binding.fileSeparator
|
||||
override val lastModification: TextView
|
||||
get() = binding.lastMod
|
||||
override val overflowMenu: ImageView
|
||||
get() = binding.overflowMenu
|
||||
override val sharedAvatars: AvatarGroupLayout
|
||||
get() = binding.sharedAvatars
|
||||
override val fileName: TextView
|
||||
get() = binding.Filename
|
||||
override val thumbnail: ImageView
|
||||
get() = binding.thumbnail
|
||||
override val shimmerThumbnail: LoaderImageView
|
||||
get() = binding.thumbnailShimmer
|
||||
override val favorite: ImageView
|
||||
get() = binding.favoriteAction
|
||||
override val localFileIndicator: ImageView
|
||||
get() = binding.localFileIndicator
|
||||
override val shared: ImageView
|
||||
get() = binding.sharedIcon
|
||||
override val checkbox: ImageView
|
||||
get() = binding.customCheckbox
|
||||
override val itemLayout: View
|
||||
get() = binding.ListItemLayout
|
||||
override val unreadComments: ImageView
|
||||
get() = binding.unreadComments
|
||||
|
||||
init {
|
||||
binding.favoriteAction.drawable.mutate()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.adapter
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.OCShare
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.lib.resources.shares.ShareeUser
|
||||
|
||||
object OCShareToOCFileConverter {
|
||||
private const val MILLIS_PER_SECOND = 1000
|
||||
|
||||
/**
|
||||
* Generates a list of incomplete [OCFile] from a list of [OCShare]
|
||||
*
|
||||
* This is actually pretty complex as we get one [OCShare] item for each shared instance for the same folder
|
||||
*
|
||||
* **THIS ONLY WORKS WITH FILES SHARED *BY* THE USER, NOT FOR SHARES *WITH* THE USER**
|
||||
*/
|
||||
@JvmStatic
|
||||
fun buildOCFilesFromShares(shares: List<OCShare>): List<OCFile> {
|
||||
val groupedByPath: Map<String, List<OCShare>> = shares.groupBy { it.path }
|
||||
return groupedByPath
|
||||
.map { (path: String, shares: List<OCShare>) -> buildOcFile(path, shares) }
|
||||
.sortedByDescending { it.firstShareTimestamp }
|
||||
}
|
||||
|
||||
private fun buildOcFile(path: String, shares: List<OCShare>): OCFile {
|
||||
require(shares.all { it.path == path })
|
||||
// common attributes
|
||||
val firstShare = shares.first()
|
||||
val file = OCFile(path).apply {
|
||||
decryptedRemotePath = path
|
||||
ownerId = firstShare.userId
|
||||
ownerDisplayName = firstShare.ownerDisplayName
|
||||
isPreviewAvailable = firstShare.isHasPreview
|
||||
mimeType = firstShare.mimetype
|
||||
note = firstShare.note
|
||||
fileId = firstShare.fileSource
|
||||
remoteId = firstShare.remoteId.toString()
|
||||
// use first share timestamp as timestamp
|
||||
firstShareTimestamp = shares.minOf { it.sharedDate * MILLIS_PER_SECOND }
|
||||
// don't have file length or mod timestamp
|
||||
fileLength = -1
|
||||
modificationTimestamp = -1
|
||||
}
|
||||
if (shares.any { it.shareType in listOf(ShareType.PUBLIC_LINK, ShareType.EMAIL) }) {
|
||||
file.isSharedViaLink = true
|
||||
}
|
||||
if (shares.any { it.shareType !in listOf(ShareType.PUBLIC_LINK, ShareType.EMAIL) }) {
|
||||
file.isSharedWithSharee = true
|
||||
file.sharees = shares
|
||||
.filter { it.shareType != ShareType.PUBLIC_LINK && it.shareType != ShareType.EMAIL }
|
||||
.map { ShareeUser(it.shareWith, it.sharedWithDisplayName, it.shareType) }
|
||||
}
|
||||
return file
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,9 @@ public class ShareeListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
shares.addAll(users);
|
||||
|
||||
// add internal share link at end
|
||||
shares.add(new OCShare().setShareType(ShareType.INTERNAL));
|
||||
final OCShare ocShare = new OCShare();
|
||||
ocShare.setShareType(ShareType.INTERNAL);
|
||||
shares.add(ocShare);
|
||||
}
|
||||
|
||||
public List<OCShare> getShares() {
|
||||
|
||||
@@ -43,6 +43,8 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
|
||||
public class GallerySearchTask extends AsyncTask<Void, Void, GallerySearchTask.Result> {
|
||||
|
||||
private final User user;
|
||||
@@ -99,9 +101,6 @@ public class GallerySearchTask extends AsyncTask<Void, Void, GallerySearchTask.R
|
||||
|
||||
boolean emptySearch = parseMedia(startDate, endDate, result.getData());
|
||||
long lastTimeStamp = findLastTimestamp(result.getData());
|
||||
|
||||
photoFragment.getAdapter().showAllGalleryItems(storageManager);
|
||||
|
||||
return new Result(result.isSuccess(), emptySearch, lastTimeStamp);
|
||||
} else {
|
||||
return new Result(false, false, -1);
|
||||
@@ -117,7 +116,9 @@ public class GallerySearchTask extends AsyncTask<Void, Void, GallerySearchTask.R
|
||||
photoFragment.setLoading(false);
|
||||
photoFragment.searchCompleted(result.emptySearch, result.lastTimestamp);
|
||||
|
||||
if (!result.success) {
|
||||
if (result.success && photoFragment.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
photoFragment.showAllGalleryItems();
|
||||
} else {
|
||||
photoFragment.setEmptyListMessage(SearchType.GALLERY_SEARCH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,11 +273,13 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View
|
||||
}
|
||||
|
||||
private void checkEnablingCreateButton() {
|
||||
Template selectedTemplate = adapter.getSelectedTemplate();
|
||||
String name = binding.filename.getText().toString();
|
||||
if (positiveButton != null) {
|
||||
Template selectedTemplate = adapter.getSelectedTemplate();
|
||||
String name = binding.filename.getText().toString();
|
||||
|
||||
positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() &&
|
||||
!name.equalsIgnoreCase(DOT + selectedTemplate.getExtension()));
|
||||
positiveButton.setEnabled(selectedTemplate != null && !name.isEmpty() &&
|
||||
!name.equalsIgnoreCase(DOT + selectedTemplate.getExtension()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class CreateFileFromTemplateTask extends AsyncTask<Void, Void, String> {
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.adapter.LocalFileListAdapter;
|
||||
import com.owncloud.android.ui.adapter.OCFileListAdapter;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils;
|
||||
import com.owncloud.android.utils.theme.ThemeCheckableUtils;
|
||||
@@ -194,17 +193,17 @@ public class ConflictsResolveDialog extends DialogFragment {
|
||||
// set info for existing file
|
||||
binding.existingSize.setText(DisplayUtils.bytesToHumanReadable(existingFile.getFileLength()));
|
||||
binding.existingTimestamp.setText(DisplayUtils.getRelativeTimestamp(getContext(),
|
||||
existingFile.getModificationTimestamp()));
|
||||
existingFile.getModificationTimestamp()));
|
||||
|
||||
binding.existingThumbnail.setTag(existingFile.getFileId());
|
||||
OCFileListAdapter.setThumbnail(existingFile,
|
||||
binding.existingThumbnail,
|
||||
user,
|
||||
new FileDataStorageManager(user,
|
||||
requireContext().getContentResolver()),
|
||||
asyncTasks,
|
||||
false,
|
||||
getContext());
|
||||
DisplayUtils.setThumbnail(existingFile,
|
||||
binding.existingThumbnail,
|
||||
user,
|
||||
new FileDataStorageManager(user,
|
||||
requireContext().getContentResolver()),
|
||||
asyncTasks,
|
||||
false,
|
||||
getContext());
|
||||
|
||||
View.OnClickListener checkBoxClickListener = v -> {
|
||||
positiveButton.setEnabled(binding.newCheckbox.isChecked() || binding.existingCheckbox.isChecked());
|
||||
|
||||
+32
-10
@@ -72,6 +72,19 @@ public class ExpirationDatePickerDialogFragment
|
||||
this.onExpiryDateListener = onExpiryDateListener;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
final Dialog currentDialog = getDialog();
|
||||
if (currentDialog != null) {
|
||||
final DatePickerDialog dialog = (DatePickerDialog) currentDialog;
|
||||
dialog.getButton(DatePickerDialog.BUTTON_NEUTRAL).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
|
||||
dialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
|
||||
dialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
@@ -109,11 +122,6 @@ public class ExpirationDatePickerDialogFragment
|
||||
});
|
||||
}
|
||||
|
||||
dialog.show();
|
||||
dialog.getButton(DatePickerDialog.BUTTON_NEUTRAL).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
|
||||
dialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
|
||||
dialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(ThemeColorUtils.primaryColor(getContext(), true));
|
||||
|
||||
// Prevent days in the past may be chosen
|
||||
DatePicker picker = dialog.getDatePicker();
|
||||
picker.setMinDate(tomorrowInMillis - 1000);
|
||||
@@ -126,6 +134,16 @@ public class ExpirationDatePickerDialogFragment
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public long getCurrentSelectionMillis() {
|
||||
final Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
final DatePickerDialog datePickerDialog = (DatePickerDialog) dialog;
|
||||
final DatePicker picker = datePickerDialog.getDatePicker();
|
||||
return yearMonthDayToMillis(picker.getYear(), picker.getMonth(), picker.getDayOfMonth());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user chooses an expiration date.
|
||||
*
|
||||
@@ -137,17 +155,21 @@ public class ExpirationDatePickerDialogFragment
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
||||
|
||||
Calendar chosenDate = Calendar.getInstance();
|
||||
chosenDate.set(Calendar.YEAR, year);
|
||||
chosenDate.set(Calendar.MONTH, monthOfYear);
|
||||
chosenDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
long chosenDateInMillis = chosenDate.getTimeInMillis();
|
||||
long chosenDateInMillis = yearMonthDayToMillis(year, monthOfYear, dayOfMonth);
|
||||
|
||||
if (onExpiryDateListener != null) {
|
||||
onExpiryDateListener.onDateSet(year, monthOfYear, dayOfMonth, chosenDateInMillis);
|
||||
}
|
||||
}
|
||||
|
||||
private long yearMonthDayToMillis(int year, int monthOfYear, int dayOfMonth) {
|
||||
Calendar date = Calendar.getInstance();
|
||||
date.set(Calendar.YEAR, year);
|
||||
date.set(Calendar.MONTH, monthOfYear);
|
||||
date.set(Calendar.DAY_OF_MONTH, dayOfMonth);
|
||||
return date.getTimeInMillis();
|
||||
}
|
||||
|
||||
public interface OnExpiryDateListener {
|
||||
void onDateSet(int year, int monthOfYear, int dayOfMonth, long chosenDateInMillis);
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.events
|
||||
|
||||
data class FileLockEvent(val filePath: String, val shouldLock: Boolean)
|
||||
@@ -41,7 +41,6 @@ import android.view.MotionEvent;
|
||||
import android.view.ScaleGestureDetector;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
package com.owncloud.android.ui.fragment;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -310,6 +309,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
||||
|
||||
/**
|
||||
* show quick sharing permission dialog
|
||||
*
|
||||
* @param share
|
||||
*/
|
||||
@Override
|
||||
@@ -322,10 +322,22 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
||||
*
|
||||
* @param result {@link RemoteOperationResult} of an update on the edited {@link OCFile} sharing information.
|
||||
* @param file the edited {@link OCFile}
|
||||
* @see #onUpdateShareInformation(RemoteOperationResult)
|
||||
*/
|
||||
public void onUpdateShareInformation(RemoteOperationResult result, OCFile file) {
|
||||
this.file = file;
|
||||
|
||||
onUpdateShareInformation(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the UI after the result of an update operation on the edited {@link OCFile}. Keeps the current {@link
|
||||
* OCFile held by this fragment}.
|
||||
*
|
||||
* @param result {@link RemoteOperationResult} of an update on the edited {@link OCFile} sharing information.
|
||||
* @see #onUpdateShareInformation(RemoteOperationResult, OCFile)
|
||||
*/
|
||||
public void onUpdateShareInformation(RemoteOperationResult result) {
|
||||
if (result.isSuccess()) {
|
||||
refreshUiFromDB();
|
||||
} else {
|
||||
@@ -410,7 +422,9 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
||||
|
||||
|
||||
if (publicShares.isEmpty() && containsNoNewPublicShare(adapter.getShares())) {
|
||||
publicShares.add(new OCShare().setShareType(ShareType.NEW_PUBLIC_LINK));
|
||||
final OCShare ocShare = new OCShare();
|
||||
ocShare.setShareType(ShareType.NEW_PUBLIC_LINK);
|
||||
publicShares.add(ocShare);
|
||||
} else {
|
||||
adapter.removeNewPublicShare();
|
||||
}
|
||||
|
||||
+21
-4
@@ -22,6 +22,7 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
@@ -116,6 +117,8 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
||||
private var isReshareShown: Boolean = true // show or hide reshare option
|
||||
private var isExpDateShown: Boolean = true // show or hide expiry date option
|
||||
|
||||
private var expirationDatePickerFragment: ExpirationDatePickerDialogFragment? = null
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
try {
|
||||
@@ -160,6 +163,19 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
||||
implementClickEvents()
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
// Force recreation of dialog fragment when screen rotates
|
||||
// This is needed because the calendar layout should be different in portrait and landscape,
|
||||
// but as FDA persists through config changes, the dialog is not recreated automatically
|
||||
val datePicker = expirationDatePickerFragment
|
||||
if (datePicker?.dialog?.isShowing == true) {
|
||||
val currentSelectionMillis = datePicker.currentSelectionMillis
|
||||
datePicker.dismiss()
|
||||
showExpirationDateDialog(currentSelectionMillis)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showShareProcessFirst() {
|
||||
binding.shareProcessGroupOne.visibility = View.VISIBLE
|
||||
binding.shareProcessEditShareLink.visibility = View.VISIBLE
|
||||
@@ -347,12 +363,13 @@ class FileDetailsSharingProcessFragment : Fragment(), ExpirationDatePickerDialog
|
||||
}
|
||||
}
|
||||
|
||||
private fun showExpirationDateDialog() {
|
||||
val dialog = ExpirationDatePickerDialogFragment.newInstance(chosenExpDateInMills)
|
||||
private fun showExpirationDateDialog(chosenDateInMillis: Long = chosenExpDateInMills) {
|
||||
val dialog = ExpirationDatePickerDialogFragment.newInstance(chosenDateInMillis)
|
||||
dialog.setOnExpiryDateListener(this)
|
||||
fileActivity?.let { it1 ->
|
||||
expirationDatePickerFragment = dialog
|
||||
fileActivity?.let {
|
||||
dialog.show(
|
||||
it1.supportFragmentManager,
|
||||
it.supportFragmentManager,
|
||||
ExpirationDatePickerDialogFragment.DATE_PICKER_DIALOG
|
||||
)
|
||||
}
|
||||
|
||||
@@ -27,12 +27,16 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.nextcloud.utils.view.FastScroll;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.adapter.CommonOCFileListAdapterInterface;
|
||||
import com.owncloud.android.ui.adapter.GalleryAdapter;
|
||||
import com.owncloud.android.ui.asynctasks.GallerySearchTask;
|
||||
import com.owncloud.android.ui.events.ChangeMenuEvent;
|
||||
import com.owncloud.android.ui.fragment.util.GalleryFastScrollViewHelper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
@@ -50,6 +54,7 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
private long endDate;
|
||||
private long daySpan = 30;
|
||||
private int limit = 300;
|
||||
private GalleryAdapter mAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -87,18 +92,33 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
mAdapter.setShowMetadata(false);
|
||||
|
||||
currentSearchType = SearchType.GALLERY_SEARCH;
|
||||
|
||||
switchToGridView();
|
||||
|
||||
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT;
|
||||
requireActivity().invalidateOptionsMenu();
|
||||
|
||||
handleSearchEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setAdapter(Bundle args) {
|
||||
mAdapter = new GalleryAdapter(requireContext(),
|
||||
accountManager.getUser(),
|
||||
this,
|
||||
preferences,
|
||||
mContainerActivity);
|
||||
|
||||
setRecyclerViewAdapter(mAdapter);
|
||||
|
||||
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), getColumnsCount());
|
||||
mAdapter.setLayoutManager(layoutManager);
|
||||
getRecyclerView().setLayoutManager(layoutManager);
|
||||
|
||||
FastScroll.applyFastScroll(getRecyclerView(), new GalleryFastScrollViewHelper(getRecyclerView(), mAdapter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
super.onRefresh();
|
||||
@@ -106,6 +126,11 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
handleSearchEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonOCFileListAdapterInterface getCommonAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@@ -128,7 +153,7 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
setEmptyListLoadingMessage();
|
||||
|
||||
// always show first stored items
|
||||
mAdapter.showAllGalleryItems(mContainerActivity.getStorageManager());
|
||||
mAdapter.showAllGalleryItems();
|
||||
|
||||
setFabVisible(false);
|
||||
|
||||
@@ -155,13 +180,12 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
|
||||
public void searchCompleted(boolean emptySearch, long lastTimeStamp) {
|
||||
photoSearchQueryRunning = false;
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
if (mAdapter.isEmpty()) {
|
||||
setEmptyListMessage(SearchType.GALLERY_SEARCH);
|
||||
}
|
||||
|
||||
if (emptySearch && getAdapter().getItemCount() > 0) {
|
||||
if (emptySearch && mAdapter.getItemCount() > 0) {
|
||||
Log_OC.d(this, "End gallery search");
|
||||
return;
|
||||
}
|
||||
@@ -213,6 +237,10 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
// Almost reached the end, continue to load new photos
|
||||
OCFile lastFile = mAdapter.getItem(lastVisibleItem - 1);
|
||||
|
||||
if (lastFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
daySpan = 30;
|
||||
endDate = lastFile.getModificationTimestamp() / 1000;
|
||||
startDate = endDate - (daySpan * 24 * 60 * 60);
|
||||
@@ -229,4 +257,8 @@ public class GalleryFragment extends OCFileListFragment {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showAllGalleryItems() {
|
||||
mAdapter.showAllGalleryItems();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import com.owncloud.android.files.FileMenuFilter;
|
||||
import com.owncloud.android.lib.common.Creator;
|
||||
import com.owncloud.android.lib.common.DirectEditing;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.ui.activity.AppScanActivity;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.theme.ThemeColorUtils;
|
||||
@@ -183,10 +184,14 @@ public class OCFileListBottomSheetDialog extends BottomSheetDialog {
|
||||
dismiss();
|
||||
});
|
||||
|
||||
binding.menuScanDocUpload.setOnClickListener(v -> {
|
||||
actions.scanDocUpload();
|
||||
dismiss();
|
||||
});
|
||||
if(AppScanActivity.getEnabled()) {
|
||||
binding.menuScanDocUpload.setOnClickListener(v -> {
|
||||
actions.scanDocUpload();
|
||||
dismiss();
|
||||
});
|
||||
}else {
|
||||
binding.menuScanDocUpload.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
binding.menuUploadFiles.setOnClickListener(v -> {
|
||||
actions.uploadFiles();
|
||||
|
||||
@@ -41,13 +41,15 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
import com.google.android.material.behavior.HideBottomViewOnScrollBehavior;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.android.files.FileLockingMenuCustomization;
|
||||
import com.nextcloud.android.files.ThemedPopupMenu;
|
||||
import com.nextcloud.android.lib.resources.files.ToggleFileLockRemoteOperation;
|
||||
import com.nextcloud.android.lib.richWorkspace.RichWorkspaceDirectEditingRemoteOperation;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
@@ -56,6 +58,8 @@ import com.nextcloud.client.di.Injectable;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.utils.Throttler;
|
||||
import com.nextcloud.common.NextcloudClient;
|
||||
import com.nextcloud.utils.view.FastScroll;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
@@ -71,13 +75,14 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.shares.GetSharesRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.ui.activity.AppScanActivity;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.activity.FolderPickerActivity;
|
||||
import com.owncloud.android.ui.activity.OnEnforceableRefreshListener;
|
||||
import com.owncloud.android.ui.activity.UploadFilesActivity;
|
||||
import com.owncloud.android.ui.adapter.CommonOCFileListAdapterInterface;
|
||||
import com.owncloud.android.ui.adapter.OCFileListAdapter;
|
||||
import com.owncloud.android.ui.dialog.ChooseRichDocumentsTemplateDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.ChooseTemplateDialogFragment;
|
||||
@@ -91,6 +96,7 @@ import com.owncloud.android.ui.events.ChangeMenuEvent;
|
||||
import com.owncloud.android.ui.events.CommentsEvent;
|
||||
import com.owncloud.android.ui.events.EncryptionEvent;
|
||||
import com.owncloud.android.ui.events.FavoriteEvent;
|
||||
import com.owncloud.android.ui.events.FileLockEvent;
|
||||
import com.owncloud.android.ui.events.SearchEvent;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
||||
@@ -178,6 +184,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
|
||||
private static final String DIALOG_CREATE_FOLDER = "DIALOG_CREATE_FOLDER";
|
||||
private static final String DIALOG_CREATE_DOCUMENT = "DIALOG_CREATE_DOCUMENT";
|
||||
private static final String DIALOG_BOTTOM_SHEET = "DIALOG_BOTTOM_SHEET";
|
||||
private static final String DIALOG_LOCK_DETAILS = "DIALOG_LOCK_DETAILS";
|
||||
|
||||
private static final int SINGLE_SELECTION = 1;
|
||||
private static final int NOT_ENOUGH_SPACE_FRAG_REQUEST_CODE = 2;
|
||||
@@ -189,7 +197,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
protected FileFragment.ContainerActivity mContainerActivity;
|
||||
|
||||
protected OCFile mFile;
|
||||
protected OCFileListAdapter mAdapter;
|
||||
private OCFileListAdapter mAdapter;
|
||||
protected boolean mOnlyFoldersClickable;
|
||||
protected boolean mFileSelectable;
|
||||
|
||||
@@ -326,7 +334,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mAdapter.cancelAllPendingTasks();
|
||||
if (mAdapter != null) {
|
||||
mAdapter.cancelAllPendingTasks();
|
||||
}
|
||||
|
||||
if (getActivity() != null) {
|
||||
getActivity().getIntent().removeExtra(OCFileListFragment.SEARCH_EVENT);
|
||||
@@ -349,18 +359,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
mOnlyFoldersClickable = args != null && args.getBoolean(ARG_ONLY_FOLDERS_CLICKABLE, false);
|
||||
mFileSelectable = args != null && args.getBoolean(ARG_FILE_SELECTABLE, false);
|
||||
mLimitToMimeType = args != null ? args.getString(ARG_MIMETYPE, "") : "";
|
||||
boolean hideItemOptions = args != null && args.getBoolean(ARG_HIDE_ITEM_OPTIONS, false);
|
||||
|
||||
mAdapter = new OCFileListAdapter(
|
||||
getActivity(),
|
||||
accountManager.getUser(),
|
||||
preferences,
|
||||
mContainerActivity,
|
||||
this,
|
||||
hideItemOptions,
|
||||
isGridViewPreferred(mFile)
|
||||
);
|
||||
setRecyclerViewAdapter(mAdapter);
|
||||
setAdapter(args);
|
||||
|
||||
mHideFab = args != null && args.getBoolean(ARG_HIDE_FAB, false);
|
||||
|
||||
@@ -403,7 +403,25 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) fragmentActivity;
|
||||
fileDisplayActivity.updateActionBarTitleAndHomeButton(fileDisplayActivity.getCurrentDir());
|
||||
}
|
||||
listDirectory(false, false);
|
||||
listDirectory(MainApp.isOnlyOnDevice(), false);
|
||||
}
|
||||
|
||||
protected void setAdapter(Bundle args) {
|
||||
boolean hideItemOptions = args != null && args.getBoolean(ARG_HIDE_ITEM_OPTIONS, false);
|
||||
|
||||
mAdapter = new OCFileListAdapter(
|
||||
getActivity(),
|
||||
accountManager.getUser(),
|
||||
preferences,
|
||||
mContainerActivity,
|
||||
this,
|
||||
hideItemOptions,
|
||||
isGridViewPreferred(mFile)
|
||||
);
|
||||
|
||||
setRecyclerViewAdapter(mAdapter);
|
||||
|
||||
FastScroll.applyFastScroll(getRecyclerView());
|
||||
}
|
||||
|
||||
protected void prepareCurrentSearch(SearchEvent event) {
|
||||
@@ -487,7 +505,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) getActivity();
|
||||
|
||||
if (fileDisplayActivity != null) {
|
||||
fileDisplayActivity.getFileOperationsHelper()
|
||||
AppScanActivity
|
||||
.scanFromCamera(fileDisplayActivity, FileDisplayActivity.REQUEST_CODE__UPLOAD_SCAN_DOC_FROM_CAMERA);
|
||||
} else {
|
||||
Toast.makeText(getContext(),
|
||||
@@ -528,7 +546,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
if (file.isFolder()) {
|
||||
mContainerActivity.showDetails(file, 1);
|
||||
} else {
|
||||
mContainerActivity.getFileOperationsHelper().sendShareFile(file);
|
||||
throttler.run("shareIconClick", () -> {
|
||||
mContainerActivity.getFileOperationsHelper().sendShareFile(file);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,7 +565,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
@Override
|
||||
public void onOverflowIconClicked(OCFile file, View view) {
|
||||
throttler.run("overflowClick", () -> {
|
||||
PopupMenu popup = new PopupMenu(getActivity(), view);
|
||||
final ThemedPopupMenu popup = new ThemedPopupMenu(requireContext(), view);
|
||||
popup.inflate(R.menu.item_file);
|
||||
FileMenuFilter mf = new FileMenuFilter(mAdapter.getFiles().size(),
|
||||
Collections.singleton(file),
|
||||
@@ -553,11 +573,13 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
true,
|
||||
accountManager.getUser());
|
||||
mf.filter(popup.getMenu(), true);
|
||||
new FileLockingMenuCustomization(requireContext()).customizeMenu(popup.getMenu(), file);
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
Set<OCFile> checkedFiles = new HashSet<>();
|
||||
checkedFiles.add(file);
|
||||
return onFileActionChosen(item, checkedFiles);
|
||||
});
|
||||
|
||||
popup.show();
|
||||
});
|
||||
}
|
||||
@@ -566,7 +588,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
public void newDocument() {
|
||||
ChooseRichDocumentsTemplateDialogFragment.newInstance(mFile,
|
||||
ChooseRichDocumentsTemplateDialogFragment.Type.DOCUMENT)
|
||||
.show(requireActivity().getSupportFragmentManager(), DIALOG_CREATE_DOCUMENT);
|
||||
.show(requireActivity().getSupportFragmentManager(), DIALOG_CREATE_DOCUMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -580,7 +602,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
public void newPresentation() {
|
||||
ChooseRichDocumentsTemplateDialogFragment.newInstance(mFile,
|
||||
ChooseRichDocumentsTemplateDialogFragment.Type.PRESENTATION)
|
||||
.show(requireActivity().getSupportFragmentManager(), DIALOG_CREATE_DOCUMENT);
|
||||
.show(requireActivity().getSupportFragmentManager(), DIALOG_CREATE_DOCUMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -593,7 +615,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
@Override
|
||||
public void showTemplate(Creator creator, String headline) {
|
||||
ChooseTemplateDialogFragment.newInstance(mFile, creator, headline).show(requireActivity().getSupportFragmentManager(),
|
||||
DIALOG_CREATE_DOCUMENT);
|
||||
DIALOG_CREATE_DOCUMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -691,7 +713,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
// hide FAB in multi selection mode
|
||||
setFabVisible(false);
|
||||
|
||||
mAdapter.setMultiSelect(true);
|
||||
getCommonAdapter().setMultiSelect(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -700,12 +722,12 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
*/
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
final int checkedCount = mAdapter.getCheckedItems().size();
|
||||
Set<OCFile> checkedFiles = mAdapter.getCheckedItems();
|
||||
Set<OCFile> checkedFiles = getCommonAdapter().getCheckedItems();
|
||||
final int checkedCount = checkedFiles.size();
|
||||
String title = getResources().getQuantityString(R.plurals.items_selected_count, checkedCount, checkedCount);
|
||||
mode.setTitle(title);
|
||||
FileMenuFilter mf = new FileMenuFilter(
|
||||
mAdapter.getFiles().size(),
|
||||
getCommonAdapter().getFilesCount(),
|
||||
checkedFiles,
|
||||
mContainerActivity,
|
||||
getActivity(),
|
||||
@@ -718,6 +740,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
// Determine if we need to finish the action mode because there are no items selected
|
||||
if (checkedCount == 0 && !mIsActionModeNew) {
|
||||
exitSelectionMode();
|
||||
} else if (checkedCount == 1) {
|
||||
// customize for locking if file is locked
|
||||
new FileLockingMenuCustomization(requireContext()).customizeMenu(menu, checkedFiles.iterator().next());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -728,7 +753,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
*/
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
Set<OCFile> checkedFiles = mAdapter.getCheckedItems();
|
||||
Set<OCFile> checkedFiles = getCommonAdapter().getCheckedItems();
|
||||
return onFileActionChosen(item, checkedFiles);
|
||||
}
|
||||
|
||||
@@ -738,14 +763,14 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
mActiveActionMode = null;
|
||||
|
||||
|
||||
// show FAB on multi selection mode exit
|
||||
if (!mHideFab && !searchFragment) {
|
||||
setFabVisible(true);
|
||||
}
|
||||
|
||||
mAdapter.setMultiSelect(false);
|
||||
mAdapter.clearCheckedItems();
|
||||
getCommonAdapter().setMultiSelect(false);
|
||||
getCommonAdapter().clearCheckedItems();
|
||||
}
|
||||
|
||||
public void storeStateIn(Bundle outState) {
|
||||
@@ -865,10 +890,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
* @param file The concerned OCFile by the selection/deselection
|
||||
*/
|
||||
private void toggleItemToCheckedList(OCFile file) {
|
||||
if (getAdapter().isCheckedFile(file)) {
|
||||
getAdapter().removeCheckedFile(file);
|
||||
if (getCommonAdapter().isCheckedFile(file)) {
|
||||
getCommonAdapter().removeCheckedFile(file);
|
||||
} else {
|
||||
getAdapter().addCheckedFile(file);
|
||||
getCommonAdapter().addCheckedFile(file);
|
||||
}
|
||||
updateActionModeFile(file);
|
||||
}
|
||||
@@ -881,7 +906,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
mIsActionModeNew = false;
|
||||
if (mActiveActionMode != null) {
|
||||
mActiveActionMode.invalidate();
|
||||
mAdapter.notifyItemChanged(getAdapter().getItemPosition(file));
|
||||
getCommonAdapter().notifyItemChanged(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,7 +919,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
toggleItemToCheckedList(file);
|
||||
} else {
|
||||
actionBarActivity.startActionMode(mMultiChoiceModeListener);
|
||||
getAdapter().addCheckedFile(file);
|
||||
getCommonAdapter().addCheckedFile(file);
|
||||
}
|
||||
updateActionModeFile(file);
|
||||
}
|
||||
@@ -904,11 +929,11 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
|
||||
@Override
|
||||
public void onItemClicked(OCFile file) {
|
||||
if (getAdapter().isMultiSelect()) {
|
||||
if (getCommonAdapter().isMultiSelect()) {
|
||||
toggleItemToCheckedList(file);
|
||||
} else {
|
||||
if (file != null) {
|
||||
int position = mAdapter.getItemPosition(file);
|
||||
int position = getCommonAdapter().getItemPosition(file);
|
||||
|
||||
if (file.isFolder()) {
|
||||
resetHeaderScrollingState();
|
||||
@@ -1123,6 +1148,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
} else if (itemId == R.id.action_unset_encrypted) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleEncryption(singleFile, false);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_lock_file) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFileLock(singleFile, true);
|
||||
} else if (itemId == R.id.action_unlock_file) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFileLock(singleFile, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1169,6 +1198,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
} else if (itemId == R.id.action_send_file) {
|
||||
mContainerActivity.getFileOperationsHelper().sendFiles(checkedFiles);
|
||||
return true;
|
||||
} else if (itemId == R.id.action_lock_file) {
|
||||
// TODO call lock API
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1229,6 +1260,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
if (!directory.isFolder()) {
|
||||
Log_OC.w(TAG, "You see, that is not a directory -> " + directory);
|
||||
directory = storageManager.getFileById(directory.getParentId());
|
||||
|
||||
if (directory == null) {
|
||||
return; // no files, wait for sync
|
||||
}
|
||||
}
|
||||
|
||||
if (searchView != null && !searchView.isIconified() && !fromSearch) {
|
||||
@@ -1379,6 +1414,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
getAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public CommonOCFileListAdapterInterface getCommonAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
|
||||
public OCFileListAdapter getAdapter() {
|
||||
return mAdapter;
|
||||
}
|
||||
@@ -1509,7 +1548,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
handleSearchEvent(event);
|
||||
}
|
||||
|
||||
private void handleSearchEvent(SearchEvent event) {
|
||||
protected void handleSearchEvent(SearchEvent event) {
|
||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.getSearchType()) {
|
||||
return;
|
||||
}
|
||||
@@ -1537,30 +1576,29 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
|
||||
final User currentUser = accountManager.getUser();
|
||||
|
||||
final RemoteOperation remoteOperation;
|
||||
if (currentSearchType != SearchType.SHARED_FILTER) {
|
||||
boolean searchOnlyFolders = false;
|
||||
if (getArguments() != null && getArguments().getBoolean(ARG_SEARCH_ONLY_FOLDER, false)) {
|
||||
searchOnlyFolders = true;
|
||||
}
|
||||
|
||||
OCCapability ocCapability = mContainerActivity.getStorageManager()
|
||||
.getCapability(currentUser.getAccountName());
|
||||
|
||||
remoteOperation = new SearchRemoteOperation(event.getSearchQuery(),
|
||||
event.getSearchType(),
|
||||
searchOnlyFolders,
|
||||
ocCapability);
|
||||
} else {
|
||||
remoteOperation = new GetSharesRemoteOperation();
|
||||
}
|
||||
|
||||
final RemoteOperation remoteOperation = getSearchRemoteOperation(currentUser, event);
|
||||
|
||||
remoteOperationAsyncTask = new OCFileListSearchAsyncTask(mContainerActivity, this, remoteOperation, currentUser, event);
|
||||
|
||||
remoteOperationAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
|
||||
|
||||
protected RemoteOperation getSearchRemoteOperation(final User currentUser, final SearchEvent event) {
|
||||
boolean searchOnlyFolders = false;
|
||||
if (getArguments() != null && getArguments().getBoolean(ARG_SEARCH_ONLY_FOLDER, false)) {
|
||||
searchOnlyFolders = true;
|
||||
}
|
||||
|
||||
OCCapability ocCapability = mContainerActivity.getStorageManager()
|
||||
.getCapability(currentUser.getAccountName());
|
||||
|
||||
return new SearchRemoteOperation(event.getSearchQuery(),
|
||||
event.getSearchType(),
|
||||
searchOnlyFolders,
|
||||
ocCapability);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||
public void onMessageEvent(EncryptionEvent event) {
|
||||
final User user = accountManager.getUser();
|
||||
@@ -1588,7 +1626,11 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
|
||||
|
||||
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
|
||||
int position = mAdapter.getItemPosition(storageManager.getFileByRemoteId(event.remoteId));
|
||||
OCFile file = storageManager.getFileByRemoteId(event.remoteId);
|
||||
int position = -1;
|
||||
if (file != null) {
|
||||
position = mAdapter.getItemPosition(file);
|
||||
}
|
||||
SetupEncryptionDialogFragment dialog = SetupEncryptionDialogFragment.newInstance(user, position);
|
||||
dialog.setTargetFragment(this, SetupEncryptionDialogFragment.SETUP_ENCRYPTION_REQUEST_CODE);
|
||||
dialog.show(getParentFragmentManager(), SetupEncryptionDialogFragment.SETUP_ENCRYPTION_DIALOG_TAG);
|
||||
@@ -1608,13 +1650,37 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTitle(@StringRes final int title) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (getActivity() != null && ((FileDisplayActivity) getActivity()).getSupportActionBar() != null) {
|
||||
ThemeToolbarUtils.setColoredTitle(((FileDisplayActivity) getActivity()).getSupportActionBar(),
|
||||
title, getContext());
|
||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||
public void onMessageEvent(FileLockEvent event) {
|
||||
final User user = accountManager.getUser();
|
||||
|
||||
try {
|
||||
new Handler(Looper.getMainLooper()).post(() -> setLoading(true));
|
||||
NextcloudClient client = clientFactory.createNextcloudClient(user);
|
||||
ToggleFileLockRemoteOperation operation = new ToggleFileLockRemoteOperation(event.getShouldLock(), event.getFilePath());
|
||||
RemoteOperationResult<Void> result = operation.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
// TODO only refresh the modified file?
|
||||
new Handler(Looper.getMainLooper()).post(this::onRefresh);
|
||||
} else {
|
||||
Snackbar.make(getRecyclerView(),
|
||||
R.string.error_file_lock,
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
} catch (ClientFactory.CreationException e) {
|
||||
Log_OC.e(TAG, "Cannot create client", e);
|
||||
Snackbar.make(getRecyclerView(),
|
||||
R.string.error_file_lock,
|
||||
Snackbar.LENGTH_LONG).show();
|
||||
} finally {
|
||||
new Handler(Looper.getMainLooper()).post(() -> setLoading(false));
|
||||
}
|
||||
}
|
||||
|
||||
protected void setTitle(@StringRes final int title) {
|
||||
setTitle(getContext().getString(title));
|
||||
}
|
||||
|
||||
protected void setTitle(final String title) {
|
||||
@@ -1644,7 +1710,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
if (isSearchEventSet(searchEvent) && searchFragment) {
|
||||
if (searchFragment && isSearchEventSet(searchEvent)) {
|
||||
handleSearchEvent(searchEvent);
|
||||
|
||||
mRefreshListLayout.setRefreshing(false);
|
||||
@@ -1673,7 +1739,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
if (select) {
|
||||
ocFileListAdapter.addAllFilesToCheckedFiles();
|
||||
} else {
|
||||
ocFileListAdapter.removeAllFilesFromCheckedFiles();
|
||||
ocFileListAdapter.clearCheckedItems();
|
||||
}
|
||||
|
||||
for (int i = 0; i < mAdapter.getItemCount(); i++) {
|
||||
@@ -1698,7 +1764,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
||||
}
|
||||
SearchRemoteOperation.SearchType searchType = event.getSearchType();
|
||||
return !TextUtils.isEmpty(event.getSearchQuery()) ||
|
||||
searchType == SearchRemoteOperation.SearchType.SHARED_SEARCH ||
|
||||
searchType == SearchRemoteOperation.SearchType.SHARED_FILTER ||
|
||||
searchType == SearchRemoteOperation.SearchType.FAVORITE_SEARCH ||
|
||||
searchType == SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH;
|
||||
|
||||
@@ -69,7 +69,7 @@ class OCFileListSearchAsyncTask(
|
||||
if (remoteOperationResult.resultData.isNullOrEmpty()) {
|
||||
fragment.setEmptyView(event)
|
||||
} else {
|
||||
fragment.mAdapter.setData(
|
||||
fragment.adapter.setData(
|
||||
remoteOperationResult.resultData,
|
||||
fragment.currentSearchType,
|
||||
fileDataStorageManager,
|
||||
@@ -85,7 +85,7 @@ class OCFileListSearchAsyncTask(
|
||||
fragmentReference.get()?.let { fragment ->
|
||||
fragment.isLoading = false
|
||||
if (!isCancelled) {
|
||||
fragment.mAdapter.notifyDataSetChanged()
|
||||
fragment.adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2019 Tobias Kaminsky
|
||||
* Copyright (C) 2019 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.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.View
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.logger.Logger
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.SearchRemoteOperation
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile
|
||||
import com.owncloud.android.lib.resources.shares.GetSharesRemoteOperation
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.events.SearchEvent
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* A Fragment that lists folders shared by the user
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
class SharedListFragment : OCFileListFragment(), Injectable {
|
||||
|
||||
@Inject
|
||||
lateinit var logger: Logger
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
searchFragment = true
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
adapter.setShowMetadata(false)
|
||||
currentSearchType = SearchType.SHARED_FILTER
|
||||
searchEvent = SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER)
|
||||
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT
|
||||
requireActivity().invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
Handler().post {
|
||||
if (activity is FileDisplayActivity) {
|
||||
val fileDisplayActivity = activity as FileDisplayActivity
|
||||
fileDisplayActivity.updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_shared))
|
||||
fileDisplayActivity.setMainFabVisible(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSearchRemoteOperation(currentUser: User?, event: SearchEvent?): RemoteOperation<*> {
|
||||
return GetSharesRemoteOperation()
|
||||
}
|
||||
|
||||
private suspend fun fetchFileData(partialFile: OCFile): OCFile? {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val user = accountManager.user
|
||||
val fetchResult = ReadFileRemoteOperation(partialFile.remotePath)
|
||||
.execute(user.toPlatformAccount(), context)
|
||||
if (!fetchResult.isSuccess) {
|
||||
logger.e(SHARED_TAG, "Error fetching file")
|
||||
if (fetchResult.isException) {
|
||||
logger.e(SHARED_TAG, "exception: ", fetchResult.exception)
|
||||
}
|
||||
null
|
||||
} else {
|
||||
val remoteFile = fetchResult.data[0] as RemoteFile
|
||||
val file = FileStorageUtils.fillOCFile(remoteFile)
|
||||
FileStorageUtils.searchForLocalFileInDefaultPath(file, user.accountName)
|
||||
val savedFile = mContainerActivity.storageManager.saveFileWithParent(file, context)
|
||||
savedFile.apply {
|
||||
isSharedViaLink = partialFile.isSharedViaLink
|
||||
isSharedWithSharee = partialFile.isSharedWithSharee
|
||||
sharees = partialFile.sharees
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchFileAndRun(partialFile: OCFile, block: (file: OCFile) -> Unit) {
|
||||
lifecycleScope.launch {
|
||||
isLoading = true
|
||||
val file = fetchFileData(partialFile)
|
||||
isLoading = false
|
||||
if (file != null) {
|
||||
block(file)
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(requireActivity(), R.string.error_retrieving_file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onShareIconClick(file: OCFile) {
|
||||
fetchFileAndRun(file) { fetched ->
|
||||
super.onShareIconClick(fetched)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showShareDetailView(file: OCFile) {
|
||||
fetchFileAndRun(file) { fetched ->
|
||||
super.showShareDetailView(fetched)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showActivityDetailView(file: OCFile) {
|
||||
fetchFileAndRun(file) { fetched ->
|
||||
super.showActivityDetailView(fetched)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOverflowIconClicked(file: OCFile, view: View?) {
|
||||
fetchFileAndRun(file) { fetched ->
|
||||
super.onOverflowIconClicked(fetched, view)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClicked(file: OCFile) {
|
||||
fetchFileAndRun(file) { fetched ->
|
||||
super.onItemClicked(fetched)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLongItemClicked(file: OCFile): Boolean {
|
||||
fetchFileAndRun(file) { fetched ->
|
||||
super.onLongItemClicked(fetched)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val SHARED_TAG = SharedListFragment::class.java.simpleName
|
||||
}
|
||||
}
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* 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.owncloud.android.ui.fragment.util
|
||||
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.view.MotionEvent
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
||||
import androidx.recyclerview.widget.RecyclerView.SimpleOnItemTouchListener
|
||||
import com.afollestad.sectionedrecyclerview.ItemCoord
|
||||
import com.owncloud.android.datamodel.GalleryItems
|
||||
import com.owncloud.android.ui.adapter.GalleryAdapter
|
||||
import me.zhanghai.android.fastscroll.FastScroller
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
import me.zhanghai.android.fastscroll.Predicate
|
||||
import kotlin.math.ceil
|
||||
|
||||
/**
|
||||
* Custom ViewHelper to get fast scroll working on gallery, which has a gridview and variable height (due to headers)
|
||||
*
|
||||
* Copied from me.zhanghai.android.fastscroll.RecyclerViewHelper and heavily modified for gallery structure
|
||||
*/
|
||||
class GalleryFastScrollViewHelper(
|
||||
private val mView: RecyclerView,
|
||||
private val mPopupTextProvider: PopupTextProvider?
|
||||
) : FastScroller.ViewHelper {
|
||||
// used to calculate paddings
|
||||
private val mTempRect = Rect()
|
||||
|
||||
private val layoutManager by lazy { mView.layoutManager as GridLayoutManager }
|
||||
|
||||
// header is always 1st in the adapter
|
||||
private val headerHeight by lazy { getItemHeight(0) }
|
||||
// the 2nd element is always an item
|
||||
private val rowHeight by lazy { getItemHeight(1) }
|
||||
|
||||
private val columnCount by lazy { layoutManager.spanCount }
|
||||
|
||||
private fun getItemHeight(position: Int): Int {
|
||||
if (mView.childCount <= position) {
|
||||
return 0
|
||||
}
|
||||
val itemView = mView.getChildAt(position)
|
||||
mView.getDecoratedBoundsWithMargins(itemView, mTempRect)
|
||||
return mTempRect.height()
|
||||
}
|
||||
|
||||
override fun addOnPreDrawListener(onPreDraw: Runnable) {
|
||||
mView.addItemDecoration(object : ItemDecoration() {
|
||||
override fun onDraw(canvas: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||
onPreDraw.run()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun addOnScrollChangedListener(onScrollChanged: Runnable) {
|
||||
mView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
onScrollChanged.run()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun addOnTouchEventListener(onTouchEvent: Predicate<MotionEvent?>) {
|
||||
mView.addOnItemTouchListener(object : SimpleOnItemTouchListener() {
|
||||
override fun onInterceptTouchEvent(recyclerView: RecyclerView, event: MotionEvent): Boolean {
|
||||
return onTouchEvent.test(event)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(recyclerView: RecyclerView, event: MotionEvent) {
|
||||
onTouchEvent.test(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun getScrollRange(): Int {
|
||||
val headerCount = getHeaderCount()
|
||||
val rowCount = getRowCount()
|
||||
|
||||
if (headerCount == 0 || rowCount == 0) {
|
||||
return 0
|
||||
}
|
||||
val totalHeaderHeight = headerCount * headerHeight
|
||||
val totalRowHeight = rowCount * rowHeight
|
||||
return mView.paddingTop + totalHeaderHeight + totalRowHeight + mView.paddingBottom
|
||||
}
|
||||
|
||||
private fun getHeaderCount(): Int {
|
||||
val adapter = mView.adapter as GalleryAdapter
|
||||
return adapter.sectionCount
|
||||
}
|
||||
|
||||
private fun getRowCount(): Int {
|
||||
val adapter = mView.adapter as GalleryAdapter
|
||||
if (adapter.sectionCount == 0) return 0
|
||||
// in each section, the final row may contain less than the max of items
|
||||
return adapter.files.sumOf { itemCountToRowCount(it.files.size) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates current absolute offset depending on view state (first visible element)
|
||||
*/
|
||||
override fun getScrollOffset(): Int {
|
||||
val firstItemPosition = getFirstItemAdapterPosition()
|
||||
if (firstItemPosition == RecyclerView.NO_POSITION) {
|
||||
return 0
|
||||
}
|
||||
|
||||
val adapter = mView.adapter as GalleryAdapter
|
||||
val itemCoord: ItemCoord = adapter.getRelativePosition(firstItemPosition)
|
||||
val isHeader = itemCoord.relativePos() == -1
|
||||
|
||||
val seenRowsInPreviousSections = adapter.files
|
||||
.subList(0, itemCoord.section())
|
||||
.sumOf { itemCountToRowCount(it.files.size) }
|
||||
val seenRowsInThisSection = if (isHeader) 0 else itemCountToRowCount(itemCoord.relativePos())
|
||||
val totalSeenRows = seenRowsInPreviousSections + seenRowsInThisSection
|
||||
|
||||
val seenHeaders = when {
|
||||
isHeader -> itemCoord.section() // don't count the current section header
|
||||
else -> itemCoord.section() + 1
|
||||
}
|
||||
|
||||
val firstItemTop = getFirstItemOffset()
|
||||
|
||||
val totalRowOffset = totalSeenRows * rowHeight
|
||||
val totalHeaderOffset = seenHeaders * headerHeight
|
||||
return mView.paddingTop + totalHeaderOffset + totalRowOffset - firstItemTop
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolls to an absolute offset
|
||||
*/
|
||||
override fun scrollTo(offset: Int) {
|
||||
mView.stopScroll()
|
||||
val offsetTmp = offset - mView.paddingTop
|
||||
val (position, remainingOffset) = findPositionForOffset(offsetTmp)
|
||||
scrollToPositionWithOffset(position, -remainingOffset)
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an absolute offset, returns the closest position to that offset (without going over it),
|
||||
* and the remaining offset
|
||||
*/
|
||||
private fun findPositionForOffset(offset: Int): Pair<Int, Int> {
|
||||
val adapter = mView.adapter as GalleryAdapter
|
||||
|
||||
// find section
|
||||
val sectionStartOffsets = getSectionStartOffsets(adapter.files)
|
||||
val previousSections = sectionStartOffsets.filter { it <= offset }
|
||||
|
||||
val section = previousSections.size - 1
|
||||
val sectionStartOffset = previousSections.last()
|
||||
|
||||
// now calculate where to scroll within the section
|
||||
var remainingOffset = offset - sectionStartOffset
|
||||
val positionWithinSection: Int
|
||||
if (remainingOffset <= headerHeight) {
|
||||
// header position
|
||||
positionWithinSection = -1
|
||||
} else {
|
||||
// row position
|
||||
remainingOffset -= headerHeight
|
||||
val rowCount = remainingOffset / rowHeight
|
||||
if (rowCount > 0) {
|
||||
val rowStartIndex = rowCount * columnCount
|
||||
positionWithinSection = rowStartIndex
|
||||
|
||||
remainingOffset -= rowCount * rowHeight
|
||||
} else {
|
||||
positionWithinSection = 0 // first item
|
||||
}
|
||||
}
|
||||
val absolutePosition = adapter.getAbsolutePosition(section, positionWithinSection)
|
||||
return Pair(absolutePosition, remainingOffset)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the offset heights at which the section corresponding to that index starts
|
||||
*/
|
||||
private fun getSectionStartOffsets(files: List<GalleryItems>): List<Int> {
|
||||
val sectionHeights =
|
||||
files.map { headerHeight + itemCountToRowCount(it.files.size) * rowHeight }
|
||||
val sectionStartOffsets = sectionHeights.indices.map { i ->
|
||||
when (i) {
|
||||
0 -> 0
|
||||
else -> sectionHeights.subList(0, i).sum()
|
||||
}
|
||||
}
|
||||
return sectionStartOffsets
|
||||
}
|
||||
|
||||
private fun itemCountToRowCount(itemsCount: Int): Int {
|
||||
return ceil(itemsCount.toDouble() / columnCount).toInt()
|
||||
}
|
||||
|
||||
override fun getPopupText(): String? {
|
||||
var popupTextProvider: PopupTextProvider? = mPopupTextProvider
|
||||
if (popupTextProvider == null) {
|
||||
val adapter = mView.adapter
|
||||
if (adapter is PopupTextProvider) {
|
||||
popupTextProvider = adapter
|
||||
}
|
||||
}
|
||||
if (popupTextProvider == null) {
|
||||
return null
|
||||
}
|
||||
val position = getFirstItemAdapterPosition()
|
||||
return if (position == RecyclerView.NO_POSITION) {
|
||||
null
|
||||
} else popupTextProvider.getPopupText(position)
|
||||
}
|
||||
|
||||
private fun getFirstItemAdapterPosition(): Int {
|
||||
if (mView.childCount == 0) {
|
||||
return RecyclerView.NO_POSITION
|
||||
}
|
||||
val itemView = mView.getChildAt(0)
|
||||
return layoutManager.getPosition(itemView)
|
||||
}
|
||||
|
||||
private fun getFirstItemOffset(): Int {
|
||||
if (mView.childCount == 0) {
|
||||
return RecyclerView.NO_POSITION
|
||||
}
|
||||
val itemView = mView.getChildAt(0)
|
||||
mView.getDecoratedBoundsWithMargins(itemView, mTempRect)
|
||||
return mTempRect.top
|
||||
}
|
||||
|
||||
private fun scrollToPositionWithOffset(position: Int, offset: Int) {
|
||||
var offsetTmp = offset
|
||||
// LinearLayoutManager actually takes offset from paddingTop instead of top of RecyclerView.
|
||||
offsetTmp -= mView.paddingTop
|
||||
layoutManager.scrollToPositionWithOffset(position, offsetTmp)
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
@@ -69,7 +68,6 @@ import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||
import com.owncloud.android.services.OperationsService;
|
||||
import com.owncloud.android.ui.activity.AppScanActivity;
|
||||
import com.owncloud.android.ui.activity.ConflictsResolveActivity;
|
||||
import com.owncloud.android.ui.activity.ExternalSiteWebView;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
@@ -81,12 +79,12 @@ import com.owncloud.android.ui.dialog.SendFilesDialog;
|
||||
import com.owncloud.android.ui.dialog.SendShareDialog;
|
||||
import com.owncloud.android.ui.events.EncryptionEvent;
|
||||
import com.owncloud.android.ui.events.FavoriteEvent;
|
||||
import com.owncloud.android.ui.events.FileLockEvent;
|
||||
import com.owncloud.android.ui.events.SyncEventFinished;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.PermissionUtil;
|
||||
import com.owncloud.android.utils.UriUtils;
|
||||
import com.zynksoftware.documentscanner.ui.DocumentScanner;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
@@ -454,7 +452,7 @@ public class FileOperationsHelper {
|
||||
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
|
||||
final User user = currentAccount.getUser();
|
||||
new Thread(() -> {
|
||||
StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getLocalId());
|
||||
StreamMediaFileOperation sfo = new StreamMediaFileOperation(file.getRemoteId());
|
||||
RemoteOperationResult result = sfo.execute(user.toPlatformAccount(), fileActivity);
|
||||
|
||||
fileActivity.dismissLoadingDialog();
|
||||
@@ -920,6 +918,12 @@ public class FileOperationsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleFileLock(OCFile file, boolean shouldBeLocked) {
|
||||
if (file.isLocked() != shouldBeLocked) {
|
||||
EventBus.getDefault().post(new FileLockEvent(file.getRemotePath(), shouldBeLocked));
|
||||
}
|
||||
}
|
||||
|
||||
public void renameFile(OCFile file, String newFilename) {
|
||||
// RenameFile
|
||||
Intent service = new Intent(fileActivity, OperationsService.class);
|
||||
@@ -1068,26 +1072,13 @@ public class FileOperationsHelper {
|
||||
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
||||
activity.startActivityForResult(pictureIntent, requestCode);
|
||||
} else {
|
||||
PermissionUtil.requestCameraPermission(activity);
|
||||
PermissionUtil.requestCameraPermission(activity, PermissionUtil.PERMISSIONS_CAMERA);
|
||||
}
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(activity, "No Camera found");
|
||||
}
|
||||
}
|
||||
|
||||
public void scanFromCamera(Activity activity, int requestCode) {
|
||||
DocumentScanner.Configuration configuration = new DocumentScanner.Configuration();
|
||||
configuration.setImageType(Bitmap.CompressFormat.PNG);
|
||||
DocumentScanner.INSTANCE.init(activity, configuration);
|
||||
|
||||
Intent scanIntent = new Intent(activity, AppScanActivity.class);
|
||||
if (PermissionUtil.checkSelfPermission(activity, Manifest.permission.CAMERA)) {
|
||||
activity.startActivityForResult(scanIntent, requestCode);
|
||||
} else {
|
||||
PermissionUtil.requestCameraPermission(activity);
|
||||
}
|
||||
}
|
||||
|
||||
public static File createImageFile(Activity activity) {
|
||||
File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
|
||||
|
||||
|
||||
@@ -48,6 +48,4 @@ public interface OCFileListFragmentInterface {
|
||||
boolean isLoading();
|
||||
|
||||
void onHeaderClicked();
|
||||
|
||||
boolean isSearchFragment();
|
||||
}
|
||||
@@ -165,6 +165,8 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
|
||||
} else {
|
||||
if (file.isEncrypted()) {
|
||||
fragment = FileDownloadFragment.newInstance(file, user, mObsoletePositions.contains(i));
|
||||
} else if (PreviewMediaFragment.canBePreviewed(file)) {
|
||||
fragment = PreviewMediaFragment.newInstance(file, user, 0, false);
|
||||
} else {
|
||||
fragment = PreviewImageFragment.newInstance(file, mObsoletePositions.contains(i), true);
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||
playVideoUri(getFile().getStorageUri());
|
||||
} else {
|
||||
try {
|
||||
new LoadStreamUrl(this, user, clientFactory).execute(getFile().getLocalId());
|
||||
new LoadStreamUrl(this, user, clientFactory).execute(getFile().getRemoteId());
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Loading stream url not possible: " + e);
|
||||
}
|
||||
@@ -506,7 +506,10 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||
if (savedPlaybackPosition >= 0) {
|
||||
exoPlayer.seekTo(savedPlaybackPosition);
|
||||
}
|
||||
exoPlayer.play();
|
||||
|
||||
if (autoplay) {
|
||||
exoPlayer.play();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -575,7 +578,6 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
autoplay = false;
|
||||
if(getActivity() instanceof FileDisplayActivity){
|
||||
((FileDisplayActivity) getActivity()).configureToolbarForMediaPreview(getFile());
|
||||
}
|
||||
@@ -601,7 +603,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
||||
final OCFile file = getFile();
|
||||
if (MimeTypeUtil.isAudio(file) && !mediaPlayerServiceConnection.isPlaying()) {
|
||||
stopAudio();
|
||||
} else if (MimeTypeUtil.isVideo(file) && exoPlayer.isPlaying()) {
|
||||
} else if (MimeTypeUtil.isVideo(file) && exoPlayer != null && exoPlayer.isPlaying()) {
|
||||
savedPlaybackPosition = exoPlayer.getCurrentPosition();
|
||||
exoPlayer.pause();
|
||||
}
|
||||
|
||||
@@ -114,6 +114,8 @@ class PreviewVideoActivity :
|
||||
if (mSavedPlaybackPosition >= 0) {
|
||||
exoPlayer?.seekTo(mSavedPlaybackPosition)
|
||||
}
|
||||
|
||||
onIsPlayingChanged(exoPlayer!!.isPlaying)
|
||||
}
|
||||
|
||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||
@@ -200,7 +202,10 @@ class PreviewVideoActivity :
|
||||
private fun play(item: MediaItem) {
|
||||
exoPlayer?.addMediaItem(item)
|
||||
exoPlayer?.prepare()
|
||||
exoPlayer?.play()
|
||||
|
||||
if (mAutoplay) {
|
||||
exoPlayer?.play()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@@ -220,6 +225,7 @@ class PreviewVideoActivity :
|
||||
else -> MediaItem.fromUri(mStreamUri!!)
|
||||
}
|
||||
if (exoPlayer != null) {
|
||||
setupPlayerView()
|
||||
play(mediaItem)
|
||||
} else {
|
||||
val context = this
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
|
||||
/**
|
||||
* Data holder utility to store & retrieve stuff
|
||||
*/
|
||||
@@ -39,6 +41,7 @@ public class DataHolderUtil {
|
||||
@SuppressLint("TrulyRandom")
|
||||
private SecureRandom random = new SecureRandom();
|
||||
|
||||
@SuppressFBWarnings("MS_EXPOSE_REP")
|
||||
public static synchronized DataHolderUtil getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new DataHolderUtil();
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.graphics.Point;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.PictureDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
@@ -46,6 +47,9 @@ import android.text.style.StyleSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.GenericRequestBuilder;
|
||||
@@ -56,13 +60,16 @@ import com.bumptech.glide.load.resource.file.FileToStreamDecoder;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.caverock.androidsvg.SVG;
|
||||
import com.elyeproj.loaderviewlibrary.LoaderImageView;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.nextcloud.client.account.CurrentAccountProvider;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
@@ -89,17 +96,19 @@ import java.math.BigDecimal;
|
||||
import java.net.IDN;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.widget.AppCompatDrawableManager;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
@@ -130,6 +139,10 @@ public final class DisplayUtils {
|
||||
private static final double BYTE_SIZE_DIVIDER_DOUBLE = 1024.0;
|
||||
private static final int DATE_TIME_PARTS_SIZE = 2;
|
||||
|
||||
public static final String MONTH_YEAR_PATTERN = "MMMM yyyy";
|
||||
public static final String MONTH_PATTERN = "MMMM";
|
||||
public static final String YEAR_PATTERN = "yyyy";
|
||||
|
||||
private static Map<String, String> mimeType2HumanReadable;
|
||||
|
||||
static {
|
||||
@@ -820,4 +833,186 @@ public final class DisplayUtils {
|
||||
return R.string.menu_item_sort_by_name_a_z;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDateByPattern(long timestamp, Context context, String pattern) {
|
||||
DateFormat df = new SimpleDateFormat(pattern, context.getResources().getConfiguration().locale);
|
||||
df.setTimeZone(TimeZone.getTimeZone(TimeZone.getDefault().getID()));
|
||||
|
||||
return df.format(timestamp);
|
||||
}
|
||||
|
||||
public static void setThumbnail(OCFile file,
|
||||
ImageView thumbnailView,
|
||||
User user,
|
||||
FileDataStorageManager storageManager,
|
||||
List<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks,
|
||||
boolean gridView,
|
||||
Context context) {
|
||||
setThumbnail(file,
|
||||
thumbnailView,
|
||||
user,
|
||||
storageManager,
|
||||
asyncTasks,
|
||||
gridView,
|
||||
context,
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
public static void setThumbnail(OCFile file,
|
||||
ImageView thumbnailView,
|
||||
User user,
|
||||
FileDataStorageManager storageManager,
|
||||
List<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks,
|
||||
boolean gridView,
|
||||
Context context,
|
||||
LoaderImageView shimmerThumbnail,
|
||||
AppPreferences preferences) {
|
||||
if (file.isFolder()) {
|
||||
stopShimmer(shimmerThumbnail, thumbnailView);
|
||||
thumbnailView.setImageDrawable(MimeTypeUtil
|
||||
.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
|
||||
file.isSharedViaLink(), file.isEncrypted(),
|
||||
file.getMountType(), context));
|
||||
} else {
|
||||
if (file.getRemoteId() != null && file.isPreviewAvailable()) {
|
||||
// Thumbnail in cache?
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.getRemoteId()
|
||||
);
|
||||
|
||||
if (thumbnail != null && !file.isUpdateThumbnailNeeded()) {
|
||||
stopShimmer(shimmerThumbnail, thumbnailView);
|
||||
|
||||
if (MimeTypeUtil.isVideo(file)) {
|
||||
Bitmap withOverlay = ThumbnailsCacheManager.addVideoOverlay(thumbnail);
|
||||
thumbnailView.setImageBitmap(withOverlay);
|
||||
} else {
|
||||
if (gridView) {
|
||||
BitmapUtils.setRoundedBitmapForGridMode(thumbnail, thumbnailView);
|
||||
} else {
|
||||
BitmapUtils.setRoundedBitmap(thumbnail, thumbnailView);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// generate new thumbnail
|
||||
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView)) {
|
||||
for (ThumbnailsCacheManager.ThumbnailGenerationTask task : asyncTasks) {
|
||||
if (file.getRemoteId() != null && task.getImageKey() != null &&
|
||||
file.getRemoteId().equals(task.getImageKey())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(thumbnailView,
|
||||
storageManager,
|
||||
user,
|
||||
asyncTasks,
|
||||
gridView,
|
||||
file.getRemoteId());
|
||||
if (thumbnail == null) {
|
||||
Drawable drawable = MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
||||
file.getFileName(),
|
||||
user,
|
||||
context);
|
||||
if (drawable == null) {
|
||||
drawable = ResourcesCompat.getDrawable(context.getResources(),
|
||||
R.drawable.file_image,
|
||||
null);
|
||||
}
|
||||
int px = ThumbnailsCacheManager.getThumbnailDimension();
|
||||
thumbnail = BitmapUtils.drawableToBitmap(drawable, px, px);
|
||||
}
|
||||
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
||||
new ThumbnailsCacheManager.AsyncThumbnailDrawable(context.getResources(),
|
||||
thumbnail, task);
|
||||
|
||||
if (shimmerThumbnail != null && shimmerThumbnail.getVisibility() == View.GONE) {
|
||||
if (gridView) {
|
||||
configShimmerGridImageSize(shimmerThumbnail, preferences.getGridColumns());
|
||||
}
|
||||
startShimmer(shimmerThumbnail, thumbnailView);
|
||||
}
|
||||
|
||||
task.setListener(new ThumbnailsCacheManager.ThumbnailGenerationTask.Listener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
stopShimmer(shimmerThumbnail, thumbnailView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
stopShimmer(shimmerThumbnail, thumbnailView);
|
||||
}
|
||||
});
|
||||
|
||||
thumbnailView.setImageDrawable(asyncDrawable);
|
||||
asyncTasks.add(task);
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTaskObject(file,
|
||||
file.getRemoteId()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log_OC.d(TAG, "ThumbnailGenerationTask : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ("image/png".equalsIgnoreCase(file.getMimeType())) {
|
||||
thumbnailView.setBackgroundColor(context.getResources().getColor(R.color.bg_default));
|
||||
}
|
||||
} else {
|
||||
stopShimmer(shimmerThumbnail, thumbnailView);
|
||||
thumbnailView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(),
|
||||
file.getFileName(),
|
||||
user,
|
||||
context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void startShimmer(LoaderImageView thumbnailShimmer, ImageView thumbnailView) {
|
||||
thumbnailShimmer.setImageResource(R.drawable.background);
|
||||
thumbnailShimmer.resetLoader();
|
||||
thumbnailView.setVisibility(View.GONE);
|
||||
thumbnailShimmer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private static void stopShimmer(@Nullable LoaderImageView thumbnailShimmer, ImageView thumbnailView) {
|
||||
if (thumbnailShimmer != null) {
|
||||
thumbnailShimmer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
thumbnailView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private static void configShimmerGridImageSize(LoaderImageView thumbnailShimmer, float gridColumns) {
|
||||
FrameLayout.LayoutParams targetLayoutParams = (FrameLayout.LayoutParams) thumbnailShimmer.getLayoutParams();
|
||||
|
||||
try {
|
||||
final Point screenSize = getScreenSize(thumbnailShimmer.getContext());
|
||||
final int marginLeftAndRight = targetLayoutParams.leftMargin + targetLayoutParams.rightMargin;
|
||||
final int size = Math.round(screenSize.x / gridColumns - marginLeftAndRight);
|
||||
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(size, size);
|
||||
params.setMargins(targetLayoutParams.leftMargin,
|
||||
targetLayoutParams.topMargin,
|
||||
targetLayoutParams.rightMargin,
|
||||
targetLayoutParams.bottomMargin);
|
||||
thumbnailShimmer.setLayoutParams(params);
|
||||
} catch (Exception exception) {
|
||||
Log_OC.e("ConfigShimmer", exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static Point getScreenSize(Context context) throws Exception {
|
||||
final WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
if (windowManager != null) {
|
||||
final Point displaySize = new Point();
|
||||
windowManager.getDefaultDisplay().getSize(displaySize);
|
||||
return displaySize;
|
||||
} else {
|
||||
throw new Exception("WindowManager not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,10 @@ open class FileSortOrder(@JvmField var name: String, var isAscending: Boolean) {
|
||||
trashBinView, localFileListView
|
||||
}
|
||||
|
||||
enum class SortType {
|
||||
SIZE, ALPHABET, DATE
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val sort_a_to_z_id = "sort_a_to_z"
|
||||
const val sort_z_to_a_id = "sort_z_to_a"
|
||||
@@ -106,4 +110,19 @@ open class FileSortOrder(@JvmField var name: String, var isAscending: Boolean) {
|
||||
open fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
return files
|
||||
}
|
||||
|
||||
open fun getType(): SortType {
|
||||
return when (name) {
|
||||
sort_z_to_a_id,
|
||||
sort_a_to_z_id -> SortType.ALPHABET
|
||||
|
||||
sort_small_to_big_id,
|
||||
sort_big_to_small_id -> SortType.SIZE
|
||||
|
||||
sort_new_to_old_id,
|
||||
sort_old_to_new_id -> SortType.DATE
|
||||
|
||||
else -> SortType.ALPHABET
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -233,6 +233,14 @@ public final class FileStorageUtils {
|
||||
file.setNote(remote.getNote());
|
||||
file.setSharees(new ArrayList<>(Arrays.asList(remote.getSharees())));
|
||||
file.setRichWorkspace(remote.getRichWorkspace());
|
||||
file.setLocked(remote.isLocked());
|
||||
file.setLockType(remote.getLockType());
|
||||
file.setLockOwnerId(remote.getLockOwner());
|
||||
file.setLockOwnerDisplayName(remote.getLockOwnerDisplayName());
|
||||
file.setLockOwnerEditor(remote.getLockOwnerEditor());
|
||||
file.setLockTimestamp(remote.getLockTimestamp());
|
||||
file.setLockTimeout(remote.getLockTimeout());
|
||||
file.setLockToken(remote.getLockToken());
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ object PermissionUtil {
|
||||
const val PERMISSIONS_CAMERA = 5
|
||||
const val PERMISSIONS_READ_CALENDAR_AUTOMATIC = 6
|
||||
const val PERMISSIONS_WRITE_CALENDAR = 7
|
||||
const val PERMISSIONS_SCAN_DOCUMENT = 6
|
||||
|
||||
const val REQUEST_CODE_MANAGE_ALL_FILES = 19203
|
||||
|
||||
@@ -226,10 +227,10 @@ object PermissionUtil {
|
||||
* @param activity The target activity.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun requestCameraPermission(activity: Activity) {
|
||||
fun requestCameraPermission(activity: Activity, requestCode: Int) {
|
||||
ActivityCompat.requestPermissions(
|
||||
activity, arrayOf(Manifest.permission.CAMERA),
|
||||
PERMISSIONS_CAMERA
|
||||
requestCode
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/text_color" android:state_enabled="true"/>
|
||||
<item android:color="@color/disabled_text" />
|
||||
</selector>
|
||||
@@ -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/>.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="m7.9482,15.6104c0.3479,0 0.682,-0.1385 0.9282,-0.3847 0.2462,-0.2462 0.3847,-0.5803 0.3847,-0.9282 0,-0.7286 -0.5908,-1.3129 -1.3129,-1.3129 -0.3479,0 -0.682,0.1385 -0.9282,0.3847 -0.2462,0.2462 -0.3847,0.5803 -0.3847,0.9282 0,0.3479 0.1385,0.682 0.3847,0.9282 0.2462,0.2462 0.5803,0.3847 0.9282,0.3847M11.8868,9.7025c0.3479,0 0.682,0.1385 0.9282,0.3847 0.2462,0.2462 0.3847,0.5803 0.3847,0.9282v6.5644c0,0.3479 -0.1385,0.682 -0.3847,0.9282 -0.2462,0.2462 -0.5803,0.3847 -0.9282,0.3847H4.0095c-0.3479,0 -0.682,-0.1385 -0.9282,-0.3847 -0.2462,-0.2462 -0.3847,-0.5803 -0.3847,-0.9282v-6.5644c0,-0.7286 0.5908,-1.3129 1.3129,-1.3129H4.666V8.3896c0,-0.8704 0.3459,-1.7054 0.961,-2.3212 0.6157,-0.6151 1.4507,-0.961 2.3212,-0.961 0.8704,0 1.7054,0.3459 2.3212,0.961 0.6151,0.6157 0.961,1.4507 0.961,2.3212v1.3129h0.6564M7.9482,6.4203c-0.5219,0 -1.0234,0.2074 -1.3923,0.577C6.1863,7.3662 5.9789,7.8677 5.9789,8.3896V9.7025H9.9175V8.3896c0,-0.5219 -0.2074,-1.0234 -0.577,-1.3923C8.9716,6.6277 8.47,6.4203 7.9482,6.4203Z"
|
||||
android:strokeWidth="0.656438"
|
||||
android:fillColor="#666666"/>
|
||||
<path
|
||||
android:pathData="m19.3033,8c1.1,0 2,-0.9 2,-2 0,-1.1 -0.9,-2 -2,-2 -1.1,0 -2,0.9 -2,2 0,1.1 0.9,2 2,2zM19.3033,10c-1.1,0 -2,0.9 -2,2 0,1.1 0.9,2 2,2 1.1,0 2,-0.9 2,-2 0,-1.1 -0.9,-2 -2,-2zM19.3033,16c-1.1,0 -2,0.9 -2,2 0,1.1 0.9,2 2,2 1.1,0 2,-0.9 2,-2 0,-1.1 -0.9,-2 -2,-2z"
|
||||
android:fillColor="#666666"/>
|
||||
</vector>
|
||||
@@ -26,7 +26,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
tools:context=".ui.preview.PreviewMediaFragment">
|
||||
|
||||
<ImageView
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~
|
||||
~ 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/>.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/alternate_half_padding"
|
||||
android:paddingTop="@dimen/alternate_half_padding"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/month"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/standard_margin"
|
||||
android:layout_marginTop="@dimen/standard_margin"
|
||||
android:layout_marginEnd="@dimen/standard_half_margin"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textStyle="bold"
|
||||
tools:text="July" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/year"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/standard_margin"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
tools:text="2016" />
|
||||
</LinearLayout>
|
||||
@@ -43,7 +43,7 @@
|
||||
android:contentDescription="@null"
|
||||
android:padding="@dimen/grid_image_icon_padding"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/folder" />
|
||||
android:src="@drawable/file_image" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favorite_action"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/ListItemLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/standard_list_item_size"
|
||||
@@ -137,10 +138,11 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical|end"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/standard_half_padding"
|
||||
android:paddingEnd="@dimen/zero">
|
||||
|
||||
@@ -148,7 +150,6 @@
|
||||
android:id="@+id/unreadComments"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/unread_comments"
|
||||
android:focusable="true"
|
||||
@@ -161,8 +162,6 @@
|
||||
android:id="@+id/sharedIcon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/unreadComments"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/shared_icon_share"
|
||||
android:focusable="true"
|
||||
@@ -173,10 +172,8 @@
|
||||
<com.owncloud.android.ui.AvatarGroupLayout
|
||||
android:id="@+id/sharedAvatars"
|
||||
android:layout_width="100dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_height="@dimen/file_icon_size"
|
||||
android:layout_alignEnd="@id/sharedIcon"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/sharedIcon"
|
||||
android:contentDescription="@string/shared_avatar_desc"
|
||||
android:visibility="visible" />
|
||||
|
||||
@@ -184,8 +181,6 @@
|
||||
android:id="@+id/custom_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/sharedAvatars"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/checkbox"
|
||||
android:focusable="false"
|
||||
@@ -197,8 +192,6 @@
|
||||
android:id="@+id/overflow_menu"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/custom_checkbox"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/overflow_menu"
|
||||
android:focusable="true"
|
||||
@@ -206,5 +199,5 @@
|
||||
android:paddingEnd="12dp"
|
||||
android:src="@drawable/ic_dots_vertical" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
@@ -111,7 +111,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/appbar"
|
||||
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
|
||||
android:theme="@style/Theme.ToolbarWithDisabled"
|
||||
app:popupTheme="@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
tools:visibility="gone">
|
||||
|
||||
|
||||
@@ -18,9 +18,40 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="AppCompatResource">
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="AppCompatResource">
|
||||
|
||||
<group
|
||||
android:id="@+id/menu_group_lock_info"
|
||||
android:visible="false"
|
||||
android:enabled="false"
|
||||
tools:visible="true">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_locked_by"
|
||||
android:showAsAction="never"
|
||||
android:title="Locked by %1$s"
|
||||
android:enabled="false"
|
||||
app:showAsAction="never"
|
||||
tools:ignore="HardcodedText"
|
||||
tools:title="Locked by Username With Surname at bla bla bla bla bla" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_locked_until"
|
||||
android:showAsAction="never"
|
||||
android:enabled="false"
|
||||
android:title="Lock expires: %1$s"
|
||||
app:showAsAction="never"
|
||||
tools:ignore="HardcodedText"
|
||||
tools:title="Lock expires: in 20 minutes" />
|
||||
</group>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_unlock_file"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/unlock_file"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_edit"
|
||||
@@ -46,6 +77,12 @@
|
||||
app:showAsAction="never"
|
||||
android:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_lock_file"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/lock_file"
|
||||
app:showAsAction="never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_rename_file"
|
||||
android:title="@string/common_rename"
|
||||
|
||||
Loaded 100 of 191 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user