Compare commits
166
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
c543846918 | ||
|
|
6b0023a28a | ||
|
|
bdef26f774 | ||
|
|
0efdf2bbac | ||
|
|
a6910a3d13 | ||
|
|
6909794879 | ||
|
|
3f3cef84b1 | ||
|
|
6caa0b927b | ||
|
|
a1253ce117 | ||
|
|
d9ce5b0228 | ||
|
|
df742e0712 | ||
|
|
3d3980a67b | ||
|
|
785433108e | ||
|
|
1f8854769b | ||
|
|
4da88c2acb | ||
|
|
c99cea497d | ||
|
|
521b1cda01 | ||
|
|
aa09934df1 | ||
|
|
82ea0bcd68 | ||
|
|
903b0802a0 | ||
|
|
0e7e85fabf | ||
|
|
23a1a1f3b6 | ||
|
|
e46aacc9c8 | ||
|
|
7a7c1100c3 | ||
|
|
e164da3beb | ||
|
|
e04b94b2f6 | ||
|
|
fddcbbbecd | ||
|
|
d0f474e611 | ||
|
|
086492b6d4 | ||
|
|
5ac1af47c1 | ||
|
|
0c86ed9f77 | ||
|
|
ff6cf2df4a | ||
|
|
9f2b8a73c8 | ||
|
|
c4bbb792dc | ||
|
|
ba84def527 | ||
|
|
d7d2e1916f | ||
|
|
cc66d8857e | ||
|
|
b49e881d43 | ||
|
|
fc62aa42b8 | ||
|
|
fc3a911a14 | ||
|
|
ee4ec654de | ||
|
|
755425cf0c | ||
|
|
c839a5b83e | ||
|
|
112450418a | ||
|
|
f6f0165caf | ||
|
|
0fb3dedef1 | ||
|
|
333dfcb1ed | ||
|
|
f81415dbab | ||
|
|
d5008116db | ||
|
|
994d73f529 | ||
|
|
65df2e82b3 | ||
|
|
ce4ce8db41 | ||
|
|
0f7fe6fd1c | ||
|
|
4724ab3329 | ||
|
|
b40b12e0eb | ||
|
|
5195badfd1 | ||
|
|
fb4b9a932f | ||
|
|
69399c394f | ||
|
|
0e93f00277 | ||
|
|
5f10a9301b | ||
|
|
916ef99313 | ||
|
|
00a045864d | ||
|
|
7ffc8660bb | ||
|
|
0c371b9603 | ||
|
|
dafe42d1c5 | ||
|
|
cbf84e27bb | ||
|
|
f5ab3c9a53 | ||
|
|
d8da2f8007 | ||
|
|
da8d098fa1 | ||
|
|
9e4a9d7027 | ||
|
|
21ebf1568e | ||
|
|
3ac8a8875b | ||
|
|
63fe97e7e0 | ||
|
|
bca12ca282 | ||
|
|
637f117784 | ||
|
|
ca05284cda | ||
|
|
6ade530a26 | ||
|
|
7dc0604b8b | ||
|
|
f996b3f671 | ||
|
|
775671463d | ||
|
|
66b59ddf07 | ||
|
|
9e640c6837 | ||
|
|
914a2b67ca | ||
|
|
3168dc779a | ||
|
|
ef466a372c | ||
|
|
cd65368ead | ||
|
|
58e43e27ef | ||
|
|
591bf4f422 | ||
|
|
807537f8fd | ||
|
|
46efc82c51 |
No files matched your search
+3
-3
@@ -1,6 +1,6 @@
|
||||
pipeline:
|
||||
compile:
|
||||
image: nextcloudci/android:android-35
|
||||
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-35
|
||||
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-37
|
||||
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
|
||||
@@ -20,6 +20,10 @@ group_defaults:
|
||||
enabled: false
|
||||
reset_on_reopened:
|
||||
enabled: true
|
||||
conditions:
|
||||
labels:
|
||||
exclude:
|
||||
- dependencies
|
||||
|
||||
groups:
|
||||
code-review:
|
||||
|
||||
+25
-10
@@ -1,10 +1,25 @@
|
||||
## 3.2.4 (Sept, 04, 2018)
|
||||
fix push notification on gplay release
|
||||
## 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.3 (Aug, 21, 2018)
|
||||
## 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 +37,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 +73,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
|
||||
|
||||
@@ -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:
|
||||
|
||||
+18
-16
@@ -15,9 +15,9 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.4'
|
||||
classpath 'com.android.tools.build:gradle:3.2.0'
|
||||
classpath 'org.codehaus.groovy:groovy-all:2.4.12'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.2') {
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.3') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
}
|
||||
@@ -30,13 +30,14 @@ apply plugin: 'findbugs'
|
||||
apply plugin: 'jacoco-android'
|
||||
|
||||
configurations.all {
|
||||
exclude group: 'com.google.firebase', module: 'firebase-core'
|
||||
// check for updates every build
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
}
|
||||
|
||||
ext {
|
||||
supportLibraryVersion = '27.1.1'
|
||||
jacocoVersion = "0.7.4.201502262128"
|
||||
supportLibraryVersion = '28.0.0'
|
||||
jacocoVersion = "0.8.2"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
@@ -59,7 +60,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 / 99=stable
|
||||
|
||||
def taskRequest = getGradle().getStartParameter().getTaskRequests().toString()
|
||||
if (taskRequest.contains("Gplay") || taskRequest.contains("findbugs") || taskRequest.contains("lint")) {
|
||||
@@ -78,11 +79,11 @@ android {
|
||||
javaMaxHeapSize "4g"
|
||||
}
|
||||
|
||||
compileSdkVersion 27
|
||||
compileSdkVersion 28
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
targetSdkVersion 28
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -97,8 +98,8 @@ android {
|
||||
|
||||
if (versionBuild > 98) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
|
||||
} else if (versionBuild > 49) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-49)
|
||||
} else if (versionBuild > 50) {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} RC"+(versionBuild-50)
|
||||
} else {
|
||||
versionName "${versionMajor}.${versionMinor}.${versionPatch} Alpha"+(versionBuild+1)
|
||||
}
|
||||
@@ -129,8 +130,8 @@ android {
|
||||
versionDev {
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
dimension "default"
|
||||
versionCode 20180908
|
||||
versionName "20180908"
|
||||
versionCode 20180927
|
||||
versionName "20180927"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,7 +183,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
|
||||
@@ -214,15 +215,16 @@ dependencies {
|
||||
genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
|
||||
gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
|
||||
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
|
||||
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.1.0'
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.2.0'
|
||||
implementation 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.5'
|
||||
implementation 'commons-io:commons-io:2.6'
|
||||
implementation 'com.github.evernote:android-job:v1.2.5'
|
||||
implementation 'com.jakewharton:butterknife:8.8.1'
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
|
||||
@@ -246,7 +248,7 @@ dependencies {
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.mockito:mockito-core:2.21.0'
|
||||
testImplementation 'org.mockito:mockito-core:2.22.0'
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
androidTestImplementation 'com.android.support.test:rules:1.0.2'
|
||||
@@ -260,7 +262,7 @@ dependencies {
|
||||
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
//androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
|
||||
implementation 'org.jetbrains:annotations:15.0'
|
||||
implementation 'org.jetbrains:annotations:16.0.3'
|
||||
|
||||
androidTestImplementation 'tools.fastlane:screengrab:1.2.0'
|
||||
|
||||
|
||||
@@ -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 |
+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,38 +0,0 @@
|
||||
-optimizationpasses 5
|
||||
-dontusemixedcaseclassnames
|
||||
-dontskipnonpubliclibraryclasses
|
||||
-dontpreverify
|
||||
-verbose
|
||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||
|
||||
-keep public class * extends android.app.Activity
|
||||
-keep public class * extends android.app.Application
|
||||
-keep public class * extends android.app.Service
|
||||
-keep public class * extends android.content.BroadcastReceiver
|
||||
-keep public class * extends android.content.ContentProvider
|
||||
-keep public class * extends android.app.backup.BackupAgentHelper
|
||||
-keep public class * extends android.preference.Preference
|
||||
-keep public class com.android.vending.licensing.ILicensingService
|
||||
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
}
|
||||
|
||||
-keep class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
||||
|
||||
-keepattributes InnerClasses
|
||||
@@ -11,13 +11,13 @@
|
||||
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
|
||||
@@ -58,6 +58,17 @@ 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" ")
|
||||
|
||||
@@ -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: 113 warnings</span>
|
||||
@@ -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;
|
||||
@@ -26,7 +26,7 @@ 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;
|
||||
@@ -36,14 +36,10 @@ public abstract class AbstractIT extends ApplicationTestCase<MainApp> {
|
||||
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));
|
||||
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Приложението Nextcloud за Android осигурява достъп до всичките ви файлове в Next
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -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 & Synchronizace 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
|
||||
|
||||
Noví v Nextcloud? Nextcloud je server pro soukromou synchronizaci souborů &, sdílení a komunikaci. Je to svobodný software a můžete ho buď provozovat sami nebo pronajímat od 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
|
||||
@@ -0,0 +1 @@
|
||||
Hệ thống là ứng dụng Android cho phép modile truy cập tất cả các tập tin của bạn
|
||||
@@ -0,0 +1 @@
|
||||
Nextcloud
|
||||
@@ -28,9 +28,12 @@ import com.owncloud.android.db.PreferenceManager;
|
||||
|
||||
import java.security.Key;
|
||||
|
||||
public class PushUtils {
|
||||
public final class PushUtils {
|
||||
public static final String KEY_PUSH = "push";
|
||||
|
||||
private PushUtils() {
|
||||
}
|
||||
|
||||
public static void pushRegistrationToServer() {
|
||||
// do nothing
|
||||
}
|
||||
@@ -44,7 +47,7 @@ public class PushUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
public static SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,13 @@ import android.util.Log;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
|
||||
public class GooglePlayUtils {
|
||||
public final class GooglePlayUtils {
|
||||
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
|
||||
private static final String TAG = "GooglePlayUtils";
|
||||
|
||||
private GooglePlayUtils() {
|
||||
}
|
||||
|
||||
public static boolean checkPlayServices(Activity activity) {
|
||||
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
|
||||
int resultCode = apiAvailability.isGooglePlayServicesAvailable(activity);
|
||||
|
||||
@@ -71,7 +71,7 @@ import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Locale;
|
||||
|
||||
public class PushUtils {
|
||||
public final class PushUtils {
|
||||
|
||||
public static final String KEY_PUSH = "push";
|
||||
private static final String TAG = "PushUtils";
|
||||
@@ -81,6 +81,9 @@ public class PushUtils {
|
||||
private static final String KEYPAIR_PUB_EXTENSION = ".pub";
|
||||
private static ArbitraryDataProvider arbitraryDataProvider;
|
||||
|
||||
private PushUtils() {
|
||||
}
|
||||
|
||||
public static String generateSHA512Hash(String pushToken) {
|
||||
MessageDigest messageDigest = null;
|
||||
try {
|
||||
@@ -295,7 +298,6 @@ public class PushUtils {
|
||||
fileInputStream = new FileInputStream(path);
|
||||
byte[] bytes = new byte[fileInputStream.available()];
|
||||
fileInputStream.read(bytes);
|
||||
fileInputStream.close();
|
||||
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
|
||||
@@ -315,6 +317,14 @@ public class PushUtils {
|
||||
Log_OC.d(TAG, "InvalidKeySpecException while reading the key");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log_OC.d(TAG, "RSA algorithm not supported");
|
||||
} finally {
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error closing input stream during reading key from file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -331,12 +341,19 @@ public class PushUtils {
|
||||
}
|
||||
keyFileOutputStream = new FileOutputStream(path);
|
||||
keyFileOutputStream.write(encoded);
|
||||
keyFileOutputStream.close();
|
||||
return 0;
|
||||
} catch (FileNotFoundException e) {
|
||||
Log_OC.d(TAG, "Failed to save key to file");
|
||||
} catch (IOException e) {
|
||||
Log_OC.d(TAG, "Failed to save key to file via IOException");
|
||||
} finally {
|
||||
if (keyFileOutputStream != null) {
|
||||
try {
|
||||
keyFileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error closing input stream during reading key from file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -400,7 +417,7 @@ public class PushUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
public static SignatureVerification verifySignature(Context context, byte[] signatureBytes, byte[] subjectBytes) {
|
||||
Signature signature = null;
|
||||
PublicKey publicKey;
|
||||
SignatureVerification signatureVerification = new SignatureVerification();
|
||||
@@ -413,7 +430,6 @@ public class PushUtils {
|
||||
Gson gson = new Gson();
|
||||
PushConfigurationState pushArbitraryData;
|
||||
|
||||
|
||||
try {
|
||||
signature = Signature.getInstance("SHA512withRSA");
|
||||
if (accounts.length > 0) {
|
||||
@@ -444,7 +460,7 @@ public class PushUtils {
|
||||
return signatureVerification;
|
||||
}
|
||||
|
||||
private Key readKeyFromString(boolean readPublicKey, String keyString) {
|
||||
private static Key readKeyFromString(boolean readPublicKey, String keyString) {
|
||||
String modifiedKey;
|
||||
if (readPublicKey) {
|
||||
modifiedKey = keyString.replaceAll("\\n", "").replace("-----BEGIN PUBLIC KEY-----",
|
||||
@@ -464,7 +480,6 @@ public class PushUtils {
|
||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(Base64.decode(modifiedKey, Base64.DEFAULT));
|
||||
return keyFactory.generatePrivate(keySpec);
|
||||
}
|
||||
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.d("TAG", "No such algorithm while reading key from string");
|
||||
} catch (InvalidKeySpecException e) {
|
||||
@@ -473,5 +488,4 @@ public class PushUtils {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -304,6 +304,10 @@
|
||||
android:exported="true" >
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.SsoGrantPermissionActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.ownCloud.Dialog.NoTitle" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -3,14 +3,20 @@ package com.nextcloud.android.sso;
|
||||
public class Constants {
|
||||
|
||||
// Authenticator related constants
|
||||
public final static String SSO_USERNAME = "username";
|
||||
public final static String SSO_TOKEN = "token";
|
||||
public final static String SSO_SERVER_URL = "server_url";
|
||||
public static final String SSO_USERNAME = "username";
|
||||
public static final String SSO_TOKEN = "token";
|
||||
public static final String SSO_SERVER_URL = "server_url";
|
||||
public static final String SSO_SHARED_PREFERENCE = "single-sign-on";
|
||||
public static final String NEXTCLOUD_SSO_EXCEPTION = "NextcloudSsoException";
|
||||
public static final String NEXTCLOUD_SSO = "NextcloudSSO";
|
||||
public static final String NEXTCLOUD_FILES_ACCOUNT = "NextcloudFilesAccount";
|
||||
|
||||
|
||||
// Custom Exceptions
|
||||
static final String EXCEPTION_INVALID_TOKEN = "CE_1";
|
||||
static final String EXCEPTION_ACCOUNT_NOT_FOUND = "CE_2";
|
||||
static final String EXCEPTION_UNSUPPORTED_METHOD = "CE_3";
|
||||
static final String EXCEPTION_INVALID_REQUEST_URL = "CE_4";
|
||||
static final String EXCEPTION_HTTP_REQUEST_FAILED = "CE_5";
|
||||
public static final String EXCEPTION_INVALID_TOKEN = "CE_1";
|
||||
public static final String EXCEPTION_ACCOUNT_NOT_FOUND = "CE_2";
|
||||
public static final String EXCEPTION_UNSUPPORTED_METHOD = "CE_3";
|
||||
public static final String EXCEPTION_INVALID_REQUEST_URL = "CE_4";
|
||||
public static final String EXCEPTION_HTTP_REQUEST_FAILED = "CE_5";
|
||||
public static final String EXCEPTION_ACCOUNT_ACCESS_DECLINED = "CE_6";
|
||||
}
|
||||
@@ -33,7 +33,6 @@ import android.util.Log;
|
||||
import com.nextcloud.android.sso.aidl.IInputStreamService;
|
||||
import com.nextcloud.android.sso.aidl.NextcloudRequest;
|
||||
import com.nextcloud.android.sso.aidl.ParcelFileDescriptorUtil;
|
||||
import com.owncloud.android.authentication.AccountAuthenticator;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
@@ -64,6 +63,7 @@ import static com.nextcloud.android.sso.Constants.EXCEPTION_HTTP_REQUEST_FAILED;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_INVALID_REQUEST_URL;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_INVALID_TOKEN;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_UNSUPPORTED_METHOD;
|
||||
import static com.nextcloud.android.sso.Constants.SSO_SHARED_PREFERENCE;
|
||||
|
||||
|
||||
/**
|
||||
@@ -220,7 +220,7 @@ public class InputStreamBinder extends IInputStreamService.Stub {
|
||||
private boolean isValid(NextcloudRequest request) {
|
||||
String callingPackageName = context.getPackageManager().getNameForUid(Binder.getCallingUid());
|
||||
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(AccountAuthenticator.SSO_SHARED_PREFERENCE,
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences(SSO_SHARED_PREFERENCE,
|
||||
Context.MODE_PRIVATE);
|
||||
String hash = sharedPreferences.getString(callingPackageName, "");
|
||||
return validateToken(hash, request.getToken());
|
||||
|
||||
@@ -28,21 +28,14 @@ import android.accounts.AccountManager;
|
||||
import android.accounts.NetworkErrorException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.nextcloud.android.sso.Constants;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
@@ -64,10 +57,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
public static final String KEY_REQUIRED_FEATURES = "requiredFeatures";
|
||||
public static final String KEY_LOGIN_OPTIONS = "loginOptions";
|
||||
public static final String KEY_ACCOUNT = "account";
|
||||
public static final String SSO_SHARED_PREFERENCE = "sso";
|
||||
|
||||
private static final String NEXTCLOUD_SSO = "NextcloudSSO";
|
||||
|
||||
|
||||
private static final String TAG = AccountAuthenticator.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
@@ -162,51 +152,6 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
|
||||
@Override
|
||||
public Bundle getAuthToken(AccountAuthenticatorResponse response,
|
||||
Account account, String authTokenType, Bundle options) {
|
||||
|
||||
if (NEXTCLOUD_SSO.equals(authTokenType)) {
|
||||
final Bundle result = new Bundle();
|
||||
|
||||
String packageName = options.getString("androidPackageName");
|
||||
|
||||
if (packageName == null) {
|
||||
Log_OC.e(TAG, "No calling package, exit.");
|
||||
return result;
|
||||
}
|
||||
|
||||
// create token
|
||||
SharedPreferences sharedPreferences = mContext.getSharedPreferences(SSO_SHARED_PREFERENCE,
|
||||
Context.MODE_PRIVATE);
|
||||
String token = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
|
||||
String hashedTokenWithSalt = EncryptionUtils.generateSHA512(token);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(packageName, hashedTokenWithSalt);
|
||||
editor.apply();
|
||||
|
||||
String serverUrl;
|
||||
String userId;
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(account, mContext);
|
||||
serverUrl = ocAccount.getBaseUri().toString();
|
||||
AccountManager accountManager = AccountManager.get(mContext);
|
||||
userId = accountManager.getUserData(account,
|
||||
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
||||
} catch (AccountUtils.AccountNotFoundException e) {
|
||||
Log_OC.e(TAG, "Account not found");
|
||||
return new Bundle();
|
||||
}
|
||||
|
||||
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
|
||||
result.putString(AccountManager.KEY_ACCOUNT_TYPE, MainApp.getAccountType(mContext));
|
||||
result.putString(AccountManager.KEY_AUTHTOKEN, NEXTCLOUD_SSO);
|
||||
result.putString(Constants.SSO_USERNAME, userId);
|
||||
result.putString(Constants.SSO_TOKEN, token);
|
||||
result.putString(Constants.SSO_SERVER_URL, serverUrl);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// validate parameters
|
||||
try {
|
||||
validateAccountType(account.type);
|
||||
|
||||
@@ -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 {
|
||||
@@ -1525,13 +1523,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
}
|
||||
|
||||
private boolean authSupported(AuthenticationMethod authMethod) {
|
||||
return ((basicTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
|
||||
(oauthTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
|
||||
(samlTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.SAML_WEB_SSO.equals(authMethod))
|
||||
);
|
||||
return (basicTokenType.equals(mAuthTokenType) && AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
|
||||
(oauthTokenType.equals(mAuthTokenType) && AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
|
||||
(samlTokenType.equals(mAuthTokenType) && AuthenticationMethod.SAML_WEB_SSO.equals(authMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2081,6 +2075,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private abstract static class RightDrawableOnTouchListener implements OnTouchListener {
|
||||
|
||||
private static final int RIGHT_DRAWABLE_COMPOUND_DRAWABLES_LENGTH = 2;
|
||||
|
||||
private int fuzz = 75;
|
||||
|
||||
/**
|
||||
@@ -2091,7 +2087,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
Drawable rightDrawable = null;
|
||||
if (view instanceof TextView) {
|
||||
Drawable[] drawables = ((TextView) view).getCompoundDrawables();
|
||||
if (drawables.length > 2) {
|
||||
if (drawables.length > RIGHT_DRAWABLE_COMPOUND_DRAWABLES_LENGTH) {
|
||||
rightDrawable = drawables[2];
|
||||
}
|
||||
}
|
||||
@@ -2220,7 +2216,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
||||
|
||||
private void doOnResumeAndBound() {
|
||||
//Log_OC.e(TAG, "registering to listen for operation callbacks" );
|
||||
mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);
|
||||
mOperationsServiceBinder.addOperationListener(this, mHandler);
|
||||
if (mWaitingForOpId <= Integer.MAX_VALUE) {
|
||||
mOperationsServiceBinder.dispatchResultIfFinished((int) mWaitingForOpId, this);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.Locale;
|
||||
/**
|
||||
* Helper class for authenticator-URL related logic.
|
||||
*/
|
||||
public abstract class AuthenticatorUrlUtils {
|
||||
public final class AuthenticatorUrlUtils {
|
||||
public static final String WEBDAV_PATH_4_0_AND_LATER = "/remote.php/webdav";
|
||||
|
||||
private static final String HTTPS_PROTOCOL = "https://";
|
||||
@@ -41,6 +41,9 @@ public abstract class AuthenticatorUrlUtils {
|
||||
private static final String ODAV_PATH = "/remote.php/odav";
|
||||
private static final String SAML_SSO_PATH = "/remote.php/webdav";
|
||||
|
||||
private AuthenticatorUrlUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the proper URL path to access the WebDAV interface of an ownCloud server,
|
||||
* according to its version and the authorization method used.
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.owncloud.android.utils.DeviceCredentialUtils;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PassCodeManager {
|
||||
public final class PassCodeManager {
|
||||
|
||||
private static final Set<Class> exemptOfPasscodeActivities;
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ import java.util.List;
|
||||
* Database provider for handling the persistence aspects of arbitrary data table.
|
||||
*/
|
||||
public class ArbitraryDataProvider {
|
||||
static private final String TAG = ArbitraryDataProvider.class.getSimpleName();
|
||||
private static final String TAG = ArbitraryDataProvider.class.getSimpleName();
|
||||
private static final String TRUE = "true";
|
||||
|
||||
private ContentResolver contentResolver;
|
||||
|
||||
@@ -115,9 +116,7 @@ public class ArbitraryDataProvider {
|
||||
}
|
||||
|
||||
public boolean getBooleanValue(String accountName, String key) {
|
||||
String value = getValue(accountName, key);
|
||||
|
||||
return !value.isEmpty() && value.equalsIgnoreCase("true");
|
||||
return TRUE.equalsIgnoreCase(getValue(accountName, key));
|
||||
}
|
||||
|
||||
public boolean getBooleanValue(Account account, String key) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Decrypted class representation of metadata json of folder metadata
|
||||
* Decrypted class representation of metadata json of folder metadata.
|
||||
*/
|
||||
public class DecryptedFolderMetadata {
|
||||
private Metadata metadata;
|
||||
@@ -36,7 +36,7 @@ public class DecryptedFolderMetadata {
|
||||
this.files = new HashMap<>();
|
||||
}
|
||||
|
||||
public DecryptedFolderMetadata(Metadata metadata, HashMap<String, DecryptedFile> files) {
|
||||
public DecryptedFolderMetadata(Metadata metadata, Map<String, DecryptedFile> files) {
|
||||
this.metadata = metadata;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
@@ -455,7 +455,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;
|
||||
}
|
||||
@@ -487,7 +487,7 @@ public class FileDataStorageManager {
|
||||
cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail());
|
||||
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());
|
||||
return cv;
|
||||
@@ -557,7 +557,7 @@ 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()};
|
||||
@@ -766,7 +766,8 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void migrateStoredFiles(String srcPath, String dstPath) throws Exception {
|
||||
public void migrateStoredFiles(String srcPath, String dstPath)
|
||||
throws RemoteException, OperationApplicationException {
|
||||
Cursor cursor;
|
||||
try {
|
||||
if (getContentResolver() != null) {
|
||||
@@ -1398,7 +1399,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_FAVORITE, file.getIsFavorite());
|
||||
cv.put(ProviderTableMeta.FILE_FAVORITE, file.isFavorite());
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_UPDATE_THUMBNAIL,
|
||||
file.needsUpdateThumbnail() ? 1 : 0
|
||||
@@ -1465,8 +1466,8 @@ public class FileDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSharesDB(ArrayList<OCShare> shares) {
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
|
||||
public void saveSharesDB(List<OCShare> shares) {
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
|
||||
|
||||
// Reset flags & Remove shares for this files
|
||||
String filePath = "";
|
||||
@@ -1580,7 +1581,7 @@ public class FileDataStorageManager {
|
||||
* @return
|
||||
*/
|
||||
private ArrayList<ContentProviderOperation> prepareInsertShares(
|
||||
ArrayList<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
|
||||
List<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
|
||||
|
||||
if (shares != null) {
|
||||
// prepare operations to insert or update files to save in the given folder
|
||||
@@ -1663,23 +1664,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);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Mario Danic
|
||||
@@ -22,16 +22,16 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
/*
|
||||
Model for filesystem data from the database
|
||||
/**
|
||||
* Model for filesystem data from the database.
|
||||
*/
|
||||
public class FileSystemDataSet {
|
||||
|
||||
private int id;
|
||||
private String localPath;
|
||||
private long modifiedAt;
|
||||
private boolean isFolder;
|
||||
private boolean isSentForUpload;
|
||||
private boolean folder;
|
||||
private boolean sentForUpload;
|
||||
private long foundAt;
|
||||
private long syncedFolderId;
|
||||
@Nullable private String crc32;
|
||||
@@ -39,13 +39,13 @@ public class FileSystemDataSet {
|
||||
public FileSystemDataSet() {
|
||||
}
|
||||
|
||||
public FileSystemDataSet(int id, String localPath, long modifiedAt, boolean isFolder,
|
||||
boolean isSentForUpload, long foundAt, long syncedFolderId, @Nullable String crc32) {
|
||||
public FileSystemDataSet(int id, String localPath, long modifiedAt, boolean folder,
|
||||
boolean sentForUpload, long foundAt, long syncedFolderId, @Nullable String crc32) {
|
||||
this.id = id;
|
||||
this.localPath = localPath;
|
||||
this.modifiedAt = modifiedAt;
|
||||
this.isFolder = isFolder;
|
||||
this.isSentForUpload = isSentForUpload;
|
||||
this.folder = folder;
|
||||
this.sentForUpload = sentForUpload;
|
||||
this.foundAt = foundAt;
|
||||
this.syncedFolderId = syncedFolderId;
|
||||
this.crc32 = crc32;
|
||||
@@ -84,11 +84,11 @@ public class FileSystemDataSet {
|
||||
}
|
||||
|
||||
public boolean isFolder() {
|
||||
return isFolder;
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void setFolder(boolean folder) {
|
||||
isFolder = folder;
|
||||
this.folder = folder;
|
||||
}
|
||||
|
||||
public long getFoundAt() {
|
||||
@@ -100,11 +100,11 @@ public class FileSystemDataSet {
|
||||
}
|
||||
|
||||
public boolean isSentForUpload() {
|
||||
return isSentForUpload;
|
||||
return sentForUpload;
|
||||
}
|
||||
|
||||
public void setSentForUpload(boolean sentForUpload) {
|
||||
isSentForUpload = sentForUpload;
|
||||
this.sentForUpload = sentForUpload;
|
||||
}
|
||||
|
||||
public long getSyncedFolderId() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -59,6 +59,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
|
||||
private final static String PERMISSION_SHARED_WITH_ME = "S"; // TODO move to better location
|
||||
private final static String PERMISSION_CAN_RESHARE = "R";
|
||||
private final static String PERMISSION_CAN_WRITE = "CK";
|
||||
|
||||
public static final String PATH_SEPARATOR = "/";
|
||||
public static final String ROOT_PATH = PATH_SEPARATOR;
|
||||
@@ -197,7 +198,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
dest.writeSerializable(mMountType);
|
||||
}
|
||||
|
||||
public boolean getIsFavorite() {
|
||||
public boolean isFavorite() {
|
||||
return mIsFavorite;
|
||||
}
|
||||
|
||||
@@ -713,7 +714,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
* @return 'True' if the file is hidden
|
||||
*/
|
||||
public boolean isHidden() {
|
||||
return getFileName().startsWith(".");
|
||||
return getFileName().length() > 0 && getFileName().charAt(0) == '.';
|
||||
}
|
||||
|
||||
public String getPermissions() {
|
||||
@@ -784,6 +785,11 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
|
||||
return permissions != null && permissions.contains(PERMISSION_CAN_RESHARE);
|
||||
}
|
||||
|
||||
public boolean canWrite() {
|
||||
String permissions = getPermissions();
|
||||
return permissions != null && permissions.contains(PERMISSION_CAN_WRITE);
|
||||
}
|
||||
|
||||
public WebdavEntry.MountType getMountType() {
|
||||
return mMountType;
|
||||
}
|
||||
|
||||
@@ -249,14 +249,11 @@ public class SyncedFolderProvider extends Observable {
|
||||
* @param account whose synced folders should be deleted
|
||||
*/
|
||||
public int deleteSyncFoldersForAccount(Account account) {
|
||||
int result = mContentResolver.delete(
|
||||
return mContentResolver.delete(
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_SYNCED_FOLDERS,
|
||||
ProviderMeta.ProviderTableMeta.SYNCED_FOLDER_ACCOUNT + " = ?",
|
||||
new String[]{String.valueOf(account.name)}
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -78,7 +78,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
/**
|
||||
* Manager for concurrent access to thumbnails cache.
|
||||
*/
|
||||
public class ThumbnailsCacheManager {
|
||||
public final class ThumbnailsCacheManager {
|
||||
|
||||
public static final String PREFIX_RESIZED_IMAGE = "r";
|
||||
public static final String PREFIX_THUMBNAIL = "t";
|
||||
@@ -90,19 +90,22 @@ public class ThumbnailsCacheManager {
|
||||
private static final String ETAG = "ETag";
|
||||
|
||||
private static final Object mThumbnailsDiskCacheLock = new Object();
|
||||
private static DiskLruImageCache mThumbnailCache = null;
|
||||
private static DiskLruImageCache mThumbnailCache;
|
||||
private static boolean mThumbnailCacheStarting = true;
|
||||
|
||||
private static final int DISK_CACHE_SIZE = 1024 * 1024 * 200; // 200MB
|
||||
private static final CompressFormat mCompressFormat = CompressFormat.JPEG;
|
||||
private static final int mCompressQuality = 70;
|
||||
private static OwnCloudClient mClient = null;
|
||||
private static OwnCloudClient mClient;
|
||||
|
||||
public static final Bitmap mDefaultImg = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(),
|
||||
R.drawable.file_image);
|
||||
|
||||
public static final Bitmap mDefaultVideo = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(),
|
||||
R.drawable.file_movie);
|
||||
|
||||
private ThumbnailsCacheManager() {
|
||||
}
|
||||
|
||||
public static class InitDiskCacheTask extends AsyncTask<File, Void, Void> {
|
||||
@Override
|
||||
@@ -381,7 +384,7 @@ public class ThumbnailsCacheManager {
|
||||
private static Account mAccount;
|
||||
private List<ThumbnailGenerationTask> mAsyncTasks;
|
||||
private Object mFile;
|
||||
private String mImageKey = null;
|
||||
private String mImageKey;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private GetMethod getMethod;
|
||||
|
||||
@@ -641,6 +644,9 @@ public class ThumbnailsCacheManager {
|
||||
}
|
||||
|
||||
public static class MediaThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
|
||||
|
||||
private static final int IMAGE_KEY_PARAMS_LENGTH = 2;
|
||||
|
||||
private enum Type {IMAGE, VIDEO}
|
||||
private final WeakReference<ImageView> mImageViewReference;
|
||||
private File mFile;
|
||||
@@ -660,7 +666,7 @@ public class ThumbnailsCacheManager {
|
||||
try {
|
||||
if (params[0] instanceof File) {
|
||||
mFile = (File) params[0];
|
||||
if (params.length == 2) {
|
||||
if (params.length == IMAGE_KEY_PARAMS_LENGTH) {
|
||||
mImageKey = (String) params[1];
|
||||
}
|
||||
|
||||
@@ -870,7 +876,8 @@ public class ThumbnailsCacheManager {
|
||||
// we are using eTag to download a new avatar only if it changed
|
||||
switch (status) {
|
||||
case HttpStatus.SC_OK:
|
||||
// new avatar
|
||||
case HttpStatus.SC_CREATED:
|
||||
// new avatar
|
||||
InputStream inputStream = get.getResponseBodyAsStream();
|
||||
|
||||
String newETag = null;
|
||||
|
||||
@@ -45,13 +45,14 @@ import java.util.Observable;
|
||||
* information for each file.
|
||||
*/
|
||||
public class UploadsStorageManager extends Observable {
|
||||
private static final String TAG = UploadsStorageManager.class.getSimpleName();
|
||||
|
||||
private static final String AND = " AND ";
|
||||
static private final String TAG = UploadsStorageManager.class.getSimpleName();
|
||||
private static final int SINGLE_RESULT = 1;
|
||||
|
||||
private ContentResolver mContentResolver;
|
||||
private Context mContext;
|
||||
|
||||
|
||||
public UploadsStorageManager(ContentResolver contentResolver, Context context) {
|
||||
if (contentResolver == null) {
|
||||
throw new IllegalArgumentException("Cannot create an instance with a NULL contentResolver");
|
||||
@@ -123,7 +124,7 @@ public class UploadsStorageManager extends Observable {
|
||||
);
|
||||
|
||||
Log_OC.d(TAG, "updateUpload returns with: " + result + " for file: " + ocUpload.getLocalPath());
|
||||
if (result != 1) {
|
||||
if (result != SINGLE_RESULT) {
|
||||
Log_OC.e(TAG, "Failed to update item " + ocUpload.getLocalPath() + " into upload db.");
|
||||
} else {
|
||||
notifyObserversNow();
|
||||
@@ -189,7 +190,7 @@ public class UploadsStorageManager extends Observable {
|
||||
);
|
||||
|
||||
if (c != null) {
|
||||
if (c.getCount() != 1) {
|
||||
if (c.getCount() != SINGLE_RESULT) {
|
||||
Log_OC.e(TAG, c.getCount() + " items for id=" + id
|
||||
+ " available in UploadDb. Expected 1. Failed to update upload db.");
|
||||
} else {
|
||||
@@ -272,7 +273,7 @@ public class UploadsStorageManager extends Observable {
|
||||
}
|
||||
|
||||
public OCUpload[] getAllStoredUploads() {
|
||||
return getUploads(null, null);
|
||||
return getUploads(null, (String[]) null);
|
||||
}
|
||||
|
||||
private OCUpload[] getUploads(@Nullable String selection, @Nullable String... selectionArgs) {
|
||||
@@ -393,7 +394,7 @@ public class UploadsStorageManager extends Observable {
|
||||
*/
|
||||
public OCUpload[] getFinishedUploads() {
|
||||
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value, null);
|
||||
return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value, (String[]) null);
|
||||
}
|
||||
|
||||
public OCUpload[] getFailedButNotDelayedUploadsForCurrentAccount() {
|
||||
@@ -432,7 +433,7 @@ public class UploadsStorageManager extends Observable {
|
||||
"<>" + UploadResult.DELAYED_FOR_CHARGING.getValue() +
|
||||
AND + ProviderTableMeta.UPLOADS_LAST_RESULT +
|
||||
"<>" + UploadResult.DELAYED_IN_POWER_SAVE_MODE.getValue(),
|
||||
null
|
||||
(String[]) null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -24,14 +24,14 @@ package com.owncloud.android.datastorage.providers;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
abstract class AbstractStoragePointProvider implements IStoragePointProvider {
|
||||
|
||||
boolean canBeAddedToAvailableList(Vector<StoragePoint> currentList, String path) {
|
||||
boolean canBeAddedToAvailableList(List<StoragePoint> currentList, String path) {
|
||||
if (path == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -25,6 +25,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
@@ -40,15 +41,15 @@ public class EnvironmentStoragePointProvider extends AbstractStoragePointProvide
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
public List<StoragePoint> getAvailableStoragePoint() {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
addEntriesFromEnv(result, sSecondaryStorageEnvName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addEntriesFromEnv(Vector<StoragePoint> result, String envName) {
|
||||
private void addEntriesFromEnv(List<StoragePoint> result, String envName) {
|
||||
String env = System.getenv(envName);
|
||||
if (env != null) {
|
||||
for (String p : env.split(":")) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -23,7 +23,7 @@ package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
@@ -38,11 +38,9 @@ public interface IStoragePointProvider {
|
||||
*/
|
||||
boolean canProvideStoragePoints();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return available storage points
|
||||
*/
|
||||
Vector<StoragePoint> getAvailableStoragePoint();
|
||||
|
||||
List<StoragePoint> getAvailableStoragePoint();
|
||||
}
|
||||
+7
-6
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
@@ -23,6 +23,7 @@ package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -42,8 +43,8 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
public List<StoragePoint> getAvailableStoragePoint() {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
for (String p : getPotentialPaths(getCommandLineResult())) {
|
||||
if (canBeAddedToAvailableList(result, p)) {
|
||||
@@ -54,14 +55,14 @@ public class MountCommandStoragePointProvider extends AbstractCommandLineStorage
|
||||
return result;
|
||||
}
|
||||
|
||||
private Vector<String> getPotentialPaths(String mounted) {
|
||||
final Vector<String> result = new Vector<>();
|
||||
private List<String> getPotentialPaths(String mounted) {
|
||||
final List<String> result = new Vector<>();
|
||||
|
||||
for (String line : mounted.split("\n")) {
|
||||
if (!line.toLowerCase(Locale.US).contains("asec") && sPattern.matcher(line).matches()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -24,6 +24,7 @@ package com.owncloud.android.datastorage.providers;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
@@ -38,8 +39,8 @@ public class VDCStoragePointProvider extends AbstractCommandLineStoragePoint {
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
public List<StoragePoint> getAvailableStoragePoint() {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
result.addAll(getPaths(getCommandLineResult()));
|
||||
|
||||
@@ -51,8 +52,8 @@ public class VDCStoragePointProvider extends AbstractCommandLineStoragePoint {
|
||||
return sVDCVolListCommand;
|
||||
}
|
||||
|
||||
private Vector<StoragePoint> getPaths(String vdcResources) {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
private List<StoragePoint> getPaths(String vdcResources) {
|
||||
List<StoragePoint> result = new Vector<>();
|
||||
|
||||
for (String line : vdcResources.split("\n")) {
|
||||
String vdcLine[] = line.split(" ");
|
||||
|
||||
@@ -36,12 +36,13 @@ import static com.owncloud.android.ui.fragment.OCFileListFragment.FOLDER_LAYOUT_
|
||||
/**
|
||||
* Helper to simplify reading of Preferences all around the app
|
||||
*/
|
||||
public abstract class PreferenceManager {
|
||||
public final class PreferenceManager {
|
||||
/**
|
||||
* Constant to access value of last path selected by the user to upload a file shared from other app.
|
||||
* Value handled by the app without direct access in the UI.
|
||||
*/
|
||||
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";
|
||||
@@ -65,6 +66,9 @@ public abstract class PreferenceManager {
|
||||
private static final String PREF__FOLDER_SORT_ORDER = "folder_sort_order";
|
||||
private static final String PREF__FOLDER_LAYOUT = "folder_layout";
|
||||
|
||||
private PreferenceManager() {
|
||||
}
|
||||
|
||||
public static void setKeysReInit(Context context) {
|
||||
saveBooleanPreference(context, PREF__KEYS_REINIT, true);
|
||||
}
|
||||
@@ -183,6 +187,27 @@ public abstract 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.
|
||||
*
|
||||
|
||||
@@ -495,7 +495,7 @@ public class FileMenuFilter {
|
||||
|
||||
private boolean allFavorites() {
|
||||
for (OCFile file : mFiles) {
|
||||
if (!file.getIsFavorite()) {
|
||||
if (!file.isFavorite()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -504,7 +504,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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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,7 +78,8 @@ 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 = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG);
|
||||
wakeLock.acquire();
|
||||
}
|
||||
|
||||
@@ -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,11 +71,10 @@ public class NotificationJob extends Job {
|
||||
try {
|
||||
byte[] base64DecodedSubject = Base64.decode(subject, Base64.DEFAULT);
|
||||
byte[] base64DecodedSignature = Base64.decode(signature, Base64.DEFAULT);
|
||||
PushUtils pushUtils = new PushUtils();
|
||||
PrivateKey privateKey = (PrivateKey) PushUtils.readKeyFromFile(false);
|
||||
|
||||
try {
|
||||
SignatureVerification signatureVerification = pushUtils.verifySignature(context,
|
||||
SignatureVerification signatureVerification = PushUtils.verifySignature(context,
|
||||
base64DecodedSignature, base64DecodedSubject);
|
||||
|
||||
if (signatureVerification.isSignatureValid()) {
|
||||
|
||||
@@ -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,7 +70,8 @@ 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 = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MainApp.getAuthority() +
|
||||
WAKELOCK_TAG_SEPARATION + TAG);
|
||||
wakeLock.acquire();
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -37,9 +37,11 @@ import java.util.Map;
|
||||
|
||||
|
||||
public class OAuth2GetAccessToken extends RemoteOperation {
|
||||
|
||||
private static final String TAG = OAuth2GetAccessToken.class.getSimpleName();
|
||||
|
||||
|
||||
private static final int KEY_INDEX = 0;
|
||||
private static final int VALUE_INDEX = 1;
|
||||
|
||||
private String mClientId;
|
||||
private String mRedirectUri;
|
||||
private String mGrantType;
|
||||
@@ -149,9 +151,9 @@ public class OAuth2GetAccessToken extends RemoteOperation {
|
||||
String[] part = pairs[i].split("=");
|
||||
while (part.length > j) {
|
||||
String p = part[j];
|
||||
if (j == 0) {
|
||||
if (j == KEY_INDEX) {
|
||||
key = p;
|
||||
} else if (j == 1) {
|
||||
} else if (j == VALUE_INDEX) {
|
||||
value = p;
|
||||
mOAuth2ParsedAuthorizationResponse.put(key, value);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
* <p>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
* <p>
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* <p>
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -39,6 +39,7 @@ import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
||||
import com.owncloud.android.utils.DataHolderUtil;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
@@ -344,7 +345,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
*
|
||||
* @param folderAndFiles Remote folder and children files in Folder
|
||||
*/
|
||||
private void synchronizeData(ArrayList<Object> folderAndFiles) {
|
||||
private void synchronizeData(List<Object> folderAndFiles) {
|
||||
// get 'fresh data' from the database
|
||||
mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
|
||||
|
||||
@@ -362,6 +363,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, mStorageManager);
|
||||
mLocalFolder.setEncrypted(encryptedAncestor);
|
||||
|
||||
// update permission
|
||||
mLocalFolder.setPermissions(remoteFolder.getPermissions());
|
||||
|
||||
DecryptedFolderMetadata metadata = getDecryptedFolderMetadata(encryptedAncestor);
|
||||
|
||||
// get current data about local contents of the folder to synchronize
|
||||
@@ -397,10 +401,9 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
|
||||
// prepare content synchronization for kept-in-sync files
|
||||
if (updatedFile.isAvailableOffline()) {
|
||||
SynchronizeFileOperation operation = new SynchronizeFileOperation(localFile, remoteFile, mAccount, true,
|
||||
mContext);
|
||||
|
||||
mFilesToSyncContents.add(operation);
|
||||
mFilesToSyncContents.add(
|
||||
new SynchronizeFileOperation(localFile, remoteFile, mAccount, true, mContext)
|
||||
);
|
||||
}
|
||||
|
||||
// update file name for encrypted files
|
||||
@@ -550,8 +553,13 @@ public class RefreshFolderOperation extends RemoteOperation {
|
||||
if (result.isSuccess()) {
|
||||
// update local database
|
||||
ArrayList<OCShare> shares = new ArrayList<>();
|
||||
OCShare share;
|
||||
for (Object obj : result.getData()) {
|
||||
shares.add((OCShare) obj);
|
||||
share = (OCShare) obj;
|
||||
|
||||
if (!ShareType.NO_SHARED.equals(share.getShareType())) {
|
||||
shares.add(share);
|
||||
}
|
||||
}
|
||||
mStorageManager.saveSharesInFolder(shares, mLocalFolder);
|
||||
}
|
||||
|
||||
@@ -81,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()) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -43,7 +43,8 @@ import java.util.List;
|
||||
public class UnshareOperation extends SyncOperation {
|
||||
|
||||
private static final String TAG = UnshareOperation.class.getSimpleName();
|
||||
|
||||
private static final int SINGLY_SHARED = 1;
|
||||
|
||||
private String mRemotePath;
|
||||
private ShareType mShareType;
|
||||
private String mShareWith;
|
||||
@@ -83,7 +84,7 @@ public class UnshareOperation extends SyncOperation {
|
||||
List <OCShare> sharesWith = getStorageManager().
|
||||
getSharesWithForAFile(mRemotePath,
|
||||
getStorageManager().getAccount().name);
|
||||
if (sharesWith.size() == 1) {
|
||||
if (sharesWith.size() == SINGLY_SHARED) {
|
||||
file.setShareWithSharee(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -699,12 +699,10 @@ public class UploadFileOperation extends SyncOperation {
|
||||
|
||||
private RemoteOperationResult unlockFolder(OCFile parentFolder, OwnCloudClient client, String token) {
|
||||
if (token != null) {
|
||||
UnlockFileOperation unlockFileOperation = new UnlockFileOperation(parentFolder.getLocalId(), token);
|
||||
RemoteOperationResult unlockFileOperationResult = unlockFileOperation.execute(client, true);
|
||||
|
||||
return unlockFileOperationResult;
|
||||
} else
|
||||
return new UnlockFileOperation(parentFolder.getLocalId(), token).execute(client, true);
|
||||
} else {
|
||||
return new RemoteOperationResult(new Exception("No token available"));
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteOperationResult checkConditions(File originalFile) {
|
||||
@@ -723,8 +721,8 @@ public class UploadFileOperation extends SyncOperation {
|
||||
}
|
||||
|
||||
// check if charging conditions are met and delays the upload otherwise
|
||||
if (mWhileChargingOnly && (!Device.getBatteryStatus(mContext).isCharging() && Device.getBatteryStatus(mContext)
|
||||
.getBatteryPercent() < 1)) {
|
||||
if (mWhileChargingOnly && !Device.getBatteryStatus(mContext).isCharging()
|
||||
&& Device.getBatteryStatus(mContext).getBatteryPercent() < 1) {
|
||||
Log_OC.d(TAG, "Upload delayed until the device is charging: " + getRemotePath());
|
||||
remoteOperationResult = new RemoteOperationResult(ResultCode.DELAYED_FOR_CHARGING);
|
||||
}
|
||||
|
||||
@@ -86,6 +86,9 @@ public class FileContentProvider extends ContentProvider {
|
||||
private static final String ADD_COLUMN = " ADD COLUMN ";
|
||||
private static final String REMOVE_COLUMN = " REMOVE COLUMN ";
|
||||
private static final String UPGRADE_VERSION_MSG = "OUT of the ADD in onUpgrade; oldVersion == %d, newVersion == %d";
|
||||
private static final int SINGLE_PATH_SEGMENT = 1;
|
||||
public static final int ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION = 20;
|
||||
|
||||
private DataBaseHelper mDbHelper;
|
||||
private Context mContext;
|
||||
private UriMatcher mUriMatcher;
|
||||
@@ -175,14 +178,14 @@ public class FileContentProvider extends ContentProvider {
|
||||
db,
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, childId),
|
||||
null,
|
||||
null
|
||||
(String[]) null
|
||||
);
|
||||
} else {
|
||||
count += delete(
|
||||
db,
|
||||
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, childId),
|
||||
null,
|
||||
null
|
||||
(String[]) null
|
||||
);
|
||||
}
|
||||
children.moveToNext();
|
||||
@@ -401,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)
|
||||
@@ -501,67 +510,66 @@ public class FileContentProvider extends ContentProvider {
|
||||
case ROOT_DIRECTORY:
|
||||
break;
|
||||
case DIRECTORY:
|
||||
String folderId = uri.getPathSegments().get(1);
|
||||
sqlQuery.appendWhere(ProviderTableMeta.FILE_PARENT + "="
|
||||
+ folderId);
|
||||
+ uri.getPathSegments().get(1));
|
||||
break;
|
||||
case SINGLE_FILE:
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case SHARES:
|
||||
sqlQuery.setTables(ProviderTableMeta.OCSHARES_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case CAPABILITIES:
|
||||
sqlQuery.setTables(ProviderTableMeta.CAPABILITIES_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case UPLOADS:
|
||||
sqlQuery.setTables(ProviderTableMeta.UPLOADS_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case SYNCED_FOLDERS:
|
||||
sqlQuery.setTables(ProviderTableMeta.SYNCED_FOLDERS_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case EXTERNAL_LINKS:
|
||||
sqlQuery.setTables(ProviderTableMeta.EXTERNAL_LINKS_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case ARBITRARY_DATA:
|
||||
sqlQuery.setTables(ProviderTableMeta.ARBITRARY_DATA_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case VIRTUAL:
|
||||
sqlQuery.setTables(ProviderTableMeta.VIRTUAL_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "=" + uri.getPathSegments().get(1));
|
||||
}
|
||||
break;
|
||||
case FILESYSTEM:
|
||||
sqlQuery.setTables(ProviderTableMeta.FILESYSTEM_TABLE_NAME);
|
||||
if (uri.getPathSegments().size() > 1) {
|
||||
if (uri.getPathSegments().size() > SINGLE_PATH_SEGMENT) {
|
||||
sqlQuery.appendWhere(ProviderTableMeta._ID + "="
|
||||
+ uri.getPathSegments().get(1));
|
||||
}
|
||||
@@ -1629,7 +1637,7 @@ public class FileContentProvider extends ContentProvider {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.FILE_TABLE_NAME +
|
||||
ADD_COLUMN + ProviderTableMeta.FILE_ENCRYPTED_NAME + " TEXT ");
|
||||
}
|
||||
if (oldVersion > 20) {
|
||||
if (oldVersion > ARBITRARY_DATA_TABLE_INTRODUCTION_VERSION) {
|
||||
if (!checkIfColumnExists(db, ProviderTableMeta.CAPABILITIES_TABLE_NAME,
|
||||
ProviderTableMeta.CAPABILITIES_END_TO_END_ENCRYPTION)) {
|
||||
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
|
||||
|
||||
@@ -1,24 +1,23 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @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/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.owncloud.android.providers;
|
||||
|
||||
import android.accounts.Account;
|
||||
@@ -32,6 +31,7 @@ import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.BaseColumns;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -52,6 +52,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -84,7 +85,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
private UriMatcher mUriMatcher;
|
||||
|
||||
private static HashMap<String, ShareType> sShareTypes = new HashMap<>();
|
||||
private static Map<String, ShareType> sShareTypes = new HashMap<>();
|
||||
|
||||
public static ShareType getShareType(String authority) {
|
||||
|
||||
@@ -93,14 +94,17 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
public String getType(@NonNull Uri uri) {
|
||||
// TODO implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@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";
|
||||
@@ -109,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);
|
||||
|
||||
@@ -118,22 +123,23 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO description
|
||||
* <p/>
|
||||
* 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(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);
|
||||
@@ -149,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();
|
||||
@@ -193,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) {
|
||||
@@ -240,20 +267,17 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
// TODO implementation
|
||||
public Uri insert(@NonNull Uri uri, ContentValues values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||
// TODO implementation
|
||||
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
// TODO implementation
|
||||
public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -262,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
|
||||
@@ -271,17 +295,10 @@ 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -617,13 +617,13 @@ public class OperationsService extends Service {
|
||||
remotePath,
|
||||
shareType,
|
||||
shareWith,
|
||||
OperationsService.this
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
} else if (ACTION_GET_SERVER_INFO.equals(action)) {
|
||||
// check OC server and get basic information from it
|
||||
operation = new GetServerInfoOperation(serverUrl, OperationsService.this);
|
||||
operation = new GetServerInfoOperation(serverUrl, this);
|
||||
|
||||
} else if (ACTION_OAUTH2_GET_ACCESS_TOKEN.equals(action)) {
|
||||
/// GET ACCESS TOKEN to the OAuth server
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.SynchronizeFolderOperation;
|
||||
import com.owncloud.android.operations.UpdateOCVersionOperation;
|
||||
import com.owncloud.android.ui.activity.ErrorsWhileCopyingHandlerActivity;
|
||||
import com.owncloud.android.ui.notifications.NotificationUtils;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-2
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* Copyright (C) 2018 Edvard Holst
|
||||
@@ -34,6 +34,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.activities.GetRemoteActivitiesOperation;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -94,7 +96,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
|
||||
Log_OC.d(TAG, result.getLogMessage());
|
||||
// show error
|
||||
errorMessage = result.getLogMessage();
|
||||
if (result.getHttpCode() == 304) {
|
||||
if (result.getHttpCode() == HttpStatus.SC_NOT_MODIFIED) {
|
||||
errorMessage = context.getString(R.string.file_list_empty_headline_server_search);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -89,6 +89,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 +100,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;
|
||||
@@ -403,12 +405,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 +473,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 +504,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.
|
||||
*
|
||||
@@ -663,7 +678,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
*
|
||||
* @param accounts list of accounts
|
||||
*/
|
||||
private void repopulateAccountList(ArrayList<Account> accounts) {
|
||||
private void repopulateAccountList(List<Account> accounts) {
|
||||
// remove all accounts from list
|
||||
mNavigationView.getMenu().removeGroup(R.id.drawer_menu_accounts);
|
||||
|
||||
@@ -1386,7 +1401,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 +1420,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();
|
||||
|
||||
@@ -493,7 +493,7 @@ public abstract class FileActivity extends DrawerActivity
|
||||
|
||||
|
||||
private void doOnResumeAndBound() {
|
||||
mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler);
|
||||
mOperationsServiceBinder.addOperationListener(this, mHandler);
|
||||
long waitingForOpId = mFileOperationsHelper.getOpIdWaitingFor();
|
||||
if (waitingForOpId <= Integer.MAX_VALUE) {
|
||||
boolean wait = mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId,
|
||||
|
||||
@@ -86,6 +86,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.media.MediaService;
|
||||
import com.owncloud.android.media.MediaServiceBinder;
|
||||
@@ -191,6 +192,8 @@ public class FileDisplayActivity extends HookActivity
|
||||
|
||||
public static final String TEXT_PREVIEW = "TEXT_PREVIEW";
|
||||
|
||||
private static final String VERSION_DOT = ".";
|
||||
|
||||
private OCFile mWaitingToPreview;
|
||||
|
||||
private boolean mSyncInProgress;
|
||||
@@ -365,8 +368,14 @@ public class FileDisplayActivity extends HookActivity
|
||||
|
||||
if (MainApp.getVersionCode() > lastSeenVersion) {
|
||||
OwnCloudVersion serverVersion = AccountUtils.getServerVersionForAccount(account, this);
|
||||
|
||||
if (serverVersion == null) {
|
||||
OCCapability capability = getCapabilities();
|
||||
serverVersion = new OwnCloudVersion(capability.getVersionMayor() + VERSION_DOT +
|
||||
capability.getVersionMinor() + VERSION_DOT + capability.getVersionMicro());
|
||||
}
|
||||
|
||||
if (serverVersion.compareTo(MainApp.OUTDATED_SERVER_VERSION) < 0) {
|
||||
if (MainApp.OUTDATED_SERVER_VERSION.compareTo(serverVersion) >= 0) {
|
||||
DisplayUtils.showServerOutdatedSnackbar(this);
|
||||
}
|
||||
|
||||
@@ -528,6 +537,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));
|
||||
@@ -537,8 +547,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();
|
||||
@@ -1111,7 +1121,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1240,10 +1250,16 @@ 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");
|
||||
@@ -1297,8 +1313,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) {
|
||||
|
||||
@@ -1449,9 +1465,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 {
|
||||
@@ -1459,7 +1474,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,
|
||||
@@ -1556,19 +1571,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) {
|
||||
@@ -2016,7 +2027,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
if (fileDetailFragment != null && fileDetailFragment instanceof FileDetailFragment) {
|
||||
if (fileDetailFragment instanceof FileDetailFragment) {
|
||||
((FileDetailFragment) fileDetailFragment).getFileDetailSharingFragment()
|
||||
.onUpdateShareInformation(result, getFile());
|
||||
}
|
||||
|
||||
@@ -216,10 +216,21 @@ public class FirstRunActivity extends BaseActivity implements ViewPager.OnPageCh
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (FIRST_RUN_RESULT_CODE == requestCode && RESULT_OK == resultCode) {
|
||||
setAccount(AccountUtils.getCurrentOwnCloudAccount(this));
|
||||
|
||||
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
|
||||
Account account = AccountUtils.getOwnCloudAccountByName(this, accountName);
|
||||
|
||||
if (account == null) {
|
||||
DisplayUtils.showSnackMessage(this, R.string.account_creation_failed);
|
||||
return;
|
||||
}
|
||||
|
||||
setAccount(account);
|
||||
AccountUtils.setCurrentOwnCloudAccount(this, account.name);
|
||||
onAccountSet(false);
|
||||
|
||||
Intent i = new Intent(this, FileDisplayActivity.class);
|
||||
i.setAction(FileDisplayActivity.RESTART);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@@ -74,15 +74,17 @@ import java.util.Set;
|
||||
public class ManageAccountsActivity extends FileActivity
|
||||
implements AccountListAdapter.AccountListAdapterListener, AccountManagerCallback<Boolean>, ComponentsGetter {
|
||||
private static final String TAG = ManageAccountsActivity.class.getSimpleName();
|
||||
|
||||
public static final String KEY_ACCOUNT_LIST_CHANGED = "ACCOUNT_LIST_CHANGED";
|
||||
public static final String KEY_CURRENT_ACCOUNT_CHANGED = "CURRENT_ACCOUNT_CHANGED";
|
||||
|
||||
public static final String PENDING_FOR_REMOVAL = "PENDING_FOR_REMOVAL";
|
||||
|
||||
private static final String KEY_DISPLAY_NAME = "DISPLAY_NAME";
|
||||
|
||||
private static final int KEY_USER_INFO_REQUEST_CODE = 13;
|
||||
private static final int KEY_DELETE_CODE = 101;
|
||||
private static final int SINGLE_ACCOUNT = 1;
|
||||
private static final int MIN_MULTI_ACCOUNT_SIZE = 2;
|
||||
|
||||
private ListView mListView;
|
||||
private final Handler mHandler = new Handler();
|
||||
@@ -90,8 +92,8 @@ public class ManageAccountsActivity extends FileActivity
|
||||
private AccountListAdapter mAccountListAdapter;
|
||||
private ServiceConnection mDownloadServiceConnection;
|
||||
private ServiceConnection mUploadServiceConnection;
|
||||
Set<String> mOriginalAccounts;
|
||||
String mOriginalCurrentAccount;
|
||||
private Set<String> mOriginalAccounts;
|
||||
private String mOriginalCurrentAccount;
|
||||
private Drawable mTintedCheck;
|
||||
|
||||
private ArbitraryDataProvider arbitraryDataProvider;
|
||||
@@ -347,7 +349,7 @@ public class ManageAccountsActivity extends FileActivity
|
||||
}
|
||||
|
||||
List<AccountListItem> accountListItemArray = getAccountListItems();
|
||||
if (accountListItemArray.size() > 1) {
|
||||
if (accountListItemArray.size() > SINGLE_ACCOUNT) {
|
||||
mAccountListAdapter = new AccountListAdapter(this, accountListItemArray, mTintedCheck);
|
||||
mListView.setAdapter(mAccountListAdapter);
|
||||
} else {
|
||||
@@ -452,7 +454,7 @@ public class ManageAccountsActivity extends FileActivity
|
||||
}
|
||||
|
||||
// only one to be (deleted) account remaining
|
||||
if (accounts.length < 2) {
|
||||
if (accounts.length < MIN_MULTI_ACCOUNT_SIZE) {
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, true);
|
||||
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, true);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -315,9 +315,9 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
*
|
||||
* @return list of account list items
|
||||
*/
|
||||
private ArrayList<AccountListItem> getAccountListItems(ReceiveExternalFilesActivity activity) {
|
||||
private List<AccountListItem> getAccountListItems(ReceiveExternalFilesActivity activity) {
|
||||
Account[] accountList = activity.mAccountManager.getAccountsByType(MainApp.getAccountType(getActivity()));
|
||||
ArrayList<AccountListItem> adapterAccountList = new ArrayList<>(accountList.length);
|
||||
List<AccountListItem> adapterAccountList = new ArrayList<>(accountList.length);
|
||||
for (Account account : accountList) {
|
||||
adapterAccountList.add(new AccountListItem(account));
|
||||
}
|
||||
@@ -332,6 +332,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
private static final int CATEGORY_URL = 1;
|
||||
private static final int CATEGORY_MAPS_URL = 2;
|
||||
private static final int EXTRA_TEXT_LENGTH = 3;
|
||||
private static final int SINGLE_SPINNER_ENTRY = 1;
|
||||
|
||||
private List<String> mFilenameBase;
|
||||
private List<String> mFilenameSuffix;
|
||||
@@ -430,9 +432,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
final Spinner spinner = view.findViewById(R.id.file_type);
|
||||
setupSpinner(adapter, selectPos, userInput, spinner);
|
||||
if (adapter.getCount() == 1) {
|
||||
TextView label = view.findViewById(R.id.label_file_type);
|
||||
label.setVisibility(View.GONE);
|
||||
if (adapter.getCount() == SINGLE_SPINNER_ENTRY) {
|
||||
view.findViewById(R.id.label_file_type).setVisibility(View.GONE);
|
||||
spinner.setVisibility(View.GONE);
|
||||
}
|
||||
mSpinner = spinner;
|
||||
@@ -527,7 +528,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
String filename = mFilenameBase.get(selectPos) + mFilenameSuffix.get(selectPos);
|
||||
inputText.setText(filename);
|
||||
int selectionStart = 0;
|
||||
int extensionStart = filename.lastIndexOf(".");
|
||||
int extensionStart = filename.lastIndexOf('.');
|
||||
int selectionEnd = extensionStart >= 0 ? extensionStart : filename.length();
|
||||
if (selectionEnd >= 0) {
|
||||
inputText.setSelection(
|
||||
@@ -538,10 +539,14 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
private boolean isIntentFromGoogleMap(String subjectText, String extraText) {
|
||||
String texts[] = extraText.split("\n");
|
||||
if (texts.length != 3)
|
||||
if (texts.length != EXTRA_TEXT_LENGTH) {
|
||||
return false;
|
||||
if (texts[0].length() == 0 || !subjectText.equals(texts[0]))
|
||||
}
|
||||
|
||||
if (texts[0].length() == 0 || !subjectText.equals(texts[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return texts[2].startsWith("https://goo.gl/maps/");
|
||||
}
|
||||
|
||||
@@ -625,7 +630,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mParents.size() <= 1) {
|
||||
if (mParents.size() <= SINGLE_PARENT) {
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
mParents.pop();
|
||||
|
||||
@@ -151,8 +151,8 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
|
||||
return getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
|
||||
OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9;
|
||||
} else {
|
||||
return (getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE);
|
||||
return getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
|
||||
OCShare.MAXIMUM_PERMISSIONS_FOR_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author David Luhmer
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2018 David Luhmer
|
||||
* Copyright (C) 2018 Andy Scherzinger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.nextcloud.android.sso.Constants;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_ACCESS_DECLINED;
|
||||
import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_NOT_FOUND;
|
||||
import static com.nextcloud.android.sso.Constants.NEXTCLOUD_FILES_ACCOUNT;
|
||||
import static com.nextcloud.android.sso.Constants.NEXTCLOUD_SSO;
|
||||
import static com.nextcloud.android.sso.Constants.NEXTCLOUD_SSO_EXCEPTION;
|
||||
import static com.nextcloud.android.sso.Constants.SSO_SHARED_PREFERENCE;
|
||||
|
||||
/**
|
||||
* Activity for granting access rights to a Nextcloud account, used for SSO.
|
||||
*/
|
||||
public class SsoGrantPermissionActivity extends BaseActivity {
|
||||
|
||||
private static final String TAG = SsoGrantPermissionActivity.class.getCanonicalName();
|
||||
|
||||
private String packageName;
|
||||
private Account account;
|
||||
|
||||
private Unbinder unbinder;
|
||||
|
||||
@BindView(R.id.appIcon)
|
||||
ImageView appIcon;
|
||||
|
||||
@BindView(R.id.permissionText)
|
||||
TextView permissionText;
|
||||
|
||||
@BindView(R.id.btnGrant)
|
||||
Button grantPermissionButton;
|
||||
|
||||
@BindView(R.id.btnDecline)
|
||||
Button declinePermissionButton;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sso_grant_permission);
|
||||
|
||||
unbinder = ButterKnife.bind(this);
|
||||
|
||||
ComponentName callingActivity = getCallingActivity();
|
||||
|
||||
if (callingActivity != null) {
|
||||
packageName = callingActivity.getPackageName();
|
||||
String appName = getAppNameForPackage(packageName);
|
||||
account = getIntent().getParcelableExtra(NEXTCLOUD_FILES_ACCOUNT);
|
||||
permissionText.setText(makeSpecialPartsBold(
|
||||
getString(R.string.single_sign_on_request_token, appName, account.name),
|
||||
appName,
|
||||
account.name)
|
||||
);
|
||||
Log.v(TAG, "TOKEN-REQUEST: Calling Package: " + packageName);
|
||||
Log.v(TAG, "TOKEN-REQUEST: App Name: " + appName);
|
||||
} else {
|
||||
// Activity was not started using startActivityForResult!
|
||||
Log.e(TAG, "Calling Package is null");
|
||||
setResultAndExit("Request was not executed properly. Use startActivityForResult()");
|
||||
}
|
||||
|
||||
try {
|
||||
if (packageName != null) {
|
||||
Drawable appIcon = getPackageManager().getApplicationIcon(packageName);
|
||||
this.appIcon.setImageDrawable(appIcon);
|
||||
}
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
}
|
||||
|
||||
int primaryColor = ThemeUtils.primaryColor(this, true);
|
||||
grantPermissionButton.setTextColor(primaryColor);
|
||||
declinePermissionButton.setTextColor(primaryColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
unbinder.unbind();
|
||||
}
|
||||
|
||||
private SpannableStringBuilder makeSpecialPartsBold(String text, String... toBeStyledText) {
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder(text);
|
||||
for (String textBlock : toBeStyledText) {
|
||||
int start = text.indexOf(textBlock);
|
||||
int end = start + textBlock.length();
|
||||
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, end, 0);
|
||||
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
return ssb;
|
||||
}
|
||||
|
||||
private void setResultAndExit(String exception) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra(NEXTCLOUD_SSO_EXCEPTION, exception);
|
||||
setResult(RESULT_CANCELED, data);
|
||||
finish();
|
||||
}
|
||||
|
||||
private String getAppNameForPackage(String pkg) {
|
||||
final PackageManager pm = getApplicationContext().getPackageManager();
|
||||
ApplicationInfo ai = null;
|
||||
try {
|
||||
ai = pm.getApplicationInfo(pkg, 0);
|
||||
} catch (final PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, e.getMessage());
|
||||
}
|
||||
return (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)");
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnDecline)
|
||||
void exitFailed() {
|
||||
setResultAndExit(EXCEPTION_ACCOUNT_ACCESS_DECLINED);
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnGrant)
|
||||
void grantPermission() {
|
||||
// create token
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(SSO_SHARED_PREFERENCE, Context.MODE_PRIVATE);
|
||||
String token = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
|
||||
String hashedTokenWithSalt = EncryptionUtils.generateSHA512(token);
|
||||
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putString(packageName, hashedTokenWithSalt);
|
||||
editor.apply();
|
||||
|
||||
String serverUrl;
|
||||
String userId;
|
||||
try {
|
||||
OwnCloudAccount ocAccount = new OwnCloudAccount(account, this);
|
||||
serverUrl = ocAccount.getBaseUri().toString();
|
||||
AccountManager accountManager = AccountManager.get(this);
|
||||
userId = accountManager.getUserData(account,
|
||||
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
|
||||
} catch (AccountUtils.AccountNotFoundException e) {
|
||||
Log_OC.e(TAG, "Account not found");
|
||||
setResultAndExit(EXCEPTION_ACCOUNT_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
final Bundle result = new Bundle();
|
||||
result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
|
||||
result.putString(AccountManager.KEY_ACCOUNT_TYPE, MainApp.getAccountType(this));
|
||||
result.putString(AccountManager.KEY_AUTHTOKEN, NEXTCLOUD_SSO);
|
||||
result.putString(Constants.SSO_USERNAME, userId);
|
||||
result.putString(Constants.SSO_TOKEN, token);
|
||||
result.putString(Constants.SSO_SERVER_URL, serverUrl);
|
||||
|
||||
Intent data = new Intent();
|
||||
data.putExtra(NEXTCLOUD_SSO, result);
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -251,14 +251,14 @@ public class StorageMigration {
|
||||
}
|
||||
|
||||
protected void stopAccountsSyncing() {
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
ContentResolver.setSyncAutomatically(mOcAccounts[i], mAuthority, false);
|
||||
for (Account ocAccount : mOcAccounts) {
|
||||
ContentResolver.setSyncAutomatically(ocAccount, mAuthority, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void waitForUnfinishedSynchronizations() {
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
while (ContentResolver.isSyncActive(mOcAccounts[i], mAuthority)) {
|
||||
for (Account ocAccount : mOcAccounts) {
|
||||
while (ContentResolver.isSyncActive(ocAccount, mAuthority)) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -274,8 +274,9 @@ public class StorageMigration {
|
||||
// probably migration failed even before saving states,
|
||||
// which is weird and should be investigated.
|
||||
// But its better than crashing on ArrayOutOfBounds.
|
||||
if (oldSync == null)
|
||||
if (oldSync == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
ContentResolver.setSyncAutomatically(mOcAccounts[i], mAuthority, oldSync[i]);
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
|
||||
|
||||
List<SyncedFolder> syncedFolderArrayList = mSyncedFolderProvider.getSyncedFolders();
|
||||
List<SyncedFolder> currentAccountSyncedFoldersList = new ArrayList<>();
|
||||
Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(SyncedFoldersActivity.this);
|
||||
Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(this);
|
||||
for (SyncedFolder syncedFolder : syncedFolderArrayList) {
|
||||
if (currentAccount != null && syncedFolder.getAccount().equals(currentAccount.name)) {
|
||||
currentAccountSyncedFoldersList.add(syncedFolder);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David A. Velasco
|
||||
@@ -82,6 +82,7 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
OnClickListener, ConfirmationDialogFragmentListener, SortingOrderDialogFragment.OnSortingOrderListener {
|
||||
|
||||
private static final String SORT_ORDER_DIALOG_TAG = "SORT_ORDER_DIALOG";
|
||||
private static final int SINGLE_DIR = 1;
|
||||
|
||||
private ArrayAdapter<String> mDirectories;
|
||||
private File mCurrentDir;
|
||||
@@ -125,12 +126,22 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
mLocalFolderPickerMode = extras.getBoolean(KEY_LOCAL_FOLDER_PICKER_MODE, false);
|
||||
}
|
||||
|
||||
if(savedInstanceState != null) {
|
||||
if (savedInstanceState != null) {
|
||||
mCurrentDir = new File(savedInstanceState.getString(UploadFilesActivity.KEY_DIRECTORY_PATH, Environment
|
||||
.getExternalStorageDirectory().getAbsolutePath()));
|
||||
mSelectAll = savedInstanceState.getBoolean(UploadFilesActivity.KEY_ALL_SELECTED, false);
|
||||
} else {
|
||||
mCurrentDir = Environment.getExternalStorageDirectory();
|
||||
String lastUploadFrom = PreferenceManager.getUploadFromLocalLastPath(this);
|
||||
|
||||
if (!lastUploadFrom.isEmpty()) {
|
||||
mCurrentDir = new File(lastUploadFrom);
|
||||
|
||||
while (!mCurrentDir.exists()) {
|
||||
mCurrentDir = mCurrentDir.getParentFile();
|
||||
}
|
||||
} else {
|
||||
mCurrentDir = Environment.getExternalStorageDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
mAccountOnCreation = getAccount();
|
||||
@@ -333,7 +344,7 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
mSearchView.onActionViewCollapsed();
|
||||
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
|
||||
} else {
|
||||
if (mDirectories.getCount() <= 1) {
|
||||
if (mDirectories.getCount() <= SINGLE_DIR) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
@@ -486,9 +497,11 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
finish();
|
||||
|
||||
} else if (v.getId() == R.id.upload_files_btn_upload) {
|
||||
if(mLocalFolderPickerMode) {
|
||||
PreferenceManager.setUploadFromLocalLastPath(this, mCurrentDir.getAbsolutePath());
|
||||
|
||||
if (mLocalFolderPickerMode) {
|
||||
Intent data = new Intent();
|
||||
if(mCurrentDir != null) {
|
||||
if (mCurrentDir != null) {
|
||||
data.putExtra(EXTRA_CHOSEN_FILES, mCurrentDir.getAbsolutePath());
|
||||
}
|
||||
setResult(RESULT_OK, data);
|
||||
|
||||
@@ -42,7 +42,6 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -261,8 +260,7 @@ public class UserInfoActivity extends FileActivity {
|
||||
private void populateUserInfoUi(UserInfo userInfo) {
|
||||
userName.setText(account.name);
|
||||
avatar.setTag(account.name);
|
||||
DisplayUtils.setAvatar(account, UserInfoActivity.this, mCurrentAccountAvatarRadiusDimension, getResources(),
|
||||
avatar, this);
|
||||
DisplayUtils.setAvatar(account, this, mCurrentAccountAvatarRadiusDimension, getResources(), avatar, this);
|
||||
|
||||
int tint = ThemeUtils.primaryColor(account, true, this);
|
||||
|
||||
@@ -301,8 +299,9 @@ public class UserInfoActivity extends FileActivity {
|
||||
|
||||
private void addToListIfNeeded(List<UserInfoDetailsItem> info, @DrawableRes int icon, String text,
|
||||
@StringRes int contentDescriptionInt) {
|
||||
if (!TextUtils.isEmpty(text))
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
info.add(new UserInfoDetailsItem(icon, text, getResources().getString(contentDescriptionInt)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void openAccountRemovalConfirmationDialog(Account account, FragmentManager fragmentManager,
|
||||
@@ -412,7 +411,7 @@ public class UserInfoActivity extends FileActivity {
|
||||
private void fetchAndSetData() {
|
||||
Thread t = new Thread(() -> {
|
||||
RemoteOperation getRemoteUserInfoOperation = new GetRemoteUserInfoOperation();
|
||||
RemoteOperationResult result = getRemoteUserInfoOperation.execute(account, UserInfoActivity.this);
|
||||
RemoteOperationResult result = getRemoteUserInfoOperation.execute(account, this);
|
||||
|
||||
if (result.isSuccess() && result.getData() != null) {
|
||||
userInfo = (UserInfo) result.getData().get(0);
|
||||
@@ -462,8 +461,8 @@ public class UserInfoActivity extends FileActivity {
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
@BindView(R.id.icon) protected ImageView icon = null;
|
||||
@BindView(R.id.text) protected TextView text = null;
|
||||
@BindView(R.id.icon) protected ImageView icon;
|
||||
@BindView(R.id.text) protected TextView text;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@@ -486,8 +485,7 @@ public class UserInfoActivity extends FileActivity {
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.user_info_details_table_item, parent, false);
|
||||
ViewHolder holder = new ViewHolder(view);
|
||||
return holder;
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -127,9 +127,9 @@ public class ActivityAndVersionListAdapter extends ActivityListAdapter {
|
||||
public int getItemViewType(int position) {
|
||||
Object value = values.get(position);
|
||||
|
||||
if (value instanceof Activity)
|
||||
if (value instanceof Activity) {
|
||||
return ACTIVITY_TYPE;
|
||||
else if (value instanceof FileVersion) {
|
||||
} else if (value instanceof FileVersion) {
|
||||
return VERSION_TYPE;
|
||||
} else {
|
||||
return HEADER_TYPE;
|
||||
|
||||
@@ -299,10 +299,10 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
String text = richElement.getRichSubject();
|
||||
SpannableStringBuilder ssb = new SpannableStringBuilder(text);
|
||||
|
||||
int idx1 = text.indexOf("{");
|
||||
int idx1 = text.indexOf('{');
|
||||
int idx2;
|
||||
while (idx1 != -1) {
|
||||
idx2 = text.indexOf("}", idx1) + 1;
|
||||
idx2 = text.indexOf('}', idx1) + 1;
|
||||
final String clickString = text.substring(idx1 + 1, idx2 - 1);
|
||||
final RichObject richObject = searchObjectByName(richElement.getRichObjectList(), clickString);
|
||||
if (richObject != null) {
|
||||
@@ -324,7 +324,7 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), idx1, idx2, 0);
|
||||
ssb.setSpan(new ForegroundColorSpan(Color.BLACK), idx1, idx2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
idx1 = text.indexOf("{", idx2);
|
||||
idx1 = text.indexOf('{', idx2);
|
||||
}
|
||||
|
||||
return ssb;
|
||||
@@ -332,8 +332,9 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
private RichObject searchObjectByName(List<RichObject> richObjectList, String name) {
|
||||
for (RichObject richObject : richObjectList) {
|
||||
if (richObject.getTag().equalsIgnoreCase(name))
|
||||
if (richObject.getTag().equalsIgnoreCase(name)) {
|
||||
return richObject;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -341,10 +342,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (values.get(position) instanceof Activity)
|
||||
if (values.get(position) instanceof Activity) {
|
||||
return ACTIVITY_TYPE;
|
||||
else
|
||||
} else {
|
||||
return HEADER_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -241,14 +241,14 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
/* Cancellation needs do be checked and done before changing the drawable in fileIcon, or
|
||||
* {@link ThumbnailsCacheManager#cancelPotentialThumbnailWork} will NEVER cancel any task.
|
||||
*/
|
||||
boolean allowedToCreateNewThumbnail = (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView));
|
||||
boolean allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView);
|
||||
|
||||
|
||||
// get Thumbnail if file is image
|
||||
if (MimeTypeUtil.isImage(file)) {
|
||||
// Thumbnail in Cache?
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
ThumbnailsCacheManager.PREFIX_THUMBNAIL + String.valueOf(file.hashCode())
|
||||
ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.hashCode()
|
||||
);
|
||||
if (thumbnail != null) {
|
||||
thumbnailView.setImageBitmap(thumbnail);
|
||||
@@ -519,6 +519,10 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
return output;
|
||||
}
|
||||
|
||||
public void setGridView(boolean gridView) {
|
||||
this.gridView = gridView;
|
||||
}
|
||||
|
||||
static class LocalFileListItemViewHolder extends LocalFileListGridViewHolder {
|
||||
private final TextView fileSize;
|
||||
private final TextView lastModification;
|
||||
@@ -530,6 +534,8 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
fileSize = itemView.findViewById(R.id.file_size);
|
||||
fileSeparator = itemView.findViewById(R.id.file_separator);
|
||||
lastModification = itemView.findViewById(R.id.last_mod);
|
||||
|
||||
itemView.findViewById(R.id.overflow_menu).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +553,6 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
checkbox = itemView.findViewById(R.id.custom_checkbox);
|
||||
itemLayout = itemView.findViewById(R.id.ListItemLayout);
|
||||
|
||||
itemView.findViewById(R.id.overflow_menu).setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.sharedIcon).setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.favorite_action).setVisibility(View.GONE);
|
||||
itemView.findViewById(R.id.keptOfflineIcon).setVisibility(View.GONE);
|
||||
|
||||
@@ -108,6 +108,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
private static final int VIEWTYPE_IMAGE = 2;
|
||||
|
||||
private List<ThumbnailsCacheManager.ThumbnailGenerationTask> asyncTasks = new ArrayList<>();
|
||||
private boolean onlyOnDevice = false;
|
||||
|
||||
public OCFileListAdapter(Context context, ComponentsGetter transferServiceGetter,
|
||||
OCFileListFragmentInterface ocFileListFragmentInterface, boolean argHideItemOptions,
|
||||
@@ -162,14 +163,16 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
}
|
||||
|
||||
public void setFavoriteAttributeForItemID(String fileId, boolean favorite) {
|
||||
for (int i = 0; i < mFiles.size(); i++) {
|
||||
int filesSize = mFiles.size();
|
||||
for (int i = 0; i < filesSize; i++) {
|
||||
if (mFiles.get(i).getRemoteId().equals(fileId)) {
|
||||
mFiles.get(i).setFavorite(favorite);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mFilesAll.size(); i++) {
|
||||
filesSize = mFilesAll.size();
|
||||
for (int i = 0; i < filesSize; i++) {
|
||||
if (mFilesAll.get(i).getRemoteId().equals(fileId)) {
|
||||
mFilesAll.get(i).setFavorite(favorite);
|
||||
break;
|
||||
@@ -283,7 +286,21 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
|
||||
if (holder instanceof OCFileListItemViewHolder) {
|
||||
OCFileListItemViewHolder itemViewHolder = (OCFileListItemViewHolder) holder;
|
||||
itemViewHolder.fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
||||
|
||||
if (onlyOnDevice) {
|
||||
File localFile = new File(file.getStoragePath());
|
||||
|
||||
long localSize;
|
||||
if (localFile.isDirectory()) {
|
||||
localSize = FileStorageUtils.getFolderSize(localFile);
|
||||
} else {
|
||||
localSize = localFile.length();
|
||||
}
|
||||
|
||||
itemViewHolder.fileSize.setText(DisplayUtils.bytesToHumanReadable(localSize));
|
||||
} else {
|
||||
itemViewHolder.fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
||||
}
|
||||
itemViewHolder.lastModification.setText(DisplayUtils.getRelativeTimestamp(mContext,
|
||||
file.getModificationTimestamp()));
|
||||
|
||||
@@ -323,7 +340,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
gridViewHolder.localFileIndicator.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
gridViewHolder.favorite.setVisibility(file.getIsFavorite() ? View.VISIBLE : View.GONE);
|
||||
gridViewHolder.favorite.setVisibility(file.isFavorite() ? View.VISIBLE : View.GONE);
|
||||
gridViewHolder.offlineIcon.setVisibility(file.isAvailableOffline() ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (multiSelect) {
|
||||
@@ -365,7 +382,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
|
||||
// Thumbnail in cache?
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
ThumbnailsCacheManager.PREFIX_THUMBNAIL + String.valueOf(file.getRemoteId())
|
||||
ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.getRemoteId()
|
||||
);
|
||||
|
||||
if (thumbnail != null && !file.needsUpdateThumbnail()) {
|
||||
@@ -499,6 +516,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
||||
*/
|
||||
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager,
|
||||
boolean onlyOnDevice) {
|
||||
this.onlyOnDevice = onlyOnDevice;
|
||||
if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
|
||||
mStorageManager = updatedStorageManager;
|
||||
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package com.owncloud.android.ui.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -31,7 +32,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.shares.ShareType;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
@@ -90,27 +90,25 @@ public class ShareUserListAdapter extends ArrayAdapter {
|
||||
final ImageView unshareButton = view.findViewById(R.id.unshareButton);
|
||||
|
||||
String name = share.getSharedWithDisplayName();
|
||||
if (share.getShareType() == ShareType.GROUP) {
|
||||
name = getContext().getString(R.string.share_group_clarification, name);
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_group);
|
||||
}
|
||||
} else if (share.getShareType() == ShareType.EMAIL) {
|
||||
name = getContext().getString(R.string.share_email_clarification, name);
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_email);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(R.drawable.ic_user);
|
||||
}
|
||||
|
||||
switch (share.getShareType()) {
|
||||
case GROUP:
|
||||
name = getContext().getString(R.string.share_group_clarification, name);
|
||||
setImage(icon, name, R.drawable.ic_group);
|
||||
break;
|
||||
case EMAIL:
|
||||
name = getContext().getString(R.string.share_email_clarification, name);
|
||||
setImage(icon, name, R.drawable.ic_email);
|
||||
break;
|
||||
case ROOM:
|
||||
name = getContext().getString(R.string.share_room_clarification, name);
|
||||
setImage(icon, name, R.drawable.ic_chat_bubble);
|
||||
break;
|
||||
default:
|
||||
setImage(icon, name, R.drawable.ic_user);
|
||||
break;
|
||||
}
|
||||
|
||||
userName.setText(name);
|
||||
|
||||
/// bind listener to edit privileges
|
||||
@@ -122,6 +120,14 @@ public class ShareUserListAdapter extends ArrayAdapter {
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setImage(ImageView icon, String name, @DrawableRes int fallback) {
|
||||
try {
|
||||
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
icon.setImageResource(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
public interface ShareUserAdapterListener {
|
||||
void unshareButtonPressed(OCShare share);
|
||||
void editShare(OCShare share);
|
||||
|
||||
@@ -211,7 +211,7 @@ public class TrashbinListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) && file.getRemoteId() != null) {
|
||||
// Thumbnail in cache?
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
ThumbnailsCacheManager.PREFIX_THUMBNAIL + String.valueOf(file.getRemoteId())
|
||||
ThumbnailsCacheManager.PREFIX_THUMBNAIL + file.getRemoteId()
|
||||
);
|
||||
|
||||
if (thumbnail != null) {
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.owncloud.android.ui.adapter;
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
@@ -71,7 +72,6 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
|
||||
private float avatarRadiusDimension;
|
||||
private Account account;
|
||||
private OCFile file;
|
||||
private FileDataStorageManager storageManager;
|
||||
|
||||
public UserListAdapter(FragmentManager fragmentManager, Context context, List<OCShare> shares, Account account,
|
||||
OCFile file, ShareeListAdapterListener listener) {
|
||||
@@ -83,8 +83,7 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
|
||||
this.file = file;
|
||||
|
||||
accentColor = ThemeUtils.primaryAccentColor(context);
|
||||
storageManager = new FileDataStorageManager(account, context.getContentResolver());
|
||||
capabilities = storageManager.getCapability(account.name);
|
||||
capabilities = new FileDataStorageManager(account, context.getContentResolver()).getCapability(account.name);
|
||||
avatarRadiusDimension = context.getResources().getDimension(R.dimen.user_icon_radius);
|
||||
}
|
||||
|
||||
@@ -101,25 +100,25 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
|
||||
final OCShare share = shares.get(position);
|
||||
|
||||
String name = share.getSharedWithDisplayName();
|
||||
if (share.getShareType() == ShareType.GROUP) {
|
||||
name = context.getString(R.string.share_group_clarification, name);
|
||||
try {
|
||||
holder.avatar.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
holder.avatar.setImageResource(R.drawable.ic_group);
|
||||
}
|
||||
} else if (share.getShareType() == ShareType.EMAIL) {
|
||||
name = context.getString(R.string.share_email_clarification, name);
|
||||
try {
|
||||
holder.avatar.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
holder.avatar.setImageResource(R.drawable.ic_email);
|
||||
}
|
||||
} else {
|
||||
holder.avatar.setTag(share.getShareWith());
|
||||
DisplayUtils.setAvatar(account, share.getShareWith(), this, avatarRadiusDimension,
|
||||
context.getResources(), holder.avatar, context);
|
||||
|
||||
switch (share.getShareType()) {
|
||||
case GROUP:
|
||||
name = context.getString(R.string.share_group_clarification, name);
|
||||
setImage(holder, name, R.drawable.ic_group);
|
||||
break;
|
||||
case EMAIL:
|
||||
name = context.getString(R.string.share_email_clarification, name);
|
||||
setImage(holder, name, R.drawable.ic_email);
|
||||
break;
|
||||
case ROOM:
|
||||
name = context.getString(R.string.share_room_clarification, name);
|
||||
setImage(holder, name, R.drawable.ic_chat_bubble);
|
||||
break;
|
||||
default:
|
||||
setImage(holder, name, R.drawable.ic_user);
|
||||
break;
|
||||
}
|
||||
|
||||
holder.name.setText(name);
|
||||
|
||||
ThemeUtils.tintCheckbox(holder.allowEditing, accentColor);
|
||||
@@ -131,6 +130,14 @@ public class UserListAdapter extends RecyclerView.Adapter<UserListAdapter.UserVi
|
||||
}
|
||||
}
|
||||
|
||||
private void setImage(UserViewHolder holder, String name, @DrawableRes int fallback) {
|
||||
try {
|
||||
holder.avatar.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
holder.avatar.setImageResource(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return shares.get(position).getId();
|
||||
|
||||
@@ -61,9 +61,9 @@ public class CustomEditText extends android.support.v7.widget.AppCompatEditText
|
||||
|| getText().toString().startsWith(AuthenticatorActivity.HTTPS_PROTOCOL)) {
|
||||
return getText().toString();
|
||||
} else if (isPrefixFixed) {
|
||||
return (getResources().getString(R.string.server_url) + "/" + getText().toString());
|
||||
return getResources().getString(R.string.server_url) + "/" + getText().toString();
|
||||
} else {
|
||||
return (getText().toString() + "." + getResources().getString(R.string.server_url));
|
||||
return getText().toString() + "." + getResources().getString(R.string.server_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
@@ -37,10 +37,6 @@ public class LoadingDialog extends DialogFragment {
|
||||
|
||||
private String mMessage;
|
||||
|
||||
public LoadingDialog() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
@@ -42,10 +42,10 @@ import java.util.Collection;
|
||||
public class RemoveFilesDialogFragment extends ConfirmationDialogFragment implements
|
||||
ConfirmationDialogFragmentListener {
|
||||
|
||||
private Collection<OCFile> mTargetFiles;
|
||||
|
||||
private static final int SINGLE_SELECTION = 1;
|
||||
private static final String ARG_TARGET_FILES = "TARGET_FILES";
|
||||
|
||||
private Collection<OCFile> mTargetFiles;
|
||||
private ActionMode actionMode;
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class RemoveFilesDialogFragment extends ConfirmationDialogFragment implem
|
||||
containsFavorite |= file.isAvailableOffline();
|
||||
}
|
||||
|
||||
if (files.size() == 1) {
|
||||
if (files.size() == SINGLE_SELECTION) {
|
||||
// choose message for a single file
|
||||
OCFile file = files.get(0);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class RemoveFilesDialogFragment extends ConfirmationDialogFragment implem
|
||||
-1;
|
||||
|
||||
args.putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId);
|
||||
if (files.size() == 1) {
|
||||
if (files.size() == SINGLE_SELECTION) {
|
||||
args.putStringArray(ARG_MESSAGE_ARGUMENTS, new String[]{files.get(0).getFileName()});
|
||||
}
|
||||
args.putInt(ARG_POSITIVE_BTN_RES, R.string.file_delete);
|
||||
|
||||
@@ -185,6 +185,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
|
||||
|
||||
try {
|
||||
String privateKey = task.get();
|
||||
String mnemonicUnchanged = passwordField.getText().toString();
|
||||
String mnemonic = passwordField.getText().toString().replaceAll("\\s", "")
|
||||
.toLowerCase(Locale.ROOT);
|
||||
String decryptedPrivateKey = EncryptionUtils.decryptPrivateKey(privateKey,
|
||||
@@ -197,7 +198,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
|
||||
Log_OC.d(TAG, "Private key successfully decrypted and stored");
|
||||
|
||||
arbitraryDataProvider.storeOrUpdateKeyValue(account.name, EncryptionUtils.MNEMONIC,
|
||||
mnemonic);
|
||||
mnemonicUnchanged);
|
||||
|
||||
Intent intentExisting = new Intent();
|
||||
intentExisting.putExtra(SUCCESS, true);
|
||||
|
||||
@@ -321,11 +321,11 @@ public class SslValidatorDialog extends Dialog {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
String toParse = principal.getName();
|
||||
String[] pieces = toParse.split(",");
|
||||
String[] tokens = {"CN", "O", "OU", "C", "ST", "L"};
|
||||
for (int i=0; i < pieces.length ; i++) {
|
||||
for (int j=0; j<tokens.length; j++) {
|
||||
if (pieces[i].startsWith(tokens[j] + "=")) {
|
||||
result.put(tokens[j], pieces[i].substring(tokens[j].length()+1));
|
||||
String[] tokens = {"CN", "O", "OU", "C", "ST", "L"};
|
||||
for (String piece : pieces) {
|
||||
for (String token : tokens) {
|
||||
if (piece.startsWith(token + "=")) {
|
||||
result.put(token, piece.substring(token.length() + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,12 +290,11 @@ public class EditShareFragment extends Fragment {
|
||||
if (isChecked) {
|
||||
if (!isFederated) {
|
||||
/// not federated shares -> enable all the subpermisions
|
||||
for (int i = 0; i < sSubordinateCheckBoxIds.length; i++) {
|
||||
for (int subordinateCheckBoxId : sSubordinateCheckBoxIds) {
|
||||
//noinspection ConstantConditions, prevented in the method beginning
|
||||
subordinate = getView().findViewById(sSubordinateCheckBoxIds[i]);
|
||||
subordinate = getView().findViewById(subordinateCheckBoxId);
|
||||
subordinate.setVisibility(View.VISIBLE);
|
||||
if (!subordinate.isChecked() &&
|
||||
!mFile.isSharedWithMe()) { // see (1)
|
||||
if (!subordinate.isChecked() && !mFile.isSharedWithMe()) { // see (1)
|
||||
toggleDisablingListener(subordinate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.owncloud.android.ui.fragment;
|
||||
import android.animation.LayoutTransition;
|
||||
import android.app.Activity;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -208,7 +209,7 @@ public class ExtendedListFragment extends Fragment
|
||||
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)) {
|
||||
|
||||
if (!(getActivity() instanceof UploadFilesActivity)) {
|
||||
setFabEnabled(!hasFocus);
|
||||
setFabVisible(!hasFocus);
|
||||
}
|
||||
|
||||
boolean searchSupported = AccountUtils.hasSearchSupport(AccountUtils.
|
||||
@@ -298,7 +299,7 @@ public class ExtendedListFragment extends Fragment
|
||||
delay = 0;
|
||||
}
|
||||
|
||||
if (adapter != null && adapter instanceof OCFileListAdapter) {
|
||||
if (adapter instanceof OCFileListAdapter) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -312,7 +313,7 @@ public class ExtendedListFragment extends Fragment
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
} else if (adapter != null && adapter instanceof LocalFileListAdapter) {
|
||||
} else if (adapter instanceof LocalFileListAdapter) {
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -588,21 +589,42 @@ public class ExtendedListFragment extends Fragment
|
||||
|
||||
/**
|
||||
* Sets the 'visibility' state of the FAB contained in the fragment.
|
||||
* <p>
|
||||
* When 'false' is set, FAB visibility is set to View.GONE programmatically,
|
||||
*
|
||||
* When 'false' is set, FAB visibility is set to View.GONE programmatically.
|
||||
*
|
||||
* @param visible Desired visibility for the FAB.
|
||||
*/
|
||||
public void setFabVisible(final boolean visible) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(() -> {
|
||||
if (visible) {
|
||||
mFabMain.show();
|
||||
ThemeUtils.tintDrawable(mFabMain.getBackground(), ThemeUtils.primaryColor(getContext()));
|
||||
} else {
|
||||
mFabMain.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the 'visibility' state of the FAB contained in the fragment.
|
||||
*
|
||||
* When 'false' is set, FAB is greyed out
|
||||
*
|
||||
* @param enabled Desired visibility for the FAB.
|
||||
*/
|
||||
public void setFabEnabled(final boolean enabled) {
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (enabled) {
|
||||
mFabMain.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mFabMain.setVisibility(View.GONE);
|
||||
}
|
||||
getActivity().runOnUiThread(() -> {
|
||||
mFabMain.show();
|
||||
|
||||
if (enabled) {
|
||||
mFabMain.setEnabled(true);
|
||||
ThemeUtils.tintDrawable(mFabMain.getBackground(), ThemeUtils.primaryColor(getContext()));
|
||||
} else {
|
||||
mFabMain.setEnabled(false);
|
||||
ThemeUtils.tintDrawable(mFabMain.getBackground(), Color.GRAY);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.features.FeatureItem;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
|
||||
public class FeatureFragment extends Fragment {
|
||||
@@ -46,7 +47,7 @@ public class FeatureFragment extends Fragment {
|
||||
|
||||
ImageView whatsNewImage = view.findViewById(R.id.whatsNewImage);
|
||||
if (item.shouldShowImage()) {
|
||||
whatsNewImage.setImageResource(item.getImage());
|
||||
whatsNewImage.setImageDrawable(ThemeUtils.tintDrawable(item.getImage(), fontColor));
|
||||
}
|
||||
|
||||
TextView whatsNewTitle = view.findViewById(R.id.whatsNewTitle);
|
||||
|
||||
@@ -69,6 +69,8 @@ import com.owncloud.android.ui.interfaces.ActivityListInterface;
|
||||
import com.owncloud.android.ui.interfaces.VersionListInterface;
|
||||
import com.owncloud.android.utils.ThemeUtils;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -332,7 +334,7 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
|
||||
Log_OC.d(TAG, result.getLogMessage());
|
||||
// show error
|
||||
String logMessage = result.getLogMessage();
|
||||
if (result.getHttpCode() == 304) {
|
||||
if (result.getHttpCode() == HttpStatus.SC_NOT_MODIFIED) {
|
||||
logMessage = noResultsMessage;
|
||||
}
|
||||
final String finalLogMessage = logMessage;
|
||||
|
||||
@@ -433,12 +433,12 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||
break;
|
||||
}
|
||||
case R.id.favorite: {
|
||||
if (getFile().getIsFavorite()) {
|
||||
if (getFile().isFavorite()) {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), false);
|
||||
} else {
|
||||
mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), true);
|
||||
}
|
||||
setFavoriteIconStatus(!getFile().getIsFavorite());
|
||||
setFavoriteIconStatus(!getFile().isFavorite());
|
||||
break;
|
||||
}
|
||||
case R.id.overflow_menu: {
|
||||
@@ -503,7 +503,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||
fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
|
||||
fileModifiedTimestamp.setText(DisplayUtils.getRelativeTimestamp(getContext(), file.getModificationTimestamp()));
|
||||
setFilePreview(file);
|
||||
setFavoriteIconStatus(file.getIsFavorite());
|
||||
setFavoriteIconStatus(file.isFavorite());
|
||||
|
||||
// configure UI for depending upon local state of the file
|
||||
FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
|
||||
@@ -577,7 +577,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(getFile(), activity.getPreviewImageView()) &&
|
||||
mContainerActivity.getStorageManager() != null) {
|
||||
final ThumbnailsCacheManager.ResizedImageGenerationTask task =
|
||||
new ThumbnailsCacheManager.ResizedImageGenerationTask(FileDetailFragment.this,
|
||||
new ThumbnailsCacheManager.ResizedImageGenerationTask(this,
|
||||
activity.getPreviewImageView(),
|
||||
mContainerActivity.getStorageManager(),
|
||||
mContainerActivity.getStorageManager().getAccount());
|
||||
|
||||
@@ -24,6 +24,8 @@ import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -91,7 +93,7 @@ public class LocalFileListFragment extends ExtendedListFragment implements Local
|
||||
}
|
||||
|
||||
setSwipeEnabled(false); // Disable pull-to-refresh
|
||||
setFabEnabled(false); // Disable FAB
|
||||
setFabVisible(false); // Disable FAB
|
||||
|
||||
Log_OC.i(TAG, "onCreateView() end");
|
||||
return v;
|
||||
@@ -271,6 +273,43 @@ public class LocalFileListFragment extends ExtendedListFragment implements Local
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchToGridView() {
|
||||
mAdapter.setGridView(true);
|
||||
/**
|
||||
* Set recyclerview adapter again to force new view for items. If this is not done
|
||||
* a few items keep their old view.
|
||||
*
|
||||
* https://stackoverflow.com/questions/36495009/force-recyclerview-to-redraw-android
|
||||
*/
|
||||
getRecyclerView().setAdapter(mAdapter);
|
||||
|
||||
if (!isGridEnabled()) {
|
||||
RecyclerView.LayoutManager layoutManager;
|
||||
layoutManager = new GridLayoutManager(getContext(), getColumnSize());
|
||||
((GridLayoutManager) layoutManager).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
if (position == mAdapter.getItemCount() - 1) {
|
||||
return ((GridLayoutManager) layoutManager).getSpanCount();
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getRecyclerView().setLayoutManager(layoutManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchToListView() {
|
||||
mAdapter.setGridView(false);
|
||||
/** Same problem here, see switchToGridView() */
|
||||
getRecyclerView().setAdapter(mAdapter);
|
||||
super.switchToListView();
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to implement by any Activity that includes some instance of LocalFileListFragment
|
||||
*/
|
||||
|
||||
Loaded 100 of 153 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user