Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f053ef4a35 |
No files matched your search
@@ -16,9 +16,6 @@ comment:
|
||||
layout: "header, diff, changes, uncovered, tree"
|
||||
behavior: default
|
||||
|
||||
github_checks:
|
||||
annotations: false
|
||||
|
||||
ignore:
|
||||
- "app/src/main/res/values*/*"
|
||||
- "src/main/res/values*/*"
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
local testOnServer(serverBranch, ciImageVersion) = {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "tests-"+serverBranch,
|
||||
"steps": [
|
||||
{
|
||||
"name": "gplay",
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-android8:2",
|
||||
"privileged": true,
|
||||
"environment": {
|
||||
"LOG_USERNAME": {
|
||||
"from_secret": "LOG_USERNAME"
|
||||
},
|
||||
"LOG_PASSWORD": {
|
||||
"from_secret": "LOG_PASSWORD"
|
||||
},
|
||||
"GIT_USERNAME": {
|
||||
"from_secret": "GIT_USERNAME"
|
||||
},
|
||||
"GIT_TOKEN": {
|
||||
"from_secret": "GIT_TOKEN"
|
||||
}
|
||||
},
|
||||
"commands": [
|
||||
"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",
|
||||
"scripts/wait_for_emulator.sh",
|
||||
"scripts/deleteOldComments.sh 'stable' 'Unit' $DRONE_PULL_REQUEST $GIT_TOKEN",
|
||||
"./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER 'stable' 'Unit' $DRONE_PULL_REQUEST $GIT_TOKEN",
|
||||
"./gradlew installGplayDebugAndroidTest",
|
||||
"scripts/wait_for_server.sh 'server'",
|
||||
"scripts/deleteOldComments.sh 'stable' 'IT' $DRONE_PULL_REQUEST $GIT_TOKEN",
|
||||
"./gradlew createGplayDebugCoverageReport -Pcoverage -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER 'stable' 'IT' $DRONE_PULL_REQUEST $GIT_TOKEN",
|
||||
"./gradlew combinedTestReport",
|
||||
],
|
||||
}
|
||||
],
|
||||
"services": [
|
||||
{
|
||||
"name": "server",
|
||||
"image": ciImageVersion, // also change in updateScreenshots.sh
|
||||
"environment": {
|
||||
"EVAL": "true"
|
||||
},
|
||||
"commands": [
|
||||
"BRANCH='"+serverBranch+"' /usr/local/bin/initnc.sh",
|
||||
"echo 127.0.0.1 server >> /etc/hosts",
|
||||
"su www-data -c \"OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1\"",
|
||||
"su www-data -c \"OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2\"",
|
||||
"su www-data -c \"OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3\"",
|
||||
"su www-data -c \"php /var/www/html/occ user:setting user2 files quota 1G\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:add users\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user1\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user2\"",
|
||||
"su www-data -c \"git clone -b "+serverBranch+" https://github.com/nextcloud/activity.git /var/www/html/apps/activity\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable activity\"",
|
||||
"su www-data -c \"git clone -b "+serverBranch+" https://github.com/nextcloud/text.git /var/www/html/apps/text\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable text\"",
|
||||
"su www-data -c \"git clone -b "+serverBranch+" https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable end_to_end_encryption\"",
|
||||
"/usr/local/bin/run.sh"
|
||||
]
|
||||
}
|
||||
],
|
||||
"trigger": {
|
||||
"branch": [
|
||||
"master",
|
||||
"stable-*"
|
||||
],
|
||||
"event": [
|
||||
"push",
|
||||
"pull_request"
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
local allScreenshots() = {
|
||||
"kind": "pipeline",
|
||||
"type": "docker",
|
||||
"name": "allScreenshots",
|
||||
"steps": [
|
||||
{
|
||||
"name": "runAllScreenshots",
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-android8:2",
|
||||
"privileged": true,
|
||||
"environment": {
|
||||
"GIT_USERNAME": {
|
||||
"from_secret": "GIT_USERNAME"
|
||||
},
|
||||
"GIT_TOKEN": {
|
||||
"from_secret": "GIT_TOKEN"
|
||||
},
|
||||
"LOG_USERNAME": {
|
||||
"from_secret": "LOG_USERNAME"
|
||||
},
|
||||
"LOG_PASSWORD": {
|
||||
"from_secret": "LOG_PASSWORD"
|
||||
}
|
||||
},
|
||||
"commands": [
|
||||
"emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &",
|
||||
"sed -i s'#<bool name=\"is_beta\">false</bool>#<bool name=\"is_beta\">true</bool>#'g app/src/main/res/values/setup.xml",
|
||||
"sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle",
|
||||
"scripts/wait_for_emulator.sh",
|
||||
"scripts/runAllScreenshotCombinations noCI false",
|
||||
"scripts/screenshotSummary.sh"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "notify",
|
||||
"image": "drillster/drone-email",
|
||||
"settings": {
|
||||
"port": 587,
|
||||
"from": "nextcloud-drone@kaminsky.me",
|
||||
"recipients_only": true,
|
||||
"username": {
|
||||
"from_secret": "EMAIL_USERNAME"
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "EMAIL_PASSWORD"
|
||||
},
|
||||
"recipients": {
|
||||
"from_secret": "EMAIL_RECIPIENTS"
|
||||
},
|
||||
"host": {
|
||||
"from_secret": "EMAIL_HOST"
|
||||
}
|
||||
},
|
||||
"when": {
|
||||
"event": [
|
||||
"push"
|
||||
],
|
||||
"status": [
|
||||
"failure"
|
||||
],
|
||||
"branch": [
|
||||
"master",
|
||||
"stable-*"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trigger": {
|
||||
"event": [
|
||||
"cron"
|
||||
],
|
||||
"cron": [
|
||||
"allscreenshots"
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
## to create .drone.yml run: drone jsonnet --stream
|
||||
[
|
||||
testOnServer("stable16", "ghcr.io/nextcloud/continuous-integration-server/php-7.2:1"),
|
||||
testOnServer("stable23", "ghcr.io/nextcloud/continuous-integration-server:latest"),
|
||||
testOnServer("master", "ghcr.io/nextcloud/continuous-integration-server:latest"),
|
||||
allScreenshots(),
|
||||
]
|
||||
|
||||
@@ -1,316 +1,218 @@
|
||||
---
|
||||
{
|
||||
"kind": "pipeline",
|
||||
"name": "tests-stable16",
|
||||
"services": [
|
||||
{
|
||||
"commands": [
|
||||
"BRANCH='stable16' /usr/local/bin/initnc.sh",
|
||||
"echo 127.0.0.1 server >> /etc/hosts",
|
||||
"su www-data -c \"OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1\"",
|
||||
"su www-data -c \"OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2\"",
|
||||
"su www-data -c \"OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3\"",
|
||||
"su www-data -c \"php /var/www/html/occ user:setting user2 files quota 1G\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:add users\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user1\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user2\"",
|
||||
"su www-data -c \"git clone -b stable16 https://github.com/nextcloud/activity.git /var/www/html/apps/activity\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable activity\"",
|
||||
"su www-data -c \"git clone -b stable16 https://github.com/nextcloud/text.git /var/www/html/apps/text\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable text\"",
|
||||
"su www-data -c \"git clone -b stable16 https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable end_to_end_encryption\"",
|
||||
"/usr/local/bin/run.sh"
|
||||
],
|
||||
"environment": {
|
||||
"EVAL": "true"
|
||||
},
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-server/php-7.2:1",
|
||||
"name": "server"
|
||||
}
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"commands": [
|
||||
"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",
|
||||
"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"
|
||||
],
|
||||
"environment": {
|
||||
"GIT_TOKEN": {
|
||||
"from_secret": "GIT_TOKEN"
|
||||
},
|
||||
"GIT_USERNAME": {
|
||||
"from_secret": "GIT_USERNAME"
|
||||
},
|
||||
"LOG_PASSWORD": {
|
||||
"from_secret": "LOG_PASSWORD"
|
||||
},
|
||||
"LOG_USERNAME": {
|
||||
"from_secret": "LOG_USERNAME"
|
||||
}
|
||||
},
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-android8:2",
|
||||
"name": "gplay",
|
||||
"privileged": true
|
||||
}
|
||||
],
|
||||
"trigger": {
|
||||
"branch": [
|
||||
"master",
|
||||
"stable-*"
|
||||
],
|
||||
"event": [
|
||||
"push",
|
||||
"pull_request"
|
||||
]
|
||||
},
|
||||
"type": "docker"
|
||||
}
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tests-stable
|
||||
|
||||
steps:
|
||||
- name: gplay
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:2
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
commands:
|
||||
- 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 src/main/res/values/setup.xml
|
||||
- sed -i s"#server#server#" gradle.properties
|
||||
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- 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
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
- stable-*
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
environment:
|
||||
EVAL: true
|
||||
commands:
|
||||
- BRANCH='stable22' /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
|
||||
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
|
||||
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
|
||||
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
|
||||
- su www-data -c "php /var/www/html/occ group:add users"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user1"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user2"
|
||||
- su www-data -c "git clone -b stable22 https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable activity"
|
||||
- su www-data -c "git clone -b stable22 https://github.com/nextcloud/text.git /var/www/html/apps/text/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable text"
|
||||
- su www-data -c "git clone -b stable22 https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
- stable-*
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
---
|
||||
{
|
||||
"kind": "pipeline",
|
||||
"name": "tests-stable23",
|
||||
"services": [
|
||||
{
|
||||
"commands": [
|
||||
"BRANCH='stable23' /usr/local/bin/initnc.sh",
|
||||
"echo 127.0.0.1 server >> /etc/hosts",
|
||||
"su www-data -c \"OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1\"",
|
||||
"su www-data -c \"OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2\"",
|
||||
"su www-data -c \"OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3\"",
|
||||
"su www-data -c \"php /var/www/html/occ user:setting user2 files quota 1G\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:add users\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user1\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user2\"",
|
||||
"su www-data -c \"git clone -b stable23 https://github.com/nextcloud/activity.git /var/www/html/apps/activity\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable activity\"",
|
||||
"su www-data -c \"git clone -b stable23 https://github.com/nextcloud/text.git /var/www/html/apps/text\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable text\"",
|
||||
"su www-data -c \"git clone -b stable23 https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable end_to_end_encryption\"",
|
||||
"/usr/local/bin/run.sh"
|
||||
],
|
||||
"environment": {
|
||||
"EVAL": "true"
|
||||
},
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-server:latest",
|
||||
"name": "server"
|
||||
}
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"commands": [
|
||||
"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",
|
||||
"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"
|
||||
],
|
||||
"environment": {
|
||||
"GIT_TOKEN": {
|
||||
"from_secret": "GIT_TOKEN"
|
||||
},
|
||||
"GIT_USERNAME": {
|
||||
"from_secret": "GIT_USERNAME"
|
||||
},
|
||||
"LOG_PASSWORD": {
|
||||
"from_secret": "LOG_PASSWORD"
|
||||
},
|
||||
"LOG_USERNAME": {
|
||||
"from_secret": "LOG_USERNAME"
|
||||
}
|
||||
},
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-android8:2",
|
||||
"name": "gplay",
|
||||
"privileged": true
|
||||
}
|
||||
],
|
||||
"trigger": {
|
||||
"branch": [
|
||||
"master",
|
||||
"stable-*"
|
||||
],
|
||||
"event": [
|
||||
"push",
|
||||
"pull_request"
|
||||
]
|
||||
},
|
||||
"type": "docker"
|
||||
}
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tests-master
|
||||
|
||||
steps:
|
||||
- name: gplay
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:2
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
commands:
|
||||
- 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 src/main/res/values/setup.xml
|
||||
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- scripts/runCombinedTest.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
- stable-*
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
environment:
|
||||
EVAL: true
|
||||
commands:
|
||||
- /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
|
||||
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
|
||||
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
|
||||
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
|
||||
- su www-data -c "php /var/www/html/occ group:add users"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user1"
|
||||
- su www-data -c "php /var/www/html/occ group:adduser users user2"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable activity"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable text"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
- stable-*
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
|
||||
---
|
||||
{
|
||||
"kind": "pipeline",
|
||||
"name": "tests-master",
|
||||
"services": [
|
||||
{
|
||||
"commands": [
|
||||
"BRANCH='master' /usr/local/bin/initnc.sh",
|
||||
"echo 127.0.0.1 server >> /etc/hosts",
|
||||
"su www-data -c \"OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1\"",
|
||||
"su www-data -c \"OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2\"",
|
||||
"su www-data -c \"OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3\"",
|
||||
"su www-data -c \"php /var/www/html/occ user:setting user2 files quota 1G\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:add users\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user1\"",
|
||||
"su www-data -c \"php /var/www/html/occ group:adduser users user2\"",
|
||||
"su www-data -c \"git clone -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable activity\"",
|
||||
"su www-data -c \"git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable text\"",
|
||||
"su www-data -c \"git clone -b master https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption\"",
|
||||
"su www-data -c \"php /var/www/html/occ app:enable end_to_end_encryption\"",
|
||||
"/usr/local/bin/run.sh"
|
||||
],
|
||||
"environment": {
|
||||
"EVAL": "true"
|
||||
},
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-server:latest",
|
||||
"name": "server"
|
||||
}
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"commands": [
|
||||
"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",
|
||||
"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"
|
||||
],
|
||||
"environment": {
|
||||
"GIT_TOKEN": {
|
||||
"from_secret": "GIT_TOKEN"
|
||||
},
|
||||
"GIT_USERNAME": {
|
||||
"from_secret": "GIT_USERNAME"
|
||||
},
|
||||
"LOG_PASSWORD": {
|
||||
"from_secret": "LOG_PASSWORD"
|
||||
},
|
||||
"LOG_USERNAME": {
|
||||
"from_secret": "LOG_USERNAME"
|
||||
}
|
||||
},
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-android8:2",
|
||||
"name": "gplay",
|
||||
"privileged": true
|
||||
}
|
||||
],
|
||||
"trigger": {
|
||||
"branch": [
|
||||
"master",
|
||||
"stable-*"
|
||||
],
|
||||
"event": [
|
||||
"push",
|
||||
"pull_request"
|
||||
]
|
||||
},
|
||||
"type": "docker"
|
||||
}
|
||||
---
|
||||
{
|
||||
"kind": "pipeline",
|
||||
"name": "allScreenshots",
|
||||
"steps": [
|
||||
{
|
||||
"commands": [
|
||||
"emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &",
|
||||
"sed -i s'#<bool name=\"is_beta\">false</bool>#<bool name=\"is_beta\">true</bool>#'g app/src/main/res/values/setup.xml",
|
||||
"sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle",
|
||||
"scripts/wait_for_emulator.sh",
|
||||
"scripts/runAllScreenshotCombinations noCI false",
|
||||
"scripts/screenshotSummary.sh"
|
||||
],
|
||||
"environment": {
|
||||
"GIT_TOKEN": {
|
||||
"from_secret": "GIT_TOKEN"
|
||||
},
|
||||
"GIT_USERNAME": {
|
||||
"from_secret": "GIT_USERNAME"
|
||||
},
|
||||
"LOG_PASSWORD": {
|
||||
"from_secret": "LOG_PASSWORD"
|
||||
},
|
||||
"LOG_USERNAME": {
|
||||
"from_secret": "LOG_USERNAME"
|
||||
}
|
||||
},
|
||||
"image": "ghcr.io/nextcloud/continuous-integration-android8:2",
|
||||
"name": "runAllScreenshots",
|
||||
"privileged": true
|
||||
},
|
||||
{
|
||||
"image": "drillster/drone-email",
|
||||
"name": "notify",
|
||||
"settings": {
|
||||
"from": "[email protected]",
|
||||
"host": {
|
||||
"from_secret": "EMAIL_HOST"
|
||||
},
|
||||
"password": {
|
||||
"from_secret": "EMAIL_PASSWORD"
|
||||
},
|
||||
"port": 587,
|
||||
"recipients": {
|
||||
"from_secret": "EMAIL_RECIPIENTS"
|
||||
},
|
||||
"recipients_only": true,
|
||||
"username": {
|
||||
"from_secret": "EMAIL_USERNAME"
|
||||
}
|
||||
},
|
||||
"when": {
|
||||
"branch": [
|
||||
"master",
|
||||
"stable-*"
|
||||
],
|
||||
"event": [
|
||||
"push"
|
||||
],
|
||||
"status": [
|
||||
"failure"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"trigger": {
|
||||
"cron": [
|
||||
"allscreenshots"
|
||||
],
|
||||
"event": [
|
||||
"cron"
|
||||
]
|
||||
},
|
||||
"type": "docker"
|
||||
}
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: allScreenshots
|
||||
|
||||
steps:
|
||||
- name: runAllScreenshots
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:2
|
||||
privileged: true
|
||||
environment:
|
||||
GIT_USERNAME:
|
||||
from_secret: GIT_USERNAME
|
||||
GIT_TOKEN:
|
||||
from_secret: GIT_TOKEN
|
||||
LOG_USERNAME:
|
||||
from_secret: LOG_USERNAME
|
||||
LOG_PASSWORD:
|
||||
from_secret: LOG_PASSWORD
|
||||
commands:
|
||||
- emulator -avd android -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
- sed -i s'#showOnlyFailingTestsInReports = ciBuild#showOnlyFailingTestsInReports = false#' build.gradle
|
||||
- scripts/wait_for_emulator.sh
|
||||
- scripts/runAllScreenshotCombinations noCI false
|
||||
- scripts/screenshotSummary.sh
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
port: 587
|
||||
from: [email protected]
|
||||
recipients_only: true
|
||||
username:
|
||||
from_secret: EMAIL_USERNAME
|
||||
password:
|
||||
from_secret: EMAIL_PASSWORD
|
||||
recipients:
|
||||
from_secret: EMAIL_RECIPIENTS
|
||||
host:
|
||||
from_secret: EMAIL_HOST
|
||||
when:
|
||||
event:
|
||||
- push
|
||||
status:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
- stable-*
|
||||
trigger:
|
||||
event:
|
||||
- cron
|
||||
cron:
|
||||
- allscreenshots
|
||||
@@ -1,47 +1,21 @@
|
||||
name: "Analysis"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches: [ master, stable-* ]
|
||||
push:
|
||||
pull_request:
|
||||
branches: [ master, stable-* ]
|
||||
|
||||
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 }}
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: "temurin"
|
||||
distribution: "adopt"
|
||||
java-version: 11
|
||||
- name: Run analysis wrapper
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
|
||||
scripts/analysis/analysis-wrapper.sh ${{ secrets.GIT_USERNAME }} ${{ secrets.GIT_TOKEN }} ${{ steps.get-vars.outputs.branch }} ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} $GITHUB_RUN_NUMBER ${{ steps.get-vars.outputs.pr }}
|
||||
scripts/analysis/analysis-wrapper.sh ${{ secrets.GIT_USERNAME }} ${{ secrets.GIT_TOKEN }} $GITHUB_REF ${{ secrets.LOG_USERNAME }} ${{ secrets.LOG_PASSWORD }} $GITHUB_RUN_NUMBER ${{ github.event.pull_request.number }}
|
||||
@@ -12,11 +12,11 @@ jobs:
|
||||
matrix:
|
||||
flavor: [ Generic, Gplay, Huawei ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: "temurin"
|
||||
distribution: "adopt"
|
||||
java-version: 11
|
||||
- name: Build ${{ matrix.flavor }}
|
||||
run: |
|
||||
|
||||
@@ -12,11 +12,11 @@ jobs:
|
||||
matrix:
|
||||
task: [ detekt, ktlint ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: "temurin"
|
||||
distribution: "adopt"
|
||||
java-version: 11
|
||||
- name: Check ${{ matrix.task }}
|
||||
run: ./gradlew ${{ matrix.task }}
|
||||
@@ -6,41 +6,41 @@
|
||||
name: Rebase command
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: created
|
||||
issue_comment:
|
||||
types: created
|
||||
|
||||
jobs:
|
||||
rebase:
|
||||
runs-on: ubuntu-latest
|
||||
rebase:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# On pull requests and if the comment starts with `/rebase`
|
||||
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase')
|
||||
# On pull requests and if the comment starts with `/rebase`
|
||||
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase')
|
||||
|
||||
steps:
|
||||
- name: Add reaction on start
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "+1"
|
||||
steps:
|
||||
- name: Add reaction on start
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "+1"
|
||||
|
||||
- name: Checkout the latest code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
- name: Checkout the latest code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
- name: Automatic Rebase
|
||||
uses: cirrus-actions/[email protected]
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
- name: Automatic Rebase
|
||||
uses: cirrus-actions/[email protected]
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
- name: Add reaction on failure
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
if: failure()
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "-1"
|
||||
- name: Add reaction on failure
|
||||
uses: peter-evans/create-or-update-comment@v1
|
||||
if: failure()
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "-1"
|
||||
@@ -9,6 +9,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- name: Detect SNAPSHOT
|
||||
run: scripts/analysis/detectSNAPSHOT.sh
|
||||
@@ -9,5 +9,5 @@ jobs:
|
||||
name: "Validation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
@@ -11,13 +11,13 @@ jobs:
|
||||
- name: Check if secrets are available
|
||||
run: echo "::set-output name=ok::${{ secrets.KS_PASS != '' }}"
|
||||
id: check-secrets
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
- name: set up JDK 11
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: "temurin"
|
||||
distribution: "adopt"
|
||||
java-version: 11
|
||||
- name: Build QA
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
@@ -29,8 +29,8 @@ jobs:
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
echo "org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > $HOME/.gradle/gradle.properties
|
||||
sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" app/build.gradle
|
||||
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" app/build.gradle
|
||||
sed -i "/qa/,/\}/ s/versionCode .*/versionCode ${{github.event.number}} /" build.gradle
|
||||
sed -i "/qa/,/\}/ s/versionName .*/versionName \"${{github.event.number}}\"/" build.gradle
|
||||
./gradlew assembleQaDebug
|
||||
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks app/build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
$(find /usr/local/lib/android/sdk/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
sudo scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD ${{github.event.number}} ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,55 +0,0 @@
|
||||
name: Scorecards supply-chain security
|
||||
on:
|
||||
# Only the default branch is supported.
|
||||
branch_protection_rule:
|
||||
schedule:
|
||||
- cron: '33 1 * * 5'
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecards analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
actions: read
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v3 # v2.4.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@e3e75cf2ffbf9364bbff86cdbdf52b23176fe492 # v1.0.1
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# Read-only PAT token. To create it,
|
||||
# follow the steps in https://github.com/ossf/scorecard-action#pat-token-creation.
|
||||
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
|
||||
# Publish the results to enable scorecard badges. For more details, see
|
||||
# https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories, `publish_results` will automatically be set to `false`,
|
||||
# regardless of the value entered here.
|
||||
publish_results: false
|
||||
|
||||
# Upload the results as artifacts (optional).
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535 # v2.3.1
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -14,7 +14,7 @@ jobs:
|
||||
color: [ blue ]
|
||||
api-level: [ 27 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@v2
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: "temurin"
|
||||
distribution: "adopt"
|
||||
java-version: 11
|
||||
|
||||
- name: create AVD and generate snapshot for caching
|
||||
@@ -71,15 +71,15 @@ jobs:
|
||||
sdcard-path-or-size: 100M
|
||||
target: google_apis
|
||||
emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -skin 500x833
|
||||
script: ./gradlew uninstallAll gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
|
||||
script: ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest -Pandroid.testInstrumentationRunnerArguments.COLOR=${{ matrix.color }} -Pandroid.testInstrumentationRunnerArguments.DARKMODE=${{ matrix.scheme }}
|
||||
- name: upload failing results
|
||||
if: ${{ failure() }}
|
||||
run:
|
||||
scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}} ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Archive Espresso results
|
||||
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
|
||||
uses: actions/upload-artifact@v2
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
path: app/build/reports
|
||||
path: build/reports
|
||||
retention-days: 4
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
- uses: actions/stale@v4.1.0
|
||||
with:
|
||||
days-before-stale: 28
|
||||
days-before-close: 14
|
||||
|
||||
@@ -65,6 +65,9 @@
|
||||
<MarkdownNavigatorCodeStyleSettings>
|
||||
<option name="RIGHT_MARGIN" value="120" />
|
||||
</MarkdownNavigatorCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
|
||||
<option name="ALIGN_MULTILINE_METHOD_BRACKETS" value="true" />
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
host = https://www.transifex.com
|
||||
|
||||
[nextcloud.android]
|
||||
file_filter = app/src/main/res/values-<lang>/strings.xml
|
||||
source_file = app/src/main/res/values/strings.xml
|
||||
file_filter = src/main/res/values-<lang>/strings.xml
|
||||
source_file = src/main/res/values/strings.xml
|
||||
type = ANDROID
|
||||
source_lang = en
|
||||
lang_map = af_ZA: af-rZA, am_ET: am-rET, ar_AE: ar-rAE, ar_BH: ar-rBH, ar_DZ: ar-rDZ, ar_EG: ar-rEG, ar_IQ: ar-rIQ, ar_JO: ar-rJO, ar_KW: ar-rKW, ar_LB: ar-rLB, ar_LY: ar-rLY, ar_MA: ar-rMA, ar_OM: ar-rOM, ar_QA: ar-rQA, ar_SA: ar-rSA, ar_SY: ar-rSY, ar_TN: ar-rTN, ar_YE: ar-rYE, arn_CL: arn-rCL, as_IN: as-rIN, az_AZ: az-rAZ, ba_RU: ba-rRU, be_BY: be-rBY, bg_BG: bg-rBG, bn_BD: bn-rBD, bn_IN: bn-rIN, bo_CN: bo-rCN, br_FR: br-rFR, bs_BA: bs-rBA, ca_ES: ca-rES, co_FR: co-rFR, cs_CZ: cs-rCZ, cy_GB: cy-rGB, da_DK: da-rDK, de_AT: de-rAT, de_CH: de-rCH, de_DE: de-rDE, de_LI: de-rLI, de_LU: de-rLU, dsb_DE: dsb-rDE, dv_MV: dv-rMV, el_GR: el-rGR, en_AU: en-rAU, en_BZ: en-rBZ, en_CA: en-rCA, en_GB: b+en+001, en_IE: en-rIE, en_IN: en-rIN, en_JM: en-rJM, en_MY: en-rMY, en_NZ: en-rNZ, en_PH: en-rPH, en_SG: en-rSG, en_TT: en-rTT, en_US: en-rUS, en_ZA: en-rZA, en_ZW: en-rZW, en@pirate: en-rpirate, es_AR: es-rAR, es_BO: es-rBO, es_CL: es-rCL, es_CO: es-rCO, es_CR: es-rCR, es_DO: es-rDO, es_EC: es-rEC, es_ES: es-rES, es_GT: es-rGT, es_HN: es-rHN, es_MX: es-rMX, es_NI: es-rNI, es_PA: es-rPA, es_PE: es-rPE, es_PR: es-rPR, es_PY: es-rPY, es_SV: es-rSV, es_419: b+es+419, es_UY: es-rUY, es_VE: es-rVE, et_EE: et-rEE, eu_ES: eu-rES, fa_IR: fa-rIR, fi_FI: fi-rFI, fil_PH: fil-rPH, fo_FO: fo-rFO, fr_BE: fr-rBE, fr_CA: fr-rCA, fr_CH: fr-rCH, fr_FR: fr-rFR, fr_LU: fr-rLU, fr_MC: fr-rMC, fy_NL: fy-rNL, ga_IE: ga-rIE, gd_GB: gd-rGB, gl_ES: gl-rES, gsw_FR: gsw-rFR, gu_IN: gu-rIN, ha_NG: ha-rNG, he: iw, he_IL: he-rIL, hi_IN: hi-rIN, hr_BA: hr-rBA, hr_HR: hr-rHR, hsb_DE: hsb-rDE, hu_HU: hu-rHU, hy_AM: hy-rAM, id: in, id_ID: id-rID, ig_NG: ig-rNG, ii_CN: ii-rCN, is_IS: is-rIS, it_CH: it-rCH, it_IT: it-rIT, iu_CA: iu-rCA, ja_JP: ja-rJP, ka_GE: ka-rGE, kk_KZ: kk-rKZ, kl_GL: kl-rGL, km_KH: km-rKH, kn_IN: kn-rIN, ko_KR: ko-rKR, kok_IN: kok-rIN, ku_IQ: ku-rIQ, ky_KG: ky-rKG, lb_LU: lb-rLU, lo_LA: lo-rLA, lt_LT: lt-rLT, lv_LV: lv-rLV, mi_NZ: mi-rNZ, mk_MK: mk-rMK, ml_IN: ml-rIN, mn_CN: mn-rCN, mn_MN: mn-rMN, moh_CA: moh-rCA, mr_IN: mr-rIN, ms_BN: ms-rBN, ms_MY: ms-rMY, my_MM: my, mt_MT: mt-rMT, nb_NO: nb-rNO, ne_NP: ne-rNP, nl_BE: nl-rBE, nl_NL: nl-rNL, nn_NO: nn-rNO, nso_ZA: nso-rZA, oc_FR: oc-rFR, or_IN: or-rIN, pa_IN: pa-rIN, pl_PL: pl-rPL, prs_AF: prs-rAF, ps_AF: ps-rAF, pt_BR: pt-rBR, pt_PT: pt-rPT, qut_GT: qut-rGT, quz_BO: quz-rBO, quz_EC: quz-rEC, quz_PE: quz-rPE, rm_CH: rm-rCH, ro_RO: ro-rRO, ru_RU: ru-rRU, rw_RW: rw-rRW, sa_IN: sa-rIN, sah_RU: sah-rRU, se_FI: se-rFI, se_NO: se-rNO, se_SE: se-rSE, si_LK: si-rLK, sk_SK: sk-rSK, sl_SI: sl-rSI, sma_NO: sma-rNO, sma_SE: sma-rSE, smj_NO: smj-rNO, smj_SE: smj-rSE, smn_FI: smn-rFI, sms_FI: sms-rFI, sq_AL: sq-rAL, sr_BA: sr-rBA, sr_CS: sr-rCS, sr_ME: sr-rME, sr_RS: sr-rRS, sr@latin: sr-rSP, sv_FI: sv-rFI, sv_SE: sv-rSE, sw_KE: sw-rKE, syr_SY: syr-rSY, ta_IN: ta-rIN, ta_LK: ta-rLK, te_IN: te-rIN, tg_TJ: tg-rTJ, th_TH: th-rTH, tk_TM: tk-rTM, tn_ZA: tn-rZA, tr_TR: tr-rTR, tt_RU: tt-rRU, tzm_DZ: tzm-rDZ, ug_CN: ug-rCN, uk_UA: uk-rUA, ur_PK: ur-rPK, uz_UZ: uz-rUZ, vi_VN: vi-rVN, wo_SN: wo-rSN, xh_ZA: xh-rZA, yo_NG: yo-rNG, zh_CN: zh-rCN, zh_CN.GB2312:zh-rBG, zh_HK: zh-rHK, zh_MO: zh-rMO, zh_SG: zh-rSG, zh_TW: zh-rTW, zu_ZA: zu-rZA
|
||||
@@ -1,19 +1,3 @@
|
||||
## 3.19.1 (March 10, 2022)
|
||||
|
||||
- Minor fixes and improvements
|
||||
|
||||
Minimum: NC 16 Server, Android 6.0 Marshmallow
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/65
|
||||
## 3.19.0 (February 3, 2022)
|
||||
|
||||
- Support external storage in Media page
|
||||
- Connection fallback to IPv4 when IPv6 fails
|
||||
- Many other fixes and improvements
|
||||
|
||||
Minimum: NC 16 Server, Android 6.0 Marshmallow
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/62
|
||||
## 3.18.1 (December 22, 2021)
|
||||
|
||||
- Fix connection bug for usernames with spaces
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# [Nextcloud](https://nextcloud.com) Android app
|
||||
|
||||
[](https://webchat.freenode.net/?channels=nextcloud)
|
||||
[](https://webchat.freenode.net/?channels=nextcloud-mobile)
|
||||
|
||||
|
||||
# Index
|
||||
1. [Guidelines](#guidelines)
|
||||
1. [Issue reporting](#issue-reporting)
|
||||
|
||||
@@ -8,23 +8,23 @@ GEM
|
||||
artifactory (3.0.15)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.2.0)
|
||||
aws-partitions (1.549.0)
|
||||
aws-sdk-core (3.125.5)
|
||||
aws-partitions (1.541.0)
|
||||
aws-sdk-core (3.124.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.525.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.53.0)
|
||||
aws-sdk-core (~> 3, >= 3.125.0)
|
||||
aws-sdk-kms (1.52.0)
|
||||
aws-sdk-core (~> 3, >= 3.122.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.111.2)
|
||||
aws-sdk-core (~> 3, >= 3.125.0)
|
||||
aws-sdk-s3 (1.109.0)
|
||||
aws-sdk-core (~> 3, >= 3.122.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.4)
|
||||
aws-sigv4 (1.4.0)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
claide (1.1.0)
|
||||
claide (1.0.3)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
@@ -36,18 +36,17 @@ GEM
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.7.6)
|
||||
emoji_regex (3.2.3)
|
||||
excon (0.90.0)
|
||||
faraday (1.9.3)
|
||||
excon (0.89.0)
|
||||
faraday (1.8.0)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
faraday-retry (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-cookie_jar (0.0.7)
|
||||
faraday (>= 0.8.0)
|
||||
@@ -56,17 +55,14 @@ GEM
|
||||
faraday-em_synchrony (1.0.0)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.0.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-net_http (1.0.1)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.3)
|
||||
faraday_middleware (1.2.0)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.2.6)
|
||||
fastlane (2.201.1)
|
||||
fastimage (2.2.5)
|
||||
fastlane (2.199.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
@@ -105,11 +101,11 @@ GEM
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.3.0)
|
||||
xcpretty-travis-formatter (>= 0.0.3)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.18)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.17)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.15.0)
|
||||
google-apis-androidpublisher_v3 (0.14.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-core (0.4.2)
|
||||
google-apis-core (0.4.1)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
googleauth (>= 0.16.2, < 2.a)
|
||||
httpclient (>= 2.8.1, < 3.a)
|
||||
@@ -118,11 +114,11 @@ GEM
|
||||
retriable (>= 2.0, < 4.a)
|
||||
rexml
|
||||
webrick
|
||||
google-apis-iamcredentials_v1 (0.10.0)
|
||||
google-apis-iamcredentials_v1 (0.9.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-playcustomapp_v1 (0.7.0)
|
||||
google-apis-playcustomapp_v1 (0.6.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-apis-storage_v1 (0.11.0)
|
||||
google-apis-storage_v1 (0.10.0)
|
||||
google-apis-core (>= 0.4, < 2.a)
|
||||
google-cloud-core (1.6.0)
|
||||
google-cloud-env (~> 1.0)
|
||||
@@ -130,7 +126,7 @@ GEM
|
||||
google-cloud-env (1.5.0)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
google-cloud-errors (1.2.0)
|
||||
google-cloud-storage (1.36.0)
|
||||
google-cloud-storage (1.35.0)
|
||||
addressable (~> 2.8)
|
||||
digest-crc (~> 0.4)
|
||||
google-apis-iamcredentials_v1 (~> 0.1)
|
||||
@@ -149,7 +145,7 @@ GEM
|
||||
http-cookie (1.0.4)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.8.3)
|
||||
jmespath (1.5.0)
|
||||
jmespath (1.4.0)
|
||||
json (2.6.1)
|
||||
jwt (2.3.0)
|
||||
memoist (0.16.2)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# [Nextcloud](https://nextcloud.com) Android app :iphone:
|
||||
|
||||
[](https://drone.nextcloud.com/nextcloud/android) [](https://www.codacy.com/app/Nextcloud/android?utm_source=github.com&utm_medium=referral&utm_content=nextcloud/android&utm_campaign=Badge_Grade) [](https://github.com/nextcloud/android/releases/latest)
|
||||
[](https://drone.nextcloud.com/nextcloud/android) [](https://www.codacy.com/app/Nextcloud/android?utm_source=github.com&utm_medium=referral&utm_content=nextcloud/android&utm_campaign=Badge_Grade) [](https://github.com/nextcloud/android/releases/latest) [](https://webchat.freenode.net/?channels=nextcloud-mobile)
|
||||
|
||||
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png"
|
||||
alt="Download from Google Play"
|
||||
@@ -16,6 +16,7 @@
|
||||
## How to contribute :rocket:
|
||||
If you want to [contribute](https://nextcloud.com/contribute/) to Nextcloud, you are very welcome:
|
||||
|
||||
- on our IRC channels [](https://webchat.freenode.net/?channels=nextcloud) and [](https://webchat.freenode.net/?channels=nextcloud-mobile) on freenode
|
||||
- our forum at https://help.nextcloud.com
|
||||
- for translations of the app on [Transifex](https://www.transifex.com/nextcloud/nextcloud/android/)
|
||||
- opening issues and PRs (including a corresponding issue)
|
||||
@@ -74,7 +75,7 @@ or
|
||||
|
||||
## Support :rescue_worker_helmet:
|
||||
|
||||
If you need assistance or want to ask a question about the Android app, you are welcome to [ask for support](https://help.nextcloud.com/c/clients/android) in our Forums. If you have found a bug, feel free to [open a new Issue on GitHub](https://github.com/nextcloud/android/issues). Keep in mind, that this repository only manages the Android app. If you find bugs or have problems with the server/backend, you should ask the [Nextcloud server team](https://github.com/nextcloud/server) for help!
|
||||
If you need assistance or want to ask a question about the Android app, you are welcome to [ask for support](https://help.nextcloud.com/c/clients/android) in our Forums or the [IRC-Channel](https://webchat.freenode.net/?channels=nextcloud-mobile). If you have found a bug, feel free to [open a new Issue on GitHub](https://github.com/nextcloud/android/issues). Keep in mind, that this repository only manages the Android app. If you find bugs or have problems with the server/backend, you should ask the [Nextcloud server team](https://github.com/nextcloud/server) for help!
|
||||
|
||||
## Remarks :scroll:
|
||||
|
||||
|
||||
@@ -89,23 +89,20 @@ The app is currently equipped to be built with three flavours:
|
||||
#### 1. Direct usage of library project
|
||||
|
||||
This is handy if one wants to make changes both to files app and library:
|
||||
- In the repository root: `ln -s [path to library clone] nextcloud-android-library`
|
||||
- Add the following to `settings.gradle`:
|
||||
```groovy
|
||||
include ':nextcloud-android-library'
|
||||
```
|
||||
- In `app/build.gradle`, replace the following:
|
||||
```groovy
|
||||
implementation ("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: 'org.ogce', module: 'xpp3'
|
||||
}
|
||||
```
|
||||
with:
|
||||
``` groovy
|
||||
implementation project(':nextcloud-android-library')
|
||||
```
|
||||
|
||||
- Sync project with gradle files
|
||||
- in files app root: ln -s $pathToLibraryProject nextcloud-android-library
|
||||
- uncomment in build.gradle:
|
||||
- `// implementation project('nextcloud-android-library')`
|
||||
- comment in build.gradle:
|
||||
```
|
||||
implementation ("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
|
||||
}
|
||||
```
|
||||
- comment in settings.gradle:
|
||||
- `include ':'`
|
||||
- add in settings.gradle:
|
||||
- `include 'nextcloud-android-library'`
|
||||
- sync project with gradle files
|
||||
|
||||
Now every change in library can be directly used in files app.
|
||||
|
||||
|
||||
@@ -43,6 +43,18 @@ The third party software included and used by this project is:
|
||||
The library is included in the Nextcloud client APK.
|
||||
See http://jackrabbit.apache.org/
|
||||
|
||||
* TouchImageView, 1.2.0. commit 6dbeac4f11936185ba374c73144ac431c23c9aab
|
||||
Copyright (c) 2014 Michael Ortiz
|
||||
Licensed under MIT License
|
||||
This library is in the source code.
|
||||
See https://github.com/MikeOrtiz/TouchImageView
|
||||
|
||||
* floatingactionbutton 1.10.21.
|
||||
Copyright (c) 2014 Jerzy Chalupski
|
||||
Licensed under Apache License, Version 2.0.
|
||||
The library is included in the Nextcloud client APK.
|
||||
See https://github.com/futuresimple/android-floating-action-button
|
||||
|
||||
* AndroidSVG 1.2.1.
|
||||
Copyright (c) 2014 Paul LeBeau
|
||||
Licensed under Apache License, Version 2.0.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,457 +0,0 @@
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
import org.gradle.internal.jvm.Jvm
|
||||
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.2'
|
||||
classpath 'com.hiya:jacoco-android:0.2'
|
||||
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.6'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.19.0"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:5.13.0'
|
||||
classpath "org.jacoco:org.jacoco.core:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.report:$jacoco_version"
|
||||
classpath "org.jacoco:org.jacoco.agent:$jacoco_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'pmd'
|
||||
apply plugin: 'com.hiya.jacoco-android'
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
apply plugin: 'io.gitlab.arturbosch.detekt'
|
||||
apply plugin: 'shot'
|
||||
|
||||
println "Gradle uses Java ${Jvm.current()}"
|
||||
|
||||
configurations {
|
||||
ktlint
|
||||
|
||||
all {
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
|
||||
|
||||
// check for updates every build
|
||||
resolutionStrategy {
|
||||
cacheChangingModulesFor 0, 'seconds'
|
||||
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy.eachDependency {
|
||||
if (requested.group == "org.checkerframework" && requested.name != "checker-compat-qual") {
|
||||
useVersion(checkerVersion)
|
||||
because("https://github.com/google/ExoPlayer/issues/10007")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
android {
|
||||
|
||||
compileSdkVersion 31
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
|
||||
buildConfigField 'boolean', 'CI', ciBuild.toString()
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
testInstrumentationRunner "com.nextcloud.client.ScreenshotTestRunner"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_URL", "${NC_TEST_SERVER_BASEURL}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_USERNAME", "${NC_TEST_SERVER_USERNAME}"
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_PASSWORD", "${NC_TEST_SERVER_PASSWORD}"
|
||||
testInstrumentationRunnerArguments disableAnalytics: 'true'
|
||||
|
||||
multiDexEnabled true
|
||||
|
||||
versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
|
||||
if (versionBuild > 89) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
} else if (versionBuild > 50) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC" + (versionBuild - 50)
|
||||
} else {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
flavorDimensions "default"
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
testCoverageEnabled (project.hasProperty('coverage'))
|
||||
}
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
// used for f-droid
|
||||
generic {
|
||||
applicationId 'com.nextcloud.client'
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
gplay {
|
||||
applicationId 'com.nextcloud.client'
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
huawei {
|
||||
applicationId 'com.nextcloud.client'
|
||||
dimension "default"
|
||||
}
|
||||
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20200129
|
||||
versionName "20200129"
|
||||
}
|
||||
|
||||
qa {
|
||||
applicationId "com.nextcloud.android.qa"
|
||||
dimension "default"
|
||||
versionCode 1
|
||||
versionName "1"
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
animationsDisabled true
|
||||
}
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
packagingOptions {
|
||||
resources {
|
||||
excludes += ['META-INF/LICENSE.txt', 'META-INF/LICENSE']
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkstyle", Checkstyle) {
|
||||
configFile = file("${rootProject.projectDir}/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
|
||||
source 'src'
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
classpath = files()
|
||||
}
|
||||
|
||||
tasks.register("pmd", Pmd) {
|
||||
ruleSetFiles = files("${project.rootDir}/ruleset.xml")
|
||||
ignoreFailures = true // should continue checking
|
||||
ruleSets = []
|
||||
|
||||
source 'src'
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html.enabled = true
|
||||
xml {
|
||||
destination = file("$project.buildDir/reports/pmd/pmd.xml")
|
||||
}
|
||||
html {
|
||||
destination = file("$project.buildDir/reports/pmd/pmd.html")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
viewBinding true
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
lint {
|
||||
abortOnError false
|
||||
checkGeneratedSources true
|
||||
disable 'MissingTranslation', 'GradleDependency', 'VectorPath', 'IconMissingDensityFolder', 'IconDensities', 'GoogleAppIndexingWarning', 'MissingDefaultResource', 'InvalidPeriodicWorkRequestInterval', 'StringFormatInvalid', 'MissingQuantity'
|
||||
htmlOutput file("$project.buildDir/reports/lint/lint.html")
|
||||
htmlReport true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// dependencies for app building
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
// implementation project('nextcloud-android-library')
|
||||
implementation ("com.github.nextcloud:android-library:$androidLibraryVersion") {
|
||||
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
|
||||
}
|
||||
|
||||
compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' // remove after entire switch to lib v2
|
||||
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.5' // remove after entire switch to lib v2
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.webkit:webkit:1.4.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.3.3'
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
|
||||
implementation "androidx.work:work-runtime:$workRuntime"
|
||||
implementation "androidx.work:work-runtime-ktx:$workRuntime"
|
||||
implementation "androidx.fragment:fragment-ktx:1.4.1"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
|
||||
compileOnly 'com.google.code.findbugs:annotations:3.0.1u2'
|
||||
implementation 'commons-io:commons-io:2.11.0'
|
||||
implementation 'org.greenrobot:eventbus:3.3.1'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
||||
implementation 'org.lukhnos:nnio:0.2'
|
||||
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.70'
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
|
||||
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.github.bumptech.glide:glide:3.8.0') {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
implementation 'com.caverock:androidsvg:1.4'
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
implementation 'com.vanniktech:emoji-google:0.8.0'
|
||||
|
||||
implementation "com.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'
|
||||
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0'
|
||||
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
|
||||
|
||||
implementation "com.google.dagger:dagger:$daggerVersion"
|
||||
implementation "com.google.dagger:dagger-android:$daggerVersion"
|
||||
implementation "com.google.dagger:dagger-android-support:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.44.0"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.5.2'
|
||||
|
||||
implementation "com.google.android.exoplayer:exoplayer:$exoplayerVersion"
|
||||
implementation "com.google.android.exoplayer:extension-okhttp:$exoplayerVersion"
|
||||
|
||||
// Shimmer animation
|
||||
implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0'
|
||||
|
||||
// dependencies for markdown rendering
|
||||
implementation "io.noties.markwon:core:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-strikethrough:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-tables:$markwonVersion"
|
||||
implementation "io.noties.markwon:ext-tasklist:$markwonVersion"
|
||||
implementation "io.noties.markwon:html:$markwonVersion"
|
||||
|
||||
implementation "io.noties.markwon:syntax-highlight:$markwonVersion"
|
||||
implementation "io.noties:prism4j:$prismVersion"
|
||||
kapt "io.noties:prism4j-bundler:$prismVersion"
|
||||
|
||||
implementation ('org.mnode.ical4j:ical4j:1.0.8') {
|
||||
['org.apache.commons','commons-logging'].each {
|
||||
exclude group: "$it"
|
||||
}
|
||||
}
|
||||
|
||||
if (!ciBuild) {
|
||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
|
||||
}
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
testImplementation "androidx.test:core:$androidxTestVersion"
|
||||
testImplementation "org.powermock:powermock-core:$powermockVersion"
|
||||
testImplementation "org.powermock:powermock-module-junit4:$powermockVersion"
|
||||
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
|
||||
testImplementation 'org.json:json:20211205'
|
||||
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
testImplementation 'androidx.arch.core:core-testing:2.1.0'
|
||||
testImplementation "io.mockk:mockk:$mockkVersion"
|
||||
testImplementation "io.mockk:mockk-android:$mockkVersion"
|
||||
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation "androidx.test:rules:$androidxTestVersion"
|
||||
// Android JUnit Runner
|
||||
androidTestImplementation "androidx.test:runner:$androidxTestVersion"
|
||||
androidTestUtil "androidx.test:orchestrator:$androidxTestVersion"
|
||||
|
||||
// Espresso core
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-web:$espressoVersion"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-accessibility:$espressoVersion"
|
||||
|
||||
// Mocking support
|
||||
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
|
||||
androidTestImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
|
||||
androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
|
||||
androidTestImplementation("org.mockito:mockito-android:$mockitoVersion") {
|
||||
exclude group: "net.bytebuddy", module: "byte-buddy-android"
|
||||
}
|
||||
androidTestImplementation "net.bytebuddy:byte-buddy:$byteBuddyVersion"
|
||||
androidTestImplementation "net.bytebuddy:byte-buddy-android:$byteBuddyVersion"
|
||||
androidTestImplementation "io.mockk:mockk-android:$mockkVersion"
|
||||
androidTestImplementation 'androidx.arch.core:core-testing:2.0.1'
|
||||
androidTestImplementation "com.facebook.testing.screenshot:core:0.15.0"
|
||||
|
||||
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
|
||||
// androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
androidTestImplementation('androidx.test.espresso:espresso-intents:3.4.0')
|
||||
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
|
||||
// upon each update first test: new registration, receive push
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:20.1.3"
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy{
|
||||
cacheChangingModulesFor 0, 'seconds'
|
||||
force 'org.objenesis:objenesis:2.6'
|
||||
eachDependency { details ->
|
||||
if ('org.jacoco' == details.requested.group) {
|
||||
details.useVersion "$jacoco_version"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tasks.withType(Test) {
|
||||
// increased logging for tests
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
}
|
||||
}
|
||||
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
outputFileName = "${output.baseName}-${variant.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("combinedTestReport", JacocoReport) {
|
||||
|
||||
jacocoClasspath = configurations['jacocoAnt']
|
||||
|
||||
reports {
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
csv.enabled false
|
||||
}
|
||||
|
||||
additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
classDirectories.setFrom files(subprojects.sourceSets.main.output)
|
||||
executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
|
||||
task ktlint(type: JavaExec, group: "verification") {
|
||||
description = "Check Kotlin code style."
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
classpath = configurations.ktlint
|
||||
args "--reporter=plain", "--reporter=plain,output=${buildDir}/ktlint.txt,${projectDir}/src/**/*.kt"
|
||||
}
|
||||
|
||||
task ktlintFormat(type: JavaExec, group: "formatting") {
|
||||
description = "Fix Kotlin code style deviations."
|
||||
main = "com.pinterest.ktlint.Main"
|
||||
classpath = configurations.ktlint
|
||||
args "-F", "${projectDir}/src/**/*.kt"
|
||||
}
|
||||
|
||||
task installGitHooks(type: Copy, group: "development") {
|
||||
description = "Install git hooks"
|
||||
from("${project.rootDir}/scripts/hooks") {
|
||||
include '*'
|
||||
}
|
||||
into "${project.rootDir}/.git/hooks"
|
||||
}
|
||||
|
||||
detekt {
|
||||
reports {
|
||||
xml {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
config = files("detekt.yml")
|
||||
}
|
||||
|
||||
shot {
|
||||
showOnlyFailingTestsInReports = ciBuild
|
||||
// CI environment renders some shadows slightly different from local VMs
|
||||
// Add a 0.5% tolerance to account for that
|
||||
tolerance = ciBuild ? 0.5: 0
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "$jacoco_version"
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = "max"
|
||||
reportLevel = "medium"
|
||||
}
|
||||
|
||||
tasks.withType(SpotBugsTask){task ->
|
||||
String variantNameCap = task.name.replace("spotbugs", "")
|
||||
String variantName = variantNameCap.substring(0, 1).toLowerCase() + variantNameCap.substring(1)
|
||||
|
||||
dependsOn "compile${variantNameCap}Sources"
|
||||
|
||||
excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
|
||||
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html {
|
||||
enabled = true
|
||||
destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 26 KiB |
@@ -1,70 +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 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
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
class FileDataStorageManagerContentResolverIT : FileDataStorageManagerIT() {
|
||||
companion object {
|
||||
private const val MANY_FILES_AMOUNT = 5000
|
||||
}
|
||||
|
||||
override fun before() {
|
||||
sut = FileDataStorageManager(user, targetContext.contentResolver)
|
||||
super.before()
|
||||
}
|
||||
|
||||
/**
|
||||
* only on FileDataStorageManager
|
||||
*/
|
||||
@Test
|
||||
fun testFolderWithManyFiles() {
|
||||
// create folder
|
||||
val folderA = OCFile("/folderA/")
|
||||
folderA.setFolder().parentId = sut.getFileByDecryptedRemotePath("/")!!.fileId
|
||||
sut.saveFile(folderA)
|
||||
Assert.assertTrue(sut.fileExists("/folderA/"))
|
||||
Assert.assertEquals(0, sut.getFolderContent(folderA, false).size)
|
||||
val folderAId = sut.getFileByDecryptedRemotePath("/folderA/")!!.fileId
|
||||
|
||||
// create files
|
||||
val newFiles = (1..MANY_FILES_AMOUNT).map {
|
||||
val file = OCFile("/folderA/file$it")
|
||||
file.parentId = folderAId
|
||||
sut.saveFile(file)
|
||||
|
||||
val storedFile = sut.getFileByDecryptedRemotePath("/folderA/file$it")
|
||||
Assert.assertNotNull(storedFile)
|
||||
storedFile
|
||||
}
|
||||
|
||||
// save files in folder
|
||||
sut.saveFolder(
|
||||
folderA,
|
||||
newFiles,
|
||||
ArrayList()
|
||||
)
|
||||
// check file count is correct
|
||||
Assert.assertEquals(MANY_FILES_AMOUNT, sut.getFolderContent(folderA, false).size)
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
class OCFileListAdapterIT : AbstractIT() {
|
||||
@Test
|
||||
fun testParseMedia() {
|
||||
// empty start
|
||||
storageManager.deleteAllFiles()
|
||||
|
||||
val startDate: Long = 0
|
||||
val endDate: Long = 3642752043
|
||||
assertEquals(0, storageManager.getGalleryItems(startDate, endDate).size)
|
||||
|
||||
// create dummy files
|
||||
OCFile("/test.txt").apply {
|
||||
mimeType = "text/plain"
|
||||
}.let {
|
||||
storageManager.saveFile(it)
|
||||
}
|
||||
|
||||
OCFile("/image.png").apply {
|
||||
mimeType = "image/png"
|
||||
modificationTimestamp = 1000000
|
||||
}.let {
|
||||
storageManager.saveFile(it)
|
||||
}
|
||||
|
||||
OCFile("/image2.png").apply {
|
||||
mimeType = "image/png"
|
||||
modificationTimestamp = 1000050
|
||||
}.let {
|
||||
storageManager.saveFile(it)
|
||||
}
|
||||
|
||||
OCFile("/video.mpg").apply {
|
||||
mimeType = "video/mpg"
|
||||
modificationTimestamp = 1000045
|
||||
}.let {
|
||||
storageManager.saveFile(it)
|
||||
}
|
||||
|
||||
OCFile("/video2.avi").apply {
|
||||
mimeType = "video/avi"
|
||||
modificationTimestamp = endDate + 10
|
||||
}.let {
|
||||
storageManager.saveFile(it)
|
||||
}
|
||||
|
||||
// list of remoteFiles
|
||||
assertEquals(5, storageManager.allFiles.size)
|
||||
assertEquals(3, storageManager.getGalleryItems(startDate, endDate).size)
|
||||
assertEquals(4, storageManager.allGalleryItems.size)
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.preview
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
|
||||
companion object {
|
||||
private const val PNG_FILE_ASSET = "imageFile.png"
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(PreviewBitmapActivity::class.java, true, false)
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showBitmap() {
|
||||
|
||||
val pngFile = getFile(PNG_FILE_ASSET)
|
||||
|
||||
val activity = testActivityRule.launchActivity(
|
||||
Intent().putExtra(
|
||||
PreviewBitmapActivity.EXTRA_BITMAP_PATH,
|
||||
pngFile.absolutePath
|
||||
)
|
||||
)
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(activity)
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* 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.preview.pdf
|
||||
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule
|
||||
import com.nextcloud.client.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewPdfFragmentScreenshotIT : AbstractIT() {
|
||||
|
||||
companion object {
|
||||
private const val PDF_FILE_ASSET = "test.pdf"
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val testActivityRule = IntentsTestRule(TestActivity::class.java, true, false)
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun showPdf() {
|
||||
val activity = testActivityRule.launchActivity(null)
|
||||
|
||||
val pdfFile = getFile(PDF_FILE_ASSET)
|
||||
val ocFile = OCFile("/test.pdf").apply {
|
||||
storagePath = pdfFile.absolutePath
|
||||
}
|
||||
|
||||
val sut = PreviewPdfFragment.newInstance(ocFile)
|
||||
activity.addFragment(sut)
|
||||
|
||||
while (!sut.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
shortSleep()
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
sut.dismissSnack()
|
||||
}
|
||||
|
||||
shortSleep()
|
||||
waitForIdleSync()
|
||||
|
||||
screenshot(activity)
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.client.media
|
||||
|
||||
import android.content.Context
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.ext.okhttp.OkHttpDataSource
|
||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSource
|
||||
import com.nextcloud.common.NextcloudClient
|
||||
|
||||
object NextcloudExoPlayer {
|
||||
|
||||
/**
|
||||
* Creates an [ExoPlayer] that uses [NextcloudClient] for HTTP connections, thus respecting redirections,
|
||||
* IP versions and certificates.
|
||||
*
|
||||
*/
|
||||
@JvmStatic
|
||||
fun createNextcloudExoplayer(context: Context, nextcloudClient: NextcloudClient): ExoPlayer {
|
||||
val okHttpDataSourceFactory = OkHttpDataSource.Factory(nextcloudClient.client)
|
||||
val mediaSourceFactory = DefaultMediaSourceFactory(
|
||||
DefaultDataSource.Factory(
|
||||
context,
|
||||
okHttpDataSourceFactory
|
||||
)
|
||||
)
|
||||
return ExoPlayer.Builder(context).setMediaSourceFactory(mediaSourceFactory).build()
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.owncloud.android.authentication
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.PowerManager
|
||||
import android.view.WindowManager
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.ui.activity.PassCodeActivity
|
||||
import com.owncloud.android.ui.activity.RequestCredentialsActivity
|
||||
import com.owncloud.android.ui.activity.SettingsActivity
|
||||
import com.owncloud.android.utils.DeviceCredentialUtils
|
||||
import kotlin.math.abs
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class PassCodeManager(private val preferences: AppPreferences, private val clock: Clock) {
|
||||
companion object {
|
||||
private val exemptOfPasscodeActivities = setOf(
|
||||
PassCodeActivity::class.java,
|
||||
RequestCredentialsActivity::class.java
|
||||
)
|
||||
const val PASSCODE_ACTIVITY = 9999
|
||||
|
||||
/**
|
||||
* Keeping a "low" positive value is the easiest way to prevent
|
||||
* the pass code being requested on screen rotations.
|
||||
*/
|
||||
private const val PASS_CODE_TIMEOUT = 5000
|
||||
}
|
||||
|
||||
private var visibleActivitiesCounter = 0
|
||||
|
||||
private fun isExemptActivity(activity: Activity): Boolean {
|
||||
return exemptOfPasscodeActivities.contains(activity.javaClass)
|
||||
}
|
||||
|
||||
fun onActivityStarted(activity: Activity): Boolean {
|
||||
var askedForPin = false
|
||||
val timestamp = preferences.lockTimestamp
|
||||
setSecureFlag(activity)
|
||||
|
||||
if (!isExemptActivity(activity)) {
|
||||
if (passCodeShouldBeRequested(timestamp)) {
|
||||
askedForPin = true
|
||||
preferences.lockTimestamp = 0
|
||||
requestPasscode(activity)
|
||||
}
|
||||
if (deviceCredentialsShouldBeRequested(timestamp, activity)) {
|
||||
askedForPin = true
|
||||
preferences.lockTimestamp = 0
|
||||
requestCredentials(activity)
|
||||
}
|
||||
}
|
||||
|
||||
if (!askedForPin && preferences.lockTimestamp != 0L) {
|
||||
updateLockTimestamp()
|
||||
}
|
||||
|
||||
if (!isExemptActivity(activity)) {
|
||||
visibleActivitiesCounter++ // keep it AFTER passCodeShouldBeRequested was checked
|
||||
}
|
||||
return askedForPin
|
||||
}
|
||||
|
||||
private fun setSecureFlag(activity: Activity) {
|
||||
val window = activity.window
|
||||
if (window != null) {
|
||||
if (isPassCodeEnabled() || deviceCredentialsAreEnabled(activity)) {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
||||
} else {
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestPasscode(activity: Activity) {
|
||||
val i = Intent(MainApp.getAppContext(), PassCodeActivity::class.java)
|
||||
i.action = PassCodeActivity.ACTION_CHECK
|
||||
i.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
activity.startActivityForResult(i, PASSCODE_ACTIVITY)
|
||||
}
|
||||
|
||||
private fun requestCredentials(activity: Activity) {
|
||||
val i = Intent(MainApp.getAppContext(), RequestCredentialsActivity::class.java)
|
||||
i.flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
activity.startActivityForResult(i, PASSCODE_ACTIVITY)
|
||||
}
|
||||
|
||||
fun onActivityStopped(activity: Activity) {
|
||||
if (visibleActivitiesCounter > 0 && !isExemptActivity(activity)) {
|
||||
visibleActivitiesCounter--
|
||||
}
|
||||
val powerMgr = activity.getSystemService(Context.POWER_SERVICE) as PowerManager
|
||||
if ((isPassCodeEnabled() || deviceCredentialsAreEnabled(activity)) && !powerMgr?.isScreenOn) {
|
||||
activity.moveTaskToBack(true)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateLockTimestamp() {
|
||||
preferences.lockTimestamp = clock.millisSinceBoot
|
||||
}
|
||||
|
||||
/**
|
||||
* `true` if the time elapsed since last unlock is longer than [PASS_CODE_TIMEOUT] and no activities are visible
|
||||
*/
|
||||
private fun shouldBeLocked(timestamp: Long) =
|
||||
abs(clock.millisSinceBoot - timestamp) > PASS_CODE_TIMEOUT &&
|
||||
visibleActivitiesCounter <= 0
|
||||
|
||||
private fun passCodeShouldBeRequested(timestamp: Long): Boolean {
|
||||
return shouldBeLocked(timestamp) && isPassCodeEnabled()
|
||||
}
|
||||
|
||||
private fun isPassCodeEnabled(): Boolean = SettingsActivity.LOCK_PASSCODE == preferences.lockPreference
|
||||
|
||||
private fun deviceCredentialsShouldBeRequested(timestamp: Long, activity: Activity): Boolean {
|
||||
return shouldBeLocked(timestamp) && deviceCredentialsAreEnabled(activity)
|
||||
}
|
||||
|
||||
private fun deviceCredentialsAreEnabled(activity: Activity): Boolean {
|
||||
return SettingsActivity.LOCK_DEVICE_CREDENTIALS == preferences.lockPreference ||
|
||||
(preferences.isFingerprintUnlockEnabled && DeviceCredentialUtils.areCredentialsAvailable(activity))
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Nextcloud application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2018 Mario Danic <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datamodel
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
/*
|
||||
* Push data from server, https://github.com/nextcloud/notifications/blob/master/docs/push-v2.md#encrypted-subject-data
|
||||
*/
|
||||
@Parcelize
|
||||
data class DecryptedPushMessage(
|
||||
val app: String,
|
||||
val type: String,
|
||||
val subject: String,
|
||||
val id: String,
|
||||
val nid: Int,
|
||||
val delete: Boolean,
|
||||
@SerializedName("delete-all")
|
||||
val deleteAll: Boolean
|
||||
) : Parcelable
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Nextcloud application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2018 Mario Danic <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.datamodel
|
||||
|
||||
import android.accounts.Account
|
||||
import android.os.Parcelable
|
||||
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class SignatureVerification(val signatureValid: Boolean, val account: Account?) : Parcelable
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 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.datamodel
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
/**
|
||||
* Template for creating a file from it via RichDocuments app
|
||||
*/
|
||||
@Parcelize
|
||||
data class Template(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val thumbnailLink: String,
|
||||
val type: Type,
|
||||
val extension: String
|
||||
) : Parcelable {
|
||||
enum class Type {
|
||||
DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN;
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun parse(name: String) = try {
|
||||
valueOf(name.uppercase())
|
||||
} catch (_: IllegalArgumentException) {
|
||||
UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.owncloud.android.ui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.net.http.SslCertificate
|
||||
import android.net.http.SslError
|
||||
import android.webkit.SslErrorHandler
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity
|
||||
import com.owncloud.android.lib.common.network.NetworkUtils
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.security.cert.CertificateException
|
||||
import java.security.cert.CertificateFactory
|
||||
import java.security.cert.X509Certificate
|
||||
|
||||
open class NextcloudWebViewClient(val supportFragmentManager: FragmentManager) : WebViewClient() {
|
||||
|
||||
private val tag: String? = NextcloudWebViewClient::class.simpleName
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
@SuppressLint("WebViewClientOnReceivedSslError")
|
||||
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler, error: SslError?) {
|
||||
val cert = error?.let { getX509CertificateFromError(it) }
|
||||
try {
|
||||
if (NetworkUtils.isCertInKnownServersStore(cert, view?.context?.applicationContext)) {
|
||||
handler.proceed()
|
||||
} else {
|
||||
showUntrustedCertDialog(cert, error, handler)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log_OC.e(tag, "Cert could not be verified")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain the X509Certificate from SslError
|
||||
*
|
||||
* @param error SslError
|
||||
* @return X509Certificate from error
|
||||
*/
|
||||
open fun getX509CertificateFromError(error: SslError): X509Certificate? {
|
||||
val bundle = SslCertificate.saveState(error.certificate)
|
||||
val x509Certificate: X509Certificate?
|
||||
val bytes = bundle.getByteArray("x509-certificate")
|
||||
x509Certificate = if (bytes == null) {
|
||||
null
|
||||
} else {
|
||||
try {
|
||||
val certFactory = CertificateFactory.getInstance("X.509")
|
||||
val cert = certFactory.generateCertificate(ByteArrayInputStream(bytes))
|
||||
cert as X509Certificate
|
||||
} catch (e: CertificateException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
return x509Certificate
|
||||
}
|
||||
/**
|
||||
* Show untrusted cert dialog
|
||||
*/
|
||||
private fun showUntrustedCertDialog(
|
||||
x509Certificate: X509Certificate?,
|
||||
error: SslError?,
|
||||
handler: SslErrorHandler?
|
||||
) {
|
||||
// Show a dialog with the certificate info
|
||||
val dialog: SslUntrustedCertDialog = if (x509Certificate == null) {
|
||||
SslUntrustedCertDialog.newInstanceForEmptySslError(error, handler)
|
||||
} else {
|
||||
SslUntrustedCertDialog.newInstanceForFullSslError(x509Certificate, error, handler)
|
||||
}
|
||||
val fm: FragmentManager = supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
dialog.show(ft, AuthenticatorActivity.UNTRUSTED_CERT_DIALOG_TAG)
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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 android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.zynksoftware.documentscanner.ScanActivity
|
||||
import com.zynksoftware.documentscanner.model.DocumentScannerErrorModel
|
||||
import com.zynksoftware.documentscanner.model.ScannerResults
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.os.AsyncTask
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class ManageSpaceActivity : AppCompatActivity(), Injectable {
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: AppPreferences
|
||||
|
||||
@Inject
|
||||
lateinit var userAccountManager: UserAccountManager
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_manage_space)
|
||||
val actionBar = supportActionBar
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||
actionBar.setTitle(R.string.manage_space_title)
|
||||
}
|
||||
val descriptionTextView = findViewById<TextView>(R.id.general_description)
|
||||
descriptionTextView.text = getString(R.string.manage_space_description, getString(R.string.app_name))
|
||||
val clearDataButton = findViewById<Button>(R.id.clearDataButton)
|
||||
clearDataButton.setOnClickListener {
|
||||
val clearDataTask = ClearDataAsyncTask()
|
||||
clearDataTask.execute()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
var retval = true
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> finish()
|
||||
else -> {
|
||||
Log_OC.w(TAG, "Unknown menu item triggered")
|
||||
retval = super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
return retval
|
||||
}
|
||||
|
||||
/**
|
||||
* AsyncTask for Clear Data, saving the passcode
|
||||
*/
|
||||
private inner class ClearDataAsyncTask : AsyncTask<Void, Void, Boolean>() {
|
||||
private val preferences = this@ManageSpaceActivity.preferences
|
||||
private val userAccountManager = this@ManageSpaceActivity.userAccountManager
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
override fun doInBackground(vararg params: Void): Boolean {
|
||||
val lockPref = preferences.lockPreference
|
||||
val passCodeEnable = SettingsActivity.LOCK_PASSCODE == lockPref
|
||||
var passCodeDigits = arrayOfNulls<String>(4)
|
||||
if (passCodeEnable) {
|
||||
passCodeDigits = preferences.passCode
|
||||
}
|
||||
|
||||
// Clear data
|
||||
preferences.clear()
|
||||
val result = clearApplicationData()
|
||||
|
||||
// Recover passcode
|
||||
if (passCodeEnable) {
|
||||
preferences.setPassCode(
|
||||
passCodeDigits[0],
|
||||
passCodeDigits[1],
|
||||
passCodeDigits[2],
|
||||
passCodeDigits[3]
|
||||
)
|
||||
}
|
||||
preferences.lockPreference = lockPref
|
||||
userAccountManager.removeAllAccounts()
|
||||
return result
|
||||
}
|
||||
|
||||
override fun onPostExecute(result: Boolean) {
|
||||
super.onPostExecute(result)
|
||||
if (!result) {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
R.string.manage_space_clear_data,
|
||||
Snackbar.LENGTH_LONG
|
||||
).show()
|
||||
} else {
|
||||
finishAndRemoveTask()
|
||||
exitProcess(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearApplicationData(): Boolean {
|
||||
var clearResult = true
|
||||
val appDir = File(cacheDir.parent!!)
|
||||
if (appDir.exists()) {
|
||||
val children = appDir.list()
|
||||
if (children != null) {
|
||||
children.filter { it != LIB_FOLDER }.forEach { s ->
|
||||
val fileToDelete = File(appDir, s)
|
||||
clearResult = clearResult && deleteDir(fileToDelete)
|
||||
Log_OC.d(TAG, "Clear Application Data, File: " + fileToDelete.name + " DELETED *****")
|
||||
}
|
||||
} else {
|
||||
clearResult = false
|
||||
}
|
||||
}
|
||||
return clearResult
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
fun deleteDir(dir: File?): Boolean {
|
||||
if (dir != null && dir.isDirectory) {
|
||||
dir.list()?.forEach { child ->
|
||||
val success = deleteDir(File(dir, child))
|
||||
if (!success) {
|
||||
Log_OC.w(TAG, "File NOT deleted $child")
|
||||
return false
|
||||
} else {
|
||||
Log_OC.d(TAG, "File deleted $child")
|
||||
}
|
||||
} ?: return false
|
||||
}
|
||||
return dir?.delete() ?: false
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = ManageSpaceActivity::class.java.simpleName
|
||||
private const val LIB_FOLDER = "lib"
|
||||
}
|
||||
}
|
||||
@@ -1,809 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2016 Andy Scherzinger
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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.annotation.SuppressLint
|
||||
import android.app.NotificationManager
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.PowerManager
|
||||
import android.provider.Settings
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.nextcloud.client.core.Clock
|
||||
import com.nextcloud.client.device.PowerManagementService
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.jobs.BackgroundJobManager
|
||||
import com.nextcloud.client.jobs.MediaFoldersDetectionWork
|
||||
import com.nextcloud.client.jobs.NotificationWork
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.BuildConfig
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.SyncedFoldersLayoutBinding
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider
|
||||
import com.owncloud.android.datamodel.MediaFolder
|
||||
import com.owncloud.android.datamodel.MediaFolderType
|
||||
import com.owncloud.android.datamodel.MediaProvider
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem
|
||||
import com.owncloud.android.datamodel.SyncedFolderProvider
|
||||
import com.owncloud.android.files.services.FileUploader
|
||||
import com.owncloud.android.files.services.NameCollisionPolicy
|
||||
import com.owncloud.android.ui.adapter.SyncedFolderAdapter
|
||||
import com.owncloud.android.ui.decoration.MediaGridItemDecoration
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment.OnSyncedFolderPreferenceListener
|
||||
import com.owncloud.android.ui.dialog.parcel.SyncedFolderParcelable
|
||||
import com.owncloud.android.utils.PermissionUtil
|
||||
import com.owncloud.android.utils.SyncedFolderUtils
|
||||
import com.owncloud.android.utils.theme.ThemeButtonUtils
|
||||
import com.owncloud.android.utils.theme.ThemeUtils
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Activity displaying all auto-synced folders and/or instant upload media folders.
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
class SyncedFoldersActivity :
|
||||
FileActivity(),
|
||||
SyncedFolderAdapter.ClickListener,
|
||||
OnSyncedFolderPreferenceListener,
|
||||
Injectable {
|
||||
|
||||
companion object {
|
||||
private const val SYNCED_FOLDER_PREFERENCES_DIALOG_TAG = "SYNCED_FOLDER_PREFERENCES_DIALOG"
|
||||
// yes, there is a typo in this value
|
||||
private const val KEY_SYNCED_FOLDER_INITIATED_PREFIX = "syncedFolderIntitiated_"
|
||||
private val PRIORITIZED_FOLDERS = arrayOf("Camera", "Screenshots")
|
||||
private val TAG = SyncedFoldersActivity::class.java.simpleName
|
||||
|
||||
/**
|
||||
* Sorts list of [SyncedFolderDisplayItem]s.
|
||||
*
|
||||
* @param syncFolderItemList list of items to be sorted
|
||||
* @return sorted list of items
|
||||
*/
|
||||
@JvmStatic
|
||||
@Suppress("ComplexMethod")
|
||||
fun sortSyncedFolderItems(syncFolderItemList: List<SyncedFolderDisplayItem?>): List<SyncedFolderDisplayItem?> {
|
||||
return syncFolderItemList.sortedWith { f1, f2 ->
|
||||
if (f1 == null && f2 == null) {
|
||||
0
|
||||
} else if (f1 == null) {
|
||||
-1
|
||||
} else if (f2 == null) {
|
||||
1
|
||||
} else if (f1.isEnabled && f2.isEnabled) {
|
||||
when {
|
||||
f1.folderName == null -> -1
|
||||
f2.folderName == null -> 1
|
||||
else -> f1.folderName.lowercase(Locale.getDefault()).compareTo(
|
||||
f2.folderName.lowercase(Locale.getDefault())
|
||||
)
|
||||
}
|
||||
} else if (f1.folderName == null && f2.folderName == null) {
|
||||
0
|
||||
} else if (f1.isEnabled) {
|
||||
-1
|
||||
} else if (f2.isEnabled) {
|
||||
1
|
||||
} else if (f1.folderName == null) {
|
||||
-1
|
||||
} else if (f2.folderName == null) {
|
||||
1
|
||||
} else {
|
||||
for (folder in PRIORITIZED_FOLDERS) {
|
||||
if (folder == f1.folderName && folder == f2.folderName) {
|
||||
return@sortedWith 0
|
||||
} else if (folder == f1.folderName) {
|
||||
return@sortedWith -1
|
||||
} else if (folder == f2.folderName) {
|
||||
return@sortedWith 1
|
||||
}
|
||||
}
|
||||
f1.folderName.lowercase(Locale.getDefault()).compareTo(
|
||||
f2.folderName.lowercase(Locale.getDefault())
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var preferences: AppPreferences
|
||||
|
||||
@Inject
|
||||
lateinit var powerManagementService: PowerManagementService
|
||||
|
||||
@Inject
|
||||
lateinit var clock: Clock
|
||||
|
||||
@Inject
|
||||
lateinit var backgroundJobManager: BackgroundJobManager
|
||||
|
||||
private lateinit var binding: SyncedFoldersLayoutBinding
|
||||
private lateinit var adapter: SyncedFolderAdapter
|
||||
private lateinit var syncedFolderProvider: SyncedFolderProvider
|
||||
|
||||
private var syncedFolderPreferencesDialogFragment: SyncedFolderPreferencesDialogFragment? = null
|
||||
private var path: String? = null
|
||||
private var type = 0
|
||||
private var loadJob: Job? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = SyncedFoldersLayoutBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
if (intent != null && intent.extras != null) {
|
||||
val accountName = intent.extras!!.getString(NotificationWork.KEY_NOTIFICATION_ACCOUNT)
|
||||
val optionalUser = user
|
||||
if (optionalUser.isPresent && accountName != null) {
|
||||
val user = optionalUser.get()
|
||||
if (!accountName.equals(user.accountName, ignoreCase = true)) {
|
||||
accountManager.setCurrentOwnCloudAccount(accountName)
|
||||
setUser(userAccountManager.user)
|
||||
}
|
||||
}
|
||||
path = intent.getStringExtra(MediaFoldersDetectionWork.KEY_MEDIA_FOLDER_PATH)
|
||||
type = intent.getIntExtra(MediaFoldersDetectionWork.KEY_MEDIA_FOLDER_TYPE, -1)
|
||||
|
||||
// Cancel notification
|
||||
val notificationId = intent.getIntExtra(MediaFoldersDetectionWork.NOTIFICATION_ID, 0)
|
||||
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
notificationManager.cancel(notificationId)
|
||||
}
|
||||
|
||||
// setup toolbar
|
||||
setupToolbar()
|
||||
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_synced_folders))
|
||||
setupDrawer()
|
||||
setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
|
||||
}
|
||||
if (mDrawerToggle != null) {
|
||||
mDrawerToggle.isDrawerIndicatorEnabled = false
|
||||
}
|
||||
|
||||
setupContent()
|
||||
if (ThemeUtils.themingEnabled(this)) {
|
||||
setTheme(R.style.FallbackThemingTheme)
|
||||
}
|
||||
binding.emptyList.emptyListViewAction.setOnClickListener { showHiddenItems() }
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
val inflater = menuInflater
|
||||
inflater.inflate(R.menu.activity_synced_folders, menu)
|
||||
if (powerManagementService.isPowerSavingExclusionAvailable) {
|
||||
val item = menu.findItem(R.id.action_disable_power_save_check)
|
||||
item.isVisible = true
|
||||
item.isChecked = preferences.isPowerCheckDisabled
|
||||
item.setOnMenuItemClickListener { powerCheck -> onDisablePowerSaveCheckClicked(powerCheck) }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun onDisablePowerSaveCheckClicked(powerCheck: MenuItem): Boolean {
|
||||
if (!powerCheck.isChecked) {
|
||||
showPowerCheckDialog()
|
||||
}
|
||||
preferences.isPowerCheckDisabled = !powerCheck.isChecked
|
||||
powerCheck.isChecked = !powerCheck.isChecked
|
||||
return true
|
||||
}
|
||||
|
||||
private fun showPowerCheckDialog() {
|
||||
val alertDialog = AlertDialog.Builder(this)
|
||||
.setView(findViewById(R.id.root_layout))
|
||||
.setPositiveButton(R.string.common_ok) { dialog, _ -> dialog.dismiss() }
|
||||
.setTitle(R.string.autoupload_disable_power_save_check)
|
||||
.setMessage(getString(R.string.power_save_check_dialog_message))
|
||||
.show()
|
||||
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE))
|
||||
}
|
||||
|
||||
/**
|
||||
* sets up the UI elements and loads all media/synced folders.
|
||||
*/
|
||||
private fun setupContent() {
|
||||
val gridWidth = resources.getInteger(R.integer.media_grid_width)
|
||||
val lightVersion = resources.getBoolean(R.bool.syncedFolder_light)
|
||||
adapter = SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion)
|
||||
syncedFolderProvider = SyncedFolderProvider(contentResolver, preferences, clock)
|
||||
binding.emptyList.emptyListIcon.setImageResource(R.drawable.nav_synced_folders)
|
||||
ThemeButtonUtils.colorPrimaryButton(binding.emptyList.emptyListViewAction, this)
|
||||
val lm = GridLayoutManager(this, gridWidth)
|
||||
adapter.setLayoutManager(lm)
|
||||
val spacing = resources.getDimensionPixelSize(R.dimen.media_grid_spacing)
|
||||
binding.list.addItemDecoration(MediaGridItemDecoration(spacing))
|
||||
binding.list.layoutManager = lm
|
||||
binding.list.adapter = adapter
|
||||
load(getItemsDisplayedPerFolder(), false)
|
||||
}
|
||||
|
||||
private fun showHiddenItems() {
|
||||
if (adapter.sectionCount == 0 && adapter.unfilteredSectionCount > adapter.sectionCount) {
|
||||
adapter.toggleHiddenItemsVisibility()
|
||||
binding.emptyList.emptyListView.visibility = View.GONE
|
||||
binding.list.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loads all media/synced folders, adds them to the recycler view adapter and shows the list.
|
||||
*
|
||||
* @param perFolderMediaItemLimit the amount of media items to be loaded/shown per media folder
|
||||
*/
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun load(perFolderMediaItemLimit: Int, force: Boolean) {
|
||||
if (adapter.itemCount > 0 && !force) {
|
||||
return
|
||||
}
|
||||
showLoadingContent()
|
||||
loadJob = CoroutineScope(Dispatchers.IO).launch {
|
||||
loadJob?.cancel()
|
||||
val mediaFolders = MediaProvider.getImageFolders(
|
||||
contentResolver,
|
||||
perFolderMediaItemLimit, this@SyncedFoldersActivity, false
|
||||
)
|
||||
mediaFolders.addAll(
|
||||
MediaProvider.getVideoFolders(
|
||||
contentResolver, perFolderMediaItemLimit,
|
||||
this@SyncedFoldersActivity, false
|
||||
)
|
||||
)
|
||||
val syncedFolderArrayList = syncedFolderProvider.syncedFolders
|
||||
val currentAccountSyncedFoldersList: MutableList<SyncedFolder> = ArrayList()
|
||||
val user = userAccountManager.user
|
||||
for (syncedFolder in syncedFolderArrayList) {
|
||||
if (syncedFolder.account == user.accountName) {
|
||||
// delete non-existing & disabled synced folders
|
||||
if (!File(syncedFolder.localPath).exists() && !syncedFolder.isEnabled) {
|
||||
syncedFolderProvider.deleteSyncedFolder(syncedFolder.id)
|
||||
} else {
|
||||
currentAccountSyncedFoldersList.add(syncedFolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
val syncFolderItems = sortSyncedFolderItems(
|
||||
mergeFolderData(currentAccountSyncedFoldersList, mediaFolders)
|
||||
)
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
adapter.setSyncFolderItems(syncFolderItems)
|
||||
adapter.notifyDataSetChanged()
|
||||
showList()
|
||||
if (!TextUtils.isEmpty(path)) {
|
||||
val section = adapter.getSectionByLocalPathAndType(path, type)
|
||||
if (section >= 0) {
|
||||
onSyncFolderSettingsClick(section, adapter[section])
|
||||
}
|
||||
}
|
||||
loadJob = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
loadJob?.cancel()
|
||||
}
|
||||
|
||||
/**
|
||||
* merges two lists of [SyncedFolder] and [MediaFolder] items into one of SyncedFolderItems.
|
||||
*
|
||||
* @param syncedFolders the synced folders
|
||||
* @param mediaFolders the media folders
|
||||
* @return the merged list of SyncedFolderItems
|
||||
*/
|
||||
private fun mergeFolderData(
|
||||
syncedFolders: List<SyncedFolder>,
|
||||
mediaFolders: List<MediaFolder>
|
||||
): List<SyncedFolderDisplayItem?> {
|
||||
val syncedFoldersMap = createSyncedFoldersMap(syncedFolders)
|
||||
val result: MutableList<SyncedFolderDisplayItem?> = ArrayList()
|
||||
for (mediaFolder in mediaFolders) {
|
||||
if (syncedFoldersMap.containsKey(mediaFolder.absolutePath + "-" + mediaFolder.type)) {
|
||||
val syncedFolder = syncedFoldersMap[mediaFolder.absolutePath + "-" + mediaFolder.type]
|
||||
syncedFoldersMap.remove(mediaFolder.absolutePath + "-" + mediaFolder.type)
|
||||
if (syncedFolder != null && SyncedFolderUtils.isQualifyingMediaFolder(syncedFolder)) {
|
||||
if (MediaFolderType.CUSTOM == syncedFolder.type) {
|
||||
result.add(createSyncedFolderWithoutMediaFolder(syncedFolder))
|
||||
} else {
|
||||
result.add(createSyncedFolder(syncedFolder, mediaFolder))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (SyncedFolderUtils.isQualifyingMediaFolder(mediaFolder)) {
|
||||
result.add(createSyncedFolderFromMediaFolder(mediaFolder))
|
||||
}
|
||||
}
|
||||
}
|
||||
for (syncedFolder in syncedFoldersMap.values) {
|
||||
result.add(createSyncedFolderWithoutMediaFolder(syncedFolder))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun createSyncedFolderWithoutMediaFolder(syncedFolder: SyncedFolder): SyncedFolderDisplayItem {
|
||||
val localFolder = File(syncedFolder.localPath)
|
||||
val files = SyncedFolderUtils.getFileList(localFolder)
|
||||
val filePaths = getDisplayFilePathList(files.toList())
|
||||
return SyncedFolderDisplayItem(
|
||||
syncedFolder.id,
|
||||
syncedFolder.localPath,
|
||||
syncedFolder.remotePath,
|
||||
syncedFolder.isWifiOnly,
|
||||
syncedFolder.isChargingOnly,
|
||||
syncedFolder.isExisting,
|
||||
syncedFolder.isSubfolderByDate,
|
||||
syncedFolder.account,
|
||||
syncedFolder.uploadAction,
|
||||
syncedFolder.nameCollisionPolicyInt,
|
||||
syncedFolder.isEnabled,
|
||||
clock.currentTime,
|
||||
filePaths,
|
||||
localFolder.name,
|
||||
files.size.toLong(),
|
||||
syncedFolder.type,
|
||||
syncedFolder.isHidden
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a SyncedFolderDisplayItem merging a [SyncedFolder] and a [MediaFolder] object instance.
|
||||
*
|
||||
* @param syncedFolder the synced folder object
|
||||
* @param mediaFolder the media folder object
|
||||
* @return the created SyncedFolderDisplayItem
|
||||
*/
|
||||
private fun createSyncedFolder(syncedFolder: SyncedFolder, mediaFolder: MediaFolder): SyncedFolderDisplayItem {
|
||||
return SyncedFolderDisplayItem(
|
||||
syncedFolder.id,
|
||||
syncedFolder.localPath,
|
||||
syncedFolder.remotePath,
|
||||
syncedFolder.isWifiOnly,
|
||||
syncedFolder.isChargingOnly,
|
||||
syncedFolder.isExisting,
|
||||
syncedFolder.isSubfolderByDate,
|
||||
syncedFolder.account,
|
||||
syncedFolder.uploadAction,
|
||||
syncedFolder.nameCollisionPolicyInt,
|
||||
syncedFolder.isEnabled,
|
||||
clock.currentTime,
|
||||
mediaFolder.filePaths,
|
||||
mediaFolder.folderName,
|
||||
mediaFolder.numberOfFiles,
|
||||
mediaFolder.type,
|
||||
syncedFolder.isHidden
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a [SyncedFolderDisplayItem] based on a [MediaFolder] object instance.
|
||||
*
|
||||
* @param mediaFolder the media folder object
|
||||
* @return the created SyncedFolderDisplayItem
|
||||
*/
|
||||
private fun createSyncedFolderFromMediaFolder(mediaFolder: MediaFolder): SyncedFolderDisplayItem {
|
||||
return SyncedFolderDisplayItem(
|
||||
SyncedFolder.UNPERSISTED_ID,
|
||||
mediaFolder.absolutePath,
|
||||
getString(R.string.instant_upload_path) + "/" + mediaFolder.folderName,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
account.name,
|
||||
FileUploader.LOCAL_BEHAVIOUR_FORGET,
|
||||
NameCollisionPolicy.ASK_USER.serialize(),
|
||||
false,
|
||||
clock.currentTime,
|
||||
mediaFolder.filePaths,
|
||||
mediaFolder.folderName,
|
||||
mediaFolder.numberOfFiles,
|
||||
mediaFolder.type,
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
private fun getItemsDisplayedPerFolder(): Int {
|
||||
return resources.getInteger(R.integer.media_grid_width) * 2
|
||||
}
|
||||
|
||||
private fun getDisplayFilePathList(files: List<File>?): List<String>? {
|
||||
if (!files.isNullOrEmpty()) {
|
||||
return files.take(getItemsDisplayedPerFolder())
|
||||
.map { it.absolutePath }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a lookup map for a list of given [SyncedFolder]s with their local path as the key.
|
||||
*
|
||||
* @param syncFolders list of [SyncedFolder]s
|
||||
* @return the lookup map for [SyncedFolder]s
|
||||
*/
|
||||
private fun createSyncedFoldersMap(syncFolders: List<SyncedFolder>?): MutableMap<String, SyncedFolder> {
|
||||
val result: MutableMap<String, SyncedFolder> = HashMap()
|
||||
if (syncFolders != null) {
|
||||
for (syncFolder in syncFolders) {
|
||||
result[syncFolder.localPath + "-" + syncFolder.type] = syncFolder
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* show recycler view list or the empty message info (in case list is empty).
|
||||
*/
|
||||
private fun showList() {
|
||||
binding.list.visibility = View.VISIBLE
|
||||
binding.loadingContent.visibility = View.GONE
|
||||
checkAndShowEmptyListContent()
|
||||
}
|
||||
|
||||
private fun checkAndShowEmptyListContent() {
|
||||
if (adapter.sectionCount == 0 && adapter.unfilteredSectionCount > adapter.sectionCount) {
|
||||
binding.emptyList.emptyListView.visibility = View.VISIBLE
|
||||
val hiddenFoldersCount = adapter.hiddenFolderCount
|
||||
showEmptyContent(
|
||||
getString(R.string.drawer_synced_folders),
|
||||
resources.getQuantityString(
|
||||
R.plurals.synced_folders_show_hidden_folders,
|
||||
hiddenFoldersCount,
|
||||
hiddenFoldersCount
|
||||
),
|
||||
resources.getQuantityString(
|
||||
R.plurals.synced_folders_show_hidden_folders,
|
||||
hiddenFoldersCount,
|
||||
hiddenFoldersCount
|
||||
)
|
||||
)
|
||||
} else if (adapter.sectionCount == 0 && adapter.unfilteredSectionCount == 0) {
|
||||
binding.emptyList.emptyListView.visibility = View.VISIBLE
|
||||
showEmptyContent(
|
||||
getString(R.string.drawer_synced_folders),
|
||||
getString(R.string.synced_folders_no_results)
|
||||
)
|
||||
} else {
|
||||
binding.emptyList.emptyListView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
var result = true
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> finish()
|
||||
R.id.action_create_custom_folder -> {
|
||||
Log.d(TAG, "Show custom folder dialog")
|
||||
val emptyCustomFolder = SyncedFolderDisplayItem(
|
||||
SyncedFolder.UNPERSISTED_ID,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
account.name,
|
||||
FileUploader.LOCAL_BEHAVIOUR_FORGET,
|
||||
NameCollisionPolicy.ASK_USER.serialize(),
|
||||
false,
|
||||
clock.currentTime,
|
||||
null,
|
||||
MediaFolderType.CUSTOM,
|
||||
false
|
||||
)
|
||||
onSyncFolderSettingsClick(0, emptyCustomFolder)
|
||||
result = super.onOptionsItemSelected(item)
|
||||
}
|
||||
else -> result = super.onOptionsItemSelected(item)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun onSyncStatusToggleClick(section: Int, syncedFolderDisplayItem: SyncedFolderDisplayItem) {
|
||||
if (syncedFolderDisplayItem.id > SyncedFolder.UNPERSISTED_ID) {
|
||||
syncedFolderProvider.updateSyncedFolderEnabled(
|
||||
syncedFolderDisplayItem.id,
|
||||
syncedFolderDisplayItem.isEnabled
|
||||
)
|
||||
} else {
|
||||
val storedId = syncedFolderProvider.storeSyncedFolder(syncedFolderDisplayItem)
|
||||
if (storedId != -1L) {
|
||||
syncedFolderDisplayItem.id = storedId
|
||||
}
|
||||
}
|
||||
if (syncedFolderDisplayItem.isEnabled) {
|
||||
backgroundJobManager.startImmediateFilesSyncJob(skipCustomFolders = false, overridePowerSaving = false)
|
||||
showBatteryOptimizationInfo()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSyncFolderSettingsClick(section: Int, syncedFolderDisplayItem: SyncedFolderDisplayItem) {
|
||||
val fm = supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
syncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(
|
||||
syncedFolderDisplayItem, section
|
||||
).also {
|
||||
it.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVisibilityToggleClick(section: Int, syncedFolder: SyncedFolderDisplayItem) {
|
||||
syncedFolder.isHidden = !syncedFolder.isHidden
|
||||
saveOrUpdateSyncedFolder(syncedFolder)
|
||||
adapter.setSyncFolderItem(section, syncedFolder)
|
||||
checkAndShowEmptyListContent()
|
||||
}
|
||||
|
||||
private fun showEmptyContent(headline: String, message: String, action: String) {
|
||||
showEmptyContent(headline, message)
|
||||
binding.emptyList.emptyListViewAction.text = action
|
||||
binding.emptyList.emptyListViewAction.visibility = View.VISIBLE
|
||||
binding.emptyList.emptyListViewText.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun showLoadingContent() {
|
||||
binding.loadingContent.visibility = View.VISIBLE
|
||||
binding.emptyList.emptyListViewAction.visibility = View.GONE
|
||||
}
|
||||
|
||||
private fun showEmptyContent(headline: String, message: String) {
|
||||
binding.emptyList.emptyListViewAction.visibility = View.GONE
|
||||
binding.emptyList.emptyListView.visibility = View.VISIBLE
|
||||
binding.list.visibility = View.GONE
|
||||
binding.loadingContent.visibility = View.GONE
|
||||
binding.emptyList.emptyListViewHeadline.text = headline
|
||||
binding.emptyList.emptyListViewText.text = message
|
||||
binding.emptyList.emptyListViewText.visibility = View.VISIBLE
|
||||
binding.emptyList.emptyListIcon.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_REMOTE_FOLDER &&
|
||||
resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null
|
||||
) {
|
||||
val chosenFolder: OCFile = data!!.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER)!!
|
||||
syncedFolderPreferencesDialogFragment!!.setRemoteFolderSummary(chosenFolder.remotePath)
|
||||
} else if (
|
||||
requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_LOCAL_FOLDER &&
|
||||
resultCode == RESULT_OK && syncedFolderPreferencesDialogFragment != null
|
||||
) {
|
||||
val localPath = data!!.getStringExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES)
|
||||
syncedFolderPreferencesDialogFragment!!.setLocalFolderSummary(localPath)
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveSyncedFolderPreference(syncedFolder: SyncedFolderParcelable) {
|
||||
// custom folders newly created aren't in the list already,
|
||||
// so triggering a refresh
|
||||
if (MediaFolderType.CUSTOM == syncedFolder.type && syncedFolder.id == SyncedFolder.UNPERSISTED_ID) {
|
||||
val newCustomFolder = SyncedFolderDisplayItem(
|
||||
SyncedFolder.UNPERSISTED_ID,
|
||||
syncedFolder.localPath,
|
||||
syncedFolder.remotePath,
|
||||
syncedFolder.isWifiOnly,
|
||||
syncedFolder.isChargingOnly,
|
||||
syncedFolder.isExisting,
|
||||
syncedFolder.isSubfolderByDate,
|
||||
syncedFolder.account,
|
||||
syncedFolder.uploadAction,
|
||||
syncedFolder.nameCollisionPolicy.serialize(),
|
||||
syncedFolder.isEnabled,
|
||||
clock.currentTime,
|
||||
File(syncedFolder.localPath).name,
|
||||
syncedFolder.type,
|
||||
syncedFolder.isHidden
|
||||
)
|
||||
saveOrUpdateSyncedFolder(newCustomFolder)
|
||||
adapter.addSyncFolderItem(newCustomFolder)
|
||||
} else {
|
||||
val item = adapter[syncedFolder.section]
|
||||
updateSyncedFolderItem(
|
||||
item,
|
||||
syncedFolder.id,
|
||||
syncedFolder.localPath,
|
||||
syncedFolder.remotePath,
|
||||
syncedFolder.isWifiOnly,
|
||||
syncedFolder.isChargingOnly,
|
||||
syncedFolder.isExisting,
|
||||
syncedFolder.isSubfolderByDate,
|
||||
syncedFolder.uploadAction,
|
||||
syncedFolder.nameCollisionPolicy.serialize(),
|
||||
syncedFolder.isEnabled
|
||||
)
|
||||
saveOrUpdateSyncedFolder(item)
|
||||
|
||||
// TODO test if notifyItemChanged is sufficient (should improve performance)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
syncedFolderPreferencesDialogFragment = null
|
||||
if (syncedFolder.isEnabled) {
|
||||
showBatteryOptimizationInfo()
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveOrUpdateSyncedFolder(item: SyncedFolderDisplayItem) {
|
||||
if (item.id == SyncedFolder.UNPERSISTED_ID) {
|
||||
// newly set up folder sync config
|
||||
storeSyncedFolder(item)
|
||||
} else {
|
||||
// existing synced folder setup to be updated
|
||||
syncedFolderProvider.updateSyncFolder(item)
|
||||
if (item.isEnabled) {
|
||||
backgroundJobManager.startImmediateFilesSyncJob(skipCustomFolders = false, overridePowerSaving = false)
|
||||
} else {
|
||||
val syncedFolderInitiatedKey = KEY_SYNCED_FOLDER_INITIATED_PREFIX + item.id
|
||||
val arbitraryDataProvider = ArbitraryDataProvider(MainApp.getAppContext().contentResolver)
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun storeSyncedFolder(item: SyncedFolderDisplayItem) {
|
||||
val arbitraryDataProvider = ArbitraryDataProvider(MainApp.getAppContext().contentResolver)
|
||||
val storedId = syncedFolderProvider.storeSyncedFolder(item)
|
||||
if (storedId != -1L) {
|
||||
item.id = storedId
|
||||
if (item.isEnabled) {
|
||||
backgroundJobManager.startImmediateFilesSyncJob(skipCustomFolders = false, overridePowerSaving = false)
|
||||
} else {
|
||||
val syncedFolderInitiatedKey = KEY_SYNCED_FOLDER_INITIATED_PREFIX + item.id
|
||||
arbitraryDataProvider.deleteKeyForAccount("global", syncedFolderInitiatedKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCancelSyncedFolderPreference() {
|
||||
syncedFolderPreferencesDialogFragment = null
|
||||
}
|
||||
|
||||
override fun onDeleteSyncedFolderPreference(syncedFolder: SyncedFolderParcelable) {
|
||||
syncedFolderProvider.deleteSyncedFolder(syncedFolder.id)
|
||||
adapter.removeItem(syncedFolder.section)
|
||||
}
|
||||
|
||||
/**
|
||||
* update given synced folder with the given values.
|
||||
*
|
||||
* @param item the synced folder to be updated
|
||||
* @param localPath the local path
|
||||
* @param remotePath the remote path
|
||||
* @param wifiOnly upload on wifi only
|
||||
* @param chargingOnly upload on charging only
|
||||
* @param existing also upload existing
|
||||
* @param subfolderByDate created sub folders
|
||||
* @param uploadAction upload action
|
||||
* @param nameCollisionPolicy what to do on name collision
|
||||
* @param enabled is sync enabled
|
||||
*/
|
||||
@Suppress("LongParameterList")
|
||||
private fun updateSyncedFolderItem(
|
||||
item: SyncedFolderDisplayItem,
|
||||
id: Long,
|
||||
localPath: String,
|
||||
remotePath: String,
|
||||
wifiOnly: Boolean,
|
||||
chargingOnly: Boolean,
|
||||
existing: Boolean,
|
||||
subfolderByDate: Boolean,
|
||||
uploadAction: Int,
|
||||
nameCollisionPolicy: Int,
|
||||
enabled: Boolean
|
||||
) {
|
||||
item.id = id
|
||||
item.localPath = localPath
|
||||
item.remotePath = remotePath
|
||||
item.isWifiOnly = wifiOnly
|
||||
item.isChargingOnly = chargingOnly
|
||||
item.isExisting = existing
|
||||
item.isSubfolderByDate = subfolderByDate
|
||||
item.uploadAction = uploadAction
|
||||
item.setNameCollisionPolicy(nameCollisionPolicy)
|
||||
item.setEnabled(enabled, clock.currentTime)
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(
|
||||
requestCode: Int,
|
||||
permissions: Array<String>,
|
||||
grantResults: IntArray
|
||||
) {
|
||||
when (requestCode) {
|
||||
PermissionUtil.PERMISSIONS_EXTERNAL_STORAGE -> {
|
||||
|
||||
// If request is cancelled, result arrays are empty.
|
||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// permission was granted
|
||||
|
||||
load(getItemsDisplayedPerFolder(), true)
|
||||
} else {
|
||||
// permission denied --> do nothing
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
else -> super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showBatteryOptimizationInfo() {
|
||||
if (powerManagementService.isPowerSavingExclusionAvailable || checkIfBatteryOptimizationEnabled()) {
|
||||
val alertDialogBuilder = AlertDialog.Builder(this, R.style.Theme_ownCloud_Dialog)
|
||||
.setTitle(getString(R.string.battery_optimization_title))
|
||||
.setMessage(getString(R.string.battery_optimization_message))
|
||||
.setPositiveButton(getString(R.string.battery_optimization_disable)) { _, _ ->
|
||||
// show instant upload
|
||||
@SuppressLint("BatteryLife") val intent = Intent(
|
||||
Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,
|
||||
Uri.parse("package:" + BuildConfig.APPLICATION_ID)
|
||||
)
|
||||
if (intent.resolveActivity(packageManager) != null) {
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
.setNeutralButton(getString(R.string.battery_optimization_close)) { dialog, _ -> dialog.dismiss() }
|
||||
.setIcon(R.drawable.ic_battery_alert)
|
||||
if (lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
val alertDialog = alertDialogBuilder.show()
|
||||
ThemeButtonUtils.themeBorderlessButton(
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if battery optimization is enabled. If unknown, fallback to true.
|
||||
*
|
||||
* @return true if battery optimization is enabled
|
||||
*/
|
||||
private fun checkIfBatteryOptimizationEnabled(): Boolean {
|
||||
val powerManager = getSystemService(POWER_SERVICE) as PowerManager?
|
||||
return when {
|
||||
powerManager != null -> !powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,201 +0,0 @@
|
||||
/*
|
||||
* 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.asynctasks;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.ui.fragment.GalleryFragment;
|
||||
import com.owncloud.android.ui.fragment.SearchType;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class GallerySearchTask extends AsyncTask<Void, Void, GallerySearchTask.Result> {
|
||||
|
||||
private final User user;
|
||||
private final WeakReference<GalleryFragment> photoFragmentWeakReference;
|
||||
private final FileDataStorageManager storageManager;
|
||||
private final int limit;
|
||||
private final long startDate;
|
||||
private final long endDate;
|
||||
|
||||
public GallerySearchTask(GalleryFragment photoFragment,
|
||||
User user,
|
||||
FileDataStorageManager storageManager,
|
||||
long startDate,
|
||||
long endDate,
|
||||
int limit) {
|
||||
this.user = user;
|
||||
this.photoFragmentWeakReference = new WeakReference<>(photoFragment);
|
||||
this.storageManager = storageManager;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GallerySearchTask.Result doInBackground(Void... voids) {
|
||||
if (photoFragmentWeakReference.get() == null) {
|
||||
return new Result(false, false, -1);
|
||||
}
|
||||
GalleryFragment photoFragment = photoFragmentWeakReference.get();
|
||||
|
||||
if (isCancelled()) {
|
||||
return new Result(false, false, -1);
|
||||
} else {
|
||||
OCCapability ocCapability = storageManager.getCapability(user.getAccountName());
|
||||
|
||||
SearchRemoteOperation searchRemoteOperation = new SearchRemoteOperation("",
|
||||
SearchRemoteOperation.SearchType.GALLERY_SEARCH,
|
||||
false,
|
||||
ocCapability);
|
||||
|
||||
|
||||
searchRemoteOperation.setLimit(limit);
|
||||
searchRemoteOperation.setStartDate(startDate);
|
||||
searchRemoteOperation.setEndDate(endDate);
|
||||
|
||||
if (photoFragment.getContext() != null) {
|
||||
Log_OC.d(this,
|
||||
"Start gallery search with " + new Date(startDate * 1000L) +
|
||||
" - " + new Date(endDate * 1000L) +
|
||||
" with limit: " + limit);
|
||||
|
||||
RemoteOperationResult result = searchRemoteOperation.execute(user.toPlatformAccount(),
|
||||
photoFragment.getContext());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(GallerySearchTask.Result result) {
|
||||
if (photoFragmentWeakReference.get() != null) {
|
||||
GalleryFragment photoFragment = photoFragmentWeakReference.get();
|
||||
|
||||
photoFragment.setLoading(false);
|
||||
photoFragment.searchCompleted(result.emptySearch, result.lastTimestamp);
|
||||
|
||||
if (!result.success) {
|
||||
photoFragment.setEmptyListMessage(SearchType.GALLERY_SEARCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long findLastTimestamp(ArrayList<RemoteFile> remoteFiles) {
|
||||
int lastPosition = remoteFiles.size() - 1;
|
||||
|
||||
if (lastPosition < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
RemoteFile lastFile = remoteFiles.get(lastPosition);
|
||||
return lastFile.getModifiedTimestamp() / 1000;
|
||||
}
|
||||
|
||||
private boolean parseMedia(long startDate, long endDate, List<Object> remoteFiles) {
|
||||
// retrieve all between startDate and endDate
|
||||
Map<String, OCFile> localFilesMap = RefreshFolderOperation.prefillLocalFilesMap(null,
|
||||
storageManager.getGalleryItems(startDate * 1000L,
|
||||
endDate * 1000L));
|
||||
List<OCFile> filesToAdd = new ArrayList<>();
|
||||
List<OCFile> filesToUpdate = new ArrayList<>();
|
||||
|
||||
OCFile localFile;
|
||||
for (Object file : remoteFiles) {
|
||||
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) file);
|
||||
|
||||
localFile = localFilesMap.remove(ocFile.getRemotePath());
|
||||
|
||||
if (localFile == null) {
|
||||
// add new file
|
||||
filesToAdd.add(ocFile);
|
||||
} else if (!localFile.getEtag().equals(ocFile.getEtag())) {
|
||||
// update file
|
||||
ocFile.setLastSyncDateForData(System.currentTimeMillis());
|
||||
filesToUpdate.add(ocFile);
|
||||
}
|
||||
}
|
||||
|
||||
// add new files
|
||||
for (OCFile file : filesToAdd) {
|
||||
storageManager.saveFile(file);
|
||||
}
|
||||
|
||||
// update existing files
|
||||
for (OCFile file : filesToUpdate) {
|
||||
storageManager.saveFile(file);
|
||||
}
|
||||
|
||||
// existing files to remove
|
||||
for (OCFile file : localFilesMap.values()) {
|
||||
storageManager.removeFile(file, true, true);
|
||||
}
|
||||
|
||||
Log_OC.d(this, "Gallery search result:" +
|
||||
" new: " + filesToAdd.size() +
|
||||
" updated: " + filesToUpdate.size() +
|
||||
" deleted: " + localFilesMap.size());
|
||||
|
||||
return didNotFindNewResults(filesToAdd, filesToUpdate, localFilesMap.values());
|
||||
}
|
||||
|
||||
private boolean didNotFindNewResults(List<OCFile> filesToAdd,
|
||||
List<OCFile> filesToUpdate,
|
||||
Collection<OCFile> filesToRemove) {
|
||||
return filesToAdd.isEmpty() && filesToUpdate.isEmpty() && filesToRemove.isEmpty();
|
||||
}
|
||||
|
||||
public static class Result {
|
||||
public boolean success;
|
||||
public boolean emptySearch;
|
||||
public long lastTimestamp;
|
||||
|
||||
public Result(boolean success, boolean emptySearch, long lastTimestamp) {
|
||||
this.success = success;
|
||||
this.emptySearch = emptySearch;
|
||||
this.lastTimestamp = lastTimestamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017 Mario Danic
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.ui.events
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
data class SyncEventFinished(val intent: Intent) : Parcelable
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
enum class SearchType : Parcelable {
|
||||
NO_SEARCH,
|
||||
REGULAR_FILTER,
|
||||
FILE_SEARCH,
|
||||
FAVORITE_SEARCH,
|
||||
GALLERY_SEARCH,
|
||||
RECENTLY_MODIFIED_SEARCH,
|
||||
|
||||
// not a real filter, but nevertheless
|
||||
SHARED_FILTER
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* 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.preview
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.owncloud.android.databinding.ActivityPreviewBitmapBinding
|
||||
|
||||
/**
|
||||
* Zoomable preview of a single bitmap
|
||||
*/
|
||||
class PreviewBitmapActivity : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
const val EXTRA_BITMAP_PATH = "EXTRA_BITMAP_PATH"
|
||||
}
|
||||
|
||||
private lateinit var binding: ActivityPreviewBitmapBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityPreviewBitmapBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
setupImage()
|
||||
|
||||
supportActionBar?.let {
|
||||
it.setDisplayHomeAsUpEnabled(true)
|
||||
it.setDisplayShowHomeEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupImage() {
|
||||
val path = intent.getStringExtra(EXTRA_BITMAP_PATH)
|
||||
require(path != null)
|
||||
|
||||
val bitmap = BitmapFactory.decodeFile(path)
|
||||
binding.image.setImageBitmap(bitmap)
|
||||
}
|
||||
|
||||
override fun onSupportNavigateUp(): Boolean {
|
||||
onBackPressed()
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,259 +0,0 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.media.MediaPlayer
|
||||
import android.media.MediaPlayer.OnCompletionListener
|
||||
import android.media.MediaPlayer.OnPreparedListener
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.MediaItem
|
||||
import com.google.android.exoplayer2.Player
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.media.ErrorFormat.toString
|
||||
import com.nextcloud.client.media.NextcloudExoPlayer.createNextcloudExoplayer
|
||||
import com.nextcloud.client.network.ClientFactory
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.ActivityPreviewVideoBinding
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.activity.FileActivity
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Activity implementing a basic video player.
|
||||
*
|
||||
* THIS CLASS NEEDS WORK; the old listeners (OnCompletion, OnPrepared; OnError) don't work with ExoPlayer
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
class PreviewVideoActivity :
|
||||
FileActivity(),
|
||||
OnCompletionListener,
|
||||
OnPreparedListener,
|
||||
MediaPlayer.OnErrorListener,
|
||||
Player.Listener,
|
||||
Injectable {
|
||||
|
||||
@Inject
|
||||
lateinit var clientFactory: ClientFactory
|
||||
|
||||
@Inject
|
||||
lateinit var accountManager: UserAccountManager
|
||||
|
||||
private var mSavedPlaybackPosition: Long = -1 // in the unit time handled by MediaPlayer.getCurrentPosition()
|
||||
private var mAutoplay = false // when 'true', the playback starts immediately with the activity
|
||||
private var exoPlayer: ExoPlayer? = null // view to play the file; both performs and show the playback
|
||||
private var mStreamUri: Uri? = null
|
||||
private lateinit var binding: ActivityPreviewVideoBinding
|
||||
|
||||
private lateinit var pauseButton: View
|
||||
|
||||
private lateinit var playButton: View
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log_OC.v(TAG, "onCreate")
|
||||
|
||||
binding = ActivityPreviewVideoBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
val extras = intent.extras
|
||||
|
||||
if (savedInstanceState == null && extras != null) {
|
||||
mSavedPlaybackPosition = extras.getLong(EXTRA_START_POSITION)
|
||||
mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY)
|
||||
mStreamUri = extras[EXTRA_STREAM_URL] as Uri?
|
||||
} else if (savedInstanceState != null) {
|
||||
mSavedPlaybackPosition = savedInstanceState.getLong(EXTRA_START_POSITION)
|
||||
mAutoplay = savedInstanceState.getBoolean(EXTRA_AUTOPLAY)
|
||||
mStreamUri = savedInstanceState[EXTRA_STREAM_URL] as Uri?
|
||||
}
|
||||
|
||||
supportActionBar?.hide()
|
||||
}
|
||||
|
||||
private fun setupPlayerView() {
|
||||
binding.videoPlayer.player = exoPlayer
|
||||
exoPlayer!!.addListener(this)
|
||||
|
||||
binding.root.findViewById<View>(R.id.exo_exit_fs).setOnClickListener { onBackPressed() }
|
||||
|
||||
pauseButton = binding.root.findViewById(R.id.exo_pause)
|
||||
pauseButton.setOnClickListener { exoPlayer!!.pause() }
|
||||
|
||||
playButton = binding.root.findViewById(R.id.exo_play)
|
||||
playButton.setOnClickListener { exoPlayer!!.play() }
|
||||
|
||||
if (mSavedPlaybackPosition >= 0) {
|
||||
exoPlayer?.seekTo(mSavedPlaybackPosition)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||
super.onIsPlayingChanged(isPlaying)
|
||||
if (isPlaying) {
|
||||
playButton.visibility = View.GONE
|
||||
pauseButton.visibility = View.VISIBLE
|
||||
} else {
|
||||
playButton.visibility = View.VISIBLE
|
||||
pauseButton.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putLong(EXTRA_START_POSITION, currentPosition())
|
||||
outState.putBoolean(EXTRA_AUTOPLAY, isPlaying())
|
||||
outState.putParcelable(EXTRA_STREAM_URL, mStreamUri)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
Log_OC.v(TAG, "onBackPressed")
|
||||
val i = Intent()
|
||||
i.putExtra(EXTRA_AUTOPLAY, isPlaying())
|
||||
i.putExtra(EXTRA_START_POSITION, currentPosition())
|
||||
setResult(RESULT_OK, i)
|
||||
exoPlayer?.stop()
|
||||
exoPlayer?.release()
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
private fun isPlaying() = exoPlayer?.isPlaying ?: false
|
||||
private fun currentPosition() = exoPlayer?.currentPosition ?: 0
|
||||
|
||||
/**
|
||||
* Called when the file is ready to be played.
|
||||
*
|
||||
* Just starts the playback.
|
||||
*
|
||||
* @param mp [MediaPlayer] instance performing the playback.
|
||||
*/
|
||||
override fun onPrepared(mp: MediaPlayer) {
|
||||
Log_OC.v(TAG, "onPrepare")
|
||||
exoPlayer?.seekTo(mSavedPlaybackPosition)
|
||||
if (mAutoplay) {
|
||||
exoPlayer?.play()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the file is finished playing.
|
||||
*
|
||||
* Rewinds the video
|
||||
*
|
||||
* @param mp [MediaPlayer] instance performing the playback.
|
||||
*/
|
||||
override fun onCompletion(mp: MediaPlayer?) {
|
||||
exoPlayer?.seekTo(0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an error in playback occurs.
|
||||
*
|
||||
* @param mp [MediaPlayer] instance performing the playback.
|
||||
* @param what Type of error
|
||||
* @param extra Extra code specific to the error
|
||||
*/
|
||||
override fun onError(mp: MediaPlayer, what: Int, extra: Int): Boolean {
|
||||
Log_OC.e(TAG, "Error in video playback, what = $what, extra = $extra")
|
||||
val message = toString(this, what, extra)
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(android.R.string.VideoView_error_button) { _: DialogInterface?, _: Int ->
|
||||
onCompletion(null)
|
||||
}
|
||||
.setCancelable(false)
|
||||
.show()
|
||||
return true
|
||||
}
|
||||
|
||||
private fun play(item: MediaItem) {
|
||||
exoPlayer?.addMediaItem(item)
|
||||
exoPlayer?.prepare()
|
||||
exoPlayer?.play()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (account != null) {
|
||||
|
||||
require(file != null) { throw IllegalStateException("Instanced with a NULL OCFile") }
|
||||
var fileToPlay: OCFile? = file
|
||||
|
||||
// Validate handled file (first image to preview)
|
||||
require(MimeTypeUtil.isVideo(fileToPlay)) { "Non-video file passed as argument" }
|
||||
|
||||
fileToPlay = storageManager.getFileById(fileToPlay!!.fileId)
|
||||
if (fileToPlay != null) {
|
||||
val mediaItem = when {
|
||||
fileToPlay.isDown -> MediaItem.fromUri(fileToPlay.storageUri)
|
||||
else -> MediaItem.fromUri(mStreamUri!!)
|
||||
}
|
||||
if (exoPlayer != null) {
|
||||
play(mediaItem)
|
||||
} else {
|
||||
val context = this
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val client = clientFactory.createNextcloudClient(accountManager.user)
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
exoPlayer = createNextcloudExoplayer(context, client)
|
||||
setupPlayerView()
|
||||
play(mediaItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
if (exoPlayer?.isPlaying == true) {
|
||||
exoPlayer?.pause()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/** Key to receive a flag signaling if the video should be started immediately */
|
||||
const val EXTRA_AUTOPLAY = "AUTOPLAY"
|
||||
|
||||
/** Key to receive the position of the playback where the video should be put at start */
|
||||
const val EXTRA_START_POSITION = "START_POSITION"
|
||||
const val EXTRA_STREAM_URL = "STREAM_URL"
|
||||
private val TAG = PreviewVideoActivity::class.java.simpleName
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* 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.preview.pdf
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.pdf.PdfRenderer
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.owncloud.android.databinding.PreviewPdfPageItemBinding
|
||||
|
||||
/**
|
||||
* @param renderer an **open** [PdfRenderer]
|
||||
*/
|
||||
class PreviewPdfAdapter(
|
||||
private val renderer: PdfRenderer,
|
||||
private val screenWidth: Int,
|
||||
private val onClickListener: (Bitmap) -> Unit
|
||||
) :
|
||||
RecyclerView.Adapter<PreviewPdfAdapter.ViewHolder>() {
|
||||
|
||||
class ViewHolder(val binding: PreviewPdfPageItemBinding, val onClickListener: (Bitmap) -> Unit) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
fun bind(bitmap: Bitmap) {
|
||||
binding.page.setImageBitmap(bitmap)
|
||||
binding.root.setOnClickListener {
|
||||
onClickListener(bitmap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val binding = PreviewPdfPageItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
return ViewHolder(binding, onClickListener)
|
||||
}
|
||||
|
||||
override fun getItemCount() = renderer.pageCount
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val page = renderer.openPage(position)
|
||||
val bitmap = renderPage(page)
|
||||
holder.bind(bitmap)
|
||||
}
|
||||
|
||||
private fun renderPage(page: PdfRenderer.Page) = page.use {
|
||||
val bitmap = createBitmapForPage(it)
|
||||
page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY)
|
||||
bitmap
|
||||
}
|
||||
|
||||
private fun createBitmapForPage(page: PdfRenderer.Page): Bitmap {
|
||||
val bitmap = Bitmap.createBitmap(
|
||||
screenWidth, (screenWidth.toFloat() / page.width * page.height).toInt(), Bitmap.Config.ARGB_8888
|
||||
)
|
||||
|
||||
val canvas = Canvas(bitmap)
|
||||
canvas.drawColor(Color.WHITE)
|
||||
canvas.drawBitmap(bitmap, 0f, 0f, null)
|
||||
|
||||
return bitmap
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* 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.preview.pdf
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.nextcloud.client.di.Injectable
|
||||
import com.nextcloud.client.di.ViewModelFactory
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.databinding.PreviewPdfFragmentBinding
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.files.FileMenuFilter
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.preview.PreviewBitmapActivity
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import javax.inject.Inject
|
||||
|
||||
class PreviewPdfFragment : Fragment(), Injectable {
|
||||
|
||||
@Inject
|
||||
lateinit var vmFactory: ViewModelFactory
|
||||
|
||||
private lateinit var binding: PreviewPdfFragmentBinding
|
||||
private lateinit var viewModel: PreviewPdfViewModel
|
||||
private lateinit var file: OCFile
|
||||
|
||||
private var snack: Snackbar? = null
|
||||
|
||||
companion object {
|
||||
private const val ARG_FILE = "FILE"
|
||||
|
||||
@JvmStatic
|
||||
fun newInstance(file: OCFile): PreviewPdfFragment = PreviewPdfFragment().apply {
|
||||
arguments = Bundle().apply {
|
||||
putParcelable(ARG_FILE, file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
binding = PreviewPdfFragmentBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
setupObservers()
|
||||
|
||||
file = requireArguments().getParcelable(ARG_FILE)!!
|
||||
viewModel.process(file)
|
||||
}
|
||||
|
||||
private fun setupObservers() {
|
||||
viewModel.pdfRenderer.observe(viewLifecycleOwner) { renderer ->
|
||||
binding.pdfRecycler.adapter = PreviewPdfAdapter(renderer, getScreenWidth()) { page ->
|
||||
viewModel.onClickPage(page)
|
||||
}
|
||||
}
|
||||
viewModel.previewImagePath.observe(viewLifecycleOwner) {
|
||||
it?.let { path ->
|
||||
val intent = Intent(context, PreviewBitmapActivity::class.java).apply {
|
||||
putExtra(PreviewBitmapActivity.EXTRA_BITMAP_PATH, path)
|
||||
}
|
||||
requireContext().startActivity(intent)
|
||||
}
|
||||
}
|
||||
viewModel.shouldShowZoomTip.observe(viewLifecycleOwner) { shouldShow ->
|
||||
if (shouldShow) {
|
||||
snack = DisplayUtils.showSnackMessage(binding.root, R.string.pdf_zoom_tip)
|
||||
viewModel.onZoomTipShown()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
viewModel = ViewModelProvider(this, vmFactory)[PreviewPdfViewModel::class.java]
|
||||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
private fun getScreenWidth(): Int =
|
||||
requireContext().resources.displayMetrics.widthPixels
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||
super.onPrepareOptionsMenu(menu)
|
||||
FileMenuFilter.hideAll(menu)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
val parent = activity
|
||||
if (parent is FileDisplayActivity) {
|
||||
parent.showSortListGroup(false)
|
||||
parent.updateActionBarTitleAndHomeButton(file)
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
fun dismissSnack() {
|
||||
snack?.dismiss()
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* 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.preview.pdf
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.pdf.PdfRenderer
|
||||
import android.os.ParcelFileDescriptor
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import javax.inject.Inject
|
||||
|
||||
class PreviewPdfViewModel @Inject constructor(val appPreferences: AppPreferences) : ViewModel() {
|
||||
|
||||
companion object {
|
||||
private const val SHOW_ZOOM_TIP_TIMES = 3
|
||||
}
|
||||
|
||||
private var _pdfRenderer = MutableLiveData<PdfRenderer>()
|
||||
val pdfRenderer: LiveData<PdfRenderer>
|
||||
get() = _pdfRenderer
|
||||
|
||||
private var _previewImagePath = MutableLiveData<String>()
|
||||
val previewImagePath: LiveData<String>
|
||||
get() = _previewImagePath
|
||||
|
||||
private var _showZoomTip = MutableLiveData<Boolean>()
|
||||
val shouldShowZoomTip: LiveData<Boolean>
|
||||
get() = _showZoomTip
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
closeRenderer()
|
||||
}
|
||||
|
||||
private fun closeRenderer() {
|
||||
try {
|
||||
_pdfRenderer.value?.close()
|
||||
} catch (e: IllegalStateException) {
|
||||
Log_OC.e(this, "closeRenderer: trying to close already closed renderer", e)
|
||||
}
|
||||
}
|
||||
|
||||
fun process(file: OCFile) {
|
||||
closeRenderer()
|
||||
_pdfRenderer.value =
|
||||
PdfRenderer(ParcelFileDescriptor.open(File(file.storagePath), ParcelFileDescriptor.MODE_READ_ONLY))
|
||||
if (appPreferences.pdfZoomTipShownCount < SHOW_ZOOM_TIP_TIMES) {
|
||||
_showZoomTip.value = true
|
||||
}
|
||||
}
|
||||
|
||||
fun onClickPage(page: Bitmap) {
|
||||
val file = File.createTempFile("pdf_page", ".bmp", MainApp.getAppContext().cacheDir)
|
||||
val outStream = FileOutputStream(file)
|
||||
page.compress(Bitmap.CompressFormat.PNG, 0, outStream)
|
||||
outStream.close()
|
||||
|
||||
_previewImagePath.value = file.path
|
||||
}
|
||||
|
||||
fun onZoomTipShown() {
|
||||
appPreferences.pdfZoomTipShownCount++
|
||||
_showZoomTip.value = false
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import java.io.File
|
||||
import java.util.Collections
|
||||
|
||||
/**
|
||||
* Sort order
|
||||
*/
|
||||
open class FileSortOrder(@JvmField var name: String, var isAscending: Boolean) {
|
||||
|
||||
val sortMultiplier: Int
|
||||
get() = if (isAscending) 1 else -1
|
||||
|
||||
@Suppress("EnumNaming") // already saved in user preferences -.-'
|
||||
enum class Type {
|
||||
trashBinView, localFileListView
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val sort_a_to_z_id = "sort_a_to_z"
|
||||
const val sort_z_to_a_id = "sort_z_to_a"
|
||||
const val sort_old_to_new_id = "sort_old_to_new"
|
||||
const val sort_new_to_old_id = "sort_new_to_old"
|
||||
const val sort_small_to_big_id = "sort_small_to_big"
|
||||
const val sort_big_to_small_id = "sort_big_to_small"
|
||||
|
||||
@JvmField
|
||||
val sort_a_to_z: FileSortOrder = FileSortOrderByName(sort_a_to_z_id, true)
|
||||
|
||||
@JvmField
|
||||
val sort_z_to_a: FileSortOrder = FileSortOrderByName(sort_z_to_a_id, false)
|
||||
|
||||
@JvmField
|
||||
val sort_old_to_new: FileSortOrder = FileSortOrderByDate(sort_old_to_new_id, true)
|
||||
|
||||
@JvmField
|
||||
val sort_new_to_old: FileSortOrder = FileSortOrderByDate(sort_new_to_old_id, false)
|
||||
|
||||
@JvmField
|
||||
val sort_small_to_big: FileSortOrder = FileSortOrderBySize(sort_small_to_big_id, true)
|
||||
|
||||
@JvmField
|
||||
val sort_big_to_small: FileSortOrder = FileSortOrderBySize(sort_big_to_small_id, false)
|
||||
|
||||
@JvmField
|
||||
val sortOrders: Map<String, FileSortOrder> = Collections.unmodifiableMap(
|
||||
mapOf(
|
||||
sort_a_to_z.name to sort_a_to_z,
|
||||
sort_z_to_a.name to sort_z_to_a,
|
||||
sort_old_to_new.name to sort_old_to_new,
|
||||
sort_new_to_old.name to sort_new_to_old,
|
||||
sort_small_to_big.name to sort_small_to_big,
|
||||
sort_big_to_small.name to sort_big_to_small
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Sorts list by Favourites.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
@JvmStatic
|
||||
fun sortCloudFilesByFavourite(files: MutableList<OCFile>): List<OCFile> {
|
||||
files.sortWith { o1: OCFile, o2: OCFile ->
|
||||
when {
|
||||
o1.isFavorite && o2.isFavorite -> 0
|
||||
o1.isFavorite -> -1
|
||||
o2.isFavorite -> 1
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
|
||||
open fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
return sortCloudFilesByFavourite(files)
|
||||
}
|
||||
|
||||
open fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
return files
|
||||
}
|
||||
|
||||
open fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Created by srkunze on 28.08.17.
|
||||
*/
|
||||
class FileSortOrderByDate(name: String, ascending: Boolean) : FileSortOrder(name, ascending) {
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
override fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
val multiplier = if (isAscending) 1 else -1
|
||||
files.sortWith { o1: OCFile, o2: OCFile ->
|
||||
multiplier * o1.modificationTimestamp.compareTo(o2.modificationTimestamp)
|
||||
}
|
||||
return super.sortCloudFiles(files)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
override fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
val multiplier = if (isAscending) 1 else -1
|
||||
files.sortWith { o1: TrashbinFile, o2: TrashbinFile ->
|
||||
multiplier * o1.deletionTimestamp.compareTo(o2.deletionTimestamp)
|
||||
}
|
||||
return super.sortTrashbinFiles(files)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Date.
|
||||
*
|
||||
* @param files list of files to sort
|
||||
*/
|
||||
override fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
val multiplier = if (isAscending) 1 else -1
|
||||
files.sortWith { o1: File, o2: File ->
|
||||
multiplier * o1.lastModified().compareTo(o2.lastModified())
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
|
||||
import third_parties.daveKoeller.AlphanumComparator
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* Created by srkunze on 28.08.17.
|
||||
*/
|
||||
class FileSortOrderByName internal constructor(name: String?, ascending: Boolean) : FileSortOrder(name!!, ascending) {
|
||||
/**
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
@SuppressFBWarnings("Bx")
|
||||
override fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
val sortedByName = sortServerFiles(files)
|
||||
return super.sortCloudFiles(sortedByName)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
override fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
val sortedByName = sortServerFiles(files)
|
||||
return super.sortTrashbinFiles(sortedByName)
|
||||
}
|
||||
|
||||
private fun <T : ServerFileInterface> sortServerFiles(files: MutableList<T>): MutableList<T> {
|
||||
files.sortWith { o1: ServerFileInterface, o2: ServerFileInterface ->
|
||||
when {
|
||||
o1.isFolder && o2.isFolder -> sortMultiplier * AlphanumComparator.compare(o1, o2)
|
||||
o1.isFolder -> -1
|
||||
o2.isFolder -> 1
|
||||
else -> sortMultiplier * AlphanumComparator.compare(o1, o2)
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts list by Name.
|
||||
*
|
||||
* @param files files to sort
|
||||
*/
|
||||
override fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
files.sortWith { o1: File, o2: File ->
|
||||
when {
|
||||
o1.isDirectory && o2.isDirectory -> sortMultiplier * o1.path.lowercase(Locale.getDefault())
|
||||
.compareTo(o2.path.lowercase(Locale.getDefault()))
|
||||
o1.isDirectory -> -1
|
||||
o2.isDirectory -> 1
|
||||
else -> sortMultiplier * AlphanumComparator.compare(
|
||||
o1.path.lowercase(Locale.getDefault()),
|
||||
o2.path.lowercase(Locale.getDefault())
|
||||
)
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Sven R. Kunze
|
||||
* Copyright (C) 2017 Sven R. Kunze
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
*
|
||||
* 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.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.files.model.ServerFileInterface
|
||||
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Sorts files by sizes
|
||||
*/
|
||||
class FileSortOrderBySize internal constructor(name: String?, ascending: Boolean) : FileSortOrder(name!!, ascending) {
|
||||
|
||||
override fun sortCloudFiles(files: MutableList<OCFile>): List<OCFile> {
|
||||
val sortedBySize = sortServerFiles(files)
|
||||
return super.sortCloudFiles(sortedBySize)
|
||||
}
|
||||
|
||||
override fun sortTrashbinFiles(files: MutableList<TrashbinFile>): List<TrashbinFile> {
|
||||
val sortedBySize = sortServerFiles(files)
|
||||
return super.sortTrashbinFiles(sortedBySize)
|
||||
}
|
||||
|
||||
private fun <T : ServerFileInterface> sortServerFiles(files: MutableList<T>): MutableList<T> {
|
||||
files.sortWith { o1: ServerFileInterface, o2: ServerFileInterface ->
|
||||
when {
|
||||
o1.isFolder && o2.isFolder -> sortMultiplier * o1.fileLength.compareTo(o2.fileLength)
|
||||
o1.isFolder -> -1
|
||||
o2.isFolder -> 1
|
||||
else -> sortMultiplier * o1.fileLength.compareTo(o2.fileLength)
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
override fun sortLocalFiles(files: MutableList<File>): List<File> {
|
||||
|
||||
files.sortWith { o1: File, o2: File ->
|
||||
when {
|
||||
o1.isDirectory && o2.isDirectory -> sortMultiplier * FileStorageUtils.getFolderSize(o1)
|
||||
.compareTo(FileStorageUtils.getFolderSize(o2))
|
||||
o1.isDirectory -> -1
|
||||
o2.isDirectory -> 1
|
||||
else -> sortMultiplier * o1.length().compareTo(o2.length())
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:autoMirrored="true"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
tools:ignore="VectorRaster">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M23,21.1663C23,22.1728 22.1728,23 21.1663,23L17.5,23L17.5,21.1663L21.1663,21.1663L21.1663,17.5L23,17.5L23,21.1663ZM2.8337,23C1.8272,23 1,22.1728 1,21.1663L1,17.5L2.8337,17.5L2.8337,21.1663L6.5,21.1663L6.5,23L2.8337,23ZM6.4483,4.85C6.1645,4.85 5.9423,5.0744 5.9423,5.3604L5.9423,18.6396C5.9423,18.9256 6.1645,19.15 6.4483,19.15L17.5616,19.15C17.8443,19.15 18.0665,18.9256 18.0665,18.6396L18.0665,7.9146L15.036,4.85L6.4483,4.85ZM7.963,16.0854L12.0044,16.0854L12.0044,17.1073L7.963,17.1073L7.963,16.0854ZM7.963,13.0219L16.0458,13.0219L16.0458,14.0427L7.963,14.0427L7.963,13.0219ZM7.963,9.9573L13.0153,9.9573L13.0153,10.9781L7.963,10.9781L7.963,9.9573ZM7.963,6.8927L14.0251,6.8927L14.0251,7.9146L7.963,7.9146L7.963,6.8927ZM1,2.8337C1,1.8272 1.8272,1 2.8337,1L6.5,1L6.5,2.8337L2.8337,2.8337L2.8337,6.5L1,6.5L1,2.8337ZM21.1663,1C22.1728,1 23,1.8272 23,2.8337L23,6.5L21.1663,6.5L21.1663,2.8337L17.5,2.8337L17.5,1L21.1663,1Z" />
|
||||
</vector>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?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/>.
|
||||
-->
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/grey_200">
|
||||
<item android:id="@android:id/mask">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="?android:colorPrimary" />
|
||||
</shape>
|
||||
<color android:color="@color/white" />
|
||||
</item>
|
||||
</ripple>
|
||||
@@ -1,41 +0,0 @@
|
||||
<?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/>.
|
||||
-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:paddingTop="?attr/actionBarSize"
|
||||
tools:context=".ui.preview.PreviewBitmapActivity">
|
||||
|
||||
<com.github.chrisbanes.photoview.PhotoView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@drawable/all_files"
|
||||
android:layout_margin="@dimen/zero" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?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/>.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
tools:context=".ui.preview.pdf.PreviewPdfFragment">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/pdf_recycler"
|
||||
android:scrollbars="vertical"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
android:background="@color/grey_200"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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/>.
|
||||
-->
|
||||
|
||||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/page"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="1dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:scaleType="fitCenter" />
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* 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.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import third_parties.daveKoeller.AlphanumComparator
|
||||
|
||||
/**
|
||||
* Adapted on 2022/02/04 from https://github.com/nextcloud/server/blob/caff1023ea72bb2ea94130e18a2a6e2ccf819e5f/tests/lib/NaturalSortTest.php
|
||||
*/
|
||||
@RunWith(Parameterized::class)
|
||||
class NaturalSortTest {
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
lateinit var title: String
|
||||
|
||||
@Parameterized.Parameter(1)
|
||||
lateinit var expected: Array<String>
|
||||
|
||||
companion object {
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
@JvmStatic
|
||||
@Suppress("LongMethod")
|
||||
fun data(): Iterable<Array<Any>> = listOf(
|
||||
arrayOf(
|
||||
"Different casing",
|
||||
arrayOf("aaa", "AAA", "bbb", "BBB")
|
||||
),
|
||||
arrayOf(
|
||||
"Numbers",
|
||||
arrayOf(
|
||||
"15.txt", "15b.txt", "123.txt", "124.txt", "abc", "abc1", "abc2", "abc10", "abc12", "def.txt",
|
||||
"def (1).txt", "def (2).txt", "def (10).txt", "def (12).txt", "ghi.txt", "ghi 1.txt", "ghi 2.txt",
|
||||
"ghi 10.txt", "ghi 12.txt", "z", "za", "zz"
|
||||
)
|
||||
),
|
||||
arrayOf(
|
||||
"Chinese characters",
|
||||
arrayOf(
|
||||
"123.txt", "abc.txt", "一.txt", "七.txt", "三.txt", "九.txt", "二.txt", "五.txt", "八.txt", "六.txt",
|
||||
"十.txt", "十 2.txt", "十一.txt", "啊.txt", "四.txt", "波.txt", "破.txt", "莫.txt"
|
||||
)
|
||||
),
|
||||
arrayOf(
|
||||
"With umlauts",
|
||||
arrayOf(
|
||||
"ah.txt", "äh.txt", "Äh.txt", "oh.txt", "öh.txt", "Öh.txt", "uh.txt", "üh.txt", "Üh.txt",
|
||||
"Üh 2.txt",
|
||||
)
|
||||
),
|
||||
arrayOf(
|
||||
"Leading zeroes",
|
||||
arrayOf(
|
||||
"2012-09-15 22.50.37.jpg", "2012-Card.jpg", "1584164_460s_v1.jpg", "08082008.jpg",
|
||||
"02122011150.jpg", "03122011151.jpg", "9999999999999999999999999999991.jpg",
|
||||
"9999999999999999999999999999992.jpg", "T 0 abc", "T 00 abc", "T 000 abc", "T 1 abc", "T 01 abc",
|
||||
"T 001 abc", "T 2 abc", "T 02 abc", "T 3 abc", "T 03 abc"
|
||||
)
|
||||
),
|
||||
arrayOf(
|
||||
"Trailing digits",
|
||||
arrayOf("A", "T", "T 01", "T 2", "T 003", "Zeros", "Zeros 2")
|
||||
),
|
||||
arrayOf(
|
||||
"Special chars",
|
||||
arrayOf(
|
||||
"[Test] Folder", "01 - January", "11 - November", "Ôle", "Test 1", "Test 01", "Test 04", "Üüü",
|
||||
"z.[Test], z. Test"
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
val sut = AlphanumComparator<String>()
|
||||
val shuffled = expected.clone().apply { shuffle() }
|
||||
val sorted = shuffled.sortedWith(sut).toTypedArray()
|
||||
Assert.assertArrayEquals("Wrong sort", expected, sorted)
|
||||
}
|
||||
}
|
||||
@@ -1,350 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2017 Tobias Kaminsky
|
||||
* Copyright (C) 2022 Álvaro Brey Vilas
|
||||
* Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.utils
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.FileSortOrder
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
/*
|
||||
Tests used from
|
||||
https://github.com/nextcloud/server/blob/9a4253ef7c34f9dc71a6a9f7828a10df769f0c32/tests/lib/NaturalSortTest.php
|
||||
at 2017-11-21 to stay in sync with server.
|
||||
Added first test with special chars
|
||||
*/
|
||||
@RunWith(Parameterized::class)
|
||||
class OCFileSortTest {
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
lateinit var title: String
|
||||
|
||||
@Parameterized.Parameter(1)
|
||||
lateinit var expected: Array<OCFile>
|
||||
|
||||
@Test
|
||||
fun testFileSortOrder() {
|
||||
val toSort = getShuffledList()
|
||||
|
||||
FileSortOrder.sort_a_to_z.sortCloudFiles(toSort)
|
||||
|
||||
verifySort(toSort)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCompareTo() {
|
||||
val toSort = getShuffledList()
|
||||
|
||||
toSort.sort()
|
||||
|
||||
verifySort(toSort)
|
||||
}
|
||||
|
||||
private fun getShuffledList(): MutableList<OCFile> {
|
||||
return expected.toMutableList().apply { shuffle() }
|
||||
}
|
||||
|
||||
private fun verifySort(actual: MutableList<OCFile>) {
|
||||
val targetNames = expected.map { it.fileName }.toTypedArray()
|
||||
val actualNames = actual.map { it.fileName }.toTypedArray()
|
||||
|
||||
Assert.assertArrayEquals("Wrong sort", targetNames, actualNames)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
@JvmStatic
|
||||
@Suppress("LongMethod")
|
||||
fun data(): Iterable<Array<Any>> = listOf(
|
||||
arrayOf(
|
||||
"Folder first",
|
||||
arrayOf(
|
||||
OCFile("/ah.txt").setFolder(), OCFile("/Äh.txt").setFolder(), OCFile("/oh.txt").setFolder(),
|
||||
OCFile("/öh.txt").setFolder(), OCFile("/üh.txt").setFolder(), OCFile("/Üh.txt").setFolder(),
|
||||
OCFile("/äh.txt"), OCFile("/Öh.txt"), OCFile("/uh.txt"), OCFile("/Üh 2.txt")
|
||||
)
|
||||
),
|
||||
arrayOf(
|
||||
"Cloud files",
|
||||
listOf(
|
||||
"/Joplin/0ed1778f8f88414286c13b2cbff8664e.md", "/Joplin/0edf70ab1b722172088257b3d73d6c46.md",
|
||||
"/Joplin/0fb063d4d18128fdf464878d18439ca3.md", "/Joplin/8a2d6a6461eb4979bb049837a8710a3d.md",
|
||||
"/Joplin/8b7ff9081f5944399e1fc83c6191a09f.md", "/Joplin/8c45ac421149a21f32edab06f0955839.md",
|
||||
"/Joplin/8cd855a41cca4cbd8a0c20e79c4f2f9e.md", "/Joplin/8f062be696e3488ca12a9d3f3f6aa10a.md",
|
||||
"/Joplin/8f74a571a11b4709bb1cdf75b4a51a8e.md", "/Joplin/10e27391096748b187392f913da048f8.md",
|
||||
"/Joplin/41bd23f62ebb4d0b64c5f78b5ad13133.md", "/Joplin/49bfe05d968c3c0612ddceb2250b3a18.md",
|
||||
"/Joplin/70ba2272c85353a0216577ec76d0d343.md", "/Joplin/90f61d36f4dd4ef79525b7b0812213e2.md",
|
||||
"/Joplin/448d96a6c76b48b68030c8c11339088d.md", "/Joplin/730c09e169bc4289af163a34d7fe2553.md",
|
||||
"/Joplin/736be455ce8aff18694649001a74722a.md", "/Joplin/749c837930174e828620a99a9e7ad7bc.md",
|
||||
"/Joplin/4292ef3223334677bed0ad0268e5bd4b.md", "/Joplin/4969e02c5c504899b17a355e61989bed.md",
|
||||
"/Joplin/7172f37973434fe3aeb6ef96bb48d968.md", "/Joplin/9846fdafaffa718ebcfa19474e8be251.md",
|
||||
"/Joplin/41890bd1b11a44f7a6b226120ee1efbc.md", "/Joplin/73098c81e1ae4831b3a90ffda82ddcec.md",
|
||||
"/Joplin/701409a07ee4464fb82d9bc0c451f204.md", "/Joplin/4093463de91947b990fccff4a1d13d8f.md",
|
||||
"/Joplin/72068539d77c6e7b3271b653422d6e76.md", "/Joplin/4307355783f4108aad5eba4d1b81ff91.md",
|
||||
"/Joplin/71563833027a49dcaa86208a3f621402.md", "/Joplin/41742897324842849667274b2d1a0bb6.md",
|
||||
"/Joplin/a441cb730c22451aa4352129231fe898.md", "/Joplin/a551ce1ae06e6f05669a0cadc4eb2f7b.md",
|
||||
"/Joplin/a590cd1671b648c7a3bae0d6fbb7da81.md"
|
||||
).map { OCFile(it) }.toTypedArray()
|
||||
),
|
||||
arrayOf(
|
||||
"With dots",
|
||||
listOf(
|
||||
"/1.0.1",
|
||||
"/11.04.8933",
|
||||
"/121.04.8933",
|
||||
"/1234.04.8933",
|
||||
"/2010.01.66",
|
||||
"/2010.01.84",
|
||||
"/2010.02.2724",
|
||||
"/2010.02.6786",
|
||||
"/2010.03.5635",
|
||||
"/2010.04.5241",
|
||||
"/2010.04.9515",
|
||||
"/2010.04.9549",
|
||||
"/2010.05.1230",
|
||||
"/2010.05.7857",
|
||||
"/2010.06.1591",
|
||||
"/2010.06.5763",
|
||||
"/2010.06.7521",
|
||||
"/2010.07.4053",
|
||||
"/2010.07.81260",
|
||||
"/2010.08.5827",
|
||||
"/2010.09.2319",
|
||||
"/2010.09.3989",
|
||||
"/2010.09.6730",
|
||||
"/2010.11.7728",
|
||||
"/2010.11.81271",
|
||||
"/2011.01.3175",
|
||||
"/2011.02.1659",
|
||||
"/2011.02.3068",
|
||||
"/2011.02.9824",
|
||||
"/2011.03.7712",
|
||||
"/2011.04.4308",
|
||||
"/2011.04.5001",
|
||||
"/2011.05.5452",
|
||||
"/2011.05.5902",
|
||||
"/2011.06.1760",
|
||||
"/2011.06.1937",
|
||||
"/2011.06.2733",
|
||||
"/2011.06.2954",
|
||||
"/2011.06.2990",
|
||||
"/2011.07.1017",
|
||||
"/2011.07.6014",
|
||||
"/2011.08.2065",
|
||||
"/2011.08.2122",
|
||||
"/2011.08.2295",
|
||||
"/2011.08.7430",
|
||||
"/2011.09.1398",
|
||||
"/2011.09.2769",
|
||||
"/2011.09.7857",
|
||||
"/2011.10.1147",
|
||||
"/2011.10.2285",
|
||||
"/2011.10.4875",
|
||||
"/2011.10.7269",
|
||||
"/2011.11.3716",
|
||||
"/2011.11.4597",
|
||||
"/2011.11.5201",
|
||||
"/2011.11.5326",
|
||||
"/2011.11.5763",
|
||||
"/2012.01.2319",
|
||||
"/2012.01.2966",
|
||||
"/2012.01.3098",
|
||||
"/2012.01.9713",
|
||||
"/2012.02.935",
|
||||
"/2012.02.9249",
|
||||
"/2012.03.2416",
|
||||
"/2012.03.2638",
|
||||
"/2012.03.3599",
|
||||
"/2012.03.3784",
|
||||
"/2012.03.8055",
|
||||
"/2012.05.9095",
|
||||
"/2012.06.206",
|
||||
"/2012.06.7947",
|
||||
"/2012.07.2853",
|
||||
"/2012.08.170",
|
||||
"/2012.08.841",
|
||||
"/2012.08.3684",
|
||||
"/2012.08.8905",
|
||||
"/2012.09.5068",
|
||||
"/2012.11.2195",
|
||||
"/2012.11.6968",
|
||||
"/2012.11.9046",
|
||||
"/2013.02.861",
|
||||
"/2013.04.1710",
|
||||
"/2013.04.2152",
|
||||
"/2013.04.3372",
|
||||
"/2013.05.1754",
|
||||
"/2013.05.2216",
|
||||
"/2013.05.7761",
|
||||
"/2013.05.8741",
|
||||
"/2013.07.1882",
|
||||
"/2013.07.6003",
|
||||
"/2013.08.8660",
|
||||
"/2013.09.7070",
|
||||
"/2013.09.7388",
|
||||
"/2013.10.804",
|
||||
"/2013.10.1946",
|
||||
"/2013.11.1929",
|
||||
"/2013.11.2766",
|
||||
"/2013.11.8259",
|
||||
"/2014.02.3514",
|
||||
"/2014.02.4056",
|
||||
"/2014.02.5390",
|
||||
"/2014.02.6094",
|
||||
"/2014.02.8980",
|
||||
"/2014.03.8426",
|
||||
"/2014.04.105",
|
||||
"/2014.04.3249",
|
||||
"/2014.04.8584",
|
||||
"/2014.05.2610",
|
||||
"/2014.05.5375",
|
||||
"/2014.05.7808",
|
||||
"/2014.06.2181",
|
||||
"/2014.07.2094",
|
||||
"/2014.07.7095",
|
||||
"/2014.07.7342",
|
||||
"/2014.08.365",
|
||||
"/2014.08.7792",
|
||||
"/2014.08.7971",
|
||||
"/2014.09.4869",
|
||||
"/2014.09.8531",
|
||||
"/2014.09.9809",
|
||||
"/2014.11.3443",
|
||||
"/2014.11.8557",
|
||||
"/2015.01.812",
|
||||
"/2015.01.8283",
|
||||
"/2015.02.1406",
|
||||
"/2015.02.2764",
|
||||
"/2015.02.6614",
|
||||
"/2015.03.3019",
|
||||
"/2015.04.2022",
|
||||
"/2015.04.5635",
|
||||
"/2015.04.7370",
|
||||
"/2015.04.9059",
|
||||
"/2015.05.3916",
|
||||
"/2015.05.4675",
|
||||
"/2015.05.5681",
|
||||
"/2015.05.7043",
|
||||
"/2015.05.7767",
|
||||
"/2015.05.9830",
|
||||
"/2015.06.7024",
|
||||
"/2015.06.7667",
|
||||
"/2015.07.845",
|
||||
"/2015.07.8494",
|
||||
"/2015.08.2715",
|
||||
"/2015.08.3915",
|
||||
"/2015.09.7108",
|
||||
"/2015.09.9047",
|
||||
"/2015.10.645",
|
||||
"/2015.11.1950",
|
||||
"/2015.11.3243",
|
||||
"/2015.11.9182",
|
||||
"/2016.01.9777",
|
||||
"/2016.02.5648",
|
||||
"/2016.03.8389",
|
||||
"/2016.04.6043",
|
||||
"/2016.04.6305",
|
||||
"/2016.05.4529",
|
||||
"/2016.05.6597",
|
||||
"/2016.05.8586",
|
||||
"/2016.06.782",
|
||||
"/2016.06.1030",
|
||||
"/2016.06.5603",
|
||||
"/2016.07.5437",
|
||||
"/2016.08.2250",
|
||||
"/2016.08.7554",
|
||||
"/2016.08.7836",
|
||||
"/2016.08.8918",
|
||||
"/2016.09.3652",
|
||||
"/2016.09.4720",
|
||||
"/2016.09.6503",
|
||||
"/2016.10.38",
|
||||
"/2016.10.1857",
|
||||
"/2016.10.8252",
|
||||
"/2016.11.4425",
|
||||
"/2017.01.962",
|
||||
"/2017.01.1958",
|
||||
"/2017.01.2733",
|
||||
"/2017.01.4330",
|
||||
"/2017.01.7891",
|
||||
"/2017.02.41",
|
||||
"/2017.02.593",
|
||||
"/2017.02.1957",
|
||||
"/2017.02.5664",
|
||||
"/2017.03.786",
|
||||
"/2017.03.2849",
|
||||
"/2017.03.4025",
|
||||
"/2017.03.4545",
|
||||
"/2017.04.4579",
|
||||
"/2017.04.5291",
|
||||
"/2017.04.7168",
|
||||
"/2017.05.1116",
|
||||
"/2017.06.1672",
|
||||
"/2017.07.2056",
|
||||
"/2017.07.3936",
|
||||
"/2017.07.6682",
|
||||
"/2017.07.7894",
|
||||
"/2017.08.1603",
|
||||
"/2017.08.7493",
|
||||
"/2017.08.7545",
|
||||
"/2017.09.1846",
|
||||
"/2017.09.3665",
|
||||
"/2017.09.3978",
|
||||
"/2017.11.920",
|
||||
"/2017.11.5763",
|
||||
"/112233.04.8933",
|
||||
"/1231232.4.8933",
|
||||
"/1231232.40.8933",
|
||||
"/1231232.040.8933"
|
||||
).map { OCFile(it) }.toTypedArray()
|
||||
),
|
||||
arrayOf(
|
||||
"With dot files and folders",
|
||||
arrayOf(
|
||||
OCFile("/.apache2").setFolder(),
|
||||
OCFile("/.cache").setFolder(),
|
||||
OCFile("/.config").setFolder(),
|
||||
OCFile("/.local").setFolder(),
|
||||
OCFile("/.logs").setFolder(),
|
||||
OCFile("/.nano").setFolder(),
|
||||
OCFile("/.nginx").setFolder(),
|
||||
OCFile("/.script-credentials").setFolder(),
|
||||
OCFile("/.ssh").setFolder(),
|
||||
OCFile("/.subversion").setFolder(),
|
||||
OCFile("/.znc").setFolder(),
|
||||
OCFile("/.bash_aliases"),
|
||||
OCFile("/.bash_history"),
|
||||
OCFile("/.bash_logout"),
|
||||
OCFile("/.bashrc"),
|
||||
OCFile("/.feral_aliases"),
|
||||
OCFile("/.mysql_history"),
|
||||
OCFile("/.profile"),
|
||||
OCFile("/.selected_editor"),
|
||||
OCFile("/.wget-hsts")
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
target/
|
||||
ScreenShots/
|
||||
.DS_Store
|
||||
Users/
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>androidtest</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,12 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,20 @@
|
||||
** Work in progress
|
||||
|
||||
This project contains a set of automatic tests operating in the UI level.
|
||||
|
||||
Tests are to be run with the tool Appium. Check [here][0] to install it and all its dependencies (including Maven).
|
||||
|
||||
You will need to modify the constants in automationTest/src/test/java/com/owncloud/android/test/ui/testSuites/Config.java to assign appropriate values for your test server and accounts.
|
||||
You will need to include the ownCloud.apk to test in automationTest/src/test/resources/.
|
||||
|
||||
To run the tests from command line, plug a device to your computer or start and emulator. Then type
|
||||
|
||||
mvn clean tests
|
||||
|
||||
To run only one category of the test
|
||||
|
||||
mvn clean -Dtest=RunSmokeTests test
|
||||
|
||||
The project may also be imported in Eclipse, with the appropriate plug-ins, and run from it.
|
||||
|
||||
[0]: http://appium.io/slate/en/master/?java#about-appium
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.owncloud</groupId>
|
||||
<artifactId>androidtest</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test**.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>2.45.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.selendroid</groupId>
|
||||
<version>0.9.0</version>
|
||||
<artifactId>selendroid-standalone</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.selendroid</groupId>
|
||||
<version>0.9.0</version>
|
||||
<artifactId>selendroid-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.appium</groupId>
|
||||
<artifactId>java-client</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,4 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@@ -0,0 +1,244 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.actions;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.NoSuchElementException;
|
||||
import org.openqa.selenium.ScreenOrientation;
|
||||
import org.openqa.selenium.remote.RemoteWebElement;
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
import com.owncloud.android.test.ui.models.CertificatePopUp;
|
||||
import com.owncloud.android.test.ui.models.ElementMenuOptions;
|
||||
import com.owncloud.android.test.ui.models.GmailSendMailView;
|
||||
import com.owncloud.android.test.ui.models.ShareView;
|
||||
import com.owncloud.android.test.ui.models.UploadFilesView;
|
||||
import com.owncloud.android.test.ui.models.LoginForm;
|
||||
import com.owncloud.android.test.ui.models.FileListView;
|
||||
import com.owncloud.android.test.ui.models.MenuList;
|
||||
import com.owncloud.android.test.ui.models.NewFolderPopUp;
|
||||
import com.owncloud.android.test.ui.models.RemoveConfirmationView;
|
||||
import com.owncloud.android.test.ui.models.SettingsView;
|
||||
import com.owncloud.android.test.ui.models.WaitAMomentPopUp;
|
||||
import com.owncloud.android.test.ui.testSuites.Common;
|
||||
import com.owncloud.android.test.ui.testSuites.Config;
|
||||
|
||||
public class Actions {
|
||||
|
||||
public static FileListView login(String url, String user, String password,
|
||||
Boolean isTrusted, AndroidDriver driver)
|
||||
throws InterruptedException {
|
||||
LoginForm loginForm = new LoginForm(driver);
|
||||
CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url);
|
||||
if(!isTrusted){
|
||||
WebDriverWait wait = new WebDriverWait(driver, 30);
|
||||
//sometimes the certificate has been already accept
|
||||
//and it doesn't appear again
|
||||
try {
|
||||
wait.until(ExpectedConditions
|
||||
.visibilityOf(certificatePopUp.getOkButtonElement()));
|
||||
//we need to repaint the screen
|
||||
//because of some element are misplaced
|
||||
driver.rotate(ScreenOrientation.LANDSCAPE);
|
||||
driver.rotate(ScreenOrientation.PORTRAIT);
|
||||
certificatePopUp.clickOnOkButton();
|
||||
}catch (NoSuchElementException e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
loginForm.typeUserName(user);
|
||||
loginForm.typePassword(password);
|
||||
//TODO. Assert related to check the connection?
|
||||
return loginForm.clickOnConnectButton();
|
||||
}
|
||||
|
||||
public static WaitAMomentPopUp createFolder(String folderName,
|
||||
FileListView fileListView){
|
||||
NewFolderPopUp newFolderPopUp = fileListView.clickOnNewFolderButton();
|
||||
newFolderPopUp.typeNewFolderName(folderName);
|
||||
WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp
|
||||
.clickOnNewFolderOkButton();
|
||||
//TODO. assert here
|
||||
return waitAMomentPopUp;
|
||||
}
|
||||
|
||||
|
||||
public static AndroidElement scrollTillFindElement (String elementName,
|
||||
AndroidElement element, AndroidDriver driver) {
|
||||
AndroidElement fileElement;
|
||||
|
||||
if(element.getAttribute("scrollable").equals("true")){
|
||||
HashMap<String, String> scrollObject = new HashMap<String,String>();
|
||||
scrollObject.put("text", elementName);
|
||||
scrollObject.put("element", ( (RemoteWebElement) element).getId());
|
||||
driver.executeScript("mobile: scrollTo", scrollObject);
|
||||
}
|
||||
try {
|
||||
fileElement = (AndroidElement) driver
|
||||
.findElementByName(elementName);
|
||||
} catch (NoSuchElementException e) {
|
||||
fileElement = null;
|
||||
}
|
||||
return fileElement;
|
||||
}
|
||||
|
||||
|
||||
public static void deleteAccount (int accountPosition,FileListView fileListView) {
|
||||
MenuList menulist = fileListView.clickOnMenuButton();
|
||||
SettingsView settingView = menulist.clickOnSettingsButton();
|
||||
deleteAccount(accountPosition,settingView);
|
||||
}
|
||||
|
||||
public static void deleteAccount (int accountPosition, SettingsView settingsView) {
|
||||
settingsView.tapOnAccountElement(accountPosition,1, 1000);
|
||||
settingsView.clickOnDeleteAccountElement();
|
||||
}
|
||||
|
||||
public static void clickOnMainLayout(AndroidDriver driver){
|
||||
driver.tap(1, 0, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
public static AndroidElement deleteElement(String elementName,
|
||||
FileListView fileListView, AndroidDriver driver) throws Exception{
|
||||
AndroidElement fileElement;
|
||||
WaitAMomentPopUp waitAMomentPopUp;
|
||||
try{
|
||||
//To open directly the "file list view" and
|
||||
//we don't need to know in which view we are
|
||||
driver.startActivity("com.owncloud.android",
|
||||
".ui.activity.FileDisplayActivity");
|
||||
fileElement = (AndroidElement) driver
|
||||
.findElementByName(elementName);
|
||||
ElementMenuOptions menuOptions = fileListView
|
||||
.longPressOnElement(elementName);
|
||||
RemoveConfirmationView removeConfirmationView = menuOptions
|
||||
.clickOnRemove();;
|
||||
waitAMomentPopUp = removeConfirmationView
|
||||
.clickOnRemoteAndLocalButton();
|
||||
Common.waitTillElementIsNotPresent(
|
||||
waitAMomentPopUp.getWaitAMomentTextElement(), 100);
|
||||
}catch(NoSuchElementException e){
|
||||
fileElement=null;
|
||||
}
|
||||
return fileElement;
|
||||
}
|
||||
|
||||
public static AndroidElement shareLinkElementByGmail(String elementName,
|
||||
FileListView fileListView, AndroidDriver driver, Common common)
|
||||
throws Exception{
|
||||
try{
|
||||
//To open directly the "file list view" and
|
||||
//we don't need to know in which view we are
|
||||
driver.startActivity("com.owncloud.android",
|
||||
".ui.activity.FileDisplayActivity");
|
||||
ElementMenuOptions menuOptions = fileListView
|
||||
.longPressOnElement(elementName);
|
||||
ShareView shareView = menuOptions.clickOnShareLinkElement();
|
||||
Actions.scrollTillFindElement("Gmail", shareView
|
||||
.getListViewLayout(), driver).click();
|
||||
GmailSendMailView gmailSendMailView = new GmailSendMailView(driver);
|
||||
gmailSendMailView.typeToEmailAdress(Config.gmailAccount);
|
||||
gmailSendMailView.clickOnSendButton();
|
||||
Common.waitTillElementIsNotPresentWithoutTimeout(fileListView
|
||||
.getProgressCircular(), 1000);
|
||||
common.wait.until(ExpectedConditions.visibilityOf(
|
||||
fileListView.getFileElementLayout()
|
||||
.findElement(By.id(FileListView
|
||||
.getSharedElementIndicator()))));
|
||||
|
||||
}catch(NoSuchElementException e){
|
||||
return null;
|
||||
}
|
||||
return (AndroidElement) fileListView.getFileElementLayout()
|
||||
.findElement(By.id(FileListView.getSharedElementIndicator()));
|
||||
}
|
||||
|
||||
public static AndroidElement shareLinkElementByCopyLink(String elementName,
|
||||
FileListView fileListView, AndroidDriver driver, Common common)
|
||||
throws Exception{
|
||||
try{
|
||||
//To open directly the "file list view" and
|
||||
//we don't need to know in which view we are
|
||||
driver.startActivity("com.owncloud.android",
|
||||
".ui.activity.FileDisplayActivity");
|
||||
ElementMenuOptions menuOptions = fileListView
|
||||
.longPressOnElement(elementName);
|
||||
ShareView shareView = menuOptions.clickOnShareLinkElement();
|
||||
Actions.scrollTillFindElement("Copy link", shareView.getListViewLayout(),
|
||||
driver).click();
|
||||
WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
|
||||
Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp
|
||||
.getWaitAMomentTextElement(), 100);
|
||||
common.wait.until(ExpectedConditions.visibilityOf(
|
||||
fileListView.getFileElementLayout()
|
||||
.findElement(By.id(FileListView.getSharedElementIndicator()))));
|
||||
}catch(NoSuchElementException e){
|
||||
return null;
|
||||
}
|
||||
return (AndroidElement) fileListView.getFileElementLayout()
|
||||
.findElement(By.id(FileListView.getSharedElementIndicator()));
|
||||
}
|
||||
|
||||
|
||||
public static void unshareLinkElement(String elementName,
|
||||
FileListView fileListView, AndroidDriver driver, Common common)
|
||||
throws Exception{
|
||||
try{
|
||||
//To open directly the "file list view" and
|
||||
//we don't need to know in which view we are
|
||||
driver.startActivity("com.owncloud.android",
|
||||
".ui.activity.FileDisplayActivity");
|
||||
ElementMenuOptions menuOptions = fileListView
|
||||
.longPressOnElement(elementName);
|
||||
WaitAMomentPopUp waitAMomentPopUp = menuOptions
|
||||
.clickOnUnshareLinkElement();
|
||||
Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp
|
||||
.getWaitAMomentTextElement(), 100);
|
||||
Common.waitTillElementIsNotPresent((AndroidElement) fileListView
|
||||
.getFileElementLayout()
|
||||
.findElement(By.id(FileListView.getSharedElementIndicator())
|
||||
),100);
|
||||
}catch(NoSuchElementException e){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static FileListView uploadFile(String elementName,
|
||||
FileListView fileListView) throws InterruptedException{
|
||||
fileListView.clickOnUploadButton();
|
||||
UploadFilesView uploadFilesView = fileListView
|
||||
.clickOnFilesElementUploadFile();
|
||||
uploadFilesView.clickOnFileName(elementName);
|
||||
FileListView fileListViewAfterUploadFile = uploadFilesView
|
||||
.clickOnUploadButton();
|
||||
//TO DO. detect when the file is successfully uploaded
|
||||
Thread.sleep(15000);
|
||||
return fileListViewAfterUploadFile;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
public interface FailingTestCategory extends IgnoreTestCategory {}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Categories.CategoryFilter;
|
||||
import org.junit.experimental.categories.Categories.ExcludeCategory;
|
||||
import org.junit.experimental.categories.Categories.IncludeCategory;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.manipulation.NoTestsRemainException;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
import org.junit.runners.model.RunnerBuilder;
|
||||
|
||||
/**
|
||||
* This class is based on org.junit.experimental.categories.Categories from JUnit 4.10.
|
||||
*
|
||||
* All anotations and inner classes from the original class Categories are removed,
|
||||
* since they will be re-used.
|
||||
* Unfortunately sub-classing Categories did not work.
|
||||
*/
|
||||
public class FlexibleCategories extends Suite {
|
||||
|
||||
/**
|
||||
* Specifies the package which should be scanned for test classes (e.g. @TestScanPackage("my.package")).
|
||||
* This annotation is required.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TestScanPackage {
|
||||
public String value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the prefix of matching class names (e.g. @TestClassPrefix("Test")).
|
||||
* This annotation is optional (default: "").
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TestClassPrefix {
|
||||
public String value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the suffix of matching class names (e.g. @TestClassSuffix("Test")).
|
||||
* This annotation is optional (default: "Test").
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TestClassSuffix {
|
||||
public String value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies an annotation for methods which must be present in a matching class (e.g. @TestMethodAnnotationFilter(Test.class)).
|
||||
* This annotation is optional (default: org.junit.Test.class).
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TestMethodAnnotation {
|
||||
public Class<? extends Annotation> value();
|
||||
}
|
||||
|
||||
public FlexibleCategories(Class<?> clazz, RunnerBuilder builder)
|
||||
throws InitializationError {
|
||||
this(builder, clazz, PatternClasspathClassesFinder.getSuiteClasses(
|
||||
getTestScanPackage(clazz), getTestClassPrefix(clazz), getTestClassSuffix(clazz),
|
||||
getTestMethodAnnotation(clazz)));
|
||||
try {
|
||||
filter(new CategoryFilter(getIncludedCategory(clazz),
|
||||
getExcludedCategory(clazz)));
|
||||
} catch (NoTestsRemainException e) {
|
||||
// Ignore all classes with no matching tests.
|
||||
}
|
||||
assertNoCategorizedDescendentsOfUncategorizeableParents(getDescription());
|
||||
}
|
||||
|
||||
public FlexibleCategories(RunnerBuilder builder, Class<?> clazz,
|
||||
Class<?>[] suiteClasses) throws InitializationError {
|
||||
super(builder, clazz, suiteClasses);
|
||||
}
|
||||
|
||||
private static String getTestScanPackage(Class<?> clazz) throws InitializationError {
|
||||
TestScanPackage annotation = clazz.getAnnotation(TestScanPackage.class);
|
||||
if (annotation == null) {
|
||||
throw new InitializationError("No package given to scan for tests!\nUse the annotation @TestScanPackage(\"my.package\") on the test suite " + clazz + ".");
|
||||
}
|
||||
return annotation.value();
|
||||
}
|
||||
|
||||
private static String getTestClassPrefix(Class<?> clazz) {
|
||||
TestClassPrefix annotation = clazz.getAnnotation(TestClassPrefix.class);
|
||||
return annotation == null ? "" : annotation.value();
|
||||
}
|
||||
|
||||
private static String getTestClassSuffix(Class<?> clazz) {
|
||||
TestClassSuffix annotation = clazz.getAnnotation(TestClassSuffix.class);
|
||||
return annotation == null ? "Test" : annotation.value();
|
||||
}
|
||||
|
||||
private static Class<? extends Annotation> getTestMethodAnnotation(Class<?> clazz) {
|
||||
TestMethodAnnotation annotation = clazz.getAnnotation(TestMethodAnnotation.class);
|
||||
return annotation == null ? Test.class : annotation.value();
|
||||
}
|
||||
|
||||
private Class<?> getIncludedCategory(Class<?> clazz) {
|
||||
IncludeCategory annotation= clazz.getAnnotation(IncludeCategory.class);
|
||||
return annotation == null ? null : annotation.value();
|
||||
}
|
||||
|
||||
private Class<?> getExcludedCategory(Class<?> clazz) {
|
||||
ExcludeCategory annotation= clazz.getAnnotation(ExcludeCategory.class);
|
||||
return annotation == null ? null : annotation.value();
|
||||
}
|
||||
|
||||
private void assertNoCategorizedDescendentsOfUncategorizeableParents(Description description) throws InitializationError {
|
||||
if (!canHaveCategorizedChildren(description))
|
||||
assertNoDescendantsHaveCategoryAnnotations(description);
|
||||
for (Description each : description.getChildren())
|
||||
assertNoCategorizedDescendentsOfUncategorizeableParents(each);
|
||||
}
|
||||
|
||||
private void assertNoDescendantsHaveCategoryAnnotations(Description description) throws InitializationError {
|
||||
for (Description each : description.getChildren()) {
|
||||
if (each.getAnnotation(Category.class) != null)
|
||||
throw new InitializationError("Category annotations on Parameterized classes are not supported on individual methods.");
|
||||
assertNoDescendantsHaveCategoryAnnotations(each);
|
||||
}
|
||||
}
|
||||
|
||||
// If children have names like [0], our current magical category code can't determine their
|
||||
// parentage.
|
||||
private static boolean canHaveCategorizedChildren(Description description) {
|
||||
for (Description each : description.getChildren())
|
||||
if (each.getTestClass() == null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
public interface IgnoreTestCategory {}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
public interface InProgressCategory extends IgnoreTestCategory{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
public interface NoIgnoreTestCategory {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
public interface OtherTestCategory extends IgnoreTestCategory {}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Modified version of ClasspathClassesFinder from:
|
||||
* http://linsolas.free.fr/wordpress/index.php/2011/02/how-to-categorize-junit-tests-with-maven/
|
||||
*
|
||||
* The difference is, that it does not search for annotated classes but for classes with a certain
|
||||
* class name prefix and suffix.
|
||||
*/
|
||||
public final class PatternClasspathClassesFinder {
|
||||
|
||||
/**
|
||||
* Get the list of classes of a given package name, and that are annotated
|
||||
* by a given annotation.
|
||||
*
|
||||
* @param packageName
|
||||
* The package name of the classes.
|
||||
* @param classPrefix
|
||||
* The prefix of the class name.
|
||||
* @param classSuffix
|
||||
* The suffix of the class name.
|
||||
* @param methodAnnotation
|
||||
* Only return classes containing methods annotated with methodAnnotation.
|
||||
* @return The List of classes that matches the requirements.
|
||||
*/
|
||||
public static Class<?>[] getSuiteClasses(String packageName,
|
||||
String classPrefix, String classSuffix,
|
||||
Class<? extends Annotation> methodAnnotation) {
|
||||
try {
|
||||
return getClasses(packageName, classPrefix, classSuffix, methodAnnotation);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of classes of a given package name, and that are annotated
|
||||
* by a given annotation.
|
||||
*
|
||||
* @param packageName
|
||||
* The package name of the classes.
|
||||
* @param classPrefix
|
||||
* The prefix of the class name.
|
||||
* @param classSuffix
|
||||
* The suffix of the class name.
|
||||
* @param methodAnnotation
|
||||
* Only return classes containing methods annotated with methodAnnotation.
|
||||
* @return The List of classes that matches the requirements.
|
||||
* @throws ClassNotFoundException
|
||||
* If something goes wrong...
|
||||
* @throws IOException
|
||||
* If something goes wrong...
|
||||
*/
|
||||
private static Class<?>[] getClasses(String packageName,
|
||||
String classPrefix, String classSuffix,
|
||||
Class<? extends Annotation> methodAnnotation)
|
||||
throws ClassNotFoundException, IOException {
|
||||
ClassLoader classLoader = Thread.currentThread()
|
||||
.getContextClassLoader();
|
||||
String path = packageName.replace('.', '/');
|
||||
// Get classpath
|
||||
Enumeration<URL> resources = classLoader.getResources(path);
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
while (resources.hasMoreElements()) {
|
||||
URL resource = resources.nextElement();
|
||||
dirs.add(new File(resource.getFile()));
|
||||
}
|
||||
// For each classpath, get the classes.
|
||||
ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
for (File directory : dirs) {
|
||||
classes.addAll(findClasses(directory, packageName, classPrefix, classSuffix, methodAnnotation));
|
||||
}
|
||||
return classes.toArray(new Class[classes.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find classes, in a given directory (recursively), for a given package
|
||||
* name, that are annotated by a given annotation.
|
||||
*
|
||||
* @param directory
|
||||
* The directory where to look for.
|
||||
* @param packageName
|
||||
* The package name of the classes.
|
||||
* @param classPrefix
|
||||
* The prefix of the class name.
|
||||
* @param classSuffix
|
||||
* The suffix of the class name.
|
||||
* @param methodAnnotation
|
||||
* Only return classes containing methods annotated with methodAnnotation.
|
||||
* @return The List of classes that matches the requirements.
|
||||
* @throws ClassNotFoundException
|
||||
* If something goes wrong...
|
||||
*/
|
||||
private static List<Class<?>> findClasses(File directory,
|
||||
String packageName, String classPrefix, String classSuffix,
|
||||
Class<? extends Annotation> methodAnnotation)
|
||||
throws ClassNotFoundException {
|
||||
List<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
if (!directory.exists()) {
|
||||
return classes;
|
||||
}
|
||||
File[] files = directory.listFiles();
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
classes.addAll(findClasses(file,
|
||||
packageName + "." + file.getName(), classPrefix, classSuffix, methodAnnotation));
|
||||
} else if (file.getName().startsWith(classPrefix) && file.getName().endsWith(classSuffix + ".class")) {
|
||||
// We remove the .class at the end of the filename to get the
|
||||
// class name...
|
||||
Class<?> clazz = Class.forName(packageName
|
||||
+ '.'
|
||||
+ file.getName().substring(0,
|
||||
file.getName().length() - 6));
|
||||
|
||||
// Check, if class contains test methods (prevent "No runnable methods" exception):
|
||||
boolean classHasTest = false;
|
||||
for (Method method : clazz.getMethods()) {
|
||||
if (method.getAnnotation(methodAnnotation) != null) {
|
||||
classHasTest = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (classHasTest) {
|
||||
classes.add(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
return classes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
public interface SmokeTestCategory {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.groups;
|
||||
|
||||
public interface UnfinishedTestCategory extends IgnoreTestCategory{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class CertificatePopUp {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(name = "OK")
|
||||
private AndroidElement okButton;
|
||||
|
||||
public CertificatePopUp (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public void clickOnOkButton () {
|
||||
okButton.click();
|
||||
}
|
||||
|
||||
public AndroidElement getOkButtonElement () {
|
||||
return okButton;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class ElementMenuOptions {
|
||||
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(name = "Share link")
|
||||
private AndroidElement shareLinkElement;
|
||||
|
||||
@AndroidFindBy(name = "Unshare link")
|
||||
private AndroidElement unshareLinkElement;
|
||||
|
||||
@AndroidFindBy(name = "Details")
|
||||
private AndroidElement detailsFileElement;
|
||||
|
||||
@AndroidFindBy(name = "Rename")
|
||||
private AndroidElement renameFileElement;
|
||||
|
||||
@AndroidFindBy(name = "Remove")
|
||||
private AndroidElement removeFileElement;
|
||||
|
||||
@AndroidFindBy(name = "Move")
|
||||
private AndroidElement moveElement;
|
||||
|
||||
public ElementMenuOptions (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public FileDetailsView clickOnDetails () {
|
||||
detailsFileElement.click();
|
||||
FileDetailsView fileDetailsView = new FileDetailsView(driver);
|
||||
return fileDetailsView;
|
||||
}
|
||||
|
||||
public RemoveConfirmationView clickOnRemove () {
|
||||
removeFileElement.click();
|
||||
RemoveConfirmationView removeConfirmationView =
|
||||
new RemoveConfirmationView(driver);
|
||||
return removeConfirmationView;
|
||||
}
|
||||
|
||||
|
||||
public MoveView clickOnMove () {
|
||||
moveElement.click();
|
||||
MoveView moveView = new MoveView(driver);
|
||||
return moveView;
|
||||
}
|
||||
|
||||
public NewFolderPopUp clickOnRename () {
|
||||
renameFileElement.click();
|
||||
NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver);
|
||||
return newFolderPopUp;
|
||||
}
|
||||
|
||||
public ShareView clickOnShareLinkElement () {
|
||||
shareLinkElement.click();
|
||||
ShareView shareView = new ShareView(driver);
|
||||
return shareView;
|
||||
}
|
||||
|
||||
public WaitAMomentPopUp clickOnUnshareLinkElement () {
|
||||
unshareLinkElement.click();
|
||||
WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
|
||||
return waitAMomentPopUp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class FileDetailsView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(name = "Keep file up to date")
|
||||
private AndroidElement keepFileUpToDateCheckbox;
|
||||
|
||||
@AndroidFindBy(id = "com.owncloud.android:id/fdProgressBar")
|
||||
private AndroidElement progressBar;
|
||||
|
||||
public FileDetailsView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public void checkKeepFileUpToDateCheckbox () {
|
||||
if(keepFileUpToDateCheckbox.getAttribute("checked").equals("false")){
|
||||
keepFileUpToDateCheckbox.click();
|
||||
}
|
||||
}
|
||||
|
||||
public void unCheckKeepFileUpToDateCheckbox () {
|
||||
if(keepFileUpToDateCheckbox.getAttribute("checked").equals("true")){
|
||||
keepFileUpToDateCheckbox.click();
|
||||
}
|
||||
}
|
||||
|
||||
public AndroidElement getProgressBar (){
|
||||
return progressBar;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.android.AndroidKeyCode;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.NoSuchElementException;
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
import org.openqa.selenium.Point;
|
||||
|
||||
import com.owncloud.android.test.ui.actions.Actions;
|
||||
|
||||
public class FileListView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".description(\"More options\")")
|
||||
private AndroidElement menuButton;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(id = "com.owncloud.android:id/list_root")
|
||||
private AndroidElement filesLayout;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".resourceId(\"android:id/action_bar_title\")")
|
||||
private AndroidElement titleText;
|
||||
|
||||
@AndroidFindBy(id = "android:id/progress_circular")
|
||||
private AndroidElement progressCircular;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".description(\"New folder\")")
|
||||
private AndroidElement newFolderButton;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"Upload\")")
|
||||
private AndroidElement uploadButton;
|
||||
|
||||
private AndroidElement waitAMomentText;
|
||||
|
||||
@AndroidFindBy(id = "com.owncloud.android:id/ListItemLayout")
|
||||
private List<AndroidElement> listItemLayout;
|
||||
|
||||
@AndroidFindBy(id = "com.owncloud.android:id/list_root")
|
||||
private AndroidElement listRootLayout;
|
||||
|
||||
@AndroidFindBy(name = "Files")
|
||||
private AndroidElement filesElementUploadFile;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".description(\"List Layout\")")
|
||||
private AndroidElement listLayout;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)")
|
||||
private AndroidElement deviceScreen;
|
||||
|
||||
private AndroidElement fileElement;
|
||||
|
||||
private AndroidElement fileElementLayout;
|
||||
|
||||
private static String localFileIndicator =
|
||||
"com.owncloud.android:id/localFileIndicator";
|
||||
private static String favoriteFileIndicator =
|
||||
"com.owncloud.android:id/keptOfflineIcon";
|
||||
private static String sharedElementIndicator =
|
||||
"com.owncloud.android:id/sharedIcon";
|
||||
|
||||
|
||||
public FileListView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public MenuList clickOnMenuButton () {
|
||||
//if the menu option is not in the actionBar, it is opening again
|
||||
try {
|
||||
menuButton.click();
|
||||
} catch (NoSuchElementException e){
|
||||
driver.sendKeyEvent(AndroidKeyCode.MENU);
|
||||
}
|
||||
MenuList menuList = new MenuList (driver);
|
||||
return menuList;
|
||||
}
|
||||
|
||||
public SettingsView getSettingsView () {
|
||||
SettingsView settingsView = new SettingsView(driver);
|
||||
return settingsView;
|
||||
}
|
||||
|
||||
public NewFolderPopUp clickOnNewFolderButton () {
|
||||
newFolderButton.click();
|
||||
NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver);
|
||||
return newFolderPopUp;
|
||||
}
|
||||
|
||||
public void clickOnUploadButton () {
|
||||
uploadButton.click();
|
||||
}
|
||||
|
||||
public UploadFilesView clickOnFilesElementUploadFile () {
|
||||
filesElementUploadFile.click();
|
||||
UploadFilesView uploadFilesView = new UploadFilesView(driver);
|
||||
return uploadFilesView;
|
||||
}
|
||||
|
||||
public AndroidElement getTitleTextElement () {
|
||||
return titleText;
|
||||
}
|
||||
|
||||
public AndroidElement getUploadButton () {
|
||||
return uploadButton;
|
||||
}
|
||||
|
||||
public AndroidElement getWaitAMomentTextElement () {
|
||||
return waitAMomentText;
|
||||
}
|
||||
|
||||
public AndroidElement getListRootElement () {
|
||||
return listRootLayout;
|
||||
}
|
||||
|
||||
public List<AndroidElement> getListItemLayout () {
|
||||
return listItemLayout;
|
||||
}
|
||||
|
||||
public AndroidElement getFileElement () {
|
||||
return fileElement;
|
||||
}
|
||||
|
||||
public ElementMenuOptions longPressOnElement (String elementName) {
|
||||
scrollTillFindElement(elementName).tap(1, 1000);
|
||||
//fileElement.tap(1, 1000);
|
||||
ElementMenuOptions menuOptions = new ElementMenuOptions(driver);
|
||||
return menuOptions;
|
||||
}
|
||||
|
||||
public AndroidElement scrollTillFindElement (String elementName) {
|
||||
fileElement = Actions
|
||||
.scrollTillFindElement (elementName,filesLayout,driver);
|
||||
try {
|
||||
fileElementLayout = (AndroidElement) driver
|
||||
.findElementByAndroidUIAutomator("new UiSelector()"
|
||||
+ ".description(\"LinearLayout-"+ elementName +"\")");
|
||||
} catch (NoSuchElementException e) {
|
||||
fileElementLayout = null;
|
||||
}
|
||||
return fileElement;
|
||||
}
|
||||
|
||||
public AndroidElement getFileElementLayout () {
|
||||
return fileElementLayout;
|
||||
}
|
||||
|
||||
public AndroidElement getProgressCircular () {
|
||||
return progressCircular;
|
||||
}
|
||||
|
||||
public static String getLocalFileIndicator() {
|
||||
return localFileIndicator;
|
||||
}
|
||||
|
||||
public static String getFavoriteFileIndicator() {
|
||||
return favoriteFileIndicator;
|
||||
}
|
||||
|
||||
public static String getSharedElementIndicator() {
|
||||
return sharedElementIndicator;
|
||||
}
|
||||
public void pulldownToRefresh () throws InterruptedException {
|
||||
Point listLocation = listLayout.getLocation();
|
||||
driver.swipe(listLocation.getX(),listLocation.getY(),
|
||||
listLocation.getX(),listLocation.getY()+1000, 5000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void pulldownToSeeNotification () throws InterruptedException {
|
||||
Point listLocation = deviceScreen.getLocation();
|
||||
driver.swipe(listLocation.getX(),listLocation.getY(),
|
||||
listLocation.getX(),listLocation.getY()+1000, 5000);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.NoSuchElementException;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class GmailEmailListView {
|
||||
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\""
|
||||
+ "me about UploadFile, on May 11, conversation read\")")
|
||||
private AndroidElement emailAmericanFormatDate;
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\""
|
||||
+ "me about UploadFile, on 11 May, conversation read\")")
|
||||
private AndroidElement emailEuropeanFormatDate;
|
||||
|
||||
|
||||
public GmailEmailListView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public GmailEmailView clickOnEmail (){
|
||||
try{
|
||||
emailAmericanFormatDate.click();
|
||||
}catch (NoSuchElementException e) {
|
||||
emailEuropeanFormatDate.click();
|
||||
}
|
||||
GmailEmailView gmailEmailView = new GmailEmailView(driver);
|
||||
return gmailEmailView;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import com.owncloud.android.test.ui.testSuites.Config;
|
||||
|
||||
public class GmailEmailView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(name = Config.fileToTestSendByEmailName)
|
||||
private AndroidElement fileButton;
|
||||
|
||||
public GmailEmailView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public ImageView clickOnfileButton (){
|
||||
fileButton.click();
|
||||
ImageView imageView = new ImageView(driver);
|
||||
return imageView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class GmailSendMailView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"To\")")
|
||||
private AndroidElement toTextField;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(name = "Subject")
|
||||
private AndroidElement subjectTextField;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"Send\")")
|
||||
private AndroidElement sendButton;
|
||||
|
||||
public GmailSendMailView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public void typeToEmailAdress (String email) {
|
||||
toTextField.sendKeys(email + "\n");
|
||||
}
|
||||
|
||||
public void clickOnSendButton () {
|
||||
sendButton.click();
|
||||
}
|
||||
|
||||
public void typeSubject (String subject) {
|
||||
subjectTextField.clear();
|
||||
subjectTextField.sendKeys(subject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import com.owncloud.android.test.ui.actions.Actions;
|
||||
import com.owncloud.android.test.ui.testSuites.Common;
|
||||
|
||||
|
||||
public class ImageView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".description(\"More options\")")
|
||||
private AndroidElement optionsButton;
|
||||
|
||||
@AndroidFindBy(name = "Share")
|
||||
private AndroidElement shareButton;
|
||||
|
||||
@AndroidFindBy(name = "ownCloud")
|
||||
private AndroidElement ownCloudButton;
|
||||
|
||||
@AndroidFindBy(name = "Share with ownCloud")
|
||||
private AndroidElement shareWithOwnCloudButton;
|
||||
|
||||
@AndroidFindBy(name = "Just once")
|
||||
private AndroidElement justOnceButton;
|
||||
|
||||
@AndroidFindBy(id = "android:id/resolver_list")
|
||||
private AndroidElement sharingAppsLayout;
|
||||
|
||||
public ImageView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public void clickOnOptionsButton(){
|
||||
optionsButton.click();
|
||||
}
|
||||
|
||||
public void clickOnShareButton(){
|
||||
shareButton.click();
|
||||
}
|
||||
|
||||
public void clickOnOwnCloudButton(){
|
||||
if(Common.isElementPresent(ownCloudButton)){
|
||||
Actions.scrollTillFindElement("ownCloud",sharingAppsLayout,driver);
|
||||
ownCloudButton.click();
|
||||
}else if(Common.isElementPresent(shareWithOwnCloudButton)){}
|
||||
}
|
||||
|
||||
public void clickOnJustOnceButton(){
|
||||
justOnceButton.click();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
public class LoginForm {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".description(\"Server address\")")
|
||||
private AndroidElement hostUrlInput;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"Username\")")
|
||||
private AndroidElement userNameInput;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"Password\")")
|
||||
private AndroidElement passwordInput;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"Connect\")")
|
||||
private AndroidElement connectButton;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".description(\"Testing connection\")")
|
||||
private AndroidElement serverStatusText;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".description(\"Wrong username or password\")")
|
||||
private AndroidElement authStatusText;
|
||||
|
||||
public LoginForm (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public CertificatePopUp typeHostUrl (String hostUrl) {
|
||||
hostUrlInput.clear();
|
||||
hostUrlInput.sendKeys(hostUrl + "\n");
|
||||
CertificatePopUp certificatePopUp = new CertificatePopUp(driver);
|
||||
return certificatePopUp;
|
||||
}
|
||||
|
||||
public void clickOnUserName () {
|
||||
userNameInput.click();
|
||||
}
|
||||
|
||||
public void typeUserName (String userName) {
|
||||
userNameInput.clear();
|
||||
//using the \n , it not need to hide the keyboard
|
||||
//which sometimes gives problems
|
||||
userNameInput.sendKeys(userName + "\n");
|
||||
//driver.hideKeyboard();
|
||||
}
|
||||
|
||||
public void typePassword (String password) {
|
||||
passwordInput.clear();
|
||||
passwordInput.sendKeys(password + "\n");
|
||||
//driver.hideKeyboard();
|
||||
}
|
||||
|
||||
public FileListView clickOnConnectButton () {
|
||||
connectButton.click();
|
||||
FileListView fileListView = new FileListView(driver);
|
||||
return fileListView;
|
||||
}
|
||||
|
||||
public AndroidElement gethostUrlInput () {
|
||||
return hostUrlInput;
|
||||
}
|
||||
|
||||
public AndroidElement getUserNameInput () {
|
||||
return userNameInput;
|
||||
}
|
||||
|
||||
public AndroidElement getPasswordInput () {
|
||||
return passwordInput;
|
||||
}
|
||||
|
||||
|
||||
public AndroidElement getServerStatusTextElement () {
|
||||
return serverStatusText;
|
||||
}
|
||||
|
||||
public AndroidElement getAuthStatusText () {
|
||||
return authStatusText;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
public class MenuList {
|
||||
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(name = "Settings")
|
||||
private AndroidElement settingsButton;
|
||||
|
||||
public MenuList (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public SettingsView clickOnSettingsButton () {
|
||||
settingsButton.click();
|
||||
SettingsView settingsView = new SettingsView(driver);
|
||||
return settingsView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import com.owncloud.android.test.ui.actions.Actions;
|
||||
|
||||
public class MoveView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(id = "com.owncloud.android:id/list_root")
|
||||
private AndroidElement filesLayout;
|
||||
|
||||
@AndroidFindBy(name = "Choose")
|
||||
private AndroidElement chooseButton;
|
||||
|
||||
public MoveView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public WaitAMomentPopUp clickOnChoose () {
|
||||
chooseButton.click();
|
||||
WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
|
||||
return waitAMomentPopUp;
|
||||
}
|
||||
|
||||
public AndroidElement scrollTillFindElement (String elementName) {
|
||||
return Actions.scrollTillFindElement (elementName,filesLayout,driver);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
public class NewFolderPopUp {
|
||||
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".resourceId(\"android:id/button1\")")
|
||||
private AndroidElement newFolderOkButton;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".resourceId(\"com.owncloud.android:id/user_input\")")
|
||||
private AndroidElement newFolderNameField;
|
||||
|
||||
public NewFolderPopUp (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public void typeNewFolderName (String newFolderName) {
|
||||
newFolderNameField.clear();
|
||||
newFolderNameField.sendKeys(newFolderName + "\n");
|
||||
//driver.hideKeyboard();
|
||||
}
|
||||
|
||||
public WaitAMomentPopUp clickOnNewFolderOkButton () {
|
||||
newFolderOkButton.click();
|
||||
WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
|
||||
return waitAMomentPopUp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class NotificationView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(name = "Upload succeeded")
|
||||
private static AndroidElement uploadSucceededNotification;
|
||||
|
||||
@AndroidFindBy(name = "Uploading ?")
|
||||
private static AndroidElement uploadingNotification;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().description(\"Clear all notifications.\")")
|
||||
private AndroidElement clearAllNotificationButton;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.FrameLayout\").index(0)")
|
||||
private AndroidElement notificationArea;
|
||||
|
||||
|
||||
public NotificationView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
|
||||
public AndroidElement getUploadSucceededNotification() {
|
||||
return uploadSucceededNotification;
|
||||
}
|
||||
|
||||
public AndroidElement getUploadingNotification() {
|
||||
return uploadingNotification;
|
||||
}
|
||||
|
||||
public AndroidElement getClearAllNotificationButton() {
|
||||
return clearAllNotificationButton;
|
||||
}
|
||||
|
||||
public void tapOnClearAllNotification () {
|
||||
clearAllNotificationButton.tap(1, 1000);
|
||||
}
|
||||
|
||||
public void tapOnBottomNotificationArea(){
|
||||
//TODO. it is not working
|
||||
notificationArea.getSize();
|
||||
notificationArea.tap(1, 1000);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
public class PassCodeRequestView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(0)")
|
||||
private AndroidElement codeElement1;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(1)")
|
||||
private AndroidElement codeElement2;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(2)")
|
||||
private AndroidElement codeElement3;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(3)")
|
||||
private AndroidElement codeElement4;
|
||||
|
||||
public PassCodeRequestView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public void enterPasscode(String codeNumber1, String codeNumber2,
|
||||
String codeNumber3, String codeNumber4){
|
||||
codeElement1
|
||||
.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class PassCodeView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(0)")
|
||||
private AndroidElement codeElement1;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(1)")
|
||||
private AndroidElement codeElement2;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(2)")
|
||||
private AndroidElement codeElement3;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.EditText\").index(3)")
|
||||
private AndroidElement codeElement4;
|
||||
|
||||
@AndroidFindBy(name = "Cancel")
|
||||
private AndroidElement cancelButton;
|
||||
|
||||
public PassCodeView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public PassCodeView enterPasscode(String codeNumber1, String codeNumber2,
|
||||
String codeNumber3, String codeNumber4){
|
||||
codeElement1
|
||||
.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1);
|
||||
return this;
|
||||
}
|
||||
public SettingsView reenterPasscode(String codeNumber1,
|
||||
String codeNumber2, String codeNumber3, String codeNumber4){
|
||||
codeElement1
|
||||
.sendKeys(codeNumber1 + codeNumber1 + codeNumber1 + codeNumber1);
|
||||
SettingsView settingsView = new SettingsView(driver);
|
||||
return settingsView;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
public class RemoveConfirmationView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@AndroidFindBy(name = "Remote and local")
|
||||
private AndroidElement remoteAndLocalButton;
|
||||
|
||||
public RemoveConfirmationView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public WaitAMomentPopUp clickOnRemoteAndLocalButton () {
|
||||
remoteAndLocalButton.click();
|
||||
WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
|
||||
return waitAMomentPopUp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author purigarcia
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.test.ui.models;
|
||||
|
||||
import io.appium.java_client.android.AndroidDriver;
|
||||
import io.appium.java_client.android.AndroidElement;
|
||||
import io.appium.java_client.pagefactory.AndroidFindBy;
|
||||
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
|
||||
|
||||
import org.openqa.selenium.support.CacheLookup;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import com.owncloud.android.test.ui.testSuites.Config;
|
||||
|
||||
public class SettingsView {
|
||||
final AndroidDriver driver;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(name = Config.userAccount)
|
||||
private AndroidElement accountElement;
|
||||
|
||||
@CacheLookup
|
||||
@AndroidFindBy(name = Config.userAccount2)
|
||||
private AndroidElement accountElement2;
|
||||
|
||||
@AndroidFindBy(name = "Delete account")
|
||||
private AndroidElement deleteAccountElement;
|
||||
|
||||
@AndroidFindBy(name = "Change password")
|
||||
private AndroidElement changePasswordElement;
|
||||
|
||||
@AndroidFindBy(name = "Add account")
|
||||
private AndroidElement addAccountElement;
|
||||
|
||||
@AndroidFindBy(uiAutomator = "new UiSelector()"
|
||||
+ ".className(\"android.widget.CheckBox\").index(0)")
|
||||
private AndroidElement passcodeCheckbox;
|
||||
|
||||
public SettingsView (AndroidDriver driver) {
|
||||
this.driver = driver;
|
||||
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
|
||||
}
|
||||
|
||||
public void tapOnAccountElement (int accountPosition, int fingers, int milliSeconds) {
|
||||
if(accountPosition==1)
|
||||
accountElement.tap(fingers, milliSeconds);
|
||||
else
|
||||
accountElement2.tap(fingers, milliSeconds);
|
||||
}
|
||||
|
||||
public void tapOnAddAccount (int fingers, int milliSeconds) {
|
||||
addAccountElement.tap(fingers, milliSeconds);
|
||||
}
|
||||
|
||||
public LoginForm clickOnDeleteAccountElement () {
|
||||
deleteAccountElement.click();
|
||||
LoginForm loginForm = new LoginForm(driver);
|
||||
return loginForm;
|
||||
}
|
||||
|
||||
public LoginForm clickOnChangePasswordElement () {
|
||||
changePasswordElement.click();
|
||||
LoginForm loginForm = new LoginForm(driver);
|
||||
return loginForm;
|
||||
}
|
||||
|
||||
public PassCodeView EnablePassCode(){
|
||||
if(!passcodeCheckbox.isSelected()){
|
||||
passcodeCheckbox.click();
|
||||
}
|
||||
PassCodeView passcodeview = new PassCodeView(driver);
|
||||
return passcodeview;
|
||||
}
|
||||
|
||||
public PassCodeView DisablePassCode(){
|
||||
if(passcodeCheckbox.isSelected()){
|
||||
passcodeCheckbox.click();
|
||||
}
|
||||
PassCodeView passcodeview = new PassCodeView(driver);
|
||||
return passcodeview;
|
||||
}
|
||||
|
||||
}
|
||||