Compare commits
244
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a41be3d3cb | ||
|
|
798093ae19 | ||
|
|
929cb20149 | ||
|
|
2676cd88e5 | ||
|
|
6a177d3dee | ||
|
|
79677f5281 | ||
|
|
7e17aca4ff | ||
|
|
c78e05e873 | ||
|
|
2e9d7ce028 | ||
|
|
a4eafbf757 | ||
|
|
799c3a3163 | ||
|
|
22e7f71e22 | ||
|
|
0ae679f3b5 | ||
|
|
13d602422e | ||
|
|
ed95f486fc | ||
|
|
93ef48add6 | ||
|
|
2c6bfc4c9e | ||
|
|
fd23d58cb9 | ||
|
|
d40a4a1731 | ||
|
|
01edfe6491 | ||
|
|
ae94e219ba | ||
|
|
1958c06b87 | ||
|
|
c543846918 | ||
|
|
6b0023a28a | ||
|
|
bdef26f774 | ||
|
|
a6910a3d13 | ||
|
|
6909794879 | ||
|
|
3f3cef84b1 | ||
|
|
6caa0b927b | ||
|
|
a1253ce117 | ||
|
|
d9ce5b0228 | ||
|
|
df742e0712 | ||
|
|
3d3980a67b | ||
|
|
785433108e | ||
|
|
1f8854769b | ||
|
|
4da88c2acb | ||
|
|
c99cea497d | ||
|
|
521b1cda01 | ||
|
|
aa09934df1 | ||
|
|
82ea0bcd68 | ||
|
|
903b0802a0 | ||
|
|
0e7e85fabf | ||
|
|
23a1a1f3b6 | ||
|
|
e46aacc9c8 | ||
|
|
7a7c1100c3 | ||
|
|
e164da3beb | ||
|
|
e04b94b2f6 | ||
|
|
fddcbbbecd | ||
|
|
d0f474e611 | ||
|
|
086492b6d4 | ||
|
|
5ac1af47c1 | ||
|
|
0c86ed9f77 | ||
|
|
ff6cf2df4a | ||
|
|
9f2b8a73c8 | ||
|
|
c4bbb792dc | ||
|
|
ba84def527 | ||
|
|
d7d2e1916f | ||
|
|
cc66d8857e | ||
|
|
b49e881d43 | ||
|
|
fc62aa42b8 | ||
|
|
fc3a911a14 | ||
|
|
ee4ec654de | ||
|
|
755425cf0c | ||
|
|
c839a5b83e | ||
|
|
112450418a | ||
|
|
f6f0165caf | ||
|
|
0fb3dedef1 | ||
|
|
333dfcb1ed | ||
|
|
f81415dbab | ||
|
|
d5008116db | ||
|
|
994d73f529 | ||
|
|
65df2e82b3 | ||
|
|
ce4ce8db41 | ||
|
|
0f7fe6fd1c | ||
|
|
4724ab3329 | ||
|
|
b40b12e0eb | ||
|
|
5195badfd1 | ||
|
|
fb4b9a932f | ||
|
|
69399c394f | ||
|
|
0e93f00277 | ||
|
|
5f10a9301b | ||
|
|
916ef99313 | ||
|
|
00a045864d | ||
|
|
7ffc8660bb | ||
|
|
0c371b9603 | ||
|
|
dafe42d1c5 | ||
|
|
cbf84e27bb | ||
|
|
f5ab3c9a53 | ||
|
|
d8da2f8007 | ||
|
|
da8d098fa1 | ||
|
|
9e4a9d7027 | ||
|
|
21ebf1568e | ||
|
|
3ac8a8875b | ||
|
|
63fe97e7e0 | ||
|
|
bca12ca282 | ||
|
|
637f117784 | ||
|
|
ca05284cda | ||
|
|
6ade530a26 | ||
|
|
7dc0604b8b | ||
|
|
f996b3f671 | ||
|
|
775671463d | ||
|
|
66b59ddf07 | ||
|
|
9e640c6837 | ||
|
|
914a2b67ca | ||
|
|
3168dc779a | ||
|
|
ef466a372c | ||
|
|
cd65368ead | ||
|
|
58e43e27ef | ||
|
|
c45adad67a | ||
|
|
33087f7b63 | ||
|
|
9aa38b5c3a | ||
|
|
479112204f | ||
|
|
36c22d2001 | ||
|
|
b8e1975824 | ||
|
|
a0c038e9d6 | ||
|
|
a7c8e5e1fb | ||
|
|
591bf4f422 | ||
|
|
d5e70d6cf1 | ||
|
|
68ea0890e0 | ||
|
|
8caa5769e6 | ||
|
|
807537f8fd | ||
|
|
4a9d42b785 | ||
|
|
dbe451e5dd | ||
|
|
26c56114ee | ||
|
|
b27beb7f8f | ||
|
|
46efc82c51 | ||
|
|
0f5febd1ae | ||
|
|
2e5bdd5c4d | ||
|
|
659649791c | ||
|
|
ba26aa741a | ||
|
|
9a8b57c3a6 | ||
|
|
f7202bb13a | ||
|
|
a403109464 | ||
|
|
da4f2a2831 | ||
|
|
16afbeb3eb | ||
|
|
8b0a4ca09c | ||
|
|
d8ba6f3c3a | ||
|
|
1ccccb1ffe | ||
|
|
a0698feb96 | ||
|
|
c1ee0fbbb0 | ||
|
|
77af543b48 | ||
|
|
ec6b1aa37d | ||
|
|
ae256ad13a | ||
|
|
67e1cf39e9 | ||
|
|
98ebd9b8c8 | ||
|
|
dfca74b1e8 | ||
|
|
63f2d407a4 | ||
|
|
df18d6eccc | ||
|
|
eafa49c822 | ||
|
|
54c36092c2 | ||
|
|
10eb9d3920 | ||
|
|
0275b81c7b | ||
|
|
4170370f63 | ||
|
|
06039a9e01 | ||
|
|
d5fba307d7 | ||
|
|
caaf13d678 | ||
|
|
7f7ee24e2b | ||
|
|
681be2bad5 | ||
|
|
37c974f871 | ||
|
|
bbd942c122 | ||
|
|
25704d19a6 | ||
|
|
cc21e815d8 | ||
|
|
ce4a4d3652 | ||
|
|
051345a647 | ||
|
|
c83356cd40 | ||
|
|
625810803f | ||
|
|
e329809802 | ||
|
|
2a64998555 | ||
|
|
79fdf11512 | ||
|
|
b9998c74f0 | ||
|
|
b26f5dc5d2 | ||
|
|
5ed69587e2 | ||
|
|
e765cc8306 | ||
|
|
6ae79355b5 | ||
|
|
b9bc9bc84b | ||
|
|
16836ad119 | ||
|
|
4577084517 | ||
|
|
d969bc816c | ||
|
|
506acd0bbb | ||
|
|
056dc6ece1 | ||
|
|
030d697d85 | ||
|
|
b607d8d176 | ||
|
|
a9027218f5 | ||
|
|
a09b983209 | ||
|
|
ea74122370 | ||
|
|
3da5db1646 | ||
|
|
8585208249 | ||
|
|
7358c3dd09 | ||
|
|
e9d4a31f18 | ||
|
|
322aee0454 | ||
|
|
e3c708c87f | ||
|
|
6a33b72654 | ||
|
|
537e896e57 | ||
|
|
c73ffe0e0c | ||
|
|
31c795faa5 | ||
|
|
cd5c360155 | ||
|
|
415afeb4e3 | ||
|
|
f077a7ef33 | ||
|
|
6978fd35d1 | ||
|
|
65dde41927 | ||
|
|
c1d4d3d484 | ||
|
|
e360ce456a | ||
|
|
96e79e71fb | ||
|
|
614982a642 | ||
|
|
0234e8097f | ||
|
|
57e7eee9ff | ||
|
|
97b924d545 | ||
|
|
e84be102ff | ||
|
|
e387edc696 | ||
|
|
dbef39c436 | ||
|
|
8133875769 | ||
|
|
f97b7e4ea1 | ||
|
|
ba89fcba8b | ||
|
|
7948876041 | ||
|
|
07a9e8c55f | ||
|
|
cdf3ec2680 | ||
|
|
767ca18e5e | ||
|
|
89684052b8 | ||
|
|
e08cb4dec4 | ||
|
|
da79ca4afa | ||
|
|
6eec0a3a1c | ||
|
|
12c86d721d | ||
|
|
f41bd34407 | ||
|
|
2eece7aa33 | ||
|
|
c2d18556c3 | ||
|
|
b2d099c39f | ||
|
|
fb2bd16d4b | ||
|
|
27970e77ed | ||
|
|
45cf8af64f | ||
|
|
0547a0974d | ||
|
|
b810a59167 | ||
|
|
9cd3b6cbae | ||
|
|
09dbb43d74 | ||
|
|
c102b9552a | ||
|
|
347c0edef2 | ||
|
|
ebc50d44b6 | ||
|
|
73e41885c6 | ||
|
|
b6593f783e | ||
|
|
b7712e7580 | ||
|
|
294d23bfb6 | ||
|
|
0435448727 | ||
|
|
68d8499049 | ||
|
|
f52eb08606 | ||
|
|
bdfabd70e9 |
No files matched your search
+3
-3
@@ -1,6 +1,6 @@
|
||||
pipeline:
|
||||
compile:
|
||||
image: nextcloudci/android:android-35
|
||||
image: nextcloudci/android:android-40
|
||||
commands:
|
||||
# build app and assemble APK
|
||||
- sh -c "if [ '${FLAVOR}' != 'Analysis' ]; then ./gradlew assemble${FLAVOR}; fi"
|
||||
@@ -9,7 +9,7 @@ pipeline:
|
||||
FLAVOR: [Generic, Gplay]
|
||||
|
||||
test:
|
||||
image: nextcloudci/android:android-35
|
||||
image: nextcloudci/android:android-40
|
||||
privileged: true
|
||||
commands:
|
||||
- emulator -avd android-27 -no-window -no-audio &
|
||||
@@ -27,7 +27,7 @@ pipeline:
|
||||
FLAVOR: Gplay
|
||||
|
||||
analysis:
|
||||
image: nextcloudci/android:android-37
|
||||
image: nextcloudci/android:android-40
|
||||
commands:
|
||||
- export BRANCH=$(scripts/analysis/getBranchName.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST)
|
||||
- scripts/analysis/analysis-wrapper.sh $GIT_USERNAME $GIT_TOKEN $BRANCH $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST
|
||||
|
||||
@@ -20,6 +20,10 @@ group_defaults:
|
||||
enabled: false
|
||||
reset_on_reopened:
|
||||
enabled: true
|
||||
conditions:
|
||||
labels:
|
||||
exclude:
|
||||
- dependencies
|
||||
|
||||
groups:
|
||||
code-review:
|
||||
|
||||
+30
-6
@@ -1,3 +1,27 @@
|
||||
## 3.3.0 (September, 19, 2018)
|
||||
- Support for Trashbin (Nc14+)
|
||||
- Media streaming (Nc14+)
|
||||
- New media detection for AutoUpload
|
||||
- Improved TalkBack screenreader support
|
||||
- Show outdated server warning for server <NC12
|
||||
- Add support for device credentials
|
||||
- Show offline / maintenance info
|
||||
- Improved activities
|
||||
- Improved file detail / sharing with comments
|
||||
- Improved Share link creation via bottom sheet
|
||||
- Improved Notification, supporting actions
|
||||
- Minor UI/UX improvements
|
||||
- Many bug fixes
|
||||
|
||||
## 3.2.4 (September, 04, 2018)
|
||||
- Fix push notification on gplay release
|
||||
|
||||
## 3.2.3 (August, 21, 2018)
|
||||
- Fix crash on Android Android 4.x
|
||||
|
||||
## 3.2.2 (August, 20, 2018)
|
||||
- New simple signup screen
|
||||
|
||||
## 3.2.1 (June, 11, 2018)
|
||||
- Enhanced file detail/sharing screen for mail-shares
|
||||
- Fix local sorting and file selection
|
||||
@@ -13,27 +37,27 @@
|
||||
- minor UI/UX improvements
|
||||
- many bug fixes
|
||||
|
||||
## 3.1.0 (Apr, 22, 2018)
|
||||
## 3.1.0 (April, 22, 2018)
|
||||
- enhance support for 8.x
|
||||
- speed improvements
|
||||
- minor UI/UX improvements
|
||||
- many bug fixes
|
||||
|
||||
## 3.0.3 (Mar, 05, 2018)
|
||||
## 3.0.3 (March, 05, 2018)
|
||||
- Fix creating folders in auto upload
|
||||
|
||||
## 3.0.2 (Feb, 27, 2018)
|
||||
## 3.0.2 (February, 27, 2018)
|
||||
- Fix crash on old android versions
|
||||
- Fix E2E
|
||||
- Fix crash on old server
|
||||
|
||||
## 3.0.1 (Feb, 14, 2018)
|
||||
## 3.0.1 (February, 14, 2018)
|
||||
- Bugfix E2E
|
||||
- Fix SSL via PlayStore updater
|
||||
- Fix push notification
|
||||
- New android lib, fixing wrong user agent
|
||||
|
||||
## 3.0.0 (Feb, 08, 2018)
|
||||
## 3.0.0 (February, 08, 2018)
|
||||
- End to end encryption
|
||||
- Screen adapted images instead of downloading
|
||||
- direct access to operations for single files
|
||||
@@ -49,7 +73,7 @@
|
||||
- UI enhancements
|
||||
- bug fixes
|
||||
|
||||
## 2.0.0 (Oct, 17, 2017)
|
||||
## 2.0.0 (October, 17, 2017)
|
||||
- Account-wide search (Nc 12+)
|
||||
- Auto upload available on Android 4+
|
||||
- Separation between Image & Video for Auto upload
|
||||
|
||||
+23
-21
@@ -17,7 +17,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.4'
|
||||
classpath 'org.codehaus.groovy:groovy-all:2.4.12'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.2') {
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.3') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
}
|
||||
@@ -30,13 +30,14 @@ apply plugin: 'findbugs'
|
||||
apply plugin: 'jacoco-android'
|
||||
|
||||
configurations.all {
|
||||
exclude group: 'com.google.firebase', module: 'firebase-core'
|
||||
// check for updates every build
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
}
|
||||
|
||||
ext {
|
||||
supportLibraryVersion = '27.1.1'
|
||||
jacocoVersion = "0.7.4.201502262128"
|
||||
jacocoVersion = "0.8.2"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
@@ -57,9 +58,9 @@ repositories {
|
||||
|
||||
// semantic versioning for version code
|
||||
def versionMajor = 3
|
||||
def versionMinor = 3
|
||||
def versionMinor = 4
|
||||
def versionPatch = 0
|
||||
def versionBuild = 0 // 0-49=Alpha / 50-98=RC / 99=stable
|
||||
def versionBuild = 0 // 0-50=Alpha / 51-98=RC / 99=stable
|
||||
|
||||
def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
|
||||
if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
|
||||
@@ -97,8 +98,8 @@ android {
|
||||
|
||||
if (versionBuild > 98) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
} else if (versionBuild > 49) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-49)
|
||||
} else if (versionBuild > 50) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-50)
|
||||
} else {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha"+(versionBuild+1)
|
||||
}
|
||||
@@ -129,8 +130,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20180903
|
||||
versionName "20180903"
|
||||
versionCode 20180920
|
||||
versionName "20180920"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,6 +213,7 @@ dependencies {
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
// implementation project('nextcloud-android-library')
|
||||
genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
|
||||
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
|
||||
implementation "com.android.support:support-v4:${supportLibraryVersion}"
|
||||
@@ -220,33 +222,33 @@ dependencies {
|
||||
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
|
||||
implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
|
||||
implementation "com.android.support:exifinterface:${supportLibraryVersion}"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:v2.0.0'
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.2.0'
|
||||
implementation 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.5'
|
||||
implementation 'commons-io:commons-io:2.6'
|
||||
implementation 'com.github.evernote:android-job:v1.2.5'
|
||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.4'
|
||||
implementation 'org.lukhnos:nnio:0.2'
|
||||
implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.afollestad:sectioned-recyclerview:0.5.0'
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
|
||||
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
|
||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.15'
|
||||
|
||||
implementation 'org.parceler:parceler-api:1.1.9'
|
||||
annotationProcessor 'org.parceler:parceler:1.1.9'
|
||||
implementation 'org.parceler:parceler-api:1.1.11'
|
||||
annotationProcessor 'org.parceler:parceler:1.1.11'
|
||||
implementation ('com.github.bumptech.glide:glide:3.7.0') {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
implementation 'com.caverock:androidsvg:1.3'
|
||||
implementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.2.5'
|
||||
testImplementation 'org.mockito:mockito-core:2.22.0'
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
androidTestImplementation 'com.android.support.test:rules:1.0.2'
|
||||
@@ -260,12 +262,12 @@ dependencies {
|
||||
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
implementation 'org.jetbrains:annotations:15.0'
|
||||
implementation 'org.jetbrains:annotations:16.0.3'
|
||||
|
||||
androidTestImplementation 'tools.fastlane:screengrab:1.0.0'
|
||||
androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
|
||||
|
||||
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.4.4'
|
||||
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.2'
|
||||
findbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.8.0'
|
||||
findbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.3'
|
||||
|
||||
// jacocoAnt "org.jacoco:org.jacoco.ant:${jacocoVersion}"
|
||||
// jacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 16 16" width="16" height="16">
|
||||
<path
|
||||
d="m9.025 1.08c-3.95 0-6.535 3.447-6.364 6.72h-2.161l3.904 3.92 4.08-3.874h-2.147c-0.237-1.7 1.163-3.114 2.689-3.092 1.595 0.024 2.8 1.23 2.8 2.734 0.09 1.594-1.63 3.428-3.966 2.53 0 1.23 0.003 2.545 0 3.765 4.19 0.83 7.64-2.51 7.64-6.25 0-3.563-2.92-6.453-6.475-6.453z"/>
|
||||
<path style="fill:#757575"
|
||||
d="m9.025 1.08c-3.95 0-6.535 3.447-6.364 6.72h-2.161l3.904 3.92 4.08-3.874h-2.147c-0.237-1.7 1.163-3.114 2.689-3.092 1.595 0.024 2.8 1.23 2.8 2.734 0.09 1.594-1.63 3.428-3.966 2.53 0 1.23 0.003 2.545 0 3.765 4.19 0.83 7.64-2.51 7.64-6.25 0-3.563-2.92-6.453-6.475-6.453z"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 396 B After Width: | Height: | Size: 419 B |
+1
-2
@@ -1,4 +1,3 @@
|
||||
dependencies {
|
||||
implementation "com.google.firebase:firebase-messaging:17.1.0"
|
||||
implementation "com.google.android.gms:play-services-gcm:15.0.1"
|
||||
implementation "com.google.firebase:firebase-messaging:17.3.0"
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
-optimizationpasses 5
|
||||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-dontpreverify
|
||||
-verbose
|
||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
-keep public class * extends android.app.backup.BackupAgentHelper
|
||||
-keep public class * extends android.preference.Preference
|
||||
-keep public class com.android.vending.licensing.ILicensingService
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-keep class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
||||
|
||||
-keepattributes InnerClasses
|
||||
@@ -21,14 +21,14 @@ lintValue=$?
|
||||
echo "Branch: $3"
|
||||
|
||||
if [ $3 = "master" ]; then
|
||||
echo "New findbugs result for master at: https://nextcloud.kaminsky.me/index.php/s/fYZa7NeBsnmFZQD"
|
||||
echo "New findbugs result for master at: https://www.kaminsky.me/nc-dev/client-findbugs/master.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/master.html --upload-file build/reports/findbugs/findbugs.html
|
||||
|
||||
summary=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html | head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s'/Summary/FindBugs (master)/' | tr "\"" "\'" | tr -d "\r\n")
|
||||
curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/findbugs.html
|
||||
|
||||
if [ $lintValue -ne 1 ]; then
|
||||
echo "New lint result for master at: https://nextcloud.kaminsky.me/index.php/s/tXwtChzyqMj6I8v"
|
||||
echo "New lint result for master at: https://www.kaminsky.me/nc-dev/client-lint/master.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/master.html --upload-file build/reports/lint/lint.html
|
||||
exit 0
|
||||
fi
|
||||
@@ -36,10 +36,10 @@ else
|
||||
if [ -e $6 ]; then
|
||||
6="master-"$(date +%F)
|
||||
fi
|
||||
echo "New lint results at https://nextcloud.kaminsky.me/index.php/s/tXwtChzyqMj6I8v ->" $6.html
|
||||
echo "New lint results at https://www.kaminsky.me/nc-dev/client-lint/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/droneLogs/$6.html --upload-file build/reports/lint/lint.html
|
||||
|
||||
echo "New findbugs results at https://nextcloud.kaminsky.me/index.php/s/fYZa7NeBsnmFZQD ->" $6.html
|
||||
echo "New findbugs results at https://www.kaminsky.me/nc-dev/client-findbugs/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/findbugs/$6.html --upload-file build/reports/findbugs/findbugs.html
|
||||
|
||||
# delete all old comments
|
||||
@@ -64,9 +64,9 @@ else
|
||||
lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
||||
lintErrorOld=$(grep "[0-9]* error" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
|
||||
lintWarningOld=$(grep "[0-9]* warning" scripts/analysis/lint-results.txt -o | cut -f1 -d" ")
|
||||
lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td>Master</td><td>PR</td></tr><tr class='tablerow1'><td>Warnings</td><td>"$lintWarningOld"</td><td>"$lintWarningNew"</td></tr><tr class='tablerow0'><td>Errors</td><td>"$lintErrorOld"</td><td>"$lintErrorNew"</td></tr></table>"
|
||||
findbugsResultNew=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s'/Summary/FindBugs (new)/' | tr "\"" "\'" | tr -d "\n")
|
||||
findbugsResultOld=$(curl 2>/dev/null https://nextcloud.kaminsky.me/index.php/s/YaHngKMM6ERmBeg/download | tr "\"" "\'" | tr -d "\r\n")
|
||||
lintResult="<h1>Lint</h1><table width='500' cellpadding='5' cellspacing='2'><tr class='tablerow0'><td>Type</td><td><a href='https://www.kaminsky.me/nc-dev/client-lint/master.html'>Master</a></td><td><a href='https://www.kaminsky.me/nc-dev/client-lint/"$6".html'>PR</a></td></tr><tr class='tablerow1'><td>Warnings</td><td>"$lintWarningOld"</td><td>"$lintWarningNew"</td></tr><tr class='tablerow0'><td>Errors</td><td>"$lintErrorOld"</td><td>"$lintErrorNew"</td></tr></table>"
|
||||
findbugsResultNew=$(sed -n "/<h1>Summary<\/h1>/,/<h1>Warnings<\/h1>/p" build/reports/findbugs/findbugs.html |head -n-1 | sed s'/<\/a>//'g | sed s'/<a.*>//'g | sed s"#Summary#<a href=\"https://www.kaminsky.me/nc-dev/client-findbugs/$6.html\">FindBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
|
||||
findbugsResultOld=$(curl 2>/dev/null https://nextcloud.kaminsky.me/index.php/s/YaHngKMM6ERmBeg/download | tr "\"" "\'" | tr -d "\r\n" | sed s'#FindBugs#<a href=\"https://www.kaminsky.me/nc-dev/client-findbugs/master.html">FindBugs</a>#'| tr "\"" "\'" | tr -d "\n")
|
||||
curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage \" }"
|
||||
|
||||
if [ $checkLibrary -eq 1 ]; then
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 93 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 94 warnings</span>
|
||||
@@ -258,6 +258,19 @@ public class EncryptionTestIT {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSHA512() {
|
||||
// sent to 3rd party app in cleartext
|
||||
String token = "4ae5978bf5354cd284b539015d442141";
|
||||
String salt = EncryptionUtils.encodeBytesToBase64String(EncryptionUtils.randomBytes(EncryptionUtils.saltLength));
|
||||
|
||||
// stored in database
|
||||
String hashedToken = EncryptionUtils.generateSHA512(token, salt);
|
||||
|
||||
// check: use passed cleartext and salt to verify hashed token
|
||||
assertTrue(EncryptionUtils.verifySHA512(hashedToken, token));
|
||||
}
|
||||
|
||||
|
||||
// Helper
|
||||
private boolean compareJsonStrings(String expected, String actual) {
|
||||
@@ -362,4 +375,4 @@ public class EncryptionTestIT {
|
||||
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Приложението Nextcloud за Android осигурява достъп до всичките ви файлове в Next
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -0,0 +1 @@
|
||||
Hệ thống là ứng dụng Android cho phép modile truy cập tất cả các tập tin của bạn
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -28,9 +28,12 @@ import com.owncloud.android.db.PreferenceManager;
|
||||
|
||||
import java.security.Key;
|
||||
|
||||
public class PushUtils {
|
||||
public final class PushUtils {
|
||||
public static final String KEY_PUSH = "push";
|
||||
|
||||
private PushUtils() {
|
||||
}
|
||||
|
||||
public static void pushRegistrationToServer() {
|
||||
// do nothing
|
||||
}
|
||||
@@ -44,7 +47,7 @@ public class PushUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
public static SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,13 @@ import android.util.Log;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
|
||||
public class GooglePlayUtils {
|
||||
public final class GooglePlayUtils {
|
||||
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
|
||||
private static final String TAG = "GooglePlayUtils";
|
||||
|
||||
private GooglePlayUtils() {
|
||||
}
|
||||
|
||||
public static boolean checkPlayServices(Activity activity) {
|
||||
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
|
||||
int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
|
||||
|
||||
@@ -71,7 +71,7 @@ import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Locale;
|
||||
|
||||
public class PushUtils {
|
||||
public final class PushUtils {
|
||||
|
||||
public static final String KEY_PUSH = "push";
|
||||
private static final String TAG = "PushUtils";
|
||||
@@ -81,6 +81,9 @@ public class PushUtils {
|
||||
private static final String KEYPAIR_PUB_EXTENSION = ".pub";
|
||||
private static ArbitraryDataProvider arbitraryDataProvider;
|
||||
|
||||
private PushUtils() {
|
||||
}
|
||||
|
||||
public static String generateSHA512Hash(String pushToken) {
|
||||
MessageDigest messageDigest = null;
|
||||
try {
|
||||
@@ -295,7 +298,6 @@ public class PushUtils {
|
||||
fileInputStream = new FileInputStream(path);
|
||||
byte[] bytes = new byte[fileInputStream.available()];
|
||||
fileInputStream.read(bytes);
|
||||
fileInputStream.close();
|
||||
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
|
||||
@@ -315,6 +317,14 @@ public class PushUtils {
|
||||
Log_OC.d(TAG, "InvalidKeySpecException while reading the key");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log_OC.d(TAG, "RSA algorithm not supported");
|
||||
} finally {
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error closing input stream during reading key from file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -331,12 +341,19 @@ public class PushUtils {
|
||||
}
|
||||
keyFileOutputStream = new FileOutputStream(path);
|
||||
keyFileOutputStream.write(encoded);
|
||||
keyFileOutputStream.close();
|
||||
return 0;
|
||||
} catch (FileNotFoundException e) {
|
||||
Log_OC.d(TAG, "Failed to save key to file");
|
||||
} catch (IOException e) {
|
||||
Log_OC.d(TAG, "Failed to save key to file via IOException");
|
||||
} finally {
|
||||
if (keyFileOutputStream != null) {
|
||||
try {
|
||||
keyFileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error closing input stream during reading key from file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -400,7 +417,7 @@ public class PushUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
public static SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
Signature signature = null;
|
||||
PublicKey publicKey;
|
||||
SignatureVerification signatureVerification = new SignatureVerification();
|
||||
@@ -413,7 +430,6 @@ public class PushUtils {
|
||||
Gson gson = new Gson();
|
||||
PushConfigurationState pushArbitraryData;
|
||||
|
||||
|
||||
try {
|
||||
signature = Signature.getInstance("SHA512withRSA");
|
||||
if (accounts.length > 0) {
|
||||
@@ -444,7 +460,7 @@ public class PushUtils {
|
||||
return signatureVerification;
|
||||
}
|
||||
|
||||
private Key readKeyFromString(boolean readPublicKey, String keyString) {
|
||||
private static Key readKeyFromString(boolean readPublicKey, String keyString) {
|
||||
String modifiedKey;
|
||||
if (readPublicKey) {
|
||||
modifiedKey = keyString.replaceAll("\\n", "").replace("-----BEGIN PUBLIC KEY-----",
|
||||
@@ -464,7 +480,6 @@ public class PushUtils {
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decode(modifiedKey, Base64.DEFAULT));
|
||||
return keyFactory.generatePrivate(keySpec);
|
||||
}
|
||||
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.d("TAG", "No such algorithm while reading key from string");
|
||||
} catch (InvalidKeySpecException e) {
|
||||
@@ -473,5 +488,4 @@ public class PushUtils {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -66,6 +66,7 @@
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
|
||||
|
||||
<application
|
||||
android:name=".MainApp"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@@ -295,6 +296,18 @@
|
||||
<activity android:name=".ui.activity.ManageSpaceActivity"
|
||||
android:label="@string/manage_space_title"
|
||||
android:theme="@style/Theme.ownCloud" />
|
||||
|
||||
|
||||
<service
|
||||
android:name=".services.AccountManagerService"
|
||||
android:enabled="true"
|
||||
android:exported="true" >
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.SsoGrantPermissionActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.ownCloud.Dialog.NoTitle" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,25 @@
|
||||
/***
|
||||
Copyright (c) 2008-2011 CommonsWare, LLC
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
use this file except in compliance with the License. You may obtain a copy
|
||||
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required
|
||||
by applicable law or agreed to in writing, software distributed under the
|
||||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||
OF ANY KIND, either express or implied. See the License for the specific
|
||||
language governing permissions and limitations under the License.
|
||||
|
||||
From _The Busy Coder's Guide to Advanced Android Development_
|
||||
http://commonsware.com/AdvAndroid
|
||||
|
||||
|
||||
More information here: https://github.com/abeluck/android-streams-ipc
|
||||
*/
|
||||
|
||||
package com.nextcloud.android.sso.aidl;
|
||||
|
||||
// Declare the interface.
|
||||
interface IInputStreamService {
|
||||
|
||||
ParcelFileDescriptor performNextcloudRequest(in ParcelFileDescriptor input);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.nextcloud.android.sso;
|
||||
|
||||
public class Constants {
|
||||
|
||||
// Authenticator related constants
|
||||
public static final String SSO_USERNAME = "username";
|
||||
public static final String SSO_TOKEN = "token";
|
||||
public static final String SSO_SERVER_URL = "server_url";
|
||||
public static final String SSO_SHARED_PREFERENCE = "single-sign-on";
|
||||
public static final String NEXTCLOUD_SSO_EXCEPTION = "NextcloudSsoException";
|
||||
public static final String NEXTCLOUD_SSO = "NextcloudSSO";
|
||||
public static final String NEXTCLOUD_FILES_ACCOUNT = "NextcloudFilesAccount";
|
||||
|
||||
|
||||
// Custom Exceptions
|
||||
public static final String EXCEPTION_INVALID_TOKEN = "CE_1";
|
||||
public static final String EXCEPTION_ACCOUNT_NOT_FOUND = "CE_2";
|
||||
public static final String EXCEPTION_UNSUPPORTED_METHOD = "CE_3";
|
||||
public static final String EXCEPTION_INVALID_REQUEST_URL = "CE_4";
|
||||
public static final String EXCEPTION_HTTP_REQUEST_FAILED = "CE_5";
|
||||
public static final String EXCEPTION_ACCOUNT_ACCESS_DECLINED = "CE_6";
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Nextcloud SingleSignOn
|
||||
*
|
||||
* @author David Luhmer
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
* More information here: https://github.com/abeluck/android-streams-ipc
|
||||
*/
|
||||
|
||||
package com.nextcloud.android.sso;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Binder;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nextcloud.android.sso.aidl.IInputStreamService;
|
||||
import com.nextcloud.android.sso.aidl.NextcloudRequest;
|
||||
import com.nextcloud.android.sso.aidl.ParcelFileDescriptorUtil;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
|
||||
import org.apache.commons.httpclient.HttpMethodBase;
|
||||
import org.apache.commons.httpclient.NameValuePair;
|
||||
import org.apache.commons.httpclient.methods.DeleteMethod;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_NOT_FOUND;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_HTTP_REQUEST_FAILED;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_INVALID_REQUEST_URL;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_INVALID_TOKEN;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_UNSUPPORTED_METHOD;
|
||||
import static com.nextcloud.android.sso.Constants.SSO_SHARED_PREFERENCE;
|
||||
|
||||
|
||||
/**
|
||||
* Stream binder to pass usable InputStreams across the process boundary in Android.
|
||||
*/
|
||||
public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
|
||||
private final static String TAG = "InputStreamBinder";
|
||||
private static final String CONTENT_TYPE_APPLICATION_JSON = "application/json";
|
||||
private static final String CHARSET_UTF8 = "UTF-8";
|
||||
|
||||
private static final int HTTP_STATUS_CODE_OK = 200;
|
||||
private static final int HTTP_STATUS_CODE_MULTIPLE_CHOICES = 300;
|
||||
|
||||
private static final char PATH_SEPARATOR = '/';
|
||||
private Context context;
|
||||
|
||||
public InputStreamBinder(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
private NameValuePair[] convertMapToNVP(Map<String, String> map) {
|
||||
NameValuePair[] nvp = new NameValuePair[map.size()];
|
||||
int i = 0;
|
||||
for (String key : map.keySet()) {
|
||||
nvp[i] = new NameValuePair(key, map.get(key));
|
||||
i++;
|
||||
}
|
||||
return nvp;
|
||||
}
|
||||
|
||||
public ParcelFileDescriptor performNextcloudRequest(ParcelFileDescriptor input) {
|
||||
// read the input
|
||||
final InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input);
|
||||
|
||||
Exception exception = null;
|
||||
InputStream httpStream = new InputStream() {
|
||||
@Override
|
||||
public int read() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
try {
|
||||
// Start request and catch exceptions
|
||||
NextcloudRequest request = deserializeObjectAndCloseStream(is);
|
||||
httpStream = processRequest(request);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
exception = e;
|
||||
}
|
||||
|
||||
try {
|
||||
// Write exception to the stream followed by the actual network stream
|
||||
InputStream exceptionStream = serializeObjectToInputStream(exception);
|
||||
InputStream resultStream = new java.io.SequenceInputStream(exceptionStream, httpStream);
|
||||
return ParcelFileDescriptorUtil.pipeFrom(resultStream, thread -> Log.d(TAG, "Done sending result"));
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T extends Serializable> ByteArrayInputStream serializeObjectToInputStream(T obj) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(obj);
|
||||
oos.flush();
|
||||
oos.close();
|
||||
return new ByteArrayInputStream(baos.toByteArray());
|
||||
}
|
||||
|
||||
private <T extends Serializable> T deserializeObjectAndCloseStream(InputStream is) throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream ois = new ObjectInputStream(is);
|
||||
T result = (T) ois.readObject();
|
||||
is.close();
|
||||
ois.close();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private InputStream processRequest(final NextcloudRequest request) throws UnsupportedOperationException, com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException {
|
||||
Account account = AccountUtils.getOwnCloudAccountByName(context, request.getAccountName()); // TODO handle case that account is not found!
|
||||
if(account == null) {
|
||||
throw new IllegalStateException(EXCEPTION_ACCOUNT_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Validate token
|
||||
if (!isValid(request)) {
|
||||
throw new IllegalStateException(EXCEPTION_INVALID_TOKEN);
|
||||
}
|
||||
|
||||
// Validate URL
|
||||
if(request.getUrl().length() == 0 || request.getUrl().charAt(0) != PATH_SEPARATOR) {
|
||||
throw new IllegalStateException(EXCEPTION_INVALID_REQUEST_URL, new IllegalStateException("URL need to start with a /"));
|
||||
}
|
||||
|
||||
OwnCloudClientManager ownCloudClientManager = OwnCloudClientManagerFactory.getDefaultSingleton();
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(account, context);
|
||||
OwnCloudClient client = ownCloudClientManager.getClientFor(ocAccount, context);
|
||||
|
||||
String requestUrl = client.getBaseUri() + request.getUrl();
|
||||
HttpMethodBase method;
|
||||
|
||||
switch (request.getMethod()) {
|
||||
case "GET":
|
||||
method = new GetMethod(requestUrl);
|
||||
break;
|
||||
|
||||
case "POST":
|
||||
method = new PostMethod(requestUrl);
|
||||
if (request.getRequestBody() != null) {
|
||||
StringRequestEntity requestEntity = new StringRequestEntity(
|
||||
request.getRequestBody(),
|
||||
CONTENT_TYPE_APPLICATION_JSON,
|
||||
CHARSET_UTF8);
|
||||
((PostMethod) method).setRequestEntity(requestEntity);
|
||||
}
|
||||
break;
|
||||
|
||||
case "PUT":
|
||||
method = new PutMethod(requestUrl);
|
||||
if (request.getRequestBody() != null) {
|
||||
StringRequestEntity requestEntity = new StringRequestEntity(
|
||||
request.getRequestBody(),
|
||||
CONTENT_TYPE_APPLICATION_JSON,
|
||||
CHARSET_UTF8);
|
||||
((PutMethod) method).setRequestEntity(requestEntity);
|
||||
}
|
||||
break;
|
||||
|
||||
case "DELETE":
|
||||
method = new DeleteMethod(requestUrl);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new UnsupportedOperationException(EXCEPTION_UNSUPPORTED_METHOD);
|
||||
|
||||
}
|
||||
|
||||
method.setQueryString(convertMapToNVP(request.getParameter()));
|
||||
method.addRequestHeader("OCS-APIREQUEST", "true");
|
||||
|
||||
client.setFollowRedirects(request.isFollowRedirects());
|
||||
int status = client.executeMethod(method);
|
||||
|
||||
// Check if status code is 2xx --> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success
|
||||
if (status >= HTTP_STATUS_CODE_OK && status < HTTP_STATUS_CODE_MULTIPLE_CHOICES) {
|
||||
return method.getResponseBodyAsStream();
|
||||
} else {
|
||||
throw new IllegalStateException(EXCEPTION_HTTP_REQUEST_FAILED, new IllegalStateException(String.valueOf(status)));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValid(NextcloudRequest request) {
|
||||
String callingPackageName = context.getPackageManager().getNameForUid(Binder.getCallingUid());
|
||||
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(SSO_SHARED_PREFERENCE,
|
||||
Context.MODE_PRIVATE);
|
||||
String hash = sharedPreferences.getString(callingPackageName, "");
|
||||
return validateToken(hash, request.getToken());
|
||||
}
|
||||
|
||||
private boolean validateToken(String hash, String token) {
|
||||
String salt = hash.split("\\$")[1]; // TODO extract "$"
|
||||
|
||||
String newHash = EncryptionUtils.generateSHA512(token, salt);
|
||||
|
||||
// As discussed with Lukas R. at the Nextcloud Conf 2018, always compare whole strings
|
||||
// and don't exit prematurely if the string does not match anymore to prevent timing-attacks
|
||||
return isEqual(hash.getBytes(), newHash.getBytes());
|
||||
}
|
||||
|
||||
// Taken from http://codahale.com/a-lesson-in-timing-attacks/
|
||||
private static boolean isEqual(byte[] a, byte[] b) {
|
||||
if (a.length != b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
result |= a[i] ^ b[i];
|
||||
}
|
||||
return result == 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Nextcloud SingleSignOn
|
||||
*
|
||||
* @author David Luhmer
|
||||
*
|
||||
* 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.nextcloud.android.sso.aidl;
|
||||
|
||||
public interface IThreadListener {
|
||||
|
||||
void onThreadFinished(final Thread thread);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Nextcloud SingleSignOn
|
||||
*
|
||||
* @author David Luhmer
|
||||
*
|
||||
* 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.nextcloud.android.sso.aidl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NextcloudRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 215521212534240L; //assign a long value
|
||||
|
||||
private String method;
|
||||
private Map<String, List<String>> header = new HashMap<>();
|
||||
private Map<String, String> parameter = new HashMap<>();
|
||||
private String requestBody;
|
||||
private String url;
|
||||
private String token;
|
||||
private String packageName;
|
||||
private String accountName;
|
||||
private boolean followRedirects;
|
||||
|
||||
private NextcloudRequest() { }
|
||||
|
||||
public static class Builder {
|
||||
private NextcloudRequest ncr;
|
||||
|
||||
public Builder() {
|
||||
ncr = new NextcloudRequest();
|
||||
}
|
||||
|
||||
public NextcloudRequest build() {
|
||||
return ncr;
|
||||
}
|
||||
|
||||
public Builder setMethod(String method) {
|
||||
ncr.method = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setHeader(Map<String, List<String>> header) {
|
||||
ncr.header = header;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setParameter(Map<String, String> parameter) {
|
||||
ncr.parameter = parameter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRequestBody(String requestBody) {
|
||||
ncr.requestBody = requestBody;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setUrl(String url) {
|
||||
ncr.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setToken(String token) {
|
||||
ncr.token = token;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAccountName(String accountName) {
|
||||
ncr.accountName = accountName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default value: true
|
||||
* @param followRedirects
|
||||
* @return
|
||||
*/
|
||||
public Builder setFollowRedirects(boolean followRedirects) {
|
||||
ncr.followRedirects = followRedirects;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameter() {
|
||||
return this.parameter;
|
||||
}
|
||||
|
||||
public String getRequestBody() {
|
||||
return this.requestBody;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return this.packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getAccountName() {
|
||||
return this.accountName;
|
||||
}
|
||||
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
public boolean isFollowRedirects() {
|
||||
return this.followRedirects;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Nextcloud SingleSignOn
|
||||
*
|
||||
* @author David Luhmer
|
||||
*
|
||||
* 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.nextcloud.android.sso.aidl;
|
||||
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public final class ParcelFileDescriptorUtil {
|
||||
|
||||
private ParcelFileDescriptorUtil() { }
|
||||
|
||||
public static ParcelFileDescriptor pipeFrom(InputStream inputStream, IThreadListener listener)
|
||||
throws IOException {
|
||||
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
|
||||
ParcelFileDescriptor readSide = pipe[0];
|
||||
ParcelFileDescriptor writeSide = pipe[1];
|
||||
|
||||
// start the transfer thread
|
||||
new TransferThread(inputStream, new ParcelFileDescriptor.AutoCloseOutputStream(writeSide),
|
||||
listener)
|
||||
.start();
|
||||
|
||||
return readSide;
|
||||
}
|
||||
|
||||
public static ParcelFileDescriptor pipeTo(OutputStream outputStream, IThreadListener listener)
|
||||
throws IOException {
|
||||
ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
|
||||
ParcelFileDescriptor readSide = pipe[0];
|
||||
ParcelFileDescriptor writeSide = pipe[1];
|
||||
|
||||
// start the transfer thread
|
||||
new TransferThread(new ParcelFileDescriptor.AutoCloseInputStream(readSide), outputStream,
|
||||
listener)
|
||||
.start();
|
||||
|
||||
return writeSide;
|
||||
}
|
||||
|
||||
public static class TransferThread extends Thread {
|
||||
private static final String TAG = TransferThread.class.getCanonicalName();
|
||||
private final InputStream mIn;
|
||||
private final OutputStream mOut;
|
||||
private final IThreadListener mListener;
|
||||
|
||||
TransferThread(InputStream in, OutputStream out, IThreadListener listener) {
|
||||
super("ParcelFileDescriptor Transfer Thread");
|
||||
mIn = in;
|
||||
mOut = out;
|
||||
mListener = listener;
|
||||
setDaemon(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
|
||||
try {
|
||||
while ((len = mIn.read(buf)) > 0) {
|
||||
mOut.write(buf, 0, len);
|
||||
}
|
||||
mOut.flush(); // just to be safe
|
||||
} catch (IOException e) {
|
||||
Log.e("TransferThread", "writing failed");
|
||||
} finally {
|
||||
try {
|
||||
mIn.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
}
|
||||
try {
|
||||
mOut.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
if (mListener != null) {
|
||||
mListener.onThreadFinished(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class MainApp extends MultiDexApplication {
|
||||
|
||||
private static String storagePath;
|
||||
|
||||
private static boolean mOnlyOnDevice = false;
|
||||
private static boolean mOnlyOnDevice;
|
||||
|
||||
private SharedPreferences appPrefs;
|
||||
@SuppressWarnings("unused")
|
||||
@@ -154,7 +154,7 @@ public class MainApp extends MultiDexApplication {
|
||||
Log_OC.d("Debug", "start logging");
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
try {
|
||||
Method m = StrictMode.class.getMethod("disableDeathOnFileUriExposure");
|
||||
m.invoke(null);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -57,7 +57,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
public static final String KEY_REQUIRED_FEATURES = "requiredFeatures";
|
||||
public static final String KEY_LOGIN_OPTIONS = "loginOptions";
|
||||
public static final String KEY_ACCOUNT = "account";
|
||||
|
||||
|
||||
private static final String TAG = AccountAuthenticator.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
@@ -75,16 +75,15 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
*/
|
||||
@Override
|
||||
public Bundle addAccount(AccountAuthenticatorResponse response,
|
||||
String accountType, String authTokenType,
|
||||
String[] requiredFeatures, Bundle options)
|
||||
throws NetworkErrorException {
|
||||
String accountType, String authTokenType,
|
||||
String[] requiredFeatures, Bundle options) {
|
||||
Log_OC.i(TAG, "Adding account with type " + accountType + " and auth token " + authTokenType);
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
|
||||
|
||||
AccountManager accountManager = AccountManager.get(mContext);
|
||||
Account[] accounts = accountManager.getAccountsByType(MainApp.getAccountType(mContext));
|
||||
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
|
||||
if (mContext.getResources().getBoolean(R.bool.multiaccount_support) || accounts.length < 1) {
|
||||
try {
|
||||
validateAccountType(accountType);
|
||||
@@ -104,16 +103,13 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
setIntentFlags(intent);
|
||||
|
||||
bundle.putParcelable(AccountManager.KEY_INTENT, intent);
|
||||
|
||||
} else {
|
||||
|
||||
// Return an error
|
||||
bundle.putInt(AccountManager.KEY_ERROR_CODE, AccountManager.ERROR_CODE_UNSUPPORTED_OPERATION);
|
||||
final String message = String.format(mContext.getString(R.string.auth_unsupported_multiaccount), mContext.getString(R.string.app_name));
|
||||
bundle.putString(AccountManager.KEY_ERROR_MESSAGE, message);
|
||||
|
||||
mHandler.post(() -> Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show());
|
||||
|
||||
}
|
||||
|
||||
return bundle;
|
||||
@@ -124,7 +120,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
*/
|
||||
@Override
|
||||
public Bundle confirmCredentials(AccountAuthenticatorResponse response,
|
||||
Account account, Bundle options) throws NetworkErrorException {
|
||||
Account account, Bundle options) {
|
||||
try {
|
||||
validateAccountType(account.type);
|
||||
} catch (AuthenticatorException e) {
|
||||
@@ -155,9 +151,8 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
*/
|
||||
@Override
|
||||
public Bundle getAuthToken(AccountAuthenticatorResponse response,
|
||||
Account account, String authTokenType, Bundle options)
|
||||
throws NetworkErrorException {
|
||||
/// validate parameters
|
||||
Account account, String authTokenType, Bundle options) {
|
||||
// validate parameters
|
||||
try {
|
||||
validateAccountType(account.type);
|
||||
validateAuthTokenType(authTokenType);
|
||||
@@ -203,7 +198,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
|
||||
@Override
|
||||
public Bundle hasFeatures(AccountAuthenticatorResponse response,
|
||||
Account account, String[] features) throws NetworkErrorException {
|
||||
Account account, String[] features) {
|
||||
final Bundle result = new Bundle();
|
||||
result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, true);
|
||||
return result;
|
||||
@@ -211,8 +206,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
|
||||
@Override
|
||||
public Bundle updateCredentials(AccountAuthenticatorResponse response,
|
||||
Account account, String authTokenType, Bundle options)
|
||||
throws NetworkErrorException {
|
||||
Account account, String authTokenType, Bundle options) {
|
||||
|
||||
Intent intent = new Intent(mContext, AuthenticatorActivity.class);
|
||||
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*
|
||||
* 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;
|
||||
@@ -34,12 +33,14 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.ui.activity.ManageAccountsActivity;
|
||||
|
||||
|
||||
public class AccountUtils {
|
||||
/**
|
||||
* Helper class for dealing with accounts.
|
||||
*/
|
||||
public final class AccountUtils {
|
||||
private static final String PREF_SELECT_OC_ACCOUNT = "select_oc_account";
|
||||
|
||||
public static final int ACCOUNT_VERSION = 1;
|
||||
public static final int ACCOUNT_VERSION_WITH_PROPER_ID = 2;
|
||||
//public static final int ACCOUNT_VERSION_WITH_PROPER_ID = 2;
|
||||
public static final String ACCOUNT_USES_STANDARD_PASSWORD = "ACCOUNT_USES_STANDARD_PASSWORD";
|
||||
|
||||
private AccountUtils() {
|
||||
@@ -152,10 +153,8 @@ public class AccountUtils {
|
||||
public static boolean setCurrentOwnCloudAccount(final Context context, String accountName) {
|
||||
boolean result = false;
|
||||
if (accountName != null) {
|
||||
boolean found;
|
||||
for (final Account account : getAccounts(context)) {
|
||||
found = (account.name.equals(accountName));
|
||||
if (found) {
|
||||
if (accountName.equals(account.name)) {
|
||||
SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
||||
appPrefs.putString(PREF_SELECT_OC_ACCOUNT, accountName);
|
||||
appPrefs.apply();
|
||||
|
||||
@@ -188,6 +188,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
public static final String REGULAR_SERVER_INPUT_TYPE = "regular";
|
||||
public static final String SUBDOMAIN_SERVER_INPUT_TYPE = "prefix";
|
||||
public static final String DIRECTORY_SERVER_INPUT_TYPE = "suffix";
|
||||
public static final int NO_ICON = 0;
|
||||
public static final String EMPTY_STRING = "";
|
||||
|
||||
/// parameters from EXTRAs in starter Intent
|
||||
private byte mAction;
|
||||
@@ -196,8 +198,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
/// activity-level references / state
|
||||
private final Handler mHandler = new Handler();
|
||||
private ServiceConnection mOperationsServiceConnection = null;
|
||||
private OperationsServiceBinder mOperationsServiceBinder = null;
|
||||
private ServiceConnection mOperationsServiceConnection;
|
||||
private OperationsServiceBinder mOperationsServiceBinder;
|
||||
private AccountManager mAccountMgr;
|
||||
private Uri mNewCapturedUriFromOAuth2Redirection;
|
||||
|
||||
@@ -207,7 +209,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
private TextView mServerStatusView;
|
||||
|
||||
private TextWatcher mHostUrlInputWatcher;
|
||||
private String mServerStatusText = "";
|
||||
private String mServerStatusText = EMPTY_STRING;
|
||||
private int mServerStatusIcon;
|
||||
|
||||
private boolean mServerIsChecked;
|
||||
@@ -227,10 +229,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private WebView mLoginWebView;
|
||||
|
||||
private String mAuthStatusText = "";
|
||||
private String mAuthStatusText = EMPTY_STRING;
|
||||
private int mAuthStatusIcon;
|
||||
|
||||
private String mAuthToken = "";
|
||||
private String mAuthToken = EMPTY_STRING;
|
||||
private AuthenticatorAsyncTask mAsyncTask;
|
||||
|
||||
private boolean mIsFirstAuthAttempt;
|
||||
@@ -547,7 +549,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (dataString.length() < prefix.length()) {
|
||||
throw new IllegalArgumentException("Invalid login URL detected");
|
||||
}
|
||||
LoginUrlInfo loginUrlInfo = new LoginUrlInfo();
|
||||
|
||||
// format is basically xxx://login/server:xxx&user:xxx&password while all variables are optional
|
||||
String data = dataString.substring(prefix.length());
|
||||
@@ -560,6 +561,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
throw new IllegalArgumentException("Illegal number of login URL elements detected: " + values.length);
|
||||
}
|
||||
|
||||
LoginUrlInfo loginUrlInfo = new LoginUrlInfo();
|
||||
|
||||
for (String value : values) {
|
||||
if (value.startsWith("user" + LOGIN_URL_DATA_KEY_VALUE_SEPARATOR)) {
|
||||
loginUrlInfo.username = URLDecoder.decode(
|
||||
@@ -584,10 +587,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (mAuthTokenType == null) {
|
||||
if (mAccount != null) {
|
||||
boolean oAuthRequired = mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null;
|
||||
boolean samlWebSsoRequired = (
|
||||
mAccountMgr.getUserData
|
||||
(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null
|
||||
);
|
||||
boolean samlWebSsoRequired = mAccountMgr.getUserData
|
||||
(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
|
||||
mAuthTokenType = chooseAuthTokenType(oAuthRequired, samlWebSsoRequired);
|
||||
|
||||
} else {
|
||||
@@ -754,7 +755,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (mAuthStatusIcon != 0) {
|
||||
Log_OC.d(TAG, "onTextChanged: hiding authentication status");
|
||||
mAuthStatusIcon = 0;
|
||||
mAuthStatusText = "";
|
||||
mAuthStatusText = EMPTY_STRING;
|
||||
showAuthStatus();
|
||||
}
|
||||
}
|
||||
@@ -815,7 +816,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
mUsernameInput.setEnabled(false);
|
||||
mUsernameInput.setFocusable(false);
|
||||
}
|
||||
mPasswordInput.setText(""); // clean password to avoid social hacking
|
||||
mPasswordInput.setText(EMPTY_STRING); // clean password to avoid social hacking
|
||||
if (isPasswordExposed) {
|
||||
showPassword();
|
||||
}
|
||||
@@ -1179,7 +1180,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
} else {
|
||||
mServerStatusText = "";
|
||||
mServerStatusText = EMPTY_STRING;
|
||||
mServerStatusIcon = 0;
|
||||
if (!webViewLoginMethod) {
|
||||
showServerStatus();
|
||||
@@ -1403,7 +1404,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (!webViewLoginMethod && !mUsernameInput.getText().toString().trim().equals(username)) {
|
||||
// fail - not a new account, but an existing one; disallow
|
||||
result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME);
|
||||
mAuthToken = "";
|
||||
mAuthToken = EMPTY_STRING;
|
||||
updateAuthStatusIconAndText(result);
|
||||
showAuthStatus();
|
||||
Log_OC.d(TAG, result.getLogMessage());
|
||||
@@ -1522,13 +1523,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
private boolean authSupported(AuthenticationMethod authMethod) {
|
||||
return ((basicTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
|
||||
(oauthTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
|
||||
(samlTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.SAML_WEB_SSO.equals(authMethod))
|
||||
);
|
||||
return (basicTokenType.equals(mAuthTokenType) && AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
|
||||
(oauthTokenType.equals(mAuthTokenType) && AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
|
||||
(samlTokenType.equals(mAuthTokenType) && AuthenticationMethod.SAML_WEB_SSO.equals(authMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1622,7 +1619,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
mServerStatusText = getResources().getString(R.string.untrusted_domain);
|
||||
break;
|
||||
default:
|
||||
mServerStatusText = "";
|
||||
mServerStatusText = EMPTY_STRING;
|
||||
mServerStatusIcon = 0;
|
||||
break;
|
||||
}
|
||||
@@ -1718,7 +1715,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes the result of the access check performed to try the user credentials.
|
||||
*
|
||||
@@ -1790,7 +1786,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
updateServerStatusIconAndText(result);
|
||||
showServerStatus();
|
||||
mAuthStatusIcon = 0;
|
||||
mAuthStatusText = "";
|
||||
mAuthStatusText = EMPTY_STRING;
|
||||
if (!webViewLoginMethod) {
|
||||
showAuthStatus();
|
||||
|
||||
@@ -1823,7 +1819,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the authentication token.
|
||||
*
|
||||
@@ -1873,7 +1868,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new account through the Account Authenticator that started this activity.
|
||||
*
|
||||
@@ -1922,7 +1916,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
if (isOAuth || isSaml) {
|
||||
// with external authorizations, the password is never input in the app
|
||||
mAccountMgr.addAccountExplicitly(mAccount, "", null);
|
||||
mAccountMgr.addAccountExplicitly(mAccount, EMPTY_STRING, null);
|
||||
} else {
|
||||
if (!webViewLoginMethod) {
|
||||
mAccountMgr.addAccountExplicitly(mAccount, mPasswordInput.getText().toString(), null);
|
||||
@@ -1983,12 +1977,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Updates the content and visibility state of the icon and text associated
|
||||
* to the last check on the ownCloud server.
|
||||
*/
|
||||
private void showServerStatus() {
|
||||
if (mServerStatusIcon == 0 && "".equals(mServerStatusText)) {
|
||||
if (mServerStatusIcon == NO_ICON && EMPTY_STRING.equals(mServerStatusText)) {
|
||||
mServerStatusView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mServerStatusView.setText(mServerStatusText);
|
||||
@@ -1997,13 +1992,12 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the content and visibility state of the icon and text associated
|
||||
* to the interactions with the OAuth authorization server.
|
||||
*/
|
||||
private void showAuthStatus() {
|
||||
if (mAuthStatusIcon == 0 && "".equals(mAuthStatusText)) {
|
||||
if (mAuthStatusIcon == NO_ICON && EMPTY_STRING.equals(mAuthStatusText)) {
|
||||
mAuthStatusView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
mAuthStatusView.setText(mAuthStatusText);
|
||||
@@ -2012,7 +2006,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void showRefreshButton(boolean show) {
|
||||
if (webViewLoginMethod && mRefreshButton != null) {
|
||||
if (show) {
|
||||
@@ -2082,6 +2075,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private abstract static class RightDrawableOnTouchListener implements OnTouchListener {
|
||||
|
||||
private static final int RIGHT_DRAWABLE_COMPOUND_DRAWABLES_LENGTH = 2;
|
||||
|
||||
private int fuzz = 75;
|
||||
|
||||
/**
|
||||
@@ -2092,7 +2087,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
Drawable rightDrawable = null;
|
||||
if (view instanceof TextView) {
|
||||
Drawable[] drawables = ((TextView) view).getCompoundDrawables();
|
||||
if (drawables.length > 2) {
|
||||
if (drawables.length > RIGHT_DRAWABLE_COMPOUND_DRAWABLES_LENGTH) {
|
||||
rightDrawable = drawables[2];
|
||||
}
|
||||
}
|
||||
@@ -2221,7 +2216,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private void doOnResumeAndBound() {
|
||||
//Log_OC.e(TAG, "registering to listen for operation callbacks" );
|
||||
mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);
|
||||
mOperationsServiceBinder.addOperationListener(this, mHandler);
|
||||
if (mWaitingForOpId <= Integer.MAX_VALUE) {
|
||||
mOperationsServiceBinder.dispatchResultIfFinished((int) mWaitingForOpId, this);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Locale;
|
||||
/**
|
||||
* Helper class for authenticator-URL related logic.
|
||||
*/
|
||||
public abstract class AuthenticatorUrlUtils {
|
||||
public final class AuthenticatorUrlUtils {
|
||||
public static final String WEBDAV_PATH_4_0_AND_LATER = "/remote.php/webdav";
|
||||
|
||||
private static final String HTTPS_PROTOCOL = "https://";
|
||||
@@ -41,6 +41,9 @@ public abstract class AuthenticatorUrlUtils {
|
||||
private static final String ODAV_PATH = "/remote.php/odav";
|
||||
private static final String SAML_SSO_PATH = "/remote.php/webdav";
|
||||
|
||||
private AuthenticatorUrlUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the proper URL path to access the WebDAV interface of an ownCloud server,
|
||||
* according to its version and the authorization method used.
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.owncloud.android.utils.DeviceCredentialUtils;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PassCodeManager {
|
||||
public final class PassCodeManager {
|
||||
|
||||
private static final Set<Class> exemptOfPasscodeActivities;
|
||||
|
||||
@@ -53,10 +53,10 @@ public class PassCodeManager {
|
||||
private static final int PASS_CODE_TIMEOUT = 1000;
|
||||
// keeping a "low" positive value is the easiest way to prevent the pass code is requested on rotations
|
||||
|
||||
private static PassCodeManager passCodeManagerInstance = null;
|
||||
private static PassCodeManager passCodeManagerInstance;
|
||||
|
||||
private Long timestamp = 0L;
|
||||
private int visibleActivitiesCounter = 0;
|
||||
private int visibleActivitiesCounter;
|
||||
|
||||
public static PassCodeManager getPassCodeManager() {
|
||||
if (passCodeManagerInstance == null) {
|
||||
|
||||
@@ -35,7 +35,8 @@ import java.util.List;
|
||||
* Database provider for handling the persistence aspects of arbitrary data table.
|
||||
*/
|
||||
public class ArbitraryDataProvider {
|
||||
static private final String TAG = ArbitraryDataProvider.class.getSimpleName();
|
||||
private static final String TAG = ArbitraryDataProvider.class.getSimpleName();
|
||||
private static final String TRUE = "true";
|
||||
|
||||
private ContentResolver contentResolver;
|
||||
|
||||
@@ -115,9 +116,7 @@ public class ArbitraryDataProvider {
|
||||
}
|
||||
|
||||
public boolean getBooleanValue(String accountName, String key) {
|
||||
String value = getValue(accountName, key);
|
||||
|
||||
return !value.isEmpty() && value.equalsIgnoreCase("true");
|
||||
return TRUE.equalsIgnoreCase(getValue(accountName, key));
|
||||
}
|
||||
|
||||
public boolean getBooleanValue(Account account, String key) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Decrypted class representation of metadata json of folder metadata
|
||||
* Decrypted class representation of metadata json of folder metadata.
|
||||
*/
|
||||
public class DecryptedFolderMetadata {
|
||||
private Metadata metadata;
|
||||
@@ -36,7 +36,7 @@ public class DecryptedFolderMetadata {
|
||||
this.files = new HashMap<>();
|
||||
}
|
||||
|
||||
public DecryptedFolderMetadata(Metadata metadata, HashMap<String, DecryptedFile> files) {
|
||||
public DecryptedFolderMetadata(Metadata metadata, Map<String, DecryptedFile> files) {
|
||||
this.metadata = metadata;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
@@ -766,7 +766,8 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void migrateStoredFiles(String srcPath, String dstPath) throws Exception {
|
||||
public void migrateStoredFiles(String srcPath, String dstPath)
|
||||
throws RemoteException, OperationApplicationException {
|
||||
Cursor cursor;
|
||||
try {
|
||||
if (getContentResolver() != null) {
|
||||
@@ -1465,8 +1466,8 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSharesDB(ArrayList<OCShare> shares) {
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
|
||||
public void saveSharesDB(List<OCShare> shares) {
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
|
||||
|
||||
// Reset flags & Remove shares for this files
|
||||
String filePath = "";
|
||||
@@ -1580,7 +1581,7 @@ public class FileDataStorageManager {
|
||||
* @return
|
||||
*/
|
||||
private ArrayList<ContentProviderOperation> prepareInsertShares(
|
||||
ArrayList<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
|
||||
List<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
|
||||
|
||||
if (shares != null) {
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
@@ -22,16 +22,16 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
/*
|
||||
Model for filesystem data from the database
|
||||
/**
|
||||
* Model for filesystem data from the database.
|
||||
*/
|
||||
public class FileSystemDataSet {
|
||||
|
||||
private int id;
|
||||
private String localPath;
|
||||
private long modifiedAt;
|
||||
private boolean isFolder;
|
||||
private boolean isSentForUpload;
|
||||
private boolean folder;
|
||||
private boolean sentForUpload;
|
||||
private long foundAt;
|
||||
private long syncedFolderId;
|
||||
@Nullable private String crc32;
|
||||
@@ -39,13 +39,13 @@ public class FileSystemDataSet {
|
||||
public FileSystemDataSet() {
|
||||
}
|
||||
|
||||
public FileSystemDataSet(int id, String localPath, long modifiedAt, boolean isFolder,
|
||||
boolean isSentForUpload, long foundAt, long syncedFolderId, @Nullable String crc32) {
|
||||
public FileSystemDataSet(int id, String localPath, long modifiedAt, boolean folder,
|
||||
boolean sentForUpload, long foundAt, long syncedFolderId, @Nullable String crc32) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.modifiedAt = modifiedAt;
|
||||
this.isFolder = isFolder;
|
||||
this.isSentForUpload = isSentForUpload;
|
||||
this.folder = folder;
|
||||
this.sentForUpload = sentForUpload;
|
||||
this.foundAt = foundAt;
|
||||
this.syncedFolderId = syncedFolderId;
|
||||
this.crc32 = crc32;
|
||||
@@ -84,11 +84,11 @@ public class FileSystemDataSet {
|
||||
}
|
||||
|
||||
public boolean isFolder() {
|
||||
return isFolder;
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void setFolder(boolean folder) {
|
||||
isFolder = folder;
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public long getFoundAt() {
|
||||
@@ -100,11 +100,11 @@ public class FileSystemDataSet {
|
||||
}
|
||||
|
||||
public boolean isSentForUpload() {
|
||||
return isSentForUpload;
|
||||
return sentForUpload;
|
||||
}
|
||||
|
||||
public void setSentForUpload(boolean sentForUpload) {
|
||||
isSentForUpload = sentForUpload;
|
||||
this.sentForUpload = sentForUpload;
|
||||
}
|
||||
|
||||
public long getSyncedFolderId() {
|
||||
|
||||
@@ -44,7 +44,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* Media queries to gain access to media lists for the device.
|
||||
*/
|
||||
public class MediaProvider {
|
||||
public final class MediaProvider {
|
||||
private static final String TAG = MediaProvider.class.getSimpleName();
|
||||
|
||||
// fixed query parameters
|
||||
@@ -58,6 +58,10 @@ public class MediaProvider {
|
||||
private static final String[] VIDEOS_FOLDER_PROJECTION = {"Distinct " + MediaStore.Video.Media.BUCKET_ID,
|
||||
MediaStore.Video.Media.BUCKET_DISPLAY_NAME};
|
||||
|
||||
private MediaProvider() {
|
||||
// utility class -> private constructor
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting All Images Paths.
|
||||
*
|
||||
@@ -115,9 +119,9 @@ public class MediaProvider {
|
||||
MediaStore.MediaColumns.DATA));
|
||||
|
||||
// check if valid path
|
||||
if (filePath != null && filePath.lastIndexOf("/") > 0) {
|
||||
if (filePath != null && filePath.lastIndexOf('/') > 0) {
|
||||
mediaFolder.filePaths.add(filePath);
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf("/"));
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf('/'));
|
||||
}
|
||||
}
|
||||
cursorImages.close();
|
||||
|
||||
@@ -59,6 +59,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
|
||||
private final static String PERMISSION_SHARED_WITH_ME = "S"; // TODO move to better location
|
||||
private final static String PERMISSION_CAN_RESHARE = "R";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
|
||||
public static final String PATH_SEPARATOR = "/";
|
||||
public static final String ROOT_PATH = PATH_SEPARATOR;
|
||||
@@ -466,8 +467,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
Log_OC.d(TAG, "OCFile name changing from " + mRemotePath);
|
||||
if (name != null && name.length() > 0 && !name.contains(PATH_SEPARATOR) &&
|
||||
!mRemotePath.equals(ROOT_PATH)) {
|
||||
String parent = (new File(this.getRemotePath())).getParent();
|
||||
parent = (parent.endsWith(PATH_SEPARATOR)) ? parent : parent + PATH_SEPARATOR;
|
||||
String parent = new File(this.getRemotePath()).getParent();
|
||||
parent = parent.endsWith(PATH_SEPARATOR) ? parent : parent + PATH_SEPARATOR;
|
||||
mRemotePath = parent + name;
|
||||
if (isFolder()) {
|
||||
mRemotePath += PATH_SEPARATOR;
|
||||
@@ -784,6 +785,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
return permissions != null && permissions.contains(PERMISSION_CAN_RESHARE);
|
||||
}
|
||||
|
||||
public boolean canWrite() {
|
||||
String permissions = getPermissions();
|
||||
return permissions != null && permissions.contains(PERMISSION_CAN_WRITE);
|
||||
}
|
||||
|
||||
public WebdavEntry.MountType getMountType() {
|
||||
return mMountType;
|
||||
}
|
||||
|
||||
@@ -249,14 +249,11 @@ public class SyncedFolderProvider extends Observable {
|
||||
* @param account whose synced folders should be deleted
|
||||
*/
|
||||
public int deleteSyncFoldersForAccount(Account account) {
|
||||
int result = mContentResolver.delete(
|
||||
return mContentResolver.delete(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " = ?",
|
||||
new String[]{String.valueOf(account.name)}
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,7 +78,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
/**
|
||||
* Manager for concurrent access to thumbnails cache.
|
||||
*/
|
||||
public class ThumbnailsCacheManager {
|
||||
public final class ThumbnailsCacheManager {
|
||||
|
||||
public static final String PREFIX_RESIZED_IMAGE = "r";
|
||||
public static final String PREFIX_THUMBNAIL = "t";
|
||||
@@ -90,19 +90,22 @@ public class ThumbnailsCacheManager {
|
||||
private static final String ETAG = "ETag";
|
||||
|
||||
private static final Object mThumbnailsDiskCacheLock = new Object();
|
||||
private static DiskLruImageCache mThumbnailCache = null;
|
||||
private static DiskLruImageCache mThumbnailCache;
|
||||
private static boolean mThumbnailCacheStarting = true;
|
||||
|
||||
private static final int DISK_CACHE_SIZE = 1024 * 1024 * 200; // 200MB
|
||||
private static final CompressFormat mCompressFormat = CompressFormat.JPEG;
|
||||
private static final int mCompressQuality = 70;
|
||||
private static OwnCloudClient mClient = null;
|
||||
private static OwnCloudClient mClient;
|
||||
|
||||
public static final Bitmap mDefaultImg = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(),
|
||||
R.drawable.file_image);
|
||||
|
||||
public static final Bitmap mDefaultVideo = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(),
|
||||
R.drawable.file_movie);
|
||||
|
||||
private ThumbnailsCacheManager() {
|
||||
}
|
||||
|
||||
public static class InitDiskCacheTask extends AsyncTask<File, Void, Void> {
|
||||
@Override
|
||||
@@ -381,7 +384,7 @@ public class ThumbnailsCacheManager {
|
||||
private static Account mAccount;
|
||||
private List<ThumbnailGenerationTask> mAsyncTasks;
|
||||
private Object mFile;
|
||||
private String mImageKey = null;
|
||||
private String mImageKey;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private GetMethod getMethod;
|
||||
|
||||
@@ -641,6 +644,9 @@ public class ThumbnailsCacheManager {
|
||||
}
|
||||
|
||||
public static class MediaThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
|
||||
|
||||
private static final int IMAGE_KEY_PARAMS_LENGTH = 2;
|
||||
|
||||
private enum Type {IMAGE, VIDEO}
|
||||
private final WeakReference<ImageView> mImageViewReference;
|
||||
private File mFile;
|
||||
@@ -660,7 +666,7 @@ public class ThumbnailsCacheManager {
|
||||
try {
|
||||
if (params[0] instanceof File) {
|
||||
mFile = (File) params[0];
|
||||
if (params.length == 2) {
|
||||
if (params.length == IMAGE_KEY_PARAMS_LENGTH) {
|
||||
mImageKey = (String) params[1];
|
||||
}
|
||||
|
||||
@@ -870,7 +876,8 @@ public class ThumbnailsCacheManager {
|
||||
// we are using eTag to download a new avatar only if it changed
|
||||
switch (status) {
|
||||
case HttpStatus.SC_OK:
|
||||
// new avatar
|
||||
case HttpStatus.SC_CREATED:
|
||||
// new avatar
|
||||
InputStream inputStream = get.getResponseBodyAsStream();
|
||||
|
||||
String newETag = null;
|
||||
|
||||
@@ -45,13 +45,14 @@ import java.util.Observable;
|
||||
* information for each file.
|
||||
*/
|
||||
public class UploadsStorageManager extends Observable {
|
||||
private static final String TAG = UploadsStorageManager.class.getSimpleName();
|
||||
|
||||
private static final String AND = " AND ";
|
||||
static private final String TAG = UploadsStorageManager.class.getSimpleName();
|
||||
private static final int SINGLE_RESULT = 1;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
private Context mContext;
|
||||
|
||||
|
||||
public UploadsStorageManager(ContentResolver contentResolver, Context context) {
|
||||
if (contentResolver == null) {
|
||||
throw new IllegalArgumentException("Cannot create an instance with a NULL contentResolver");
|
||||
@@ -123,7 +124,7 @@ public class UploadsStorageManager extends Observable {
|
||||
);
|
||||
|
||||
Log_OC.d(TAG, "updateUpload returns with: " + result + " for file: " + ocUpload.getLocalPath());
|
||||
if (result != 1) {
|
||||
if (result != SINGLE_RESULT) {
|
||||
Log_OC.e(TAG, "Failed to update item " + ocUpload.getLocalPath() + " into upload db.");
|
||||
} else {
|
||||
notifyObserversNow();
|
||||
@@ -189,7 +190,7 @@ public class UploadsStorageManager extends Observable {
|
||||
);
|
||||
|
||||
if (c != null) {
|
||||
if (c.getCount() != 1) {
|
||||
if (c.getCount() != SINGLE_RESULT) {
|
||||
Log_OC.e(TAG, c.getCount() + " items for id=" + id
|
||||
+ " available in UploadDb. Expected 1. Failed to update upload db.");
|
||||
} else {
|
||||
@@ -272,10 +273,10 @@ public class UploadsStorageManager extends Observable {
|
||||
}
|
||||
|
||||
public OCUpload[] getAllStoredUploads() {
|
||||
return getUploads(null, null);
|
||||
return getUploads(null, (String[]) null);
|
||||
}
|
||||
|
||||
private OCUpload[] getUploads(@Nullable String selection, @Nullable String[] selectionArgs) {
|
||||
private OCUpload[] getUploads(@Nullable String selection, @Nullable String... selectionArgs) {
|
||||
OCUpload[] list;
|
||||
|
||||
Cursor c = getDB().query(
|
||||
@@ -393,7 +394,7 @@ public class UploadsStorageManager extends Observable {
|
||||
*/
|
||||
public OCUpload[] getFinishedUploads() {
|
||||
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value, null);
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value, (String[]) null);
|
||||
}
|
||||
|
||||
public OCUpload[] getFailedButNotDelayedUploadsForCurrentAccount() {
|
||||
@@ -432,7 +433,7 @@ public class UploadsStorageManager extends Observable {
|
||||
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue(),
|
||||
null
|
||||
(String[]) null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -24,14 +24,14 @@ package com.owncloud.android.datastorage.providers;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
abstract class AbstractStoragePointProvider implements IStoragePointProvider {
|
||||
|
||||
boolean canBeAddedToAvailableList(Vector<StoragePoint> currentList, String path) {
|
||||
boolean canBeAddedToAvailableList(List<StoragePoint> currentList, String path) {
|
||||
if (path == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -25,6 +25,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
@@ -40,15 +41,15 @@ public class EnvironmentStoragePointProvider extends AbstractStoragePointProvide
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
public List<StoragePoint> getAvailableStoragePoint() {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
addEntriesFromEnv(result, sSecondaryStorageEnvName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addEntriesFromEnv(Vector<StoragePoint> result, String envName) {
|
||||
private void addEntriesFromEnv(List<StoragePoint> result, String envName) {
|
||||
String env = System.getenv(envName);
|
||||
if (env != null) {
|
||||
for (String p : env.split(":")) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -23,7 +23,7 @@ package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
@@ -38,11 +38,9 @@ public interface IStoragePointProvider {
|
||||
*/
|
||||
boolean canProvideStoragePoints();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return available storage points
|
||||
*/
|
||||
Vector<StoragePoint> getAvailableStoragePoint();
|
||||
|
||||
List<StoragePoint> getAvailableStoragePoint();
|
||||
}
|
||||
+6
-5
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -23,6 +23,7 @@ package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -42,8 +43,8 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
public List<StoragePoint> getAvailableStoragePoint() {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
for (String p : getPotentialPaths(getCommandLineResult())) {
|
||||
if (canBeAddedToAvailableList(result, p)) {
|
||||
@@ -54,8 +55,8 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
|
||||
return result;
|
||||
}
|
||||
|
||||
private Vector<String> getPotentialPaths(String mounted) {
|
||||
final Vector<String> result = new Vector<>();
|
||||
private List<String> getPotentialPaths(String mounted) {
|
||||
final List<String> result = new Vector<>();
|
||||
|
||||
for (String line : mounted.split("\n")) {
|
||||
if (!line.toLowerCase(Locale.US).contains("asec") && sPattern.matcher(line).matches()) {
|
||||
|
||||
+5
-4
@@ -24,6 +24,7 @@ package com.owncloud.android.datastorage.providers;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
@@ -38,8 +39,8 @@ public class VDCStoragePointProvider extends AbstractCommandLineStoragePoint {
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
public List<StoragePoint> getAvailableStoragePoint() {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
result.addAll(getPaths(getCommandLineResult()));
|
||||
|
||||
@@ -51,8 +52,8 @@ public class VDCStoragePointProvider extends AbstractCommandLineStoragePoint {
|
||||
return sVDCVolListCommand;
|
||||
}
|
||||
|
||||
private Vector<StoragePoint> getPaths(String vdcResources) {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
private List<StoragePoint> getPaths(String vdcResources) {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
for (String line : vdcResources.split("\n")) {
|
||||
String vdcLine[] = line.split(" ");
|
||||
|
||||
@@ -353,7 +353,7 @@ public class OCUpload implements Parcelable {
|
||||
(getLastResult() == null ? "null" : getLastResult().getValue());
|
||||
} catch (NullPointerException e) {
|
||||
Log_OC.d(TAG, "Exception " + e.toString());
|
||||
return (e.toString());
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ import static com.owncloud.android.ui.fragment.OCFileListFragment.FOLDER_LAYOUT_
|
||||
/**
|
||||
* Helper to simplify reading of Preferences all around the app
|
||||
*/
|
||||
public abstract class PreferenceManager {
|
||||
public final class PreferenceManager {
|
||||
/**
|
||||
* Constant to access value of last path selected by the user to upload a file shared from other app.
|
||||
* Value handled by the app without direct access in the UI.
|
||||
@@ -65,6 +65,9 @@ public abstract class PreferenceManager {
|
||||
private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
|
||||
private static final String PREF__FOLDER_LAYOUT = "folder_layout";
|
||||
|
||||
private PreferenceManager() {
|
||||
}
|
||||
|
||||
public static void setKeysReInit(Context context) {
|
||||
saveBooleanPreference(context, PREF__KEYS_REINIT, true);
|
||||
}
|
||||
|
||||
@@ -363,11 +363,9 @@ public class FileMenuFilter {
|
||||
OperationsServiceBinder opsBinder = mComponentsGetter.getOperationsServiceBinder();
|
||||
FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder();
|
||||
FileDownloaderBinder downloaderBinder = mComponentsGetter.getFileDownloaderBinder();
|
||||
synchronizing = (
|
||||
anyFileSynchronizing(opsBinder) || // comparing local and remote
|
||||
synchronizing = anyFileSynchronizing(opsBinder) || // comparing local and remote
|
||||
anyFileDownloading(downloaderBinder) ||
|
||||
anyFileUploading(uploaderBinder)
|
||||
);
|
||||
anyFileUploading(uploaderBinder);
|
||||
}
|
||||
return synchronizing;
|
||||
}
|
||||
|
||||
@@ -321,10 +321,7 @@ public class FileDownloader extends Service
|
||||
* @param file A file that could be in the queue of downloads.
|
||||
*/
|
||||
public boolean isDownloading(Account account, OCFile file) {
|
||||
if (account == null || file == null) {
|
||||
return false;
|
||||
}
|
||||
return (mPendingDownloads.contains(account.name, file.getRemotePath()));
|
||||
return account != null && file != null && mPendingDownloads.contains(account.name, file.getRemotePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -599,8 +596,8 @@ public class FileDownloader extends Service
|
||||
}
|
||||
|
||||
if (!downloadResult.isCancelled()) {
|
||||
int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker :
|
||||
R.string.downloader_download_failed_ticker;
|
||||
int tickerId = downloadResult.isSuccess() ?
|
||||
R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
|
||||
|
||||
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(downloadResult.getCode());
|
||||
tickerId = needsToUpdateCredentials ?
|
||||
|
||||
@@ -399,11 +399,10 @@ public class FileUploader extends Service
|
||||
boolean isPowerSaving = PowerUtils.isPowerSaveMode(context);
|
||||
|
||||
for ( OCUpload failedUpload: failedUploads) {
|
||||
accountMatch = (account == null || account.name.equals(failedUpload.getAccountName()));
|
||||
resultMatch = ((uploadResult == null || uploadResult.equals(failedUpload.getLastResult())));
|
||||
accountMatch = account == null || account.name.equals(failedUpload.getAccountName());
|
||||
resultMatch = uploadResult == null || uploadResult.equals(failedUpload.getLastResult());
|
||||
if (accountMatch && resultMatch) {
|
||||
if (currentAccount == null ||
|
||||
!currentAccount.name.equals(failedUpload.getAccountName())) {
|
||||
if (currentAccount == null || !currentAccount.name.equals(failedUpload.getAccountName())) {
|
||||
currentAccount = failedUpload.getAccount(context);
|
||||
}
|
||||
|
||||
@@ -572,12 +571,6 @@ public class FileUploader extends Service
|
||||
mimeTypes = intent.getStringArrayExtra(KEY_MIME_TYPE);
|
||||
}
|
||||
|
||||
boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false);
|
||||
int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_FORGET);
|
||||
|
||||
boolean isCreateRemoteFolder = intent.getBooleanExtra(KEY_CREATE_REMOTE_FOLDER, false);
|
||||
int createdBy = intent.getIntExtra(KEY_CREATED_BY, UploadFileOperation.CREATED_BY_USER);
|
||||
|
||||
if (intent.hasExtra(KEY_FILE) && files == null) {
|
||||
Log_OC.e(TAG, "Incorrect array for OCFiles provided in upload intent");
|
||||
return Service.START_NOT_STICKY;
|
||||
@@ -612,6 +605,10 @@ public class FileUploader extends Service
|
||||
}
|
||||
// at this point variable "OCFile[] files" is loaded correctly.
|
||||
|
||||
boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false);
|
||||
int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_FORGET);
|
||||
boolean isCreateRemoteFolder = intent.getBooleanExtra(KEY_CREATE_REMOTE_FOLDER, false);
|
||||
int createdBy = intent.getIntExtra(KEY_CREATED_BY, UploadFileOperation.CREATED_BY_USER);
|
||||
String uploadKey;
|
||||
UploadFileOperation newUpload;
|
||||
try {
|
||||
@@ -1217,15 +1214,14 @@ public class FileUploader extends Service
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_IN_POWER_SAVE_MODE) &&
|
||||
!uploadResult.getCode().equals(ResultCode.LOCK_FAILED) ) {
|
||||
|
||||
int tickerId = (uploadResult.isSuccess()) ? R.string.uploader_upload_succeeded_ticker :
|
||||
int tickerId = uploadResult.isSuccess() ? R.string.uploader_upload_succeeded_ticker :
|
||||
R.string.uploader_upload_failed_ticker;
|
||||
|
||||
String content;
|
||||
|
||||
// check credentials error
|
||||
boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(uploadResult.getCode());
|
||||
tickerId = (needsToUpdateCredentials) ?
|
||||
R.string.uploader_upload_failed_credentials_error : tickerId;
|
||||
tickerId = needsToUpdateCredentials ? R.string.uploader_upload_failed_credentials_error : tickerId;
|
||||
|
||||
mNotificationBuilder
|
||||
.setTicker(getString(tickerId))
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.ui.activity.Preferences;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.FilesSyncHelper;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
import com.owncloud.android.utils.PowerUtils;
|
||||
|
||||
@@ -65,7 +66,6 @@ import java.util.TimeZone;
|
||||
*/
|
||||
public class FilesSyncJob extends Job {
|
||||
public static final String TAG = "FilesSyncJob";
|
||||
|
||||
public static final String SKIP_CUSTOM = "skipCustom";
|
||||
public static final String OVERRIDE_POWER_SAVING = "overridePowerSaving";
|
||||
|
||||
@@ -73,8 +73,6 @@ public class FilesSyncJob extends Job {
|
||||
@Override
|
||||
protected Result onRunJob(@NonNull Params params) {
|
||||
final Context context = MainApp.getAppContext();
|
||||
final ContentResolver contentResolver = context.getContentResolver();
|
||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||
PowerManager.WakeLock wakeLock = null;
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
@@ -84,7 +82,6 @@ public class FilesSyncJob extends Job {
|
||||
}
|
||||
|
||||
PersistableBundleCompat bundle = params.getExtras();
|
||||
final boolean skipCustom = bundle.getBoolean(SKIP_CUSTOM, false);
|
||||
final boolean overridePowerSaving = bundle.getBoolean(OVERRIDE_POWER_SAVING, false);
|
||||
|
||||
// If we are in power save mode, better to postpone upload
|
||||
@@ -96,102 +93,24 @@ public class FilesSyncJob extends Job {
|
||||
Resources resources = MainApp.getAppContext().getResources();
|
||||
boolean lightVersion = resources.getBoolean(R.bool.syncedFolder_light);
|
||||
|
||||
final boolean skipCustom = bundle.getBoolean(SKIP_CUSTOM, false);
|
||||
FilesSyncHelper.restartJobsIfNeeded();
|
||||
FilesSyncHelper.insertAllDBEntries(skipCustom);
|
||||
|
||||
// Create all the providers we'll need
|
||||
final ContentResolver contentResolver = context.getContentResolver();
|
||||
final FilesystemDataProvider filesystemDataProvider = new FilesystemDataProvider(contentResolver);
|
||||
SyncedFolderProvider syncedFolderProvider = new SyncedFolderProvider(contentResolver);
|
||||
|
||||
Locale currentLocale = context.getResources().getConfiguration().locale;
|
||||
SimpleDateFormat sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", currentLocale);
|
||||
sFormatter.setTimeZone(TimeZone.getTimeZone(TimeZone.getDefault().getID()));
|
||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||
|
||||
for (SyncedFolder syncedFolder : syncedFolderProvider.getSyncedFolders()) {
|
||||
if ((syncedFolder.isEnabled()) && (!skipCustom || MediaFolderType.CUSTOM != syncedFolder.getType())) {
|
||||
for (String path : filesystemDataProvider.getFilesForUpload(syncedFolder.getLocalPath(),
|
||||
Long.toString(syncedFolder.getId()))) {
|
||||
File file = new File(path);
|
||||
|
||||
Long lastModificationTime = file.lastModified();
|
||||
final Locale currentLocale = context.getResources().getConfiguration().locale;
|
||||
|
||||
if (MediaFolderType.IMAGE == syncedFolder.getType()) {
|
||||
String mimeTypeString = FileStorageUtils.getMimeTypeFromName(file.getAbsolutePath());
|
||||
if ("image/jpeg".equalsIgnoreCase(mimeTypeString) || "image/tiff".
|
||||
equalsIgnoreCase(mimeTypeString)) {
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(file.getAbsolutePath());
|
||||
String exifDate = exifInterface.getAttribute(ExifInterface.TAG_DATETIME);
|
||||
if (!TextUtils.isEmpty(exifDate)) {
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
SimpleDateFormat sFormatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss",
|
||||
currentLocale);
|
||||
sFormatter.setTimeZone(TimeZone.getTimeZone(TimeZone.getDefault().getID()));
|
||||
Date dateTime = sFormatter.parse(exifDate, pos);
|
||||
lastModificationTime = dateTime.getTime();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log_OC.d(TAG, "Failed to get the proper time " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(file.getAbsolutePath());
|
||||
|
||||
Account account = AccountUtils.getOwnCloudAccountByName(context, syncedFolder.getAccount());
|
||||
|
||||
String remotePath;
|
||||
boolean subfolderByDate;
|
||||
Integer uploadAction;
|
||||
boolean needsCharging;
|
||||
boolean needsWifi;
|
||||
|
||||
if (lightVersion) {
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(
|
||||
context.getContentResolver());
|
||||
|
||||
needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging);
|
||||
needsWifi = account == null || arbitraryDataProvider.getBooleanValue(account.name,
|
||||
Preferences.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
|
||||
String uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour);
|
||||
uploadAction = getUploadAction(uploadActionString);
|
||||
|
||||
subfolderByDate = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders);
|
||||
|
||||
remotePath = resources.getString(R.string.syncedFolder_remote_folder);
|
||||
} else {
|
||||
needsCharging = syncedFolder.getChargingOnly();
|
||||
needsWifi = syncedFolder.getWifiOnly();
|
||||
uploadAction = syncedFolder.getUploadAction();
|
||||
subfolderByDate = syncedFolder.getSubfolderByDate();
|
||||
remotePath = syncedFolder.getRemotePath();
|
||||
}
|
||||
|
||||
if (!subfolderByDate) {
|
||||
String adaptedPath = file.getAbsolutePath()
|
||||
.replace(syncedFolder.getLocalPath(), "")
|
||||
.replace("/" + file.getName(), "");
|
||||
remotePath += adaptedPath;
|
||||
}
|
||||
|
||||
requester.uploadFileWithOverwrite(
|
||||
context,
|
||||
account,
|
||||
file.getAbsolutePath(),
|
||||
FileStorageUtils.getInstantUploadFilePath(
|
||||
currentLocale,
|
||||
remotePath, file.getName(),
|
||||
lastModificationTime, subfolderByDate),
|
||||
uploadAction,
|
||||
mimeType,
|
||||
true, // create parent folder if not existent
|
||||
UploadFileOperation.CREATED_AS_INSTANT_PICTURE,
|
||||
needsWifi,
|
||||
needsCharging,
|
||||
true
|
||||
);
|
||||
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(path,
|
||||
Long.toString(syncedFolder.getId()));
|
||||
}
|
||||
syncFolder(context, resources, lightVersion, filesystemDataProvider, currentLocale, sFormatter,
|
||||
requester, syncedFolder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,6 +121,102 @@ public class FilesSyncJob extends Job {
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void syncFolder(Context context, Resources resources, boolean lightVersion,
|
||||
FilesystemDataProvider filesystemDataProvider, Locale currentLocale,
|
||||
SimpleDateFormat sFormatter, FileUploader.UploadRequester requester,
|
||||
SyncedFolder syncedFolder) {
|
||||
String remotePath;
|
||||
boolean subfolderByDate;
|
||||
Integer uploadAction;
|
||||
boolean needsCharging;
|
||||
boolean needsWifi;
|
||||
File file;
|
||||
ArbitraryDataProvider arbitraryDataProvider;
|
||||
Account account = AccountUtils.getOwnCloudAccountByName(context, syncedFolder.getAccount());
|
||||
|
||||
if (lightVersion) {
|
||||
arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
} else {
|
||||
arbitraryDataProvider = null;
|
||||
}
|
||||
|
||||
for (String path : filesystemDataProvider.getFilesForUpload(syncedFolder.getLocalPath(),
|
||||
Long.toString(syncedFolder.getId()))) {
|
||||
file = new File(path);
|
||||
Long lastModificationTime = calculateLastModificationTime(file, syncedFolder, sFormatter);
|
||||
String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(file.getAbsolutePath());
|
||||
|
||||
if (lightVersion) {
|
||||
needsCharging = resources.getBoolean(R.bool.syncedFolder_light_on_charging);
|
||||
needsWifi = account == null || arbitraryDataProvider.getBooleanValue(account.name,
|
||||
Preferences.SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI);
|
||||
String uploadActionString = resources.getString(R.string.syncedFolder_light_upload_behaviour);
|
||||
uploadAction = getUploadAction(uploadActionString);
|
||||
|
||||
subfolderByDate = resources.getBoolean(R.bool.syncedFolder_light_use_subfolders);
|
||||
|
||||
remotePath = resources.getString(R.string.syncedFolder_remote_folder);
|
||||
} else {
|
||||
needsCharging = syncedFolder.getChargingOnly();
|
||||
needsWifi = syncedFolder.getWifiOnly();
|
||||
uploadAction = syncedFolder.getUploadAction();
|
||||
subfolderByDate = syncedFolder.getSubfolderByDate();
|
||||
remotePath = syncedFolder.getRemotePath();
|
||||
}
|
||||
|
||||
if (!subfolderByDate) {
|
||||
String adaptedPath = file.getAbsolutePath()
|
||||
.replace(syncedFolder.getLocalPath(), "")
|
||||
.replace("/" + file.getName(), "");
|
||||
remotePath += adaptedPath;
|
||||
}
|
||||
|
||||
requester.uploadFileWithOverwrite(
|
||||
context,
|
||||
account,
|
||||
file.getAbsolutePath(),
|
||||
FileStorageUtils.getInstantUploadFilePath(
|
||||
currentLocale,
|
||||
remotePath, file.getName(),
|
||||
lastModificationTime, subfolderByDate),
|
||||
uploadAction,
|
||||
mimeType,
|
||||
true, // create parent folder if not existent
|
||||
UploadFileOperation.CREATED_AS_INSTANT_PICTURE,
|
||||
needsWifi,
|
||||
needsCharging,
|
||||
true
|
||||
);
|
||||
|
||||
filesystemDataProvider.updateFilesystemFileAsSentForUpload(path,
|
||||
Long.toString(syncedFolder.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
private Long calculateLastModificationTime(File file, SyncedFolder syncedFolder, SimpleDateFormat formatter) {
|
||||
Long lastModificationTime = file.lastModified();
|
||||
|
||||
if (MediaFolderType.IMAGE == syncedFolder.getType()) {
|
||||
String mimeTypeString = FileStorageUtils.getMimeTypeFromName(file.getAbsolutePath());
|
||||
if (MimeType.JPEG.equalsIgnoreCase(mimeTypeString)
|
||||
|| MimeType.TIFF.equalsIgnoreCase(mimeTypeString)) {
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(file.getAbsolutePath());
|
||||
String exifDate = exifInterface.getAttribute(ExifInterface.TAG_DATETIME);
|
||||
if (!TextUtils.isEmpty(exifDate)) {
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
Date dateTime = formatter.parse(exifDate, pos);
|
||||
lastModificationTime = dateTime.getTime();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log_OC.d(TAG, "Failed to get the proper time " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lastModificationTime;
|
||||
}
|
||||
|
||||
private Integer getUploadAction(String action) {
|
||||
switch (action) {
|
||||
case "LOCAL_BEHAVIOUR_FORGET":
|
||||
|
||||
@@ -71,11 +71,10 @@ public class NotificationJob extends Job {
|
||||
try {
|
||||
byte[] base64DecodedSubject = Base64.decode(subject, Base64.DEFAULT);
|
||||
byte[] base64DecodedSignature = Base64.decode(signature, Base64.DEFAULT);
|
||||
PushUtils pushUtils = new PushUtils();
|
||||
PrivateKey privateKey = (PrivateKey) PushUtils.readKeyFromFile(false);
|
||||
|
||||
try {
|
||||
SignatureVerification signatureVerification = pushUtils.verifySignature(context,
|
||||
SignatureVerification signatureVerification = PushUtils.verifySignature(context,
|
||||
base64DecodedSignature, base64DecodedSubject);
|
||||
|
||||
if (signatureVerification.isSignatureValid()) {
|
||||
|
||||
@@ -84,9 +84,9 @@ public class OfflineSyncJob extends Job {
|
||||
if (cursorOnKeptInSync != null) {
|
||||
if (cursorOnKeptInSync.moveToFirst()) {
|
||||
|
||||
String localPath = "";
|
||||
String accountName = "";
|
||||
Account account = null;
|
||||
String localPath;
|
||||
String accountName;
|
||||
Account account;
|
||||
do {
|
||||
localPath = cursorOnKeptInSync.getString(cursorOnKeptInSync
|
||||
.getColumnIndex(ProviderMeta.ProviderTableMeta.FILE_STORAGE_PATH));
|
||||
|
||||
@@ -100,10 +100,10 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
private static final float DUCK_VOLUME = 0.1f;
|
||||
|
||||
/** Media player instance */
|
||||
private MediaPlayer mPlayer = null;
|
||||
private MediaPlayer mPlayer;
|
||||
|
||||
/** Reference to the system AudioManager */
|
||||
private AudioManager mAudioManager = null;
|
||||
private AudioManager mAudioManager;
|
||||
|
||||
|
||||
/** Values to indicate the state of the service */
|
||||
@@ -426,9 +426,9 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
private void tryToGetAudioFocus() {
|
||||
if (mAudioFocus != AudioFocus.FOCUS
|
||||
&& mAudioManager != null
|
||||
&& (AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this,
|
||||
&& AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.requestAudioFocus(this,
|
||||
AudioManager.STREAM_MUSIC,
|
||||
AudioManager.AUDIOFOCUS_GAIN))
|
||||
AudioManager.AUDIOFOCUS_GAIN)
|
||||
) {
|
||||
mAudioFocus = AudioFocus.FOCUS;
|
||||
}
|
||||
@@ -700,7 +700,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
}
|
||||
|
||||
|
||||
protected void setMediaContoller(MediaControlView mediaController) {
|
||||
protected void setMediaController(MediaControlView mediaController) {
|
||||
mMediaController = mediaController;
|
||||
}
|
||||
|
||||
@@ -734,7 +734,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
|
||||
protected void onPostExecute(String url) {
|
||||
MediaService mediaService = mediaServiceWeakReference.get();
|
||||
|
||||
if (mediaService != null) {
|
||||
if (mediaService != null && mediaService.getCurrentFile() != null) {
|
||||
if (url != null) {
|
||||
try {
|
||||
mediaService.mPlayer.setDataSource(url);
|
||||
|
||||
@@ -118,7 +118,7 @@ public class MediaServiceBinder extends Binder implements MediaController.MediaP
|
||||
@Override
|
||||
public boolean isPlaying() {
|
||||
MediaService.State currentState = mService.getState();
|
||||
return (currentState == State.PLAYING || (currentState == State.PREPARING && mService.mPlayOnPrepared));
|
||||
return currentState == State.PLAYING || (currentState == State.PREPARING && mService.mPlayOnPrepared);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,27 +157,25 @@ public class MediaServiceBinder extends Binder implements MediaController.MediaP
|
||||
|
||||
|
||||
public void registerMediaController(MediaControlView mediaController) {
|
||||
mService.setMediaContoller(mediaController);
|
||||
mService.setMediaController(mediaController);
|
||||
}
|
||||
|
||||
public void unregisterMediaController(MediaControlView mediaController) {
|
||||
if (mediaController != null && mediaController == mService.getMediaController()) {
|
||||
mService.setMediaContoller(null);
|
||||
mService.setMediaController(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isInPlaybackState() {
|
||||
MediaService.State currentState = mService.getState();
|
||||
return (currentState == MediaService.State.PLAYING || currentState == MediaService.State.PAUSED);
|
||||
return currentState == MediaService.State.PLAYING || currentState == MediaService.State.PAUSED;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getAudioSessionId() {
|
||||
return 1; // not really used
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* ownCloud Android client application
|
||||
/* ownCloud Android client application
|
||||
* Copyright (C) 2012-2014 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -12,7 +12,6 @@
|
||||
*
|
||||
* 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.operations;
|
||||
@@ -36,10 +35,8 @@ public class CopyFileOperation extends SyncOperation {
|
||||
|
||||
private String mSrcPath;
|
||||
private String mTargetParentPath;
|
||||
|
||||
private OCFile mFile;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -63,8 +60,6 @@ public class CopyFileOperation extends SyncOperation {
|
||||
*/
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
|
||||
/// 1. check copy validity
|
||||
if (mTargetParentPath.startsWith(mSrcPath)) {
|
||||
return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT);
|
||||
@@ -84,7 +79,8 @@ public class CopyFileOperation extends SyncOperation {
|
||||
targetPath,
|
||||
false
|
||||
);
|
||||
result = operation.execute(client);
|
||||
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
|
||||
/// 3. local copy
|
||||
if (result.isSuccess()) {
|
||||
@@ -94,6 +90,4 @@ public class CopyFileOperation extends SyncOperation {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -154,21 +154,21 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
File newFile;
|
||||
boolean moved;
|
||||
|
||||
/// download will be performed to a temporal file, then moved to the final location
|
||||
File tmpFile = new File(getTmpPath());
|
||||
|
||||
String tmpFolder = getTmpFolder();
|
||||
|
||||
/// perform the download
|
||||
synchronized(mCancellationRequested) {
|
||||
if (mCancellationRequested.get()) {
|
||||
return new RemoteOperationResult(new OperationCancelledException());
|
||||
}
|
||||
}
|
||||
|
||||
RemoteOperationResult result;
|
||||
File newFile;
|
||||
boolean moved;
|
||||
|
||||
/// download will be performed to a temporal file, then moved to the final location
|
||||
File tmpFile = new File(getTmpPath());
|
||||
|
||||
String tmpFolder = getTmpFolder();
|
||||
|
||||
mDownloadOperation = new DownloadRemoteFileOperation(mFile.getRemotePath(), tmpFolder);
|
||||
Iterator<OnDatatransferProgressListener> listener = mDataTransferListeners.iterator();
|
||||
|
||||
@@ -49,7 +49,6 @@ public class GetServerInfoOperation extends RemoteOperation {
|
||||
|
||||
private String mUrl;
|
||||
private Context mContext;
|
||||
|
||||
private ServerInfo mResultData;
|
||||
|
||||
/**
|
||||
@@ -62,11 +61,9 @@ public class GetServerInfoOperation extends RemoteOperation {
|
||||
public GetServerInfoOperation(String url, Context context) {
|
||||
mUrl = trimWebdavSuffix(url);
|
||||
mContext = context;
|
||||
|
||||
mResultData = new ServerInfo();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the operation
|
||||
*
|
||||
@@ -85,7 +82,7 @@ public class GetServerInfoOperation extends RemoteOperation {
|
||||
if (result.isSuccess()) {
|
||||
// second: get authentication method required by the server
|
||||
mResultData.mVersion = (OwnCloudVersion)(result.getData().get(0));
|
||||
mResultData.mIsSslConn = (result.getCode() == ResultCode.OK_SSL);
|
||||
mResultData.mIsSslConn = result.getCode() == ResultCode.OK_SSL;
|
||||
mResultData.mBaseUrl = normalizeProtocolPrefix(mUrl, mResultData.mIsSslConn);
|
||||
RemoteOperationResult detectAuthResult = detectAuthorizationMethod(client);
|
||||
|
||||
@@ -143,10 +140,10 @@ public class GetServerInfoOperation extends RemoteOperation {
|
||||
|
||||
|
||||
public static class ServerInfo {
|
||||
public OwnCloudVersion mVersion = null;
|
||||
public OwnCloudVersion mVersion;
|
||||
public String mBaseUrl = "";
|
||||
public AuthenticationMethod mAuthMethod = AuthenticationMethod.UNKNOWN;
|
||||
public boolean mIsSslConn = false;
|
||||
public boolean mIsSslConn;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -15,7 +15,6 @@
|
||||
*
|
||||
* 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.operations;
|
||||
@@ -37,7 +36,6 @@ public class MoveFileOperation extends SyncOperation {
|
||||
|
||||
private String mSrcPath;
|
||||
private String mTargetParentPath;
|
||||
|
||||
private OCFile mFile;
|
||||
|
||||
/**
|
||||
@@ -63,8 +61,6 @@ public class MoveFileOperation extends SyncOperation {
|
||||
*/
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
|
||||
/// 1. check move validity
|
||||
if (mTargetParentPath.startsWith(mSrcPath)) {
|
||||
return new RemoteOperationResult(ResultCode.INVALID_MOVE_INTO_DESCENDANT);
|
||||
@@ -84,7 +80,7 @@ public class MoveFileOperation extends SyncOperation {
|
||||
targetPath,
|
||||
false
|
||||
);
|
||||
result = operation.execute(client);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
|
||||
/// 3. local move
|
||||
if (result.isSuccess()) {
|
||||
|
||||
@@ -37,9 +37,11 @@ import java.util.Map;
|
||||
|
||||
|
||||
public class OAuth2GetAccessToken extends RemoteOperation {
|
||||
|
||||
private static final String TAG = OAuth2GetAccessToken.class.getSimpleName();
|
||||
|
||||
|
||||
private static final int KEY_INDEX = 0;
|
||||
private static final int VALUE_INDEX = 1;
|
||||
|
||||
private String mClientId;
|
||||
private String mRedirectUri;
|
||||
private String mGrantType;
|
||||
@@ -149,9 +151,9 @@ public class OAuth2GetAccessToken extends RemoteOperation {
|
||||
String[] part = pairs[i].split("=");
|
||||
while (part.length > j) {
|
||||
String p = part[j];
|
||||
if (j == 0) {
|
||||
if (j == KEY_INDEX) {
|
||||
key = p;
|
||||
} else if (j == 1) {
|
||||
} else if (j == VALUE_INDEX) {
|
||||
value = p;
|
||||
mOAuth2ParsedAuthorizationResponse.put(key, value);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
* <p>
|
||||
*
|
||||
* 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.
|
||||
* <p>
|
||||
*
|
||||
* 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.
|
||||
* <p>
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -39,6 +39,7 @@ import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
||||
import com.owncloud.android.utils.DataHolderUtil;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
@@ -344,7 +345,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
*
|
||||
* @param folderAndFiles Remote folder and children files in Folder
|
||||
*/
|
||||
private void synchronizeData(ArrayList<Object> folderAndFiles) {
|
||||
private void synchronizeData(List<Object> folderAndFiles) {
|
||||
// get 'fresh data' from the database
|
||||
mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
|
||||
|
||||
@@ -362,6 +363,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, mStorageManager);
|
||||
mLocalFolder.setEncrypted(encryptedAncestor);
|
||||
|
||||
// update permission
|
||||
mLocalFolder.setPermissions(remoteFolder.getPermissions());
|
||||
|
||||
DecryptedFolderMetadata metadata = getDecryptedFolderMetadata(encryptedAncestor);
|
||||
|
||||
// get current data about local contents of the folder to synchronize
|
||||
@@ -397,10 +401,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
|
||||
// prepare content synchronization for kept-in-sync files
|
||||
if (updatedFile.isAvailableOffline()) {
|
||||
SynchronizeFileOperation operation = new SynchronizeFileOperation(localFile, remoteFile, mAccount, true,
|
||||
mContext);
|
||||
|
||||
mFilesToSyncContents.add(operation);
|
||||
mFilesToSyncContents.add(
|
||||
new SynchronizeFileOperation(localFile, remoteFile, mAccount, true, mContext)
|
||||
);
|
||||
}
|
||||
|
||||
// update file name for encrypted files
|
||||
@@ -550,8 +553,13 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
if (result.isSuccess()) {
|
||||
// update local database
|
||||
ArrayList<OCShare> shares = new ArrayList<>();
|
||||
OCShare share;
|
||||
for (Object obj : result.getData()) {
|
||||
shares.add((OCShare) obj);
|
||||
share = (OCShare) obj;
|
||||
|
||||
if (!ShareType.NO_SHARED.equals(share.getShareType())) {
|
||||
shares.add(share);
|
||||
}
|
||||
}
|
||||
mStorageManager.saveSharesInFolder(shares, mLocalFolder);
|
||||
}
|
||||
|
||||
@@ -81,9 +81,8 @@ public class RenameFileOperation extends SyncOperation {
|
||||
if (!isValidNewName()) {
|
||||
return new RemoteOperationResult(ResultCode.INVALID_LOCAL_FILE_NAME);
|
||||
}
|
||||
String parent = (new File(mFile.getRemotePath())).getParent();
|
||||
parent = (parent.endsWith(OCFile.PATH_SEPARATOR)) ? parent : parent +
|
||||
OCFile.PATH_SEPARATOR;
|
||||
String parent = new File(mFile.getRemotePath()).getParent();
|
||||
parent = parent.endsWith(OCFile.PATH_SEPARATOR) ? parent : parent + OCFile.PATH_SEPARATOR;
|
||||
mNewRemotePath = parent + mNewName;
|
||||
if (mFile.isFolder()) {
|
||||
mNewRemotePath += OCFile.PATH_SEPARATOR;
|
||||
|
||||
@@ -50,8 +50,7 @@ public class SynchronizeFileOperation extends SyncOperation {
|
||||
private Account mAccount;
|
||||
private boolean mSyncFileContents;
|
||||
private Context mContext;
|
||||
|
||||
private boolean mTransferWasRequested = false;
|
||||
private boolean mTransferWasRequested;
|
||||
|
||||
/**
|
||||
* When 'false', uploads to the server are not done; only downloads or conflict detection.
|
||||
@@ -212,9 +211,8 @@ public class SynchronizeFileOperation extends SyncOperation {
|
||||
} else {
|
||||
serverChanged = !mServerFile.getEtag().equals(mLocalFile.getEtag());
|
||||
}
|
||||
boolean localChanged = (
|
||||
mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData()
|
||||
);
|
||||
boolean localChanged =
|
||||
mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData();
|
||||
|
||||
/// decide action to perform depending upon changes
|
||||
//if (!mLocalFile.getEtag().isEmpty() && localChanged && serverChanged) {
|
||||
|
||||
@@ -172,7 +172,6 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
Log_OC.d(TAG, "Checking changes in " + mAccount.name + mRemotePath);
|
||||
|
||||
mRemoteFolderChanged = true;
|
||||
RemoteOperationResult result;
|
||||
|
||||
if (mCancellationRequested.get()) {
|
||||
throw new OperationCancelledException();
|
||||
@@ -180,7 +179,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
|
||||
// remote request
|
||||
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mRemotePath);
|
||||
result = operation.execute(client);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
if (result.isSuccess()) {
|
||||
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
|
||||
|
||||
@@ -243,10 +242,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
storageManager.removeFolder(
|
||||
mLocalFolder,
|
||||
true,
|
||||
( mLocalFolder.isDown() && // TODO: debug, I think this is
|
||||
// always false for folders
|
||||
mLocalFolder.getStoragePath().startsWith(currentSavePath)
|
||||
)
|
||||
mLocalFolder.isDown() // TODO: debug, I think this is always false for folders
|
||||
&& mLocalFolder.getStoragePath().startsWith(currentSavePath)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -261,8 +258,6 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
* @param folderAndFiles Remote folder and children files in Folder
|
||||
*/
|
||||
private void synchronizeData(List<Object> folderAndFiles) throws OperationCancelledException {
|
||||
FileDataStorageManager storageManager = getStorageManager();
|
||||
|
||||
// parse data from remote folder
|
||||
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) folderAndFiles.get(0));
|
||||
remoteFolder.setParentId(mLocalFolder.getParentId());
|
||||
@@ -271,7 +266,6 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
Log_OC.d(TAG, "Remote folder " + mLocalFolder.getRemotePath()
|
||||
+ " changed - starting update of local data ");
|
||||
|
||||
List<OCFile> updatedFiles = new Vector<>(folderAndFiles.size() - 1);
|
||||
mFilesForDirectDownload.clear();
|
||||
mFilesToSyncContents.clear();
|
||||
|
||||
@@ -279,6 +273,9 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
throw new OperationCancelledException();
|
||||
}
|
||||
|
||||
FileDataStorageManager storageManager = getStorageManager();
|
||||
List<OCFile> updatedFiles = new Vector<>(folderAndFiles.size() - 1);
|
||||
|
||||
// get current data about local contents of the folder to synchronize
|
||||
List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder, false);
|
||||
Map<String, OCFile> localFilesMap = new HashMap<>(localFiles.size());
|
||||
@@ -398,7 +395,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
/// this should result in direct upload of files that were locally modified
|
||||
SynchronizeFileOperation operation = new SynchronizeFileOperation(
|
||||
child,
|
||||
(child.getEtagInConflict() != null ? child : null),
|
||||
child.getEtagInConflict() != null ? child : null,
|
||||
mAccount,
|
||||
true,
|
||||
mContext
|
||||
|
||||
@@ -43,7 +43,8 @@ import java.util.List;
|
||||
public class UnshareOperation extends SyncOperation {
|
||||
|
||||
private static final String TAG = UnshareOperation.class.getSimpleName();
|
||||
|
||||
private static final int SINGLY_SHARED = 1;
|
||||
|
||||
private String mRemotePath;
|
||||
private ShareType mShareType;
|
||||
private String mShareWith;
|
||||
@@ -83,7 +84,7 @@ public class UnshareOperation extends SyncOperation {
|
||||
List <OCShare> sharesWith = getStorageManager().
|
||||
getSharesWithForAFile(mRemotePath,
|
||||
getStorageManager().getAccount().name);
|
||||
if (sharesWith.size() == 1) {
|
||||
if (sharesWith.size() == SINGLY_SHARED) {
|
||||
file.setShareWithSharee(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,14 +48,10 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
* @param path Full path of the file/folder being shared. Mandatory argument
|
||||
*/
|
||||
public UpdateShareViaLinkOperation(String path) {
|
||||
|
||||
mPath = path;
|
||||
mPassword = null;
|
||||
mExpirationDateInMillis = 0;
|
||||
mPublicUpload = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set password to update in public link.
|
||||
*
|
||||
@@ -67,7 +63,6 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
mPassword = password;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set expiration date to update in Share resource.
|
||||
*
|
||||
@@ -90,7 +85,6 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
mPublicUpload = publicUpload;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
|
||||
@@ -157,6 +151,5 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
getStorageManager().saveFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
/**
|
||||
* Local path to file which is to be uploaded (before any possible renaming or moving).
|
||||
*/
|
||||
private String mOriginalStoragePath = null;
|
||||
private String mOriginalStoragePath;
|
||||
private Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<>();
|
||||
private OnRenameListener mRenameUploadListener;
|
||||
|
||||
@@ -138,7 +138,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
|
||||
private UploadRemoteFileOperation mUploadOperation;
|
||||
|
||||
protected RequestEntity mEntity = null;
|
||||
protected RequestEntity mEntity;
|
||||
|
||||
private Account mAccount;
|
||||
private OCUpload mUpload;
|
||||
@@ -215,7 +215,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
mCreatedBy = upload.getCreatedBy();
|
||||
mRemoteFolderToBeCreated = upload.isCreateRemoteFolder();
|
||||
// Ignore power save mode only if user explicitly created this upload
|
||||
mIgnoringPowerSaveMode = (mCreatedBy == CREATED_BY_USER);
|
||||
mIgnoringPowerSaveMode = mCreatedBy == CREATED_BY_USER;
|
||||
mFolderUnlockToken = upload.getFolderUnlockToken();
|
||||
}
|
||||
|
||||
@@ -699,12 +699,10 @@ public class UploadFileOperation extends SyncOperation {
|
||||
|
||||
private RemoteOperationResult unlockFolder(OCFile parentFolder, OwnCloudClient client, String token) {
|
||||
if (token != null) {
|
||||
UnlockFileOperation unlockFileOperation = new UnlockFileOperation(parentFolder.getLocalId(), token);
|
||||
RemoteOperationResult unlockFileOperationResult = unlockFileOperation.execute(client, true);
|
||||
|
||||
return unlockFileOperationResult;
|
||||
} else
|
||||
return new UnlockFileOperation(parentFolder.getLocalId(), token).execute(client, true);
|
||||
} else {
|
||||
return new RemoteOperationResult(new Exception("No token available"));
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteOperationResult checkConditions(File originalFile) {
|
||||
@@ -723,8 +721,8 @@ public class UploadFileOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
// check if charging conditions are met and delays the upload otherwise
|
||||
if (mWhileChargingOnly && (!Device.getBatteryStatus(mContext).isCharging() && Device.getBatteryStatus(mContext)
|
||||
.getBatteryPercent() < 1)) {
|
||||
if (mWhileChargingOnly && !Device.getBatteryStatus(mContext).isCharging()
|
||||
&& Device.getBatteryStatus(mContext).getBatteryPercent() < 1) {
|
||||
Log_OC.d(TAG, "Upload delayed until the device is charging: " + getRemotePath());
|
||||
remoteOperationResult = new RemoteOperationResult(ResultCode.DELAYED_FOR_CHARGING);
|
||||
}
|
||||
|
||||
@@ -86,18 +86,20 @@ public class FileContentProvider extends ContentProvider {
|
||||
private static final String ADD_COLUMN = " ADD COLUMN ";
|
||||
private static final String REMOVE_COLUMN = " REMOVE COLUMN ";
|
||||
private static final String UPGRADE_VERSION_MSG = "OUT of the ADD in onUpgrade; oldVersion == %d, newVersion == %d";
|
||||
private static final int SINGLE_PATH_SEGMENT = 1;
|
||||
public static final int ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION = 20;
|
||||
|
||||
private DataBaseHelper mDbHelper;
|
||||
private Context mContext;
|
||||
private UriMatcher mUriMatcher;
|
||||
|
||||
@Override
|
||||
public int delete(@NonNull Uri uri, String where, String[] whereArgs) {
|
||||
int count;
|
||||
|
||||
if (isCallerNotAllowed()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int count;
|
||||
SQLiteDatabase db = mDbHelper.getWritableDatabase();
|
||||
db.beginTransaction();
|
||||
try {
|
||||
@@ -110,95 +112,20 @@ public class FileContentProvider extends ContentProvider {
|
||||
return count;
|
||||
}
|
||||
|
||||
private int delete(SQLiteDatabase db, Uri uri, String where, String[] whereArgs) {
|
||||
private int delete(SQLiteDatabase db, Uri uri, String where, String... whereArgs) {
|
||||
if (isCallerNotAllowed()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
int count;
|
||||
switch (mUriMatcher.match(uri)) {
|
||||
case SINGLE_FILE:
|
||||
Cursor c = query(db, uri, null, where, whereArgs, null);
|
||||
String remoteId = "";
|
||||
try {
|
||||
if (c != null && c.moveToFirst()) {
|
||||
remoteId = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID));
|
||||
//ThumbnailsCacheManager.removeFileFromCache(remoteId);
|
||||
}
|
||||
Log_OC.d(TAG, "Removing FILE " + remoteId);
|
||||
|
||||
count = db.delete(ProviderTableMeta.FILE_TABLE_NAME,
|
||||
ProviderTableMeta._ID
|
||||
+ "="
|
||||
+ uri.getPathSegments().get(1)
|
||||
+ (!TextUtils.isEmpty(where) ? " AND (" + where + ")" : ""),
|
||||
whereArgs);
|
||||
} catch (Exception e) {
|
||||
Log_OC.d(TAG, "DB-Error removing file!", e);
|
||||
} finally {
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
count = deleteSingleFile(db, uri, where, whereArgs);
|
||||
break;
|
||||
case DIRECTORY:
|
||||
// deletion of folder is recursive
|
||||
/*
|
||||
Uri folderUri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, Long.parseLong(uri.getPathSegments().get(1)));
|
||||
Cursor folder = query(db, folderUri, null, null, null, null);
|
||||
String folderName = "(unknown)";
|
||||
if (folder != null && folder.moveToFirst()) {
|
||||
folderName = folder.getString(folder.getColumnIndex(ProviderTableMeta.FILE_PATH));
|
||||
}
|
||||
*/
|
||||
Cursor children = query(uri, null, null, null, null);
|
||||
if (children != null) {
|
||||
if (children.moveToFirst()) {
|
||||
long childId;
|
||||
boolean isDir;
|
||||
while (!children.isAfterLast()) {
|
||||
childId = children.getLong(children.getColumnIndex(ProviderTableMeta._ID));
|
||||
isDir = MimeType.DIRECTORY.equals(children.getString(
|
||||
children.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)
|
||||
));
|
||||
//remotePath = children.getString(children.getColumnIndex(ProviderTableMeta.FILE_PATH));
|
||||
if (isDir) {
|
||||
count += delete(
|
||||
db,
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, childId),
|
||||
null,
|
||||
null
|
||||
);
|
||||
} else {
|
||||
count += delete(
|
||||
db,
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, childId),
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
children.moveToNext();
|
||||
}
|
||||
}
|
||||
children.close();
|
||||
} /*else {
|
||||
Log_OC.d(TAG, "No child to remove in DIRECTORY " + folderName);
|
||||
}
|
||||
Log_OC.d(TAG, "Removing DIRECTORY " + folderName + " (or maybe not) ");
|
||||
*/
|
||||
count += db.delete(ProviderTableMeta.FILE_TABLE_NAME,
|
||||
ProviderTableMeta._ID
|
||||
+ "="
|
||||
+ uri.getPathSegments().get(1)
|
||||
+ (!TextUtils.isEmpty(where) ? " AND (" + where
|
||||
+ ")" : ""), whereArgs);
|
||||
/* Just for log
|
||||
if (folder != null) {
|
||||
folder.close();
|
||||
}*/
|
||||
count = deleteDirectory(db, uri, where, whereArgs);
|
||||
break;
|
||||
case ROOT_DIRECTORY:
|
||||
//Log_OC.d(TAG, "Removing ROOT!");
|
||||
count = db.delete(ProviderTableMeta.FILE_TABLE_NAME, where, whereArgs);
|
||||
break;
|
||||
case SHARES:
|
||||
@@ -226,9 +153,82 @@ public class FileContentProvider extends ContentProvider {
|
||||
count = db.delete(ProviderTableMeta.FILESYSTEM_TABLE_NAME, where, whereArgs);
|
||||
break;
|
||||
default:
|
||||
//Log_OC.e(TAG, "Unknown uri " + uri);
|
||||
throw new IllegalArgumentException("Unknown uri: " + uri.toString());
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private int deleteDirectory(SQLiteDatabase db, Uri uri, String where, String... whereArgs) {
|
||||
int count = 0;
|
||||
|
||||
Cursor children = query(uri, null, null, null, null);
|
||||
if (children != null) {
|
||||
if (children.moveToFirst()) {
|
||||
long childId;
|
||||
boolean isDir;
|
||||
while (!children.isAfterLast()) {
|
||||
childId = children.getLong(children.getColumnIndex(ProviderTableMeta._ID));
|
||||
isDir = MimeType.DIRECTORY.equals(children.getString(
|
||||
children.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)
|
||||
));
|
||||
//remotePath = children.getString(children.getColumnIndex(ProviderTableMeta.FILE_PATH));
|
||||
if (isDir) {
|
||||
count += delete(
|
||||
db,
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, childId),
|
||||
null,
|
||||
(String[]) null
|
||||
);
|
||||
} else {
|
||||
count += delete(
|
||||
db,
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, childId),
|
||||
null,
|
||||
(String[]) null
|
||||
);
|
||||
}
|
||||
children.moveToNext();
|
||||
}
|
||||
}
|
||||
children.close();
|
||||
}
|
||||
|
||||
count += db.delete(ProviderTableMeta.FILE_TABLE_NAME,
|
||||
ProviderTableMeta._ID
|
||||
+ "="
|
||||
+ uri.getPathSegments().get(1)
|
||||
+ (!TextUtils.isEmpty(where) ? " AND (" + where
|
||||
+ ")" : ""), whereArgs);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private int deleteSingleFile(SQLiteDatabase db, Uri uri, String where, String... whereArgs) {
|
||||
int count = 0;
|
||||
Cursor c = query(db, uri, null, where, whereArgs, null);
|
||||
String remoteId = "";
|
||||
try {
|
||||
if (c != null && c.moveToFirst()) {
|
||||
remoteId = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID));
|
||||
//ThumbnailsCacheManager.removeFileFromCache(remoteId);
|
||||
}
|
||||
Log_OC.d(TAG, "Removing FILE " + remoteId);
|
||||
|
||||
count = db.delete(ProviderTableMeta.FILE_TABLE_NAME,
|
||||
ProviderTableMeta._ID
|
||||
+ "="
|
||||
+ uri.getPathSegments().get(1)
|
||||
+ (!TextUtils.isEmpty(where) ? " AND (" + where + ")" : ""),
|
||||
whereArgs);
|
||||
} catch (Exception e) {
|
||||
Log_OC.d(TAG, "DB-Error removing file!", e);
|
||||
} finally {
|
||||
if (c != null) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -504,67 +504,66 @@ public class FileContentProvider extends ContentProvider {
|
||||
case ROOT_DIRECTORY:
|
||||
break;
|
||||
case DIRECTORY:
|
||||
String folderId = uri.getPathSegments().get(1);
|
||||
sqlQuery.appendWhere(ProviderTableMeta.FILE_PARENT + "="
|
||||
+ folderId);
|
||||
+ uri.getPathSegments().get(1));
|
||||
break;
|
||||
case SINGLE_FILE:
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case SHARES:
|
||||
sqlQuery.setTables(ProviderTableMeta.OCSHARES_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case CAPABILITIES:
|
||||
sqlQuery.setTables(ProviderTableMeta.CAPABILITIES_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case UPLOADS:
|
||||
sqlQuery.setTables(ProviderTableMeta.UPLOADS_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case SYNCED_FOLDERS:
|
||||
sqlQuery.setTables(ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case EXTERNAL_LINKS:
|
||||
sqlQuery.setTables(ProviderTableMeta.EXTERNAL_LINKS_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case ARBITRARY_DATA:
|
||||
sqlQuery.setTables(ProviderTableMeta.ARBITRARY_DATA_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case VIRTUAL:
|
||||
sqlQuery.setTables(ProviderTableMeta.VIRTUAL_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "=" + uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case FILESYSTEM:
|
||||
sqlQuery.setTables(ProviderTableMeta.FILESYSTEM_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
@@ -654,13 +653,12 @@ public class FileContentProvider extends ContentProvider {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
private int update(
|
||||
SQLiteDatabase db,
|
||||
Uri uri,
|
||||
ContentValues values,
|
||||
String selection,
|
||||
String[] selectionArgs
|
||||
String... selectionArgs
|
||||
) {
|
||||
switch (mUriMatcher.match(uri)) {
|
||||
case DIRECTORY:
|
||||
@@ -1633,7 +1631,7 @@ public class FileContentProvider extends ContentProvider {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_ENCRYPTED_NAME + " TEXT ");
|
||||
}
|
||||
if (oldVersion > 20) {
|
||||
if (oldVersion > ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION) {
|
||||
if (!checkIfColumnExists(db, ProviderTableMeta.CAPABILITIES_TABLE_NAME,
|
||||
ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION)) {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -18,7 +18,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.owncloud.android.providers;
|
||||
|
||||
import android.accounts.Account;
|
||||
@@ -32,6 +31,7 @@ import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -84,7 +85,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
private UriMatcher mUriMatcher;
|
||||
|
||||
private static HashMap<String, ShareType> sShareTypes = new HashMap<>();
|
||||
private static Map<String, ShareType> sShareTypes = new HashMap<>();
|
||||
|
||||
public static ShareType getShareType(String authority) {
|
||||
|
||||
@@ -93,7 +94,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
public String getType(@NonNull Uri uri) {
|
||||
// TODO implement
|
||||
return null;
|
||||
}
|
||||
@@ -119,7 +120,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
/**
|
||||
* TODO description
|
||||
* <p/>
|
||||
*
|
||||
* Reference: http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#CustomContentProvider
|
||||
*
|
||||
* @param uri Content {@link Uri}, formattted as
|
||||
@@ -133,7 +134,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
Log_OC.d(TAG, "query received in thread " + Thread.currentThread().getName());
|
||||
|
||||
int match = mUriMatcher.match(uri);
|
||||
@@ -240,19 +241,19 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
public Uri insert(@NonNull Uri uri, ContentValues values) {
|
||||
// TODO implementation
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
|
||||
// TODO implementation
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
// TODO implementation
|
||||
return 0;
|
||||
}
|
||||
@@ -283,5 +284,4 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Nextcloud SingleSignOn
|
||||
*
|
||||
* @author David Luhmer
|
||||
*
|
||||
* 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.services;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.nextcloud.android.sso.InputStreamBinder;
|
||||
|
||||
public class AccountManagerService extends Service {
|
||||
|
||||
private InputStreamBinder mBinder;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
if(mBinder == null) {
|
||||
mBinder = new InputStreamBinder(this);
|
||||
}
|
||||
return mBinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUnbind(Intent intent) {
|
||||
return super.onUnbind(intent);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -269,10 +269,9 @@ public class OperationsService extends Service {
|
||||
* Map of listeners that will be reported about the end of operations from a
|
||||
* {@link OperationsServiceBinder} instance
|
||||
*/
|
||||
private final ConcurrentMap<OnRemoteOperationListener, Handler> mBoundListeners =
|
||||
new ConcurrentHashMap<OnRemoteOperationListener, Handler>();
|
||||
private final ConcurrentMap<OnRemoteOperationListener, Handler> mBoundListeners = new ConcurrentHashMap<>();
|
||||
|
||||
private ServiceHandler mServiceHandler = null;
|
||||
private ServiceHandler mServiceHandler;
|
||||
|
||||
public OperationsServiceBinder(ServiceHandler serviceHandler) {
|
||||
mServiceHandler = serviceHandler;
|
||||
@@ -355,7 +354,6 @@ public class OperationsService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean dispatchResultIfFinished(int operationId,
|
||||
OnRemoteOperationListener listener) {
|
||||
Pair<RemoteOperation, RemoteOperationResult> undispatched =
|
||||
@@ -363,13 +361,11 @@ public class OperationsService extends Service {
|
||||
if (undispatched != null) {
|
||||
listener.onRemoteOperationFinish(undispatched.first, undispatched.second);
|
||||
return true;
|
||||
//Log_OC.e(TAG, "Sending callback later");
|
||||
} else {
|
||||
return (!mServiceHandler.mPendingOperations.isEmpty());
|
||||
return !mServiceHandler.mPendingOperations.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns True when the file described by 'file' in the ownCloud account 'account' is
|
||||
* downloading or waiting to download.
|
||||
@@ -402,10 +398,10 @@ public class OperationsService extends Service {
|
||||
|
||||
|
||||
private ConcurrentLinkedQueue<Pair<Target, RemoteOperation>> mPendingOperations =
|
||||
new ConcurrentLinkedQueue<Pair<Target, RemoteOperation>>();
|
||||
private RemoteOperation mCurrentOperation = null;
|
||||
private Target mLastTarget = null;
|
||||
private OwnCloudClient mOwnCloudClient = null;
|
||||
new ConcurrentLinkedQueue<>();
|
||||
private RemoteOperation mCurrentOperation;
|
||||
private Target mLastTarget;
|
||||
private OwnCloudClient mOwnCloudClient;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
|
||||
|
||||
@@ -423,7 +419,6 @@ public class OperationsService extends Service {
|
||||
Log_OC.d(TAG, "Stopping after command with id " + msg.arg1);
|
||||
mService.stopSelf(msg.arg1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Performs the next operation in the queue
|
||||
@@ -622,13 +617,13 @@ public class OperationsService extends Service {
|
||||
remotePath,
|
||||
shareType,
|
||||
shareWith,
|
||||
OperationsService.this
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
} else if (ACTION_GET_SERVER_INFO.equals(action)) {
|
||||
// check OC server and get basic information from it
|
||||
operation = new GetServerInfoOperation(serverUrl, OperationsService.this);
|
||||
operation = new GetServerInfoOperation(serverUrl, this);
|
||||
|
||||
} else if (ACTION_OAUTH2_GET_ACCESS_TOKEN.equals(action)) {
|
||||
/// GET ACCESS TOKEN to the OAuth server
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.SynchronizeFolderOperation;
|
||||
import com.owncloud.android.operations.UpdateOCVersionOperation;
|
||||
import com.owncloud.android.ui.activity.ErrorsWhileCopyingHandlerActivity;
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils;
|
||||
@@ -141,9 +142,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
SyncResult syncResult) {
|
||||
|
||||
mCancellation = false;
|
||||
/* When 'true' the process was requested by the user through the user interface;
|
||||
when 'false', it was requested automatically by the system */
|
||||
boolean mIsManualSync = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
|
||||
mFailedResultsCounter = 0;
|
||||
mLastFailedResult = null;
|
||||
mConflictsFound = 0;
|
||||
@@ -170,7 +168,10 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
Log_OC.d(TAG, "Synchronization of ownCloud account " + account.name + " starting");
|
||||
sendLocalBroadcast(EVENT_FULL_SYNC_START, null, null); // message to signal the start
|
||||
// of the synchronization to the UI
|
||||
|
||||
|
||||
/* When 'true' the process was requested by the user through the user interface;
|
||||
when 'false', it was requested automatically by the system */
|
||||
boolean mIsManualSync = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
|
||||
try {
|
||||
updateOCVersion();
|
||||
mCurrentSyncTime = System.currentTimeMillis();
|
||||
@@ -182,7 +183,6 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
"because cancellation request");
|
||||
}
|
||||
|
||||
|
||||
} finally {
|
||||
// it's important making this although very unexpected errors occur;
|
||||
// that's the reason for the finally
|
||||
@@ -316,12 +316,12 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
* synchronization
|
||||
*/
|
||||
private boolean isFinisher(RemoteOperationResult failedResult) {
|
||||
if (failedResult != null) {
|
||||
if (failedResult != null) {
|
||||
RemoteOperationResult.ResultCode code = failedResult.getCode();
|
||||
return (code.equals(RemoteOperationResult.ResultCode.SSL_ERROR) ||
|
||||
code.equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) ||
|
||||
code.equals(RemoteOperationResult.ResultCode.BAD_OC_VERSION) ||
|
||||
code.equals(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED));
|
||||
return code.equals(RemoteOperationResult.ResultCode.SSL_ERROR)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.BAD_OC_VERSION)
|
||||
|| code.equals(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
*
|
||||
* @param event Event in the process of synchronization to be notified.
|
||||
* @param dirRemotePath Remote path of the folder target of the event occurred.
|
||||
* @param result Result of an individual {@ SynchronizeFolderOperation},
|
||||
* @param result Result of an individual {@link SynchronizeFolderOperation},
|
||||
* if completed; may be null.
|
||||
*/
|
||||
private void sendLocalBroadcast(String event, String dirRemotePath,
|
||||
@@ -389,10 +389,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
*/
|
||||
private void notifyFailedSynchronization() {
|
||||
NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
|
||||
boolean needsToUpdateCredentials = (
|
||||
mLastFailedResult != null &&
|
||||
ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode())
|
||||
);
|
||||
boolean needsToUpdateCredentials = mLastFailedResult != null
|
||||
&& ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode());
|
||||
if (needsToUpdateCredentials) {
|
||||
// let the user update credentials with one click
|
||||
Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);
|
||||
@@ -522,8 +520,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
|
||||
* @param builder
|
||||
*/
|
||||
private void showNotification(int id, NotificationCompat.Builder builder) {
|
||||
NotificationManager notificationManager = ((NotificationManager) getContext().
|
||||
getSystemService(Context.NOTIFICATION_SERVICE));
|
||||
NotificationManager notificationManager = (NotificationManager) getContext().
|
||||
getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
builder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_FILE_SYNC);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class EmptyRecyclerView extends RecyclerView {
|
||||
int emptyCount = hasFooter ? 1 : 0;
|
||||
boolean empty = getAdapter() == null || getAdapter().getItemCount() == emptyCount;
|
||||
mEmptyView.setVisibility(empty ? VISIBLE : GONE);
|
||||
EmptyRecyclerView.this.setVisibility(empty ? GONE : VISIBLE);
|
||||
this.setVisibility(empty ? GONE : VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ExtendedListView extends ListView {
|
||||
|
||||
private static final String TAG = ExtendedListView.class.getSimpleName();
|
||||
|
||||
private int mPositionToSetAndCenter = 0;
|
||||
private int mPositionToSetAndCenter;
|
||||
|
||||
public ExtendedListView(Context context) {
|
||||
super(context);
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||
/**
|
||||
* Themeable switch preference
|
||||
*/
|
||||
|
||||
public class ThemeableSwitchPreference extends SwitchPreference {
|
||||
|
||||
public ThemeableSwitchPreference(Context context) {
|
||||
@@ -64,24 +63,31 @@ public class ThemeableSwitchPreference extends SwitchPreference {
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
private void findSwitch(ViewGroup viewGroup) {
|
||||
ColorStateList thumbColorStateList = null;
|
||||
ColorStateList trackColorStateList = null;
|
||||
|
||||
for (int i = 0; i < viewGroup.getChildCount(); i++) {
|
||||
View child = viewGroup.getChildAt(i);
|
||||
|
||||
if (child instanceof Switch) {
|
||||
Switch switchView = (Switch) child;
|
||||
|
||||
int color = ThemeUtils.primaryAccentColor(getContext());
|
||||
int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color));
|
||||
if(thumbColorStateList == null && trackColorStateList == null) {
|
||||
int color = ThemeUtils.primaryAccentColor(getContext());
|
||||
int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color));
|
||||
thumbColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{color, Color.WHITE});
|
||||
trackColorStateList = new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{trackColor, Color.parseColor("#4D000000")});
|
||||
}
|
||||
|
||||
// setting the thumb color
|
||||
DrawableCompat.setTintList(switchView.getThumbDrawable(), new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{color, Color.WHITE}));
|
||||
DrawableCompat.setTintList(switchView.getThumbDrawable(), thumbColorStateList);
|
||||
|
||||
// setting the track color
|
||||
DrawableCompat.setTintList(switchView.getTrackDrawable(), new ColorStateList(
|
||||
new int[][]{new int[]{android.R.attr.state_checked}, new int[]{}},
|
||||
new int[]{trackColor, Color.parseColor("#4D000000")}));
|
||||
DrawableCompat.setTintList(switchView.getTrackDrawable(), trackColorStateList);
|
||||
|
||||
break;
|
||||
} else if (child instanceof ViewGroup) {
|
||||
|
||||
+4
-2
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* Copyright (C) 2018 Edvard Holst
|
||||
@@ -34,6 +34,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.activities.GetRemoteActivitiesOperation;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -94,7 +96,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
Log_OC.d(TAG, result.getLogMessage());
|
||||
// show error
|
||||
errorMessage = result.getLogMessage();
|
||||
if (result.getHttpCode() == 304) {
|
||||
if (result.getHttpCode() == HttpStatus.SC_NOT_MODIFIED) {
|
||||
errorMessage = context.getString(R.string.file_list_empty_headline_server_search);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -663,7 +663,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
*
|
||||
* @param accounts list of accounts
|
||||
*/
|
||||
private void repopulateAccountList(ArrayList<Account> accounts) {
|
||||
private void repopulateAccountList(List<Account> accounts) {
|
||||
// remove all accounts from list
|
||||
mNavigationView.getMenu().removeGroup(R.id.drawer_menu_accounts);
|
||||
|
||||
@@ -946,13 +946,13 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
Context context = MainApp.getAppContext();
|
||||
AccountManager mAccountMgr = AccountManager.get(context);
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
|
||||
if (account == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
AccountManager mAccountMgr = AccountManager.get(context);
|
||||
String userId = mAccountMgr.getUserData(account,
|
||||
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
||||
|
||||
@@ -1386,7 +1386,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
getCapabilities.execute(getStorageManager(), getBaseContext());
|
||||
}
|
||||
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(DrawerActivity.this);
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(this);
|
||||
|
||||
if (account != null && getStorageManager() != null &&
|
||||
getStorageManager().getCapability(account.name) != null &&
|
||||
@@ -1405,7 +1405,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
|
||||
Log_OC.d("ExternalLinks", "update via api");
|
||||
RemoteOperation getExternalLinksOperation = new ExternalLinksOperation();
|
||||
RemoteOperationResult result = getExternalLinksOperation.execute(account, DrawerActivity.this);
|
||||
RemoteOperationResult result = getExternalLinksOperation.execute(account, this);
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
externalLinksProvider.deleteAllExternalLinks();
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.owncloud.android.ui.activity;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -77,14 +78,13 @@ import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.FilesSyncHelper;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
||||
/**
|
||||
* Activity with common behaviour for activities handling {@link OCFile}s in ownCloud {@link Account}s .
|
||||
*/
|
||||
public abstract class FileActivity extends DrawerActivity
|
||||
implements OnRemoteOperationListener, ComponentsGetter, SslUntrustedCertDialog.OnSslUntrustedCertListener {
|
||||
implements OnRemoteOperationListener, ComponentsGetter, SslUntrustedCertDialog.OnSslUntrustedCertListener,
|
||||
LoadingVersionNumberTask.VersionDevInterface {
|
||||
|
||||
public static final String EXTRA_FILE = "com.owncloud.android.ui.activity.FILE";
|
||||
public static final String EXTRA_ACCOUNT = "com.owncloud.android.ui.activity.ACCOUNT";
|
||||
@@ -493,7 +493,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
|
||||
|
||||
private void doOnResumeAndBound() {
|
||||
mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler);
|
||||
mOperationsServiceBinder.addOperationListener(this, mHandler);
|
||||
long waitingForOpId = mFileOperationsHelper.getOpIdWaitingFor();
|
||||
if (waitingForOpId <= Integer.MAX_VALUE) {
|
||||
boolean wait = mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId,
|
||||
@@ -596,45 +596,51 @@ public abstract class FileActivity extends DrawerActivity
|
||||
int count = arbitraryDataProvider.getIntegerValue(FilesSyncHelper.GLOBAL, APP_OPENED_COUNT);
|
||||
|
||||
if (count > 10 || count == -1) {
|
||||
checkForNewDevVersion(view, context, false);
|
||||
checkForNewDevVersion(this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkForNewDevVersion(View view, Context context, boolean openDirectly) {
|
||||
Integer latestVersion = -1;
|
||||
@Override
|
||||
public void returnVersion(Integer latestVersion) {
|
||||
showDevSnackbar(this, latestVersion, false);
|
||||
}
|
||||
|
||||
public static void checkForNewDevVersion(LoadingVersionNumberTask.VersionDevInterface callback, Context context) {
|
||||
String url = context.getString(R.string.dev_latest);
|
||||
LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask(callback);
|
||||
loadTask.execute(url);
|
||||
}
|
||||
|
||||
public static void showDevSnackbar(Activity activity, Integer latestVersion, boolean openDirectly) {
|
||||
Integer currentVersion = -1;
|
||||
try {
|
||||
currentVersion = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
|
||||
String url = context.getString(R.string.dev_latest);
|
||||
LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask();
|
||||
loadTask.execute(url);
|
||||
latestVersion = loadTask.get();
|
||||
} catch (InterruptedException | ExecutionException | PackageManager.NameNotFoundException e) {
|
||||
Log_OC.e(TAG, "Error detecting app version", e);
|
||||
currentVersion = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionCode;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log_OC.e(TAG, "Package not found", e);
|
||||
}
|
||||
|
||||
if (latestVersion == -1 || currentVersion == -1) {
|
||||
Snackbar.make(view, R.string.dev_version_no_information_available, Snackbar.LENGTH_LONG).show();
|
||||
DisplayUtils.showSnackMessage(activity, R.string.dev_version_no_information_available, Snackbar.LENGTH_LONG);
|
||||
}
|
||||
if (latestVersion > currentVersion) {
|
||||
if (openDirectly) {
|
||||
String devApkLink = (String) context.getText(R.string.dev_link) + latestVersion + ".apk";
|
||||
String devApkLink = (String) activity.getText(R.string.dev_link) + latestVersion + ".apk";
|
||||
Uri uriUrl = Uri.parse(devApkLink);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
context.startActivity(intent);
|
||||
activity.startActivity(intent);
|
||||
} else {
|
||||
Integer finalLatestVersion = latestVersion;
|
||||
Snackbar.make(view, R.string.dev_version_new_version_available, Snackbar.LENGTH_LONG)
|
||||
.setAction(context.getString(R.string.version_dev_download), v -> {
|
||||
String devApkLink = (String) context.getText(R.string.dev_link)
|
||||
+ finalLatestVersion + ".apk";
|
||||
Snackbar.make(activity.findViewById(android.R.id.content), R.string.dev_version_new_version_available,
|
||||
Snackbar.LENGTH_LONG)
|
||||
.setAction(activity.getString(R.string.version_dev_download), v -> {
|
||||
String devApkLink = (String) activity.getText(R.string.dev_link) + latestVersion + ".apk";
|
||||
Uri uriUrl = Uri.parse(devApkLink);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
context.startActivity(intent);
|
||||
activity.startActivity(intent);
|
||||
}).show();
|
||||
}
|
||||
} else {
|
||||
Snackbar.make(view, R.string.dev_version_no_new_version_available, Snackbar.LENGTH_LONG).show();
|
||||
DisplayUtils.showSnackMessage(activity, R.string.dev_version_no_new_version_available, Snackbar.LENGTH_LONG);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.media.MediaService;
|
||||
import com.owncloud.android.media.MediaServiceBinder;
|
||||
@@ -123,6 +124,7 @@ import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewMediaFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewTextFragment;
|
||||
import com.owncloud.android.ui.preview.PreviewVideoActivity;
|
||||
import com.owncloud.android.utils.ClipboardUtil;
|
||||
import com.owncloud.android.utils.DataHolderUtil;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
@@ -190,6 +192,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
|
||||
public static final String TEXT_PREVIEW = "TEXT_PREVIEW";
|
||||
|
||||
private static final String VERSION_DOT = ".";
|
||||
|
||||
private OCFile mWaitingToPreview;
|
||||
|
||||
private boolean mSyncInProgress;
|
||||
@@ -276,9 +280,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
PermissionUtil.requestWriteExternalStoreagePermission(FileDisplayActivity.this);
|
||||
}
|
||||
});
|
||||
|
||||
ThemeUtils.colorSnackbar(this, snackbar);
|
||||
|
||||
snackbar.show();
|
||||
} else {
|
||||
// No explanation needed, request the permission.
|
||||
@@ -366,8 +368,14 @@ public class FileDisplayActivity extends HookActivity
|
||||
|
||||
if (MainApp.getVersionCode() > lastSeenVersion) {
|
||||
OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this);
|
||||
|
||||
if (serverVersion == null) {
|
||||
OCCapability capability = getCapabilities();
|
||||
serverVersion = new OwnCloudVersion(capability.getVersionMayor() + VERSION_DOT +
|
||||
capability.getVersionMinor() + VERSION_DOT + capability.getVersionMicro());
|
||||
}
|
||||
|
||||
if (serverVersion.compareTo(MainApp.OUTDATED_SERVER_VERSION) < 0) {
|
||||
if (MainApp.OUTDATED_SERVER_VERSION.compareTo(serverVersion) >= 0) {
|
||||
DisplayUtils.showServerOutdatedSnackbar(this);
|
||||
}
|
||||
|
||||
@@ -705,8 +713,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath,
|
||||
boolean success) {
|
||||
FileFragment secondFragment = getSecondFragment();
|
||||
boolean waitedPreview = (mWaitingToPreview != null &&
|
||||
mWaitingToPreview.getRemotePath().equals(downloadedRemotePath));
|
||||
boolean waitedPreview = mWaitingToPreview != null
|
||||
&& mWaitingToPreview.getRemotePath().equals(downloadedRemotePath);
|
||||
if (secondFragment instanceof FileDetailFragment) {
|
||||
FileDetailFragment detailsFragment = (FileDetailFragment) secondFragment;
|
||||
OCFile fileInFragment = detailsFragment.getFile();
|
||||
@@ -746,7 +754,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
mWaitingToPreview = null;
|
||||
}
|
||||
if (!detailsFragmentChanged) {
|
||||
detailsFragment.updateFileDetails(false, (success));
|
||||
detailsFragment.updateFileDetails(false, success);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1112,7 +1120,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
return false;
|
||||
} else {
|
||||
View mSearchEditFrame = searchView.findViewById(android.support.v7.appcompat.R.id.search_edit_frame);
|
||||
return (mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE);
|
||||
return mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1298,8 +1306,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
|
||||
RemoteOperationResult synchResult = (RemoteOperationResult)
|
||||
DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
|
||||
boolean sameAccount = (getAccount() != null &&
|
||||
accountName.equals(getAccount().name) && getStorageManager() != null);
|
||||
boolean sameAccount = getAccount() != null &&
|
||||
accountName.equals(getAccount().name) && getStorageManager() != null;
|
||||
|
||||
if (sameAccount) {
|
||||
|
||||
@@ -1450,9 +1458,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
boolean sameFile = getFile().getRemotePath().equals(uploadedRemotePath) ||
|
||||
renamedInUpload;
|
||||
FileFragment details = getSecondFragment();
|
||||
boolean detailFragmentIsShown = (details instanceof FileDetailFragment);
|
||||
|
||||
if (sameAccount && sameFile && detailFragmentIsShown) {
|
||||
if (sameAccount && sameFile && details instanceof FileDetailFragment) {
|
||||
if (uploadWasFine) {
|
||||
setFile(getStorageManager().getFileByPath(uploadedRemotePath));
|
||||
} else {
|
||||
@@ -1460,7 +1467,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
Log_OC.d(TAG, "Remove upload progress bar after upload failed");
|
||||
}
|
||||
if (renamedInUpload) {
|
||||
String newName = (new File(uploadedRemotePath)).getName();
|
||||
String newName = new File(uploadedRemotePath).getName();
|
||||
DisplayUtils.showSnackMessage(
|
||||
getActivity(),
|
||||
R.string.filedetails_renamed_in_upload_msg,
|
||||
@@ -1498,12 +1505,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
// TODO refactor this receiver, and maybe DownloadFinishReceiver; this method is duplicated :S
|
||||
private boolean isAscendant(String linkedToRemotePath) {
|
||||
OCFile currentDir = getCurrentDir();
|
||||
return (
|
||||
currentDir != null &&
|
||||
currentDir.getRemotePath().startsWith(linkedToRemotePath)
|
||||
);
|
||||
return currentDir != null && currentDir.getRemotePath().startsWith(linkedToRemotePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1561,19 +1564,15 @@ public class FileDisplayActivity extends HookActivity
|
||||
|
||||
private boolean isDescendant(String downloadedRemotePath) {
|
||||
OCFile currentDir = getCurrentDir();
|
||||
return (
|
||||
currentDir != null &&
|
||||
downloadedRemotePath != null &&
|
||||
downloadedRemotePath.startsWith(currentDir.getRemotePath())
|
||||
);
|
||||
return currentDir != null &&
|
||||
downloadedRemotePath != null &&
|
||||
downloadedRemotePath.startsWith(currentDir.getRemotePath());
|
||||
}
|
||||
|
||||
private boolean isAscendant(String linkedToRemotePath) {
|
||||
OCFile currentDir = getCurrentDir();
|
||||
return (
|
||||
currentDir != null &&
|
||||
currentDir.getRemotePath().startsWith(linkedToRemotePath)
|
||||
);
|
||||
return currentDir != null &&
|
||||
currentDir.getRemotePath().startsWith(linkedToRemotePath);
|
||||
}
|
||||
|
||||
private boolean isSameAccount(Intent intent) {
|
||||
@@ -1907,9 +1906,6 @@ public class FileDisplayActivity extends HookActivity
|
||||
if (result.isSuccess()) {
|
||||
updateFileFromDB();
|
||||
|
||||
// Create dialog to allow the user choose an app to send the link
|
||||
Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
// if share to user and share via link multiple ocshares are returned,
|
||||
// therefore filtering for public_link
|
||||
String link = "";
|
||||
@@ -1921,43 +1917,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
}
|
||||
}
|
||||
|
||||
intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
|
||||
intentToShareLink.setType("text/plain");
|
||||
|
||||
String username;
|
||||
try {
|
||||
OwnCloudAccount oca = new OwnCloudAccount(getAccount(), this);
|
||||
if (oca.getDisplayName() != null && !oca.getDisplayName().isEmpty()) {
|
||||
username = oca.getDisplayName();
|
||||
} else {
|
||||
username = AccountUtils.getUsernameForAccount(getAccount());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
username = AccountUtils.getUsernameForAccount(getAccount());
|
||||
}
|
||||
|
||||
if (username != null) {
|
||||
intentToShareLink.putExtra(
|
||||
Intent.EXTRA_SUBJECT,
|
||||
getString(
|
||||
R.string.subject_user_shared_with_you,
|
||||
username,
|
||||
getFile().getFileName()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
intentToShareLink.putExtra(
|
||||
Intent.EXTRA_SUBJECT,
|
||||
getString(
|
||||
R.string.subject_shared_with_you,
|
||||
getFile().getFileName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
String[] packagesToExclude = new String[]{getPackageName()};
|
||||
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
|
||||
chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
|
||||
copyAndShareFileLink(link);
|
||||
|
||||
if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
|
||||
fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
|
||||
@@ -1983,15 +1943,71 @@ public class FileDisplayActivity extends HookActivity
|
||||
if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
|
||||
fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
|
||||
}
|
||||
Snackbar.make(
|
||||
Snackbar snackbar = Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
|
||||
Snackbar.LENGTH_LONG
|
||||
).show();
|
||||
);
|
||||
ThemeUtils.colorSnackbar(this, snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void copyAndShareFileLink(String link) {
|
||||
ClipboardUtil.copyToClipboard(this, link, false);
|
||||
Snackbar snackbar = Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
R.string.clipboard_text_copied,
|
||||
Snackbar.LENGTH_LONG
|
||||
).setAction(R.string.share, v -> showShareLinkDialog(link));
|
||||
ThemeUtils.colorSnackbar(this, snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
public void showShareLinkDialog(String link) {
|
||||
// Create dialog to allow the user choose an app to send the link
|
||||
Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
|
||||
|
||||
intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
|
||||
intentToShareLink.setType("text/plain");
|
||||
|
||||
String username;
|
||||
try {
|
||||
OwnCloudAccount oca = new OwnCloudAccount(getAccount(), this);
|
||||
if (oca.getDisplayName() != null && !oca.getDisplayName().isEmpty()) {
|
||||
username = oca.getDisplayName();
|
||||
} else {
|
||||
username = AccountUtils.getUsernameForAccount(getAccount());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
username = AccountUtils.getUsernameForAccount(getAccount());
|
||||
}
|
||||
|
||||
if (username != null) {
|
||||
intentToShareLink.putExtra(
|
||||
Intent.EXTRA_SUBJECT,
|
||||
getString(
|
||||
R.string.subject_user_shared_with_you,
|
||||
username,
|
||||
getFile().getFileName()
|
||||
)
|
||||
);
|
||||
} else {
|
||||
intentToShareLink.putExtra(
|
||||
Intent.EXTRA_SUBJECT,
|
||||
getString(
|
||||
R.string.subject_shared_with_you,
|
||||
getFile().getFileName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
String[] packagesToExclude = new String[]{getPackageName()};
|
||||
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
|
||||
chooserDialog.show(getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
|
||||
}
|
||||
|
||||
private void onUpdateShareInformation(RemoteOperationResult result, @StringRes int errorString) {
|
||||
Fragment fileDetailFragment = getSecondFragment();
|
||||
|
||||
@@ -1999,7 +2015,9 @@ public class FileDisplayActivity extends HookActivity
|
||||
updateFileFromDB();
|
||||
refreshListOfFilesFragment(false);
|
||||
} else if (fileDetailFragment.getView() != null) {
|
||||
Snackbar.make(fileDetailFragment.getView(), errorString, Snackbar.LENGTH_LONG).show();
|
||||
Snackbar snackbar = Snackbar.make(fileDetailFragment.getView(), errorString, Snackbar.LENGTH_LONG);
|
||||
ThemeUtils.colorSnackbar(this, snackbar);
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
if (fileDetailFragment != null && fileDetailFragment instanceof FileDetailFragment) {
|
||||
|
||||
@@ -163,6 +163,13 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
PreferenceManager.setLastSeenVersionCode(this, MainApp.getVersionCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
onFinish();
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private static boolean isFirstRun(Context context) {
|
||||
return AccountUtils.getCurrentOwnCloudAccount(context) == null;
|
||||
}
|
||||
@@ -209,10 +216,21 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (FIRST_RUN_RESULT_CODE == requestCode && RESULT_OK == resultCode) {
|
||||
setAccount(AccountUtils.getCurrentOwnCloudAccount(this));
|
||||
|
||||
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
|
||||
Account account = AccountUtils.getOwnCloudAccountByName(this, accountName);
|
||||
|
||||
if (account == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.account_creation_failed);
|
||||
return;
|
||||
}
|
||||
|
||||
setAccount(account);
|
||||
AccountUtils.setCurrentOwnCloudAccount(this, account.name);
|
||||
onAccountSet(false);
|
||||
|
||||
Intent i = new Intent(this, FileDisplayActivity.class);
|
||||
i.setAction(FileDisplayActivity.RESTART);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@@ -74,15 +74,17 @@ import java.util.Set;
|
||||
public class ManageAccountsActivity extends FileActivity
|
||||
implements AccountListAdapter.AccountListAdapterListener, AccountManagerCallback<Boolean>, ComponentsGetter {
|
||||
private static final String TAG = ManageAccountsActivity.class.getSimpleName();
|
||||
|
||||
public static final String KEY_ACCOUNT_LIST_CHANGED = "ACCOUNT_LIST_CHANGED";
|
||||
public static final String KEY_CURRENT_ACCOUNT_CHANGED = "CURRENT_ACCOUNT_CHANGED";
|
||||
|
||||
public static final String PENDING_FOR_REMOVAL = "PENDING_FOR_REMOVAL";
|
||||
|
||||
private static final String KEY_DISPLAY_NAME = "DISPLAY_NAME";
|
||||
|
||||
private static final int KEY_USER_INFO_REQUEST_CODE = 13;
|
||||
private static final int KEY_DELETE_CODE = 101;
|
||||
private static final int SINGLE_ACCOUNT = 1;
|
||||
private static final int MIN_MULTI_ACCOUNT_SIZE = 2;
|
||||
|
||||
private ListView mListView;
|
||||
private final Handler mHandler = new Handler();
|
||||
@@ -90,8 +92,8 @@ public class ManageAccountsActivity extends FileActivity
|
||||
private AccountListAdapter mAccountListAdapter;
|
||||
private ServiceConnection mDownloadServiceConnection;
|
||||
private ServiceConnection mUploadServiceConnection;
|
||||
Set<String> mOriginalAccounts;
|
||||
String mOriginalCurrentAccount;
|
||||
private Set<String> mOriginalAccounts;
|
||||
private String mOriginalCurrentAccount;
|
||||
private Drawable mTintedCheck;
|
||||
|
||||
private ArbitraryDataProvider arbitraryDataProvider;
|
||||
@@ -347,7 +349,7 @@ public class ManageAccountsActivity extends FileActivity
|
||||
}
|
||||
|
||||
List<AccountListItem> accountListItemArray = getAccountListItems();
|
||||
if (accountListItemArray.size() > 1) {
|
||||
if (accountListItemArray.size() > SINGLE_ACCOUNT) {
|
||||
mAccountListAdapter = new AccountListAdapter(this, accountListItemArray, mTintedCheck);
|
||||
mListView.setAdapter(mAccountListAdapter);
|
||||
} else {
|
||||
@@ -452,7 +454,7 @@ public class ManageAccountsActivity extends FileActivity
|
||||
}
|
||||
|
||||
// only one to be (deleted) account remaining
|
||||
if (accounts.length < 2) {
|
||||
if (accounts.length < MIN_MULTI_ACCOUNT_SIZE) {
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, true);
|
||||
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, true);
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.os.Bundle;
|
||||
import android.support.design.widget.BottomNavigationView;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.MenuItem;
|
||||
@@ -249,10 +248,8 @@ public class NotificationsActivity extends FileActivity {
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, layoutManager.getOrientation());
|
||||
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.addItemDecoration(dividerItemDecoration);
|
||||
|
||||
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation_view);
|
||||
|
||||
|
||||
@@ -315,8 +315,7 @@ public class PassCodeActivity extends AppCompatActivity {
|
||||
|
||||
boolean result = true;
|
||||
for (int i = 0; i < mPassCodeDigits.length && result; i++) {
|
||||
result = (mPassCodeDigits[i] != null) &&
|
||||
mPassCodeDigits[i].equals(savedPassCodeDigits[i]);
|
||||
result = mPassCodeDigits[i] != null && mPassCodeDigits[i].equals(savedPassCodeDigits[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -332,7 +331,7 @@ public class PassCodeActivity extends AppCompatActivity {
|
||||
|
||||
boolean result = true;
|
||||
for (int i = 0; i < mPassCodeEditTexts.length && result; i++) {
|
||||
result = ((mPassCodeEditTexts[i].getText().toString()).equals(mPassCodeDigits[i]));
|
||||
result = mPassCodeEditTexts[i].getText().toString().equals(mPassCodeDigits[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ import com.owncloud.android.lib.common.ExternalLinkType;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.asynctasks.LoadingVersionNumberTask;
|
||||
import com.owncloud.android.utils.DeviceCredentialUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
@@ -85,7 +86,7 @@ import java.util.ArrayList;
|
||||
* It proxies the necessary calls via {@link android.support.v7.app.AppCompatDelegate} to be used with AppCompat.
|
||||
*/
|
||||
public class Preferences extends PreferenceActivity
|
||||
implements StorageMigration.StorageMigrationProgressListener {
|
||||
implements StorageMigration.StorageMigrationProgressListener, LoadingVersionNumberTask.VersionDevInterface {
|
||||
|
||||
private static final String TAG = Preferences.class.getSimpleName();
|
||||
|
||||
@@ -191,7 +192,7 @@ public class Preferences extends PreferenceActivity
|
||||
if (pDevLink != null) {
|
||||
if (getResources().getBoolean(R.bool.dev_version_direct_download_enabled)) {
|
||||
pDevLink.setOnPreferenceClickListener(preference -> {
|
||||
FileActivity.checkForNewDevVersion(getListView(), getApplicationContext(), true);
|
||||
FileActivity.checkForNewDevVersion(this, getApplicationContext());
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
@@ -1096,4 +1097,10 @@ public class Preferences extends PreferenceActivity
|
||||
public void onCancelMigration() {
|
||||
// Migration was canceled so we don't do anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnVersion(Integer latestVersion) {
|
||||
FileActivity.showDevSnackbar(this, latestVersion, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -98,6 +98,7 @@ import com.owncloud.android.utils.DataHolderUtil;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||
import com.owncloud.android.utils.FileSortOrder;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -131,6 +132,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
public static final String URL_FILE_SUFFIX = ".url";
|
||||
public static final String WEBLOC_FILE_SUFFIX = ".webloc";
|
||||
public static final String DESKTOP_FILE_SUFFIX = ".desktop";
|
||||
public static final int SINGLE_PARENT = 1;
|
||||
|
||||
private AccountManager mAccountManager;
|
||||
private Stack<String> mParents = new Stack<>();
|
||||
@@ -313,9 +315,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
*
|
||||
* @return list of account list items
|
||||
*/
|
||||
private ArrayList<AccountListItem> getAccountListItems(ReceiveExternalFilesActivity activity) {
|
||||
private List<AccountListItem> getAccountListItems(ReceiveExternalFilesActivity activity) {
|
||||
Account[] accountList = activity.mAccountManager.getAccountsByType(MainApp.getAccountType(getActivity()));
|
||||
ArrayList<AccountListItem> adapterAccountList = new ArrayList<>(accountList.length);
|
||||
List<AccountListItem> adapterAccountList = new ArrayList<>(accountList.length);
|
||||
for (Account account : accountList) {
|
||||
adapterAccountList.add(new AccountListItem(account));
|
||||
}
|
||||
@@ -330,6 +332,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
private static final int CATEGORY_URL = 1;
|
||||
private static final int CATEGORY_MAPS_URL = 2;
|
||||
private static final int EXTRA_TEXT_LENGTH = 3;
|
||||
private static final int SINGLE_SPINNER_ENTRY = 1;
|
||||
|
||||
private List<String> mFilenameBase;
|
||||
private List<String> mFilenameSuffix;
|
||||
@@ -428,9 +432,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
final Spinner spinner = view.findViewById(R.id.file_type);
|
||||
setupSpinner(adapter, selectPos, userInput, spinner);
|
||||
if (adapter.getCount() == 1) {
|
||||
TextView label = view.findViewById(R.id.label_file_type);
|
||||
label.setVisibility(View.GONE);
|
||||
if (adapter.getCount() == SINGLE_SPINNER_ENTRY) {
|
||||
view.findViewById(R.id.label_file_type).setVisibility(View.GONE);
|
||||
spinner.setVisibility(View.GONE);
|
||||
}
|
||||
mSpinner = spinner;
|
||||
@@ -525,8 +528,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
String filename = mFilenameBase.get(selectPos) + mFilenameSuffix.get(selectPos);
|
||||
inputText.setText(filename);
|
||||
int selectionStart = 0;
|
||||
int extensionStart = filename.lastIndexOf(".");
|
||||
int selectionEnd = (extensionStart >= 0) ? extensionStart : filename.length();
|
||||
int extensionStart = filename.lastIndexOf('.');
|
||||
int selectionEnd = extensionStart >= 0 ? extensionStart : filename.length();
|
||||
if (selectionEnd >= 0) {
|
||||
inputText.setSelection(
|
||||
Math.min(selectionStart, selectionEnd),
|
||||
@@ -536,15 +539,19 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
private boolean isIntentFromGoogleMap(String subjectText, String extraText) {
|
||||
String texts[] = extraText.split("\n");
|
||||
if (texts.length != 3)
|
||||
if (texts.length != EXTRA_TEXT_LENGTH) {
|
||||
return false;
|
||||
if (texts[0].length() == 0 || !subjectText.equals(texts[0]))
|
||||
}
|
||||
|
||||
if (texts[0].length() == 0 || !subjectText.equals(texts[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return texts[2].startsWith("https://goo.gl/maps/");
|
||||
}
|
||||
|
||||
private boolean isIntentStartWithUrl(String extraText) {
|
||||
return (extraText.startsWith("http://") || extraText.startsWith("https://"));
|
||||
return extraText.startsWith("http://") || extraText.startsWith("https://");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -623,7 +630,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mParents.size() <= 1) {
|
||||
if (mParents.size() <= SINGLE_PARENT) {
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
mParents.pop();
|
||||
@@ -728,7 +735,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
ListView mListView = findViewById(android.R.id.list);
|
||||
|
||||
String current_dir = mParents.peek();
|
||||
boolean notRoot = (mParents.size() > 1);
|
||||
boolean notRoot = mParents.size() > 1;
|
||||
|
||||
if (actionBar != null) {
|
||||
if ("".equals(current_dir)) {
|
||||
@@ -880,7 +887,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
}
|
||||
|
||||
private void saveTextsFromIntent(Intent intent) {
|
||||
if (!"text/plain".equals(intent.getType())) {
|
||||
if (!MimeType.TEXT_PLAIN.equals(intent.getType())) {
|
||||
return;
|
||||
}
|
||||
mUploadFromTmpFile = true;
|
||||
@@ -1063,7 +1070,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
|
||||
break;
|
||||
case android.R.id.home:
|
||||
if ((mParents.size() > 1)) {
|
||||
if (mParents.size() > SINGLE_PARENT) {
|
||||
onBackPressed();
|
||||
}
|
||||
break;
|
||||
@@ -1115,8 +1122,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
String syncFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
|
||||
RemoteOperationResult syncResult = (RemoteOperationResult)
|
||||
DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
|
||||
boolean sameAccount = (getAccount() != null &&
|
||||
accountName.equals(getAccount().name) && getStorageManager() != null);
|
||||
boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name)
|
||||
&& getStorageManager() != null;
|
||||
|
||||
if (sameAccount) {
|
||||
|
||||
@@ -1150,13 +1157,12 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
mFile = currentFile;
|
||||
}
|
||||
|
||||
mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
|
||||
!RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
|
||||
mSyncInProgress = !FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
|
||||
!RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event);
|
||||
|
||||
if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
|
||||
equals(event) &&
|
||||
if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.equals(event)
|
||||
/// TODO refactor and make common
|
||||
syncResult != null && !syncResult.isSuccess()) {
|
||||
&& syncResult != null && !syncResult.isSuccess()) {
|
||||
|
||||
if (syncResult.getCode() == ResultCode.UNAUTHORIZED ||
|
||||
(syncResult.isException() && syncResult.getException()
|
||||
|
||||
@@ -148,11 +148,11 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
|
||||
return OCShare.READ_PERMISSION_FLAG; // minimum permissions
|
||||
|
||||
} else if (isFederated) {
|
||||
return (getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
|
||||
OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9);
|
||||
return getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
|
||||
OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9;
|
||||
} else {
|
||||
return (getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE);
|
||||
return getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2018 David Luhmer
|
||||
* Copyright (C) 2018 Andy Scherzinger
|
||||
*
|
||||
* 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.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nextcloud.android.sso.Constants;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_ACCESS_DECLINED;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_NOT_FOUND;
|
||||
import static com.nextcloud.android.sso.Constants.NEXTCLOUD_FILES_ACCOUNT;
|
||||
import static com.nextcloud.android.sso.Constants.NEXTCLOUD_SSO;
|
||||
import static com.nextcloud.android.sso.Constants.NEXTCLOUD_SSO_EXCEPTION;
|
||||
import static com.nextcloud.android.sso.Constants.SSO_SHARED_PREFERENCE;
|
||||
|
||||
/**
|
||||
* Activity for granting access rights to a Nextcloud account, used for SSO.
|
||||
*/
|
||||
public class SsoGrantPermissionActivity extends BaseActivity {
|
||||
|
||||
private static final String TAG = SsoGrantPermissionActivity.class.getCanonicalName();
|
||||
|
||||
private String packageName;
|
||||
private Account account;
|
||||
|
||||
private Unbinder unbinder;
|
||||
|
||||
@BindView(R.id.appIcon)
|
||||
ImageView appIcon;
|
||||
|
||||
@BindView(R.id.permissionText)
|
||||
TextView permissionText;
|
||||
|
||||
@BindView(R.id.btnGrant)
|
||||
Button grantPermissionButton;
|
||||
|
||||
@BindView(R.id.btnDecline)
|
||||
Button declinePermissionButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sso_grant_permission);
|
||||
|
||||
unbinder = ButterKnife.bind(this);
|
||||
|
||||
ComponentName callingActivity = getCallingActivity();
|
||||
|
||||
if (callingActivity != null) {
|
||||
packageName = callingActivity.getPackageName();
|
||||
String appName = getAppNameForPackage(packageName);
|
||||
account = getIntent().getParcelableExtra(NEXTCLOUD_FILES_ACCOUNT);
|
||||
permissionText.setText(makeSpecialPartsBold(
|
||||
getString(R.string.single_sign_on_request_token, appName, account.name),
|
||||
appName,
|
||||
account.name)
|
||||
);
|
||||
Log.v(TAG, "TOKEN-REQUEST: Calling Package: " + packageName);
|
||||
Log.v(TAG, "TOKEN-REQUEST: App Name: " + appName);
|
||||
} else {
|
||||
// Activity was not started using startActivityForResult!
|
||||
Log.e(TAG, "Calling Package is null");
|
||||
setResultAndExit("Request was not executed properly. Use startActivityForResult()");
|
||||
}
|
||||
|
||||
try {
|
||||
if (packageName != null) {
|
||||
Drawable appIcon = getPackageManager().getApplicationIcon(packageName);
|
||||
this.appIcon.setImageDrawable(appIcon);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
}
|
||||
|
||||
int primaryColor = ThemeUtils.primaryColor(this, true);
|
||||
grantPermissionButton.setTextColor(primaryColor);
|
||||
declinePermissionButton.setTextColor(primaryColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbinder.unbind();
|
||||
}
|
||||
|
||||
private SpannableStringBuilder makeSpecialPartsBold(String text, String... toBeStyledText) {
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder(text);
|
||||
for (String textBlock : toBeStyledText) {
|
||||
int start = text.indexOf(textBlock);
|
||||
int end = start + textBlock.length();
|
||||
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, end, 0);
|
||||
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
return ssb;
|
||||
}
|
||||
|
||||
private void setResultAndExit(String exception) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra(NEXTCLOUD_SSO_EXCEPTION, exception);
|
||||
setResult(RESULT_CANCELED, data);
|
||||
finish();
|
||||
}
|
||||
|
||||
private String getAppNameForPackage(String pkg) {
|
||||
final PackageManager pm = getApplicationContext().getPackageManager();
|
||||
ApplicationInfo ai = null;
|
||||
try {
|
||||
ai = pm.getApplicationInfo(pkg, 0);
|
||||
} catch (final PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
}
|
||||
return (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnDecline)
|
||||
void exitFailed() {
|
||||
setResultAndExit(EXCEPTION_ACCOUNT_ACCESS_DECLINED);
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnGrant)
|
||||
void grantPermission() {
|
||||
// create token
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(SSO_SHARED_PREFERENCE, Context.MODE_PRIVATE);
|
||||
String token = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
|
||||
String hashedTokenWithSalt = EncryptionUtils.generateSHA512(token);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(packageName, hashedTokenWithSalt);
|
||||
editor.apply();
|
||||
|
||||
String serverUrl;
|
||||
String userId;
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(account, this);
|
||||
serverUrl = ocAccount.getBaseUri().toString();
|
||||
AccountManager accountManager = AccountManager.get(this);
|
||||
userId = accountManager.getUserData(account,
|
||||
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
||||
} catch (AccountUtils.AccountNotFoundException e) {
|
||||
Log_OC.e(TAG, "Account not found");
|
||||
setResultAndExit(EXCEPTION_ACCOUNT_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
final Bundle result = new Bundle();
|
||||
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
|
||||
result.putString(AccountManager.KEY_ACCOUNT_TYPE, MainApp.getAccountType(this));
|
||||
result.putString(AccountManager.KEY_AUTHTOKEN, NEXTCLOUD_SSO);
|
||||
result.putString(Constants.SSO_USERNAME, userId);
|
||||
result.putString(Constants.SSO_TOKEN, token);
|
||||
result.putString(Constants.SSO_SERVER_URL, serverUrl);
|
||||
|
||||
Intent data = new Intent();
|
||||
data.putExtra(NEXTCLOUD_SSO, result);
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -269,13 +269,14 @@ public class StorageMigration {
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreAccountsSyncStatus(boolean oldSync[]) {
|
||||
protected void restoreAccountsSyncStatus(boolean... oldSync) {
|
||||
// If we don't have the old sync statuses, then
|
||||
// probably migration failed even before saving states,
|
||||
// which is weird and should be investigated.
|
||||
// But its better than crashing on ArrayOutOfBounds.
|
||||
if (oldSync == null)
|
||||
if (oldSync == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
ContentResolver.setSyncAutomatically(mOcAccounts[i], mAuthority, oldSync[i]);
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
|
||||
List<SyncedFolder> syncedFolderArrayList = mSyncedFolderProvider.getSyncedFolders();
|
||||
List<SyncedFolder> currentAccountSyncedFoldersList = new ArrayList<>();
|
||||
Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(SyncedFoldersActivity.this);
|
||||
Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(this);
|
||||
for (SyncedFolder syncedFolder : syncedFolderArrayList) {
|
||||
if (currentAccount != null && syncedFolder.getAccount().equals(currentAccount.name)) {
|
||||
currentAccountSyncedFoldersList.add(syncedFolder);
|
||||
@@ -423,7 +423,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
return files;
|
||||
}
|
||||
|
||||
private List<String> getDisplayFilePathList(File[] files) {
|
||||
private List<String> getDisplayFilePathList(File... files) {
|
||||
List<String> filePaths = null;
|
||||
|
||||
if (files != null && files.length > 0) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -82,11 +82,12 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
OnClickListener, ConfirmationDialogFragmentListener, SortingOrderDialogFragment.OnSortingOrderListener {
|
||||
|
||||
private static final String SORT_ORDER_DIALOG_TAG = "SORT_ORDER_DIALOG";
|
||||
private static final int SINGLE_DIR = 1;
|
||||
|
||||
private ArrayAdapter<String> mDirectories;
|
||||
private File mCurrentDir = null;
|
||||
private boolean mSelectAll = false;
|
||||
private boolean mLocalFolderPickerMode = false;
|
||||
private File mCurrentDir;
|
||||
private boolean mSelectAll;
|
||||
private boolean mLocalFolderPickerMode;
|
||||
private LocalFileListFragment mFileListFragment;
|
||||
protected Button mUploadBtn;
|
||||
private Spinner mBehaviourSpinner;
|
||||
@@ -333,7 +334,7 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
mSearchView.onActionViewCollapsed();
|
||||
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
|
||||
} else {
|
||||
if (mDirectories.getCount() <= 1) {
|
||||
if (mDirectories.getCount() <= SINGLE_DIR) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -148,7 +147,6 @@ public class UserInfoActivity extends FileActivity {
|
||||
updateActionBarTitleAndHomeButtonByString("");
|
||||
|
||||
mUserInfoList.setAdapter(new UserInfoAdapter(null, ThemeUtils.primaryColor(getAccount(), true, this)));
|
||||
mUserInfoList.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
|
||||
|
||||
if (userInfo != null) {
|
||||
populateUserInfoUi(userInfo);
|
||||
@@ -262,8 +260,7 @@ public class UserInfoActivity extends FileActivity {
|
||||
private void populateUserInfoUi(UserInfo userInfo) {
|
||||
userName.setText(account.name);
|
||||
avatar.setTag(account.name);
|
||||
DisplayUtils.setAvatar(account, UserInfoActivity.this, mCurrentAccountAvatarRadiusDimension, getResources(),
|
||||
avatar, this);
|
||||
DisplayUtils.setAvatar(account, this, mCurrentAccountAvatarRadiusDimension, getResources(), avatar, this);
|
||||
|
||||
int tint = ThemeUtils.primaryColor(account, true, this);
|
||||
|
||||
@@ -302,8 +299,9 @@ public class UserInfoActivity extends FileActivity {
|
||||
|
||||
private void addToListIfNeeded(List<UserInfoDetailsItem> info, @DrawableRes int icon, String text,
|
||||
@StringRes int contentDescriptionInt) {
|
||||
if (!TextUtils.isEmpty(text))
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
info.add(new UserInfoDetailsItem(icon, text, getResources().getString(contentDescriptionInt)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void openAccountRemovalConfirmationDialog(Account account, FragmentManager fragmentManager,
|
||||
@@ -413,7 +411,7 @@ public class UserInfoActivity extends FileActivity {
|
||||
private void fetchAndSetData() {
|
||||
Thread t = new Thread(() -> {
|
||||
RemoteOperation getRemoteUserInfoOperation = new GetRemoteUserInfoOperation();
|
||||
RemoteOperationResult result = getRemoteUserInfoOperation.execute(account, UserInfoActivity.this);
|
||||
RemoteOperationResult result = getRemoteUserInfoOperation.execute(account, this);
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
userInfo = (UserInfo) result.getData().get(0);
|
||||
@@ -487,8 +485,7 @@ public class UserInfoActivity extends FileActivity {
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.user_info_details_table_item, parent, false);
|
||||
ViewHolder holder = new ViewHolder(view);
|
||||
return holder;
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -139,8 +139,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
|
||||
}
|
||||
|
||||
public static void runIfNeeded(Context context) {
|
||||
if (!context.getResources().getBoolean(R.bool.show_whats_new)
|
||||
|| context instanceof WhatsNewActivity) {
|
||||
if (!context.getResources().getBoolean(R.bool.show_whats_new) || context instanceof WhatsNewActivity) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,7 +173,7 @@ public class WhatsNewActivity extends FragmentActivity implements ViewPager.OnPa
|
||||
}
|
||||
|
||||
static private FeatureItem[] getWhatsNew(Context context) {
|
||||
int itemVersionCode = 30030000;
|
||||
int itemVersionCode = 30030099;
|
||||
|
||||
if (!isFirstRun(context) && MainApp.getVersionCode() >= itemVersionCode
|
||||
&& PreferenceManager.getLastSeenVersionCode(context) < itemVersionCode) {
|
||||
|
||||
@@ -127,9 +127,9 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
|
||||
public int getItemViewType(int position) {
|
||||
Object value = values.get(position);
|
||||
|
||||
if (value instanceof Activity)
|
||||
if (value instanceof Activity) {
|
||||
return ACTIVITY_TYPE;
|
||||
else if (value instanceof FileVersion) {
|
||||
} else if (value instanceof FileVersion) {
|
||||
return VERSION_TYPE;
|
||||
} else {
|
||||
return HEADER_TYPE;
|
||||
|
||||
@@ -239,7 +239,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
private void setBitmap(OCFile file, ImageView fileIcon, boolean isDetailView) {
|
||||
// No Folder
|
||||
if (!file.isFolder()) {
|
||||
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file))) {
|
||||
if (MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) {
|
||||
int placeholder;
|
||||
|
||||
if (MimeTypeUtil.isImage(file)) {
|
||||
@@ -299,10 +299,10 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
String text = richElement.getRichSubject();
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder(text);
|
||||
|
||||
int idx1 = text.indexOf("{");
|
||||
int idx1 = text.indexOf('{');
|
||||
int idx2;
|
||||
while (idx1 != -1) {
|
||||
idx2 = text.indexOf("}", idx1) + 1;
|
||||
idx2 = text.indexOf('}', idx1) + 1;
|
||||
final String clickString = text.substring(idx1 + 1, idx2 - 1);
|
||||
final RichObject richObject = searchObjectByName(richElement.getRichObjectList(), clickString);
|
||||
if (richObject != null) {
|
||||
@@ -324,7 +324,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), idx1, idx2, 0);
|
||||
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), idx1, idx2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
idx1 = text.indexOf("{", idx2);
|
||||
idx1 = text.indexOf('{', idx2);
|
||||
}
|
||||
|
||||
return ssb;
|
||||
@@ -332,8 +332,9 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
private RichObject searchObjectByName(List<RichObject> richObjectList, String name) {
|
||||
for (RichObject richObject : richObjectList) {
|
||||
if (richObject.getTag().equalsIgnoreCase(name))
|
||||
if (richObject.getTag().equalsIgnoreCase(name)) {
|
||||
return richObject;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -341,10 +342,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (values.get(position) instanceof Activity)
|
||||
if (values.get(position) instanceof Activity) {
|
||||
return ACTIVITY_TYPE;
|
||||
else
|
||||
} else {
|
||||
return HEADER_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,7 +68,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private List<File> mFiles = new ArrayList<>();
|
||||
private List<File> mFilesAll = new ArrayList<>();
|
||||
private boolean mLocalFolderPicker;
|
||||
private boolean gridView = false;
|
||||
private boolean gridView;
|
||||
private LocalFileListFragmentInterface localFileListFragmentInterface;
|
||||
private Set<File> checkedFiles;
|
||||
|
||||
@@ -241,7 +241,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
/* Cancellation needs do be checked and done before changing the drawable in fileIcon, or
|
||||
* {@link ThumbnailsCacheManager#cancelPotentialThumbnailWork} will NEVER cancel any task.
|
||||
*/
|
||||
boolean allowedToCreateNewThumbnail = (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView));
|
||||
boolean allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView);
|
||||
|
||||
|
||||
// get Thumbnail if file is image
|
||||
@@ -519,6 +519,10 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
return output;
|
||||
}
|
||||
|
||||
public void setGridView(boolean gridView) {
|
||||
this.gridView = gridView;
|
||||
}
|
||||
|
||||
static class LocalFileListItemViewHolder extends LocalFileListGridViewHolder {
|
||||
private final TextView fileSize;
|
||||
private final TextView lastModification;
|
||||
@@ -530,6 +534,8 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
fileSize = itemView.findViewById(R.id.file_size);
|
||||
fileSeparator = itemView.findViewById(R.id.file_separator);
|
||||
lastModification = itemView.findViewById(R.id.last_mod);
|
||||
|
||||
itemView.findViewById(R.id.overflow_menu).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +553,6 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
checkbox = itemView.findViewById(R.id.custom_checkbox);
|
||||
itemLayout = itemView.findViewById(R.id.ListItemLayout);
|
||||
|
||||
itemView.findViewById(R.id.overflow_menu).setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.sharedIcon).setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.favorite_action).setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.keptOfflineIcon).setVisibility(View.GONE);
|
||||
|
||||
@@ -54,7 +54,6 @@ import butterknife.ButterKnife;
|
||||
/**
|
||||
* Adapter for the trashbin view
|
||||
*/
|
||||
|
||||
public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
private static final int TRASHBIN_ITEM = 100;
|
||||
|
||||
@@ -605,7 +605,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||
return items[position];
|
||||
}
|
||||
|
||||
public void setItems(OCUpload[] items) {
|
||||
public void setItems(OCUpload... items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
|
||||
private float avatarRadiusDimension;
|
||||
private Account account;
|
||||
private OCFile file;
|
||||
private FileDataStorageManager storageManager;
|
||||
|
||||
public UserListAdapter(FragmentManager fragmentManager, Context context, List<OCShare> shares, Account account,
|
||||
OCFile file, ShareeListAdapterListener listener) {
|
||||
@@ -83,8 +82,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
|
||||
this.file = file;
|
||||
|
||||
accentColor = ThemeUtils.primaryAccentColor(context);
|
||||
storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
capabilities = storageManager.getCapability(account.name);
|
||||
capabilities = new FileDataStorageManager(account, context.getContentResolver()).getCapability(account.name);
|
||||
avatarRadiusDimension = context.getResources().getDimension(R.dimen.user_icon_radius);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*
|
||||
* 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.adapter;
|
||||
|
||||
|
||||
@@ -37,6 +37,12 @@ import java.net.URL;
|
||||
public class LoadingVersionNumberTask extends AsyncTask<String, Void, Integer> {
|
||||
private static final String TAG = LoadingVersionNumberTask.class.getSimpleName();
|
||||
|
||||
private VersionDevInterface callback;
|
||||
|
||||
public LoadingVersionNumberTask(VersionDevInterface callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
protected Integer doInBackground(String... args) {
|
||||
try {
|
||||
URL url = new URL(args[0]);
|
||||
@@ -51,4 +57,13 @@ public class LoadingVersionNumberTask extends AsyncTask<String, Void, Integer> {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Integer latestVersion) {
|
||||
callback.returnVersion(latestVersion);
|
||||
}
|
||||
|
||||
public interface VersionDevInterface {
|
||||
void returnVersion(Integer latestVersion);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 186 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user