Compare commits
345
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51db0a6f57 | ||
|
|
8264ed040d | ||
|
|
f020e02dfb | ||
|
|
b997966e90 | ||
|
|
c1e014373f | ||
|
|
8cebbf8146 | ||
|
|
d3d78ab744 | ||
|
|
96af008653 | ||
|
|
1910e4cfa6 | ||
|
|
3fc27cc927 | ||
|
|
3fdc757ac1 | ||
|
|
b972c46686 | ||
|
|
09d1fe7654 | ||
|
|
e1514db205 | ||
|
|
3a2f68523d | ||
|
|
6b038492b1 | ||
|
|
f4f9af41dc | ||
|
|
a7c95b46c5 | ||
|
|
2eb476639a | ||
|
|
cc5b9a10eb | ||
|
|
36df660d29 | ||
|
|
3bbc5adecd | ||
|
|
9bc802dddf | ||
|
|
6e6bbb7d8b | ||
|
|
8650de4d45 | ||
|
|
49bbf945fe | ||
|
|
b4fc0388c0 | ||
|
|
bd253f1584 | ||
|
|
1762ecbd26 | ||
|
|
6011fc42c5 | ||
|
|
76b8681061 | ||
|
|
4d485d00e7 | ||
|
|
3a7ef82632 | ||
|
|
0807696761 | ||
|
|
be320936d9 | ||
|
|
ce5acb05ab | ||
|
|
3c87e5a14f | ||
|
|
d5da8965d3 | ||
|
|
b785b0b18d | ||
|
|
7a0af443b2 | ||
|
|
90e74a6722 | ||
|
|
d177ed6755 | ||
|
|
ed103ad530 | ||
|
|
fb06caff1c | ||
|
|
e7a5cfd45a | ||
|
|
b34001d866 | ||
|
|
b5827c7ec1 | ||
|
|
f4d25af034 | ||
|
|
d6fcc4869f | ||
|
|
df5eddcd85 | ||
|
|
9d0457f16e | ||
|
|
5d40c37121 | ||
|
|
c72076ae21 | ||
|
|
828b0a7d75 | ||
|
|
b31d650b28 | ||
|
|
4ed02c40b7 | ||
|
|
64bfb52541 | ||
|
|
dbf8f9e68a | ||
|
|
8069f04766 | ||
|
|
23a1f2530e | ||
|
|
60d13157d5 | ||
|
|
8a19ee7d84 | ||
|
|
730f10e9d7 | ||
|
|
9a24eb221d | ||
|
|
3705e5a209 | ||
|
|
40268978e7 | ||
|
|
959cce44fb | ||
|
|
404bbe3f13 | ||
|
|
70978089b6 | ||
|
|
b35ddef4fb | ||
|
|
28112b6444 | ||
|
|
bc2f52840b | ||
|
|
2e6fb57cef | ||
|
|
c29fddfc7e | ||
|
|
9780b3ef08 | ||
|
|
b2301cb040 | ||
|
|
85170d2389 | ||
|
|
93bc0b4050 | ||
|
|
77211f2cf0 | ||
|
|
37d34de34f | ||
|
|
350f9e9ef4 | ||
|
|
8d676ea556 | ||
|
|
bef25b7bc0 | ||
|
|
a1167ea3d7 | ||
|
|
71784259f9 | ||
|
|
f6709fcf6d | ||
|
|
0d3211e974 | ||
|
|
d2e867d61b | ||
|
|
13b76b3fb9 | ||
|
|
1742509309 | ||
|
|
6850d73c40 | ||
|
|
0b1e102715 | ||
|
|
e46818f3fa | ||
|
|
9c5a390257 | ||
|
|
1f5bae0dbb | ||
|
|
8091470ae3 | ||
|
|
162ccfc15c | ||
|
|
0aae8653d8 | ||
|
|
3dab2b0a4c | ||
|
|
52c000a50f | ||
|
|
4f1d4f4250 | ||
|
|
69b86b5e6c | ||
|
|
c381bc9da8 | ||
|
|
8ba7257628 | ||
|
|
560ae2c311 | ||
|
|
c0c1e0085b | ||
|
|
c8a87a2e06 | ||
|
|
49d516969d | ||
|
|
b32e1705d9 | ||
|
|
bd58321cfa | ||
|
|
7ea630a88e | ||
|
|
e37e11cc3e | ||
|
|
facf8a2aae | ||
|
|
c5ff313d27 | ||
|
|
c9d77884c5 | ||
|
|
f20f74fec9 | ||
|
|
e250b61e01 | ||
|
|
6210a69297 | ||
|
|
f91a9725d7 | ||
|
|
0d5b557bf2 | ||
|
|
bcbbdfb9df | ||
|
|
dd95a6af0f | ||
|
|
d74c5da260 | ||
|
|
c4cfd0de25 | ||
|
|
0e23d84b72 | ||
|
|
7944422a2f | ||
|
|
8ac77c731e | ||
|
|
c15bc58a39 | ||
|
|
ab8bcbddc2 | ||
|
|
df5aa98cd0 | ||
|
|
90302c0de0 | ||
|
|
ad7771d8e4 | ||
|
|
ce72bef98c | ||
|
|
59a4e24ade | ||
|
|
630585b2e4 | ||
|
|
d375140e4a | ||
|
|
91590b2408 | ||
|
|
aa96a1ded7 | ||
|
|
ebce82e1e8 | ||
|
|
27ea5731bb | ||
|
|
5771aa3631 | ||
|
|
fbb350a64b | ||
|
|
7ad8a1a863 | ||
|
|
831f083153 | ||
|
|
4736124a9e | ||
|
|
3b9e6fa210 | ||
|
|
59745fb8ca | ||
|
|
52b61670a4 | ||
|
|
01eaebbe98 | ||
|
|
6d567fb68c | ||
|
|
27855ddb84 | ||
|
|
a90766c5b9 | ||
|
|
77a46d0e29 | ||
|
|
fac6bf5461 | ||
|
|
8dff447f68 | ||
|
|
8324d47d43 | ||
|
|
fce151948f | ||
|
|
a22a80374e | ||
|
|
e705342dc3 | ||
|
|
a81792e788 | ||
|
|
e1c27f65b5 | ||
|
|
b963818a98 | ||
|
|
b48fbb2e06 | ||
|
|
334ec4824c | ||
|
|
401f99762c | ||
|
|
44896ba832 | ||
|
|
cf983d621f | ||
|
|
e7ae1a5364 | ||
|
|
d0a3302212 | ||
|
|
7e2230970b | ||
|
|
dac6bac8df | ||
|
|
7fc2d9f902 | ||
|
|
5c0e4be5c9 | ||
|
|
87cda5a97f | ||
|
|
dab0ea373c | ||
|
|
078d19382c | ||
|
|
f74570f348 | ||
|
|
ea58ad6340 | ||
|
|
5e135e6ced | ||
|
|
82e713c167 | ||
|
|
c01061b9df | ||
|
|
148f9b119b | ||
|
|
46f916b1a2 | ||
|
|
b6c528763c | ||
|
|
bc2179965f | ||
|
|
2e2e509835 | ||
|
|
30fc18d772 | ||
|
|
7876f44e5b | ||
|
|
31ea2e7be4 | ||
|
|
08d36d68e3 | ||
|
|
e39c1658f1 | ||
|
|
5d1e3a2213 | ||
|
|
952fe722f6 | ||
|
|
c0fa9b9bf6 | ||
|
|
1d1e4f974b | ||
|
|
8e835271d5 | ||
|
|
6f8e5b53b3 | ||
|
|
a5d6731611 | ||
|
|
0c525db644 | ||
|
|
9bbf69a621 | ||
|
|
33af9119ce | ||
|
|
4eb62c7655 | ||
|
|
e9758fda6c | ||
|
|
7a17e13d55 | ||
|
|
f9bc65b6e1 | ||
|
|
febc475634 | ||
|
|
b9b6d9da78 | ||
|
|
3f4502e861 | ||
|
|
6d8c7af90c | ||
|
|
a4e3347abf | ||
|
|
a71f449adc | ||
|
|
96fe9e094c | ||
|
|
b105abc56f | ||
|
|
bb5790cd1a | ||
|
|
506dee2337 | ||
|
|
1cf1b0f1da | ||
|
|
15bc754ea7 | ||
|
|
01641a05f4 | ||
|
|
84a1cc37a5 | ||
|
|
a4088eb173 | ||
|
|
70f0d9c61b | ||
|
|
0c6b7fc4a1 | ||
|
|
bf9df6e0b2 | ||
|
|
f3fff52304 | ||
|
|
3cde7fc4ee | ||
|
|
9b19f3940b | ||
|
|
e5e776c288 | ||
|
|
f648fdc31c | ||
|
|
5ea50b1030 | ||
|
|
c3269e6639 | ||
|
|
bba96eef89 | ||
|
|
d9080650ac | ||
|
|
704a41b281 | ||
|
|
585f734e32 | ||
|
|
412d32e58d | ||
|
|
73ecd3505e | ||
|
|
f2759fc5dd | ||
|
|
5b07b66492 | ||
|
|
2b91e651d4 | ||
|
|
80582657f0 | ||
|
|
82de7f631a | ||
|
|
333b544001 | ||
|
|
6e98e25184 | ||
|
|
36bed52eae | ||
|
|
976abb854b | ||
|
|
d667354e09 | ||
|
|
6b468d5751 | ||
|
|
a61f6e8f93 | ||
|
|
86e564bb91 | ||
|
|
f5b9f28cc0 | ||
|
|
7dad67ad35 | ||
|
|
0eb93b4e8b | ||
|
|
f5ad4c9117 | ||
|
|
14e7cfcbef | ||
|
|
89e4cc7be0 | ||
|
|
00b2cfb785 | ||
|
|
8b8820ef91 | ||
|
|
d3ffbb6bd0 | ||
|
|
725ecb192c | ||
|
|
15fa3804af | ||
|
|
5d359ba7a0 | ||
|
|
df779d9f2a | ||
|
|
b9633f1c22 | ||
|
|
a6ec9e3049 | ||
|
|
bec84e799e | ||
|
|
4eb45af6d0 | ||
|
|
61579b1166 | ||
|
|
41aae0b753 | ||
|
|
23ff844e70 | ||
|
|
a3730c7c82 | ||
|
|
a587defb76 | ||
|
|
38407d55a9 | ||
|
|
63435257f0 | ||
|
|
17065f9193 | ||
|
|
6caecfce72 | ||
|
|
1dabdb5315 | ||
|
|
131a8fafcd | ||
|
|
b5f742f3ba | ||
|
|
726cb1a3eb | ||
|
|
59d0b99121 | ||
|
|
b061b1a557 | ||
|
|
3b1c6ae68f | ||
|
|
d5ed79ab66 | ||
|
|
df3bb79365 | ||
|
|
7308f3464b | ||
|
|
8a53f5ff56 | ||
|
|
3e5de81414 | ||
|
|
6b59ade7bd | ||
|
|
ebed24ab5d | ||
|
|
64c227afc9 | ||
|
|
bb6947d9d9 | ||
|
|
f35db9a594 | ||
|
|
fb446d433a | ||
|
|
1e443545c9 | ||
|
|
0ee0c655cf | ||
|
|
183f8f5398 | ||
|
|
91e300cb68 | ||
|
|
641895c0d5 | ||
|
|
e84522c2fa | ||
|
|
dc4077325b | ||
|
|
44c42e1c01 | ||
|
|
f2f86932f4 | ||
|
|
943d197253 | ||
|
|
3a015657cb | ||
|
|
974520a733 | ||
|
|
b1dedf3435 | ||
|
|
29347af729 | ||
|
|
9efd3ec7ad | ||
|
|
169b0e560b | ||
|
|
9c560eae63 | ||
|
|
3e2c4b1db0 | ||
|
|
cb47072fa7 | ||
|
|
59d4e7688f | ||
|
|
8291a19487 | ||
|
|
1bb7d764ca | ||
|
|
251cecb1a7 | ||
|
|
d67b6ab6e6 | ||
|
|
ddcca92012 | ||
|
|
739c1d9257 | ||
|
|
6978587ae1 | ||
|
|
da1064fc37 | ||
|
|
a41be3d3cb | ||
|
|
798093ae19 | ||
|
|
929cb20149 | ||
|
|
2676cd88e5 | ||
|
|
c40a912815 | ||
|
|
6a177d3dee | ||
|
|
79677f5281 | ||
|
|
7e17aca4ff | ||
|
|
c78e05e873 | ||
|
|
2e9d7ce028 | ||
|
|
a4eafbf757 | ||
|
|
799c3a3163 | ||
|
|
22e7f71e22 | ||
|
|
0ae679f3b5 | ||
|
|
13d602422e | ||
|
|
ed95f486fc | ||
|
|
93ef48add6 | ||
|
|
2c6bfc4c9e | ||
|
|
fd23d58cb9 | ||
|
|
d40a4a1731 | ||
|
|
01edfe6491 | ||
|
|
ae94e219ba | ||
|
|
1958c06b87 | ||
|
|
0efdf2bbac |
No files matched your search
+3
-3
@@ -1,6 +1,6 @@
|
||||
pipeline:
|
||||
compile:
|
||||
image: nextcloudci/android:android-40
|
||||
image: nextcloudci/android:android-42
|
||||
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-40
|
||||
image: nextcloudci/android:android-42
|
||||
privileged: true
|
||||
commands:
|
||||
- emulator -avd android-27 -no-window -no-audio &
|
||||
@@ -27,7 +27,7 @@ pipeline:
|
||||
FLAVOR: Gplay
|
||||
|
||||
analysis:
|
||||
image: nextcloudci/android:android-40
|
||||
image: nextcloudci/android:android-42
|
||||
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
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# .editorconfig
|
||||
|
||||
# see http://EditorConfig.org
|
||||
|
||||
# This is the file in the root of the project.
|
||||
# For sub folders you can have other files that override only some settings.
|
||||
# For these, this settings should be false.
|
||||
root=true
|
||||
|
||||
[*]
|
||||
max_line_length=120
|
||||
# use spaces, not tabs.
|
||||
indent_style=space
|
||||
indent_size=4
|
||||
|
||||
charset=utf-8
|
||||
|
||||
# Trimming is good for consistency
|
||||
trim_trailing_whitespace=true
|
||||
# I've seen cases where a missing new_line was ignored on *nix systems.
|
||||
# Never again with this setting!
|
||||
insert_final_newline=true
|
||||
|
||||
[*.properties]
|
||||
# Exception for Java properties files should be encoded latin1 (aka iso8859-1)
|
||||
charset=latin1
|
||||
|
||||
[*.{cmd,bat}]
|
||||
# batch files on Windows should stay with CRLF
|
||||
end_of_line=crlf
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace=false
|
||||
@@ -1,3 +1,9 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
### Actual behaviour
|
||||
- Tell us what happens
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
### Is your feature request related to a problem? Please describe.
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
### Describe the solution you'd like
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
### Describe alternatives you've considered
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
### Additional context
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
||||
**NOTE:** Be super sure to remove sensitive data like passwords, note that everybody can look here! You can use the Issue Template application to prefill some of the required information: https://apps.nextcloud.com/apps/issuetemplate
|
||||
+39
-10
@@ -1,10 +1,39 @@
|
||||
## 3.2.4 (Sept, 04, 2018)
|
||||
fix push notification on gplay release
|
||||
## 3.3.2 (November, 2, 2018)
|
||||
- fix fingerprint not working on certain devices
|
||||
|
||||
## 3.2.3 (Aug, 21, 2018)
|
||||
For full list please see https://github.com/nextcloud/android/milestone/27
|
||||
|
||||
## 3.3.1 (October, 29, 2018)
|
||||
Bugfix release
|
||||
- fix crash on shared folder/file via Talk
|
||||
- fix crash on Notification activity
|
||||
- fixed setup DAVdroid via settings
|
||||
- hide edit option on shares, if not allowed
|
||||
|
||||
For full list please see https://github.com/nextcloud/android/milestone/26
|
||||
|
||||
## 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 (Aug, 20, 2018)
|
||||
## 3.2.2 (August, 20, 2018)
|
||||
- New simple signup screen
|
||||
|
||||
## 3.2.1 (June, 11, 2018)
|
||||
@@ -22,27 +51,27 @@ fix push notification on gplay release
|
||||
- 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
|
||||
@@ -58,7 +87,7 @@ fix push notification on gplay release
|
||||
- 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
|
||||
|
||||
@@ -45,7 +45,7 @@ Easy starting points are also reviewing [pull requests](https://github.com/nextc
|
||||
#### With a computer:
|
||||
- connect the device via USB
|
||||
- open command prompt/terminal
|
||||
- enter `adb logcat | grep "$(adb shell ps | grep com.nextcloud.client | awk '{print $2}')" > logcatOutput.txt` to save the output to this file
|
||||
- enter `adb logcat | grep "$(adb shell ps | awk '/com.nextcloud.client/{print $2}')" > logcatOutput.txt` to save the output to this file
|
||||
|
||||
**Note:** You must have [adb](https://developer.android.com/studio/releases/platform-tools.html) installed first!
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ To set up the project in Android Studio follow the next steps:
|
||||
* Make sure you have called ```git submodule update``` whenever you switched branches
|
||||
* Open Android Studio and select 'Import Project (Eclipse ADT, Gradle, etc)'. Browse through your file system to the folder 'android' where the project is located. Android Studio will then create the '.iml' files it needs. If you ever close the project but the files are still there, you just select 'Open Project…'. The file chooser will show an Android face as the folder icon, which you can select to reopen the project.
|
||||
* Android Studio will try to build the project directly after importing it. To build it manually, follow the menu path 'Build'/'Make Project', or just click the 'Play' button in the toolbar to build and run it in a mobile device or an emulator. The resulting APK file will be saved in the 'build/outputs/apk/' subdirectory in the project folder.
|
||||
* Setup Android Studio editor configurtation for the project: ```Settings``` → ```Editor``` → ```Code Style``` → ```Scheme: Project``` and ```Enable EditorConfig support```
|
||||
|
||||
|
||||
### 3. Working in a terminal with Gradle:
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>4.3.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
@@ -75,4 +75,4 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
+27
-27
@@ -7,19 +7,16 @@
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
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.3') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.3')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +33,7 @@ configurations.all {
|
||||
}
|
||||
|
||||
ext {
|
||||
supportLibraryVersion = '27.1.1'
|
||||
supportLibraryVersion = '28.0.0'
|
||||
jacocoVersion = "0.8.2"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
@@ -46,10 +43,10 @@ ext {
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
||||
google()
|
||||
|
||||
flatDir {
|
||||
dirs 'libs'
|
||||
@@ -60,7 +57,7 @@ repositories {
|
||||
def versionMajor = 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 / 90-99=stable
|
||||
|
||||
def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
|
||||
if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
|
||||
@@ -79,11 +76,11 @@ android {
|
||||
javaMaxHeapSize "4g"
|
||||
}
|
||||
|
||||
compileSdkVersion 27
|
||||
compileSdkVersion 28
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
targetSdkVersion 28
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -96,12 +93,12 @@ android {
|
||||
|
||||
versionCode versionMajor * 10000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
|
||||
|
||||
if (versionBuild > 98) {
|
||||
if (versionBuild > 89) {
|
||||
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)
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha" + (versionBuild + 1)
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
@@ -130,8 +127,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20180919
|
||||
versionName "20180919"
|
||||
versionCode 20181206
|
||||
versionName "20181206"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,7 +180,7 @@ android {
|
||||
ignoreFailures = false
|
||||
effort = "max"
|
||||
reportLevel = "medium"
|
||||
classes = fileTree("$project.buildDir/intermediates/classes/gplay/debug/com/owncloud")
|
||||
classes = fileTree("$project.buildDir/intermediates/javac/gplayDebug/compileGplayDebugJavaWithJavac/classes/")
|
||||
excludeFilter = file("${project.rootDir}/findbugs-filter.xml")
|
||||
source = fileTree('src/main/java')
|
||||
pluginClasspath = project.configurations.findbugsPlugins
|
||||
@@ -213,16 +210,16 @@ 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
|
||||
versionDevImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||
implementation "com.android.support:support-v4:${supportLibraryVersion}"
|
||||
implementation "com.android.support:design:${supportLibraryVersion}"
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
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:2.2.0'
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.0' // need this version for Android <7
|
||||
implementation 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.6'
|
||||
implementation 'com.github.evernote:android-job:v1.2.5'
|
||||
@@ -237,9 +234,9 @@ dependencies {
|
||||
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.11'
|
||||
implementation 'org.parceler:parceler-api:1.1.12'
|
||||
annotationProcessor 'org.parceler:parceler:1.1.11'
|
||||
implementation ('com.github.bumptech.glide:glide:3.7.0') {
|
||||
implementation('com.github.bumptech.glide:glide:3.7.0') {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
implementation 'com.caverock:androidsvg:1.3'
|
||||
@@ -248,7 +245,7 @@ dependencies {
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.22.0'
|
||||
testImplementation 'org.mockito:mockito-core:2.23.4'
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
androidTestImplementation 'com.android.support.test:rules:1.0.2'
|
||||
@@ -262,13 +259,16 @@ 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:16.0.2'
|
||||
implementation 'org.jetbrains:annotations:16.0.3'
|
||||
|
||||
compileOnly "org.projectlombok:lombok:1.18.4"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.4"
|
||||
|
||||
androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
|
||||
|
||||
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}"
|
||||
// androidJacocoAgent "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
@@ -309,6 +309,6 @@ task combinedTestReport(type: JacocoReport) {
|
||||
sourceDirectories = files([mainSrc])
|
||||
classDirectories = files([debugTree])
|
||||
executionData = fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/>
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 216 B |
@@ -13,7 +13,7 @@
|
||||
viewBox="0 0 128 128"
|
||||
version="1.1"
|
||||
id="svg829"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||
sodipodi:docname="first_run_talk.svg">
|
||||
<defs
|
||||
id="defs823"/>
|
||||
@@ -25,8 +25,8 @@
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.98994949"
|
||||
inkscape:cx="297.07973"
|
||||
inkscape:cy="366.5173"
|
||||
inkscape:cx="197.26742"
|
||||
inkscape:cy="78.319822"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
@@ -35,10 +35,10 @@
|
||||
fit-margin-left="2"
|
||||
fit-margin-right="2"
|
||||
fit-margin-bottom="2"
|
||||
inkscape:window-width="1600"
|
||||
inkscape:window-height="835"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1046"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-y="34"
|
||||
inkscape:window-maximized="1"/>
|
||||
<metadata
|
||||
id="metadata826">
|
||||
@@ -58,9 +58,11 @@
|
||||
id="layer1"
|
||||
transform="translate(-15.580506,-52.12649)">
|
||||
<path
|
||||
style="fill:#ffffff;stroke-width:4.78543139"
|
||||
d="M 241.85938,2.6035156 C 109.72511,2.6053865 2.6113188,109.72517 2.6152344,241.86133 c 8.69e-5,132.13334 107.1127156,239.24815 239.2441456,239.25 26.38805,-0.0535 52.46249,-4.4707 77.19954,-12.96295 16.31567,-5.60118 32.04955,-12.97512 46.90788,-22.039 12.78608,5.081 32.46588,14.50729 51.91537,22.30803 25.27886,10.13878 50.16864,17.53156 59.02799,9.06892 8.75623,-8.36216 2.65569,-33.29226 -6.22433,-58.86696 -7.73207,-22.26856 -17.57143,-45.02584 -21.54521,-57.75999 9.61628,-16.68601 17.14139,-34.39874 22.46771,-52.73831 6.22776,-21.44334 9.44951,-43.74365 9.49323,-66.26169 C 481.09967,109.72865 373.99016,2.6150774 241.86133,2.6113281 Z m 0.0273,90.9609374 h 0.002 c 81.9303,3.48e-4 148.34762,66.419397 148.34766,148.351567 -0.004,81.92844 -66.42304,148.34179 -148.34961,148.34179 -81.92656,0 -148.342022,-66.41335 -148.347658,-148.34179 2.7e-5,-81.93241 66.417128,-148.351563 148.347658,-148.351567 z"
|
||||
transform="matrix(0.26458333,0,0,0.26458333,15.580506,52.12649)"
|
||||
id="path4753"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#ffffff;stroke-width:1.26614535"
|
||||
d="m 79.572589,52.815123 a 63.300934,63.301842 0 0 0 -63.300038,63.303717 63.300934,63.301842 0 0 0 63.300038,63.3018 63.300934,63.301842 0 0 0 32.836581,-9.26097 c 7.77991,3.09162 25.20623,12.26357 29.35376,8.30176 4.33401,-4.13896 -5.08818,-23.61904 -7.34707,-30.85775 A 63.300934,63.301842 0 0 0 142.8719,116.11826 63.300934,63.301842 0 0 0 79.572762,52.817324 Z m 0.0074,24.06677 A 39.250508,39.251409 0 0 1 118.83033,116.13329 39.250508,39.251409 0 0 1 79.579825,155.382 39.250508,39.251409 0 0 1 40.329319,116.13329 39.250508,39.251409 0 0 1 79.579825,76.881893 Z"
|
||||
id="path2"/>
|
||||
sodipodi:nodetypes="cccscscscscccsccscs"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,3 @@
|
||||
# workaround since lombok and desugering have an issue
|
||||
# to be fixed with gradle Android plugin 3.3.0
|
||||
android.enableD8.desugaring=false
|
||||
+2
-2
@@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
distributionSha256Sum=7a2c66d1a78f811d5f37d14630ad21cec5e77a2a4dc61e787e2257a6341016ce
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
||||
distributionSha256Sum=9af7345c199f1731c187c96d3fe3d31f5405192a42046bafa71d846c3d9adacb
|
||||
@@ -1,17 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
<issue id="UnusedAttribute">
|
||||
<ignore regexp="importantForAutofill"/>
|
||||
<ignore regexp="autofillHints"/>
|
||||
</issue>
|
||||
<issue id="InvalidPackage">
|
||||
<ignore path="**/freemarker-2.3.23.jar"/>
|
||||
<ignore path="**/nnio-0.2.jar"/>
|
||||
<ignore path="**/pkix-1.54.0.0.jar"/>
|
||||
</issue>
|
||||
|
||||
|
||||
<issue id="UnusedResources">
|
||||
<ignore regexp="store_short_desc|store_full_desc|store_short_dev_desc|store_full_dev_desc" />
|
||||
<ignore
|
||||
regexp="screenshot_01_gridView|screenshot_02_listView|screenshot_03_drawer|screenshot_04_accounts|screenshot_05_autoUpload|screenshot_06_davdroid"/>
|
||||
</issue>
|
||||
|
||||
|
||||
<issue id="MissingQuantity">
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
</issue>
|
||||
@@ -28,178 +32,15 @@
|
||||
</issue>
|
||||
|
||||
<issue id="UnusedResources">
|
||||
<ignore path="**/values-b+en+001/strings.xml"/>
|
||||
<ignore path="**/values-b+es+419/strings.xml" />
|
||||
<ignore path="**/values-pt-rPT/strings.xml"/>
|
||||
<ignore path="**/values-ro/strings.xml"/>
|
||||
<ignore path="**/values-zh-rCN/strings.xml"/>
|
||||
<ignore path="**/values-bg-rBG/strings.xml"/>
|
||||
<ignore path="**/values-nb-rNO/strings.xml"/>
|
||||
<ignore path="**/values-es/strings.xml"/>
|
||||
<ignore path="**/values-fa/strings.xml"/>
|
||||
<ignore path="**/values-ko/strings.xml"/>
|
||||
<ignore path="**/values-ru/strings.xml"/>
|
||||
<ignore path="**/values-ast/strings.xml"/>
|
||||
<ignore path="**/values-es-rCO/strings.xml"/>
|
||||
<ignore path="**/values-es-rCL/strings.xml"/>
|
||||
<ignore path="**/values-es-rSV/strings.xml"/>
|
||||
<ignore path="**/values-sv/strings.xml"/>
|
||||
<ignore path="**/values-tr/strings.xml"/>
|
||||
<ignore path="**/values-es-rUY/strings.xml"/>
|
||||
<ignore path="**/values-es-rGT/strings.xml"/>
|
||||
<ignore path="**/values-fr/strings.xml"/>
|
||||
<ignore path="**/values-es-rMX/strings.xml"/>
|
||||
<ignore path="**/values-fi-rFI/strings.xml"/>
|
||||
<ignore path="**/values-ar/strings.xml"/>
|
||||
<ignore path="**/values-es-rAR/strings.xml"/>
|
||||
<ignore path="**/values-de-rDE/strings.xml"/>
|
||||
<ignore path="**/values-ca/strings.xml"/>
|
||||
<ignore path="**/values-is/strings.xml"/>
|
||||
<ignore path="**/values-es-rNI/strings.xml"/>
|
||||
<ignore path="**/values-es-rPR/strings.xml"/>
|
||||
<ignore path="**/values-es-rDO/strings.xml"/>
|
||||
<ignore path="**/values-sq/strings.xml"/>
|
||||
<ignore path="**/values-pt-rBR/strings.xml"/>
|
||||
<ignore path="**/values-ja-rJP/strings.xml"/>
|
||||
<ignore path="**/values-sr/strings.xml"/>
|
||||
<ignore path="**/values-it/strings.xml"/>
|
||||
<ignore path="**/values-hu-rHU/strings.xml"/>
|
||||
<ignore path="**/values-pl/strings.xml"/>
|
||||
<ignore path="**/values-es-rHN/strings.xml"/>
|
||||
<ignore path="**/values-lt-rLT/strings.xml"/>
|
||||
<ignore path="**/values-es-rPA/strings.xml"/>
|
||||
<ignore path="**/values-nl/strings.xml"/>
|
||||
<ignore path="**/values-sk-rSK/strings.xml"/>
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
<ignore path="**/values-eu/strings.xml"/>
|
||||
<ignore path="**/values-es-rCR/strings.xml"/>
|
||||
<ignore path="**/values-da/strings.xml"/>
|
||||
<ignore path="**/values-es-rEC/strings.xml"/>
|
||||
<ignore path="**/values-de/strings.xml"/>
|
||||
<ignore path="**/values-sl/strings.xml"/>
|
||||
<ignore path="**/values-es-rPY/strings.xml"/>
|
||||
<ignore path="**/values-es-rPE/strings.xml"/>
|
||||
<ignore path="**/values-zh-rTW/strings.xml"/>
|
||||
<ignore path="**/values-el/strings.xml"/>
|
||||
<ignore path="**/values-id/strings.xml"/>
|
||||
<ignore path="**/values-cs-rCZ/strings.xml"/>
|
||||
<ignore path="**/values-en-rGB/strings.xml"/>
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
|
||||
<issue id="TypographyEllipsis">
|
||||
<ignore path="**/values-b+en+001/strings.xml"/>
|
||||
<ignore path="**/values-pt-rPT/strings.xml"/>
|
||||
<ignore path="**/values-ro/strings.xml"/>
|
||||
<ignore path="**/values-zh-rCN/strings.xml"/>
|
||||
<ignore path="**/values-bg-rBG/strings.xml"/>
|
||||
<ignore path="**/values-nb-rNO/strings.xml"/>
|
||||
<ignore path="**/values-es/strings.xml"/>
|
||||
<ignore path="**/values-fa/strings.xml"/>
|
||||
<ignore path="**/values-ko/strings.xml"/>
|
||||
<ignore path="**/values-ru/strings.xml"/>
|
||||
<ignore path="**/values-ast/strings.xml"/>
|
||||
<ignore path="**/values-es-rCO/strings.xml"/>
|
||||
<ignore path="**/values-es-rCL/strings.xml"/>
|
||||
<ignore path="**/values-es-rSV/strings.xml"/>
|
||||
<ignore path="**/values-sv/strings.xml"/>
|
||||
<ignore path="**/values-tr/strings.xml"/>
|
||||
<ignore path="**/values-es-rUY/strings.xml"/>
|
||||
<ignore path="**/values-es-rGT/strings.xml"/>
|
||||
<ignore path="**/values-fr/strings.xml"/>
|
||||
<ignore path="**/values-es-rMX/strings.xml"/>
|
||||
<ignore path="**/values-fi-rFI/strings.xml"/>
|
||||
<ignore path="**/values-ar/strings.xml"/>
|
||||
<ignore path="**/values-es-rAR/strings.xml"/>
|
||||
<ignore path="**/values-de-rDE/strings.xml"/>
|
||||
<ignore path="**/values-ca/strings.xml"/>
|
||||
<ignore path="**/values-is/strings.xml"/>
|
||||
<ignore path="**/values-es-rNI/strings.xml"/>
|
||||
<ignore path="**/values-es-rPR/strings.xml"/>
|
||||
<ignore path="**/values-es-rDO/strings.xml"/>
|
||||
<ignore path="**/values-sq/strings.xml"/>
|
||||
<ignore path="**/values-pt-rBR/strings.xml"/>
|
||||
<ignore path="**/values-ja-rJP/strings.xml"/>
|
||||
<ignore path="**/values-sr/strings.xml"/>
|
||||
<ignore path="**/values-it/strings.xml"/>
|
||||
<ignore path="**/values-hu-rHU/strings.xml"/>
|
||||
<ignore path="**/values-pl/strings.xml"/>
|
||||
<ignore path="**/values-es-rHN/strings.xml"/>
|
||||
<ignore path="**/values-lt-rLT/strings.xml"/>
|
||||
<ignore path="**/values-es-rPA/strings.xml"/>
|
||||
<ignore path="**/values-nl/strings.xml"/>
|
||||
<ignore path="**/values-sk-rSK/strings.xml"/>
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
<ignore path="**/values-eu/strings.xml"/>
|
||||
<ignore path="**/values-es-rCR/strings.xml"/>
|
||||
<ignore path="**/values-da/strings.xml"/>
|
||||
<ignore path="**/values-es-rEC/strings.xml"/>
|
||||
<ignore path="**/values-de/strings.xml"/>
|
||||
<ignore path="**/values-sl/strings.xml"/>
|
||||
<ignore path="**/values-es-rPY/strings.xml"/>
|
||||
<ignore path="**/values-es-rPE/strings.xml"/>
|
||||
<ignore path="**/values-zh-rTW/strings.xml"/>
|
||||
<ignore path="**/values-el/strings.xml"/>
|
||||
<ignore path="**/values-id/strings.xml"/>
|
||||
<ignore path="**/values-cs-rCZ/strings.xml"/>
|
||||
<ignore path="**/values-en-rGB/strings.xml"/>
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
<issue id="Typos">
|
||||
<ignore path="**/values-b+en+001/strings.xml"/>
|
||||
<ignore path="**/values-pt-rPT/strings.xml"/>
|
||||
<ignore path="**/values-ro/strings.xml"/>
|
||||
<ignore path="**/values-zh-rCN/strings.xml"/>
|
||||
<ignore path="**/values-bg-rBG/strings.xml"/>
|
||||
<ignore path="**/values-nb-rNO/strings.xml"/>
|
||||
<ignore path="**/values-es/strings.xml"/>
|
||||
<ignore path="**/values-fa/strings.xml"/>
|
||||
<ignore path="**/values-ko/strings.xml"/>
|
||||
<ignore path="**/values-ru/strings.xml"/>
|
||||
<ignore path="**/values-ast/strings.xml"/>
|
||||
<ignore path="**/values-es-rCO/strings.xml"/>
|
||||
<ignore path="**/values-es-rCL/strings.xml"/>
|
||||
<ignore path="**/values-es-rSV/strings.xml"/>
|
||||
<ignore path="**/values-sv/strings.xml"/>
|
||||
<ignore path="**/values-tr/strings.xml"/>
|
||||
<ignore path="**/values-es-rUY/strings.xml"/>
|
||||
<ignore path="**/values-es-rGT/strings.xml"/>
|
||||
<ignore path="**/values-fr/strings.xml"/>
|
||||
<ignore path="**/values-es-rMX/strings.xml"/>
|
||||
<ignore path="**/values-fi-rFI/strings.xml"/>
|
||||
<ignore path="**/values-ar/strings.xml"/>
|
||||
<ignore path="**/values-es-rAR/strings.xml"/>
|
||||
<ignore path="**/values-de-rDE/strings.xml"/>
|
||||
<ignore path="**/values-ca/strings.xml"/>
|
||||
<ignore path="**/values-is/strings.xml"/>
|
||||
<ignore path="**/values-es-rNI/strings.xml"/>
|
||||
<ignore path="**/values-es-rPR/strings.xml"/>
|
||||
<ignore path="**/values-es-rDO/strings.xml"/>
|
||||
<ignore path="**/values-sq/strings.xml"/>
|
||||
<ignore path="**/values-pt-rBR/strings.xml"/>
|
||||
<ignore path="**/values-ja-rJP/strings.xml"/>
|
||||
<ignore path="**/values-sr/strings.xml"/>
|
||||
<ignore path="**/values-it/strings.xml"/>
|
||||
<ignore path="**/values-hu-rHU/strings.xml"/>
|
||||
<ignore path="**/values-pl/strings.xml"/>
|
||||
<ignore path="**/values-es-rHN/strings.xml"/>
|
||||
<ignore path="**/values-lt-rLT/strings.xml"/>
|
||||
<ignore path="**/values-es-rPA/strings.xml"/>
|
||||
<ignore path="**/values-nl/strings.xml"/>
|
||||
<ignore path="**/values-sk-rSK/strings.xml"/>
|
||||
<ignore path="**/values-ka-rGE/strings.xml"/>
|
||||
<ignore path="**/values-eu/strings.xml"/>
|
||||
<ignore path="**/values-es-rCR/strings.xml"/>
|
||||
<ignore path="**/values-da/strings.xml"/>
|
||||
<ignore path="**/values-es-rEC/strings.xml"/>
|
||||
<ignore path="**/values-de/strings.xml"/>
|
||||
<ignore path="**/values-sl/strings.xml"/>
|
||||
<ignore path="**/values-es-rPY/strings.xml"/>
|
||||
<ignore path="**/values-es-rPE/strings.xml"/>
|
||||
<ignore path="**/values-zh-rTW/strings.xml"/>
|
||||
<ignore path="**/values-el/strings.xml"/>
|
||||
<ignore path="**/values-id/strings.xml"/>
|
||||
<ignore path="**/values-cs-rCZ/strings.xml"/>
|
||||
<ignore path="**/values-en-rGB/strings.xml"/>
|
||||
|
||||
<issue id="Typos">
|
||||
<ignore path="**/values-**/strings.xml" />
|
||||
</issue>
|
||||
|
||||
</lint>
|
||||
@@ -8,74 +8,88 @@
|
||||
#6: DRONE_BUILD_NUMBER
|
||||
#7: PULL_REQUEST_NUMBER
|
||||
|
||||
stableBranch="master"
|
||||
repository="android"
|
||||
|
||||
ruby scripts/analysis/lint-up.rb $1 $2 $3
|
||||
lintValue=$?
|
||||
|
||||
./gradlew findbugs
|
||||
|
||||
# exit codes:
|
||||
# 0: count was reduced
|
||||
# 1: count was increased
|
||||
# 2: count stayed the same
|
||||
|
||||
./gradlew findbugs
|
||||
|
||||
echo "Branch: $3"
|
||||
|
||||
if [ $3 = "master" ]; then
|
||||
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 [ $3 = $stableBranch ]; then
|
||||
echo "New findbugs result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$stableBranch.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 ($stableBranch)/" | tr "\"" "\'" | tr -d "\r\n")
|
||||
curl -u $4:$5 -X PUT -d "$summary" https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/findbugs-summary-$stableBranch.html
|
||||
|
||||
if [ $lintValue -ne 1 ]; then
|
||||
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
|
||||
echo "New lint result for $stableBranch at: https://www.kaminsky.me/nc-dev/$repository-lint/$stableBranch.html"
|
||||
curl -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$stableBranch.html --upload-file build/reports/lint/lint.html
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
if [ -e $6 ]; then
|
||||
6="master-"$(date +%F)
|
||||
6=$stableBranch"-"$(date +%F)
|
||||
fi
|
||||
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://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
|
||||
|
||||
echo "New lint results at https://www.kaminsky.me/nc-dev/$repository-lint/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-lint/$6.html --upload-file build/reports/lint/lint.html
|
||||
|
||||
echo "New findbugs results at https://www.kaminsky.me/nc-dev/$repository-findbugs/$6.html"
|
||||
curl 2>/dev/null -u $4:$5 -X PUT https://nextcloud.kaminsky.me/remote.php/webdav/$repository-findbugs/$6.html --upload-file build/reports/findbugs/findbugs.html
|
||||
|
||||
# delete all old comments
|
||||
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) ' | grep true | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
oldComments=$(curl 2>/dev/null -u $1:$2 -X GET https://api.github.com/repos/nextcloud/android/issues/$7/comments | jq '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) ' | grep true | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
curl 2>/dev/null -u $1:$2 -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
|
||||
|
||||
# check library, only if base branch is master
|
||||
baseBranch=$(scripts/analysis/getBranchBase.sh $1 $2 $7 | tr -d "\"")
|
||||
if [ $baseBranch = "master" -a $(grep "android-library:master" build.gradle -c) -ne 3 ]; then
|
||||
checkLibraryMessage="<h1>Android-library is not set to master branch in build.gradle</h1>"
|
||||
checkLibrary=1
|
||||
else
|
||||
else
|
||||
checkLibrary=0
|
||||
fi
|
||||
|
||||
|
||||
# lint and findbugs file must exist
|
||||
if [ ! -s build/reports/lint/lint.html ] ; then
|
||||
echo "lint.html file is missing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -s build/reports/findbugs/findbugs.html ] ; then
|
||||
echo "findbugs.html file is missing!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# add comment with results
|
||||
lintResultNew=$(grep "Lint Report.* [0-9]* warnings" build/reports/lint/lint.html | cut -f2 -d':' |cut -f1 -d'<')
|
||||
lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ")
|
||||
lintWarningNew=$(echo $lintResultNew | grep "[0-9]* warning" -o | cut -f1 -d" ")
|
||||
lintErrorNew=$(echo $lintResultNew | grep "[0-9]* error" -o | cut -f1 -d" ")
|
||||
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><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")
|
||||
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/"$repository"-lint/"$stableBranch".html'>$stableBranch</a></td><td><a href='https://www.kaminsky.me/nc-dev/"$repository"-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/$repository-findbugs/$6.html\">FindBugs</a> (new)#" | tr "\"" "\'" | tr -d "\n")
|
||||
findbugsResultOld=$(curl 2>/dev/null https://www.kaminsky.me/nc-dev/$repository-findbugs/findbugs-summary-$stableBranch.html | tr "\"" "\'" | tr -d "\r\n" | sed s"#FindBugs#<a href=\"https://www.kaminsky.me/nc-dev/$repository-findbugs/$stableBranch.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
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ $lintValue -eq 2 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit $lintValue
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 94 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 90 warnings</span>
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/integrationTests
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
|
||||
ID=$3
|
||||
USER=$1
|
||||
PASS=$2
|
||||
@@ -8,12 +8,12 @@ TYPE=$4
|
||||
|
||||
if [ $TYPE = "IT" ]; then
|
||||
cd build/reports/androidTests/connected/flavors/GPLAY
|
||||
else
|
||||
else
|
||||
cd build/reports/tests/testGplayDebugUnitTest
|
||||
fi
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$ID/$(echo {} | sed s#\./##) \;
|
||||
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$ID/$(echo {} | sed s#\./##) --upload-file {} \;
|
||||
|
||||
echo "Uploaded failing tests to https://nextcloud.kaminsky.me/index.php/s/XqY52jBr9ZYfDiz -> $ID"
|
||||
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$ID"
|
||||
exit 1
|
||||
@@ -6,8 +6,8 @@ import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
@@ -19,6 +19,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -26,24 +27,20 @@ import java.io.IOException;
|
||||
*/
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
public abstract class AbstractIT {
|
||||
|
||||
protected static OwnCloudClient client;
|
||||
protected static Account account;
|
||||
static Account account;
|
||||
protected static Context context;
|
||||
|
||||
private static final String username = "test";
|
||||
private static final String password = "test";
|
||||
private static final String baseUrl = "server";
|
||||
|
||||
public AbstractIT() {
|
||||
super(MainApp.class);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
try {
|
||||
context = MainApp.getAppContext();
|
||||
context = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
Account temp = new Account(username + "@" + baseUrl, MainApp.getAccountType(context));
|
||||
|
||||
@@ -62,7 +59,7 @@ public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
if (account == null) {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
|
||||
|
||||
client = OwnCloudClientFactory.createOwnCloudClient(account, context);
|
||||
|
||||
createDummyFiles();
|
||||
@@ -77,14 +74,28 @@ public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
}
|
||||
}
|
||||
|
||||
protected FileDataStorageManager getStorageManager() {
|
||||
FileDataStorageManager getStorageManager() {
|
||||
return new FileDataStorageManager(account, context.getContentResolver());
|
||||
}
|
||||
|
||||
private static void createDummyFiles() throws IOException {
|
||||
new File(FileStorageUtils.getSavePath(account.name)).mkdirs();
|
||||
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + "/123.txt");
|
||||
createFile("empty.txt", 0);
|
||||
createFile("nonEmpty.txt", 100);
|
||||
createFile("chunkedFile.txt", 500000);
|
||||
}
|
||||
|
||||
private static void createFile(String name, int iteration) throws IOException {
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
|
||||
file.createNewFile();
|
||||
|
||||
FileWriter writer = new FileWriter(file);
|
||||
|
||||
for (int i = 0; i < iteration; i++) {
|
||||
writer.write("123123123123123123123123123\n");
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,12 @@ import com.owncloud.android.operations.common.SyncOperation;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* Tests related to file operations
|
||||
*/
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FileIT extends AbstractIT {
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.owncloud.android.utils.FileStorageUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests related to file uploads
|
||||
*/
|
||||
@@ -19,18 +21,45 @@ import org.junit.runner.RunWith;
|
||||
public class UploadIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
public void testSimpleUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/123.txt",
|
||||
"/testUpload/1.txt", account.name);
|
||||
public void testEmptyUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
"/testUpload/empty.txt", account.name);
|
||||
|
||||
RemoteOperationResult result = testUpload(ocUpload);
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonEmptyUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/nonEmpty.txt",
|
||||
"/testUpload/nonEmpty.txt", account.name);
|
||||
|
||||
RemoteOperationResult result = testUpload(ocUpload);
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChunkedUpload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/chunkedFile.txt",
|
||||
"/testUpload/chunkedFile.txt", account.name);
|
||||
|
||||
RemoteOperationResult result = testUpload(ocUpload);
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
}
|
||||
|
||||
public RemoteOperationResult testUpload(OCUpload ocUpload) {
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
context,
|
||||
false,
|
||||
false
|
||||
account,
|
||||
null,
|
||||
ocUpload,
|
||||
false,
|
||||
FileUploader.LOCAL_BEHAVIOUR_COPY,
|
||||
context,
|
||||
false,
|
||||
false
|
||||
);
|
||||
newUpload.addRenameUploadListener(() -> {
|
||||
// dummy
|
||||
@@ -38,13 +67,12 @@ public class UploadIT extends AbstractIT {
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
RemoteOperationResult result = newUpload.execute(client, getStorageManager());
|
||||
assertTrue(result.isSuccess());
|
||||
return newUpload.execute(client, getStorageManager());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadInNonExistingFolder() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/123.txt",
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + "/empty.txt",
|
||||
"/testUpload/2/3/4/1.txt", account.name);
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
account,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -77,7 +77,7 @@ public class OCFileUnitTest {
|
||||
mFile.setFileId(ID);
|
||||
mFile.setParentId(PARENT_ID);
|
||||
mFile.setStoragePath(STORAGE_PATH);
|
||||
mFile.setMimetype(MIME_TYPE);
|
||||
mFile.setMimeType(MIME_TYPE);
|
||||
mFile.setFileLength(FILE_LENGTH);
|
||||
mFile.setCreationTimestamp(CREATION_TIMESTAMP);
|
||||
mFile.setModificationTimestamp(MODIFICATION_TIMESTAMP);
|
||||
@@ -86,12 +86,12 @@ public class OCFileUnitTest {
|
||||
mFile.setLastSyncDateForData(LAST_SYNC_DATE_FOR_DATA);
|
||||
mFile.setAvailableOffline(true);
|
||||
mFile.setEtag(ETAG);
|
||||
mFile.setShareViaLink(true);
|
||||
mFile.setShareWithSharee(true);
|
||||
mFile.setSharedViaLink(true);
|
||||
mFile.setSharedWithSharee(true);
|
||||
mFile.setPublicLink(PUBLIC_LINK);
|
||||
mFile.setPermissions(PERMISSIONS);
|
||||
mFile.setRemoteId(REMOTE_ID);
|
||||
mFile.setNeedsUpdateThumbnail(true);
|
||||
mFile.setUpdateThumbnailNeeded(true);
|
||||
mFile.setDownloading(true);
|
||||
mFile.setEtagInConflict(ETAG_IN_CONFLICT);
|
||||
|
||||
@@ -126,9 +126,8 @@ public class OCFileUnitTest {
|
||||
assertThat(fileReadFromParcel.getPublicLink(), is(PUBLIC_LINK));
|
||||
assertThat(fileReadFromParcel.getPermissions(), is(PERMISSIONS));
|
||||
assertThat(fileReadFromParcel.getRemoteId(), is(REMOTE_ID));
|
||||
assertThat(fileReadFromParcel.needsUpdateThumbnail(), is(true));
|
||||
assertThat(fileReadFromParcel.isUpdateThumbnailNeeded(), is(true));
|
||||
assertThat(fileReadFromParcel.isDownloading(), is(true));
|
||||
assertThat(fileReadFromParcel.getEtagInConflict(), is(ETAG_IN_CONFLICT));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
Svobodná (copyleft) aplikace Nextcloud pro Android, poskytující mobilní svobodu.
|
||||
|
||||
Funkce:
|
||||
* Snadno použitelné moderní rozhraní, hodící se k vzhledu vašeho serveru
|
||||
* Nahrávání souborů na Nextcloud server
|
||||
* Jejich sdílení s ostatními
|
||||
* Synchronizace vašich oblíbených souborů a složek
|
||||
* Hledání napříč všemi složkami na serveru
|
||||
* Automatické nahrávání fotek a videí pořízených vaším zařízením
|
||||
* Doručování oznámení
|
||||
* Podpora vícero účtů
|
||||
* Zabezpečený přístup k vašim datům pomocí otisku prstu nebo PIN kódu
|
||||
* Začlenění DAVdroid pro snadný přístup ke kalendáři & synchronizaci kontaktů
|
||||
|
||||
Jakékoli problémy prosím hlaste na https://github.com/nextcloud/android/issues a o aplikaci diskutujte na https://help.nextcloud.com/c/clients/android
|
||||
|
||||
Ještě Nextcloud neznáte? Nextcloud je server pro soukromou synchronizaci souborů &, sdílení a komunikaci. Je to svobodný software a můžete ho buď provozovat sami nebo si pronajímat od nějaké společnosti. Tím vy vládnete svým fotkám, údajům v kalendáři a kontaktech, dokumentům a všemu ostatnímu.
|
||||
|
||||
Podívejte se na Nextcloud na https://nextcloud.com
|
||||
@@ -1 +1 @@
|
||||
Aplikace Nextcloud pro Android ti nabízí přístup ke všem souborům ve tvém Nextcl
|
||||
Aplikace Nextcloud pro Android poskytuje přístup ke všem souborům na vašem Nextc
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud Android programėlė suteikia jums mobiliąją prieigą prie jūsų visų Next
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -9,6 +9,6 @@ Funkcje:
|
||||
|
||||
Zgłaszaj błędy na https://github.com/nextcloud/android/issues i dyskutuj na temat tej aplikacji na https://help.nextcloud.com/c/clients/android
|
||||
|
||||
Nie znasz jeszcze Nextcloud? Nextcloud jest prywatnym serwerem synchronizacji & współdzielenia plików oraz komunikacji. Jego źródła są całkowicie otwarte, więc możesz korzystać z niego na własnym serwerze albo możesz zapłacić za to firmie trzeciej. W ten sposób kontrolujesz swoje zdjęcia, kalendarz, dane kontaktowe, twoje dokumenty i inne dane.
|
||||
Nie znasz jeszcze Nextcloud? Nextcloud jest prywatnym serwerem synchronizacji współdzielenia plików oraz komunikacji. Jego źródła są całkowicie otwarte, więc możesz korzystać z niego na własnym serwerze albo możesz zapłacić za to firmie trzeciej. W ten sposób kontrolujesz swoje zdjęcia, kalendarz, dane kontaktowe, twoje dokumenty i inne dane.
|
||||
|
||||
Zobacz Nextcloud na https://nextcloud.com
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud Android-appen ger mobilåtkomst till alla filer på ditt Nextcloud.
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -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);
|
||||
|
||||
@@ -395,19 +395,11 @@ public final class PushUtils {
|
||||
PreferenceManager.setKeysMigration(context, true);
|
||||
} else {
|
||||
if (oldPrivateKeyFile.exists()) {
|
||||
try {
|
||||
FileStorageUtils.moveFile(oldPrivateKeyFile, privateKeyFile);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to move old private key to new location");
|
||||
}
|
||||
FileStorageUtils.moveFile(oldPrivateKeyFile, privateKeyFile);
|
||||
}
|
||||
|
||||
if (oldPublicKeyFile.exists()) {
|
||||
try {
|
||||
FileStorageUtils.moveFile(oldPublicKeyFile, publicKeyFile);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to move old public key to new location");
|
||||
}
|
||||
FileStorageUtils.moveFile(oldPublicKeyFile, publicKeyFile);
|
||||
}
|
||||
|
||||
if (privateKeyFile.exists() && publicKeyFile.exists()) {
|
||||
|
||||
@@ -65,6 +65,9 @@
|
||||
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<!-- Apps that target Android 9 (API level 28) or higher and use foreground services
|
||||
must request the FOREGROUND_SERVICE permission -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
||||
|
||||
|
||||
<application
|
||||
@@ -106,10 +109,13 @@
|
||||
<activity android:name=".ui.activity.UploadFilesActivity" />
|
||||
<activity android:name=".ui.activity.ExternalSiteWebView"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden" />
|
||||
<activity
|
||||
android:name=".ui.activity.RichDocumentsWebView"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"/>
|
||||
<activity android:name=".ui.activity.ContactsPreferenceActivity"
|
||||
android:launchMode="singleInstance"/>
|
||||
<activity android:name=".ui.activity.ReceiveExternalFilesActivity"
|
||||
|
||||
|
||||
android:taskAffinity=""
|
||||
android:excludeFromRecents="true"
|
||||
android:theme="@style/Theme.ownCloud.NoActionBar">
|
||||
@@ -242,10 +248,12 @@
|
||||
<service android:name=".media.MediaService" />
|
||||
|
||||
<activity android:name=".ui.activity.PassCodeActivity" />
|
||||
<activity android:name=".ui.activity.RequestCredentialsActivity" />
|
||||
<activity
|
||||
android:name=".ui.activity.RequestCredentialsActivity"
|
||||
android:launchMode="singleTask" />
|
||||
<activity android:name=".ui.activity.ConflictsResolveActivity"/>
|
||||
<activity android:name=".ui.activity.ErrorsWhileCopyingHandlerActivity"/>
|
||||
|
||||
|
||||
<activity android:name=".ui.activity.LogHistoryActivity"/>
|
||||
|
||||
<activity android:name=".ui.errorhandling.ErrorShowActivity" />
|
||||
@@ -277,6 +285,12 @@
|
||||
<activity
|
||||
android:name=".ui.activity.FolderPickerActivity"
|
||||
android:label="@string/app_name" />
|
||||
<activity
|
||||
android:name=".ui.activity.FilePickerActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustResize"/>
|
||||
<activity
|
||||
android:name=".ui.activity.UploadPathActivity"
|
||||
android:label="@string/app_name" />
|
||||
|
||||
@@ -49,10 +49,12 @@ import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
@@ -111,7 +113,7 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
NextcloudRequest request = deserializeObjectAndCloseStream(is);
|
||||
httpStream = processRequest(request);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
Log_OC.e(TAG, "Error during Nextcloud request", e);
|
||||
exception = e;
|
||||
}
|
||||
|
||||
@@ -121,7 +123,7 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
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());
|
||||
Log_OC.e(TAG, "Error while sending response back to client app", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -213,7 +215,20 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
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)));
|
||||
StringBuilder total = new StringBuilder();
|
||||
InputStream inputStream = method.getResponseBodyAsStream();
|
||||
// If response body is available
|
||||
if (inputStream != null) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String line = reader.readLine();
|
||||
while (line != null) {
|
||||
total.append(line).append('\n');
|
||||
line = reader.readLine();
|
||||
}
|
||||
Log_OC.e(TAG, total.toString());
|
||||
}
|
||||
throw new IllegalStateException(EXCEPTION_HTTP_REQUEST_FAILED,
|
||||
new IllegalStateException(String.valueOf(status), new Throwable(total.toString())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,6 +242,10 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
}
|
||||
|
||||
private boolean validateToken(String hash, String token) {
|
||||
if (hash.isEmpty() || !hash.contains("$")) {
|
||||
throw new IllegalStateException(EXCEPTION_INVALID_TOKEN);
|
||||
}
|
||||
|
||||
String salt = hash.split("\\$")[1]; // TODO extract "$"
|
||||
|
||||
String newHash = EncryptionUtils.generateSHA512(token, salt);
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
* @author masensio
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -95,6 +95,7 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER
|
||||
public class MainApp extends MultiDexApplication {
|
||||
|
||||
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = OwnCloudVersion.nextcloud_12;
|
||||
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_10;
|
||||
|
||||
private static final String TAG = MainApp.class.getSimpleName();
|
||||
|
||||
@@ -387,7 +388,7 @@ public class MainApp extends MultiDexApplication {
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Context getAppContext() {
|
||||
return MainApp.mContext;
|
||||
@@ -405,9 +406,9 @@ public class MainApp extends MultiDexApplication {
|
||||
MainApp.storagePath = path;
|
||||
}
|
||||
|
||||
// Methods to obtain Strings referring app_name
|
||||
// From AccountAuthenticator
|
||||
// public static final String ACCOUNT_TYPE = "owncloud";
|
||||
// Methods to obtain Strings referring app_name
|
||||
// From AccountAuthenticator
|
||||
// public static final String ACCOUNT_TYPE = "owncloud";
|
||||
public static String getAccountType(Context context) {
|
||||
return context.getResources().getString(R.string.account_type);
|
||||
}
|
||||
@@ -446,7 +447,7 @@ public class MainApp extends MultiDexApplication {
|
||||
return getAppContext().getResources().getString(R.string.authority);
|
||||
}
|
||||
|
||||
// From ProviderMeta
|
||||
// From ProviderMeta
|
||||
// public static final String DB_FILE = "owncloud.db";
|
||||
public static String getDBFile() {
|
||||
return getAppContext().getResources().getString(R.string.db_file);
|
||||
|
||||
@@ -50,10 +50,10 @@ public final class AccountUtils {
|
||||
/**
|
||||
* Can be used to get the currently selected ownCloud {@link Account} in the
|
||||
* application preferences.
|
||||
*
|
||||
*
|
||||
* @param context The current application {@link Context}
|
||||
* @return The ownCloud {@link Account} currently saved in preferences, or the first
|
||||
* {@link Account} available, if valid (still registered in the system as ownCloud
|
||||
* @return The ownCloud {@link Account} currently saved in preferences, or the first
|
||||
* {@link Account} available, if valid (still registered in the system as ownCloud
|
||||
* account). If none is available and valid, returns null.
|
||||
*/
|
||||
public static @Nullable Account getCurrentOwnCloudAccount(Context context) {
|
||||
@@ -96,7 +96,7 @@ public final class AccountUtils {
|
||||
return accountManager.getAccountsByType(MainApp.getAccountType(context));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean exists(Account account, Context context) {
|
||||
Account[] ocAccounts = getAccounts(context);
|
||||
|
||||
@@ -132,7 +132,7 @@ public final class AccountUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns owncloud account identified by accountName or null if it does not exist.
|
||||
* @param context the context
|
||||
@@ -176,20 +176,23 @@ public final class AccountUtils {
|
||||
/**
|
||||
* Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
|
||||
*
|
||||
* @param account ownCloud account
|
||||
* @return Version of the OC server corresponding to account, according to the data saved
|
||||
* in the system AccountManager
|
||||
* @param account ownCloud account
|
||||
* @return Version of the OC server corresponding to account, according to the data saved
|
||||
* in the system AccountManager
|
||||
*/
|
||||
public static @NonNull
|
||||
OwnCloudVersion getServerVersion(Account account) {
|
||||
OwnCloudVersion serverVersion = OwnCloudVersion.nextcloud_10;
|
||||
OwnCloudVersion serverVersion = MainApp.MINIMUM_SUPPORTED_SERVER_VERSION;
|
||||
|
||||
if (account != null) {
|
||||
AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());
|
||||
String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);
|
||||
|
||||
if (serverVersionStr != null) {
|
||||
serverVersion = new OwnCloudVersion(serverVersionStr);
|
||||
}
|
||||
}
|
||||
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
private AccountManager mAccountMgr;
|
||||
private Uri mNewCapturedUriFromOAuth2Redirection;
|
||||
|
||||
/// Server PRE-Fragment elements
|
||||
/// Server PRE-Fragment elements
|
||||
private CustomEditText mHostUrlInput;
|
||||
private View mRefreshButton;
|
||||
private TextView mServerStatusView;
|
||||
@@ -217,7 +217,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private GetServerInfoOperation.ServerInfo mServerInfo = new GetServerInfoOperation.ServerInfo();
|
||||
|
||||
/// Authentication PRE-Fragment elements
|
||||
/// Authentication PRE-Fragment elements
|
||||
private CheckBox mOAuth2Check;
|
||||
private TextView mOAuthAuthEndpointText;
|
||||
private TextView mOAuthTokenEndpointText;
|
||||
@@ -237,7 +237,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private boolean mIsFirstAuthAttempt;
|
||||
|
||||
/// Identifier of operation in progress which result shouldn't be lost
|
||||
/// Identifier of operation in progress which result shouldn't be lost
|
||||
private long mWaitingForOpId = Long.MAX_VALUE;
|
||||
|
||||
private String basicTokenType;
|
||||
@@ -264,7 +264,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (savedInstanceState == null) {
|
||||
FirstRunActivity.runIfNeeded(this);
|
||||
}
|
||||
|
||||
|
||||
basicTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType(this));
|
||||
oauthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType(this));
|
||||
samlTokenType = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType(this));
|
||||
@@ -379,7 +379,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
mLoginWebView.getSettings().setAllowFileAccess(false);
|
||||
mLoginWebView.getSettings().setJavaScriptEnabled(true);
|
||||
mLoginWebView.getSettings().setDomStorageEnabled(true);
|
||||
|
||||
|
||||
if (useGenericUserAgent) {
|
||||
mLoginWebView.getSettings().setUserAgentString(MainApp.getNextcloudUserAgent());
|
||||
} else {
|
||||
@@ -587,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 {
|
||||
@@ -1341,7 +1339,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
uri = uriBuilder.build();
|
||||
Log_OC.d(TAG, "Starting browser to view " + uri.toString());
|
||||
Intent i = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(i);
|
||||
|
||||
DisplayUtils.startIntentIfAppAvailable(i, this, R.string.no_browser_available);
|
||||
}
|
||||
|
||||
|
||||
@@ -1373,7 +1372,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (operation instanceof GetServerInfoOperation) {
|
||||
if (operation.hashCode() == mWaitingForOpId) {
|
||||
onGetServerInfoFinish(result);
|
||||
} // else nothing ; only the last check operation is considered;
|
||||
} // else nothing ; only the last check operation is considered;
|
||||
// multiple can be started if the user amends a URL quickly
|
||||
|
||||
} else if (operation instanceof OAuth2GetAccessToken) {
|
||||
@@ -1458,7 +1457,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
// 1. connection succeeded, and we know if it's SSL or not
|
||||
// 2. server is installed
|
||||
// 3. we got the server version
|
||||
// 4. we got the authentication method required by the server
|
||||
// 4. we got the authentication method required by the server
|
||||
mServerInfo = (GetServerInfoOperation.ServerInfo) (result.getData().get(0));
|
||||
|
||||
// show outdated warning
|
||||
@@ -1525,13 +1524,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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1782,7 +1777,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
} else if (result.isServerFail() || result.isException()) {
|
||||
/// server errors or exceptions in authorization take to requiring a new check of
|
||||
/// server errors or exceptions in authorization take to requiring a new check of
|
||||
/// the server
|
||||
mServerIsChecked = true;
|
||||
mServerIsValid = false;
|
||||
@@ -1843,13 +1838,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
if (AccountTypeUtils.getAuthTokenTypeAccessToken(accountType).equals(mAuthTokenType)) {
|
||||
response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);
|
||||
// the next line is necessary, notifications are calling directly to the
|
||||
// the next line is necessary, notifications are calling directly to the
|
||||
// AuthenticatorActivity to update, without AccountManager intervention
|
||||
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
|
||||
|
||||
} else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(accountType).equals(mAuthTokenType)) {
|
||||
response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);
|
||||
// the next line is necessary; by now, notifications are calling directly to the
|
||||
// the next line is necessary; by now, notifications are calling directly to the
|
||||
// AuthenticatorActivity to update, without AccountManager intervention
|
||||
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
|
||||
|
||||
@@ -1944,7 +1939,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
/// prepare result to return to the Authenticator
|
||||
// TODO check again what the Authenticator makes with it; probably has the same
|
||||
// TODO check again what the Authenticator makes with it; probably has the same
|
||||
// effect as addAccountExplicitly, but it's not well done
|
||||
final Intent intent = new Intent();
|
||||
intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
|
||||
@@ -1953,7 +1948,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
if (isOAuth || isSaml) {
|
||||
mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
|
||||
}
|
||||
/// add user data to the new account; TODO probably can be done in the last parameter
|
||||
/// add user data to the new account; TODO probably can be done in the last parameter
|
||||
// addAccountExplicitly, or in KEY_USERDATA
|
||||
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mServerInfo.mVersion.getVersion());
|
||||
mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mServerInfo.mBaseUrl);
|
||||
@@ -2059,7 +2054,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
/**
|
||||
* Called when the 'action' button in an IME is pressed ('enter' in software keyboard).
|
||||
*
|
||||
*
|
||||
* Used to trigger the authentication check when the user presses 'enter' after writing the
|
||||
* password, or to throw the server test when the only field on screen is the URL input field.
|
||||
*/
|
||||
@@ -2198,7 +2193,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
public void onSavedCertificate() {
|
||||
Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);
|
||||
if (fd == null) {
|
||||
// if SAML dialog is not shown,
|
||||
// if SAML dialog is not shown,
|
||||
// the SslDialog was shown due to an SSL error in the server check
|
||||
checkOcServer();
|
||||
}
|
||||
@@ -2222,7 +2217,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);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio on 09/02/2015.
|
||||
@@ -43,11 +43,11 @@ public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOpera
|
||||
private static final String REMOTE_PATH = "/";
|
||||
private static final boolean SUCCESS_IF_ABSENT = false;
|
||||
|
||||
private Context mContext;
|
||||
private WeakReference<Context> mWeakContext;
|
||||
private final WeakReference<OnAuthenticatorTaskListener> mListener;
|
||||
|
||||
public AuthenticatorAsyncTask(Activity activity) {
|
||||
mContext = activity.getApplicationContext();
|
||||
mWeakContext = new WeakReference<>(activity.getApplicationContext());
|
||||
mListener = new WeakReference<>((OnAuthenticatorTaskListener)activity);
|
||||
}
|
||||
|
||||
@@ -55,21 +55,18 @@ public class AuthenticatorAsyncTask extends AsyncTask<Object, Void, RemoteOpera
|
||||
protected RemoteOperationResult doInBackground(Object... params) {
|
||||
|
||||
RemoteOperationResult result;
|
||||
if (params!= null && params.length==2) {
|
||||
if (params != null && params.length == 2 && mWeakContext.get() != null) {
|
||||
String url = (String)params[0];
|
||||
Context context = mWeakContext.get();
|
||||
OwnCloudCredentials credentials = (OwnCloudCredentials)params[1];
|
||||
|
||||
// Client
|
||||
Uri uri = Uri.parse(url);
|
||||
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(uri, mContext, true);
|
||||
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(uri, context, true);
|
||||
client.setCredentials(credentials);
|
||||
|
||||
// Operation - try credentials
|
||||
ExistenceCheckRemoteOperation operation = new ExistenceCheckRemoteOperation(
|
||||
REMOTE_PATH,
|
||||
mContext,
|
||||
SUCCESS_IF_ABSENT
|
||||
);
|
||||
ExistenceCheckRemoteOperation operation = new ExistenceCheckRemoteOperation(REMOTE_PATH, SUCCESS_IF_ABSENT);
|
||||
result = operation.execute(client);
|
||||
|
||||
if (operation.wasRedirected()) {
|
||||
|
||||
@@ -50,12 +50,11 @@ public final class PassCodeManager {
|
||||
// other activities may be exempted, if needed
|
||||
}
|
||||
|
||||
private static final int PASS_CODE_TIMEOUT = 1000;
|
||||
private static final int PASS_CODE_TIMEOUT = 5000;
|
||||
// keeping a "low" positive value is the easiest way to prevent the pass code is requested on rotations
|
||||
|
||||
private static PassCodeManager passCodeManagerInstance;
|
||||
|
||||
private Long timestamp = 0L;
|
||||
private int visibleActivitiesCounter;
|
||||
|
||||
public static PassCodeManager getPassCodeManager() {
|
||||
@@ -79,7 +78,8 @@ public final class PassCodeManager {
|
||||
}
|
||||
|
||||
public void onActivityStarted(Activity activity) {
|
||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) && passCodeShouldBeRequested()) {
|
||||
Long timestamp = PreferenceManager.getLockTimestamp(activity);
|
||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) && passCodeShouldBeRequested(timestamp)) {
|
||||
|
||||
Intent i = new Intent(MainApp.getAppContext(), PassCodeActivity.class);
|
||||
i.setAction(PassCodeActivity.ACTION_CHECK);
|
||||
@@ -88,8 +88,7 @@ public final class PassCodeManager {
|
||||
}
|
||||
|
||||
if (!exemptOfPasscodeActivities.contains(activity.getClass()) &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && deviceCredentialsShouldBeRequested(activity) &&
|
||||
!DeviceCredentialUtils.tryEncrypt(activity)) {
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && deviceCredentialsShouldBeRequested(timestamp, activity)) {
|
||||
Intent i = new Intent(MainApp.getAppContext(), RequestCredentialsActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
activity.startActivityForResult(i, PASSCODE_ACTIVITY);
|
||||
@@ -102,7 +101,7 @@ public final class PassCodeManager {
|
||||
if (visibleActivitiesCounter > 0) {
|
||||
visibleActivitiesCounter--;
|
||||
}
|
||||
setUnlockTimestamp();
|
||||
setUnlockTimestamp(activity);
|
||||
PowerManager powerMgr = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
|
||||
if ((passCodeIsEnabled() || deviceCredentialsAreEnabled(activity)) && powerMgr != null
|
||||
&& !powerMgr.isScreenOn()) {
|
||||
@@ -110,22 +109,23 @@ public final class PassCodeManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void setUnlockTimestamp() {
|
||||
timestamp = System.currentTimeMillis();
|
||||
private void setUnlockTimestamp(Activity activity) {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
PreferenceManager.setLockTimestamp(activity, timestamp);
|
||||
}
|
||||
|
||||
private boolean passCodeShouldBeRequested() {
|
||||
private boolean passCodeShouldBeRequested(Long timestamp) {
|
||||
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT &&
|
||||
visibleActivitiesCounter <= 0 && passCodeIsEnabled();
|
||||
visibleActivitiesCounter <= 0 && passCodeIsEnabled();
|
||||
}
|
||||
|
||||
private boolean passCodeIsEnabled() {
|
||||
return PreferenceManager.getLockPreference(MainApp.getAppContext()).equals(Preferences.LOCK_PASSCODE);
|
||||
}
|
||||
|
||||
private boolean deviceCredentialsShouldBeRequested(Activity activity) {
|
||||
private boolean deviceCredentialsShouldBeRequested(Long timestamp, Activity activity) {
|
||||
return (System.currentTimeMillis() - timestamp) > PASS_CODE_TIMEOUT && visibleActivitiesCounter <= 0 &&
|
||||
deviceCredentialsAreEnabled(activity);
|
||||
deviceCredentialsAreEnabled(activity);
|
||||
}
|
||||
|
||||
private boolean deviceCredentialsAreEnabled(Activity activity) {
|
||||
|
||||
@@ -24,9 +24,16 @@ package com.owncloud.android.datamodel;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Decrypted class representation of metadata json of folder metadata.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class DecryptedFolderMetadata {
|
||||
private Metadata metadata;
|
||||
private Map<String, DecryptedFile> files;
|
||||
@@ -36,170 +43,47 @@ public class DecryptedFolderMetadata {
|
||||
this.files = new HashMap<>();
|
||||
}
|
||||
|
||||
public DecryptedFolderMetadata(Metadata metadata, Map<String, DecryptedFile> files) {
|
||||
this.metadata = metadata;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(Metadata metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public Map<String, DecryptedFile> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
public void setFiles(Map<String, DecryptedFile> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Metadata {
|
||||
private Map<Integer, String> metadataKeys; // each keys is encrypted on its own, decrypt on use
|
||||
private Sharing sharing;
|
||||
private int version;
|
||||
|
||||
public Map<Integer, String> getMetadataKeys() {
|
||||
return metadataKeys;
|
||||
}
|
||||
|
||||
public void setMetadataKeys(Map<Integer, String> metadataKeys) {
|
||||
this.metadataKeys = metadataKeys;
|
||||
}
|
||||
|
||||
public Sharing getSharing() {
|
||||
return sharing;
|
||||
}
|
||||
|
||||
public void setSharing(Sharing sharing) {
|
||||
this.sharing = sharing;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(version);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Encrypted {
|
||||
private Map<Integer, String> metadataKeys;
|
||||
|
||||
public Map<Integer, String> getMetadataKeys() {
|
||||
return metadataKeys;
|
||||
}
|
||||
|
||||
public void setMetadataKeys(Map<Integer, String> metadataKeys) {
|
||||
this.metadataKeys = metadataKeys;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Sharing {
|
||||
private Map<String, String> recipient;
|
||||
private String signature;
|
||||
|
||||
public Map<String, String> getRecipient() {
|
||||
return recipient;
|
||||
}
|
||||
|
||||
public void setRecipient(Map<String, String> recipient) {
|
||||
this.recipient = recipient;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class DecryptedFile {
|
||||
private Data encrypted;
|
||||
private String initializationVector;
|
||||
private String authenticationTag;
|
||||
private int metadataKey;
|
||||
|
||||
public Data getEncrypted() {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(Data encrypted) {
|
||||
this.encrypted = encrypted;
|
||||
}
|
||||
|
||||
public String getInitializationVector() {
|
||||
return initializationVector;
|
||||
}
|
||||
|
||||
public void setInitializationVector(String initializationVector) {
|
||||
this.initializationVector = initializationVector;
|
||||
}
|
||||
|
||||
public String getAuthenticationTag() {
|
||||
return authenticationTag;
|
||||
}
|
||||
|
||||
public void setAuthenticationTag(String authenticationTag) {
|
||||
this.authenticationTag = authenticationTag;
|
||||
}
|
||||
|
||||
public int getMetadataKey() {
|
||||
return metadataKey;
|
||||
}
|
||||
|
||||
public void setMetadataKey(int metadataKey) {
|
||||
this.metadataKey = metadataKey;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Data {
|
||||
private String key;
|
||||
private String filename;
|
||||
private String mimetype;
|
||||
private int version;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getMimetype() {
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
public void setMimetype(String mimetype) {
|
||||
this.mimetype = mimetype;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,54 +22,19 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
@Parcel public class DecryptedPushMessage {
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Parcel
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DecryptedPushMessage {
|
||||
public String app;
|
||||
|
||||
public String type;
|
||||
|
||||
public String subject;
|
||||
|
||||
public String id;
|
||||
|
||||
public DecryptedPushMessage(String app, String type, String subject, String id) {
|
||||
this.app = app;
|
||||
this.type = type;
|
||||
this.subject = subject;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DecryptedPushMessage() {
|
||||
}
|
||||
|
||||
public String getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public void setApp(String app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -23,71 +23,26 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Encrypted class representation of metadata json of folder metadata
|
||||
*/
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class EncryptedFolderMetadata {
|
||||
private DecryptedFolderMetadata.Metadata metadata;
|
||||
private Map<String, EncryptedFile> files;
|
||||
|
||||
public EncryptedFolderMetadata(DecryptedFolderMetadata.Metadata metadata, Map<String, EncryptedFile> files) {
|
||||
this.metadata = metadata;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public DecryptedFolderMetadata.Metadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(DecryptedFolderMetadata.Metadata metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public Map<String, EncryptedFile> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
public void setFiles(Map<String, EncryptedFile> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class EncryptedFile {
|
||||
private String encrypted;
|
||||
private String initializationVector;
|
||||
private String authenticationTag;
|
||||
private int metadataKey;
|
||||
|
||||
public String getEncrypted() {
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(String encrypted) {
|
||||
this.encrypted = encrypted;
|
||||
}
|
||||
|
||||
public String getInitializationVector() {
|
||||
return initializationVector;
|
||||
}
|
||||
|
||||
public void setInitializationVector(String initializationVector) {
|
||||
this.initializationVector = initializationVector;
|
||||
}
|
||||
|
||||
public String getAuthenticationTag() {
|
||||
return authenticationTag;
|
||||
}
|
||||
|
||||
public void setAuthenticationTag(String authenticationTag) {
|
||||
this.authenticationTag = authenticationTag;
|
||||
}
|
||||
|
||||
public int getMetadataKey() {
|
||||
return metadataKey;
|
||||
}
|
||||
|
||||
public void setMetadataKey(int metadataKey) {
|
||||
this.metadataKey = metadataKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2012 Bartek Przybylski
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -34,6 +34,7 @@ import android.net.Uri;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
|
||||
@@ -53,6 +54,7 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -61,51 +63,36 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
public class FileDataStorageManager {
|
||||
private static final String TAG = FileDataStorageManager.class.getSimpleName();
|
||||
|
||||
public static final int ROOT_PARENT_ID = 0;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
private ContentProviderClient mContentProviderClient;
|
||||
private Account mAccount;
|
||||
private static final String AND = "=? AND ";
|
||||
private static final String FAILED_TO_INSERT_MSG = "Fail to insert insert file to database ";
|
||||
private static final String SENDING_TO_FILECONTENTPROVIDER_MSG = "Sending %d operations to FileContentProvider";
|
||||
private static final String EXCEPTION_MSG = "Exception in batch of operations ";
|
||||
|
||||
private static final String TAG = FileDataStorageManager.class.getSimpleName();
|
||||
public static final int ROOT_PARENT_ID = 0;
|
||||
|
||||
private ContentResolver contentResolver;
|
||||
private ContentProviderClient contentProviderClient;
|
||||
@Setter private Account account;
|
||||
|
||||
public FileDataStorageManager(Account account, ContentResolver cr) {
|
||||
mContentProviderClient = null;
|
||||
mContentResolver = cr;
|
||||
mAccount = account;
|
||||
contentProviderClient = null;
|
||||
contentResolver = cr;
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public FileDataStorageManager(Account account, ContentProviderClient cp) {
|
||||
mContentProviderClient = cp;
|
||||
mContentResolver = null;
|
||||
mAccount = account;
|
||||
contentProviderClient = cp;
|
||||
contentResolver = null;
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
|
||||
public void setAccount(Account account) {
|
||||
mAccount = account;
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
return mAccount;
|
||||
}
|
||||
|
||||
public ContentResolver getContentResolver() {
|
||||
return mContentResolver;
|
||||
}
|
||||
|
||||
public ContentProviderClient getContentProviderClient() {
|
||||
return mContentProviderClient;
|
||||
}
|
||||
|
||||
|
||||
public OCFile getFileByPath(String path) {
|
||||
Cursor c = getFileCursorForValue(ProviderTableMeta.FILE_PATH, path);
|
||||
OCFile file = null;
|
||||
@@ -119,7 +106,6 @@ public class FileDataStorageManager {
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
public @Nullable
|
||||
OCFile getFileById(long id) {
|
||||
Cursor c = getFileCursorForValue(ProviderTableMeta._ID, String.valueOf(id));
|
||||
@@ -130,7 +116,7 @@ public class FileDataStorageManager {
|
||||
c.close();
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
public OCFile getFileByLocalPath(String path) {
|
||||
Cursor c = getFileCursorForValue(ProviderTableMeta.FILE_STORAGE_PATH, path);
|
||||
OCFile file = null;
|
||||
@@ -172,7 +158,7 @@ public class FileDataStorageManager {
|
||||
|
||||
public List<OCFile> getFolderImages(OCFile folder, boolean onlyOnDevice) {
|
||||
List<OCFile> ret = new ArrayList<>();
|
||||
|
||||
|
||||
if (folder != null) {
|
||||
// TODO better implementation, filtering in the access to database instead of here
|
||||
List<OCFile> tmp = getFolderContent(folder, onlyOnDevice);
|
||||
@@ -205,7 +191,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, file.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isAvailableOffline() ? 1 : 0);
|
||||
@@ -215,7 +201,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded());
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
|
||||
|
||||
@@ -362,13 +348,13 @@ public class FileDataStorageManager {
|
||||
String[] whereArgs;
|
||||
for (OCFile file : filesToRemove) {
|
||||
if (file.getParentId() == folder.getFileId()) {
|
||||
whereArgs = new String[]{mAccount.name, file.getRemotePath()};
|
||||
whereArgs = new String[]{account.name, file.getRemotePath()};
|
||||
if (file.isFolder()) {
|
||||
operations.add(ContentProviderOperation.newDelete(
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, file.getFileId()))
|
||||
.withSelection(where, whereArgs).build());
|
||||
|
||||
File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
|
||||
File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(account.name, file));
|
||||
if (localFolder.exists()) {
|
||||
removeLocalFolder(localFolder);
|
||||
}
|
||||
@@ -445,7 +431,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_NAME, folder.getFileName());
|
||||
cv.put(ProviderTableMeta.FILE_PARENT, folder.getParentId());
|
||||
cv.put(ProviderTableMeta.FILE_PATH, folder.getRemotePath());
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, folder.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, folder.isAvailableOffline() ? 1 : 0);
|
||||
@@ -455,7 +441,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, folder.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, folder.getIsFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, folder.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, folder.isEncrypted());
|
||||
return cv;
|
||||
}
|
||||
@@ -474,7 +460,7 @@ public class FileDataStorageManager {
|
||||
if (!file.isFolder()) {
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
||||
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isAvailableOffline() ? 1 : 0);
|
||||
@@ -484,12 +470,13 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.isUpdateThumbnailNeeded());
|
||||
cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading());
|
||||
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.getIsFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_IS_ENCRYPTED, file.isEncrypted());
|
||||
cv.put(ProviderTableMeta.FILE_MOUNT_TYPE, file.getMountType().ordinal());
|
||||
cv.put(ProviderTableMeta.FILE_HAS_PREVIEW, file.isPreviewAvailable() ? 1 : 0);
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -505,7 +492,7 @@ public class FileDataStorageManager {
|
||||
// ""+file.getFileId());
|
||||
Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, file.getFileId());
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, file.getRemotePath()};
|
||||
String[] whereArgs = new String[]{account.name, file.getRemotePath()};
|
||||
int deleted = 0;
|
||||
if (getContentProviderClient() != null) {
|
||||
try {
|
||||
@@ -557,10 +544,10 @@ public class FileDataStorageManager {
|
||||
}
|
||||
|
||||
private boolean removeFolderInDb(OCFile folder) {
|
||||
Uri folder_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, "" + folder.getFileId()); // URI
|
||||
Uri folder_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(folder.getFileId())); // URI
|
||||
// for recursive deletion
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, folder.getRemotePath()};
|
||||
String[] whereArgs = new String[]{account.name, folder.getRemotePath()};
|
||||
int deleted = 0;
|
||||
if (getContentProviderClient() != null) {
|
||||
try {
|
||||
@@ -576,7 +563,7 @@ public class FileDataStorageManager {
|
||||
|
||||
private boolean removeLocalFolder(OCFile folder) {
|
||||
boolean success = true;
|
||||
String localFolderPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, folder);
|
||||
String localFolderPath = FileStorageUtils.getDefaultSavePathFor(account.name, folder);
|
||||
File localFolder = new File(localFolderPath);
|
||||
if (localFolder.exists()) {
|
||||
// stage 1: remove the local files already registered in the files database
|
||||
@@ -600,7 +587,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
// stage 2: remove the folder itself and any local file inside out of sync;
|
||||
// stage 2: remove the folder itself and any local file inside out of sync;
|
||||
// for instance, after clearing the app cache or reinstalling
|
||||
success &= removeLocalFolder(localFolder);
|
||||
}
|
||||
@@ -646,7 +633,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
||||
new String[]{mAccount.name, file.getRemotePath() + "%"},
|
||||
new String[]{account.name, file.getRemotePath() + "%"},
|
||||
ProviderTableMeta.FILE_PATH + " ASC "
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
@@ -658,14 +645,14 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
||||
new String[]{mAccount.name, file.getRemotePath() + "%"},
|
||||
new String[]{account.name, file.getRemotePath() + "%"},
|
||||
ProviderTableMeta.FILE_PATH + " ASC "
|
||||
);
|
||||
}
|
||||
|
||||
/// 2. prepare a batch of update operations to change all the descendants
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>(c.getCount());
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(account.name);
|
||||
List<String> originalPathsToTriggerMediaScan = new ArrayList<String>();
|
||||
List<String> newPathsToTriggerMediaScan = new ArrayList<String>();
|
||||
if (c.moveToFirst()) {
|
||||
@@ -717,8 +704,8 @@ public class FileDataStorageManager {
|
||||
Log_OC.e(TAG, "Fail to update " + file.getFileId() + " and descendants in database", e);
|
||||
}
|
||||
|
||||
/// 4. move in local file system
|
||||
String originalLocalPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file);
|
||||
/// 4. move in local file system
|
||||
String originalLocalPath = FileStorageUtils.getDefaultSavePathFor(account.name, file);
|
||||
String targetLocalPath = defaultSavePath + targetPath;
|
||||
File localFile = new File(originalLocalPath);
|
||||
boolean renamed = false;
|
||||
@@ -750,10 +737,10 @@ public class FileDataStorageManager {
|
||||
public void copyLocalFile(OCFile file, String targetPath) {
|
||||
|
||||
if (file != null && file.fileExists() && !OCFile.ROOT_PATH.equals(file.getFileName())) {
|
||||
String localPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file);
|
||||
String localPath = FileStorageUtils.getDefaultSavePathFor(account.name, file);
|
||||
File localFile = new File(localPath);
|
||||
boolean copied = false;
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name);
|
||||
String defaultSavePath = FileStorageUtils.getSavePath(account.name);
|
||||
if (localFile.exists()) {
|
||||
File targetFile = new File(defaultSavePath + targetPath);
|
||||
File targetFolder = targetFile.getParentFile();
|
||||
@@ -859,7 +846,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
|
||||
|
||||
c.close();
|
||||
}
|
||||
|
||||
@@ -869,7 +856,7 @@ public class FileDataStorageManager {
|
||||
|
||||
private OCFile createRootDir() {
|
||||
OCFile file = new OCFile(OCFile.ROOT_PATH);
|
||||
file.setMimetype(MimeType.DIRECTORY);
|
||||
file.setMimeType(MimeType.DIRECTORY);
|
||||
file.setParentId(FileDataStorageManager.ROOT_PARENT_ID);
|
||||
saveFile(file);
|
||||
return file;
|
||||
@@ -884,7 +871,7 @@ public class FileDataStorageManager {
|
||||
cmp_key + AND
|
||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||
+ "=?",
|
||||
new String[]{value, mAccount.name}, null);
|
||||
new String[]{value, account.name}, null);
|
||||
} else {
|
||||
try {
|
||||
c = getContentProviderClient().query(
|
||||
@@ -892,7 +879,7 @@ public class FileDataStorageManager {
|
||||
null,
|
||||
cmp_key + AND
|
||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
|
||||
new String[]{value, mAccount.name}, null);
|
||||
new String[]{value, account.name}, null);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Couldn't determine file existance, assuming non existance: " + e.getMessage(), e);
|
||||
return false;
|
||||
@@ -912,14 +899,14 @@ public class FileDataStorageManager {
|
||||
key + AND
|
||||
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||
+ "=?",
|
||||
new String[]{value, mAccount.name}, null);
|
||||
new String[]{value, account.name}, null);
|
||||
} else {
|
||||
try {
|
||||
c = getContentProviderClient().query(
|
||||
ProviderTableMeta.CONTENT_URI,
|
||||
null,
|
||||
key + AND + ProviderTableMeta.FILE_ACCOUNT_OWNER
|
||||
+ "=?", new String[]{value, mAccount.name},
|
||||
+ "=?", new String[]{value, account.name},
|
||||
null);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Could not get file details: " + e.getMessage(), e);
|
||||
@@ -947,13 +934,13 @@ public class FileDataStorageManager {
|
||||
file.setFileId(c.getLong(c.getColumnIndex(ProviderTableMeta._ID)));
|
||||
file.setParentId(c.getLong(c.getColumnIndex(ProviderTableMeta.FILE_PARENT)));
|
||||
file.setEncryptedFileName(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ENCRYPTED_NAME)));
|
||||
file.setMimetype(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)));
|
||||
file.setMimeType(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_CONTENT_TYPE)));
|
||||
file.setStoragePath(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH)));
|
||||
if (file.getStoragePath() == null) {
|
||||
// try to find existing file and bind it with current account;
|
||||
// with the current update of SynchronizeFolderOperation, this won't be
|
||||
// necessary anymore after a full synchronization of the account
|
||||
File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
|
||||
File f = new File(FileStorageUtils.getDefaultSavePathFor(account.name, file));
|
||||
if (f.exists()) {
|
||||
file.setStoragePath(f.getAbsolutePath());
|
||||
file.setLastSyncDateForData(f.lastModified());
|
||||
@@ -968,12 +955,12 @@ public class FileDataStorageManager {
|
||||
file.setLastSyncDateForData(c.getLong(c.getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA)));
|
||||
file.setAvailableOffline(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_KEEP_IN_SYNC)) == 1);
|
||||
file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG)));
|
||||
file.setShareViaLink(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_LINK)) == 1);
|
||||
file.setShareWithSharee(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1);
|
||||
file.setSharedViaLink(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_LINK)) == 1);
|
||||
file.setSharedWithSharee(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1);
|
||||
file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK)));
|
||||
file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS)));
|
||||
file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID)));
|
||||
file.setNeedsUpdateThumbnail(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1);
|
||||
file.setUpdateThumbnailNeeded(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1);
|
||||
file.setDownloading(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_IS_DOWNLOADING)) == 1);
|
||||
file.setEtagInConflict(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG_IN_CONFLICT)));
|
||||
file.setFavorite(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_FAVORITE)) == 1);
|
||||
@@ -983,6 +970,7 @@ public class FileDataStorageManager {
|
||||
}
|
||||
file.setMountType(WebdavEntry.MountType.values()[c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.FILE_MOUNT_TYPE))]);
|
||||
file.setPreviewAvailable(c.getInt(c.getColumnIndex(ProviderTableMeta.FILE_HAS_PREVIEW)) == 1);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
@@ -1000,16 +988,14 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
cv.put(
|
||||
ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
|
||||
share.getSharedWithDisplayName()
|
||||
);
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
|
||||
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
|
||||
if (shareExistsForRemoteId(share.getRemoteId())) {// for renamed files; no more delete and create
|
||||
overriden = true;
|
||||
@@ -1109,7 +1095,7 @@ public class FileDataStorageManager {
|
||||
null,
|
||||
key + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
||||
new String[]{value, mAccount.name},
|
||||
new String[]{value, account.name},
|
||||
null
|
||||
);
|
||||
} else {
|
||||
@@ -1118,7 +1104,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI_SHARE,
|
||||
null,
|
||||
key + AND + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
||||
new String[]{value, mAccount.name},
|
||||
new String[]{value, account.name},
|
||||
null
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
@@ -1156,13 +1142,13 @@ public class FileDataStorageManager {
|
||||
selectionArgs = new String[]{
|
||||
path,
|
||||
Integer.toString(type.getValue()),
|
||||
mAccount.name
|
||||
account.name
|
||||
};
|
||||
} else {
|
||||
selectionArgs = new String[]{
|
||||
path,
|
||||
Integer.toString(type.getValue()),
|
||||
mAccount.name,
|
||||
account.name,
|
||||
shareWith
|
||||
};
|
||||
}
|
||||
@@ -1215,6 +1201,8 @@ public class FileDataStorageManager {
|
||||
share.setUserId(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_USER_ID)));
|
||||
share.setIdRemoteShared(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)));
|
||||
share.setIsPasswordProtected(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED)) == 1);
|
||||
share.setNote(c.getString(c.getColumnIndex(ProviderTableMeta.OCSHARES_NOTE)));
|
||||
share.setHideFileDownload(c.getInt(c.getColumnIndex(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD)) == 1);
|
||||
}
|
||||
return share;
|
||||
}
|
||||
@@ -1225,7 +1213,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name};
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
||||
@@ -1245,7 +1233,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PARENT + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, String.valueOf(folder.getFileId())};
|
||||
String[] whereArgs = new String[]{account.name, String.valueOf(folder.getFileId())};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
||||
@@ -1265,7 +1253,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, filePath};
|
||||
String[] whereArgs = new String[]{account.name, filePath};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
||||
@@ -1281,7 +1269,7 @@ public class FileDataStorageManager {
|
||||
|
||||
private void cleanShares() {
|
||||
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name};
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs);
|
||||
@@ -1313,16 +1301,14 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
cv.put(
|
||||
ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
|
||||
share.getSharedWithDisplayName()
|
||||
);
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
|
||||
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
|
||||
if (shareExistsForRemoteId(share.getRemoteId())) {
|
||||
// updating an existing file
|
||||
@@ -1386,7 +1372,7 @@ public class FileDataStorageManager {
|
||||
if (!file.isFolder()) {
|
||||
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
||||
}
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
|
||||
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
|
||||
@@ -1399,10 +1385,10 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
|
||||
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
|
||||
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.getIsFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_UPDATE_THUMBNAIL,
|
||||
file.needsUpdateThumbnail() ? 1 : 0
|
||||
file.isUpdateThumbnailNeeded() ? 1 : 0
|
||||
);
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_IS_DOWNLOADING,
|
||||
@@ -1454,7 +1440,7 @@ public class FileDataStorageManager {
|
||||
Uri share_uri = ProviderTableMeta.CONTENT_URI_SHARE;
|
||||
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND +
|
||||
ProviderTableMeta._ID + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name, Long.toString(share.getId())};
|
||||
String[] whereArgs = new String[]{account.name, Long.toString(share.getId())};
|
||||
if (getContentProviderClient() != null) {
|
||||
try {
|
||||
getContentProviderClient().delete(share_uri, where, whereArgs);
|
||||
@@ -1596,23 +1582,18 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARED_DATE, share.getSharedDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
|
||||
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
|
||||
cv.put(
|
||||
ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
|
||||
share.getSharedWithDisplayName()
|
||||
);
|
||||
cv.put(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME, share.getSharedWithDisplayName());
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
|
||||
|
||||
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
||||
cv.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
||||
cv.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
||||
cv.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
||||
|
||||
// adding a new share resource
|
||||
operations.add(
|
||||
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE).
|
||||
withValues(cv).
|
||||
build()
|
||||
);
|
||||
operations.add(ContentProviderOperation.newInsert(
|
||||
ProviderTableMeta.CONTENT_URI_SHARE).withValues(cv).build());
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
@@ -1623,7 +1604,7 @@ public class FileDataStorageManager {
|
||||
if (folder != null) {
|
||||
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{"", mAccount.name};
|
||||
String[] whereArgs = new String[]{"", account.name};
|
||||
|
||||
List<OCFile> files = getFolderContent(folder, false);
|
||||
|
||||
@@ -1645,7 +1626,7 @@ public class FileDataStorageManager {
|
||||
|
||||
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{filePath, mAccount.name};
|
||||
String[] whereArgs = new String[]{filePath, account.name};
|
||||
|
||||
preparedOperations.add(
|
||||
ContentProviderOperation.newDelete(ProviderTableMeta.CONTENT_URI_SHARE).
|
||||
@@ -1664,23 +1645,22 @@ public class FileDataStorageManager {
|
||||
+ " (" + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
|
||||
+ ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? ) ";
|
||||
String[] whereArgs = new String[]{filePath, accountName,
|
||||
Integer.toString(ShareType.USER.getValue()),
|
||||
Integer.toString(ShareType.GROUP.getValue()),
|
||||
Integer.toString(ShareType.EMAIL.getValue()),
|
||||
Integer.toString(ShareType.FEDERATED.getValue())};
|
||||
Integer.toString(ShareType.FEDERATED.getValue()),
|
||||
Integer.toString(ShareType.ROOM.getValue())};
|
||||
|
||||
Cursor cursor = null;
|
||||
if (getContentResolver() != null) {
|
||||
cursor = getContentResolver().query(
|
||||
ProviderTableMeta.CONTENT_URI_SHARE,
|
||||
null, where, whereArgs, null);
|
||||
cursor = getContentResolver().query(ProviderTableMeta.CONTENT_URI_SHARE, null, where, whereArgs, null);
|
||||
} else {
|
||||
try {
|
||||
cursor = getContentProviderClient().query(
|
||||
ProviderTableMeta.CONTENT_URI_SHARE,
|
||||
null, where, whereArgs, null);
|
||||
cursor = getContentProviderClient().query(ProviderTableMeta.CONTENT_URI_SHARE, null, where,
|
||||
whereArgs, null);
|
||||
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage(), e);
|
||||
@@ -1844,7 +1824,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI_FILE,
|
||||
new String[]{ProviderTableMeta._ID},
|
||||
whereForDescencentsInConflict,
|
||||
new String[]{mAccount.name, parentPath + "%"},
|
||||
new String[]{account.name, parentPath + "%"},
|
||||
null
|
||||
);
|
||||
} else {
|
||||
@@ -1853,7 +1833,7 @@ public class FileDataStorageManager {
|
||||
ProviderTableMeta.CONTENT_URI_FILE,
|
||||
new String[]{ProviderTableMeta._ID},
|
||||
whereForDescencentsInConflict,
|
||||
new String[]{mAccount.name, parentPath + "%"},
|
||||
new String[]{account.name, parentPath + "%"},
|
||||
null
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
@@ -1868,7 +1848,7 @@ public class FileDataStorageManager {
|
||||
cv,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||
ProviderTableMeta.FILE_PATH + "=?",
|
||||
new String[]{mAccount.name, parentPath}
|
||||
new String[]{account.name, parentPath}
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
@@ -1877,7 +1857,7 @@ public class FileDataStorageManager {
|
||||
cv,
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
||||
ProviderTableMeta.FILE_PATH + "=?"
|
||||
, new String[]{mAccount.name, parentPath}
|
||||
, new String[]{account.name, parentPath}
|
||||
);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage(), e);
|
||||
@@ -1905,13 +1885,13 @@ public class FileDataStorageManager {
|
||||
|
||||
// Prepare capabilities data
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, mAccount.name);
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME, account.name);
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MAYOR, capability.getVersionMayor());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MINOR, capability.getVersionMinor());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_MICRO, capability.getVersionMicro());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_STRING, capability.getVersionString());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_VERSION_EDITION, capability.getVersionEdition());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollinterval());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL, capability.getCorePollInterval());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED, capability.getFilesSharingApiEnabled().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ENABLED,
|
||||
capability.getFilesSharingPublicEnabled().getValue());
|
||||
@@ -1951,17 +1931,22 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN, capability.getServerBackgroundPlain()
|
||||
.getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_ACTIVITY, capability.isActivityEnabled().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, capability.getRichDocuments().getValue());
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST,
|
||||
TextUtils.join(",", capability.getRichDocumentsMimeTypeList()));
|
||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING, capability.getRichDocumentsDirectEditing()
|
||||
.getValue());
|
||||
|
||||
if (capabilityExists(mAccount.name)) {
|
||||
if (capabilityExists(account.name)) {
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv,
|
||||
ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
||||
new String[]{mAccount.name});
|
||||
new String[]{account.name});
|
||||
} else {
|
||||
try {
|
||||
getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES,
|
||||
cv, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
||||
new String[]{mAccount.name});
|
||||
new String[]{account.name});
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e);
|
||||
}
|
||||
@@ -1983,7 +1968,7 @@ public class FileDataStorageManager {
|
||||
long new_id = Long.parseLong(result_uri.getPathSegments()
|
||||
.get(1));
|
||||
capability.setId(new_id);
|
||||
capability.setAccountName(mAccount.name);
|
||||
capability.setAccountName(account.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2053,7 +2038,7 @@ public class FileDataStorageManager {
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_STRING)));
|
||||
capability.setVersionEdition(c.getString(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_VERSION_EDITION)));
|
||||
capability.setCorePollinterval(c.getInt(c
|
||||
capability.setCorePollInterval(c.getInt(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL)));
|
||||
capability.setFilesSharingApiEnabled(CapabilityBooleanType.fromValue(c.getInt(c
|
||||
.getColumnIndex(ProviderTableMeta.CAPABILITIES_SHARING_API_ENABLED))));
|
||||
@@ -2106,6 +2091,15 @@ public class FileDataStorageManager {
|
||||
c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN))));
|
||||
capability.setActivity(CapabilityBooleanType.fromValue(
|
||||
c.getInt(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_ACTIVITY))));
|
||||
capability.setRichDocuments(CapabilityBooleanType.fromValue(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT))));
|
||||
String mimetypes = c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST));
|
||||
capability.setRichDocumentsDirectEditing(CapabilityBooleanType.fromValue(c.getInt(
|
||||
c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING))));
|
||||
if (mimetypes == null) {
|
||||
mimetypes = "";
|
||||
}
|
||||
capability.setRichDocumentsMimeTypeList(Arrays.asList(mimetypes.split(",")));
|
||||
}
|
||||
return capability;
|
||||
}
|
||||
@@ -2214,7 +2208,7 @@ public class FileDataStorageManager {
|
||||
|
||||
public void deleteAllFiles() {
|
||||
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{mAccount.name};
|
||||
String[] whereArgs = new String[]{account.name};
|
||||
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_FILE, where, whereArgs);
|
||||
@@ -2223,7 +2217,7 @@ public class FileDataStorageManager {
|
||||
try {
|
||||
getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_FILE, where, whereArgs);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, "Exception in deleteAllFiles for account " + mAccount.name + ": " + e.getMessage(), e);
|
||||
Log_OC.e(TAG, "Exception in deleteAllFiles for account " + account.name + ": " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2017 Mario Danic
|
||||
* Copyright (C) 2017 Nextcloud
|
||||
* 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
|
||||
@@ -22,96 +24,25 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
/*
|
||||
Model for filesystem data from the database
|
||||
*/
|
||||
public class FileSystemDataSet {
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Model for filesystem data from the database.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
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;
|
||||
|
||||
public FileSystemDataSet() {
|
||||
}
|
||||
|
||||
public FileSystemDataSet(int id, String localPath, long modifiedAt, boolean isFolder,
|
||||
boolean isSentForUpload, long foundAt, long syncedFolderId, @Nullable String crc32) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.modifiedAt = modifiedAt;
|
||||
this.isFolder = isFolder;
|
||||
this.isSentForUpload = isSentForUpload;
|
||||
this.foundAt = foundAt;
|
||||
this.syncedFolderId = syncedFolderId;
|
||||
this.crc32 = crc32;
|
||||
}
|
||||
|
||||
public String getCrc32() {
|
||||
return crc32;
|
||||
}
|
||||
|
||||
public void setCrc32(String crc32) {
|
||||
this.crc32 = crc32;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
}
|
||||
|
||||
public long getModifiedAt() {
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(long modifiedAt) {
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public boolean isFolder() {
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
public void setFolder(boolean folder) {
|
||||
isFolder = folder;
|
||||
}
|
||||
|
||||
public long getFoundAt() {
|
||||
return foundAt;
|
||||
}
|
||||
|
||||
public void setFoundAt(long foundAt) {
|
||||
this.foundAt = foundAt;
|
||||
}
|
||||
|
||||
public boolean isSentForUpload() {
|
||||
return isSentForUpload;
|
||||
}
|
||||
|
||||
public void setSentForUpload(boolean sentForUpload) {
|
||||
isSentForUpload = sentForUpload;
|
||||
}
|
||||
|
||||
public long getSyncedFolderId() {
|
||||
return syncedFolderId;
|
||||
}
|
||||
|
||||
public void setSyncedFolderId(long syncedFolderId) {
|
||||
this.syncedFolderId = syncedFolderId;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import android.util.SparseArray;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Types of media folder.
|
||||
*/
|
||||
@@ -29,7 +31,7 @@ public enum MediaFolderType {
|
||||
IMAGE(1),
|
||||
VIDEO(2);
|
||||
|
||||
private Integer id;
|
||||
@Getter private Integer id;
|
||||
|
||||
private static SparseArray<MediaFolderType> reverseMap = new SparseArray<>(3);
|
||||
|
||||
@@ -46,8 +48,4 @@ public enum MediaFolderType {
|
||||
public static MediaFolderType getById(Integer id) {
|
||||
return reverseMap.get(id);
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2018 Mario Danic
|
||||
* 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
|
||||
@@ -22,35 +24,15 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter @Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MediaFoldersModel {
|
||||
private List<String> imageMediaFolders;
|
||||
private List<String> videoMediaFolders;
|
||||
|
||||
/**
|
||||
* default constructor.
|
||||
*/
|
||||
public MediaFoldersModel() {
|
||||
// keep default constructor for GSON
|
||||
}
|
||||
|
||||
public MediaFoldersModel(List<String> imageMediaFolders, List<String> videoMediaFolders) {
|
||||
this.imageMediaFolders = imageMediaFolders;
|
||||
this.videoMediaFolders = videoMediaFolders;
|
||||
}
|
||||
|
||||
public List<String> getImageMediaFolders() {
|
||||
return imageMediaFolders;
|
||||
}
|
||||
|
||||
public void setImageMediaFolders(List<String> imageMediaFolders) {
|
||||
this.imageMediaFolders = imageMediaFolders;
|
||||
}
|
||||
|
||||
public List<String> getVideoMediaFolders() {
|
||||
return videoMediaFolders;
|
||||
}
|
||||
|
||||
public void setVideoMediaFolders(List<String> videoMediaFolders) {
|
||||
this.videoMediaFolders = videoMediaFolders;
|
||||
}
|
||||
}
|
||||
@@ -119,9 +119,9 @@ public final 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();
|
||||
@@ -223,7 +223,7 @@ public final class MediaProvider {
|
||||
|
||||
if (filePath != null) {
|
||||
mediaFolder.filePaths.add(filePath);
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf("/"));
|
||||
mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf('/'));
|
||||
}
|
||||
}
|
||||
cursorVideos.close();
|
||||
|
||||
@@ -40,73 +40,68 @@ import com.owncloud.android.utils.MimeType;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import third_parties.daveKoeller.AlphanumComparator;
|
||||
|
||||
public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterface {
|
||||
|
||||
public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
|
||||
|
||||
@Override
|
||||
public OCFile createFromParcel(Parcel source) {
|
||||
return new OCFile(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCFile[] newArray(int size) {
|
||||
return new OCFile[size];
|
||||
}
|
||||
};
|
||||
|
||||
private final static String PERMISSION_SHARED_WITH_ME = "S"; // TODO move to better location
|
||||
private final static String PERMISSION_SHARED_WITH_ME = "S";
|
||||
private final static String PERMISSION_CAN_RESHARE = "R";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
|
||||
public static final String PATH_SEPARATOR = "/";
|
||||
public static final String ROOT_PATH = PATH_SEPARATOR;
|
||||
|
||||
private static final String TAG = OCFile.class.getSimpleName();
|
||||
|
||||
private long mId;
|
||||
private long mParentId;
|
||||
private long mLength;
|
||||
private long mCreationTimestamp;
|
||||
private long mModifiedTimestamp;
|
||||
private long mModifiedTimestampAtLastSyncForData;
|
||||
private String mRemotePath;
|
||||
private String mLocalPath;
|
||||
private String mMimeType;
|
||||
private boolean mNeedsUpdating;
|
||||
private long mLastSyncDateForProperties;
|
||||
private long mLastSyncDateForData;
|
||||
private boolean mAvailableOffline;
|
||||
@Getter
|
||||
@Setter
|
||||
private long fileId; // android internal ID of the file
|
||||
@Getter @Setter private long parentId;
|
||||
@Getter @Setter private long fileLength;
|
||||
@Getter
|
||||
@Setter
|
||||
private long creationTimestamp; // UNIX timestamp of the time the file was created
|
||||
|
||||
private String mEtag;
|
||||
|
||||
private boolean mShareByLink;
|
||||
private String mPublicLink;
|
||||
|
||||
private String mPermissions;
|
||||
private String mRemoteId;
|
||||
|
||||
private boolean mNeedsUpdateThumbnail;
|
||||
|
||||
private boolean mIsDownloading;
|
||||
|
||||
private String mEtagInConflict; // Save file etag in the server, when there is a conflict. No conflict = null
|
||||
|
||||
private boolean mShareWithSharee;
|
||||
|
||||
private boolean mIsFavorite;
|
||||
|
||||
private boolean mIsEncrypted;
|
||||
|
||||
private WebdavEntry.MountType mMountType;
|
||||
@Getter
|
||||
@Setter
|
||||
private long modificationTimestamp; // UNIX timestamp of the file modification time
|
||||
/** UNIX timestamp of the modification time, corresponding to the value returned by the server
|
||||
* in the last synchronization of THE CONTENTS of this file.
|
||||
*/
|
||||
@Getter @Setter private long modificationTimestampAtLastSyncForData;
|
||||
@Setter private String remotePath;
|
||||
private String localPath;
|
||||
@Getter @Setter private String mimeType;
|
||||
@Getter private boolean needsUpdatingWhileSaving;
|
||||
@Getter @Setter private long lastSyncDateForProperties;
|
||||
@Getter @Setter private long lastSyncDateForData;
|
||||
@Getter @Setter private boolean availableOffline;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean previewAvailable;
|
||||
@Getter private String etag;
|
||||
@Getter @Setter private boolean sharedViaLink;
|
||||
@Getter @Setter private String publicLink;
|
||||
@Getter @Setter private String permissions;
|
||||
@Getter
|
||||
@Setter
|
||||
private String remoteId; // The fileid namespaced by the instance fileId, globally unique
|
||||
@Getter @Setter private boolean updateThumbnailNeeded;
|
||||
@Getter @Setter private boolean downloading;
|
||||
@Getter
|
||||
@Setter
|
||||
private String etagInConflict; // Only saves file etag in the server, when there is a conflict
|
||||
@Getter @Setter private boolean sharedWithSharee;
|
||||
@Getter @Setter private boolean favorite;
|
||||
@Getter @Setter private boolean encrypted;
|
||||
@Getter @Setter private WebdavEntry.MountType mountType;
|
||||
|
||||
/**
|
||||
* URI to the local path of the file contents, if stored in the device; cached after first call
|
||||
* to {@link #getStorageUri()}
|
||||
*/
|
||||
private Uri mLocalUri;
|
||||
private Uri localUri;
|
||||
|
||||
|
||||
/**
|
||||
@@ -114,8 +109,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* <p>
|
||||
* Cached after first call, until changed.
|
||||
*/
|
||||
private Uri mExposedFileUri;
|
||||
private String mEncryptedFileName;
|
||||
private Uri exposedFileUri;
|
||||
@Getter @Setter private String encryptedFileName;
|
||||
|
||||
|
||||
/**
|
||||
@@ -127,11 +122,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
*/
|
||||
public OCFile(String path) {
|
||||
resetData();
|
||||
mNeedsUpdating = false;
|
||||
needsUpdatingWhileSaving = false;
|
||||
if (path == null || path.length() <= 0 || !path.startsWith(PATH_SEPARATOR)) {
|
||||
throw new IllegalArgumentException("Trying to create a OCFile with a non valid remote path: " + path);
|
||||
}
|
||||
mRemotePath = path;
|
||||
remotePath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,90 +135,66 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @param source The source parcel
|
||||
*/
|
||||
private OCFile(Parcel source) {
|
||||
mId = source.readLong();
|
||||
mParentId = source.readLong();
|
||||
mLength = source.readLong();
|
||||
mCreationTimestamp = source.readLong();
|
||||
mModifiedTimestamp = source.readLong();
|
||||
mModifiedTimestampAtLastSyncForData = source.readLong();
|
||||
mRemotePath = source.readString();
|
||||
mLocalPath = source.readString();
|
||||
mMimeType = source.readString();
|
||||
mNeedsUpdating = source.readInt() == 0;
|
||||
mAvailableOffline = source.readInt() == 1;
|
||||
mLastSyncDateForProperties = source.readLong();
|
||||
mLastSyncDateForData = source.readLong();
|
||||
mEtag = source.readString();
|
||||
mShareByLink = source.readInt() == 1;
|
||||
mPublicLink = source.readString();
|
||||
mPermissions = source.readString();
|
||||
mRemoteId = source.readString();
|
||||
mNeedsUpdateThumbnail = source.readInt() == 1;
|
||||
mIsDownloading = source.readInt() == 1;
|
||||
mEtagInConflict = source.readString();
|
||||
mShareWithSharee = source.readInt() == 1;
|
||||
mIsFavorite = source.readInt() == 1;
|
||||
mIsEncrypted = source.readInt() == 1;
|
||||
mEncryptedFileName = source.readString();
|
||||
mMountType = (WebdavEntry.MountType) source.readSerializable();
|
||||
fileId = source.readLong();
|
||||
parentId = source.readLong();
|
||||
fileLength = source.readLong();
|
||||
creationTimestamp = source.readLong();
|
||||
modificationTimestamp = source.readLong();
|
||||
modificationTimestampAtLastSyncForData = source.readLong();
|
||||
remotePath = source.readString();
|
||||
localPath = source.readString();
|
||||
mimeType = source.readString();
|
||||
needsUpdatingWhileSaving = source.readInt() == 0;
|
||||
availableOffline = source.readInt() == 1;
|
||||
lastSyncDateForProperties = source.readLong();
|
||||
lastSyncDateForData = source.readLong();
|
||||
etag = source.readString();
|
||||
sharedViaLink = source.readInt() == 1;
|
||||
publicLink = source.readString();
|
||||
permissions = source.readString();
|
||||
remoteId = source.readString();
|
||||
updateThumbnailNeeded = source.readInt() == 1;
|
||||
downloading = source.readInt() == 1;
|
||||
etagInConflict = source.readString();
|
||||
sharedWithSharee = source.readInt() == 1;
|
||||
favorite = source.readInt() == 1;
|
||||
encrypted = source.readInt() == 1;
|
||||
encryptedFileName = source.readString();
|
||||
mountType = (WebdavEntry.MountType) source.readSerializable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(mId);
|
||||
dest.writeLong(mParentId);
|
||||
dest.writeLong(mLength);
|
||||
dest.writeLong(mCreationTimestamp);
|
||||
dest.writeLong(mModifiedTimestamp);
|
||||
dest.writeLong(mModifiedTimestampAtLastSyncForData);
|
||||
dest.writeString(mRemotePath);
|
||||
dest.writeString(mLocalPath);
|
||||
dest.writeString(mMimeType);
|
||||
dest.writeInt(mNeedsUpdating ? 1 : 0);
|
||||
dest.writeInt(mAvailableOffline ? 1 : 0);
|
||||
dest.writeLong(mLastSyncDateForProperties);
|
||||
dest.writeLong(mLastSyncDateForData);
|
||||
dest.writeString(mEtag);
|
||||
dest.writeInt(mShareByLink ? 1 : 0);
|
||||
dest.writeString(mPublicLink);
|
||||
dest.writeString(mPermissions);
|
||||
dest.writeString(mRemoteId);
|
||||
dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0);
|
||||
dest.writeInt(mIsDownloading ? 1 : 0);
|
||||
dest.writeString(mEtagInConflict);
|
||||
dest.writeInt(mShareWithSharee ? 1 : 0);
|
||||
dest.writeInt(mIsFavorite ? 1 : 0);
|
||||
dest.writeInt(mIsEncrypted ? 1 : 0);
|
||||
dest.writeString(mEncryptedFileName);
|
||||
dest.writeSerializable(mMountType);
|
||||
}
|
||||
|
||||
public boolean getIsFavorite() {
|
||||
return mIsFavorite;
|
||||
}
|
||||
|
||||
public void setFavorite(boolean mIsFavorite) {
|
||||
this.mIsFavorite = mIsFavorite;
|
||||
}
|
||||
|
||||
public boolean isEncrypted() {
|
||||
return mIsEncrypted;
|
||||
}
|
||||
|
||||
public void setEncrypted(boolean mIsEncrypted) {
|
||||
this.mIsEncrypted = mIsEncrypted;
|
||||
}
|
||||
/**
|
||||
* Gets the android internal ID of the file
|
||||
*
|
||||
* @return the android internal file ID
|
||||
*/
|
||||
public long getFileId() {
|
||||
return mId;
|
||||
dest.writeLong(fileId);
|
||||
dest.writeLong(parentId);
|
||||
dest.writeLong(fileLength);
|
||||
dest.writeLong(creationTimestamp);
|
||||
dest.writeLong(modificationTimestamp);
|
||||
dest.writeLong(modificationTimestampAtLastSyncForData);
|
||||
dest.writeString(remotePath);
|
||||
dest.writeString(localPath);
|
||||
dest.writeString(mimeType);
|
||||
dest.writeInt(needsUpdatingWhileSaving ? 1 : 0);
|
||||
dest.writeInt(availableOffline ? 1 : 0);
|
||||
dest.writeLong(lastSyncDateForProperties);
|
||||
dest.writeLong(lastSyncDateForData);
|
||||
dest.writeString(etag);
|
||||
dest.writeInt(sharedViaLink ? 1 : 0);
|
||||
dest.writeString(publicLink);
|
||||
dest.writeString(permissions);
|
||||
dest.writeString(remoteId);
|
||||
dest.writeInt(updateThumbnailNeeded ? 1 : 0);
|
||||
dest.writeInt(downloading ? 1 : 0);
|
||||
dest.writeString(etagInConflict);
|
||||
dest.writeInt(sharedWithSharee ? 1 : 0);
|
||||
dest.writeInt(favorite ? 1 : 0);
|
||||
dest.writeInt(encrypted ? 1 : 0);
|
||||
dest.writeString(encryptedFileName);
|
||||
dest.writeSerializable(mountType);
|
||||
}
|
||||
|
||||
public String getDecryptedRemotePath() {
|
||||
return mRemotePath;
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +204,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
*/
|
||||
public String getRemotePath() {
|
||||
if (isEncrypted() && !isFolder()) {
|
||||
String parentPath = new File(mRemotePath).getParent();
|
||||
String parentPath = new File(remotePath).getParent();
|
||||
|
||||
if (parentPath.endsWith("/")) {
|
||||
return parentPath + getEncryptedFileName();
|
||||
@@ -242,21 +213,17 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
}
|
||||
} else {
|
||||
if (isFolder()) {
|
||||
if (mRemotePath.endsWith("/")) {
|
||||
return mRemotePath;
|
||||
if (remotePath.endsWith("/")) {
|
||||
return remotePath;
|
||||
} else {
|
||||
return mRemotePath + "/";
|
||||
return remotePath + "/";
|
||||
}
|
||||
} else {
|
||||
return mRemotePath;
|
||||
return remotePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRemotePath(String path) {
|
||||
mRemotePath = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check, whether or not this file exists in the database
|
||||
* already
|
||||
@@ -264,7 +231,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return true, if the file exists in the database
|
||||
*/
|
||||
public boolean fileExists() {
|
||||
return mId != -1;
|
||||
return fileId != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +240,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return true if it is a folder
|
||||
*/
|
||||
public boolean isFolder() {
|
||||
return mMimeType != null && mMimeType.equals(MimeType.DIRECTORY);
|
||||
return MimeType.DIRECTORY.equals(mimeType);
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +251,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return OCFile this file
|
||||
*/
|
||||
public OCFile setFolder() {
|
||||
setMimetype(MimeType.DIRECTORY);
|
||||
setMimeType(MimeType.DIRECTORY);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -303,8 +270,8 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return true if it is
|
||||
*/
|
||||
public boolean existsOnDevice() {
|
||||
if (mLocalPath != null && mLocalPath.length() > 0) {
|
||||
return new File(mLocalPath).exists();
|
||||
if (localPath != null && localPath.length() > 0) {
|
||||
return new File(localPath).exists();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -315,7 +282,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return The local path to the file
|
||||
*/
|
||||
public String getStoragePath() {
|
||||
return mLocalPath;
|
||||
return localPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,52 +291,52 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return A URI to the local copy of the file, or NULL if not stored in the device
|
||||
*/
|
||||
public Uri getStorageUri() {
|
||||
if (mLocalPath == null || mLocalPath.length() == 0) {
|
||||
if (localPath == null || localPath.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (mLocalUri == null) {
|
||||
if (localUri == null) {
|
||||
Uri.Builder builder = new Uri.Builder();
|
||||
builder.scheme(ContentResolver.SCHEME_FILE);
|
||||
builder.path(mLocalPath);
|
||||
mLocalUri = builder.build();
|
||||
builder.path(localPath);
|
||||
localUri = builder.build();
|
||||
}
|
||||
return mLocalUri;
|
||||
return localUri;
|
||||
}
|
||||
|
||||
|
||||
public Uri getLegacyExposedFileUri(Context context) {
|
||||
if (mLocalPath == null || mLocalPath.length() == 0) {
|
||||
public Uri getLegacyExposedFileUri() {
|
||||
if (localPath == null || localPath.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (mExposedFileUri == null) {
|
||||
return Uri.parse(ContentResolver.SCHEME_FILE + "://" + WebdavUtils.encodePath(mLocalPath));
|
||||
if (exposedFileUri == null) {
|
||||
return Uri.parse(ContentResolver.SCHEME_FILE + "://" + WebdavUtils.encodePath(localPath));
|
||||
}
|
||||
|
||||
return mExposedFileUri;
|
||||
return exposedFileUri;
|
||||
|
||||
}
|
||||
/*
|
||||
Partly disabled because not all apps understand paths that we get via this method for now
|
||||
*/
|
||||
public Uri getExposedFileUri(Context context) {
|
||||
if (mLocalPath == null || mLocalPath.length() == 0) {
|
||||
if (localPath == null || localPath.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (mExposedFileUri == null) {
|
||||
if (exposedFileUri == null) {
|
||||
try {
|
||||
mExposedFileUri = FileProvider.getUriForFile(
|
||||
exposedFileUri = FileProvider.getUriForFile(
|
||||
context,
|
||||
context.getString(R.string.file_provider_authority),
|
||||
new File(mLocalPath));
|
||||
new File(localPath));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// Could not share file using FileProvider URI scheme.
|
||||
// Fall back to legacy URI parsing.
|
||||
getLegacyExposedFileUri(context);
|
||||
getLegacyExposedFileUri();
|
||||
}
|
||||
}
|
||||
|
||||
return mExposedFileUri;
|
||||
|
||||
return exposedFileUri;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,82 +345,18 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @param storage_path to set
|
||||
*/
|
||||
public void setStoragePath(String storage_path) {
|
||||
mLocalPath = storage_path;
|
||||
mLocalUri = null;
|
||||
mExposedFileUri = null;
|
||||
localPath = storage_path;
|
||||
localUri = null;
|
||||
exposedFileUri = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a UNIX timestamp of the file creation time
|
||||
*
|
||||
* @return A UNIX timestamp of the time that file was created
|
||||
*/
|
||||
public long getCreationTimestamp() {
|
||||
return mCreationTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a UNIX timestamp of the time the file was created
|
||||
*
|
||||
* @param creation_timestamp to set
|
||||
*/
|
||||
public void setCreationTimestamp(long creation_timestamp) {
|
||||
mCreationTimestamp = creation_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a UNIX timestamp of the file modification time.
|
||||
*
|
||||
* @return A UNIX timestamp of the modification time, corresponding to the value returned by the server
|
||||
* in the last synchronization of the properties of this file.
|
||||
*/
|
||||
public long getModificationTimestamp() {
|
||||
return mModifiedTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a UNIX timestamp of the time the time the file was modified.
|
||||
* <p/>
|
||||
* To update with the value returned by the server in every synchronization of the properties
|
||||
* of this file.
|
||||
*
|
||||
* @param modification_timestamp to set
|
||||
*/
|
||||
public void setModificationTimestamp(long modification_timestamp) {
|
||||
mModifiedTimestamp = modification_timestamp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a UNIX timestamp of the file modification time.
|
||||
*
|
||||
* @return A UNIX timestamp of the modification time, corresponding to the value returned by the server
|
||||
* in the last synchronization of THE CONTENTS of this file.
|
||||
*/
|
||||
public long getModificationTimestampAtLastSyncForData() {
|
||||
return mModifiedTimestampAtLastSyncForData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a UNIX timestamp of the time the time the file was modified.
|
||||
* <p/>
|
||||
* To update with the value returned by the server in every synchronization of THE CONTENTS
|
||||
* of this file.
|
||||
*
|
||||
* @param modificationTimestamp to set
|
||||
*/
|
||||
public void setModificationTimestampAtLastSyncForData(long modificationTimestamp) {
|
||||
mModifiedTimestampAtLastSyncForData = modificationTimestamp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the filename and "/" for the root directory
|
||||
*
|
||||
* @return The name of the file
|
||||
*/
|
||||
public String getFileName() {
|
||||
File f = new File(mRemotePath);
|
||||
File f = new File(remotePath);
|
||||
return f.getName().length() == 0 ? ROOT_PATH : f.getName();
|
||||
}
|
||||
|
||||
@@ -464,121 +367,49 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* directory
|
||||
*/
|
||||
public void setFileName(String name) {
|
||||
Log_OC.d(TAG, "OCFile name changing from " + mRemotePath);
|
||||
Log_OC.d(TAG, "OCFile name changing from " + remotePath);
|
||||
if (name != null && name.length() > 0 && !name.contains(PATH_SEPARATOR) &&
|
||||
!mRemotePath.equals(ROOT_PATH)) {
|
||||
!ROOT_PATH.equals(remotePath)) {
|
||||
String parent = new File(this.getRemotePath()).getParent();
|
||||
parent = parent.endsWith(PATH_SEPARATOR) ? parent : parent + PATH_SEPARATOR;
|
||||
mRemotePath = parent + name;
|
||||
remotePath = parent + name;
|
||||
if (isFolder()) {
|
||||
mRemotePath += PATH_SEPARATOR;
|
||||
remotePath += PATH_SEPARATOR;
|
||||
}
|
||||
Log_OC.d(TAG, "OCFile name changed to " + mRemotePath);
|
||||
Log_OC.d(TAG, "OCFile name changed to " + remotePath);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEncryptedFileName(String name) {
|
||||
mEncryptedFileName = name;
|
||||
}
|
||||
|
||||
public String getEncryptedFileName() {
|
||||
return mEncryptedFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to get the MimeType
|
||||
*
|
||||
* @return the MimeType as a String
|
||||
*/
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return mMimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used internally. Reset all file properties
|
||||
*/
|
||||
private void resetData() {
|
||||
mId = -1;
|
||||
mRemotePath = null;
|
||||
mParentId = 0;
|
||||
mLocalPath = null;
|
||||
mMimeType = null;
|
||||
mLength = 0;
|
||||
mCreationTimestamp = 0;
|
||||
mModifiedTimestamp = 0;
|
||||
mModifiedTimestampAtLastSyncForData = 0;
|
||||
mLastSyncDateForProperties = 0;
|
||||
mLastSyncDateForData = 0;
|
||||
mAvailableOffline = false;
|
||||
mNeedsUpdating = false;
|
||||
mEtag = null;
|
||||
mShareByLink = false;
|
||||
mPublicLink = null;
|
||||
mPermissions = null;
|
||||
mRemoteId = null;
|
||||
mNeedsUpdateThumbnail = false;
|
||||
mIsDownloading = false;
|
||||
mEtagInConflict = null;
|
||||
mShareWithSharee = false;
|
||||
mIsFavorite = false;
|
||||
mIsEncrypted = false;
|
||||
mEncryptedFileName = null;
|
||||
mMountType = WebdavEntry.MountType.INTERNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the file
|
||||
*
|
||||
* @param file_id to set
|
||||
*/
|
||||
public void setFileId(long file_id) {
|
||||
mId = file_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Mime-Type of the
|
||||
*
|
||||
* @param mimetype to set
|
||||
*/
|
||||
public void setMimetype(String mimetype) {
|
||||
mMimeType = mimetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the parent folder
|
||||
*
|
||||
* @param parent_id to set
|
||||
*/
|
||||
public void setParentId(long parent_id) {
|
||||
mParentId = parent_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file size in bytes
|
||||
*
|
||||
* @param file_len to set
|
||||
*/
|
||||
public void setFileLength(long file_len) {
|
||||
mLength = file_len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the file in bytes
|
||||
*
|
||||
* @return The filesize in bytes
|
||||
*/
|
||||
public long getFileLength() {
|
||||
return mLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the parent Folder
|
||||
*
|
||||
* @return The ID
|
||||
*/
|
||||
public long getParentId() {
|
||||
return mParentId;
|
||||
fileId = -1;
|
||||
remotePath = null;
|
||||
parentId = 0;
|
||||
localPath = null;
|
||||
mimeType = null;
|
||||
fileLength = 0;
|
||||
creationTimestamp = 0;
|
||||
modificationTimestamp = 0;
|
||||
modificationTimestampAtLastSyncForData = 0;
|
||||
lastSyncDateForProperties = 0;
|
||||
lastSyncDateForData = 0;
|
||||
availableOffline = false;
|
||||
needsUpdatingWhileSaving = false;
|
||||
etag = null;
|
||||
sharedViaLink = false;
|
||||
publicLink = null;
|
||||
permissions = null;
|
||||
remoteId = null;
|
||||
updateThumbnailNeeded = false;
|
||||
downloading = false;
|
||||
etagInConflict = null;
|
||||
sharedWithSharee = false;
|
||||
favorite = false;
|
||||
encrypted = false;
|
||||
encryptedFileName = null;
|
||||
mountType = WebdavEntry.MountType.INTERNAL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -591,47 +422,6 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
return parentPath.endsWith("/") ? parentPath : parentPath + "/";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check, if this file needs updating
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean needsUpdatingWhileSaving() {
|
||||
return mNeedsUpdating;
|
||||
}
|
||||
|
||||
public boolean needsUpdateThumbnail() {
|
||||
return mNeedsUpdateThumbnail;
|
||||
}
|
||||
|
||||
public void setNeedsUpdateThumbnail(boolean needsUpdateThumbnail) {
|
||||
this.mNeedsUpdateThumbnail = needsUpdateThumbnail;
|
||||
}
|
||||
|
||||
public long getLastSyncDateForProperties() {
|
||||
return mLastSyncDateForProperties;
|
||||
}
|
||||
|
||||
public void setLastSyncDateForProperties(long lastSyncDate) {
|
||||
mLastSyncDateForProperties = lastSyncDate;
|
||||
}
|
||||
|
||||
public long getLastSyncDateForData() {
|
||||
return mLastSyncDateForData;
|
||||
}
|
||||
|
||||
public void setLastSyncDateForData(long lastSyncDate) {
|
||||
mLastSyncDateForData = lastSyncDate;
|
||||
}
|
||||
|
||||
public void setAvailableOffline(boolean availableOffline) {
|
||||
mAvailableOffline = availableOffline;
|
||||
}
|
||||
|
||||
public boolean isAvailableOffline() {
|
||||
return mAvailableOffline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return super.hashCode();
|
||||
@@ -660,51 +450,31 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
|
||||
OCFile ocFile = (OCFile) o;
|
||||
|
||||
return mId == ocFile.mId && mParentId == ocFile.mParentId;
|
||||
return fileId == ocFile.fileId && parentId == ocFile.parentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * (int) (mId ^ (mId >>> 32)) + (int) (mParentId ^ (mParentId >>> 32));
|
||||
return 31 * (int) (fileId ^ (fileId >>> 32)) + (int) (parentId ^ (parentId >>> 32));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " +
|
||||
"parentId=%s, availableOffline=%s etag=%s favourite=%s]";
|
||||
return String.format(asString, mId, getFileName(), mMimeType, isDown(),
|
||||
mLocalPath, mRemotePath, mParentId, mAvailableOffline,
|
||||
mEtag, mIsFavorite);
|
||||
}
|
||||
|
||||
public String getEtag() {
|
||||
return mEtag;
|
||||
String asString = "[fileId=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, " +
|
||||
"parentId=%s, availableOffline=%s etag=%s favourite=%s]";
|
||||
return String.format(asString, fileId, getFileName(), mimeType, isDown(),
|
||||
localPath, remotePath, parentId, availableOffline,
|
||||
etag, favorite);
|
||||
}
|
||||
|
||||
public void setEtag(String etag) {
|
||||
this.mEtag = (etag != null ? etag : "");
|
||||
}
|
||||
|
||||
|
||||
public boolean isSharedViaLink() {
|
||||
return mShareByLink;
|
||||
}
|
||||
|
||||
public void setShareViaLink(boolean shareByLink) {
|
||||
this.mShareByLink = shareByLink;
|
||||
}
|
||||
|
||||
public String getPublicLink() {
|
||||
return mPublicLink;
|
||||
}
|
||||
|
||||
public void setPublicLink(String publicLink) {
|
||||
this.mPublicLink = publicLink;
|
||||
this.etag = etag != null ? etag : "";
|
||||
}
|
||||
|
||||
public long getLocalModificationTimestamp() {
|
||||
if (mLocalPath != null && mLocalPath.length() > 0) {
|
||||
File f = new File(mLocalPath);
|
||||
if (localPath != null && localPath.length() > 0) {
|
||||
File f = new File(localPath);
|
||||
return f.lastModified();
|
||||
}
|
||||
return 0;
|
||||
@@ -714,65 +484,20 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return 'True' if the file is hidden
|
||||
*/
|
||||
public boolean isHidden() {
|
||||
return getFileName().startsWith(".");
|
||||
}
|
||||
|
||||
public String getPermissions() {
|
||||
return mPermissions;
|
||||
}
|
||||
|
||||
public void setPermissions(String permissions) {
|
||||
this.mPermissions = permissions;
|
||||
return getFileName().length() > 0 && getFileName().charAt(0) == '.';
|
||||
}
|
||||
|
||||
/**
|
||||
* The fileid namespaced by the instance id, globally unique
|
||||
* The unique fileId for the file within the instance
|
||||
*
|
||||
* @return globally unique file id: file id + instance id
|
||||
*/
|
||||
public String getRemoteId() {
|
||||
return mRemoteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique id for the file within the instance
|
||||
*
|
||||
* @return file id, unique within the instance
|
||||
* @return file fileId, unique within the instance
|
||||
*/
|
||||
public String getLocalId() {
|
||||
return getRemoteId().substring(0, 8).replaceAll("^0*", "");
|
||||
}
|
||||
|
||||
public void setRemoteId(String remoteId) {
|
||||
this.mRemoteId = remoteId;
|
||||
}
|
||||
|
||||
public boolean isDownloading() {
|
||||
return mIsDownloading;
|
||||
}
|
||||
|
||||
public void setDownloading(boolean isDownloading) {
|
||||
this.mIsDownloading = isDownloading;
|
||||
}
|
||||
|
||||
public String getEtagInConflict() {
|
||||
return mEtagInConflict;
|
||||
}
|
||||
|
||||
public boolean isInConflict() {
|
||||
return mEtagInConflict != null && !mEtagInConflict.equals("");
|
||||
}
|
||||
|
||||
public void setEtagInConflict(String etagInConflict) {
|
||||
mEtagInConflict = etagInConflict;
|
||||
}
|
||||
|
||||
public boolean isSharedWithSharee() {
|
||||
return mShareWithSharee;
|
||||
}
|
||||
|
||||
public void setShareWithSharee(boolean shareWithSharee) {
|
||||
this.mShareWithSharee = shareWithSharee;
|
||||
return etagInConflict != null && !"".equals(etagInConflict);
|
||||
}
|
||||
|
||||
public boolean isSharedWithMe() {
|
||||
@@ -790,11 +515,16 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
return permissions != null && permissions.contains(PERMISSION_CAN_WRITE);
|
||||
}
|
||||
|
||||
public WebdavEntry.MountType getMountType() {
|
||||
return mMountType;
|
||||
}
|
||||
public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
|
||||
|
||||
public void setMountType(WebdavEntry.MountType mountType) {
|
||||
mMountType = mountType;
|
||||
}
|
||||
@Override
|
||||
public OCFile createFromParcel(Parcel source) {
|
||||
return new OCFile(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OCFile[] newArray(int size) {
|
||||
return new OCFile[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2017 Mario Danic
|
||||
* 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
|
||||
@@ -20,62 +22,19 @@
|
||||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PushConfigurationState {
|
||||
public String pushToken;
|
||||
public String deviceIdentifier;
|
||||
public String deviceIdentifierSignature;
|
||||
public String userPublicKey;
|
||||
public boolean shouldBeDeleted;
|
||||
|
||||
public PushConfigurationState() {
|
||||
}
|
||||
|
||||
public PushConfigurationState(String pushToken, String deviceIdentifier, String deviceIdentifierSignature,
|
||||
String userPublicKey, boolean shouldBeDeleted) {
|
||||
this.pushToken = pushToken;
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
this.deviceIdentifierSignature = deviceIdentifierSignature;
|
||||
this.userPublicKey = userPublicKey;
|
||||
this.shouldBeDeleted = shouldBeDeleted;
|
||||
}
|
||||
|
||||
public String getPushToken() {
|
||||
return pushToken;
|
||||
}
|
||||
|
||||
public void setPushToken(String pushToken) {
|
||||
this.pushToken = pushToken;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifier() {
|
||||
return deviceIdentifier;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
}
|
||||
|
||||
public String getDeviceIdentifierSignature() {
|
||||
return deviceIdentifierSignature;
|
||||
}
|
||||
|
||||
public void setDeviceIdentifierSignature(String deviceIdentifierSignature) {
|
||||
this.deviceIdentifierSignature = deviceIdentifierSignature;
|
||||
}
|
||||
|
||||
public String getUserPublicKey() {
|
||||
return userPublicKey;
|
||||
}
|
||||
|
||||
public void setUserPublicKey(String userPublicKey) {
|
||||
this.userPublicKey = userPublicKey;
|
||||
}
|
||||
|
||||
public boolean isShouldBeDeleted() {
|
||||
return shouldBeDeleted;
|
||||
}
|
||||
|
||||
public void setShouldBeDeleted(boolean shouldBeDeleted) {
|
||||
this.shouldBeDeleted = shouldBeDeleted;
|
||||
}
|
||||
}
|
||||
@@ -23,32 +23,17 @@ import android.accounts.Account;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Parcel
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SignatureVerification {
|
||||
public boolean signatureValid;
|
||||
public Account account;
|
||||
|
||||
public SignatureVerification() {
|
||||
}
|
||||
|
||||
public SignatureVerification(boolean signatureValid, Account account) {
|
||||
this.signatureValid = signatureValid;
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public boolean isSignatureValid() {
|
||||
return signatureValid;
|
||||
}
|
||||
|
||||
public void setSignatureValid(boolean signatureValid) {
|
||||
this.signatureValid = signatureValid;
|
||||
}
|
||||
|
||||
public Account getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
@@ -23,12 +23,20 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Synced folder entity containing all information per synced folder.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class SyncedFolder implements Serializable, Cloneable {
|
||||
public static final long UNPERSISTED_ID = Long.MIN_VALUE;
|
||||
private static final long serialVersionUID = -793476118299906429L;
|
||||
|
||||
private long id = UNPERSISTED_ID;
|
||||
private String localPath;
|
||||
private String remotePath;
|
||||
@@ -40,35 +48,6 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
private boolean enabled;
|
||||
private MediaFolderType type;
|
||||
|
||||
/**
|
||||
* constructor for already persisted entity.
|
||||
*
|
||||
* @param id the primary key
|
||||
* @param localPath local path
|
||||
* @param remotePath remote path
|
||||
* @param wifiOnly upload on wifi only flag
|
||||
* @param chargingOnly upload on charging only
|
||||
* @param subfolderByDate create sub-folders by date (month)
|
||||
* @param account the account owning the synced folder
|
||||
* @param uploadAction the action to be done after the upload
|
||||
* @param enabled flag if synced folder config is active
|
||||
* @param type the type of the folder
|
||||
*/
|
||||
public SyncedFolder(long id, String localPath, String remotePath, Boolean wifiOnly, Boolean chargingOnly,
|
||||
Boolean subfolderByDate, String account, Integer uploadAction, Boolean enabled,
|
||||
MediaFolderType type) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.remotePath = remotePath;
|
||||
this.wifiOnly = wifiOnly;
|
||||
this.chargingOnly = chargingOnly;
|
||||
this.subfolderByDate = subfolderByDate;
|
||||
this.account = account;
|
||||
this.uploadAction = uploadAction;
|
||||
this.enabled = enabled;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* constructor for new, to be persisted entity.
|
||||
*
|
||||
@@ -103,84 +82,4 @@ public class SyncedFolder implements Serializable, Cloneable {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
}
|
||||
|
||||
public String getRemotePath() {
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
public void setRemotePath(String remotePath) {
|
||||
this.remotePath = remotePath;
|
||||
}
|
||||
|
||||
public Boolean getWifiOnly() {
|
||||
return wifiOnly;
|
||||
}
|
||||
|
||||
public void setWifiOnly(Boolean wifiOnly) {
|
||||
this.wifiOnly = wifiOnly;
|
||||
}
|
||||
|
||||
public Boolean getChargingOnly() {
|
||||
return chargingOnly;
|
||||
}
|
||||
|
||||
public void setChargingOnly(Boolean chargingOnly) {
|
||||
this.chargingOnly = chargingOnly;
|
||||
}
|
||||
|
||||
public Boolean getSubfolderByDate() {
|
||||
return subfolderByDate;
|
||||
}
|
||||
|
||||
public void setSubfolderByDate(Boolean subfolderByDate) {
|
||||
this.subfolderByDate = subfolderByDate;
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public void setAccount(String account) {
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public Integer getUploadAction() {
|
||||
return uploadAction;
|
||||
}
|
||||
|
||||
public void setUploadAction(Integer uploadAction) {
|
||||
this.uploadAction = uploadAction;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public MediaFolderType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(MediaFolderType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
@@ -23,10 +23,15 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Display item specialization for synced folder objects to be displayed in a list/grid view adding further
|
||||
* information to be displayed in the UI but not part of the persisted underlying {@link SyncedFolder} object.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
private List<String> filePaths;
|
||||
private String folderName;
|
||||
@@ -65,28 +70,4 @@ public class SyncedFolderDisplayItem extends SyncedFolder {
|
||||
super(id, localPath, remotePath, wifiOnly, chargingOnly, subfolderByDate, account, uploadAction, enabled, type);
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public List<String> getFilePaths() {
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
public void setFilePaths(List<String> filePaths) {
|
||||
this.filePaths = filePaths;
|
||||
}
|
||||
|
||||
public String getFolderName() {
|
||||
return folderName;
|
||||
}
|
||||
|
||||
public void setFolderName(String folderName) {
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public long getNumberOfFiles() {
|
||||
return numberOfFiles;
|
||||
}
|
||||
|
||||
public void setNumberOfFiles(long numberOfFiles) {
|
||||
this.numberOfFiles = numberOfFiles;
|
||||
}
|
||||
}
|
||||
@@ -182,12 +182,12 @@ public class SyncedFolderProvider extends Observable {
|
||||
|
||||
SyncedFolder result = null;
|
||||
Cursor cursor = mContentResolver.query(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
null,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + " == \"" + localPath + "\"" + " AND " +
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " == " + account.name,
|
||||
null,
|
||||
null
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
null,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + "=? AND " +
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " =? ",
|
||||
new String[]{localPath, account.name},
|
||||
null
|
||||
);
|
||||
|
||||
if (cursor != null && cursor.getCount() == 1) {
|
||||
@@ -209,54 +209,17 @@ public class SyncedFolderProvider extends Observable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* find a synced folder by local path.
|
||||
*
|
||||
* @param localPath the local path of the local folder
|
||||
* @return the synced folder if found, else null
|
||||
*/
|
||||
public SyncedFolder findByLocalPath(String localPath) {
|
||||
SyncedFolder result = null;
|
||||
Cursor cursor = mContentResolver.query(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
null,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_LOCAL_PATH + " == \"" + localPath + "\"",
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
if (cursor != null && cursor.getCount() == 1) {
|
||||
result = createSyncedFolderFromCursor(cursor);
|
||||
} else {
|
||||
if (cursor == null) {
|
||||
Log_OC.e(TAG, "Sync folder db cursor for local path=" + localPath + " in NULL.");
|
||||
} else {
|
||||
Log_OC.e(TAG, cursor.getCount() + " items for local path=" + localPath
|
||||
+ " available in sync folder db. Expected 1. Failed to update sync folder db.");
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all synced folders for an account
|
||||
*
|
||||
* @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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,14 +308,12 @@ public class SyncedFolderProvider extends Observable {
|
||||
|
||||
ContentValues cv = createContentValuesFromSyncedFolder(syncedFolder);
|
||||
|
||||
int result = mContentResolver.update(
|
||||
return mContentResolver.update(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
cv,
|
||||
ProviderMeta.ProviderTableMeta._ID + "=?",
|
||||
new String[]{String.valueOf(syncedFolder.getId())}
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Template for creating a file from it via RichDocuments app
|
||||
*/
|
||||
|
||||
@Parcel
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Template {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private String thumbnailLink;
|
||||
private String type;
|
||||
private String extension;
|
||||
}
|
||||
@@ -90,13 +90,13 @@ public final 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);
|
||||
@@ -106,7 +106,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
private ThumbnailsCacheManager() {
|
||||
}
|
||||
|
||||
|
||||
public static class InitDiskCacheTask extends AsyncTask<File, Void, Void> {
|
||||
@Override
|
||||
protected Void doInBackground(File... params) {
|
||||
@@ -115,7 +115,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
if (mThumbnailCache == null) {
|
||||
try {
|
||||
// Check if media is mounted or storage is built-in, if so,
|
||||
// Check if media is mounted or storage is built-in, if so,
|
||||
// try and use external cache dir; otherwise use internal cache dir
|
||||
File cacheDir = MainApp.getAppContext().getExternalCacheDir();
|
||||
|
||||
@@ -184,7 +184,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
|
||||
public static void addBitmapToCache(String key, Bitmap bitmap) {
|
||||
synchronized (mThumbnailsDiskCacheLock) {
|
||||
if (mThumbnailCache != null) {
|
||||
@@ -265,7 +265,7 @@ public final class ThumbnailsCacheManager {
|
||||
thumbnail = getBitmapFromDiskCache(imageKey);
|
||||
|
||||
// Not found in disk cache
|
||||
if (thumbnail == null || file.needsUpdateThumbnail()) {
|
||||
if (thumbnail == null || file.isUpdateThumbnailNeeded()) {
|
||||
Point p = getScreenDimension();
|
||||
int pxW = p.x;
|
||||
int pxH = p.y;
|
||||
@@ -281,7 +281,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), pxW, pxH);
|
||||
|
||||
file.setNeedsUpdateThumbnail(false);
|
||||
file.setUpdateThumbnailNeeded(false);
|
||||
storageManager.saveFile(file);
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ public final class ThumbnailsCacheManager {
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,7 +384,7 @@ public final 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;
|
||||
|
||||
@@ -504,7 +504,7 @@ public final class ThumbnailsCacheManager {
|
||||
thumbnail = getBitmapFromDiskCache(imageKey);
|
||||
|
||||
// Not found in disk cache
|
||||
if (thumbnail == null || (file instanceof OCFile && ((OCFile) file).needsUpdateThumbnail())) {
|
||||
if (thumbnail == null || (file instanceof OCFile && ((OCFile) file).isUpdateThumbnailNeeded())) {
|
||||
int pxW;
|
||||
int pxH;
|
||||
pxW = pxH = getThumbnailDimension();
|
||||
@@ -528,7 +528,7 @@ public final class ThumbnailsCacheManager {
|
||||
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, ocFile.getStoragePath(), pxW, pxH);
|
||||
|
||||
ocFile.setNeedsUpdateThumbnail(false);
|
||||
ocFile.setUpdateThumbnailNeeded(false);
|
||||
mStorageManager.saveFile(ocFile);
|
||||
}
|
||||
}
|
||||
@@ -555,7 +555,7 @@ public final class ThumbnailsCacheManager {
|
||||
uri = mClient.getBaseUri() + "/index.php/apps/files_trashbin/preview?fileId=" +
|
||||
file.getLocalId() + "&x=" + pxW + "&y=" + pxH;
|
||||
}
|
||||
|
||||
|
||||
Log_OC.d(TAG, "generate thumbnail: " + file.getFileName() + " URI: " + uri);
|
||||
getMethod = new GetMethod(uri);
|
||||
getMethod.setRequestHeader("Cookie",
|
||||
@@ -865,7 +865,7 @@ public final class ThumbnailsCacheManager {
|
||||
Log_OC.d("Avatar", "URI: " + uri);
|
||||
get = new GetMethod(uri);
|
||||
|
||||
// only use eTag if available and corresponding avatar is still there
|
||||
// only use eTag if available and corresponding avatar is still there
|
||||
// (might be deleted from cache)
|
||||
if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) {
|
||||
get.setRequestHeader("If-None-Match", eTag);
|
||||
@@ -1166,4 +1166,4 @@ public final class ThumbnailsCacheManager {
|
||||
addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), pxW, pxH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2017 Tobias Kaminsky
|
||||
* Copyright (C) 2017 Nextcloud GmbH.
|
||||
* <p>
|
||||
*
|
||||
* 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.
|
||||
* <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 Affero General Public License for more details.
|
||||
* <p>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
@@ -24,7 +24,6 @@ package com.owncloud.android.datamodel;
|
||||
/**
|
||||
* Type for virtual folders
|
||||
*/
|
||||
|
||||
public enum VirtualFolderType {
|
||||
FAVORITE, PHOTOS, NONE
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -21,9 +21,17 @@
|
||||
|
||||
package com.owncloud.android.datastorage;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
@Getter @Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StoragePoint implements Comparable<StoragePoint> {
|
||||
public enum StorageType {
|
||||
INTERNAL, EXTERNAL
|
||||
@@ -33,51 +41,13 @@ public class StoragePoint implements Comparable<StoragePoint> {
|
||||
PRIVATE, PUBLIC
|
||||
}
|
||||
|
||||
private String mDescription;
|
||||
private String mPath;
|
||||
private StorageType mStorageType;
|
||||
private PrivacyType mPrivacyType;
|
||||
|
||||
public StoragePoint() {
|
||||
}
|
||||
|
||||
public StoragePoint(String mDescription, String mPath, StorageType mStorageType, PrivacyType privacyType) {
|
||||
this.mDescription = mDescription;
|
||||
this.mPath = mPath;
|
||||
this.mStorageType = mStorageType;
|
||||
this.mPrivacyType = privacyType;
|
||||
}
|
||||
|
||||
public StorageType getStorageType() {
|
||||
return mStorageType;
|
||||
}
|
||||
|
||||
public PrivacyType getPrivacyType() {
|
||||
return mPrivacyType;
|
||||
}
|
||||
public String getPath() { return mPath; }
|
||||
public String getDescription() { return mDescription; }
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.mDescription = description;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.mPath = path;
|
||||
}
|
||||
|
||||
public void setStorageType(StorageType storageType) {
|
||||
this.mStorageType = storageType;
|
||||
}
|
||||
|
||||
public void setPrivacyType(PrivacyType privacyType) {
|
||||
this.mPrivacyType = privacyType;
|
||||
}
|
||||
private String description;
|
||||
private String path;
|
||||
private StorageType storageType;
|
||||
private PrivacyType privacyType;
|
||||
|
||||
@Override
|
||||
public int compareTo(StoragePoint another) {
|
||||
return mPath.compareTo(another.getPath());
|
||||
return path.compareTo(another.getPath());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
|
||||
if (!line.toLowerCase(Locale.US).contains("asec") && sPattern.matcher(line).matches()) {
|
||||
String parts[] = line.split(" ");
|
||||
for (String path : parts) {
|
||||
if (path.startsWith("/") && !path.toLowerCase(Locale.US).contains("vold")) {
|
||||
if (path.length() > 0 && path.charAt(0) == '/' && !path.toLowerCase(Locale.US).contains("vold")) {
|
||||
result.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Stores all information in order to start upload operations. PersistentUploadObject can
|
||||
* be stored persistently by {@link UploadsStorageManager}.
|
||||
@@ -47,85 +50,85 @@ public class OCUpload implements Parcelable {
|
||||
|
||||
private static final String TAG = OCUpload.class.getSimpleName();
|
||||
|
||||
private long id;
|
||||
@Getter @Setter private long uploadId;
|
||||
|
||||
/**
|
||||
* Absolute path in the local file system to the file to be uploaded.
|
||||
*/
|
||||
private String localPath;
|
||||
@Getter @Setter private String localPath;
|
||||
|
||||
/**
|
||||
* Absolute path in the remote account to set to the uploaded file (not for its parent folder!)
|
||||
*/
|
||||
private String remotePath;
|
||||
@Getter @Setter private String remotePath;
|
||||
|
||||
/**
|
||||
* Name of Owncloud account to upload file to.
|
||||
*/
|
||||
private String accountName;
|
||||
@Getter private String accountName;
|
||||
|
||||
/**
|
||||
* File size.
|
||||
*/
|
||||
private long fileSize;
|
||||
@Getter @Setter private long fileSize;
|
||||
|
||||
/**
|
||||
* Local action for upload. (0 - COPY, 1 - MOVE, 2 - FORGET)
|
||||
*/
|
||||
private int localAction;
|
||||
@Getter @Setter private int localAction;
|
||||
|
||||
/**
|
||||
* Overwrite destination file?
|
||||
*/
|
||||
private boolean forceOverwrite;
|
||||
@Getter @Setter private boolean forceOverwrite;
|
||||
|
||||
/**
|
||||
* Create destination folder?
|
||||
*/
|
||||
private boolean createRemoteFolder;
|
||||
@Getter @Setter private boolean createRemoteFolder;
|
||||
|
||||
/**
|
||||
* Status of upload (later, in_progress, ...).
|
||||
*/
|
||||
private UploadStatus uploadStatus;
|
||||
@Getter private UploadStatus uploadStatus;
|
||||
|
||||
/**
|
||||
* Result from last upload operation. Can be null.
|
||||
*/
|
||||
private UploadResult lastResult;
|
||||
@Getter private UploadResult lastResult;
|
||||
|
||||
/**
|
||||
* Defines the origin of the upload; see constants CREATED_ in {@link UploadFileOperation}
|
||||
*/
|
||||
private int createdBy;
|
||||
@Getter @Setter private int createdBy;
|
||||
|
||||
/**
|
||||
* When the upload ended
|
||||
*/
|
||||
private long uploadEndTimeStamp;
|
||||
@Getter @Setter private long uploadEndTimestamp;
|
||||
|
||||
/**
|
||||
* Upload only via wifi?
|
||||
*/
|
||||
private boolean useWifiOnly;
|
||||
@Getter @Setter private boolean useWifiOnly;
|
||||
|
||||
/**
|
||||
* Upload only if phone being charged?
|
||||
*/
|
||||
private boolean whileChargingOnly;
|
||||
@Getter @Setter private boolean whileChargingOnly;
|
||||
|
||||
/**
|
||||
* Token to unlock E2E folder
|
||||
*/
|
||||
private String folderUnlockToken;
|
||||
@Getter @Setter private String folderUnlockToken;
|
||||
|
||||
/**
|
||||
* temporary values, used for sorting
|
||||
*/
|
||||
private UploadStatus fixedUploadStatus;
|
||||
private boolean fixedUploadingNow;
|
||||
private long fixedUploadEndTimeStamp;
|
||||
private long fixedId;
|
||||
@Getter private UploadStatus fixedUploadStatus;
|
||||
@Getter private boolean fixedUploadingNow;
|
||||
@Getter private long fixedUploadEndTimeStamp;
|
||||
@Getter private long fixedUploadId;
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
@@ -168,7 +171,7 @@ public class OCUpload implements Parcelable {
|
||||
localPath = "";
|
||||
accountName = "";
|
||||
fileSize = -1;
|
||||
id = -1;
|
||||
uploadId = -1;
|
||||
localAction = FileUploader.LOCAL_BEHAVIOUR_COPY;
|
||||
forceOverwrite = false;
|
||||
createRemoteFolder = false;
|
||||
@@ -183,26 +186,11 @@ public class OCUpload implements Parcelable {
|
||||
public void setDataFixed(FileUploader.FileUploaderBinder binder) {
|
||||
fixedUploadStatus = uploadStatus;
|
||||
fixedUploadingNow = binder != null && binder.isUploadingNow(this);
|
||||
fixedUploadEndTimeStamp = uploadEndTimeStamp;
|
||||
fixedId = id;
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
public void setUploadId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getUploadId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uploadStatus
|
||||
*/
|
||||
public UploadStatus getUploadStatus() {
|
||||
return uploadStatus;
|
||||
fixedUploadEndTimeStamp = uploadEndTimestamp;
|
||||
fixedUploadId = uploadId;
|
||||
}
|
||||
|
||||
// custom Getters & Setters
|
||||
/**
|
||||
* Sets uploadStatus AND SETS lastResult = null;
|
||||
* @param uploadStatus the uploadStatus to set
|
||||
@@ -212,13 +200,6 @@ public class OCUpload implements Parcelable {
|
||||
setLastResult(UploadResult.UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lastResult
|
||||
*/
|
||||
public UploadResult getLastResult() {
|
||||
return lastResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lastResult the lastResult to set
|
||||
*/
|
||||
@@ -226,44 +207,6 @@ public class OCUpload implements Parcelable {
|
||||
this.lastResult = lastResult != null ? lastResult : UploadResult.UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the localPath
|
||||
*/
|
||||
public String getLocalPath() {
|
||||
return localPath;
|
||||
}
|
||||
|
||||
public void setLocalPath(String localPath) {
|
||||
this.localPath = localPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the remotePath
|
||||
*/
|
||||
public String getRemotePath() {
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param remotePath the remotePath
|
||||
*/
|
||||
public void setRemotePath(String remotePath) {
|
||||
this.remotePath = remotePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return File size
|
||||
*/
|
||||
public long getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mimeType
|
||||
*/
|
||||
@@ -272,77 +215,12 @@ public class OCUpload implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the localAction
|
||||
*/
|
||||
public int getLocalAction() {
|
||||
return localAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param localAction the localAction to set
|
||||
*/
|
||||
public void setLocalAction(int localAction) {
|
||||
this.localAction = localAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forceOverwrite
|
||||
*/
|
||||
public boolean isForceOverwrite() {
|
||||
return forceOverwrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param forceOverwrite the forceOverwrite to set
|
||||
*/
|
||||
public void setForceOverwrite(boolean forceOverwrite) {
|
||||
this.forceOverwrite = forceOverwrite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isCreateRemoteFolder
|
||||
*/
|
||||
public boolean isCreateRemoteFolder() {
|
||||
return createRemoteFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createRemoteFolder the createRemoteFolder to set
|
||||
*/
|
||||
public void setCreateRemoteFolder(boolean createRemoteFolder) {
|
||||
this.createRemoteFolder = createRemoteFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the accountName
|
||||
*/
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns owncloud account as {@link Account} object.
|
||||
* Returns owncloud account as {@link Account} object.
|
||||
*/
|
||||
public Account getAccount(Context context) {
|
||||
return AccountUtils.getOwnCloudAccountByName(context, getAccountName());
|
||||
}
|
||||
|
||||
public void setCreatedBy(int createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public int getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setUploadEndTimestamp(long uploadEndTimestamp) {
|
||||
uploadEndTimeStamp = uploadEndTimestamp;
|
||||
}
|
||||
|
||||
public long getUploadEndTimestamp() {
|
||||
return uploadEndTimeStamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* For debugging purposes only.
|
||||
*/
|
||||
@@ -373,36 +251,6 @@ public class OCUpload implements Parcelable {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return the isUseWifiOnly
|
||||
*/
|
||||
public boolean isUseWifiOnly() {
|
||||
return useWifiOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param useWifiOnly the useWifiOnly to set
|
||||
*/
|
||||
public void setUseWifiOnly(boolean useWifiOnly) {
|
||||
this.useWifiOnly = useWifiOnly;
|
||||
}
|
||||
|
||||
public void setWhileChargingOnly(boolean whileChargingOnly) {
|
||||
this.whileChargingOnly = whileChargingOnly;
|
||||
}
|
||||
|
||||
public boolean isWhileChargingOnly() {
|
||||
return whileChargingOnly;
|
||||
}
|
||||
|
||||
public void setFolderUnlockToken(String token) {
|
||||
folderUnlockToken = token;
|
||||
}
|
||||
|
||||
public String getFolderUnlockToken() {
|
||||
return folderUnlockToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconstruct from parcel
|
||||
*
|
||||
@@ -413,7 +261,7 @@ public class OCUpload implements Parcelable {
|
||||
}
|
||||
|
||||
private void readFromParcel(Parcel source) {
|
||||
id = source.readLong();
|
||||
uploadId = source.readLong();
|
||||
localPath = source.readString();
|
||||
remotePath = source.readString();
|
||||
accountName = source.readString();
|
||||
@@ -425,7 +273,7 @@ public class OCUpload implements Parcelable {
|
||||
} catch (IllegalArgumentException x) {
|
||||
uploadStatus = UploadStatus.UPLOAD_IN_PROGRESS;
|
||||
}
|
||||
uploadEndTimeStamp = source.readLong();
|
||||
uploadEndTimestamp = source.readLong();
|
||||
try {
|
||||
lastResult = UploadResult.valueOf(source.readString());
|
||||
} catch (IllegalArgumentException x) {
|
||||
@@ -444,7 +292,7 @@ public class OCUpload implements Parcelable {
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(id);
|
||||
dest.writeLong(uploadId);
|
||||
dest.writeString(localPath);
|
||||
dest.writeString(remotePath);
|
||||
dest.writeString(accountName);
|
||||
@@ -452,7 +300,7 @@ public class OCUpload implements Parcelable {
|
||||
dest.writeInt(forceOverwrite ? 1 : 0);
|
||||
dest.writeInt(createRemoteFolder ? 1 : 0);
|
||||
dest.writeString(uploadStatus.name());
|
||||
dest.writeLong(uploadEndTimeStamp);
|
||||
dest.writeLong(uploadEndTimestamp);
|
||||
dest.writeString(lastResult == null ? "" : lastResult.name());
|
||||
dest.writeInt(createdBy);
|
||||
dest.writeInt(useWifiOnly ? 1 : 0);
|
||||
@@ -460,21 +308,5 @@ public class OCUpload implements Parcelable {
|
||||
dest.writeString(folderUnlockToken);
|
||||
}
|
||||
|
||||
public UploadStatus getFixedUploadStatus() {
|
||||
return fixedUploadStatus;
|
||||
}
|
||||
|
||||
public boolean isFixedUploadingNow() {
|
||||
return fixedUploadingNow;
|
||||
}
|
||||
|
||||
public long getFixedUploadEndTimestamp() {
|
||||
return fixedUploadEndTimeStamp;
|
||||
}
|
||||
|
||||
public Long getFixedUploadId() {
|
||||
return fixedId;
|
||||
}
|
||||
|
||||
enum CanUploadFileNowStatus {NOW, LATER, FILE_GONE, ERROR}
|
||||
}
|
||||
@@ -3,16 +3,16 @@
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -42,6 +42,7 @@ public final class PreferenceManager {
|
||||
* Value handled by the app without direct access in the UI.
|
||||
*/
|
||||
private static final String AUTO_PREF__LAST_UPLOAD_PATH = "last_upload_path";
|
||||
private static final String AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH = "upload_from_local_last_path";
|
||||
private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_MAP_URL = "prefs_upload_file_extension_map_url";
|
||||
private static final String AUTO_PREF__UPLOAD_FILE_EXTENSION_URL = "prefs_upload_file_extension_url";
|
||||
private static final String AUTO_PREF__UPLOADER_BEHAVIOR = "prefs_uploader_behaviour";
|
||||
@@ -64,6 +65,7 @@ public final class PreferenceManager {
|
||||
private static final String PREF__AUTO_UPLOAD_INIT = "autoUploadInit";
|
||||
private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
|
||||
private static final String PREF__FOLDER_LAYOUT = "folder_layout";
|
||||
public static final String PREF__LOCK_TIMESTAMP = "lock_timestamp";
|
||||
|
||||
private PreferenceManager() {
|
||||
}
|
||||
@@ -186,6 +188,27 @@ public final class PreferenceManager {
|
||||
saveStringPreference(context, AUTO_PREF__LAST_UPLOAD_PATH, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last local path where the user selected to do an upload from.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @return path Absolute path to a folder, as previously stored by
|
||||
* {@link #setUploadFromLocalLastPath(Context, String)}, or empty String if never saved before.
|
||||
*/
|
||||
public static String getUploadFromLocalLastPath(Context context) {
|
||||
return getDefaultSharedPreferences(context).getString(AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the path where the user selected to do the last local upload of a file from.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param path Absolute path to a folder.
|
||||
*/
|
||||
public static void setUploadFromLocalLastPath(Context context, String path) {
|
||||
saveStringPreference(context, AUTO_PREF__UPLOAD_FROM_LOCAL_LAST_PATH, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lock preference configured by the user.
|
||||
*
|
||||
@@ -211,7 +234,7 @@ public final class PreferenceManager {
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to preferences manager.
|
||||
* @param folder Folder
|
||||
* @return preference value, default is
|
||||
* @return preference value, default is
|
||||
* {@link com.owncloud.android.ui.fragment.OCFileListFragment#FOLDER_LAYOUT_LIST}
|
||||
*/
|
||||
public static String getFolderLayout(Context context, OCFile folder) {
|
||||
@@ -235,19 +258,57 @@ public final class PreferenceManager {
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @return sort order the sort order, default is {@link FileSortOrder#sort_a_to_z} (sort by name)
|
||||
*/
|
||||
public static FileSortOrder getSortOrder(Context context, OCFile folder) {
|
||||
public static FileSortOrder getSortOrderByFolder(Context context, OCFile folder) {
|
||||
return FileSortOrder.sortOrders.get(getFolderPreference(context, PREF__FOLDER_SORT_ORDER, folder,
|
||||
FileSortOrder.sort_a_to_z.mName));
|
||||
FileSortOrder.sort_a_to_z.name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preferred folder sort order.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param sortOrder the sort order
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param sortOrder the sort order
|
||||
*/
|
||||
public static void setSortOrder(Context context, OCFile folder, FileSortOrder sortOrder) {
|
||||
setFolderPreference(context, PREF__FOLDER_SORT_ORDER, folder, sortOrder.mName);
|
||||
setFolderPreference(context, PREF__FOLDER_SORT_ORDER, folder, sortOrder.name);
|
||||
}
|
||||
|
||||
public static FileSortOrder getSortOrderByType(Context context, FileSortOrder.Type type) {
|
||||
return getSortOrderByType(context, type, FileSortOrder.sort_a_to_z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preferred folder sort order.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @return sort order the sort order, default is {@link FileSortOrder#sort_a_to_z} (sort by name)
|
||||
*/
|
||||
public static FileSortOrder getSortOrderByType(Context context, FileSortOrder.Type type,
|
||||
FileSortOrder defaultOrder) {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
|
||||
if (account == null) {
|
||||
return defaultOrder;
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
String value = dataProvider.getValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type);
|
||||
|
||||
return value.isEmpty() ? defaultOrder : FileSortOrder.sortOrders.get(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preferred folder sort order.
|
||||
*
|
||||
* @param context Caller {@link Context}, used to access to shared preferences manager.
|
||||
* @param sortOrder the sort order
|
||||
*/
|
||||
public static void setSortOrder(Context context, FileSortOrder.Type type, FileSortOrder sortOrder) {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
dataProvider.storeOrUpdateKeyValue(account.name, PREF__FOLDER_SORT_ORDER + "_" + type, sortOrder.name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,14 +328,14 @@ public final class PreferenceManager {
|
||||
if (account == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
FileDataStorageManager storageManager = ((ComponentsGetter)context).getStorageManager();
|
||||
|
||||
if (storageManager == null) {
|
||||
storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
}
|
||||
|
||||
|
||||
String value = dataProvider.getValue(account.name, getKeyFromFolder(preferenceName, folder));
|
||||
while (folder != null && value.isEmpty()) {
|
||||
folder = storageManager.getFileById(folder.getParentId());
|
||||
@@ -283,6 +344,29 @@ public final class PreferenceManager {
|
||||
return value.isEmpty() ? defaultValue : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get preference value for a view.
|
||||
*
|
||||
* @param context Context object.
|
||||
* @param preferenceName Name of the preference to lookup.
|
||||
* @param type view which view
|
||||
* @param defaultValue Fallback value in case nothing is set.
|
||||
* @return Preference value
|
||||
*/
|
||||
public static String getTypePreference(Context context, String preferenceName, String type, String defaultValue) {
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
|
||||
if (account == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
ArbitraryDataProvider dataProvider = new ArbitraryDataProvider(context.getContentResolver());
|
||||
|
||||
String value = dataProvider.getValue(account.name, preferenceName + "_" + type);
|
||||
|
||||
return value.isEmpty() ? defaultValue : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set preference value for a folder.
|
||||
*
|
||||
@@ -300,7 +384,7 @@ public final class PreferenceManager {
|
||||
private static String getKeyFromFolder(String preferenceName, OCFile folder) {
|
||||
final String folderIdString = String.valueOf(folder != null ? folder.getFileId() :
|
||||
FileDataStorageManager.ROOT_PARENT_ID);
|
||||
|
||||
|
||||
return preferenceName + "_" + folderIdString;
|
||||
}
|
||||
|
||||
@@ -449,6 +533,14 @@ public final class PreferenceManager {
|
||||
saveIntPreference(context, AUTO_PREF__LAST_SEEN_VERSION_CODE, versionCode);
|
||||
}
|
||||
|
||||
public static long getLockTimestamp(Context context) {
|
||||
return getDefaultSharedPreferences(context).getLong(PREF__LOCK_TIMESTAMP, 0);
|
||||
}
|
||||
|
||||
public static void setLockTimestamp(Context context, long timestamp) {
|
||||
saveLongPreference(context, PREF__LOCK_TIMESTAMP, timestamp);
|
||||
}
|
||||
|
||||
private static void saveBooleanPreference(Context context, String key, boolean value) {
|
||||
SharedPreferences.Editor appPreferences = getDefaultSharedPreferences(context.getApplicationContext()).edit();
|
||||
appPreferences.putBoolean(key, value).apply();
|
||||
@@ -475,6 +567,11 @@ public final class PreferenceManager {
|
||||
appPreferences.putFloat(key, value).apply();
|
||||
}
|
||||
|
||||
private static void saveLongPreference(Context context, String key, long value) {
|
||||
SharedPreferences.Editor appPreferences = getDefaultSharedPreferences(context.getApplicationContext()).edit();
|
||||
appPreferences.putLong(key, value).apply();
|
||||
}
|
||||
|
||||
public static SharedPreferences getDefaultSharedPreferences(Context context) {
|
||||
return android.preference.PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.owncloud.android.MainApp;
|
||||
public class ProviderMeta {
|
||||
|
||||
public static final String DB_NAME = "filelist";
|
||||
public static final int DB_VERSION = 34;
|
||||
public static final int DB_VERSION = 39;
|
||||
|
||||
private ProviderMeta() {
|
||||
}
|
||||
@@ -103,13 +103,15 @@ public class ProviderMeta {
|
||||
public static final String FILE_FAVORITE = "favorite";
|
||||
public static final String FILE_IS_ENCRYPTED = "is_encrypted";
|
||||
public static final String FILE_MOUNT_TYPE = "mount_type";
|
||||
public static final String FILE_HAS_PREVIEW = "has_preview";
|
||||
|
||||
public static final String [] FILE_ALL_COLUMNS = {_ID, FILE_PARENT, FILE_NAME
|
||||
, FILE_CREATION, FILE_MODIFIED,
|
||||
FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, FILE_CONTENT_LENGTH, FILE_CONTENT_TYPE, FILE_STORAGE_PATH,
|
||||
FILE_PATH, FILE_ACCOUNT_OWNER, FILE_LAST_SYNC_DATE, FILE_LAST_SYNC_DATE_FOR_DATA, FILE_KEEP_IN_SYNC,
|
||||
FILE_ETAG, FILE_SHARED_VIA_LINK, FILE_SHARED_WITH_SHAREE, FILE_PUBLIC_LINK, FILE_PERMISSIONS,
|
||||
FILE_REMOTE_ID, FILE_UPDATE_THUMBNAIL, FILE_IS_DOWNLOADING, FILE_ETAG_IN_CONFLICT, FILE_FAVORITE};
|
||||
FILE_REMOTE_ID, FILE_UPDATE_THUMBNAIL, FILE_IS_DOWNLOADING, FILE_ETAG_IN_CONFLICT, FILE_FAVORITE,
|
||||
FILE_HAS_PREVIEW};
|
||||
|
||||
public static final String FILE_DEFAULT_SORT_ORDER = FILE_NAME + " collate nocase asc";
|
||||
|
||||
@@ -129,6 +131,8 @@ public class ProviderMeta {
|
||||
public static final String OCSHARES_ID_REMOTE_SHARED = "id_remote_shared";
|
||||
public static final String OCSHARES_ACCOUNT_OWNER = "owner_share";
|
||||
public static final String OCSHARES_IS_PASSWORD_PROTECTED = "is_password_protected";
|
||||
public static final String OCSHARES_NOTE = "note";
|
||||
public static final String OCSHARES_HIDE_DOWNLOAD = "hide_download";
|
||||
|
||||
public static final String OCSHARES_DEFAULT_SORT_ORDER = OCSHARES_FILE_SOURCE
|
||||
+ " collate nocase asc";
|
||||
@@ -169,9 +173,11 @@ public class ProviderMeta {
|
||||
public static final String CAPABILITIES_SERVER_SLOGAN = "server_slogan";
|
||||
public static final String CAPABILITIES_SERVER_BACKGROUND_DEFAULT = "background_default";
|
||||
public static final String CAPABILITIES_SERVER_BACKGROUND_PLAIN = "background_plain";
|
||||
|
||||
public static final String CAPABILITIES_END_TO_END_ENCRYPTION = "end_to_end_encryption";
|
||||
public static final String CAPABILITIES_ACTIVITY = "activity";
|
||||
public static final String CAPABILITIES_RICHDOCUMENT = "richdocument";
|
||||
public static final String CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST = "richdocument_mimetype_list";
|
||||
public static final String CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING = "richdocument_direct_editing";
|
||||
|
||||
public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME
|
||||
+ " collate nocase asc";
|
||||
|
||||
@@ -27,15 +27,17 @@ import android.os.Parcelable;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
* @author Tobias Kaminsky
|
||||
*/
|
||||
public class FeatureItem implements Parcelable {
|
||||
private static final int DO_NOT_SHOW = -1;
|
||||
private int image;
|
||||
private int titleText;
|
||||
private int contentText;
|
||||
@Getter private int image;
|
||||
@Getter private int titleText;
|
||||
@Getter private int contentText;
|
||||
private boolean contentCentered;
|
||||
private boolean bulletList;
|
||||
|
||||
@@ -51,26 +53,14 @@ public class FeatureItem implements Parcelable {
|
||||
return image != DO_NOT_SHOW;
|
||||
}
|
||||
|
||||
public int getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public boolean shouldShowTitleText() {
|
||||
return titleText != DO_NOT_SHOW && titleText != R.string.empty;
|
||||
}
|
||||
|
||||
public int getTitleText() {
|
||||
return titleText;
|
||||
}
|
||||
|
||||
public boolean shouldShowContentText() {
|
||||
return contentText != DO_NOT_SHOW && contentText != R.string.empty;
|
||||
}
|
||||
|
||||
public int getContentText() {
|
||||
return contentText;
|
||||
}
|
||||
|
||||
public boolean shouldContentCentered() {
|
||||
return contentCentered;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.files;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CreateFileFromTemplateOperation extends RemoteOperation {
|
||||
private static final String TAG = CreateFileFromTemplateOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String NEW_FROM_TEMPLATE_URL = "/ocs/v2.php/apps/richdocuments/api/v1/templates/new";
|
||||
|
||||
private String path;
|
||||
private int templateId;
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
public CreateFileFromTemplateOperation(String path, int templateId) {
|
||||
this.path = path;
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
|
||||
postMethod = new PostMethod(client.getBaseUri() + NEW_FROM_TEMPLATE_URL + JSON_FORMAT);
|
||||
postMethod.setParameter("path", path);
|
||||
postMethod.setParameter("template", String.valueOf(templateId));
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).getString("url");
|
||||
|
||||
ArrayList<Object> templateArray = new ArrayList<>();
|
||||
templateArray.add(url);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
result.setData(templateArray);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Create file from template " + templateId + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.files;
|
||||
|
||||
import com.owncloud.android.datamodel.Template;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.ChooseTemplateDialogFragment;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class FetchTemplateOperation extends RemoteOperation {
|
||||
private static final String TAG = FetchTemplateOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String TEMPLATE_URL = "/ocs/v2.php/apps/richdocuments/api/v1/templates/";
|
||||
|
||||
private ChooseTemplateDialogFragment.Type type;
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
public FetchTemplateOperation(ChooseTemplateDialogFragment.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
GetMethod getMethod = null;
|
||||
|
||||
try {
|
||||
|
||||
getMethod = new GetMethod(client.getBaseUri() + TEMPLATE_URL + type.toString().toLowerCase(Locale.ENGLISH) +
|
||||
JSON_FORMAT);
|
||||
|
||||
// remote request
|
||||
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(getMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = getMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
JSONArray templates = respJSON.getJSONObject(NODE_OCS).getJSONArray(NODE_DATA);
|
||||
|
||||
ArrayList<Object> templateArray = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < templates.length(); i++) {
|
||||
JSONObject templateObject = templates.getJSONObject(i);
|
||||
|
||||
templateArray.add(new Template(templateObject.getInt("id"),
|
||||
templateObject.getString("name"),
|
||||
templateObject.optString("preview"),
|
||||
templateObject.getString("type"),
|
||||
templateObject.getString("extension")));
|
||||
}
|
||||
|
||||
result = new RemoteOperationResult(true, getMethod);
|
||||
result.setData(templateArray);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, getMethod);
|
||||
client.exhaustResponse(getMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Get templates for typ " + type + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (getMethod != null) {
|
||||
getMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
import com.owncloud.android.ui.activity.RichDocumentsWebView;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -44,7 +45,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Filters out the file actions available in a given {@link Menu} for a given {@link OCFile}
|
||||
* according to the current state of the latest.
|
||||
* according to the current state of the latest.
|
||||
*/
|
||||
public class FileMenuFilter {
|
||||
|
||||
@@ -185,11 +186,13 @@ public class FileMenuFilter {
|
||||
filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled);
|
||||
filterSetPictureAs(toShow, toHide);
|
||||
filterStream(toShow, toHide);
|
||||
filterOpenAsRichDocument(toShow, toHide, capability);
|
||||
}
|
||||
|
||||
private void filterShareFile(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
|
||||
if (containsEncryptedFile() || (!isShareViaLinkAllowed() && !isShareWithUsersAllowed()) ||
|
||||
!isSingleSelection() || !isShareApiEnabled(capability) || mOverflowMenu) {
|
||||
!isSingleSelection() || !isShareApiEnabled(capability) || !mFiles.iterator().next().canReshare()
|
||||
|| mOverflowMenu) {
|
||||
toHide.add(R.id.action_send_share_file);
|
||||
} else {
|
||||
toShow.add(R.id.action_send_share_file);
|
||||
@@ -262,6 +265,16 @@ public class FileMenuFilter {
|
||||
}
|
||||
}
|
||||
|
||||
private void filterOpenAsRichDocument(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
|
||||
if (isSingleFile() && android.os.Build.VERSION.SDK_INT >= RichDocumentsWebView.MINIMUM_API &&
|
||||
capability.getRichDocumentsMimeTypeList().contains(mFiles.iterator().next().getMimeType()) &&
|
||||
capability.getRichDocumentsDirectEditing().isTrue()) {
|
||||
toShow.add(R.id.action_open_file_as_richdocument);
|
||||
} else {
|
||||
toHide.add(R.id.action_open_file_as_richdocument);
|
||||
}
|
||||
}
|
||||
|
||||
private void filterSync(List<Integer> toShow, List<Integer> toHide, boolean synchronizing) {
|
||||
if (mFiles.isEmpty() || (!anyFileDown() && !containsFolder()) || synchronizing) {
|
||||
toHide.add(R.id.action_sync_file);
|
||||
@@ -495,7 +508,7 @@ public class FileMenuFilter {
|
||||
|
||||
private boolean allFavorites() {
|
||||
for (OCFile file : mFiles) {
|
||||
if (!file.getIsFavorite()) {
|
||||
if (!file.isFavorite()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -504,7 +517,7 @@ public class FileMenuFilter {
|
||||
|
||||
private boolean allNotFavorites() {
|
||||
for (OCFile file : mFiles) {
|
||||
if (file.getIsFavorite()) {
|
||||
if (file.isFavorite()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -495,11 +492,11 @@ public class FileDownloader extends Service
|
||||
long syncDate = System.currentTimeMillis();
|
||||
file.setLastSyncDateForProperties(syncDate);
|
||||
file.setLastSyncDateForData(syncDate);
|
||||
file.setNeedsUpdateThumbnail(true);
|
||||
file.setUpdateThumbnailNeeded(true);
|
||||
file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp());
|
||||
file.setModificationTimestampAtLastSyncForData(mCurrentDownload.getModificationTimestamp());
|
||||
file.setEtag(mCurrentDownload.getEtag());
|
||||
file.setMimetype(mCurrentDownload.getMimeType());
|
||||
file.setMimeType(mCurrentDownload.getMimeType());
|
||||
file.setStoragePath(mCurrentDownload.getSavePath());
|
||||
file.setFileLength(new File(mCurrentDownload.getSavePath()).length());
|
||||
file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
|
||||
@@ -531,7 +528,7 @@ public class FileDownloader extends Service
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
mNotificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD);
|
||||
}
|
||||
|
||||
|
||||
/// includes a pending intent in the notification showing the details view of the file
|
||||
Intent showDetailsIntent = null;
|
||||
if (PreviewImageFragment.canBePreviewed(download.getFile())) {
|
||||
@@ -572,7 +569,7 @@ public class FileDownloader extends Service
|
||||
if (mNotificationManager == null) {
|
||||
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
||||
}
|
||||
|
||||
|
||||
if (mNotificationManager != null) {
|
||||
mNotificationManager.notify(R.string.downloader_download_in_progress_ticker,
|
||||
mNotificationBuilder.build());
|
||||
@@ -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 ?
|
||||
|
||||
@@ -961,15 +961,15 @@ public class FileUploader extends Service
|
||||
totalToTransfer, fileName);
|
||||
|
||||
if (MainApp.getAppContext() != null) {
|
||||
if (mCurrentUpload.getIsWifiRequired() && !Device.getNetworkType(MainApp.getAppContext()).
|
||||
if (mCurrentUpload.isWifiRequired() && !Device.getNetworkType(MainApp.getAppContext()).
|
||||
equals(JobRequest.NetworkType.UNMETERED)) {
|
||||
cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
|
||||
, ResultCode.DELAYED_FOR_WIFI);
|
||||
} else if (mCurrentUpload.getIsChargingRequired() &&
|
||||
} else if (mCurrentUpload.isChargingRequired() &&
|
||||
!Device.getBatteryStatus(MainApp.getAppContext()).isCharging()) {
|
||||
cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
|
||||
, ResultCode.DELAYED_FOR_CHARGING);
|
||||
} else if (!mCurrentUpload.getIsIgnoringPowerSaveMode() &&
|
||||
} else if (!mCurrentUpload.isIgnoringPowerSaveMode() &&
|
||||
PowerUtils.isPowerSaveMode(MainApp.getAppContext())) {
|
||||
cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
|
||||
, ResultCode.DELAYED_IN_POWER_SAVE_MODE);
|
||||
|
||||
@@ -88,8 +88,8 @@ public class ContactsImportJob extends Job {
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < intArray.length; i++) {
|
||||
VCard vCard = vCards.get(intArray[i]);
|
||||
for (int checkedItem : intArray) {
|
||||
VCard vCard = vCards.get(checkedItem);
|
||||
if (ContactListFragment.getDisplayName(vCard).length() != 0) {
|
||||
if (!ownContactList.containsKey(vCard)) {
|
||||
operations.insertContact(vCard);
|
||||
|
||||
@@ -68,6 +68,7 @@ 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";
|
||||
private static final String WAKELOCK_TAG_SEPARATION = ":";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
@@ -77,8 +78,9 @@ public class FilesSyncJob extends Job {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
|
||||
wakeLock.acquire();
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG);
|
||||
wakeLock.acquire(10 * 60 * 1000);
|
||||
}
|
||||
|
||||
PersistableBundleCompat bundle = params.getExtras();
|
||||
@@ -130,18 +132,23 @@ public class FilesSyncJob extends Job {
|
||||
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 file = new File(path);
|
||||
file = new File(path);
|
||||
Long lastModificationTime = calculateLastModificationTime(file, syncedFolder, sFormatter);
|
||||
String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(file.getAbsolutePath());
|
||||
|
||||
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);
|
||||
|
||||
@@ -71,10 +71,8 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
String arbitraryDataString;
|
||||
MediaFoldersModel mediaFoldersModel;
|
||||
|
||||
List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1,
|
||||
null, true);
|
||||
List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null,
|
||||
true);
|
||||
List<MediaFolder> imageMediaFolders = MediaProvider.getImageFolders(contentResolver, 1, null, true);
|
||||
List<MediaFolder> videoMediaFolders = MediaProvider.getVideoFolders(contentResolver, 1, null, true);
|
||||
|
||||
List<String> imageMediaFolderPaths = new ArrayList<>();
|
||||
List<String> videoMediaFolderPaths = new ArrayList<>();
|
||||
@@ -109,8 +107,7 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
|
||||
for (Account account : accountList) {
|
||||
for (String imageMediaFolder : imageMediaFolderPaths) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder,
|
||||
account) == null) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(imageMediaFolder, account) == null) {
|
||||
sendNotification(String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_photos)),
|
||||
imageMediaFolder.substring(imageMediaFolder.lastIndexOf('/') + 1,
|
||||
@@ -120,8 +117,7 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
}
|
||||
|
||||
for (String videoMediaFolder : videoMediaFolderPaths) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder,
|
||||
account) == null) {
|
||||
if (syncedFolderProvider.findByLocalPathAndAccount(videoMediaFolder, account) == null) {
|
||||
sendNotification(String.format(context.getString(R.string.new_media_folder_detected),
|
||||
context.getString(R.string.new_media_folder_videos)),
|
||||
videoMediaFolder.substring(videoMediaFolder.lastIndexOf('/') + 1,
|
||||
@@ -134,14 +130,14 @@ public class MediaFoldersDetectionJob extends Job {
|
||||
|
||||
} else {
|
||||
mediaFoldersModel = new MediaFoldersModel(imageMediaFolderPaths, videoMediaFolderPaths);
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(ACCOUNT_NAME_GLOBAL, KEY_MEDIA_FOLDERS, gson.toJson(mediaFoldersModel));
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(ACCOUNT_NAME_GLOBAL, KEY_MEDIA_FOLDERS,
|
||||
gson.toJson(mediaFoldersModel));
|
||||
}
|
||||
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void sendNotification(String contentTitle, String subtitle, Account account,
|
||||
String path, int type) {
|
||||
private void sendNotification(String contentTitle, String subtitle, Account account, String path, int type) {
|
||||
Context context = getContext();
|
||||
Intent intent = new Intent(getContext(), SyncedFoldersActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
@@ -49,6 +49,7 @@ import java.util.Set;
|
||||
public class OfflineSyncJob extends Job {
|
||||
public static final String TAG = "OfflineSyncJob";
|
||||
|
||||
private static final String WAKELOCK_TAG_SEPARATION = ":";
|
||||
private List<OfflineFile> offlineFileList = new ArrayList<>();
|
||||
|
||||
@NonNull
|
||||
@@ -69,8 +70,9 @@ public class OfflineSyncJob extends Job {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
|
||||
wakeLock.acquire();
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG);
|
||||
wakeLock.acquire(10 * 60 * 1000);
|
||||
}
|
||||
|
||||
Cursor cursorOnKeptInSync = context.getContentResolver().query(
|
||||
@@ -84,9 +86,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));
|
||||
|
||||
@@ -40,16 +40,16 @@ import com.owncloud.android.utils.MimeType;
|
||||
* Save the new folder in Database
|
||||
*/
|
||||
public class CreateFolderOperation extends SyncOperation implements OnRemoteOperationListener{
|
||||
|
||||
|
||||
private static final String TAG = CreateFolderOperation.class.getSimpleName();
|
||||
|
||||
|
||||
protected String mRemotePath;
|
||||
private boolean mCreateFullPath;
|
||||
private RemoteFile createdRemoteFolder;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*
|
||||
* @param createFullPath 'True' means that all the ancestor folders should be created
|
||||
* if don't exist yet.
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
CreateRemoteFolderOperation operation = new CreateRemoteFolderOperation(mRemotePath, mCreateFullPath);
|
||||
RemoteOperationResult result = operation.execute(client, true);
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
ReadRemoteFolderOperation remoteFolderOperation = new ReadRemoteFolderOperation(mRemotePath);
|
||||
RemoteOperationResult remoteFolderOperationResult = remoteFolderOperation.execute(client, true);
|
||||
@@ -73,7 +73,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
} else {
|
||||
Log_OC.e(TAG, mRemotePath + " hasn't been created");
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
onCreateRemoteFolderOperationFinish(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onCreateRemoteFolderOperationFinish(RemoteOperationResult result) {
|
||||
if (result.isSuccess()) {
|
||||
saveFolderInDB();
|
||||
@@ -99,7 +99,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
if (mCreateFullPath && getStorageManager().
|
||||
getFileByPath(FileStorageUtils.getParentPath(mRemotePath)) == null){// When parent
|
||||
// of remote path
|
||||
// is not created
|
||||
// is not created
|
||||
String[] subFolders = mRemotePath.split("/");
|
||||
String composedRemotePath = "/";
|
||||
|
||||
@@ -113,7 +113,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
|
||||
}
|
||||
} else { // Create directory on DB
|
||||
OCFile newDir = new OCFile(mRemotePath);
|
||||
newDir.setMimetype(MimeType.DIRECTORY);
|
||||
newDir.setMimeType(MimeType.DIRECTORY);
|
||||
long parentId = getStorageManager().getFileByPath(FileStorageUtils.getParentPath(mRemotePath)).getFileId();
|
||||
newDir.setParentId(parentId);
|
||||
newDir.setRemoteId(createdRemoteFolder.getRemoteId());
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
createOp.setGetShareDetails(true);
|
||||
result = createOp.execute(client);
|
||||
}
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (result.getData().size() > 0) {
|
||||
Object item = result.getData().get(0);
|
||||
@@ -106,10 +106,10 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
}
|
||||
@@ -128,12 +128,12 @@ public class CreateShareViaLinkOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
getStorageManager().saveShare(share);
|
||||
|
||||
|
||||
// Update OCFile with data from share: ShareByLink and publicLink
|
||||
OCFile file = getStorageManager().getFileByPath(mPath);
|
||||
if (file!=null) {
|
||||
file.setPublicLink(share.getShareLink());
|
||||
file.setShareViaLink(true);
|
||||
file.setSharedViaLink(true);
|
||||
getStorageManager().saveFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author masensio
|
||||
@@ -31,6 +31,10 @@ import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Creates a new private share for a given file.
|
||||
*/
|
||||
@@ -43,6 +47,9 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
private ShareType mShareType;
|
||||
private int mPermissions;
|
||||
|
||||
private static final List<ShareType> supportedShareTypes = new ArrayList<>(Arrays.asList(ShareType.USER,
|
||||
ShareType.GROUP, ShareType.FEDERATED, ShareType.EMAIL, ShareType.ROOM));
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -54,8 +61,7 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
* https://doc.owncloud.org/server/8.2/developer_manual/core/ocs-share-api.html .
|
||||
*/
|
||||
public CreateShareWithShareeOperation(String path, String shareeName, ShareType shareType, int permissions) {
|
||||
if (!ShareType.USER.equals(shareType) && !ShareType.GROUP.equals(shareType)
|
||||
&& !ShareType.FEDERATED.equals(shareType) && !ShareType.EMAIL.equals(shareType)) {
|
||||
if (!supportedShareTypes.contains(shareType)) {
|
||||
throw new IllegalArgumentException("Illegal share type " + shareType);
|
||||
}
|
||||
mPath = path;
|
||||
@@ -78,15 +84,15 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
operation.setGetShareDetails(true);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
|
||||
|
||||
|
||||
if (result.isSuccess() && result.getData().size() > 0) {
|
||||
OCShare share = (OCShare) result.getData().get(0);
|
||||
updateData(share);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
}
|
||||
@@ -97,13 +103,12 @@ public class CreateShareWithShareeOperation extends SyncOperation {
|
||||
share.setIsFolder(mPath.endsWith(FileUtils.PATH_SEPARATOR));
|
||||
|
||||
getStorageManager().saveShare(share);
|
||||
|
||||
|
||||
// Update OCFile with data from share: ShareByLink and publicLink
|
||||
OCFile file = getStorageManager().getFileByPath(mPath);
|
||||
if (file!=null) {
|
||||
file.setShareWithSharee(true); // TODO - this should be done by the FileContentProvider, as part of getStorageManager().saveShare(share)
|
||||
file.setSharedWithSharee(true); // TODO - this should be done by the FileContentProvider, as part of getStorageManager().saveShare(share)
|
||||
getStorageManager().saveFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -144,8 +144,7 @@ public class DownloadFileOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
public long getModificationTimestamp() {
|
||||
return (mModificationTimestamp > 0) ? mModificationTimestamp :
|
||||
mFile.getModificationTimestamp();
|
||||
return mModificationTimestamp > 0 ? mModificationTimestamp : mFile.getModificationTimestamp();
|
||||
}
|
||||
|
||||
public String getEtag() {
|
||||
|
||||
@@ -82,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);
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ import java.util.Vector;
|
||||
|
||||
|
||||
/**
|
||||
* Remote operation performing the synchronization of the list of files contained
|
||||
* Remote operation performing the synchronization of the list of files contained
|
||||
* in a folder identified with its remote path.
|
||||
*
|
||||
* Fetches the list and properties of the files contained in the given folder, including their
|
||||
* Fetches the list and properties of the files contained in the given folder, including their
|
||||
* properties, and updates the local database with them.
|
||||
*
|
||||
* Does NOT enter in the child folders to synchronize their contents also.
|
||||
@@ -97,8 +97,8 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
private int mFailsInKeptInSyncFound;
|
||||
|
||||
/**
|
||||
* Map of remote and local paths to files that where locally stored in a location
|
||||
* out of the ownCloud folder and couldn't be copied automatically into it
|
||||
* Map of remote and local paths to files that where locally stored in a location
|
||||
* out of the ownCloud folder and couldn't be copied automatically into it
|
||||
**/
|
||||
private Map<String, String> mForgottenLocalFiles;
|
||||
|
||||
@@ -122,13 +122,13 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
*
|
||||
* @param folder Folder to synchronize.
|
||||
* @param currentSyncTime Time stamp for the synchronization process in progress.
|
||||
* @param syncFullAccount 'True' means that this operation is part of a full account
|
||||
* @param syncFullAccount 'True' means that this operation is part of a full account
|
||||
* synchronization.
|
||||
* @param ignoreETag 'True' means that the content of the remote folder should
|
||||
* be fetched and updated even though the 'eTag' did not
|
||||
* change.
|
||||
* be fetched and updated even though the 'eTag' did not
|
||||
* change.
|
||||
* @param dataStorageManager Interface with the local database.
|
||||
* @param account ownCloud account where the folder is located.
|
||||
* @param account ownCloud account where the folder is located.
|
||||
* @param context Application context.
|
||||
*/
|
||||
public RefreshFolderOperation(OCFile folder,
|
||||
@@ -163,7 +163,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of files and folders contained in the synchronized folder,
|
||||
* Returns the list of files and folders contained in the synchronized folder,
|
||||
* if called after synchronization is complete.
|
||||
*
|
||||
* @return List of files and folders contained in the synchronized folder.
|
||||
@@ -215,7 +215,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
if (result.isSuccess() && !mSyncFullAccount) {
|
||||
refreshSharesForFolder(client); // share result is ignored
|
||||
refreshSharesForFolder(client); // share result is ignored
|
||||
}
|
||||
|
||||
if (!mSyncFullAccount) {
|
||||
@@ -262,7 +262,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
|
||||
Log_OC.d(TAG, "Checking changes in " + mAccount.name + remotePath);
|
||||
|
||||
// remote request
|
||||
// remote request
|
||||
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
|
||||
result = operation.execute(client, true);
|
||||
if (result.isSuccess()) {
|
||||
@@ -349,7 +349,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
// get 'fresh data' from the database
|
||||
mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
|
||||
|
||||
// parse data from remote folder
|
||||
// parse data from remote folder
|
||||
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) folderAndFiles.get(0));
|
||||
remoteFolder.setParentId(mLocalFolder.getParentId());
|
||||
remoteFolder.setFileId(mLocalFolder.getFileId());
|
||||
@@ -387,7 +387,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
updatedFile = FileStorageUtils.fillOCFile(r);
|
||||
updatedFile.setParentId(mLocalFolder.getFileId());
|
||||
|
||||
// retrieve local data for the read file
|
||||
// retrieve local data for the read file
|
||||
localFile = localFilesMap.remove(remoteFile.getRemotePath());
|
||||
|
||||
// add to updatedFile data about LOCAL STATE (not existing in server)
|
||||
@@ -414,7 +414,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
// we parse content, so either the folder itself or its direct parent (which we check) must be encrypted
|
||||
boolean encrypted = updatedFile.isEncrypted() || mLocalFolder.isEncrypted();
|
||||
updatedFile.setEncrypted(encrypted);
|
||||
|
||||
|
||||
updatedFiles.add(updatedFile);
|
||||
}
|
||||
|
||||
@@ -444,9 +444,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
updatedFile.setFileName(decryptedFileName);
|
||||
|
||||
if (mimetype == null || mimetype.isEmpty()) {
|
||||
updatedFile.setMimetype("application/octet-stream");
|
||||
updatedFile.setMimeType("application/octet-stream");
|
||||
} else {
|
||||
updatedFile.setMimetype(mimetype);
|
||||
updatedFile.setMimeType(mimetype);
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
Log_OC.e(TAG, "Metadata for file " + updatedFile.getFileId() + " not found!");
|
||||
@@ -477,13 +477,13 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
} else if (remoteFolderChanged && MimeTypeUtil.isImage(remoteFile) &&
|
||||
remoteFile.getModificationTimestamp() !=
|
||||
localFile.getModificationTimestamp()) {
|
||||
updatedFile.setNeedsUpdateThumbnail(true);
|
||||
updatedFile.setUpdateThumbnailNeeded(true);
|
||||
Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
|
||||
}
|
||||
|
||||
updatedFile.setPublicLink(localFile.getPublicLink());
|
||||
updatedFile.setShareViaLink(localFile.isSharedViaLink());
|
||||
updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
|
||||
updatedFile.setSharedViaLink(localFile.isSharedViaLink());
|
||||
updatedFile.setSharedWithSharee(localFile.isSharedWithSharee());
|
||||
} else {
|
||||
// remote eTag will not be updated unless file CONTENTS are synchronized
|
||||
updatedFile.setEtag("");
|
||||
@@ -509,7 +509,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
* Performs a list of synchronization operations, determining if a download or upload is needed
|
||||
* or if exists conflict due to changes both in local and remote contents of the each file.
|
||||
*
|
||||
* If download or upload is needed, request the operation to the corresponding service and goes
|
||||
* If download or upload is needed, request the operation to the corresponding service and goes
|
||||
* on.
|
||||
*
|
||||
* @param filesToSyncContents Synchronization operations to execute.
|
||||
@@ -545,7 +545,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
|
||||
// remote request
|
||||
// remote request
|
||||
GetRemoteSharesForFileOperation operation =
|
||||
new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), true, true);
|
||||
result = operation.execute(client);
|
||||
|
||||
@@ -81,7 +81,7 @@ public class RenameFileOperation extends SyncOperation {
|
||||
if (!isValidNewName()) {
|
||||
return new RemoteOperationResult(ResultCode.INVALID_LOCAL_FILE_NAME);
|
||||
}
|
||||
String parent = (new File(mFile.getRemotePath())).getParent();
|
||||
String parent = new File(mFile.getRemotePath()).getParent();
|
||||
parent = parent.endsWith(OCFile.PATH_SEPARATOR) ? parent : parent + OCFile.PATH_SEPARATOR;
|
||||
mNewRemotePath = parent + mNewName;
|
||||
if (mFile.isFolder()) {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.operations;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Create asset for RichDocuments app from file, which is already stored on Nextcloud server
|
||||
*/
|
||||
|
||||
public class RichDocumentsCreateAssetOperation extends RemoteOperation {
|
||||
private static final String TAG = RichDocumentsCreateAssetOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String ASSET_URL = "/apps/richdocuments/assets";
|
||||
|
||||
private static final String NODE_URL = "url";
|
||||
private static final String PARAMETER_PATH = "path";
|
||||
private static final String PARAMETER_FORMAT = "format";
|
||||
private static final String PARAMETER_FORMAT_VALUE = "json";
|
||||
|
||||
private String path;
|
||||
|
||||
public RichDocumentsCreateAssetOperation(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
postMethod = new PostMethod(client.getBaseUri() + ASSET_URL);
|
||||
postMethod.setParameter(PARAMETER_PATH, path);
|
||||
postMethod.setParameter(PARAMETER_FORMAT, PARAMETER_FORMAT_VALUE);
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getString(NODE_URL);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
result.setSingleData(url);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Create asset for richdocuments with path " + path + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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.operations;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Edit a file with Richdocuments. Returns URL which can be shown in WebView.
|
||||
*/
|
||||
public class RichDocumentsUrlOperation extends RemoteOperation {
|
||||
private static final String TAG = RichDocumentsUrlOperation.class.getSimpleName();
|
||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||
private static final String DOCUMENT_URL = "/ocs/v2.php/apps/richdocuments/api/v1/document";
|
||||
private static final String FILE_ID = "fileId";
|
||||
|
||||
// JSON node names
|
||||
private static final String NODE_OCS = "ocs";
|
||||
private static final String NODE_DATA = "data";
|
||||
private static final String NODE_URL = "url";
|
||||
private static final String JSON_FORMAT = "?format=json";
|
||||
|
||||
private String fileID;
|
||||
|
||||
public RichDocumentsUrlOperation(String fileID) {
|
||||
this.fileID = fileID;
|
||||
}
|
||||
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
PostMethod postMethod = null;
|
||||
|
||||
try {
|
||||
postMethod = new PostMethod(client.getBaseUri() + DOCUMENT_URL + JSON_FORMAT);
|
||||
postMethod.setParameter(FILE_ID, fileID);
|
||||
|
||||
// remote request
|
||||
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
|
||||
|
||||
int status = client.executeMethod(postMethod, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
|
||||
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
String response = postMethod.getResponseBodyAsString();
|
||||
|
||||
// Parse the response
|
||||
JSONObject respJSON = new JSONObject(response);
|
||||
String url = respJSON.getJSONObject(NODE_OCS).getJSONObject(NODE_DATA).getString(NODE_URL);
|
||||
|
||||
result = new RemoteOperationResult(true, postMethod);
|
||||
result.setSingleData(url);
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, postMethod);
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
Log_OC.e(TAG, "Get rich document url for file with id " + fileID + " failed: " + result.getLogMessage(),
|
||||
result.getException());
|
||||
} finally {
|
||||
if (postMethod != null) {
|
||||
postMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -211,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) {
|
||||
@@ -246,7 +245,7 @@ public class SynchronizeFileOperation extends SyncOperation {
|
||||
// service when the upload finishes
|
||||
} else {
|
||||
// TODO CHECK: is this really useful in some point in the code?
|
||||
mServerFile.setFavorite(mLocalFile.getIsFavorite());
|
||||
mServerFile.setFavorite(mLocalFile.isFavorite());
|
||||
mServerFile.setAvailableOffline(mLocalFile.isAvailableOffline());
|
||||
mServerFile.setLastSyncDateForData(mLocalFile.getLastSyncDateForData());
|
||||
mServerFile.setStoragePath(mLocalFile.getStoragePath());
|
||||
|
||||
@@ -50,12 +50,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
||||
/**
|
||||
* Remote operation performing the synchronization of the list of files contained
|
||||
* Remote operation performing the synchronization of the list of files contained
|
||||
* in a folder identified with its remote path.
|
||||
*
|
||||
* Fetches the list and properties of the files contained in the given folder, including their
|
||||
*
|
||||
* Fetches the list and properties of the files contained in the given folder, including their
|
||||
* properties, and updates the local database with them.
|
||||
*
|
||||
*
|
||||
* Does NOT enter in the child folders to synchronize their contents also, BUT requests for a new operation instance
|
||||
* doing so.
|
||||
*/
|
||||
@@ -68,7 +68,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
|
||||
/** Remote path of the folder to synchronize */
|
||||
private String mRemotePath;
|
||||
|
||||
|
||||
/** Account where the file to synchronize belongs */
|
||||
private Account mAccount;
|
||||
|
||||
@@ -92,9 +92,9 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
|
||||
private List<OCFile> mFilesForDirectDownload;
|
||||
// to avoid extra PROPFINDs when there was no change in the folder
|
||||
|
||||
|
||||
private List<SyncOperation> mFilesToSyncContents;
|
||||
// this will be used for every file when 'folder synchronization' replaces 'folder download'
|
||||
// this will be used for every file when 'folder synchronization' replaces 'folder download'
|
||||
|
||||
private final AtomicBoolean mCancellationRequested;
|
||||
|
||||
@@ -137,30 +137,30 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
RemoteOperationResult result = null;
|
||||
mFailsInFileSyncsFound = 0;
|
||||
mConflictsFound = 0;
|
||||
|
||||
|
||||
try {
|
||||
// get locally cached information about folder
|
||||
mLocalFolder = getStorageManager().getFileByPath(mRemotePath);
|
||||
|
||||
// get locally cached information about folder
|
||||
mLocalFolder = getStorageManager().getFileByPath(mRemotePath);
|
||||
|
||||
result = checkForChanges(client);
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (mRemoteFolderChanged) {
|
||||
result = fetchAndSyncRemoteFolder(client);
|
||||
|
||||
|
||||
} else {
|
||||
prepareOpsFromLocalKnowledge();
|
||||
}
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
syncContents();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mCancellationRequested.get()) {
|
||||
throw new OperationCancelledException();
|
||||
}
|
||||
|
||||
|
||||
} catch (OperationCancelledException e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
}
|
||||
@@ -172,11 +172,11 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
Log_OC.d(TAG, "Checking changes in " + mAccount.name + mRemotePath);
|
||||
|
||||
mRemoteFolderChanged = true;
|
||||
|
||||
|
||||
if (mCancellationRequested.get()) {
|
||||
throw new OperationCancelledException();
|
||||
}
|
||||
|
||||
|
||||
// remote request
|
||||
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mRemotePath);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
@@ -214,7 +214,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
if (mCancellationRequested.get()) {
|
||||
throw new OperationCancelledException();
|
||||
}
|
||||
|
||||
|
||||
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(mRemotePath);
|
||||
RemoteOperationResult result = operation.execute(client);
|
||||
Log_OC.d(TAG, "Synchronizing " + mAccount.name + mRemotePath);
|
||||
@@ -242,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)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -308,7 +306,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
|
||||
/// check and fix, if needed, local storage path
|
||||
searchForLocalFileInDefaultPath(updatedFile);
|
||||
|
||||
|
||||
/// classify file to sync/download contents later
|
||||
classifyFileForLaterSyncOrDownload(remoteFile, localFile);
|
||||
|
||||
@@ -337,12 +335,12 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
} else if (mRemoteFolderChanged && MimeTypeUtil.isImage(remoteFile) &&
|
||||
remoteFile.getModificationTimestamp() !=
|
||||
localFile.getModificationTimestamp()) {
|
||||
updatedFile.setNeedsUpdateThumbnail(true);
|
||||
updatedFile.setUpdateThumbnailNeeded(true);
|
||||
Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
|
||||
}
|
||||
updatedFile.setPublicLink(localFile.getPublicLink());
|
||||
updatedFile.setShareViaLink(localFile.isSharedViaLink());
|
||||
updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
|
||||
updatedFile.setSharedViaLink(localFile.isSharedViaLink());
|
||||
updatedFile.setSharedWithSharee(localFile.isSharedWithSharee());
|
||||
updatedFile.setEtagInConflict(localFile.getEtagInConflict());
|
||||
} else {
|
||||
// remote eTag will not be updated unless file CONTENTS are synchronized
|
||||
@@ -397,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
|
||||
@@ -416,7 +414,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
startContentSynchronizations(mFilesToSyncContents);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void startDirectDownloads() throws OperationCancelledException {
|
||||
for (OCFile file : mFilesForDirectDownload) {
|
||||
synchronized(mCancellationRequested) {
|
||||
@@ -475,7 +473,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
* Scans the default location for saving local copies of files searching for
|
||||
* a 'lost' file with the same full name as the {@link com.owncloud.android.datamodel.OCFile}
|
||||
* received as parameter.
|
||||
*
|
||||
*
|
||||
* @param file File to associate a possible 'lost' local file.
|
||||
*/
|
||||
private void searchForLocalFileInDefaultPath(OCFile file) {
|
||||
@@ -488,7 +486,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cancel operation
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,7 @@ public class UnshareOperation extends SyncOperation {
|
||||
private ShareType mShareType;
|
||||
private String mShareWith;
|
||||
private Context mContext;
|
||||
|
||||
|
||||
public UnshareOperation(String remotePath, ShareType shareType, String shareWith,
|
||||
Context context) {
|
||||
mRemotePath = remotePath;
|
||||
@@ -61,11 +61,11 @@ public class UnshareOperation extends SyncOperation {
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
RemoteOperationResult result = null;
|
||||
|
||||
|
||||
// Get Share for a file
|
||||
OCShare share = getStorageManager().getFirstShareByPathAndType(mRemotePath,
|
||||
mShareType, mShareWith);
|
||||
|
||||
|
||||
if (share != null) {
|
||||
OCFile file = getStorageManager().getFileByPath(mRemotePath);
|
||||
RemoveRemoteShareOperation operation =
|
||||
@@ -76,7 +76,7 @@ public class UnshareOperation extends SyncOperation {
|
||||
Log_OC.d(TAG, "Share id = " + share.getRemoteId() + " deleted");
|
||||
|
||||
if (ShareType.PUBLIC_LINK.equals(mShareType)) {
|
||||
file.setShareViaLink(false);
|
||||
file.setSharedViaLink(false);
|
||||
file.setPublicLink("");
|
||||
} else if (ShareType.USER.equals(mShareType) || ShareType.GROUP.equals(mShareType)
|
||||
|| ShareType.FEDERATED.equals(mShareType)){
|
||||
@@ -85,7 +85,7 @@ public class UnshareOperation extends SyncOperation {
|
||||
getSharesWithForAFile(mRemotePath,
|
||||
getStorageManager().getAccount().name);
|
||||
if (sharesWith.size() == SINGLY_SHARED) {
|
||||
file.setShareWithSharee(false);
|
||||
file.setSharedWithSharee(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class UnshareOperation extends SyncOperation {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private boolean existsFile(OwnCloudClient client, String remotePath){
|
||||
ExistenceCheckRemoteOperation existsOperation =
|
||||
new ExistenceCheckRemoteOperation(remotePath, mContext, false);
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.operations;
|
||||
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.resources.shares.GetRemoteShareOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.UpdateRemoteShareOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
|
||||
|
||||
/**
|
||||
* Updates a note of a private share.
|
||||
*/
|
||||
public class UpdateNoteForShareOperation extends SyncOperation {
|
||||
|
||||
private long shareId;
|
||||
private String note;
|
||||
|
||||
public UpdateNoteForShareOperation(long shareId, String note) {
|
||||
this.shareId = shareId;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
|
||||
OCShare share = getStorageManager().getShareById(shareId);
|
||||
|
||||
if (share == null) {
|
||||
return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
}
|
||||
|
||||
UpdateRemoteShareOperation updateOperation = new UpdateRemoteShareOperation(share.getRemoteId());
|
||||
updateOperation.setNote(note);
|
||||
RemoteOperationResult result = updateOperation.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
RemoteOperation getShareOp = new GetRemoteShareOperation(share.getRemoteId());
|
||||
result = getShareOp.execute(client);
|
||||
if (result.isSuccess()) {
|
||||
getStorageManager().saveShare((OCShare) result.getData().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -37,10 +37,11 @@ import com.owncloud.android.operations.common.SyncOperation;
|
||||
*/
|
||||
public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
|
||||
private String mPath;
|
||||
private String mPassword;
|
||||
private Boolean mPublicUpload;
|
||||
private long mExpirationDateInMillis;
|
||||
private String path;
|
||||
private String password;
|
||||
private Boolean publicUpload;
|
||||
private Boolean hideFileDownload;
|
||||
private long expirationDateInMillis;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -48,8 +49,8 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
* @param path Full path of the file/folder being shared. Mandatory argument
|
||||
*/
|
||||
public UpdateShareViaLinkOperation(String path) {
|
||||
mPath = path;
|
||||
mExpirationDateInMillis = 0;
|
||||
this.path = path;
|
||||
expirationDateInMillis = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
* Null results in no update applied to the password.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
mPassword = password;
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +73,11 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
* the expiration date.
|
||||
*/
|
||||
public void setExpirationDate(long expirationDateInMillis) {
|
||||
mExpirationDateInMillis = expirationDateInMillis;
|
||||
this.expirationDateInMillis = expirationDateInMillis;
|
||||
}
|
||||
|
||||
public void setHideFileDownload(boolean hideFileDownload) {
|
||||
this.hideFileDownload = hideFileDownload;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,32 +87,23 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
* Null results in no update applied to the upload permission.
|
||||
*/
|
||||
public void setPublicUpload(Boolean publicUpload) {
|
||||
mPublicUpload = publicUpload;
|
||||
this.publicUpload = publicUpload;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||
|
||||
OCShare publicShare = getStorageManager().getFirstShareByPathAndType(
|
||||
mPath,
|
||||
ShareType.PUBLIC_LINK,
|
||||
""
|
||||
);
|
||||
OCShare publicShare = getStorageManager().getFirstShareByPathAndType(path, ShareType.PUBLIC_LINK, "");
|
||||
|
||||
if (publicShare == null) {
|
||||
// TODO try to get remote share before failing?
|
||||
return new RemoteOperationResult(
|
||||
RemoteOperationResult.ResultCode.SHARE_NOT_FOUND
|
||||
);
|
||||
return new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
|
||||
}
|
||||
|
||||
// Update remote share with password
|
||||
UpdateRemoteShareOperation updateOp = new UpdateRemoteShareOperation(
|
||||
publicShare.getRemoteId()
|
||||
);
|
||||
updateOp.setPassword(mPassword);
|
||||
updateOp.setExpirationDate(mExpirationDateInMillis);
|
||||
updateOp.setPublicUpload(mPublicUpload);
|
||||
UpdateRemoteShareOperation updateOp = new UpdateRemoteShareOperation(publicShare.getRemoteId());
|
||||
updateOp.setPassword(password);
|
||||
updateOp.setExpirationDate(expirationDateInMillis);
|
||||
updateOp.setPublicUpload(publicUpload);
|
||||
updateOp.setHideFileDownload(hideFileDownload);
|
||||
RemoteOperationResult result = updateOp.execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
@@ -124,17 +120,17 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return mPath;
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return mPassword;
|
||||
return password;
|
||||
}
|
||||
|
||||
private void updateData(OCShare share) {
|
||||
// Update DB with the response
|
||||
share.setPath(mPath);
|
||||
if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
|
||||
share.setPath(path);
|
||||
if (path.endsWith(FileUtils.PATH_SEPARATOR)) {
|
||||
share.setIsFolder(true);
|
||||
} else {
|
||||
share.setIsFolder(false);
|
||||
@@ -144,12 +140,11 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
|
||||
|
||||
// Update OCFile with data from share: ShareByLink and publicLink
|
||||
// TODO check & remove if not needed
|
||||
OCFile file = getStorageManager().getFileByPath(mPath);
|
||||
OCFile file = getStorageManager().getFileByPath(path);
|
||||
if (file != null) {
|
||||
file.setPublicLink(share.getShareLink());
|
||||
file.setShareViaLink(true);
|
||||
file.setSharedViaLink(true);
|
||||
getStorageManager().saveFile(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
// are checked when the UploadFileOperation instance is created
|
||||
|
||||
|
||||
newFile.setMimetype(mimeType);
|
||||
newFile.setMimeType(mimeType);
|
||||
|
||||
return newFile;
|
||||
}
|
||||
@@ -215,19 +215,19 @@ 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();
|
||||
}
|
||||
|
||||
public boolean getIsWifiRequired() {
|
||||
public boolean isWifiRequired() {
|
||||
return mOnWifiOnly;
|
||||
}
|
||||
|
||||
public boolean getIsChargingRequired() {
|
||||
public boolean isChargingRequired() {
|
||||
return mWhileChargingOnly;
|
||||
}
|
||||
|
||||
public boolean getIsIgnoringPowerSaveMode() { return mIgnoringPowerSaveMode; }
|
||||
public boolean isIgnoringPowerSaveMode() { return mIgnoringPowerSaveMode; }
|
||||
|
||||
public Account getAccount() {
|
||||
return mAccount;
|
||||
@@ -385,7 +385,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
// parent file is not null anymore:
|
||||
// - it was created on fresh upload or
|
||||
// - resume of encrypted upload, then parent file exists already as unlock is only for direct parent
|
||||
|
||||
|
||||
mFile.setParentId(parent.getFileId());
|
||||
|
||||
// try to unlock folder with stored token, e.g. when upload needs to be resumed or app crashed
|
||||
@@ -436,7 +436,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
String publicKey = arbitraryDataProvider.getValue(getAccount().name, EncryptionUtils.PUBLIC_KEY);
|
||||
|
||||
try {
|
||||
// check conditions
|
||||
// check conditions
|
||||
result = checkConditions(originalFile);
|
||||
|
||||
if (result != null) {
|
||||
@@ -450,7 +450,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
|
||||
if (lockFileOperationResult.isSuccess()) {
|
||||
token = (String) lockFileOperationResult.getData().get(0);
|
||||
// immediately store it
|
||||
// immediately store it
|
||||
mUpload.setFolderUnlockToken(token);
|
||||
uploadsStorageManager.updateUpload(mUpload);
|
||||
} else if (lockFileOperationResult.getHttpCode() == HttpStatus.SC_FORBIDDEN) {
|
||||
@@ -721,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);
|
||||
}
|
||||
@@ -1027,7 +1027,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
}
|
||||
if (parent != null) {
|
||||
OCFile createdFolder = new OCFile(remotePath);
|
||||
createdFolder.setMimetype(MimeType.DIRECTORY);
|
||||
createdFolder.setMimeType(MimeType.DIRECTORY);
|
||||
createdFolder.setParentId(parent.getFileId());
|
||||
getStorageManager().saveFile(createdFolder);
|
||||
return createdFolder;
|
||||
@@ -1047,7 +1047,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
OCFile newFile = new OCFile(newRemotePath);
|
||||
newFile.setCreationTimestamp(mFile.getCreationTimestamp());
|
||||
newFile.setFileLength(mFile.getFileLength());
|
||||
newFile.setMimetype(mFile.getMimeType());
|
||||
newFile.setMimeType(mFile.getMimeType());
|
||||
newFile.setModificationTimestamp(mFile.getModificationTimestamp());
|
||||
newFile.setModificationTimestampAtLastSyncForData(
|
||||
mFile.getModificationTimestampAtLastSyncForData()
|
||||
@@ -1332,7 +1332,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
// coincidence; nothing else is needed, the storagePath is right
|
||||
// in the instance returned by mCurrentUpload.getFile()
|
||||
}
|
||||
file.setNeedsUpdateThumbnail(true);
|
||||
file.setUpdateThumbnailNeeded(true);
|
||||
getStorageManager().saveFile(file);
|
||||
getStorageManager().saveConflict(file, null);
|
||||
|
||||
@@ -1347,7 +1347,7 @@ public class UploadFileOperation extends SyncOperation {
|
||||
private void updateOCFile(OCFile file, RemoteFile remoteFile) {
|
||||
file.setCreationTimestamp(remoteFile.getCreationTimestamp());
|
||||
file.setFileLength(remoteFile.getLength());
|
||||
file.setMimetype(remoteFile.getMimeType());
|
||||
file.setMimeType(remoteFile.getMimeType());
|
||||
file.setModificationTimestamp(remoteFile.getModifiedTimestamp());
|
||||
file.setModificationTimestampAtLastSyncForData(remoteFile.getModifiedTimestamp());
|
||||
file.setEtag(remoteFile.getEtag());
|
||||
|
||||
@@ -404,19 +404,25 @@ public class FileContentProvider extends ContentProvider {
|
||||
SQLiteDatabase db, ContentValues newShare
|
||||
) {
|
||||
ContentValues fileValues = new ContentValues();
|
||||
int newShareType = newShare.getAsInteger(ProviderTableMeta.OCSHARES_SHARE_TYPE);
|
||||
if (newShareType == ShareType.PUBLIC_LINK.getValue()) {
|
||||
fileValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, 1);
|
||||
} else if (
|
||||
newShareType == ShareType.USER.getValue() ||
|
||||
newShareType == ShareType.GROUP.getValue() ||
|
||||
newShareType == ShareType.EMAIL.getValue() ||
|
||||
newShareType == ShareType.FEDERATED.getValue()) {
|
||||
fileValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, 1);
|
||||
ShareType newShareType = ShareType.fromValue(newShare.getAsInteger(ProviderTableMeta.OCSHARES_SHARE_TYPE));
|
||||
|
||||
switch (newShareType) {
|
||||
case PUBLIC_LINK:
|
||||
fileValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, 1);
|
||||
break;
|
||||
case USER:
|
||||
case GROUP:
|
||||
case EMAIL:
|
||||
case FEDERATED:
|
||||
case ROOM:
|
||||
fileValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
// everything should be handled
|
||||
}
|
||||
|
||||
String where = ProviderTableMeta.FILE_PATH + "=? AND " +
|
||||
ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
||||
String where = ProviderTableMeta.FILE_PATH + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
||||
String[] whereArgs = new String[]{
|
||||
newShare.getAsString(ProviderTableMeta.OCSHARES_PATH),
|
||||
newShare.getAsString(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER)
|
||||
@@ -742,7 +748,8 @@ public class FileContentProvider extends ContentProvider {
|
||||
+ ProviderTableMeta.FILE_IS_ENCRYPTED + INTEGER // boolean
|
||||
+ ProviderTableMeta.FILE_ETAG_IN_CONFLICT + TEXT
|
||||
+ ProviderTableMeta.FILE_SHARED_WITH_SHAREE + INTEGER
|
||||
+ ProviderTableMeta.FILE_MOUNT_TYPE + " INTEGER);"
|
||||
+ ProviderTableMeta.FILE_MOUNT_TYPE + INTEGER
|
||||
+ ProviderTableMeta.FILE_HAS_PREVIEW + " INTEGER);"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -764,7 +771,9 @@ public class FileContentProvider extends ContentProvider {
|
||||
+ ProviderTableMeta.OCSHARES_USER_ID + INTEGER
|
||||
+ ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + INTEGER
|
||||
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + TEXT
|
||||
+ ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED + " INTEGER );");
|
||||
+ ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED + INTEGER
|
||||
+ ProviderTableMeta.OCSHARES_NOTE + TEXT
|
||||
+ ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD + " INTEGER );");
|
||||
}
|
||||
|
||||
private void createCapabilitiesTable(SQLiteDatabase db) {
|
||||
@@ -804,7 +813,10 @@ public class FileContentProvider extends ContentProvider {
|
||||
+ ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_ACTIVITY + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_DEFAULT + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN + " INTEGER );");
|
||||
+ ProviderTableMeta.CAPABILITIES_SERVER_BACKGROUND_PLAIN + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT + INTEGER
|
||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST + TEXT
|
||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING + " INTEGER );");
|
||||
}
|
||||
|
||||
private void createUploadsTable(SQLiteDatabase db) {
|
||||
@@ -1739,6 +1751,98 @@ public class FileContentProvider extends ContentProvider {
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 35 && newVersion >= 35) {
|
||||
Log_OC.i(SQL, "Entering in the #35 add note to share table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.OCSHARES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.OCSHARES_NOTE + " TEXT ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 36 && newVersion >= 36) {
|
||||
Log_OC.i(SQL, "Entering in the #36 add has-preview to file table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_HAS_PREVIEW + " INTEGER ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 37 && newVersion >= 37) {
|
||||
Log_OC.i(SQL, "Entering in the #37 add hide-download to share table");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.OCSHARES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD + " INTEGER ");
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 38 && newVersion >= 38) {
|
||||
Log_OC.i(SQL, "Entering in the #38 add richdocuments");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT + " INTEGER "); // boolean
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST + " TEXT "); // string
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
|
||||
if (oldVersion < 39 && newVersion >= 39) {
|
||||
Log_OC.i(SQL, "Entering in the #39 add richdocuments direct editing");
|
||||
db.beginTransaction();
|
||||
try {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING + " INTEGER "); // bool
|
||||
|
||||
upgraded = true;
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
if (!upgraded) {
|
||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
* @author David A. Velasco
|
||||
* @author Juan Carlos González Cabrero
|
||||
* 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/>.
|
||||
*/
|
||||
@@ -101,7 +101,10 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
|
||||
if (getContext() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AUTHORITY = getContext().getResources().getString(R.string.users_and_groups_search_authority);
|
||||
ACTION_SHARE_WITH = getContext().getResources().getString(R.string.users_and_groups_share_with);
|
||||
DATA_USER = AUTHORITY + ".data.user";
|
||||
@@ -110,6 +113,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
sShareTypes.put(DATA_USER, ShareType.USER);
|
||||
sShareTypes.put(DATA_GROUP, ShareType.GROUP);
|
||||
sShareTypes.put(DATA_GROUP, ShareType.ROOM);
|
||||
sShareTypes.put(DATA_REMOTE, ShareType.FEDERATED);
|
||||
sShareTypes.put(DATA_REMOTE, ShareType.EMAIL);
|
||||
|
||||
@@ -119,22 +123,23 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO description
|
||||
*
|
||||
* returns sharee from server
|
||||
*
|
||||
* Reference: http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#CustomContentProvider
|
||||
*
|
||||
* @param uri Content {@link Uri}, formattted as
|
||||
* @param uri Content {@link Uri}, formatted as
|
||||
* "content://com.nextcloud.android.providers.UsersAndGroupsSearchProvider/" +
|
||||
* {@link android.app.SearchManager#SUGGEST_URI_PATH_QUERY} + "/" + 'userQuery'
|
||||
* @param projection Expected to be NULL.
|
||||
* @param selection Expected to be NULL.
|
||||
* @param selectionArgs Expected to be NULL.
|
||||
* @param sortOrder Expected to be NULL.
|
||||
* @return Cursor with users and groups in the ownCloud server that match 'userQuery'.
|
||||
* @return Cursor with possible sharees in the server that match 'query'.
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public Cursor query(@NonNull 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);
|
||||
@@ -150,37 +155,35 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
private Cursor searchForUsersOrGroups(Uri uri) {
|
||||
MatrixCursor response = null;
|
||||
|
||||
|
||||
String userQuery = uri.getLastPathSegment().toLowerCase(Locale.ROOT);
|
||||
|
||||
|
||||
/// need to trust on the AccountUtils to get the current account since the query in the client side is not
|
||||
/// directly started by our code, but from SearchView implementation
|
||||
// need to trust on the AccountUtils to get the current account since the query in the client side is not
|
||||
// directly started by our code, but from SearchView implementation
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(getContext());
|
||||
|
||||
/// request to the OC server about users and groups matching userQuery
|
||||
// request to the OC server about users and groups matching userQuery
|
||||
GetRemoteShareesOperation searchRequest = new GetRemoteShareesOperation(
|
||||
userQuery, REQUESTED_PAGE, RESULTS_PER_PAGE
|
||||
);
|
||||
RemoteOperationResult result = searchRequest.execute(account, getContext());
|
||||
List<JSONObject> names = new ArrayList<>();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
for (Object o : result.getData()) {
|
||||
// Get JSonObjects from response
|
||||
names.add((JSONObject) o);
|
||||
}
|
||||
} else {
|
||||
showErrorMessage(result);
|
||||
}
|
||||
|
||||
/// convert the responses from the OC server to the expected format
|
||||
// convert the responses from the OC server to the expected format
|
||||
if (names.size() > 0) {
|
||||
response = new MatrixCursor(COLUMNS);
|
||||
Iterator<JSONObject> namesIt = names.iterator();
|
||||
JSONObject item;
|
||||
String displayName = null;
|
||||
String displayName;
|
||||
int icon = 0;
|
||||
Uri dataUri = null;
|
||||
Uri dataUri;
|
||||
int count = 0;
|
||||
|
||||
Uri userBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_USER).build();
|
||||
@@ -194,32 +197,55 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
try {
|
||||
while (namesIt.hasNext()) {
|
||||
item = namesIt.next();
|
||||
dataUri = null;
|
||||
displayName = null;
|
||||
String userName = item.getString(GetRemoteShareesOperation.PROPERTY_LABEL);
|
||||
JSONObject value = item.getJSONObject(GetRemoteShareesOperation.NODE_VALUE);
|
||||
int type = value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE);
|
||||
ShareType type = ShareType.fromValue(value.getInt(GetRemoteShareesOperation.PROPERTY_SHARE_TYPE));
|
||||
String shareWith = value.getString(GetRemoteShareesOperation.PROPERTY_SHARE_WITH);
|
||||
|
||||
if (ShareType.GROUP.getValue() == type) {
|
||||
displayName = getContext().getString(R.string.share_group_clarification, userName);
|
||||
icon = R.drawable.ic_group;
|
||||
dataUri = Uri.withAppendedPath(groupBaseUri, shareWith);
|
||||
} else if (ShareType.FEDERATED.getValue() == type && federatedShareAllowed) {
|
||||
icon = R.drawable.ic_user;
|
||||
if (userName.equals(shareWith)) {
|
||||
displayName = getContext().getString(R.string.share_remote_clarification, userName);
|
||||
} else {
|
||||
String[] uriSplitted = shareWith.split("@");
|
||||
displayName = getContext().getString(R.string.share_known_remote_clarification, userName,
|
||||
uriSplitted[uriSplitted.length - 1]);
|
||||
}
|
||||
dataUri = Uri.withAppendedPath(remoteBaseUri, shareWith);
|
||||
} else if (ShareType.USER.getValue() == type) {
|
||||
displayName = userName;
|
||||
icon = R.drawable.ic_user;
|
||||
dataUri = Uri.withAppendedPath(userBaseUri, shareWith);
|
||||
} else if (ShareType.EMAIL.getValue() == type) {
|
||||
icon = R.drawable.ic_email;
|
||||
displayName = getContext().getString(R.string.share_email_clarification, userName);
|
||||
switch (type) {
|
||||
case GROUP:
|
||||
displayName = getContext().getString(R.string.share_group_clarification, userName);
|
||||
icon = R.drawable.ic_group;
|
||||
dataUri = Uri.withAppendedPath(groupBaseUri, shareWith);
|
||||
break;
|
||||
|
||||
case FEDERATED:
|
||||
if (federatedShareAllowed) {
|
||||
icon = R.drawable.ic_user;
|
||||
dataUri = Uri.withAppendedPath(remoteBaseUri, shareWith);
|
||||
|
||||
if (userName.equals(shareWith)) {
|
||||
displayName = getContext().getString(R.string.share_remote_clarification, userName);
|
||||
} else {
|
||||
String[] uriSplitted = shareWith.split("@");
|
||||
displayName = getContext().getString(R.string.share_known_remote_clarification,
|
||||
userName, uriSplitted[uriSplitted.length - 1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case USER:
|
||||
displayName = userName;
|
||||
icon = R.drawable.ic_user;
|
||||
dataUri = Uri.withAppendedPath(userBaseUri, shareWith);
|
||||
break;
|
||||
|
||||
case EMAIL:
|
||||
icon = R.drawable.ic_email;
|
||||
displayName = getContext().getString(R.string.share_email_clarification, userName);
|
||||
dataUri = Uri.withAppendedPath(remoteBaseUri, shareWith);
|
||||
break;
|
||||
|
||||
case ROOM:
|
||||
icon = R.drawable.ic_chat_bubble;
|
||||
displayName = getContext().getString(R.string.share_room_clarification, userName);
|
||||
dataUri = Uri.withAppendedPath(groupBaseUri, shareWith);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (displayName != null && dataUri != null) {
|
||||
@@ -242,19 +268,16 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public Uri insert(@NonNull Uri uri, ContentValues values) {
|
||||
// TODO implementation
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
|
||||
// TODO implementation
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
// TODO implementation
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -263,7 +286,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
*
|
||||
* @param result Result with the failure information.
|
||||
*/
|
||||
public void showErrorMessage(final RemoteOperationResult result) {
|
||||
private void showErrorMessage(final RemoteOperationResult result) {
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
@@ -272,15 +295,9 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
// the thread may die before, an exception will occur, and the message will be left on the screen
|
||||
// until the app dies
|
||||
|
||||
Toast.makeText(
|
||||
getContext().getApplicationContext(),
|
||||
ErrorMessageAdapter.getErrorCauseMessage(
|
||||
result,
|
||||
null,
|
||||
getContext().getResources()
|
||||
),
|
||||
Toast.LENGTH_SHORT
|
||||
).show();
|
||||
Toast.makeText(getContext().getApplicationContext(),
|
||||
ErrorMessageAdapter.getErrorCauseMessage(result, null, getContext().getResources()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import com.owncloud.android.operations.RestoreFileVersionOperation;
|
||||
import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||
import com.owncloud.android.operations.SynchronizeFolderOperation;
|
||||
import com.owncloud.android.operations.UnshareOperation;
|
||||
import com.owncloud.android.operations.UpdateNoteForShareOperation;
|
||||
import com.owncloud.android.operations.UpdateSharePermissionsOperation;
|
||||
import com.owncloud.android.operations.UpdateShareViaLinkOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
@@ -102,7 +103,9 @@ public class OperationsService extends Service {
|
||||
public static final String EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS = "SHARE_EXPIRATION_YEAR";
|
||||
public static final String EXTRA_SHARE_PERMISSIONS = "SHARE_PERMISSIONS";
|
||||
public static final String EXTRA_SHARE_PUBLIC_UPLOAD = "SHARE_PUBLIC_UPLOAD";
|
||||
public static final String EXTRA_SHARE_HIDE_FILE_DOWNLOAD = "HIDE_FILE_DOWNLOAD";
|
||||
public static final String EXTRA_SHARE_ID = "SHARE_ID";
|
||||
public static final String EXTRA_SHARE_NOTE = "SHARE_NOTE";
|
||||
public static final String EXTRA_USER_ID = "USER_ID";
|
||||
public static final String EXTRA_IN_BACKGROUND = "IN_BACKGROUND";
|
||||
|
||||
@@ -112,6 +115,7 @@ public class OperationsService extends Service {
|
||||
public static final String ACTION_CREATE_SHARE_WITH_SHAREE = "CREATE_SHARE_WITH_SHAREE";
|
||||
public static final String ACTION_UNSHARE = "UNSHARE";
|
||||
public static final String ACTION_UPDATE_SHARE = "UPDATE_SHARE";
|
||||
public static final String ACTION_UPDATE_SHARE_NOTE = "UPDATE_SHARE_NOTE";
|
||||
public static final String ACTION_GET_SERVER_INFO = "GET_SERVER_INFO";
|
||||
public static final String ACTION_OAUTH2_GET_ACCESS_TOKEN = "OAUTH2_GET_ACCESS_TOKEN";
|
||||
public static final String ACTION_GET_USER_NAME = "GET_USER_NAME";
|
||||
@@ -148,7 +152,7 @@ public class OperationsService extends Service {
|
||||
mCookie = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Service initialization
|
||||
*/
|
||||
@@ -157,14 +161,14 @@ public class OperationsService extends Service {
|
||||
super.onCreate();
|
||||
Log_OC.d(TAG, "Creating service");
|
||||
|
||||
/// First worker thread for most of operations
|
||||
// First worker thread for most of operations
|
||||
HandlerThread thread = new HandlerThread("Operations thread",
|
||||
Process.THREAD_PRIORITY_BACKGROUND);
|
||||
thread.start();
|
||||
mOperationsHandler = new ServiceHandler(thread.getLooper(), this);
|
||||
mOperationsBinder = new OperationsServiceBinder(mOperationsHandler);
|
||||
|
||||
/// Separated worker thread for download of folders (WIP)
|
||||
|
||||
// Separated worker thread for download of folders (WIP)
|
||||
thread = new HandlerThread("Syncfolder thread", Process.THREAD_PRIORITY_BACKGROUND);
|
||||
thread.start();
|
||||
mSyncFolderHandler = new SyncFolderHandler(thread.getLooper(), this);
|
||||
@@ -208,7 +212,7 @@ public class OperationsService extends Service {
|
||||
msg.arg1 = startId;
|
||||
mOperationsHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@@ -313,8 +317,8 @@ public class OperationsService extends Service {
|
||||
/**
|
||||
* Removes a listener from the list of objects interested in the being reported about
|
||||
* the end of operations.
|
||||
*
|
||||
* @param listener Object to notify about progress of transfer.
|
||||
*
|
||||
* @param listener Object to notify about progress of transfer.
|
||||
*/
|
||||
public void removeOperationListener(OnRemoteOperationListener listener) {
|
||||
synchronized (mBoundListeners) {
|
||||
@@ -336,9 +340,9 @@ public class OperationsService extends Service {
|
||||
|
||||
/**
|
||||
* Creates and adds to the queue a new operation, as described by operationIntent.
|
||||
*
|
||||
*
|
||||
* Calls startService to make the operation is processed by the ServiceHandler.
|
||||
*
|
||||
*
|
||||
* @param operationIntent Intent describing a new operation to queue and execute.
|
||||
* @return Identifier of the operation created, or null if failed.
|
||||
*/
|
||||
@@ -348,7 +352,7 @@ public class OperationsService extends Service {
|
||||
mServiceHandler.mPendingOperations.add(itemToQueue);
|
||||
startService(new Intent(OperationsService.this, OperationsService.class));
|
||||
return itemToQueue.second.hashCode();
|
||||
|
||||
|
||||
} else {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
@@ -356,7 +360,7 @@ public class OperationsService extends Service {
|
||||
|
||||
public boolean dispatchResultIfFinished(int operationId,
|
||||
OnRemoteOperationListener listener) {
|
||||
Pair<RemoteOperation, RemoteOperationResult> undispatched =
|
||||
Pair<RemoteOperation, RemoteOperationResult> undispatched =
|
||||
mUndispatchedFinishedOperations.remove(operationId);
|
||||
if (undispatched != null) {
|
||||
listener.onRemoteOperationFinish(undispatched.first, undispatched.second);
|
||||
@@ -365,14 +369,14 @@ public class OperationsService extends Service {
|
||||
return !mServiceHandler.mPendingOperations.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns True when the file described by 'file' in the ownCloud account 'account' is
|
||||
* downloading or waiting to download.
|
||||
*
|
||||
*
|
||||
* If 'file' is a directory, returns 'true' if some of its descendant files is downloading
|
||||
* or waiting to download.
|
||||
*
|
||||
*
|
||||
* @param account ownCloud account where the remote file is stored.
|
||||
* @param file File to check if something is synchronizing
|
||||
* / downloading / uploading inside.
|
||||
@@ -387,13 +391,13 @@ public class OperationsService extends Service {
|
||||
/**
|
||||
* Operations worker. Performs the pending operations in the order they were requested.
|
||||
*
|
||||
* Created with the Looper of a new thread, started in {@link OperationsService#onCreate()}.
|
||||
* Created with the Looper of a new thread, started in {@link OperationsService#onCreate()}.
|
||||
*/
|
||||
private static class ServiceHandler extends Handler {
|
||||
// don't make it a final class, and don't remove the static ; lint will warn about a p
|
||||
// ossible memory leak
|
||||
|
||||
|
||||
|
||||
|
||||
OperationsService mService;
|
||||
|
||||
|
||||
@@ -403,8 +407,8 @@ public class OperationsService extends Service {
|
||||
private Target mLastTarget;
|
||||
private OwnCloudClient mOwnCloudClient;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
|
||||
|
||||
|
||||
|
||||
public ServiceHandler(Looper looper, OperationsService service) {
|
||||
super(looper);
|
||||
if (service == null) {
|
||||
@@ -419,21 +423,21 @@ 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
|
||||
*/
|
||||
private void nextOperation() {
|
||||
|
||||
|
||||
//Log_OC.e(TAG, "nextOperation init" );
|
||||
|
||||
|
||||
Pair<Target, RemoteOperation> next = null;
|
||||
synchronized(mPendingOperations) {
|
||||
next = mPendingOperations.peek();
|
||||
}
|
||||
|
||||
if (next != null) {
|
||||
|
||||
|
||||
mCurrentOperation = next.second;
|
||||
RemoteOperationResult result = null;
|
||||
try {
|
||||
@@ -450,7 +454,7 @@ public class OperationsService extends Service {
|
||||
mOwnCloudClient.setOwnCloudVersion(version);
|
||||
|
||||
mStorageManager = new FileDataStorageManager(
|
||||
mLastTarget.mAccount,
|
||||
mLastTarget.mAccount,
|
||||
mService.getContentResolver()
|
||||
);
|
||||
} else {
|
||||
@@ -489,7 +493,7 @@ public class OperationsService extends Service {
|
||||
mLastTarget.mAccount.name, e);
|
||||
}
|
||||
result = new RemoteOperationResult(e);
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
if (mLastTarget.mAccount == null) {
|
||||
Log_OC.e(TAG, "Error while trying to get authorization for a NULL account",
|
||||
@@ -506,13 +510,13 @@ public class OperationsService extends Service {
|
||||
Log_OC.e(TAG, "Unexpected error for " + mLastTarget.mAccount.name, e);
|
||||
}
|
||||
result = new RemoteOperationResult(e);
|
||||
|
||||
|
||||
} finally {
|
||||
synchronized(mPendingOperations) {
|
||||
mPendingOperations.poll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//sendBroadcastOperationFinished(mLastTarget, mCurrentOperation, result);
|
||||
mService.dispatchResultToOperationListeners(mCurrentOperation, result);
|
||||
}
|
||||
@@ -522,18 +526,18 @@ public class OperationsService extends Service {
|
||||
|
||||
/**
|
||||
* Creates a new operation, as described by operationIntent.
|
||||
*
|
||||
*
|
||||
* TODO - move to ServiceHandler (probably)
|
||||
*
|
||||
*
|
||||
* @param operationIntent Intent describing a new operation to queue and execute.
|
||||
* @return Pair with the new operation object and the information about its
|
||||
* target server.
|
||||
*/
|
||||
private Pair<Target , RemoteOperation> newOperation(Intent operationIntent) {
|
||||
private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) {
|
||||
RemoteOperation operation = null;
|
||||
Target target = null;
|
||||
try {
|
||||
if (!operationIntent.hasExtra(EXTRA_ACCOUNT) &&
|
||||
if (!operationIntent.hasExtra(EXTRA_ACCOUNT) &&
|
||||
!operationIntent.hasExtra(EXTRA_SERVER_URL)) {
|
||||
Log_OC.e(TAG, "Not enough information provided in intent");
|
||||
|
||||
@@ -542,170 +546,185 @@ public class OperationsService extends Service {
|
||||
String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL);
|
||||
String cookie = operationIntent.getStringExtra(EXTRA_COOKIE);
|
||||
target = new Target(
|
||||
account,
|
||||
account,
|
||||
(serverUrl == null) ? null : Uri.parse(serverUrl),
|
||||
cookie
|
||||
);
|
||||
|
||||
|
||||
String action = operationIntent.getAction();
|
||||
String remotePath;
|
||||
String password;
|
||||
ShareType shareType;
|
||||
String newParentPath;
|
||||
long shareId;
|
||||
|
||||
if (ACTION_CREATE_SHARE_VIA_LINK.equals(action)) { // Create public share via link
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
if (remotePath.length() > 0) {
|
||||
operation = new CreateShareViaLinkOperation(
|
||||
remotePath,
|
||||
password
|
||||
);
|
||||
}
|
||||
|
||||
} else if (ACTION_UPDATE_SHARE.equals(action)) {
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
|
||||
if (remotePath != null && remotePath.length() > 0) {
|
||||
operation = new UpdateShareViaLinkOperation(remotePath);
|
||||
|
||||
String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
((UpdateShareViaLinkOperation) operation).setPassword(password);
|
||||
|
||||
long expirationDate = operationIntent.getLongExtra(
|
||||
EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS,
|
||||
0
|
||||
);
|
||||
((UpdateShareViaLinkOperation)operation).setExpirationDate(
|
||||
expirationDate
|
||||
);
|
||||
|
||||
if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) {
|
||||
((UpdateShareViaLinkOperation) operation).setPublicUpload(
|
||||
operationIntent.getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false)
|
||||
);
|
||||
switch (action) {
|
||||
case ACTION_CREATE_SHARE_VIA_LINK:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
if (remotePath.length() > 0) {
|
||||
operation = new CreateShareViaLinkOperation(remotePath, password);
|
||||
}
|
||||
break;
|
||||
|
||||
} else if (shareId > 0) {
|
||||
operation = new UpdateSharePermissionsOperation(shareId);
|
||||
case ACTION_UPDATE_SHARE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
|
||||
|
||||
if (remotePath != null && remotePath.length() > 0) {
|
||||
UpdateShareViaLinkOperation updateLinkOperation = new UpdateShareViaLinkOperation(remotePath);
|
||||
|
||||
password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
updateLinkOperation.setPassword(password);
|
||||
|
||||
long expirationDate = operationIntent.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0);
|
||||
updateLinkOperation.setExpirationDate(expirationDate);
|
||||
|
||||
boolean hideFileDownload = operationIntent.getBooleanExtra(EXTRA_SHARE_HIDE_FILE_DOWNLOAD,
|
||||
false);
|
||||
updateLinkOperation.setHideFileDownload(hideFileDownload);
|
||||
|
||||
if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) {
|
||||
updateLinkOperation.setPublicUpload(
|
||||
operationIntent.getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false));
|
||||
}
|
||||
operation = updateLinkOperation;
|
||||
} else if (shareId > 0) {
|
||||
UpdateSharePermissionsOperation updateShare = new UpdateSharePermissionsOperation(shareId);
|
||||
|
||||
int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1);
|
||||
updateShare.setPermissions(permissions);
|
||||
|
||||
long expirationDateInMillis = operationIntent
|
||||
.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0L);
|
||||
updateShare.setExpirationDate(expirationDateInMillis);
|
||||
|
||||
password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
updateShare.setPassword(password);
|
||||
|
||||
operation = updateShare;
|
||||
}
|
||||
break;
|
||||
|
||||
case ACTION_UPDATE_SHARE_NOTE:
|
||||
shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1);
|
||||
String note = operationIntent.getStringExtra(EXTRA_SHARE_NOTE);
|
||||
|
||||
if (shareId > 0) {
|
||||
operation = new UpdateNoteForShareOperation(shareId, note);
|
||||
}
|
||||
break;
|
||||
|
||||
case ACTION_CREATE_SHARE_WITH_SHAREE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
String shareeName = operationIntent.getStringExtra(EXTRA_SHARE_WITH);
|
||||
shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE);
|
||||
int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1);
|
||||
((UpdateSharePermissionsOperation)operation).setPermissions(permissions);
|
||||
long expirationDateInMillis = operationIntent.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0L);
|
||||
((UpdateSharePermissionsOperation)operation).setExpirationDate(expirationDateInMillis);
|
||||
String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD);
|
||||
((UpdateSharePermissionsOperation)operation).setPassword(password);
|
||||
}
|
||||
if (remotePath.length() > 0) {
|
||||
operation = new CreateShareWithShareeOperation(remotePath, shareeName, shareType,
|
||||
permissions);
|
||||
}
|
||||
break;
|
||||
|
||||
} else if (ACTION_CREATE_SHARE_WITH_SHAREE.equals(action)) {
|
||||
// Create private share with user or group
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
String shareeName = operationIntent.getStringExtra(EXTRA_SHARE_WITH);
|
||||
ShareType shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE);
|
||||
int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1);
|
||||
if (remotePath.length() > 0) {
|
||||
operation = new CreateShareWithShareeOperation(
|
||||
case ACTION_UNSHARE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE);
|
||||
String shareWith = operationIntent.getStringExtra(EXTRA_SHARE_WITH);
|
||||
|
||||
if (remotePath.length() > 0) {
|
||||
operation = new UnshareOperation(remotePath, shareType, shareWith, this);
|
||||
}
|
||||
break;
|
||||
|
||||
case ACTION_GET_SERVER_INFO:
|
||||
operation = new GetServerInfoOperation(serverUrl, this);
|
||||
break;
|
||||
|
||||
case ACTION_OAUTH2_GET_ACCESS_TOKEN:
|
||||
String oauth2QueryParameters = operationIntent.getStringExtra(EXTRA_OAUTH2_QUERY_PARAMETERS);
|
||||
operation = new OAuth2GetAccessToken(getString(R.string.oauth2_client_id),
|
||||
getString(R.string.oauth2_redirect_uri), getString(R.string.oauth2_grant_type),
|
||||
oauth2QueryParameters);
|
||||
break;
|
||||
|
||||
case ACTION_GET_USER_NAME:
|
||||
operation = new GetRemoteUserInfoOperation();
|
||||
break;
|
||||
|
||||
case ACTION_RENAME:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
String newName = operationIntent.getStringExtra(EXTRA_NEWNAME);
|
||||
operation = new RenameFileOperation(remotePath, newName);
|
||||
break;
|
||||
|
||||
case ACTION_REMOVE:
|
||||
// Remove file or folder
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
boolean onlyLocalCopy = operationIntent.getBooleanExtra(EXTRA_REMOVE_ONLY_LOCAL, false);
|
||||
boolean inBackground = operationIntent.getBooleanExtra(EXTRA_IN_BACKGROUND, false);
|
||||
operation = new RemoveFileOperation(remotePath, onlyLocalCopy, account, inBackground,
|
||||
getApplicationContext());
|
||||
break;
|
||||
|
||||
case ACTION_CREATE_FOLDER:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
boolean createFullPath = operationIntent.getBooleanExtra(EXTRA_CREATE_FULL_PATH, true);
|
||||
operation = new CreateFolderOperation(remotePath, createFullPath);
|
||||
break;
|
||||
|
||||
case ACTION_SYNC_FILE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
boolean syncFileContents = operationIntent.getBooleanExtra(EXTRA_SYNC_FILE_CONTENTS, true);
|
||||
operation = new SynchronizeFileOperation(remotePath, account, syncFileContents,
|
||||
getApplicationContext());
|
||||
break;
|
||||
|
||||
case ACTION_SYNC_FOLDER:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
operation = new SynchronizeFolderOperation(
|
||||
this, // TODO remove this dependency from construction time
|
||||
remotePath,
|
||||
shareeName,
|
||||
shareType,
|
||||
permissions
|
||||
account,
|
||||
System.currentTimeMillis() // TODO remove this dependency from construction time
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
} else if (ACTION_UNSHARE.equals(action)) { // Unshare file
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
ShareType shareType = (ShareType) operationIntent.
|
||||
getSerializableExtra(EXTRA_SHARE_TYPE);
|
||||
String shareWith = operationIntent.getStringExtra(EXTRA_SHARE_WITH);
|
||||
if (remotePath.length() > 0) {
|
||||
operation = new UnshareOperation(
|
||||
remotePath,
|
||||
shareType,
|
||||
shareWith,
|
||||
OperationsService.this
|
||||
);
|
||||
}
|
||||
|
||||
} else if (ACTION_GET_SERVER_INFO.equals(action)) {
|
||||
// check OC server and get basic information from it
|
||||
operation = new GetServerInfoOperation(serverUrl, OperationsService.this);
|
||||
case ACTION_MOVE_FILE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
|
||||
operation = new MoveFileOperation(remotePath, newParentPath);
|
||||
break;
|
||||
|
||||
} else if (ACTION_OAUTH2_GET_ACCESS_TOKEN.equals(action)) {
|
||||
/// GET ACCESS TOKEN to the OAuth server
|
||||
String oauth2QueryParameters =
|
||||
operationIntent.getStringExtra(EXTRA_OAUTH2_QUERY_PARAMETERS);
|
||||
operation = new OAuth2GetAccessToken(
|
||||
getString(R.string.oauth2_client_id),
|
||||
getString(R.string.oauth2_redirect_uri),
|
||||
getString(R.string.oauth2_grant_type),
|
||||
oauth2QueryParameters);
|
||||
case ACTION_COPY_FILE:
|
||||
remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
|
||||
operation = new CopyFileOperation(remotePath, newParentPath);
|
||||
break;
|
||||
|
||||
} else if (ACTION_GET_USER_NAME.equals(action)) {
|
||||
// Get User Name
|
||||
operation = new GetRemoteUserInfoOperation();
|
||||
|
||||
} else if (ACTION_RENAME.equals(action)) {
|
||||
// Rename file or folder
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
String newName = operationIntent.getStringExtra(EXTRA_NEWNAME);
|
||||
operation = new RenameFileOperation(remotePath, newName);
|
||||
|
||||
} else if (ACTION_REMOVE.equals(action)) {
|
||||
// Remove file or folder
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
boolean onlyLocalCopy = operationIntent.getBooleanExtra(EXTRA_REMOVE_ONLY_LOCAL, false);
|
||||
boolean inBackground = operationIntent.getBooleanExtra(EXTRA_IN_BACKGROUND, false);
|
||||
operation = new RemoveFileOperation(remotePath, onlyLocalCopy, account, inBackground,
|
||||
getApplicationContext());
|
||||
|
||||
} else if (ACTION_CREATE_FOLDER.equals(action)) {
|
||||
// Create Folder
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
boolean createFullPath = operationIntent.getBooleanExtra(EXTRA_CREATE_FULL_PATH, true);
|
||||
operation = new CreateFolderOperation(remotePath, createFullPath);
|
||||
|
||||
} else if (ACTION_SYNC_FILE.equals(action)) {
|
||||
// Sync file
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
boolean syncFileContents = operationIntent.getBooleanExtra(EXTRA_SYNC_FILE_CONTENTS, true);
|
||||
operation = new SynchronizeFileOperation(remotePath, account, syncFileContents,
|
||||
getApplicationContext());
|
||||
|
||||
} else if (ACTION_SYNC_FOLDER.equals(action)) {
|
||||
// Sync folder (all its descendant files are sync'ed)
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
operation = new SynchronizeFolderOperation(
|
||||
this, // TODO remove this dependency from construction time
|
||||
remotePath,
|
||||
account,
|
||||
System.currentTimeMillis() // TODO remove this dependency from construction time
|
||||
);
|
||||
|
||||
} else if (ACTION_MOVE_FILE.equals(action)) {
|
||||
// Move file/folder
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
|
||||
operation = new MoveFileOperation(remotePath, newParentPath);
|
||||
|
||||
} else if (ACTION_COPY_FILE.equals(action)) {
|
||||
// Copy file/folder
|
||||
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
|
||||
String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
|
||||
operation = new CopyFileOperation(remotePath, newParentPath);
|
||||
|
||||
} else if (ACTION_CHECK_CURRENT_CREDENTIALS.equals(action)) {
|
||||
// Check validity of currently stored credentials for a given account
|
||||
case ACTION_CHECK_CURRENT_CREDENTIALS:
|
||||
operation = new CheckCurrentCredentialsOperation(account);
|
||||
} else if (ACTION_RESTORE_VERSION.equals(action)) {
|
||||
FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
|
||||
String userId = operationIntent.getStringExtra(EXTRA_USER_ID);
|
||||
operation = new RestoreFileVersionOperation(fileVersion.getRemoteId(), fileVersion.getFileName(),
|
||||
userId);
|
||||
break;
|
||||
|
||||
case ACTION_RESTORE_VERSION:
|
||||
FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
|
||||
String userId = operationIntent.getStringExtra(EXTRA_USER_ID);
|
||||
operation = new RestoreFileVersionOperation(fileVersion.getRemoteId(),
|
||||
fileVersion.getFileName(), userId);
|
||||
break;
|
||||
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage());
|
||||
operation = null;
|
||||
}
|
||||
|
||||
if (operation != null) {
|
||||
return new Pair<Target , RemoteOperation>(target, operation);
|
||||
return new Pair<Target, RemoteOperation>(target, operation);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -726,7 +745,7 @@ public class OperationsService extends Service {
|
||||
while (listeners.hasNext()) {
|
||||
final OnRemoteOperationListener listener = listeners.next();
|
||||
final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
|
||||
if (handler != null) {
|
||||
if (handler != null) {
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -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;
|
||||
@@ -357,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,
|
||||
@@ -388,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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.ExternalLinksProvider;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.PreferenceManager;
|
||||
import com.owncloud.android.lib.common.ExternalLink;
|
||||
import com.owncloud.android.lib.common.ExternalLinkType;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
@@ -89,6 +90,7 @@ import com.owncloud.android.ui.events.ChangeMenuEvent;
|
||||
import com.owncloud.android.ui.events.DummyDrawerEvent;
|
||||
import com.owncloud.android.ui.events.MenuItemClickEvent;
|
||||
import com.owncloud.android.ui.events.SearchEvent;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.ui.trashbin.TrashbinActivity;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.DrawerMenuUtil;
|
||||
@@ -99,6 +101,7 @@ import com.owncloud.android.utils.svg.MenuSimpleTarget;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
import org.parceler.Parcels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -351,7 +354,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());
|
||||
capability = storageManager.getCapability(account.name);
|
||||
}
|
||||
|
||||
|
||||
DrawerMenuUtil.filterForBottomToolbarMenuItems(menu, getResources());
|
||||
DrawerMenuUtil.filterSearchMenuItems(menu, account, getResources());
|
||||
DrawerMenuUtil.filterTrashbinMenuItem(menu, account, capability);
|
||||
@@ -403,12 +406,12 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
EventBus.getDefault().post(new ChangeMenuEvent());
|
||||
break;
|
||||
case R.id.nav_favorites:
|
||||
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
||||
SearchEvent.UnsetType.NO_UNSET));
|
||||
handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
||||
SearchEvent.UnsetType.NO_UNSET), menuItem.getItemId());
|
||||
break;
|
||||
case R.id.nav_photos:
|
||||
EventBus.getDefault().post(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||
SearchEvent.UnsetType.NO_UNSET));
|
||||
handleSearchEvents(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||
SearchEvent.UnsetType.NO_UNSET), menuItem.getItemId());
|
||||
break;
|
||||
case R.id.nav_on_device:
|
||||
EventBus.getDefault().post(new ChangeMenuEvent());
|
||||
@@ -471,20 +474,20 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
|
||||
break;
|
||||
case R.id.nav_recently_added:
|
||||
EventBus.getDefault().post(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
||||
handleSearchEvents(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
||||
break;
|
||||
case R.id.nav_recently_modified:
|
||||
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
||||
handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
||||
break;
|
||||
case R.id.nav_shared:
|
||||
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
||||
handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
||||
break;
|
||||
case R.id.nav_videos:
|
||||
EventBus.getDefault().post(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
||||
handleSearchEvents(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
||||
break;
|
||||
case Menu.NONE:
|
||||
// account clicked
|
||||
@@ -502,6 +505,19 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSearchEvents(SearchEvent searchEvent, int menuItemId) {
|
||||
if (this instanceof FileDisplayActivity) {
|
||||
EventBus.getDefault().post(searchEvent);
|
||||
} else {
|
||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.setAction(Intent.ACTION_SEARCH);
|
||||
intent.putExtra(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* show the file list to the user.
|
||||
*
|
||||
@@ -530,7 +546,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
for (ExternalLink link : externalLinksProvider.getExternalLink(ExternalLinkType.LINK)) {
|
||||
if (menuItem.getTitle().toString().equalsIgnoreCase(link.name)) {
|
||||
if (link.redirect) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link.url)));
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link.url));
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, this, R.string.no_browser_available);
|
||||
} else {
|
||||
Intent externalWebViewIntent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.name);
|
||||
@@ -1080,7 +1097,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
LayerDrawable layerDrawable = new LayerDrawable(drawables);
|
||||
setNavigationHeaderBackground(layerDrawable, navigationHeader);
|
||||
} else {
|
||||
// use url
|
||||
// use url
|
||||
if (URLUtil.isValidUrl(background) || background.isEmpty()) {
|
||||
// background image
|
||||
SimpleTarget target = new SimpleTarget<Drawable>() {
|
||||
@@ -1236,7 +1253,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
|
||||
if (result == RequestCredentialsActivity.KEY_CHECK_RESULT_CANCEL) {
|
||||
Log_OC.d(TAG, "PassCodeManager cancelled");
|
||||
super.onBackPressed();
|
||||
PreferenceManager.setLockTimestamp(this, 0);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1386,7 +1404,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 +1423,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();
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2017 Tobias Kaminsky
|
||||
* Copyright (C) 2017 Nextcloud GmbH.
|
||||
* <p>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
* <p>
|
||||
* (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.
|
||||
* <p>
|
||||
* 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/>.
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
@@ -50,12 +50,16 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
public static final String EXTRA_URL = "URL";
|
||||
public static final String EXTRA_SHOW_SIDEBAR = "SHOW_SIDEBAR";
|
||||
public static final String EXTRA_MENU_ITEM_ID = "MENU_ITEM_ID";
|
||||
public static final String EXTRA_TEMPLATE = "TEMPLATE";
|
||||
|
||||
private static final String TAG = ExternalSiteWebView.class.getSimpleName();
|
||||
|
||||
private boolean showSidebar;
|
||||
protected boolean showToolbar = true;
|
||||
private int menuItemId;
|
||||
private WebView webview;
|
||||
protected WebView webview;
|
||||
protected int webViewLayout = R.layout.externalsite_webview;
|
||||
String url;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
@@ -64,7 +68,7 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
String title = extras.getString(EXTRA_TITLE);
|
||||
String url = extras.getString(EXTRA_URL);
|
||||
url = extras.getString(EXTRA_URL);
|
||||
menuItemId = extras.getInt(EXTRA_MENU_ITEM_ID);
|
||||
showSidebar = extras.getBoolean(EXTRA_SHOW_SIDEBAR);
|
||||
|
||||
@@ -75,7 +79,8 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.externalsite_webview);
|
||||
|
||||
setContentView(webViewLayout);
|
||||
|
||||
webview = findViewById(R.id.webView);
|
||||
final WebSettings webSettings = webview.getSettings();
|
||||
@@ -85,7 +90,9 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
webview.setClickable(true);
|
||||
|
||||
// setup toolbar
|
||||
setupToolbar();
|
||||
if (showToolbar) {
|
||||
setupToolbar();
|
||||
}
|
||||
|
||||
// setup drawer
|
||||
setupDrawer(menuItemId);
|
||||
@@ -130,11 +137,13 @@ public class ExternalSiteWebView extends FileActivity {
|
||||
|
||||
final ProgressBar progressBar = findViewById(R.id.progressBar);
|
||||
|
||||
webview.setWebChromeClient(new WebChromeClient() {
|
||||
public void onProgressChanged(WebView view, int progress) {
|
||||
progressBar.setProgress(progress * 1000);
|
||||
}
|
||||
});
|
||||
if (progressBar != null) {
|
||||
webview.setWebChromeClient(new WebChromeClient() {
|
||||
public void onProgressChanged(WebView view, int progress) {
|
||||
progressBar.setProgress(progress * 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
webview.setWebViewClient(new WebViewClient() {
|
||||
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
|
||||
|
||||
@@ -90,6 +90,8 @@ public abstract class FileActivity extends DrawerActivity
|
||||
public static final String EXTRA_ACCOUNT = "com.owncloud.android.ui.activity.ACCOUNT";
|
||||
public static final String EXTRA_FROM_NOTIFICATION = "com.owncloud.android.ui.activity.FROM_NOTIFICATION";
|
||||
public static final String APP_OPENED_COUNT = "APP_OPENED_COUNT";
|
||||
public static final String EXTRA_SEARCH = "com.owncloud.android.ui.activity.SEARCH";
|
||||
public static final String EXTRA_SEARCH_QUERY = "com.owncloud.android.ui.activity.SEARCH_QUERY";
|
||||
|
||||
public static final String TAG = FileActivity.class.getSimpleName();
|
||||
|
||||
@@ -493,7 +495,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,
|
||||
@@ -611,7 +613,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask(callback);
|
||||
loadTask.execute(url);
|
||||
}
|
||||
|
||||
|
||||
public static void showDevSnackbar(Activity activity, Integer latestVersion, boolean openDirectly) {
|
||||
Integer currentVersion = -1;
|
||||
try {
|
||||
@@ -628,7 +630,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
String devApkLink = (String) activity.getText(R.string.dev_link) + latestVersion + ".apk";
|
||||
Uri uriUrl = Uri.parse(devApkLink);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
activity.startActivity(intent);
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, activity, R.string.no_browser_available);
|
||||
} else {
|
||||
Snackbar.make(activity.findViewById(android.R.id.content), R.string.dev_version_new_version_available,
|
||||
Snackbar.LENGTH_LONG)
|
||||
@@ -636,7 +638,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
String devApkLink = (String) activity.getText(R.string.dev_link) + latestVersion + ".apk";
|
||||
Uri uriUrl = Uri.parse(devApkLink);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
activity.startActivity(intent);
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, activity, R.string.no_browser_available);
|
||||
}).show();
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -86,7 +86,6 @@ 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;
|
||||
@@ -101,6 +100,7 @@ import com.owncloud.android.operations.RenameFileOperation;
|
||||
import com.owncloud.android.operations.RestoreFileVersionOperation;
|
||||
import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||
import com.owncloud.android.operations.UnshareOperation;
|
||||
import com.owncloud.android.operations.UpdateNoteForShareOperation;
|
||||
import com.owncloud.android.operations.UpdateSharePermissionsOperation;
|
||||
import com.owncloud.android.operations.UpdateShareViaLinkOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
@@ -144,8 +144,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static com.owncloud.android.db.PreferenceManager.getSortOrder;
|
||||
|
||||
/**
|
||||
* Displays, what files the user has available in his ownCloud. This is the main view.
|
||||
*/
|
||||
@@ -156,7 +154,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
SendShareDialog.SendShareDialogDownloader {
|
||||
|
||||
public static final String RESTART = "RESTART";
|
||||
|
||||
|
||||
private SyncBroadcastReceiver mSyncBroadcastReceiver;
|
||||
private UploadFinishReceiver mUploadFinishReceiver;
|
||||
private DownloadFinishReceiver mDownloadFinishReceiver;
|
||||
@@ -172,7 +170,6 @@ public class FileDisplayActivity extends HookActivity
|
||||
private static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW";
|
||||
private static final String KEY_SYNC_IN_PROGRESS = "SYNC_IN_PROGRESS";
|
||||
private static final String KEY_WAITING_TO_SEND = "WAITING_TO_SEND";
|
||||
private static final String KEY_SEARCH_QUERY = "KEY_SEARCH_QUERY";
|
||||
|
||||
public static final String ACTION_DETAILS = "com.owncloud.android.ui.activity.action.DETAILS";
|
||||
|
||||
@@ -192,8 +189,6 @@ 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;
|
||||
@@ -205,7 +200,11 @@ public class FileDisplayActivity extends HookActivity
|
||||
private MediaServiceBinder mMediaServiceBinder;
|
||||
private MediaServiceConnection mMediaServiceConnection;
|
||||
|
||||
private String searchQuery;
|
||||
public static final String KEY_IS_SEARCH_OPEN = "IS_SEARCH_OPEN";
|
||||
public static final String KEY_SEARCH_QUERY = "SEARCH_QUERY";
|
||||
|
||||
private String searchQuery = "";
|
||||
private boolean searchOpen;
|
||||
|
||||
private SearchView searchView;
|
||||
|
||||
@@ -223,6 +222,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
|
||||
mWaitingToSend = savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND);
|
||||
searchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
|
||||
searchOpen = savedInstanceState.getBoolean(FileDisplayActivity.KEY_IS_SEARCH_OPEN, false);
|
||||
} else {
|
||||
mWaitingToPreview = null;
|
||||
mSyncInProgress = false;
|
||||
@@ -368,11 +368,9 @@ 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());
|
||||
serverVersion = getCapabilities().getVersion();
|
||||
}
|
||||
|
||||
if (MainApp.OUTDATED_SERVER_VERSION.compareTo(serverVersion) >= 0) {
|
||||
@@ -537,6 +535,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
if (ACTION_DETAILS.equalsIgnoreCase(intent.getAction())) {
|
||||
setIntent(intent);
|
||||
setFile(intent.getParcelableExtra(EXTRA_FILE));
|
||||
@@ -546,8 +545,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
} else // Verify the action and get the query
|
||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||
setIntent(intent);
|
||||
Log_OC.w(TAG, "Ignored Intent requesting to query for " + query);
|
||||
|
||||
} else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) {
|
||||
Uri data = intent.getData();
|
||||
String dataString = intent.getDataString();
|
||||
@@ -626,7 +625,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
searchView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
searchView.setQuery("", true);
|
||||
searchView.setQuery(searchQuery, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -735,7 +734,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
if (success) {
|
||||
// update the file from database, for the local storage path
|
||||
mWaitingToPreview = getStorageManager().getFileById(mWaitingToPreview.getFileId());
|
||||
|
||||
|
||||
if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
|
||||
boolean streaming = AccountUtils.getServerVersionForAccount(getAccount(), this)
|
||||
.isMediaStreamingSupported();
|
||||
@@ -778,8 +777,9 @@ public class FileDisplayActivity extends HookActivity
|
||||
menu.findItem(R.id.action_create_dir).setVisible(false);
|
||||
|
||||
menu.findItem(R.id.action_select_all).setVisible(false);
|
||||
final MenuItem item = menu.findItem(R.id.action_search);
|
||||
searchView = (SearchView) MenuItemCompat.getActionView(item);
|
||||
MenuItem searchMenuItem = menu.findItem(R.id.action_search);
|
||||
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
|
||||
searchMenuItem.setVisible(false);
|
||||
|
||||
// hacky as no default way is provided
|
||||
int fontColor = ThemeUtils.fontColor(this);
|
||||
@@ -856,7 +856,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
@@ -888,7 +888,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
ft.addToBackStack(null);
|
||||
|
||||
SortingOrderDialogFragment mSortingOrderDialogFragment = SortingOrderDialogFragment.newInstance(
|
||||
getSortOrder(this, getListOfFilesFragment().getCurrentFile()));
|
||||
PreferenceManager.getSortOrderByFolder(this, getListOfFilesFragment().getCurrentFile()));
|
||||
mSortingOrderDialogFragment.show(ft, SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT);
|
||||
|
||||
break;
|
||||
@@ -1120,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,8 +1194,10 @@ public class FileDisplayActivity extends HookActivity
|
||||
// mRefreshSharesInProgress);
|
||||
outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND, mWaitingToSend);
|
||||
if (searchView != null) {
|
||||
outState.putString(KEY_SEARCH_QUERY, searchView.getQuery().toString());
|
||||
outState.putBoolean(KEY_IS_SEARCH_OPEN, !searchView.isIconified());
|
||||
}
|
||||
outState.putString(KEY_SEARCH_QUERY, searchQuery);
|
||||
|
||||
Log_OC.v(TAG, "onSaveInstanceState() end");
|
||||
}
|
||||
|
||||
@@ -1214,7 +1216,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
|
||||
// refresh list of files
|
||||
if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
|
||||
searchView.setQuery(searchQuery, true);
|
||||
searchView.setQuery(searchQuery, false);
|
||||
} else if (getListOfFilesFragment() != null && !getListOfFilesFragment().isSearchFragment()
|
||||
&& startFile == null) {
|
||||
refreshListOfFilesFragment(false);
|
||||
@@ -1249,12 +1251,18 @@ public class FileDisplayActivity extends HookActivity
|
||||
registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
|
||||
|
||||
// setup drawer
|
||||
if (MainApp.isOnlyOnDevice()) {
|
||||
setDrawerMenuItemChecked(R.id.nav_on_device);
|
||||
int menuItemId = getIntent().getIntExtra(FileDisplayActivity.DRAWER_MENU_ID, -1);
|
||||
|
||||
if (menuItemId == -1) {
|
||||
if (MainApp.isOnlyOnDevice()) {
|
||||
setDrawerMenuItemChecked(R.id.nav_on_device);
|
||||
} else {
|
||||
setDrawerMenuItemChecked(R.id.nav_all_files);
|
||||
}
|
||||
} else {
|
||||
setDrawerMenuItemChecked(R.id.nav_all_files);
|
||||
setDrawerMenuItemChecked(menuItemId);
|
||||
}
|
||||
|
||||
|
||||
Log_OC.v(TAG, "onResume() end");
|
||||
}
|
||||
|
||||
@@ -1306,8 +1314,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) {
|
||||
|
||||
@@ -1458,9 +1466,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 {
|
||||
@@ -1468,7 +1475,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,
|
||||
@@ -1565,19 +1572,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) {
|
||||
@@ -1778,6 +1781,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
onUpdateShareInformation(result, R.string.unsharing_failed);
|
||||
} else if (operation instanceof RestoreFileVersionOperation) {
|
||||
onRestoreFileVersionOperationFinish(result);
|
||||
} else if (operation instanceof UpdateNoteForShareOperation) {
|
||||
onUpdateNoteForShareOperationFinish(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1959,6 +1964,19 @@ public class FileDisplayActivity extends HookActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void onUpdateNoteForShareOperationFinish(RemoteOperationResult result) {
|
||||
FileDetailFragment fileDetailFragment = getShareFileFragment();
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (fileDetailFragment != null && fileDetailFragment.getFileDetailSharingFragment() != null) {
|
||||
fileDetailFragment.getFileDetailSharingFragment().refreshPublicShareFromDB();
|
||||
fileDetailFragment.getFileDetailSharingFragment().onUpdateShareInformation(result, getFile());
|
||||
}
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.note_could_not_sent);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyAndShareFileLink(String link) {
|
||||
ClipboardUtil.copyToClipboard(this, link, false);
|
||||
Snackbar snackbar = Snackbar.make(
|
||||
@@ -2025,7 +2043,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
if (fileDetailFragment != null && fileDetailFragment instanceof FileDetailFragment) {
|
||||
if (fileDetailFragment instanceof FileDetailFragment) {
|
||||
((FileDetailFragment) fileDetailFragment).getFileDetailSharingFragment()
|
||||
.onUpdateShareInformation(result, getFile());
|
||||
}
|
||||
@@ -2299,7 +2317,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
} else {
|
||||
Log_OC.e(TAG, "Trying to send a NULL OCFile");
|
||||
}
|
||||
|
||||
|
||||
mWaitingToSend = null;
|
||||
}
|
||||
|
||||
@@ -2393,6 +2411,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(EXTRA_FILE, file);
|
||||
args.putParcelable(EXTRA_ACCOUNT, getAccount());
|
||||
args.putBoolean(EXTRA_SEARCH, searchOpen);
|
||||
args.putString(EXTRA_SEARCH_QUERY, searchQuery);
|
||||
Fragment textPreviewFragment = Fragment.instantiate(getApplicationContext(),
|
||||
PreviewTextFragment.class.getName(), args);
|
||||
setSecondFragment(textPreviewFragment);
|
||||
@@ -2490,9 +2510,23 @@ public class FileDisplayActivity extends HookActivity
|
||||
browseToRoot();
|
||||
}
|
||||
|
||||
public void setActionBarTitle(@StringRes final int title) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getSupportActionBar() != null) {
|
||||
ThemeUtils.setColoredTitle(getSupportActionBar(), title, getBaseContext());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showFiles(boolean onDeviceOnly) {
|
||||
super.showFiles(onDeviceOnly);
|
||||
if (onDeviceOnly) {
|
||||
setActionBarTitle(R.string.drawer_item_on_device);
|
||||
}
|
||||
getListOfFilesFragment().refreshDirectory();
|
||||
}
|
||||
|
||||
@@ -2539,4 +2573,9 @@ public class FileDisplayActivity extends HookActivity
|
||||
|
||||
checkForNewDevVersionNecessary(findViewById(R.id.root_layout), getApplicationContext());
|
||||
}
|
||||
|
||||
public void setSearchQuery(String query) {
|
||||
searchQuery = query;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2018 Tobias Kaminsky
|
||||
* Copyright (C) 2018 Nextcloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.View;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.dialog.SortingOrderDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.utils.FileSortOrder;
|
||||
|
||||
/**
|
||||
* File picker of remote files
|
||||
*/
|
||||
public class FilePickerActivity extends FolderPickerActivity implements
|
||||
SortingOrderDialogFragment.OnSortingOrderListener {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
super.onClick(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createFragments() {
|
||||
OCFileListFragment listOfFiles = new OCFileListFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(OCFileListFragment.ARG_ONLY_FOLDERS_CLICKABLE, true);
|
||||
args.putBoolean(OCFileListFragment.ARG_HIDE_FAB, true);
|
||||
args.putBoolean(OCFileListFragment.ARG_HIDE_ITEM_OPTIONS, true);
|
||||
args.putBoolean(OCFileListFragment.ARG_SEARCH_ONLY_FOLDER, false);
|
||||
args.putBoolean(OCFileListFragment.ARG_FILE_SELECTABLE, true);
|
||||
args.putString(OCFileListFragment.ARG_MIMETYPE, getIntent().getStringExtra(OCFileListFragment.ARG_MIMETYPE));
|
||||
listOfFiles.setArguments(args);
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.add(R.id.fragment_container, listOfFiles, TAG_LIST_OF_FOLDERS);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSortingOrderChosen(FileSortOrder selection) {
|
||||
getListOfFilesFragment().sortFiles(selection);
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
setContentView(R.layout.first_run_activity);
|
||||
|
||||
boolean isProviderOrOwnInstallationVisible = getResources().getBoolean(R.bool.show_provider_or_own_installation);
|
||||
|
||||
|
||||
setSlideshowSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
|
||||
|
||||
Button loginButton = findViewById(R.id.login);
|
||||
@@ -181,7 +181,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
if (!isProviderOrOwnInstallationVisible) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (context instanceof FirstRunActivity) {
|
||||
return false;
|
||||
}
|
||||
@@ -210,7 +210,8 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
}
|
||||
|
||||
public void onHostYourOwnServerClick(View view) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_server_install))));
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.url_server_install)));
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, this, R.string.no_browser_available);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,7 +225,7 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
DisplayUtils.showSnackMessage(this, R.string.account_creation_failed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
setAccount(account);
|
||||
AccountUtils.setCurrentOwnCloudAccount(this, account.name);
|
||||
onAccountSet(false);
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.util.Log;
|
||||
@@ -52,6 +53,7 @@ import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
||||
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.SortingOrderDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.FileFragment;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.utils.DataHolderUtil;
|
||||
@@ -61,6 +63,8 @@ import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.owncloud.android.db.PreferenceManager.getSortOrderByFolder;
|
||||
|
||||
public class FolderPickerActivity extends FileActivity implements FileFragment.ContainerActivity,
|
||||
OnClickListener, OnEnforceableRefreshListener {
|
||||
|
||||
@@ -76,8 +80,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
|
||||
private static final String TAG = FolderPickerActivity.class.getSimpleName();
|
||||
|
||||
private static final String TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS";
|
||||
|
||||
protected static final String TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS";
|
||||
|
||||
private boolean mSyncInProgress;
|
||||
|
||||
private boolean mSearchOnlyFolders;
|
||||
@@ -93,15 +97,18 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.files_folder_picker);
|
||||
|
||||
if (this instanceof FilePickerActivity) {
|
||||
setContentView(R.layout.files_picker);
|
||||
} else {
|
||||
setContentView(R.layout.files_folder_picker);
|
||||
}
|
||||
|
||||
// sets callback listeners for UI elements
|
||||
initControls();
|
||||
|
||||
// Action bar setup
|
||||
setupToolbar();
|
||||
|
||||
|
||||
if (getIntent().getStringExtra(EXTRA_ACTION) != null) {
|
||||
switch (getIntent().getStringExtra(EXTRA_ACTION)) {
|
||||
case MOVE:
|
||||
@@ -137,7 +144,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
|
||||
setIndeterminate(mSyncInProgress);
|
||||
// always AFTER setContentView(...) ; to work around bug in its implementation
|
||||
|
||||
|
||||
// sets message for empty list of folders
|
||||
setBackgroundText();
|
||||
|
||||
@@ -156,23 +163,23 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
protected void onAccountSet(boolean stateWasRecovered) {
|
||||
super.onAccountSet(stateWasRecovered);
|
||||
if (getAccount() != null) {
|
||||
|
||||
|
||||
updateFileFromDB();
|
||||
|
||||
|
||||
OCFile folder = getFile();
|
||||
if (folder == null || !folder.isFolder()) {
|
||||
// fall back to root folder
|
||||
setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
|
||||
folder = getFile();
|
||||
}
|
||||
|
||||
|
||||
if (!stateWasRecovered) {
|
||||
OCFileListFragment listOfFolders = getListOfFilesFragment();
|
||||
OCFileListFragment listOfFolders = getListOfFilesFragment();
|
||||
listOfFolders.listDirectory(folder, false, false);
|
||||
|
||||
|
||||
startSyncFolderOperation(folder, false);
|
||||
}
|
||||
|
||||
|
||||
updateNavigationElementsInActionBar();
|
||||
}
|
||||
}
|
||||
@@ -181,7 +188,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
return this;
|
||||
}
|
||||
|
||||
private void createFragments() {
|
||||
protected void createFragments() {
|
||||
OCFileListFragment listOfFiles = new OCFileListFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(OCFileListFragment.ARG_ONLY_FOLDERS_CLICKABLE, true);
|
||||
@@ -224,10 +231,10 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
Log_OC.e(TAG, "Access to non existing list of files fragment!!");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*
|
||||
* Updates action bar and second fragment, if in dual pane mode.
|
||||
*/
|
||||
@Override
|
||||
@@ -242,12 +249,12 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
public void onSavedCertificate() {
|
||||
startSyncFolderOperation(getCurrentDir(), false);
|
||||
}
|
||||
|
||||
|
||||
public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
|
||||
long currentSyncTime = System.currentTimeMillis();
|
||||
|
||||
long currentSyncTime = System.currentTimeMillis();
|
||||
|
||||
mSyncInProgress = true;
|
||||
|
||||
|
||||
// perform folder synchronization
|
||||
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false,
|
||||
ignoreETag, getStorageManager(), getAccount(), getApplicationContext());
|
||||
@@ -273,10 +280,10 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
|
||||
mSyncBroadcastReceiver = new SyncBroadcastReceiver();
|
||||
registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
|
||||
|
||||
|
||||
Log_OC.d(TAG, "onResume() end");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
Log_OC.e(TAG, "onPause() start");
|
||||
@@ -285,11 +292,11 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
//LocalBroadcastManager.getInstance(this).unregisterReceiver(mSyncBroadcastReceiver);
|
||||
mSyncBroadcastReceiver = null;
|
||||
}
|
||||
|
||||
|
||||
Log_OC.d(TAG, "onPause() end");
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
@@ -297,7 +304,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
menu.findItem(R.id.action_switch_view).setVisible(false);
|
||||
menu.findItem(R.id.action_sync_account).setVisible(false);
|
||||
menu.findItem(R.id.action_select_all).setVisible(false);
|
||||
menu.findItem(R.id.action_sort).setVisible(false);
|
||||
// menu.findItem(R.id.action_sort).setVisible(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -306,12 +313,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
boolean retval = true;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_create_dir: {
|
||||
CreateFolderDialogFragment dialog =
|
||||
CreateFolderDialogFragment.newInstance(getCurrentFolder());
|
||||
dialog.show(
|
||||
getSupportFragmentManager(),
|
||||
CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT
|
||||
);
|
||||
CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(getCurrentFolder());
|
||||
dialog.show(getSupportFragmentManager(), CreateFolderDialogFragment.CREATE_FOLDER_FRAGMENT);
|
||||
break;
|
||||
}
|
||||
case android.R.id.home: {
|
||||
@@ -321,6 +324,17 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
}
|
||||
break;
|
||||
}
|
||||
case R.id.action_sort: {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
FragmentTransaction ft = fm.beginTransaction();
|
||||
ft.addToBackStack(null);
|
||||
|
||||
SortingOrderDialogFragment mSortingOrderDialogFragment = SortingOrderDialogFragment.newInstance(
|
||||
getSortOrderByFolder(this, getListOfFilesFragment().getCurrentFile()));
|
||||
mSortingOrderDialogFragment.show(ft, SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
retval = super.onOptionsItemSelected(item);
|
||||
break;
|
||||
@@ -341,7 +355,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void refreshListOfFilesFragment(boolean fromSearch) {
|
||||
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
||||
if (fileListFragment != null) {
|
||||
@@ -350,7 +364,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
}
|
||||
|
||||
public void browseToRoot() {
|
||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||
OCFileListFragment listOfFiles = getListOfFilesFragment();
|
||||
if (listOfFiles != null) { // should never be null, indeed
|
||||
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
|
||||
listOfFiles.listDirectory(root, false, false);
|
||||
@@ -398,10 +412,13 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
mCancelBtn = findViewById(R.id.folder_picker_btn_cancel);
|
||||
mCancelBtn.setOnClickListener(this);
|
||||
mChooseBtn = findViewById(R.id.folder_picker_btn_choose);
|
||||
mChooseBtn.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
|
||||
mChooseBtn.setOnClickListener(this);
|
||||
|
||||
if (mChooseBtn != null) {
|
||||
mChooseBtn.getBackground().setColorFilter(ThemeUtils.primaryColor(this, true), PorterDuff.Mode.SRC_ATOP);
|
||||
mChooseBtn.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.equals(mCancelBtn)) {
|
||||
@@ -418,30 +435,30 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
|
||||
super.onRemoteOperationFinish(operation, result);
|
||||
|
||||
|
||||
if (operation instanceof CreateFolderOperation) {
|
||||
onCreateFolderOperationFinish((CreateFolderOperation) operation, result);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates the view associated to the activity after the finish of an operation trying
|
||||
* Updates the view associated to the activity after the finish of an operation trying
|
||||
* to create a new folder.
|
||||
*
|
||||
*
|
||||
* @param operation Creation operation performed.
|
||||
* @param result Result of the creation.
|
||||
*/
|
||||
private void onCreateFolderOperationFinish(
|
||||
CreateFolderOperation operation, RemoteOperationResult result
|
||||
) {
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
refreshListOfFilesFragment(false);
|
||||
} else {
|
||||
@@ -455,7 +472,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class SyncBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
/**
|
||||
@@ -472,16 +489,16 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
|
||||
boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name)
|
||||
&& getStorageManager() != null;
|
||||
|
||||
|
||||
if (sameAccount) {
|
||||
if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
|
||||
mSyncInProgress = true;
|
||||
} else {
|
||||
OCFile currentFile = (getFile() == null) ? null :
|
||||
getStorageManager().getFileByPath(getFile().getRemotePath());
|
||||
OCFile currentDir = (getCurrentFolder() == null) ? null :
|
||||
OCFile currentDir = (getCurrentFolder() == null) ? null :
|
||||
getStorageManager().getFileByPath(getCurrentFolder().getRemotePath());
|
||||
|
||||
|
||||
if (currentDir == null) {
|
||||
// current folder was removed from the server
|
||||
DisplayUtils.showSnackMessage(getActivity(), R.string.sync_current_folder_was_removed,
|
||||
@@ -501,8 +518,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
}
|
||||
setFile(currentFile);
|
||||
}
|
||||
|
||||
mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.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) &&
|
||||
@@ -527,9 +544,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
|
||||
|
||||
setBackgroundText();
|
||||
}
|
||||
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
// avoid app crashes after changing the serial id of RemoteOperationResult
|
||||
// avoid app crashes after changing the serial id of RemoteOperationResult
|
||||
// in owncloud library with broadcast notifications pending to process
|
||||
removeStickyBroadcast(intent);
|
||||
DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.io.File;
|
||||
public class ManageSpaceActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = ManageSpaceActivity.class.getSimpleName();
|
||||
|
||||
private static final String LIB_FOLDER = "lib";
|
||||
|
||||
@Override
|
||||
@@ -167,13 +166,13 @@ public class ManageSpaceActivity extends AppCompatActivity {
|
||||
if (dir != null && dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
if (children != null) {
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
boolean success = deleteDir(new File(dir, children[i]));
|
||||
for (String child : children) {
|
||||
boolean success = deleteDir(new File(dir, child));
|
||||
if (!success) {
|
||||
Log_OC.w(TAG, "File NOT deleted " + children[i]);
|
||||
Log_OC.w(TAG, "File NOT deleted " + child);
|
||||
return false;
|
||||
} else {
|
||||
Log_OC.d(TAG, "File deleted " + children[i]);
|
||||
Log_OC.d(TAG, "File deleted " + child);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -181,7 +180,11 @@ public class ManageSpaceActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
return dir.delete();
|
||||
if (dir != null) {
|
||||
return dir.delete();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -234,20 +233,6 @@ public class NotificationsActivity extends FileActivity {
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
setLoadingMessage();
|
||||
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, this);
|
||||
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, this);
|
||||
client.setOwnCloudVersion(AccountUtils.getServerVersion(currentAccount));
|
||||
|
||||
hideRefreshLayoutLoader();
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException |
|
||||
IOException | OperationCanceledException | AuthenticatorException e) {
|
||||
Log_OC.e(TAG, "Error initializing client", e);
|
||||
}
|
||||
|
||||
adapter = new NotificationListAdapter(client, this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
@@ -268,6 +253,22 @@ public class NotificationsActivity extends FileActivity {
|
||||
|
||||
private void fetchAndSetData() {
|
||||
Thread t = new Thread(() -> {
|
||||
if (client == null) {
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(currentAccount, this);
|
||||
client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, this);
|
||||
client.setOwnCloudVersion(AccountUtils.getServerVersion(currentAccount));
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException |
|
||||
IOException | OperationCanceledException | AuthenticatorException e) {
|
||||
Log_OC.e(TAG, "Error initializing client", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (adapter == null) {
|
||||
adapter = new NotificationListAdapter(client, this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
RemoteOperation getRemoteNotificationOperation = new GetRemoteNotificationsOperation();
|
||||
final RemoteOperationResult result = getRemoteNotificationOperation.execute(client);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.text.Html;
|
||||
@@ -33,6 +32,7 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
/**
|
||||
@@ -94,28 +94,23 @@ public class ParticipateActivity extends FileActivity {
|
||||
|
||||
AppCompatButton reportButton = findViewById(R.id.participate_testing_report);
|
||||
reportButton.getBackground().setColorFilter(ThemeUtils.primaryAccentColor(this), PorterDuff.Mode.SRC_ATOP);
|
||||
reportButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.report_issue_link))));
|
||||
}
|
||||
});
|
||||
reportButton.setOnClickListener(v -> DisplayUtils.startLinkIntent(this, R.string.report_issue_link));
|
||||
}
|
||||
|
||||
public void onGetBetaFDroidClick(View view) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.fdroid_beta_link))));
|
||||
DisplayUtils.startLinkIntent(this, R.string.fdroid_beta_link);
|
||||
}
|
||||
|
||||
public void onGetRCFDroidClick(View view) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.fdroid_link))));
|
||||
DisplayUtils.startLinkIntent(this, R.string.fdroid_link);
|
||||
}
|
||||
|
||||
public void onGetRCPlayStoreClick(View view) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.play_store_register_beta))));
|
||||
DisplayUtils.startLinkIntent(this, R.string.play_store_register_beta);
|
||||
}
|
||||
|
||||
public void onGetBetaApkClick(View view) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.beta_apk_link))));
|
||||
DisplayUtils.startLinkIntent(this, R.string.beta_apk_link);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,8 +36,6 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceCategory;
|
||||
import android.preference.PreferenceManager;
|
||||
@@ -145,9 +143,6 @@ public class Preferences extends PreferenceActivity
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
// retrieve user's base uri
|
||||
setupBaseUri();
|
||||
|
||||
setupActionBar();
|
||||
|
||||
// Register context menu for list of preferences.
|
||||
@@ -160,6 +155,9 @@ public class Preferences extends PreferenceActivity
|
||||
mAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
|
||||
mArbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
|
||||
// retrieve user's base uri
|
||||
setupBaseUri();
|
||||
|
||||
// General
|
||||
setupGeneralCategory(accentColor);
|
||||
|
||||
@@ -174,7 +172,7 @@ public class Preferences extends PreferenceActivity
|
||||
|
||||
// About
|
||||
setupAboutCategory(accentColor, appVersion);
|
||||
|
||||
|
||||
// Dev
|
||||
setupDevCategory(accentColor, preferenceScreen);
|
||||
}
|
||||
@@ -204,10 +202,7 @@ public class Preferences extends PreferenceActivity
|
||||
Preference pChangelogLink = findPreference("changelog_link");
|
||||
if (pChangelogLink != null) {
|
||||
pChangelogLink.setOnPreferenceClickListener(preference -> {
|
||||
String devChangelogLink = getString(R.string.dev_changelog);
|
||||
Uri uriUrl = Uri.parse(devChangelogLink);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
startActivity(intent);
|
||||
DisplayUtils.startLinkIntent(this, R.string.dev_changelog);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -232,18 +227,11 @@ public class Preferences extends PreferenceActivity
|
||||
boolean licenseEnabled = getResources().getBoolean(R.bool.license_enabled);
|
||||
Preference licensePreference = findPreference("license");
|
||||
if (licensePreference != null) {
|
||||
String licenseUrl = getString(R.string.license_url);
|
||||
|
||||
if (licenseEnabled && !licenseUrl.isEmpty()) {
|
||||
if (licenseEnabled) {
|
||||
licensePreference.setSummary(R.string.prefs_gpl_v2);
|
||||
licensePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Uri uriUrl = Uri.parse(licenseUrl);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
licensePreference.setOnPreferenceClickListener(preference -> {
|
||||
DisplayUtils.startLinkIntent(this, R.string.license_url);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryAbout.removePreference(licensePreference);
|
||||
@@ -255,32 +243,30 @@ public class Preferences extends PreferenceActivity
|
||||
Preference privacyPreference = findPreference("privacy");
|
||||
if (privacyPreference != null) {
|
||||
if (privacyEnabled && URLUtil.isValidUrl(getString(R.string.privacy_url))) {
|
||||
privacyPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
try {
|
||||
Uri privacyUrl = Uri.parse(getString(R.string.privacy_url));
|
||||
String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(privacyUrl.getLastPathSegment());
|
||||
|
||||
Intent intent;
|
||||
if ("application/pdf".equals(mimeType)) {
|
||||
intent = new Intent(Intent.ACTION_VIEW, privacyUrl);
|
||||
} else {
|
||||
intent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_TITLE,
|
||||
getResources().getString(R.string.privacy));
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_URL, privacyUrl.toString());
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, -1);
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Could not parse privacy url");
|
||||
preferenceCategoryAbout.removePreference(privacyPreference);
|
||||
privacyPreference.setOnPreferenceClickListener(preference -> {
|
||||
try {
|
||||
Uri privacyUrl = Uri.parse(getString(R.string.privacy_url));
|
||||
String mimeType = MimeTypeUtil.getBestMimeTypeByFilename(privacyUrl.getLastPathSegment());
|
||||
|
||||
Intent intent;
|
||||
if ("application/pdf".equals(mimeType)) {
|
||||
intent = new Intent(Intent.ACTION_VIEW, privacyUrl);
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, this, R.string.no_pdf_app_available);
|
||||
} else {
|
||||
intent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_TITLE,
|
||||
getResources().getString(R.string.privacy));
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_URL, privacyUrl.toString());
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
|
||||
intent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, -1);
|
||||
}
|
||||
return true;
|
||||
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Could not parse privacy url");
|
||||
preferenceCategoryAbout.removePreference(privacyPreference);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryAbout.removePreference(privacyPreference);
|
||||
@@ -291,16 +277,10 @@ public class Preferences extends PreferenceActivity
|
||||
boolean sourcecodeEnabled = getResources().getBoolean(R.bool.sourcecode_enabled);
|
||||
Preference sourcecodePreference = findPreference("sourcecode");
|
||||
if (sourcecodePreference != null) {
|
||||
String sourcecodeUrl = getString(R.string.sourcecode_url);
|
||||
if (sourcecodeEnabled && !sourcecodeUrl.isEmpty()) {
|
||||
sourcecodePreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Uri uriUrl = Uri.parse(sourcecodeUrl);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
if (sourcecodeEnabled) {
|
||||
sourcecodePreference.setOnPreferenceClickListener(preference -> {
|
||||
DisplayUtils.startLinkIntent(this, R.string.sourcecode_url);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryAbout.removePreference(sourcecodePreference);
|
||||
@@ -337,18 +317,16 @@ public class Preferences extends PreferenceActivity
|
||||
Preference pImprint = findPreference("imprint");
|
||||
if (pImprint != null) {
|
||||
if (imprintEnabled) {
|
||||
pImprint.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String imprintWeb = getString(R.string.url_imprint);
|
||||
if (imprintWeb != null && imprintWeb.length() > 0) {
|
||||
Uri uriUrl = Uri.parse(imprintWeb);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
startActivity(intent);
|
||||
}
|
||||
//ImprintDialog.newInstance(true).show(preference.get, "IMPRINT_DIALOG");
|
||||
return true;
|
||||
pImprint.setOnPreferenceClickListener(preference -> {
|
||||
String imprintWeb = getString(R.string.url_imprint);
|
||||
|
||||
if (!imprintWeb.isEmpty()) {
|
||||
Uri uriUrl = Uri.parse(imprintWeb);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, this, R.string.no_browser_available);
|
||||
}
|
||||
//ImprintDialog.newInstance(true).show(preference.get, "IMPRINT_DIALOG");
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryMore.removePreference(pImprint);
|
||||
@@ -365,14 +343,11 @@ public class Preferences extends PreferenceActivity
|
||||
Preference pLogger = findPreference("logger");
|
||||
if (pLogger != null) {
|
||||
if (loggerEnabled) {
|
||||
pLogger.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent loggerIntent = new Intent(getApplicationContext(), LogHistoryActivity.class);
|
||||
startActivity(loggerIntent);
|
||||
pLogger.setOnPreferenceClickListener(preference -> {
|
||||
Intent loggerIntent = new Intent(getApplicationContext(), LogHistoryActivity.class);
|
||||
startActivity(loggerIntent);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryMore.removePreference(pLogger);
|
||||
@@ -385,26 +360,21 @@ public class Preferences extends PreferenceActivity
|
||||
Preference pFeedback = findPreference("feedback");
|
||||
if (pFeedback != null) {
|
||||
if (feedbackEnabled) {
|
||||
pFeedback.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String feedbackMail = getString(R.string.mail_feedback);
|
||||
String feedback = getText(R.string.prefs_feedback) + " - android v" + appVersion;
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
|
||||
pFeedback.setOnPreferenceClickListener(preference -> {
|
||||
String feedbackMail = getString(R.string.mail_feedback);
|
||||
String feedback = getText(R.string.prefs_feedback) + " - android v" + appVersion;
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||
intent.setDataAndType(Uri.parse(feedbackMail), "text/plain");
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
intent.setData(Uri.parse(feedbackMail));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(Preferences.this, R.string.feedback_no_mail_app);
|
||||
}
|
||||
|
||||
return true;
|
||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(intent);
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(this, R.string.feedback_no_mail_app);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryMore.removePreference(pFeedback);
|
||||
@@ -417,31 +387,28 @@ public class Preferences extends PreferenceActivity
|
||||
Preference pRecommend = findPreference("recommend");
|
||||
if (pRecommend != null) {
|
||||
if (recommendEnabled) {
|
||||
pRecommend.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
pRecommend.setOnPreferenceClickListener(preference -> {
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
String appName = getString(R.string.app_name);
|
||||
String downloadUrlGooglePlayStore = getString(R.string.url_app_download);
|
||||
String downloadUrlFDroid = getString(R.string.fdroid_link);
|
||||
String downloadUrls = String.format(getString(R.string.recommend_urls),
|
||||
downloadUrlGooglePlayStore, downloadUrlFDroid);
|
||||
String appName = getString(R.string.app_name);
|
||||
String downloadUrlGooglePlayStore = getString(R.string.url_app_download);
|
||||
String downloadUrlFDroid = getString(R.string.fdroid_link);
|
||||
String downloadUrls = String.format(getString(R.string.recommend_urls),
|
||||
downloadUrlGooglePlayStore, downloadUrlFDroid);
|
||||
|
||||
String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
|
||||
String recommendText = String.format(getString(R.string.recommend_text),
|
||||
appName, downloadUrls);
|
||||
String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
|
||||
String recommendText = String.format(getString(R.string.recommend_text),
|
||||
appName, downloadUrls);
|
||||
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, recommendText);
|
||||
startActivity(intent);
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, recommendText);
|
||||
startActivity(intent);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryMore.removePreference(pRecommend);
|
||||
@@ -456,16 +423,13 @@ public class Preferences extends PreferenceActivity
|
||||
if (pMnemonic != null) {
|
||||
if (!mnemonic.isEmpty() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (DeviceCredentialUtils.areCredentialsAvailable(this)) {
|
||||
pMnemonic.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
pMnemonic.setOnPreferenceClickListener(preference -> {
|
||||
|
||||
Intent i = new Intent(MainApp.getAppContext(), RequestCredentialsActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
Preferences.this.startActivityForResult(i, PassCodeManager.PASSCODE_ACTIVITY);
|
||||
Intent i = new Intent(MainApp.getAppContext(), RequestCredentialsActivity.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
startActivityForResult(i, PassCodeManager.PASSCODE_ACTIVITY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
pMnemonic.setEnabled(false);
|
||||
@@ -482,17 +446,14 @@ public class Preferences extends PreferenceActivity
|
||||
Preference pHelp = findPreference("help");
|
||||
if (pHelp != null) {
|
||||
if (helpEnabled) {
|
||||
pHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String helpWeb = getString(R.string.url_help);
|
||||
if (helpWeb != null && helpWeb.length() > 0) {
|
||||
Uri uriUrl = Uri.parse(helpWeb);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
startActivity(intent);
|
||||
}
|
||||
return true;
|
||||
pHelp.setOnPreferenceClickListener(preference -> {
|
||||
String helpWeb = getString(R.string.url_help);
|
||||
if (!helpWeb.isEmpty()) {
|
||||
Uri uriUrl = Uri.parse(helpWeb);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
DisplayUtils.startIntentIfAppAvailable(intent, this, R.string.no_browser_available);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryMore.removePreference(pHelp);
|
||||
@@ -506,14 +467,11 @@ public class Preferences extends PreferenceActivity
|
||||
Preference pContactsBackup = findPreference("contacts");
|
||||
if (pContactsBackup != null) {
|
||||
if (contactsBackupEnabled) {
|
||||
pContactsBackup.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent contactsIntent = new Intent(getApplicationContext(), ContactsPreferenceActivity.class);
|
||||
contactsIntent.putExtra(ContactsPreferenceActivity.EXTRA_SHOW_SIDEBAR, false);
|
||||
startActivity(contactsIntent);
|
||||
return true;
|
||||
}
|
||||
pContactsBackup.setOnPreferenceClickListener(preference -> {
|
||||
Intent contactsIntent = new Intent(getApplicationContext(), ContactsPreferenceActivity.class);
|
||||
contactsIntent.putExtra(ContactsPreferenceActivity.EXTRA_SHOW_SIDEBAR, false);
|
||||
startActivity(contactsIntent);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryMore.removePreference(pContactsBackup);
|
||||
@@ -527,20 +485,17 @@ public class Preferences extends PreferenceActivity
|
||||
if (pCalendarContacts != null) {
|
||||
if (calendarContactsEnabled) {
|
||||
final Activity activity = this;
|
||||
pCalendarContacts.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
try {
|
||||
launchDavDroidLogin();
|
||||
} catch (Throwable t) {
|
||||
Log_OC.e(TAG, "Base Uri for account could not be resolved to call DAVdroid!", t);
|
||||
DisplayUtils.showSnackMessage(
|
||||
activity,
|
||||
R.string.prefs_calendar_contacts_address_resolve_error
|
||||
);
|
||||
}
|
||||
return true;
|
||||
pCalendarContacts.setOnPreferenceClickListener(preference -> {
|
||||
try {
|
||||
launchDavDroidLogin();
|
||||
} catch (Throwable t) {
|
||||
Log_OC.e(TAG, "Base Uri for account could not be resolved to call DAVdroid!", t);
|
||||
DisplayUtils.showSnackMessage(
|
||||
activity,
|
||||
R.string.prefs_calendar_contacts_address_resolve_error
|
||||
);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryMore.removePreference(pCalendarContacts);
|
||||
@@ -577,26 +532,23 @@ public class Preferences extends PreferenceActivity
|
||||
preferenceCategoryDetails.removePreference(mExpertMode);
|
||||
} else {
|
||||
mExpertMode = (SwitchPreference) findPreference(PREFERENCE_EXPERT_MODE);
|
||||
mExpertMode.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putBoolean(PREFERENCE_EXPERT_MODE, mExpertMode.isChecked());
|
||||
editor.apply();
|
||||
mExpertMode.setOnPreferenceClickListener(preference -> {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putBoolean(PREFERENCE_EXPERT_MODE, mExpertMode.isChecked());
|
||||
editor.apply();
|
||||
|
||||
if (mExpertMode.isChecked()) {
|
||||
Log_OC.startLogging(getApplicationContext());
|
||||
} else {
|
||||
if (!BuildConfig.DEBUG &&
|
||||
!getApplicationContext().getResources().getBoolean(R.bool.logger_enabled)) {
|
||||
Log_OC.stopLogging();
|
||||
}
|
||||
if (mExpertMode.isChecked()) {
|
||||
Log_OC.startLogging(getApplicationContext());
|
||||
} else {
|
||||
if (!BuildConfig.DEBUG &&
|
||||
!getApplicationContext().getResources().getBoolean(R.bool.logger_enabled)) {
|
||||
Log_OC.stopLogging();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -605,16 +557,13 @@ public class Preferences extends PreferenceActivity
|
||||
boolean fShowHiddenFilesEnabled) {
|
||||
mShowHiddenFiles = (SwitchPreference) findPreference("show_hidden_files");
|
||||
if (fShowHiddenFilesEnabled) {
|
||||
mShowHiddenFiles.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putBoolean("show_hidden_files_pref", mShowHiddenFiles.isChecked());
|
||||
editor.apply();
|
||||
return true;
|
||||
}
|
||||
mShowHiddenFiles.setOnPreferenceClickListener(preference -> {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putBoolean("show_hidden_files_pref", mShowHiddenFiles.isChecked());
|
||||
editor.apply();
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryDetails.removePreference(mShowHiddenFiles);
|
||||
@@ -652,22 +601,19 @@ public class Preferences extends PreferenceActivity
|
||||
mLock.setEntries(lockEntriesArr);
|
||||
mLock.setEntryValues(lockValuesArr);
|
||||
mLock.setSummary(mLock.getEntry());
|
||||
mLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
pendingLock = LOCK_NONE;
|
||||
String oldValue = ((ListPreference) preference).getValue();
|
||||
String newValue = (String) o;
|
||||
if (!oldValue.equals(newValue)) {
|
||||
if (LOCK_NONE.equals(oldValue)) {
|
||||
enableLock(newValue);
|
||||
} else {
|
||||
pendingLock = newValue;
|
||||
disableLock(oldValue);
|
||||
}
|
||||
mLock.setOnPreferenceChangeListener((preference, o) -> {
|
||||
pendingLock = LOCK_NONE;
|
||||
String oldValue = ((ListPreference) preference).getValue();
|
||||
String newValue = (String) o;
|
||||
if (!oldValue.equals(newValue)) {
|
||||
if (LOCK_NONE.equals(oldValue)) {
|
||||
enableLock(newValue);
|
||||
} else {
|
||||
pendingLock = newValue;
|
||||
disableLock(oldValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
preferenceCategoryDetails.removePreference(mLock);
|
||||
@@ -690,29 +636,22 @@ public class Preferences extends PreferenceActivity
|
||||
pUploadOnWifiCheckbox.setChecked(
|
||||
arbitraryDataProvider.getBooleanValue(mAccount, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI));
|
||||
|
||||
pUploadOnWifiCheckbox.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(mAccount.name, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI,
|
||||
String.valueOf(pUploadOnWifiCheckbox.isChecked()));
|
||||
pUploadOnWifiCheckbox.setOnPreferenceClickListener(preference -> {
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(mAccount.name, SYNCED_FOLDER_LIGHT_UPLOAD_ON_WIFI,
|
||||
String.valueOf(pUploadOnWifiCheckbox.isChecked()));
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
Preference pSyncedFolder = findPreference("synced_folders_configure_folders");
|
||||
if (pSyncedFolder != null) {
|
||||
if (getResources().getBoolean(R.bool.syncedFolder_light)
|
||||
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
pSyncedFolder.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent syncedFoldersIntent =
|
||||
new Intent(getApplicationContext(), SyncedFoldersActivity.class);
|
||||
syncedFoldersIntent.putExtra(SyncedFoldersActivity.EXTRA_SHOW_SIDEBAR, false);
|
||||
startActivity(syncedFoldersIntent);
|
||||
return true;
|
||||
}
|
||||
pSyncedFolder.setOnPreferenceClickListener(preference -> {
|
||||
Intent syncedFoldersIntent = new Intent(getApplicationContext(), SyncedFoldersActivity.class);
|
||||
syncedFoldersIntent.putExtra(SyncedFoldersActivity.EXTRA_SHOW_SIDEBAR, false);
|
||||
startActivity(syncedFoldersIntent);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
preferenceCategorySyncedFolders.removePreference(pSyncedFolder);
|
||||
@@ -767,22 +706,18 @@ public class Preferences extends PreferenceActivity
|
||||
mPrefStoragePath.setEntries(entries);
|
||||
mPrefStoragePath.setEntryValues(values);
|
||||
|
||||
mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String newPath = (String) newValue;
|
||||
if (mStoragePath.equals(newPath)) {
|
||||
return true;
|
||||
}
|
||||
mPrefStoragePath.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
String newPath = (String) newValue;
|
||||
|
||||
StorageMigration storageMigration = new StorageMigration(Preferences.this, mStoragePath, newPath);
|
||||
|
||||
storageMigration.setStorageMigrationProgressListener(Preferences.this);
|
||||
|
||||
storageMigration.migrate();
|
||||
|
||||
return false;
|
||||
if (mStoragePath.equals(newPath)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
StorageMigration storageMigration = new StorageMigration(this, mStoragePath, newPath);
|
||||
storageMigration.setStorageMigrationProgressListener(this);
|
||||
storageMigration.migrate();
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -847,7 +782,6 @@ public class Preferences extends PreferenceActivity
|
||||
davDroidLoginIntent.putExtra("url", mUri.toString() + DAV_PATH);
|
||||
}
|
||||
davDroidLoginIntent.putExtra("username", AccountUtils.getAccountUsername(mAccount.name));
|
||||
//loginIntent.putExtra("password", "...");
|
||||
startActivityForResult(davDroidLoginIntent, ACTION_REQUEST_CODE_DAVDROID_SETUP);
|
||||
} else {
|
||||
// DAVdroid not installed
|
||||
@@ -860,7 +794,7 @@ public class Preferences extends PreferenceActivity
|
||||
// no f-droid market app or Play store installed --> launch browser for f-droid url
|
||||
Intent downloadIntent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse("https://f-droid.org/repository/browse/?fdid=at.bitfire.davdroid"));
|
||||
startActivity(downloadIntent);
|
||||
DisplayUtils.startIntentIfAppAvailable(downloadIntent, this, R.string.no_browser_available);
|
||||
|
||||
DisplayUtils.showSnackMessage(this, R.string.prefs_calendar_contacts_no_store_error);
|
||||
}
|
||||
@@ -869,15 +803,13 @@ public class Preferences extends PreferenceActivity
|
||||
|
||||
private void setupBaseUri() {
|
||||
// retrieve and set user's base URI
|
||||
Thread t = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, MainApp.getAppContext());
|
||||
mUri = OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
getClientFor(ocAccount, getApplicationContext()).getBaseUri();
|
||||
} catch (Throwable t) {
|
||||
Log_OC.e(TAG, "Error retrieving user's base URI", t);
|
||||
}
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, MainApp.getAppContext());
|
||||
mUri = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount,
|
||||
getApplicationContext()).getBaseUri();
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Error retrieving user's base URI", e);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
@@ -932,25 +864,30 @@ public class Preferences extends PreferenceActivity
|
||||
if (!LOCK_NONE.equals(pendingLock)) {
|
||||
enableLock(pendingLock);
|
||||
}
|
||||
} else if (requestCode == PassCodeManager.PASSCODE_ACTIVITY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||
data.getIntExtra(RequestCredentialsActivity.KEY_CHECK_RESULT,
|
||||
} else if (requestCode == PassCodeManager.PASSCODE_ACTIVITY && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (data == null) {
|
||||
DisplayUtils.showSnackMessage(this, "Error retrieving mnemonic!");
|
||||
} else {
|
||||
if (data.getIntExtra(RequestCredentialsActivity.KEY_CHECK_RESULT,
|
||||
RequestCredentialsActivity.KEY_CHECK_RESULT_FALSE) ==
|
||||
RequestCredentialsActivity.KEY_CHECK_RESULT_TRUE) {
|
||||
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
String mnemonic = arbitraryDataProvider.getValue(mAccount.name, EncryptionUtils.MNEMONIC);
|
||||
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
|
||||
String mnemonic = arbitraryDataProvider.getValue(mAccount.name, EncryptionUtils.MNEMONIC);
|
||||
|
||||
int accentColor = ThemeUtils.primaryAccentColor(this);
|
||||
int accentColor = ThemeUtils.primaryAccentColor(this);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.FallbackTheming_Dialog);
|
||||
builder.setTitle(ThemeUtils.getColoredTitle(getString(R.string.prefs_e2e_mnemonic), accentColor));
|
||||
builder.setMessage(mnemonic);
|
||||
builder.setPositiveButton(ThemeUtils.getColoredTitle(getString(R.string.common_ok), accentColor),
|
||||
(dialog, which) -> dialog.dismiss());
|
||||
builder.show();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.FallbackTheming_Dialog);
|
||||
builder.setTitle(ThemeUtils.getColoredTitle(getString(R.string.prefs_e2e_mnemonic), accentColor));
|
||||
builder.setMessage(mnemonic);
|
||||
builder.setPositiveButton(ThemeUtils.getColoredTitle(getString(R.string.common_ok), accentColor),
|
||||
(dialog, which) -> dialog.dismiss());
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public MenuInflater getMenuInflater() {
|
||||
@@ -1036,19 +973,15 @@ public class Preferences extends PreferenceActivity
|
||||
p.setTitle(link.name);
|
||||
p.setKey(link.id.toString());
|
||||
|
||||
p.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent externalWebViewIntent =
|
||||
new Intent(getApplicationContext(), ExternalSiteWebView.class);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.name);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, link.url);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, link.id);
|
||||
startActivity(externalWebViewIntent);
|
||||
p.setOnPreferenceClickListener(preference -> {
|
||||
Intent externalWebViewIntent = new Intent(getApplicationContext(), ExternalSiteWebView.class);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_TITLE, link.name);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_URL, link.url);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_SHOW_SIDEBAR, false);
|
||||
externalWebViewIntent.putExtra(ExternalSiteWebView.EXTRA_MENU_ITEM_ID, link.id);
|
||||
startActivity(externalWebViewIntent);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
preferenceCategory.addPreference(p);
|
||||
|
||||
Loaded 100 of 254 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user