Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5218d53e0 | ||
|
|
2ba7087953 | ||
|
|
911e4072f4 | ||
|
|
9809e88ec0 | ||
|
|
0c7c92c40b | ||
|
|
a638f3c31b | ||
|
|
d2c6f0c0a7 | ||
|
|
a44441bdda | ||
|
|
c6d71c4c14 | ||
|
|
fc06e1b91e | ||
|
|
e73f9970ee | ||
|
|
4c4d6948cc | ||
|
|
054717cc65 | ||
|
|
58652a5522 | ||
|
|
f7195a0192 | ||
|
|
6a6fb1dab7 | ||
|
|
70c1cef829 | ||
|
|
753399fdc7 | ||
|
|
0a463042e5 | ||
|
|
30e5ad14ae | ||
|
|
1b7ffa00bf | ||
|
|
f606d14b6d | ||
|
|
644a9ee978 | ||
|
|
0b88b6e144 | ||
|
|
99434be7c4 | ||
|
|
68c8ce6010 | ||
|
|
9fe0c6f364 | ||
|
|
3a4d516c24 | ||
|
|
a724993861 | ||
|
|
38f0266ecf | ||
|
|
7a539ef071 | ||
|
|
c4c9fac34a | ||
|
|
49a125ebd6 | ||
|
|
649c5cfe0c | ||
|
|
beb3abb7f3 | ||
|
|
32aa5113b5 | ||
|
|
ff7bb22903 | ||
|
|
c117f1eb60 | ||
|
|
1b1e20bee7 | ||
|
|
d5f143c4cc | ||
|
|
9e3499707c | ||
|
|
1b279acca8 | ||
|
|
831813fd81 | ||
|
|
44e91d4d9d | ||
|
|
7df332b2dc | ||
|
|
50a565f11d | ||
|
|
430872629d | ||
|
|
79650fbcb9 | ||
|
|
7fb56cd467 | ||
|
|
a524d9083f | ||
|
|
e7d190adf4 | ||
|
|
f5e32fb333 | ||
|
|
3d1ba53339 | ||
|
|
d0857dd009 | ||
|
|
4567ce5496 | ||
|
|
37f99a7fa2 | ||
|
|
4feff15973 | ||
|
|
25d7f4149e | ||
|
|
aa081f0080 | ||
|
|
278da5520a | ||
|
|
eba09158c3 | ||
|
|
eaf0265866 | ||
|
|
42ca74cbb0 | ||
|
|
64eeacb829 | ||
|
|
3eea52f5f3 | ||
|
|
3c0087da97 | ||
|
|
bb86f57628 | ||
|
|
57c93d37c2 | ||
|
|
5326351378 | ||
|
|
52e69cf25b | ||
|
|
3a214db461 | ||
|
|
54d82af9ff | ||
|
|
23b02079d3 | ||
|
|
2f6192a6e5 | ||
|
|
3f0df0a5c9 | ||
|
|
7f3543e802 | ||
|
|
017e68b79c | ||
|
|
1e968d6ab1 | ||
|
|
20e9b8e94f | ||
|
|
e71ae2e532 | ||
|
|
45ade381de | ||
|
|
30c18fd1ea | ||
|
|
65d16da98b | ||
|
|
1e6a090810 | ||
|
|
f402dd9692 | ||
|
|
f83bf524a8 | ||
|
|
ad2c8fc08e | ||
|
|
492cf00064 | ||
|
|
3cb205a548 | ||
|
|
e29cfabfe9 | ||
|
|
0b59dd9e2a | ||
|
|
ee17b00288 | ||
|
|
728db354f9 | ||
|
|
1df99748ef | ||
|
|
452b23cc39 | ||
|
|
773a8d6a63 | ||
|
|
a2f836bb66 | ||
|
|
1aacc2b45f | ||
|
|
9562e70450 | ||
|
|
7fece371ad | ||
|
|
94a6c44012 | ||
|
|
b4775d52ed | ||
|
|
37427304fd | ||
|
|
47edebde38 | ||
|
|
1ce514972b | ||
|
|
6b36468d19 | ||
|
|
35e9301a6d | ||
|
|
d933e88f64 | ||
|
|
7549a547de | ||
|
|
51e02f9591 | ||
|
|
2d6184ccfc | ||
|
|
4752d2741e | ||
|
|
ae947a5ca4 | ||
|
|
6ab0506c9a | ||
|
|
0faa786b2e | ||
|
|
824be9278c | ||
|
|
aa00ad74b2 | ||
|
|
c1e2b2dee5 | ||
|
|
229ff7c38b | ||
|
|
e78b0fb447 | ||
|
|
956cfa5d7b | ||
|
|
70abde93de | ||
|
|
69b368e111 | ||
|
|
3019c540a1 | ||
|
|
eef9e38065 | ||
|
|
422d432712 | ||
|
|
74e117191e | ||
|
|
7e6162815f | ||
|
|
984d0fe93c | ||
|
|
4bb1071e1a | ||
|
|
2769d9389a | ||
|
|
6417c93517 | ||
|
|
4f0b0b9116 | ||
|
|
39745e49e7 | ||
|
|
cfb25da11f | ||
|
|
b57414a759 | ||
|
|
e884640785 | ||
|
|
351905fc48 | ||
|
|
648d3f5292 | ||
|
|
845a6b2f68 | ||
|
|
ebe6c2bca7 | ||
|
|
769430b8f0 | ||
|
|
393c9b4072 | ||
|
|
ab3d19d29e | ||
|
|
e94220a906 | ||
|
|
c568af347c | ||
|
|
5c1b4ba796 | ||
|
|
e13ad5ff26 | ||
|
|
5166231481 | ||
|
|
25300cc0e9 | ||
|
|
b637679083 | ||
|
|
c928224b55 | ||
|
|
83378f60c3 | ||
|
|
237b26ae79 | ||
|
|
e393a6db27 | ||
|
|
b502872e00 | ||
|
|
df45b5543b | ||
|
|
9f86064b81 | ||
|
|
73da2a1d14 | ||
|
|
26683f5c61 | ||
|
|
56572a09ef | ||
|
|
fc8601dffc | ||
|
|
faf77cbce5 | ||
|
|
7b58b8c328 | ||
|
|
30b66dcd27 | ||
|
|
26e0dab381 | ||
|
|
93bb169c6c | ||
|
|
4e03fb3894 | ||
|
|
4d9d895b57 | ||
|
|
9fae39b45f | ||
|
|
e2cce3957e | ||
|
|
6bdde0e59a | ||
|
|
1e5a2583df | ||
|
|
b5c3d07ab3 | ||
|
|
705d942124 | ||
|
|
40a68482fe | ||
|
|
4d27d9c0a9 | ||
|
|
955cf86f05 | ||
|
|
b1dd34e18c | ||
|
|
ac695b7444 | ||
|
|
9587af3e9d | ||
|
|
2ea5eaca4c | ||
|
|
a92e749c9f | ||
|
|
8a988a9e84 | ||
|
|
8d1864d0cf | ||
|
|
4015763df6 | ||
|
|
f720c186c3 | ||
|
|
75949fb5ca | ||
|
|
033bc352f4 | ||
|
|
9e8c3f2192 | ||
|
|
39cb69737c | ||
|
|
106d02f4ee | ||
|
|
6fbfd0c6ce | ||
|
|
962f9413bf | ||
|
|
092704a1e1 | ||
|
|
69f0edec74 | ||
|
|
ae7247b008 | ||
|
|
08706b4813 | ||
|
|
a9b587b1cd | ||
|
|
5b806394b6 | ||
|
|
5170f029b2 | ||
|
|
999ec8202e | ||
|
|
658371336e | ||
|
|
447c2f9d52 | ||
|
|
c7dafff817 | ||
|
|
d238c8a7fb | ||
|
|
88b49880e1 | ||
|
|
6cf396f0d4 | ||
|
|
ac9aedecec | ||
|
|
b535fe2926 | ||
|
|
c8fba79f9f | ||
|
|
8f941939e2 | ||
|
|
75d3236fa7 | ||
|
|
6a3903afbe | ||
|
|
aeb9ea9871 | ||
|
|
7712e694b1 | ||
|
|
04ff966d63 | ||
|
|
a99032ccf4 | ||
|
|
953b5c637e | ||
|
|
2f4aef8fb2 | ||
|
|
53cfb1196d | ||
|
|
c7555938a5 | ||
|
|
cf1e7013f4 | ||
|
|
8258843ae1 | ||
|
|
67baae4441 | ||
|
|
a5509797bc | ||
|
|
3ff2d58a25 | ||
|
|
e7e02837e6 | ||
|
|
eaed9886cf | ||
|
|
cb9c6fc8f6 | ||
|
|
b4136568e5 | ||
|
|
8bb465f1e7 | ||
|
|
5511c063d6 | ||
|
|
0e1f66e0e3 | ||
|
|
2c71d2b57e | ||
|
|
a61c4b932c | ||
|
|
8b9d6b2f22 | ||
|
|
87f03c7c17 | ||
|
|
6ca77290ec | ||
|
|
2ffcb50397 | ||
|
|
55d038e801 | ||
|
|
47066401d0 | ||
|
|
3eb7aa3809 | ||
|
|
1cb345c99f | ||
|
|
870b04a390 | ||
|
|
ec14112d82 | ||
|
|
b20373d59b | ||
|
|
9745b34290 | ||
|
|
b589077669 | ||
|
|
56d0517a47 | ||
|
|
ebaf8c6ccf | ||
|
|
029c54dc2b | ||
|
|
4ab8d0cb35 | ||
|
|
ab0abea781 | ||
|
|
fadbd7629d | ||
|
|
cf2267e196 | ||
|
|
77c4819e98 | ||
|
|
76d58fbbc8 | ||
|
|
7ec2ffc6af | ||
|
|
c848d4fd3b | ||
|
|
e3d43e754d | ||
|
|
bcb55a0e4c | ||
|
|
a9fbec2934 | ||
|
|
140e923982 | ||
|
|
680cf56746 | ||
|
|
7162aa65f4 | ||
|
|
a6e16a4e71 | ||
|
|
93b143a647 | ||
|
|
78aa439660 | ||
|
|
a3fd1a0ac6 | ||
|
|
302b253e9a | ||
|
|
7469b5dd96 | ||
|
|
e4ce10f180 | ||
|
|
2ecff7c12f | ||
|
|
5849a4a93f | ||
|
|
999a2ee86e | ||
|
|
eac4e49ceb | ||
|
|
5c9c34f1d2 | ||
|
|
0302a62af5 | ||
|
|
11774de541 | ||
|
|
90382c5889 | ||
|
|
ce841a3c4f | ||
|
|
d5ee0ef158 | ||
|
|
d06a4b155d | ||
|
|
3ddb48b647 | ||
|
|
957484588e | ||
|
|
cf22541dd5 | ||
|
|
61338bbb0c | ||
|
|
e92297ccaf | ||
|
|
e5caabd104 | ||
|
|
1db620124a | ||
|
|
7fe9c02bff | ||
|
|
890b8df374 | ||
|
|
981ecb91c9 | ||
|
|
39921730b3 | ||
|
|
641ebef687 | ||
|
|
9364edbb11 | ||
|
|
efb3989ee6 | ||
|
|
37df675ca3 | ||
|
|
8c92889fa1 | ||
|
|
788ebbcdab | ||
|
|
ce35d6448e | ||
|
|
a1bc147849 | ||
|
|
e0e6512974 | ||
|
|
667d5a2a8e | ||
|
|
bb56ab939d | ||
|
|
365376f7f0 | ||
|
|
c4af121ce4 | ||
|
|
fa99fbe2d9 |
No files matched your search
@@ -1,6 +1,4 @@
|
||||
# built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# files for the dex VM
|
||||
*.dex
|
||||
@@ -31,4 +29,4 @@ tests/proguard-project.txt
|
||||
.gradle
|
||||
.idea
|
||||
*.iml
|
||||
build
|
||||
build
|
||||
@@ -1,22 +1,25 @@
|
||||
sudo: false
|
||||
language: android
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
android:
|
||||
components:
|
||||
# first 'tools' updates SDK tools 'til last version ** in remote repository number 10 **
|
||||
- tools
|
||||
# second 'tools' updates SDK tools 'til last version ** in remote repository number 11 ** (current last one)
|
||||
- tools
|
||||
- tools # to get the new `repository-11.xml`
|
||||
- platform-tools
|
||||
- build-tools-23.0.3
|
||||
- android-23
|
||||
- tools # to install Android SDK tools 25.1.x (x = 7 right now)
|
||||
- build-tools-24.0.2
|
||||
- android-$EMULATOR_TARGET
|
||||
# - android-$ANDROID_API_LEVEL
|
||||
- extra-android-m2repository
|
||||
- sys-img-armeabi-v7a-android-23
|
||||
- sys-img-armeabi-v7a-android-$EMULATOR_TARGET
|
||||
before_install:
|
||||
- echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI -c 20M
|
||||
- echo no | android create avd --force -n test -t "android-"$EMULATOR_TARGET --abi $ANDROID_ABI -c 20M
|
||||
- emulator -avd test -no-skin -no-audio -no-window &
|
||||
- chmod +x ./wait_for_emulator.sh
|
||||
- ./wait_for_emulator.sh
|
||||
script:
|
||||
# force init of adb way before any Gradle task that uses ADB; prevents a timeout error that skips emulators of android-24
|
||||
- adb devices
|
||||
# build app and assemble APK, in debug mode
|
||||
- ./gradlew assembleDebug
|
||||
# run all the local unit tests of app module
|
||||
@@ -27,11 +30,11 @@ script:
|
||||
- ./gradlew :installDebug
|
||||
- ./gradlew :installDebugAndroidTest
|
||||
# run sample instrumented unit test
|
||||
- adb shell am instrument -w -e debug false -e class com.owncloud.android.datamodel.OCFileUnitTest com.owncloud.android.test/android.support.test.runner.AndroidJUnitRunner
|
||||
# - adb shell am instrument -w -e debug false -e class com.owncloud.android.datamodel.OCFileUnitTest com.owncloud.android.test/android.support.test.runner.AndroidJUnitRunner
|
||||
env:
|
||||
global:
|
||||
- secure: h4Y7ZvgbvOj5T71ubRcw3Fy3KXF8qHugRFLGK3q2R9YuRsDAf8XH+Y/UiXyH8sac2QSj7Zlny1kA1DEJgwhTXs9wsAVKVJCQNTJGEvhm/4uQgPeNMzMv07Lqe8V+KUBsFH5qhfPJO357ERW0k2f2qljoLSHtHStclt7iGvFdynA=
|
||||
- secure: o9L6lXWpXowhQSdiUSmajliBUkQ6n7NrBUqhC09lqe7yXSGhEsgGRXqHoT3q2B4uIqGSiLCa9HQbW0dfDQCs+pADmzHIl3zbTViR88TSaIhOiTrqMUUl5iaO++pneZ2TzgU9bbGHbl6Ixjc6iALH2+F7P+RUM6vLTNPcfnCJa3g=
|
||||
- secure: ydxZrS7+1ht3p1tC6DE9W9bjLQGjMkwFBwyhNmcdEM6538kN8ZCBQe7NxSsCrC1nSDBLQ17Cziv0XJHl/pCfPrbkrPPgVFpjDfPeqC2zcGcCNcFQUEylXCvQ4uRU2hKL6dPqCsOQ57Pv3qwpPoprl/usoN5Wh8V7BKplU88ZaYM=
|
||||
matrix:
|
||||
- ANDROID_TARGET=android-23 ANDROID_ABI=armeabi-v7a
|
||||
- ANDROID_API_LEVEL=24 ANDROID_ABI=armeabi-v7a EMULATOR_TARGET=24
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
ownCloud Android client application
|
||||
Nextcloud Android client application
|
||||
|
||||
Copyright (C) 2012 Bartek Przybylski
|
||||
Copyright (C) 2012-2016 ownCloud Inc.
|
||||
@@ -20,12 +20,12 @@
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.owncloud.android"
|
||||
android:versionCode="10020099"
|
||||
android:versionName="1.2.0">
|
||||
android:versionCode="20160903"
|
||||
android:versionName="20160903" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="23" />
|
||||
android:targetSdkVersion="24" />
|
||||
|
||||
<!-- GET_ACCOUNTS is needed for API < 23.
|
||||
For API >= 23 results in the addition of CONTACTS group to the list of permissions that may be
|
||||
@@ -44,6 +44,7 @@
|
||||
<!-- WRITE_EXTERNAL_STORAGE may be enabled or disabled by the user after installation in
|
||||
API >= 23; the app needs to handle this -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
|
||||
|
||||
<!-- Next permissions are always approved in installation time,
|
||||
the apps needs to do nothing special in runtime -->
|
||||
@@ -56,15 +57,18 @@
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:name=".MainApp"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:label="Nextcloud beta"
|
||||
android:theme="@style/Theme.ownCloud.Toolbar"
|
||||
android:manageSpaceActivity="com.owncloud.android.ui.activity.ManageSpaceActivity">
|
||||
<activity
|
||||
android:name=".ui.activity.FileDisplayActivity"
|
||||
android:label="@string/app_name"
|
||||
android:label="Nextcloud beta"
|
||||
android:theme="@style/Theme.ownCloud.Toolbar.Drawer">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -77,7 +81,10 @@
|
||||
<activity android:name=".ui.activity.ReceiveExternalFilesActivity"
|
||||
android:taskAffinity=""
|
||||
android:excludeFromRecents="true"
|
||||
android:label="Nextcloud beta"
|
||||
android:theme="@style/Theme.ownCloud.NoActionBar">
|
||||
<activity android:name=".ui.activity.LocalDirectorySelectorActivity" />
|
||||
<activity android:name=".ui.activity.StorageMigrationActivity" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
|
||||
@@ -102,7 +109,7 @@
|
||||
android:theme="@style/Theme.ownCloud.Overlay" />
|
||||
<activity
|
||||
android:name=".ui.preview.PreviewVideoActivity"
|
||||
android:label="@string/app_name"
|
||||
android:label="Nextcloud beta"
|
||||
android:theme="@style/Theme.ownCloud.Fullscreen" />
|
||||
|
||||
<service
|
||||
@@ -137,8 +144,8 @@
|
||||
android:syncable="true" />
|
||||
|
||||
<provider
|
||||
android:name=".providers.UsersAndGroupsSearchProvider"
|
||||
android:authorities="com.nextcloud.android.providers.UsersAndGroupsSearchProvider"
|
||||
android:name="org.nextcloud.providers.UsersAndGroupsSearchProvider"
|
||||
android:authorities="org.nextcloud.beta.android.providers.UsersAndGroupsSearchProvider"
|
||||
android:enabled="true"
|
||||
android:exported="false"
|
||||
android:label="@string/search_users_and_groups_hint" />
|
||||
@@ -155,6 +162,23 @@
|
||||
</intent-filter>
|
||||
</provider>
|
||||
|
||||
<provider
|
||||
android:name=".ui.adapter.DiskLruImageCacheFileProvider"
|
||||
android:authorities="@string/authorityCache"
|
||||
android:exported="true">
|
||||
</provider>
|
||||
|
||||
<!-- new provider used to generate URIs without file:// scheme (forbidden from Android 7) -->
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="@string/file_provider_authority"
|
||||
android:grantUriPermissions="true"
|
||||
android:exported="false">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/exposed_filepaths" />
|
||||
</provider>
|
||||
|
||||
<activity
|
||||
android:name=".authentication.AuthenticatorActivity"
|
||||
android:exported="true"
|
||||
@@ -184,17 +208,20 @@
|
||||
<activity android:name=".ui.activity.ConflictsResolveActivity"/>
|
||||
<activity android:name=".ui.activity.GenericExplanationActivity"/>
|
||||
<activity android:name=".ui.activity.ErrorsWhileCopyingHandlerActivity"/>
|
||||
|
||||
|
||||
<activity android:name=".ui.activity.LogHistoryActivity"/>
|
||||
<activity android:name=".ui.activity.ErrorReportActivity"/>
|
||||
|
||||
<activity android:name=".ui.errorhandling.ErrorShowActivity" />
|
||||
<activity android:name=".ui.activity.UploadListActivity" />
|
||||
|
||||
|
||||
<receiver android:name=".files.services.ConnectivityActionReceiver"
|
||||
android:enabled="true" android:label="ConnectivityActionReceiver">
|
||||
<intent-filter>
|
||||
<!--action android:name="android.net.conn.CONNECTIVITY_CHANGE"/-->
|
||||
<action android:name="android.net.wifi.STATE_CHANGE"/>
|
||||
<action android:name="android.intent.action.ACTION_POWER_CONNECTED"/>
|
||||
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".files.InstantUploadBroadcastReceiver">
|
||||
@@ -224,16 +251,16 @@
|
||||
<activity
|
||||
android:name=".ui.activity.CopyToClipboardActivity"
|
||||
android:icon="@drawable/copy_link"
|
||||
android:label="@string/copy_link" />
|
||||
android:label="Copy link" />
|
||||
<activity
|
||||
android:name=".ui.activity.FolderPickerActivity"
|
||||
android:label="@string/app_name" />
|
||||
android:label="Nextcloud beta" />
|
||||
<activity
|
||||
android:name=".ui.activity.UploadPathActivity"
|
||||
android:label="@string/app_name" />
|
||||
android:label="Nextcloud beta" />
|
||||
<activity
|
||||
android:name=".ui.activity.ShareActivity"
|
||||
android:label="@string/share_dialog_title"
|
||||
android:label="Sharing"
|
||||
android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="adjustResize" >
|
||||
@@ -244,7 +271,7 @@
|
||||
android:resource="@xml/users_and_groups_searchable"/>
|
||||
</activity>
|
||||
<activity android:name=".ui.activity.ManageSpaceActivity"
|
||||
android:label="@string/manage_space_title"
|
||||
android:label="Manage space"
|
||||
android:theme="@style/Theme.ownCloud" />
|
||||
</application>
|
||||
|
||||
|
||||
@@ -1,32 +1,38 @@
|
||||
## 1.2.0 (July 29, 2016)
|
||||
## 2016-09-05
|
||||
- Display quota if configured/available in navigation drawer #204
|
||||
- bugfix for empty folder display #229
|
||||
- Update Toolchain/Android-Target to v24 #214
|
||||
- Restore display of remote folder size #235
|
||||
|
||||
- Multi select capabilities
|
||||
- confirmation dialog on account removal
|
||||
- offline available filter in main menu
|
||||
- sorting capability when choosing files to be uploaded
|
||||
- video thumbnails if activated on server
|
||||
- thumbnails during upload
|
||||
- fixed user agent for file firewalling
|
||||
- showing server side folder sizes
|
||||
- text in test preview can now be selected
|
||||
- search suggestions fixed for user/group search during sharing
|
||||
- minor bugfixes
|
||||
## 2016-08-08
|
||||
- update all PR
|
||||
- search for the right ocShare with public link #197
|
||||
- Fix comparator determining order of list of uploads #199
|
||||
- generate thumbnails only if mCurrentUpload is not null #205
|
||||
|
||||
## 1.1.0 (July 6, 2016)
|
||||
## 2016-07-31
|
||||
- External SD support #92
|
||||
- move / copy updated #178
|
||||
- prevents NPE when selecting empty local folder #180
|
||||
|
||||
- New main menu to switch accounts easily
|
||||
- Ability to open Nextcloud hosted files (read-only) from other apps that support the standard file chooser (requires Android 4.4 / KitKat or higher)
|
||||
- "Select all files" for upload within a folder
|
||||
- Optional feature to auto-create monthly folders for your instant uploads
|
||||
- Revamped login screen
|
||||
- Minor bugfixes
|
||||
## 2016-07-30
|
||||
- Upload when charging #171
|
||||
|
||||
## 1.0.1 (June 20, 2016)
|
||||
## 2016-07-28
|
||||
Fresh start on current master with these PRs:
|
||||
- Resized images #69
|
||||
- Instant upload in the context of multi account support #98
|
||||
- mix folders and files on sort by date #135
|
||||
- Files drop #141
|
||||
- Receive text file #142
|
||||
- Pinch zoom #143
|
||||
- Resize cache #144
|
||||
- filter for oc file list and local file list #152
|
||||
- djvu is not an image #153
|
||||
- delay instant upload when metered wifi is used #161
|
||||
- rename instant upload path #162
|
||||
- Refresh when app starts #166
|
||||
- Disable suggestions in password field #167
|
||||
- resume chunked uploads #168
|
||||
|
||||
- Fix thumbnail preview support for new files
|
||||
- Add support for animated GIFs
|
||||
- Optimized uploader layout
|
||||
|
||||
## 1.0.0 (June 12, 2016)
|
||||
|
||||
- initial release of the Nextcloud Android app
|
||||
From now on every new PR with "3. to review" will be merged to beta and published
|
||||
@@ -16,8 +16,8 @@ The [Android SDK][3] is necessary to build the app. There are different options
|
||||
Open a terminal and type 'android' to start the Android SDK Manager. To build the Nextcloud for Android app you will need to install at least the next SDK packages:
|
||||
|
||||
* Android SDK Tools and Android SDK Platform-tools (already installed); upgrade to their last versions is usually a good idea.
|
||||
* Android SDK Build-Tools; any version from 23 or later should work fine; avoid preview versions, if any available.
|
||||
* Android 6.0 (API 23), SDK Platform; needed to build the nextcloud app.
|
||||
* Android SDK Build-Tools 24.0.2.
|
||||
* Android 7.0 (API 24), SDK Platform; needed to build the nextcloud app.
|
||||
|
||||
Install any other package you consider interesting, such as emulators.
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
20160903
|
||||
@@ -17,7 +17,12 @@ buildscript {
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
ext {
|
||||
supportLibraryVersion = '23.4.0'
|
||||
supportLibraryVersion = '24.2.0'
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
// allows for -Dpre-dex=false to be set
|
||||
preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -33,7 +38,7 @@ dependencies {
|
||||
/// dependencies for app building
|
||||
compile name: 'touch-image-view'
|
||||
|
||||
compile 'com.github.nextcloud:android-library:1.0.6'
|
||||
compile 'com.github.nextcloud:android-library:beta-SNAPSHOT'
|
||||
compile "com.android.support:support-v4:${supportLibraryVersion}"
|
||||
compile "com.android.support:design:${supportLibraryVersion}"
|
||||
compile 'com.jakewharton:disklrucache:2.0.2'
|
||||
@@ -73,8 +78,8 @@ tasks.withType(Test) {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.3"
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion "24.0.2"
|
||||
|
||||
defaultConfig {
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
@@ -84,7 +89,9 @@ android {
|
||||
testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
|
||||
testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
|
||||
|
||||
applicationId "com.nextcloud.client"
|
||||
applicationId "com.nextcloud.android.beta"
|
||||
versionCode 20160903
|
||||
versionName "20160903"
|
||||
}
|
||||
|
||||
// adapt structure from Eclipse to Gradle/Android Studio expectations;
|
||||
@@ -118,6 +125,11 @@ android {
|
||||
release.setRoot('build-types/release')
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
|
||||
preDexLibraries = preDexEnabled && !travisBuild
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
@@ -130,5 +142,20 @@ android {
|
||||
packagingOptions {
|
||||
exclude 'META-INF/LICENSE.txt'
|
||||
}
|
||||
signingConfigs {
|
||||
release
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('RELEASE_STORE_FILE')) {
|
||||
android.signingConfigs.release.storeFile = file(RELEASE_STORE_FILE)
|
||||
android.signingConfigs.release.storePassword = RELEASE_STORE_PASSWORD
|
||||
android.signingConfigs.release.keyAlias = RELEASE_KEY_ALIAS
|
||||
android.signingConfigs.release.keyPassword = RELEASE_KEY_PASSWORD
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#Tue Aug 16 10:44:46 CEST 2016
|
||||
#Sat Sep 03 07:48:32 CEST 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -8,13 +8,20 @@ buildscript {
|
||||
}
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
ext {
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
// allows for -Dpre-dex=false to be set
|
||||
preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: '*.jar')
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.3"
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion "24.0.2"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
@@ -39,4 +46,14 @@ android {
|
||||
debug.setRoot('build-types/debug')
|
||||
release.setRoot('build-types/release')
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
|
||||
preDexLibraries = preDexEnabled && !travisBuild
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
ownCloud Android client application
|
||||
|
||||
Copyright (C) 2015 ownCloud Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:weightSum="1" >
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="@dimen/standard_margin"
|
||||
android:layout_weight="1">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingRight="@dimen/standard_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/logTV"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/empty"
|
||||
android:typeface="monospace"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/historyButtonBar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="@dimen/standard_margin"
|
||||
android:layout_marginLeft="@dimen/standard_margin"
|
||||
android:layout_marginRight="@dimen/standard_margin">
|
||||
|
||||
<Button
|
||||
android:id="@+id/cancelErrorLogButton"
|
||||
android:theme="@style/Button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/error_log_exit" />
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/sendErrorLogButton"
|
||||
android:theme="@style/Button.Primary"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/error_log_send" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Nextcloud Android client application
|
||||
|
||||
Copyright (C) 2016 Bartosz Przybylski
|
||||
Copyright (C) 2016 Nextcloud
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public
|
||||
License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/migrationProgress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:paddingLeft="30dp"
|
||||
android:paddingRight="30dp"
|
||||
android:progress="50"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/migrationText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/finishButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/drawer_close"/>
|
||||
</LinearLayout>
|
||||
@@ -190,6 +190,40 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/shareViaLinkHideListPermissionSection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
android:layout_marginBottom="@dimen/standard_half_margin"
|
||||
>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/shareViaLinkHideListPermissionSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:padding="@dimen/standard_half_padding"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/shareViaLinkHideListPermissionLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toLeftOf="@id/shareViaLinkHideListPermissionSwitch"
|
||||
android:layout_toStartOf="@id/shareViaLinkHideListPermissionSwitch"
|
||||
android:padding="@dimen/standard_half_padding"
|
||||
android:text="@string/share_via_link_hide_file_listing_permission_label"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/shareViaLinkPasswordSection"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -53,29 +53,11 @@
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_radio_group"
|
||||
android:layout_width="fill_parent"
|
||||
<Spinner
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/upload_copy_files"
|
||||
android:id="@+id/upload_radio_copy"
|
||||
android:paddingRight="8dp"
|
||||
android:checked="false" />
|
||||
|
||||
<RadioButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/upload_move_files"
|
||||
android:id="@+id/upload_radio_move"
|
||||
android:paddingRight="8dp"
|
||||
android:checked="false" />
|
||||
</RadioGroup>
|
||||
android:id="@+id/upload_files_spinner_behaviour"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 8.0 KiB |
@@ -1,10 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<!--TODO re-enable when server-side folder size calculation is available
|
||||
<item>Biggest - Smallest</item>-->
|
||||
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
|
||||
<!--<string name="drawer_item_accounts">Accounts</string>-->
|
||||
<!--TODO re-enable when "On Device" is available
|
||||
<string name="drawer_item_on_device">On device</string>-->
|
||||
<string name="empty"></string>
|
||||
</resources>
|
||||
@@ -14,10 +14,18 @@
|
||||
<string-array name="pref_behaviour_entries">
|
||||
<item>@string/pref_behaviour_entries_keep_file</item>
|
||||
<item>@string/pref_behaviour_entries_move</item>
|
||||
<item>@string/pref_behaviour_entries_delete_file</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_behaviour_entryValues">
|
||||
<item>NOTHING</item>
|
||||
<item>MOVE</item>
|
||||
<item>DELETE</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="upload_files_behaviour">
|
||||
<item>move to nextcloud folder</item>
|
||||
<item>only upload</item>
|
||||
<item>upload and delete from source</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -1,23 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- App name and other strings-->
|
||||
<string name="app_name">Nextcloud</string>
|
||||
<string name="account_type">nextcloud</string> <!-- better if was a domain name; but changing it now would require
|
||||
<string name="app_name">Nextcloud beta</string>
|
||||
<string name="account_type">nextcloud.beta</string> <!-- better if was a domain name; but changing it now would require
|
||||
migrate accounts when the app is updated -->
|
||||
<string name="authority">org.nextcloud</string> <!-- better if was the app package with ".provider" appended ; it identifies the provider -->
|
||||
<string name="document_provider_authority">org.nextcloud.documents</string>
|
||||
<string name="authority">org.nextcloud.beta.provider</string> <!-- better if was the app package with ".provider" appended ; it identifies the provider -->
|
||||
<string name="authorityCache">org.nextcloud.beta.imageCache.provider</string>
|
||||
<string name="authoritySearch">org.nextcloud.beta.android.providers.UsersAndGroupsSearchProvider</string>
|
||||
<string name="document_provider_authority">org.nextcloud.beta.documents</string>
|
||||
<string name="file_provider_authority">org.nextcloud.beta.files</string>
|
||||
<string name ="db_file">nextcloud.db</string>
|
||||
<string name ="db_name">nextcloud</string>
|
||||
<string name ="data_folder">nextcloud</string>
|
||||
<string name ="log_name">nextcloud</string>
|
||||
<string name ="default_display_name_for_root_folder">Nextcloud</string>
|
||||
<string name ="user_agent">Mozilla/5.0 (Android) ownCloud-android/%1$s</string>
|
||||
<string name ="user_agent">Mozilla/5.0 (Android) nextcloud-android/%1$s</string>
|
||||
|
||||
<!-- URLs and flags related -->
|
||||
<string name="server_url"></string>
|
||||
<bool name="show_server_url_input">true</bool>
|
||||
<bool name="show_welcome_link">true</bool>
|
||||
<string name="welcome_link_url">"https://nextcloud.com"</string>
|
||||
<string name="welcome_link_url">"https://nextcloud.com/mobile/new"</string>
|
||||
<string name="share_api_link"></string>
|
||||
|
||||
<!-- Flags to setup the authentication methods available in the app -->
|
||||
@@ -60,8 +63,10 @@
|
||||
<bool name="imprint_enabled">false</bool>
|
||||
<bool name="recommend_enabled">true</bool>
|
||||
<bool name="feedback_enabled">true</bool>
|
||||
<bool name="logger_enabled">false</bool>
|
||||
<bool name="logger_enabled">true</bool>
|
||||
<string name="url_help">https://help.nextcloud.com/c/feature</string>
|
||||
<string name="beta_link">https://github.com/nextcloud/android/raw/beta/apks/nextcloud-beta-</string>
|
||||
<string name="beta_latest">https://github.com/nextcloud/android/raw/beta/apks/latest</string>
|
||||
<string name="url_imprint"></string>
|
||||
<string name="mail_recommend">"mailto:"</string>
|
||||
<string name="mail_feedback">"mailto:[email protected]"</string>
|
||||
|
||||
@@ -295,6 +295,8 @@
|
||||
|
||||
<string name="instant_upload_on_wifi">Upload pictures via wifi only</string>
|
||||
<string name="instant_video_upload_on_wifi">Upload videos via wifi only</string>
|
||||
<string name="instant_video_upload_on_charging">Upload when charging only</string>
|
||||
<string name="instant_upload_on_charging">Upload when charging only</string>
|
||||
<string name="instant_upload_path">/InstantUpload</string>
|
||||
<string name="conflict_title">File conflict</string>
|
||||
<string name="conflict_message">Which files do you want to keep? If you select both versions, the local file will have a number added to its name.</string>
|
||||
@@ -305,8 +307,14 @@
|
||||
<string name="preview_image_description">Image preview</string>
|
||||
<string name="preview_image_error_unknown_format">This image cannot be shown</string>
|
||||
|
||||
<string name="error_log_exit">Exit</string>
|
||||
<string name="error_log_send">Send Log</string>
|
||||
<string name="error_log_title">Error Log</string>
|
||||
|
||||
<string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local folder</string>
|
||||
<string name="prefs_instant_upload_path_title">Instant upload folder</string>
|
||||
<string name="prefs_instant_upload_account">Account</string>
|
||||
<string name="prefs_instant_upload_path">Path</string>
|
||||
<string name="prefs_instant_upload_path_use_subfolders_title">Use subfolders</string>
|
||||
<string name="prefs_instant_upload_path_use_subfolders_summary">Store in subfolders based on year and month</string>
|
||||
|
||||
@@ -347,6 +355,28 @@
|
||||
<string name="uploader_upload_forbidden_permissions">to upload in this folder</string>
|
||||
<string name="downloader_download_file_not_found">The file is no longer available on the server</string>
|
||||
|
||||
<string name="file_migration_dialog_title">Updating storage path</string>
|
||||
<string name="file_migration_finish_button">Finish</string>
|
||||
<string name="file_migration_preparing">Preparing for migration…</string>
|
||||
<string name="file_migration_checking_destination">Checking destination…</string>
|
||||
<string name="file_migration_saving_accounts_configuration">Saving accounts configuration…</string>
|
||||
<string name="file_migration_waiting_for_unfinished_sync">Waiting for unfinished synchronizations…</string>
|
||||
<string name="file_migration_migrating">Moving data…</string>
|
||||
<string name="file_migration_updating_index">Updating index…</string>
|
||||
<string name="file_migration_cleaning">Cleaning…</string>
|
||||
<string name="file_migration_restoring_accounts_configuration">Restoring accounts configuration…</string>
|
||||
<string name="file_migration_ok_finished">Finished</string>
|
||||
<string name="file_migration_failed_not_enough_space">ERROR: Not enough space</string>
|
||||
<string name="file_migration_failed_not_writable">ERROR: File is not writable</string>
|
||||
<string name="file_migration_failed_not_readable">ERROR: File is not readable</string>
|
||||
<string name="file_migration_failed_dir_already_exists">ERROR: Nextcloud directory already exists</string>
|
||||
<string name="file_migration_failed_while_coping">ERROR: While migrating</string>
|
||||
<string name="file_migration_failed_while_updating_index">ERROR: While updating index</string>
|
||||
|
||||
<string name="file_migration_directory_already_exists">Data folder already exists, what to do?</string>
|
||||
<string name="file_migration_override_data_folder">Override</string>
|
||||
<string name="file_migration_use_data_folder">Use existing</string>
|
||||
|
||||
<string name="prefs_category_accounts">Accounts</string>
|
||||
<string name="prefs_add_account">Add account</string>
|
||||
<string name="drawer_manage_accounts">Manage accounts</string>
|
||||
@@ -403,14 +433,19 @@
|
||||
<string name="file_list__footer__files">%1$d files</string>
|
||||
<string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
|
||||
<string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
|
||||
<string name="prefs_instant_behaviour_dialogTitle">Original file will be...</string>
|
||||
<string name="prefs_instant_behaviour_title">Original file will be...</string>
|
||||
<string name="prefs_instant_behaviour_dialogTitle">Original file will be…</string>
|
||||
<string name="prefs_instant_behaviour_title">Original file will be…</string>
|
||||
<string name="upload_copy_files">Copy file</string>
|
||||
<string name="upload_move_files">Move file</string>
|
||||
<string name="select_all">Select all</string>
|
||||
|
||||
<string name="pref_behaviour_entries_keep_file">kept in original folder</string>
|
||||
<string name="pref_behaviour_entries_move">moved to app folder</string>
|
||||
<string name="pref_behaviour_entries_delete_file">deleted</string>
|
||||
<string name="prefs_storage_path">Storage path</string>
|
||||
<string name="prefs_common">Common</string>
|
||||
|
||||
<string name="pref_cache_size">Cache size</string>
|
||||
|
||||
<string name="share_dialog_title">Sharing</string>
|
||||
<string name="share_file">Share %1$s</string>
|
||||
@@ -422,6 +457,7 @@
|
||||
<string name="share_via_link_password_label">Password protect</string>
|
||||
<string name="share_via_link_password_title">Secured</string>
|
||||
<string name="share_via_link_edit_permission_label">Allow editing</string>
|
||||
<string name="share_via_link_hide_file_listing_permission_label">Hide file listing</string>
|
||||
<string name="share_get_public_link_button">Get link</string>
|
||||
<string name="share_with_title">Share with …</string>
|
||||
<string name="share_with_edit_title">Share with %1$s</string>
|
||||
@@ -442,6 +478,7 @@
|
||||
<string name="share_privilege_can_edit_delete">delete</string>
|
||||
<string name="edit_share_unshare">Stop sharing</string>
|
||||
<string name="edit_share_done">done</string>
|
||||
<string name="changelog">https://github.com/nextcloud/android/raw/beta/CHANGELOG.md</string>
|
||||
|
||||
<string name="action_retry_uploads">Retry failed</string>
|
||||
<string name="action_clear_failed_uploads">Clear failed</string>
|
||||
@@ -460,6 +497,7 @@
|
||||
<string name="local_file_not_found_toast">The file was not found in the local file system</string>
|
||||
<string name="confirmation_remove_files_alert">Do you really want to remove the selected items?</string>
|
||||
<string name="confirmation_remove_folders_alert">Do you really want to remove the selected items and their contents?</string>
|
||||
<string name="uploads_view_upload_status_waiting_for_charging">Waiting for device charging</string>
|
||||
<string name="actionbar_search">Search</string>
|
||||
<plurals name="items_selected_count">
|
||||
<!--
|
||||
@@ -473,4 +511,9 @@
|
||||
<item quantity="other">%d selected</item>
|
||||
</plurals>
|
||||
|
||||
<string name="storage_description_default">Default</string>
|
||||
<string name="storage_description_sd_no">SD card %1$d</string>
|
||||
<string name="storage_description_unknown">Unknown</string>
|
||||
<string name="prefs_category_beta">Beta</string>
|
||||
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="file" path="/" />
|
||||
<!-- yes, valid for ALL external storage and not only our app folder, since we can't use @string/data_folder
|
||||
as a value for 'path' attribute; in practice, we will only generate URIs in our folders, of course -->
|
||||
</paths>
|
||||
@@ -3,7 +3,7 @@
|
||||
ownCloud Android client application
|
||||
|
||||
Copyright (C) 2012 Bartek Przybylski
|
||||
Copyright (C) 2015 ownCloud Inc.
|
||||
Copyright (C) 2012-2013 ownCloud Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2,
|
||||
@@ -18,12 +18,17 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<PreferenceCategory android:title="@string/prefs_category_general">
|
||||
<ListPreference
|
||||
android:title="@string/prefs_storage_path"
|
||||
android:key="storage_path" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/prefs_category_instant_uploading" android:key="instant_uploading_category">
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading"
|
||||
android:title="@string/prefs_instant_upload"
|
||||
android:summary="@string/prefs_instant_upload_summary"/>
|
||||
<com.owncloud.android.ui.PreferenceWithLongSummary
|
||||
<com.owncloud.android.ui.PreferenceWithTwoLineLongSummary
|
||||
android:title="@string/prefs_instant_upload_path_title"
|
||||
android:key="instant_upload_path" />
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
|
||||
@@ -31,11 +36,15 @@
|
||||
android:summary="@string/prefs_instant_upload_path_use_subfolders_summary"
|
||||
android:key="instant_upload_path_use_subfolders" />
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
|
||||
android:title="@string/instant_upload_on_wifi"
|
||||
android:key="instant_upload_on_wifi"/>
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_video_uploading"
|
||||
android:title="@string/prefs_instant_video_upload"
|
||||
android:summary="@string/prefs_instant_video_upload_summary" />
|
||||
android:title="@string/instant_upload_on_wifi"
|
||||
android:key="instant_upload_on_wifi"/>
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
|
||||
android:title="@string/instant_upload_on_charging"
|
||||
android:key="instant_upload_on_charging"/>
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
|
||||
android:key="instant_video_uploading"
|
||||
android:title="@string/prefs_instant_video_upload"
|
||||
android:summary="@string/prefs_instant_video_upload_summary" />
|
||||
<com.owncloud.android.ui.PreferenceWithLongSummary
|
||||
android:title="@string/prefs_instant_video_upload_path_title"
|
||||
android:key="instant_video_upload_path" />
|
||||
@@ -46,6 +55,9 @@
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
|
||||
android:title="@string/instant_video_upload_on_wifi"
|
||||
android:key="instant_video_upload_on_wifi"/>
|
||||
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
|
||||
android:title="@string/instant_video_upload_on_charging"
|
||||
android:key="instant_video_upload_on_charging"/>
|
||||
<com.owncloud.android.ui.dialog.OwnCloudListPreference android:key="prefs_instant_behaviour"
|
||||
android:dialogTitle="@string/prefs_instant_behaviour_dialogTitle"
|
||||
android:title="@string/prefs_instant_behaviour_title"
|
||||
@@ -66,8 +78,12 @@
|
||||
|
||||
<PreferenceCategory android:title="@string/prefs_category_details">
|
||||
<android.preference.CheckBoxPreference android:title="@string/prefs_passcode" android:key="set_pincode" />
|
||||
|
||||
<EditTextPreference android:title="@string/pref_cache_size"
|
||||
android:key="pref_cache_size"
|
||||
android:digits="0123456789"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
<PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
|
||||
<Preference android:title="@string/prefs_help" android:key="help" />
|
||||
<Preference android:title="@string/prefs_recommend" android:key="recommend" />
|
||||
@@ -76,6 +92,16 @@
|
||||
<Preference android:title="@string/prefs_imprint" android:key="imprint" />
|
||||
<Preference android:title="@string/about_title" android:id="@+id/about_app" android:key="about_app" />
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
<PreferenceCategory android:title="@string/prefs_category_beta" android:key="beta_category">
|
||||
<Preference android:id="@+id/beta_link"
|
||||
android:title="Download latest beta version"
|
||||
android:key="beta_link" />
|
||||
|
||||
<Preference android:id="@+id/changelog_link"
|
||||
android:title="Changelog beta version"
|
||||
android:key="changelog_link" />
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -22,7 +22,7 @@
|
||||
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:label="@string/app_name"
|
||||
android:hint="@string/search_users_and_groups_hint"
|
||||
android:searchSuggestAuthority="com.nextcloud.android.providers.UsersAndGroupsSearchProvider"
|
||||
android:searchSuggestIntentAction="com.nextcloud.android.providers.UsersAndGroupsSearchProvider.action.SHARE_WITH"
|
||||
android:searchSuggestAuthority="org.nextcloud.beta.android.providers.UsersAndGroupsSearchProvider"
|
||||
android:searchSuggestIntentAction="org.nextcloud.beta.android.providers.UsersAndGroupsSearchProvider.action.SHARE_WITH"
|
||||
android:searchSuggestThreshold="1" >
|
||||
</searchable>
|
||||
@@ -23,17 +23,20 @@ package com.owncloud.android;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.owncloud.android.authentication.PassCodeManager;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory.Policy;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import com.owncloud.android.utils.ExceptionHandler;
|
||||
import com.owncloud.android.ui.activity.Preferences;
|
||||
|
||||
/**
|
||||
* Main Application of the project
|
||||
@@ -54,13 +57,24 @@ public class MainApp extends Application {
|
||||
|
||||
private static Context mContext;
|
||||
|
||||
private static String storagePath;
|
||||
|
||||
private static boolean mOnlyOnDevice = false;
|
||||
|
||||
|
||||
public void onCreate(){
|
||||
super.onCreate();
|
||||
MainApp.mContext = getApplicationContext();
|
||||
|
||||
|
||||
// Setup handler for uncaught exceptions.
|
||||
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
|
||||
|
||||
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
MainApp.storagePath = appPrefs.getString(Preferences.Keys.STORAGE_PATH, Environment.
|
||||
getExternalStorageDirectory().getAbsolutePath());
|
||||
|
||||
boolean isSamlAuth = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));
|
||||
|
||||
OwnCloudClientManagerFactory.setUserAgent(getUserAgent());
|
||||
@@ -80,8 +94,7 @@ public class MainApp extends Application {
|
||||
// Set folder for store logs
|
||||
Log_OC.setLogDataFolder(dataFolder);
|
||||
|
||||
//TODO: to be changed/fixed whenever SD card support gets merged.
|
||||
Log_OC.startLogging(Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||
Log_OC.startLogging(MainApp.storagePath);
|
||||
Log_OC.d("Debug", "start logging");
|
||||
}
|
||||
|
||||
@@ -132,7 +145,15 @@ public class MainApp extends Application {
|
||||
return MainApp.mContext;
|
||||
}
|
||||
|
||||
// Methods to obtain Strings referring app_name
|
||||
public static String getStoragePath(){
|
||||
return MainApp.storagePath;
|
||||
}
|
||||
|
||||
public static void setStoragePath(String path){
|
||||
MainApp.storagePath = path;
|
||||
}
|
||||
|
||||
// Methods to obtain Strings referring app_name
|
||||
// From AccountAuthenticator
|
||||
// public static final String ACCOUNT_TYPE = "owncloud";
|
||||
public static String getAccountType() {
|
||||
|
||||
@@ -332,4 +332,28 @@ public class AccountUtils {
|
||||
}
|
||||
return (serverVersion != null ? serverVersion.isSearchUsersSupported() : false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns account for instant upload or null, if not defined.
|
||||
* @return instant upload account or null
|
||||
*/
|
||||
public static Account getInstantUploadAccount(Context context) {
|
||||
return getAccount(com.owncloud.android.db.PreferenceManager.instantPictureUploadPathAccount(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns account for instant video upload or null, if not defined.
|
||||
* @return instant video upload account or null
|
||||
*/
|
||||
public static Account getInstantVideoUploadAccount(Context context) {
|
||||
return getAccount(com.owncloud.android.db.PreferenceManager.instantVideoUploadPathAccount(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns account for given account name or null, if not defined.
|
||||
* @return account named accountNam or null
|
||||
*/
|
||||
private static Account getAccount(String accountName) {
|
||||
return getOwnCloudAccountByName(MainApp.getAppContext(), accountName);
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,6 @@ import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -726,44 +721,69 @@ public class FileDataStorageManager {
|
||||
if (!targetFolder.exists()) {
|
||||
targetFolder.mkdirs();
|
||||
}
|
||||
copied = copyFile(localFile, targetFile);
|
||||
copied = FileStorageUtils.copyFile(localFile, targetFile);
|
||||
}
|
||||
Log_OC.d(TAG, "Local file COPIED : " + copied);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean copyFile(File src, File target) {
|
||||
boolean ret = true;
|
||||
public void migrateStoredFiles(String srcPath, String dstPath) throws Exception {
|
||||
Cursor c = null;
|
||||
if (getContentResolver() != null) {
|
||||
c = getContentResolver().query(ProviderTableMeta.CONTENT_URI_FILE,
|
||||
null,
|
||||
ProviderTableMeta.FILE_STORAGE_PATH + " IS NOT NULL",
|
||||
null,
|
||||
null);
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
|
||||
try {
|
||||
in = new FileInputStream(src);
|
||||
out = new FileOutputStream(target);
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ret = false;
|
||||
} finally {
|
||||
if (in != null) try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
if (out != null) try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(System.err);
|
||||
} else {
|
||||
try {
|
||||
c = getContentProviderClient().query(ProviderTableMeta.CONTENT_URI_FILE,
|
||||
new String[]{ProviderTableMeta._ID, ProviderTableMeta.FILE_STORAGE_PATH},
|
||||
ProviderTableMeta.FILE_STORAGE_PATH + " IS NOT NULL",
|
||||
null,
|
||||
null);
|
||||
} catch (RemoteException e) {
|
||||
Log_OC.e(TAG, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
ArrayList<ContentProviderOperation> operations =
|
||||
new ArrayList<ContentProviderOperation>(c.getCount());
|
||||
if (c.moveToFirst()) {
|
||||
do {
|
||||
ContentValues cv = new ContentValues();
|
||||
long fileId = c.getLong(c.getColumnIndex(ProviderTableMeta._ID));
|
||||
String oldFileStoragePath = c.getString(c.getColumnIndex(ProviderTableMeta.FILE_STORAGE_PATH));
|
||||
|
||||
if (oldFileStoragePath.startsWith(srcPath)) {
|
||||
|
||||
cv.put(
|
||||
ProviderTableMeta.FILE_STORAGE_PATH,
|
||||
oldFileStoragePath.replaceFirst(srcPath, dstPath));
|
||||
|
||||
operations.add(
|
||||
ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
|
||||
withValues(cv).
|
||||
withSelection(
|
||||
ProviderTableMeta._ID + "=?",
|
||||
new String[]{String.valueOf(fileId)}
|
||||
)
|
||||
.build());
|
||||
}
|
||||
|
||||
} while (c.moveToNext());
|
||||
}
|
||||
c.close();
|
||||
|
||||
/// 3. apply updates in batch
|
||||
if (getContentResolver() != null) {
|
||||
getContentResolver().applyBatch(MainApp.getAuthority(), operations);
|
||||
} else {
|
||||
getContentProviderClient().applyBatch(operations);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector<OCFile> getFolderContent(long parentId, boolean onlyOnDevice) {
|
||||
|
||||
|
||||
@@ -24,11 +24,16 @@ package com.owncloud.android.datamodel;
|
||||
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.MimeType;
|
||||
|
||||
@@ -95,6 +100,14 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||
private Uri mLocalUri;
|
||||
|
||||
|
||||
/**
|
||||
* Exportable URI to the local path of the file contents, if stored in the device.
|
||||
*
|
||||
* Cached after first call, until changed.
|
||||
*/
|
||||
private Uri mExposedFileUri;
|
||||
|
||||
|
||||
/**
|
||||
* Create new {@link OCFile} with given path.
|
||||
* <p/>
|
||||
@@ -245,6 +258,32 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||
return mLocalUri;
|
||||
}
|
||||
|
||||
public Uri getExposedFileUri(Context context) {
|
||||
if (mLocalPath == null || mLocalPath.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (mExposedFileUri == null) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
// TODO - use FileProvider with any Android version, with deeper testing -> 2.2.0
|
||||
mExposedFileUri = Uri.parse(
|
||||
ContentResolver.SCHEME_FILE + "://" + WebdavUtils.encodePath(mLocalPath)
|
||||
);
|
||||
} else {
|
||||
// Use the FileProvider to get a content URI
|
||||
try {
|
||||
mExposedFileUri = FileProvider.getUriForFile(
|
||||
context,
|
||||
context.getString(R.string.file_provider_authority),
|
||||
new File(mLocalPath)
|
||||
);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log_OC.e(TAG, "File can't be exported");
|
||||
}
|
||||
}
|
||||
}
|
||||
return mExposedFileUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to set the path where the file is stored
|
||||
*
|
||||
@@ -253,6 +292,7 @@ public class OCFile implements Parcelable, Comparable<OCFile> {
|
||||
public void setStoragePath(String storage_path) {
|
||||
mLocalPath = storage_path;
|
||||
mLocalUri = null;
|
||||
mExposedFileUri = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,30 +21,28 @@
|
||||
|
||||
package com.owncloud.android.datamodel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.FileNameMap;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.Image;
|
||||
import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.Display;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
@@ -56,8 +54,8 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.ui.adapter.DiskLruImageCache;
|
||||
import com.owncloud.android.utils.BitmapUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.DisplayUtils.AvatarGenerationListener;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
@@ -65,7 +63,6 @@ import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
/**
|
||||
* Manager for concurrent access to thumbnails cache.
|
||||
@@ -75,12 +72,12 @@ public class ThumbnailsCacheManager {
|
||||
private static final String TAG = ThumbnailsCacheManager.class.getSimpleName();
|
||||
|
||||
private static final String CACHE_FOLDER = "thumbnailCache";
|
||||
private static final Integer CACHE_SIZE_MB = 10;
|
||||
|
||||
private static final Object mThumbnailsDiskCacheLock = new Object();
|
||||
private static DiskLruImageCache mThumbnailCache = null;
|
||||
private static boolean mThumbnailCacheStarting = true;
|
||||
|
||||
private static final int DISK_CACHE_SIZE = 1024 * 1024 * 10; // 10MB
|
||||
|
||||
private static final CompressFormat mCompressFormat = CompressFormat.JPEG;
|
||||
private static final int mCompressQuality = 70;
|
||||
private static OwnCloudClient mClient = null;
|
||||
@@ -97,7 +94,7 @@ public class ThumbnailsCacheManager {
|
||||
R.drawable.file_movie
|
||||
);
|
||||
|
||||
|
||||
|
||||
public static class InitDiskCacheTask extends AsyncTask<File, Void, Void> {
|
||||
|
||||
@Override
|
||||
@@ -107,7 +104,19 @@ public class ThumbnailsCacheManager {
|
||||
|
||||
if (mThumbnailCache == null) {
|
||||
try {
|
||||
// Check if media is mounted or storage is built-in, if so,
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(MainApp.getAppContext());
|
||||
// due to backward compatibility
|
||||
Integer cacheSize = CACHE_SIZE_MB * 1024 * 1024;
|
||||
try {
|
||||
cacheSize = appPrefs.getInt("pref_cache_size", cacheSize);
|
||||
} catch (ClassCastException e) {
|
||||
String temp = appPrefs.getString("pref_cache_size",
|
||||
cacheSize.toString());
|
||||
cacheSize = Integer.decode(temp) * 1024 * 1024;
|
||||
}
|
||||
|
||||
// Check if media is mounted or storage is built-in, if so,
|
||||
// try and use external cache dir; otherwise use internal cache dir
|
||||
final String cachePath =
|
||||
MainApp.getAppContext().getExternalCacheDir().getPath() +
|
||||
@@ -116,7 +125,7 @@ public class ThumbnailsCacheManager {
|
||||
final File diskCacheDir = new File(cachePath);
|
||||
mThumbnailCache = new DiskLruImageCache(
|
||||
diskCacheDir,
|
||||
DISK_CACHE_SIZE,
|
||||
cacheSize,
|
||||
mCompressFormat,
|
||||
mCompressQuality
|
||||
);
|
||||
@@ -159,14 +168,40 @@ public class ThumbnailsCacheManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets max size of cache
|
||||
* @param maxSize in MB
|
||||
* @return
|
||||
*/
|
||||
public static boolean setMaxSize(long maxSize){
|
||||
if (mThumbnailCache != null){
|
||||
mThumbnailCache.setMaxSize(maxSize * 1024 * 1024);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows max cache size
|
||||
* @return max cache size in MB.
|
||||
*/
|
||||
public static long getMaxSize(){
|
||||
if (mThumbnailCache == null) {
|
||||
new ThumbnailsCacheManager.InitDiskCacheTask().execute();
|
||||
}
|
||||
return mThumbnailCache.getMaxSize() / 1024 / 1024;
|
||||
}
|
||||
|
||||
public static class ThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
|
||||
private final WeakReference<ImageView> mImageViewReference;
|
||||
private WeakReference<ProgressBar> mProgressWheelRef;
|
||||
private static Account mAccount;
|
||||
private Object mFile;
|
||||
private Boolean mIsThumbnail;
|
||||
private String mImageKey = null;
|
||||
private FileDataStorageManager mStorageManager;
|
||||
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
|
||||
Account account) {
|
||||
// Use a WeakReference to ensure the ImageView can be garbage collected
|
||||
@@ -185,6 +220,12 @@ public class ThumbnailsCacheManager {
|
||||
mImageViewReference = null;
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
|
||||
Account account, ProgressBar progressWheel) {
|
||||
this(imageView, storageManager, account);
|
||||
mProgressWheelRef = new WeakReference<ProgressBar>(progressWheel);
|
||||
}
|
||||
|
||||
public ThumbnailGenerationTask(ImageView imageView) {
|
||||
// Use a WeakReference to ensure the ImageView can be garbage collected
|
||||
mImageViewReference = new WeakReference<ImageView>(imageView);
|
||||
@@ -205,18 +246,20 @@ public class ThumbnailsCacheManager {
|
||||
}
|
||||
|
||||
mFile = params[0];
|
||||
if (params.length == 2){
|
||||
mImageKey = (String) params[1];
|
||||
mIsThumbnail = (Boolean) params[1];
|
||||
|
||||
if (params.length == 3){
|
||||
mImageKey = (String) params[2];
|
||||
}
|
||||
|
||||
|
||||
if (mFile instanceof OCFile) {
|
||||
thumbnail = doOCFileInBackground();
|
||||
thumbnail = doOCFileInBackground(mIsThumbnail);
|
||||
|
||||
if (((OCFile) mFile).isVideo() && thumbnail != null){
|
||||
thumbnail = addVideoOverlay(thumbnail);
|
||||
}
|
||||
} else if (mFile instanceof File) {
|
||||
thumbnail = doFileInBackground();
|
||||
thumbnail = doFileInBackground(mIsThumbnail);
|
||||
|
||||
String url = ((File) mFile).getAbsolutePath();
|
||||
String mMimeType = FileStorageUtils.getMimeTypeFromName(url);
|
||||
@@ -250,6 +293,12 @@ public class ThumbnailsCacheManager {
|
||||
tagId = String.valueOf(mFile.hashCode());
|
||||
}
|
||||
if (String.valueOf(imageView.getTag()).equals(tagId)) {
|
||||
if (mProgressWheelRef != null) {
|
||||
final ProgressBar progressWheel = mProgressWheelRef.get();
|
||||
if (progressWheel != null) {
|
||||
progressWheel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
@@ -261,12 +310,14 @@ public class ThumbnailsCacheManager {
|
||||
* @param imageKey: thumb key
|
||||
* @param bitmap: image for extracting thumbnail
|
||||
* @param path: image path
|
||||
* @param px: thumbnail dp
|
||||
* @param pxW: thumbnail width in pixel
|
||||
* @param pxH: thumbnail height in pixel
|
||||
* @return Bitmap
|
||||
*/
|
||||
private Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path, int px){
|
||||
private Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path,
|
||||
int pxW, int pxH){
|
||||
|
||||
Bitmap thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
|
||||
Bitmap thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
|
||||
|
||||
// Rotate image, obeying exif tag
|
||||
thumbnail = BitmapUtils.rotateImage(thumbnail,path);
|
||||
@@ -287,31 +338,56 @@ public class ThumbnailsCacheManager {
|
||||
return Math.round(r.getDimension(R.dimen.file_icon_size_grid));
|
||||
}
|
||||
|
||||
private Bitmap doOCFileInBackground() {
|
||||
private Point getScreenDimension(){
|
||||
WindowManager wm = (WindowManager) MainApp.getAppContext().
|
||||
getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
Point test = new Point();
|
||||
display.getSize(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private Bitmap doOCFileInBackground(Boolean isThumbnail) {
|
||||
Bitmap thumbnail = null;
|
||||
OCFile file = (OCFile)mFile;
|
||||
|
||||
final String imageKey = String.valueOf(file.getRemoteId());
|
||||
// distinguish between thumbnail and resized image
|
||||
String temp = String.valueOf(file.getRemoteId());
|
||||
if (isThumbnail){
|
||||
temp = "t" + temp;
|
||||
} else {
|
||||
temp = "r" + temp;
|
||||
}
|
||||
|
||||
final String imageKey = temp;
|
||||
|
||||
// Check disk cache in background thread
|
||||
Bitmap thumbnail = getBitmapFromDiskCache(imageKey);
|
||||
thumbnail = getBitmapFromDiskCache(imageKey);
|
||||
|
||||
// Not found in disk cache
|
||||
if (thumbnail == null || file.needsUpdateThumbnail()) {
|
||||
|
||||
int px = getThumbnailDimension();
|
||||
int pxW = 0;
|
||||
int pxH = 0;
|
||||
if (mIsThumbnail) {
|
||||
pxW = pxH = getThumbnailDimension();
|
||||
} else {
|
||||
Point p = getScreenDimension();
|
||||
pxW = p.x;
|
||||
pxH = p.y;
|
||||
}
|
||||
|
||||
if (file.isDown()) {
|
||||
Bitmap temp = BitmapUtils.decodeSampledBitmapFromFile(
|
||||
file.getStoragePath(), px, px);
|
||||
Bitmap bitmap = ThumbnailUtils.extractThumbnail(temp, px, px);
|
||||
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
|
||||
file.getStoragePath(), pxW, pxH);
|
||||
|
||||
if (bitmap != null) {
|
||||
// Handle PNG
|
||||
if (file.getMimetype().equalsIgnoreCase("image/png")) {
|
||||
bitmap = handlePNG(bitmap, px);
|
||||
bitmap = handlePNG(bitmap, pxW);
|
||||
}
|
||||
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), px);
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(),
|
||||
pxW, pxH);
|
||||
|
||||
file.setNeedsUpdateThumbnail(false);
|
||||
mStorageManager.saveFile(file);
|
||||
@@ -324,30 +400,47 @@ public class ThumbnailsCacheManager {
|
||||
if (serverOCVersion.supportsRemoteThumbnails()) {
|
||||
GetMethod get = null;
|
||||
try {
|
||||
String uri = mClient.getBaseUri() + "" +
|
||||
"/index.php/apps/files/api/v1/thumbnail/" +
|
||||
px + "/" + px + Uri.encode(file.getRemotePath(), "/");
|
||||
Log_OC.d("Thumbnail", "URI: " + uri);
|
||||
get = new GetMethod(uri);
|
||||
get.setRequestHeader("Cookie",
|
||||
"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
|
||||
int status = mClient.executeMethod(get);
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
InputStream inputStream = get.getResponseBodyAsStream();
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
|
||||
|
||||
// Handle PNG
|
||||
if (file.getMimetype().equalsIgnoreCase("image/png")) {
|
||||
thumbnail = handlePNG(thumbnail, px);
|
||||
}
|
||||
|
||||
// Add thumbnail to cache
|
||||
if (thumbnail != null) {
|
||||
addBitmapToCache(imageKey, thumbnail);
|
||||
if (mIsThumbnail) {
|
||||
String uri = mClient.getBaseUri() + "" +
|
||||
"/index.php/apps/files/api/v1/thumbnail/" +
|
||||
pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");
|
||||
Log_OC.d("Thumbnail", "URI: " + uri);
|
||||
get = new GetMethod(uri);
|
||||
get.setRequestHeader("Cookie",
|
||||
"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
|
||||
int status = mClient.executeMethod(get);
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
InputStream inputStream = get.getResponseBodyAsStream();
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
|
||||
}
|
||||
} else {
|
||||
mClient.exhaustResponse(get.getResponseBodyAsStream());
|
||||
String uri = mClient.getBaseUri() + "" +
|
||||
"/index.php/apps/gallery/api/preview/" +
|
||||
Integer.parseInt(file.getRemoteId().substring(0,8)) +
|
||||
"/" + pxW + "/" + pxH;
|
||||
Log_OC.d("Thumbnail", "FileName: " + file.getFileName() +
|
||||
" Download URI: " + uri);
|
||||
get = new GetMethod(uri);
|
||||
get.setRequestHeader("Cookie",
|
||||
"nc_sameSiteCookielax=true;nc_sameSiteCookiestrict=true");
|
||||
int status = mClient.executeMethod(get);
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
InputStream inputStream = get.getResponseBodyAsStream();
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
// Download via gallery app
|
||||
thumbnail = bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle PNG
|
||||
if (file.getMimetype().equalsIgnoreCase("image/png")) {
|
||||
thumbnail = handlePNG(thumbnail, pxW);
|
||||
}
|
||||
|
||||
// Add thumbnail to cache
|
||||
if (thumbnail != null) {
|
||||
addBitmapToCache(imageKey, thumbnail);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -367,7 +460,7 @@ public class ThumbnailsCacheManager {
|
||||
|
||||
}
|
||||
|
||||
private Bitmap doFileInBackground() {
|
||||
private Bitmap doFileInBackground(Boolean mIsThumbnail) {
|
||||
File file = (File)mFile;
|
||||
|
||||
final String imageKey;
|
||||
@@ -377,19 +470,33 @@ public class ThumbnailsCacheManager {
|
||||
imageKey = String.valueOf(file.hashCode());
|
||||
}
|
||||
|
||||
// distinguish between thumbnail and resized image
|
||||
if (mIsThumbnail){
|
||||
mImageKey = "t" + mImageKey;
|
||||
} else {
|
||||
mImageKey = "r" + mImageKey;
|
||||
}
|
||||
|
||||
// Check disk cache in background thread
|
||||
Bitmap thumbnail = getBitmapFromDiskCache(imageKey);
|
||||
|
||||
// Not found in disk cache
|
||||
if (thumbnail == null) {
|
||||
|
||||
int px = getThumbnailDimension();
|
||||
int pxW = 0;
|
||||
int pxH = 0;
|
||||
if (mIsThumbnail) {
|
||||
pxW = pxH = getThumbnailDimension();
|
||||
} else {
|
||||
Point p = getScreenDimension();
|
||||
pxW = p.x;
|
||||
pxH = p.y;
|
||||
}
|
||||
|
||||
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
|
||||
file.getAbsolutePath(), px, px);
|
||||
file.getAbsolutePath(), pxW, pxH);
|
||||
|
||||
if (bitmap != null) {
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), px);
|
||||
thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), pxW, pxH);
|
||||
}
|
||||
}
|
||||
return thumbnail;
|
||||
|
||||
@@ -365,7 +365,8 @@ public class UploadsStorageManager extends Observable {
|
||||
public OCUpload[] getCurrentAndPendingUploads() {
|
||||
return getUploads(
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value + " OR " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_WIFI.getValue(),
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_WIFI.getValue() + " OR " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
||||
null
|
||||
);
|
||||
}
|
||||
@@ -388,10 +389,11 @@ public class UploadsStorageManager extends Observable {
|
||||
* Get all failed uploads, except for those that were not performed due to lack of Wifi connection
|
||||
* @return Array of failed uploads, except for those that were not performed due to lack of Wifi connection.
|
||||
*/
|
||||
public OCUpload[] getFailedButNotDelayedForWifiUploads() {
|
||||
public OCUpload[] getFailedButNotDelayedUploads() {
|
||||
return getUploads(
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + " AND " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue(),
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
||||
null
|
||||
);
|
||||
}
|
||||
@@ -400,11 +402,12 @@ public class UploadsStorageManager extends Observable {
|
||||
return mContentResolver;
|
||||
}
|
||||
|
||||
public long clearFailedButNotDelayedForWifiUploads() {
|
||||
public long clearFailedButNotDelayedUploads() {
|
||||
long result = getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + " AND " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue(),
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
||||
null
|
||||
);
|
||||
Log_OC.d(TAG, "delete all failed uploads but those delayed for Wifi");
|
||||
@@ -426,14 +429,15 @@ public class UploadsStorageManager extends Observable {
|
||||
return result;
|
||||
}
|
||||
|
||||
public long clearAllFinishedButNotDelayedForWifiUploads() {
|
||||
public long clearAllFinishedButNotDelayedUploads() {
|
||||
String[] whereArgs = new String[2];
|
||||
whereArgs[0] = String.valueOf(UploadStatus.UPLOAD_SUCCEEDED.value);
|
||||
whereArgs[1] = String.valueOf(UploadStatus.UPLOAD_FAILED.value);
|
||||
long result = getDB().delete(
|
||||
ProviderTableMeta.CONTENT_URI_UPLOADS,
|
||||
ProviderTableMeta.UPLOADS_STATUS + "=? OR " + ProviderTableMeta.UPLOADS_STATUS + "=? AND " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue(),
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue() + " AND " +
|
||||
ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_CHARGING.getValue(),
|
||||
whereArgs
|
||||
);
|
||||
Log_OC.d(TAG, "delete all finished uploads");
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datastorage.providers.EnvironmentStoragePointProvider;
|
||||
import com.owncloud.android.datastorage.providers.HardcodedStoragePointProvider;
|
||||
import com.owncloud.android.datastorage.providers.IStoragePointProvider;
|
||||
import com.owncloud.android.datastorage.providers.MountCommandStoragePointProvider;
|
||||
import com.owncloud.android.datastorage.providers.SystemDefaultStoragePointProvider;
|
||||
import com.owncloud.android.datastorage.providers.VDCStoragePointProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class DataStorageProvider {
|
||||
|
||||
private static final Vector<IStoragePointProvider> mStorageProviders = new Vector<>();
|
||||
private static final UniqueStorageList mCachedStoragePoints = new UniqueStorageList();
|
||||
private static final DataStorageProvider sInstance = new DataStorageProvider() {{
|
||||
// There is no system wide way to get usb storage so we need to provide multiple
|
||||
// handcrafted ways to add those.
|
||||
addStoragePointProvider(new SystemDefaultStoragePointProvider());
|
||||
addStoragePointProvider(new EnvironmentStoragePointProvider());
|
||||
addStoragePointProvider(new VDCStoragePointProvider());
|
||||
addStoragePointProvider(new MountCommandStoragePointProvider());
|
||||
addStoragePointProvider(new HardcodedStoragePointProvider());
|
||||
}};
|
||||
|
||||
|
||||
public static DataStorageProvider getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private DataStorageProvider() {}
|
||||
|
||||
public StoragePoint[] getAvailableStoragePoints() {
|
||||
if (mCachedStoragePoints.size() != 0)
|
||||
return mCachedStoragePoints.toArray(new StoragePoint[mCachedStoragePoints.size()]);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
for (File f : MainApp.getAppContext().getExternalFilesDirs(null)) {
|
||||
if (f != null) {
|
||||
mCachedStoragePoints.add(new StoragePoint(f.getAbsolutePath(), f.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (IStoragePointProvider p : mStorageProviders)
|
||||
if (p.canProvideStoragePoints()) {
|
||||
mCachedStoragePoints.addAll(p.getAvailableStoragePoint());
|
||||
}
|
||||
}
|
||||
|
||||
return mCachedStoragePoints.toArray(new StoragePoint[mCachedStoragePoints.size()]);
|
||||
}
|
||||
|
||||
public String getStorageDescriptionByPath(String path) {
|
||||
for (StoragePoint s : getAvailableStoragePoints())
|
||||
if (s.getPath().equals(path))
|
||||
return s.getDescription();
|
||||
return MainApp.getAppContext().getString(R.string.storage_description_unknown);
|
||||
}
|
||||
|
||||
public void addStoragePointProvider(IStoragePointProvider provider) {
|
||||
mStorageProviders.add(provider);
|
||||
}
|
||||
|
||||
public void removeStoragePointProvider(IStoragePointProvider provider) {
|
||||
mStorageProviders.remove(provider);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class StoragePoint implements Comparable<StoragePoint> {
|
||||
private String mDescription;
|
||||
private String mPath;
|
||||
|
||||
public StoragePoint(String description, String path) {
|
||||
mDescription = description;
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
public String getPath() { return mPath; }
|
||||
public String getDescription() { return mDescription; }
|
||||
|
||||
@Override
|
||||
public int compareTo(StoragePoint another) {
|
||||
return mPath.compareTo(another.getPath());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class UniqueStorageList extends Vector<StoragePoint> {
|
||||
@Override
|
||||
public boolean add(StoragePoint sp) {
|
||||
try {
|
||||
for (StoragePoint s : this) {
|
||||
String thisCanonPath = new File(s.getPath()).getCanonicalPath();
|
||||
String otherCanonPath = new File(sp.getPath()).getCanonicalPath();
|
||||
if (thisCanonPath.equals(otherCanonPath))
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
return super.add(sp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean addAll(Collection<? extends StoragePoint> collection) {
|
||||
for (StoragePoint sp : collection)
|
||||
add(sp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
abstract public class AbstractCommandLineStoragePoint extends AbstractStoragePointProvider {
|
||||
|
||||
static protected final int sCommandLineOKReturnValue = 0;
|
||||
|
||||
protected abstract String[] getCommand();
|
||||
|
||||
@Override
|
||||
public boolean canProvideStoragePoints() {
|
||||
Process process;
|
||||
try {
|
||||
process = new ProcessBuilder().command(Arrays.asList(getCommand())).start();
|
||||
process.waitFor();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return process != null && process.exitValue() == sCommandLineOKReturnValue;
|
||||
}
|
||||
|
||||
protected String getCommandLineResult() {
|
||||
String s = "";
|
||||
try {
|
||||
final Process process = new ProcessBuilder().command(getCommand())
|
||||
.redirectErrorStream(true).start();
|
||||
|
||||
process.waitFor();
|
||||
final InputStream is = process.getInputStream();
|
||||
final byte buffer[] = new byte[1024];
|
||||
while (is.read(buffer) != -1)
|
||||
s += new String(buffer);
|
||||
is.close();
|
||||
} catch (final Exception e) { }
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
abstract public class AbstractStoragePointProvider implements IStoragePointProvider {
|
||||
|
||||
protected boolean canBeAddedToAvailableList(Vector<StoragePoint> currentList, String path) {
|
||||
if (path == null) return false;
|
||||
for (StoragePoint storage : currentList)
|
||||
if (storage.getPath().equals(path))
|
||||
return false;
|
||||
File f = new File(path);
|
||||
return f.exists() && f.isDirectory() && f.canRead() && f.canWrite();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class EnvironmentStoragePointProvider extends AbstractStoragePointProvider {
|
||||
|
||||
private static final String sSecondaryStorageEnvName = "SECONDARY_STORAGE";
|
||||
|
||||
@Override
|
||||
public boolean canProvideStoragePoints() {
|
||||
return !TextUtils.isEmpty(System.getenv(sSecondaryStorageEnvName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
|
||||
addEntriesFromEnv(result, sSecondaryStorageEnvName);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addEntriesFromEnv(Vector<StoragePoint> result, String envName) {
|
||||
String env = System.getenv(envName);
|
||||
if (env != null)
|
||||
for (String p : env.split(":"))
|
||||
if (canBeAddedToAvailableList(result, p))
|
||||
result.add(new StoragePoint(p, p));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class HardcodedStoragePointProvider extends AbstractStoragePointProvider {
|
||||
|
||||
static private final String[] sPaths = {
|
||||
"/mnt/external_sd/",
|
||||
"/mnt/extSdCard/",
|
||||
"/storage/extSdCard",
|
||||
"/storage/sdcard1/",
|
||||
"/storage/usbcard1/"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean canProvideStoragePoints() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
|
||||
for (String s : sPaths)
|
||||
if (canBeAddedToAvailableList(result, s))
|
||||
result.add(new StoragePoint(s, s));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public interface IStoragePointProvider {
|
||||
|
||||
/**
|
||||
* This method is used for querying storage provider to check if it can provide
|
||||
* usable and reliable data storage places.
|
||||
*
|
||||
* @return true if provider can reliably return storage path
|
||||
*/
|
||||
boolean canProvideStoragePoints();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return available storage points
|
||||
*/
|
||||
Vector<StoragePoint> getAvailableStoragePoint();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class MountCommandStoragePointProvider extends AbstractCommandLineStoragePoint {
|
||||
|
||||
static private final String[] sCommand = new String[] { "mount" };
|
||||
|
||||
private static Pattern sPattern = Pattern.compile("(?i).*vold.*(vfat|ntfs|exfat|fat32|ext3|ext4).*rw.*");
|
||||
|
||||
@Override
|
||||
protected String[] getCommand() {
|
||||
return sCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
|
||||
for (String p : getPotentialPaths(getCommandLineResult()))
|
||||
if (canBeAddedToAvailableList(result, p))
|
||||
result.add(new StoragePoint(p, p));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Vector<String> getPotentialPaths(String mounted) {
|
||||
final Vector<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"))
|
||||
result.add(path);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class SystemDefaultStoragePointProvider extends AbstractStoragePointProvider {
|
||||
@Override
|
||||
public boolean canProvideStoragePoints() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
|
||||
final String defaultStringDesc =
|
||||
MainApp.getAppContext().getString(R.string.storage_description_default);
|
||||
final String path = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
result.add(new StoragePoint(defaultStringDesc, path));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.datastorage.providers;
|
||||
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class VDCStoragePointProvider extends AbstractCommandLineStoragePoint {
|
||||
|
||||
static private final String TAG = VDCStoragePointProvider.class.getSimpleName();
|
||||
|
||||
static private final String[] sVDCVolListCommand = new String[]{ "/system/bin/vdc", "volume", "list" };
|
||||
static private final int sVDCVolumeList = 110;
|
||||
|
||||
|
||||
@Override
|
||||
public Vector<StoragePoint> getAvailableStoragePoint() {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
|
||||
result.addAll(getPaths(getCommandLineResult()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getCommand() {
|
||||
return sVDCVolListCommand;
|
||||
}
|
||||
|
||||
private Vector<StoragePoint> getPaths(String vdcResources) {
|
||||
Vector<StoragePoint> result = new Vector<>();
|
||||
|
||||
for (String line : vdcResources.split("\n")) {
|
||||
String vdcLine[] = line.split(" ");
|
||||
try {
|
||||
int status = Integer.parseInt(vdcLine[0]);
|
||||
if (status != sVDCVolumeList)
|
||||
continue;
|
||||
final String description = vdcLine[1];
|
||||
final String path = vdcLine[2];
|
||||
|
||||
if (canBeAddedToAvailableList(result, path))
|
||||
result.add(new StoragePoint(description, path));
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
Log_OC.e(TAG, "Incorrect VDC output format " + e);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG, "Unexpected exception on VDC parsing " + e);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,16 +38,22 @@ public abstract class PreferenceManager {
|
||||
private static final String AUTO_PREF__SORT_ASCENDING = "sort_ascending";
|
||||
private static final String AUTO_PREF__UPLOADER_BEHAVIOR = "prefs_uploader_behaviour";
|
||||
private static final String PREF__INSTANT_UPLOADING = "instant_uploading";
|
||||
private static final String PREF__INSTANT_UPLOAD_PATH_ACCOUNT = "instant_upload_path_account";
|
||||
private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading";
|
||||
private static final String PREF__INSTANT_UPLOAD_PATH_USE_SUBFOLDERS = "instant_upload_path_use_subfolders";
|
||||
private static final String PREF__INSTANT_UPLOAD_ON_WIFI = "instant_upload_on_wifi";
|
||||
private static final String PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI = "instant_video_upload_on_wifi";
|
||||
private static final String PREF__INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS = "instant_video_upload_path_use_subfolders";
|
||||
private static final String PREF__INSTANT_VIDEO_UPLOAD_PATH_ACCOUNT = "instant_video_upload_path_account";
|
||||
|
||||
public static boolean instantPictureUploadEnabled(Context context) {
|
||||
return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOADING, false);
|
||||
}
|
||||
|
||||
public static String instantPictureUploadPathAccount(Context context) {
|
||||
return getDefaultSharedPreferences(context).getString(PREF__INSTANT_UPLOAD_PATH_ACCOUNT, null);
|
||||
}
|
||||
|
||||
public static boolean instantVideoUploadEnabled(Context context) {
|
||||
return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOADING, false);
|
||||
}
|
||||
@@ -60,6 +66,10 @@ public abstract class PreferenceManager {
|
||||
return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOAD_ON_WIFI, false);
|
||||
}
|
||||
|
||||
public static String instantVideoUploadPathAccount(Context context) {
|
||||
return getDefaultSharedPreferences(context).getString(PREF__INSTANT_VIDEO_UPLOAD_PATH_ACCOUNT, null);
|
||||
}
|
||||
|
||||
public static boolean instantVideoUploadPathUseSubfolders(Context context) {
|
||||
return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS, false);
|
||||
}
|
||||
@@ -67,6 +77,12 @@ public abstract class PreferenceManager {
|
||||
public static boolean instantVideoUploadViaWiFiOnly(Context context) {
|
||||
return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI, false);
|
||||
}
|
||||
public static boolean instantPictureUploadWhenChargingOnly(Context context) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_upload_on_charging", false);
|
||||
}
|
||||
public static boolean instantVideoUploadWhenChargingOnly(Context context) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_upload_on_charging", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path where the user selected to do the last upload of a file shared from other app.
|
||||
@@ -137,7 +153,7 @@ public abstract class PreferenceManager {
|
||||
*/
|
||||
public static int getUploaderBehaviour(Context context) {
|
||||
return getDefaultSharedPreferences(context)
|
||||
.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,8 @@ public enum UploadResult {
|
||||
CANCELLED(7),
|
||||
FILE_NOT_FOUND(8),
|
||||
DELAYED_FOR_WIFI(9),
|
||||
SERVICE_INTERRUPTED(10);
|
||||
SERVICE_INTERRUPTED(10),
|
||||
DELAYED_FOR_CHARGING(11);
|
||||
|
||||
private final int value;
|
||||
|
||||
@@ -71,6 +72,8 @@ public enum UploadResult {
|
||||
return DELAYED_FOR_WIFI;
|
||||
case 10:
|
||||
return SERVICE_INTERRUPTED;
|
||||
case 11:
|
||||
return DELAYED_FOR_CHARGING;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -105,6 +108,8 @@ public enum UploadResult {
|
||||
return CANCELLED;
|
||||
case DELAYED_FOR_WIFI:
|
||||
return DELAYED_FOR_WIFI;
|
||||
case DELAYED_FOR_CHARGING:
|
||||
return DELAYED_FOR_CHARGING;
|
||||
case UNKNOWN_ERROR:
|
||||
if (result.getException() instanceof java.io.FileNotFoundException) {
|
||||
return FILE_ERROR;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Because we support NEW_PHOTO_ACTION and NEW_PHOTO_ACTION_UNOFFICIAL it can happen that
|
||||
* Because we support NEW_PHOTO_ACTION and NEW_PHOTO_ACTION_UNOFFICIAL it can happen that
|
||||
* handleNewPictureAction is called twice for the same photo. Use this simple static variable to
|
||||
* remember last uploaded photo to filter duplicates. Must not be null!
|
||||
*/
|
||||
@@ -92,9 +92,9 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
Account account = AccountUtils.getInstantUploadAccount(context);
|
||||
if (account == null) {
|
||||
Log_OC.w(TAG, "No account found for instant upload, aborting");
|
||||
Log_OC.w(TAG, "No account found for instant photo upload, aborting");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,9 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
||||
} else if (behaviour.equalsIgnoreCase("MOVE")) {
|
||||
Log_OC.d(TAG, "upload file and move file to oc folder");
|
||||
return FileUploader.LOCAL_BEHAVIOUR_MOVE;
|
||||
} else if (behaviour.equalsIgnoreCase("DELETE")) {
|
||||
Log_OC.d(TAG, "upload file and delete original file");
|
||||
return FileUploader.LOCAL_BEHAVIOUR_DELETE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -172,9 +175,9 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
|
||||
Account account = AccountUtils.getInstantVideoUploadAccount(context);
|
||||
if (account == null) {
|
||||
Log_OC.w(TAG, "No account found for instant upload, aborting");
|
||||
Log_OC.w(TAG, "No account found for instant video upload, aborting");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,24 @@ public class ConnectivityActionReceiver extends BroadcastReceiver {
|
||||
Log_OC.v(TAG, "no extras");
|
||||
}
|
||||
|
||||
if (intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
|
||||
// for the moment, only recovery of instant uploads, similar to behaviour in release 1.9.1
|
||||
if (
|
||||
(PreferenceManager.instantPictureUploadEnabled(context) &&
|
||||
PreferenceManager.instantPictureUploadWhenChargingOnly(context)) ||
|
||||
(PreferenceManager.instantVideoUploadEnabled(context) &&
|
||||
PreferenceManager.instantVideoUploadWhenChargingOnly(context))
|
||||
) {
|
||||
Log_OC.d(TAG, "Requesting retry of instant uploads (& friends) due to charging");
|
||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||
requester.retryFailedUploads(
|
||||
context,
|
||||
null,
|
||||
UploadResult.DELAYED_FOR_CHARGING // for the rest of enqueued when Wifi fell
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* There is an interesting mess to process WifiManager.NETWORK_STATE_CHANGED_ACTION and
|
||||
* ConnectivityManager.CONNECTIVITY_ACTION in a simple and reliable way.
|
||||
|
||||
@@ -149,7 +149,7 @@ public class FileUploader extends Service
|
||||
public static final int LOCAL_BEHAVIOUR_COPY = 0;
|
||||
public static final int LOCAL_BEHAVIOUR_MOVE = 1;
|
||||
public static final int LOCAL_BEHAVIOUR_FORGET = 2;
|
||||
|
||||
public static final int LOCAL_BEHAVIOUR_DELETE = 3;
|
||||
|
||||
private Looper mServiceLooper;
|
||||
private ServiceHandler mServiceHandler;
|
||||
@@ -954,9 +954,10 @@ public class FileUploader extends Service
|
||||
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(mStorageManager, mCurrentAccount);
|
||||
|
||||
Object[] params = new Object[2];
|
||||
params[0] = new File(mCurrentUpload.getOriginalStoragePath());
|
||||
params[1] = mCurrentUpload.getFile().getRemoteId();
|
||||
Object[] params = new Object[3];
|
||||
params[0] = mCurrentUpload.getFile();
|
||||
params[1] = true;
|
||||
params[2] = mCurrentUpload.getFile().getRemoteId();
|
||||
|
||||
task.execute(params);
|
||||
}
|
||||
@@ -1030,7 +1031,8 @@ public class FileUploader extends Service
|
||||
|
||||
// Show the result: success or fail notification
|
||||
if (!uploadResult.isCancelled() &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_WIFI)) {
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_WIFI) &&
|
||||
!uploadResult.getCode().equals(ResultCode.DELAYED_FOR_CHARGING)) {
|
||||
|
||||
int tickerId = (uploadResult.isSuccess()) ? R.string.uploader_upload_succeeded_ticker :
|
||||
R.string.uploader_upload_failed_ticker;
|
||||
|
||||
@@ -300,6 +300,12 @@ public class UploadFileOperation extends SyncOperation {
|
||||
return new RemoteOperationResult(ResultCode.DELAYED_FOR_WIFI);
|
||||
}
|
||||
|
||||
// Check if charging conditions are met and delays the upload otherwise
|
||||
if (delayForCharging()){
|
||||
Log_OC.d(TAG, "Upload delayed until the device is charging: " + getRemotePath());
|
||||
return new RemoteOperationResult(ResultCode.DELAYED_FOR_CHARGING);
|
||||
}
|
||||
|
||||
/// check if the file continues existing before schedule the operation
|
||||
if (!originalFile.exists()) {
|
||||
Log_OC.d(TAG, mOriginalStoragePath.toString() + " not exists anymore");
|
||||
@@ -391,6 +397,8 @@ public class UploadFileOperation extends SyncOperation {
|
||||
}
|
||||
mFile.setStoragePath("");
|
||||
|
||||
} else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_DELETE) {
|
||||
originalFile.delete();
|
||||
} else {
|
||||
mFile.setStoragePath(expectedPath);
|
||||
|
||||
@@ -468,6 +476,22 @@ public class UploadFileOperation extends SyncOperation {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if upload should be delayed due to not charging
|
||||
*
|
||||
* @return 'True' if the upload was delayed until device is charging, 'false' otherwise.
|
||||
*/
|
||||
private boolean delayForCharging() {
|
||||
boolean delayInstantPicture = isInstantPicture() &&
|
||||
PreferenceManager.instantPictureUploadWhenChargingOnly(mContext);
|
||||
|
||||
boolean delayInstantVideo = isInstantVideo() &&
|
||||
PreferenceManager.instantVideoUploadViaWiFiOnly(mContext);
|
||||
|
||||
return ((delayInstantPicture || delayInstantVideo)
|
||||
&& !ConnectivityUtils.isCharging(mContext));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks the existence of the folder where the current file will be uploaded both
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class PreferenceWithTwoLineLongSummary extends Preference{
|
||||
|
||||
public PreferenceWithTwoLineLongSummary(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public PreferenceWithTwoLineLongSummary(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
public PreferenceWithTwoLineLongSummary(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindView(View view) {
|
||||
super.onBindView(view);
|
||||
TextView titleView = (TextView) view.findViewById(android.R.id.summary);
|
||||
titleView.setSingleLine(false);
|
||||
titleView.setMaxLines(2);
|
||||
titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.files.FileOperationsHelper;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
||||
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* Copyright (C) 2016 Andy Scherzinger
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
* Copyright (C) 2016 Nextcloud.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
@@ -553,8 +552,8 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||
|
||||
mQuotaTextView.setText(String.format(
|
||||
getString(R.string.drawer_quota),
|
||||
DisplayUtils.bytesToHumanReadable(usedSpace),
|
||||
DisplayUtils.bytesToHumanReadable(totalSpace)));
|
||||
DisplayUtils.quotaBytesToHumanReadable(usedSpace),
|
||||
DisplayUtils.quotaBytesToHumanReadable(totalSpace)));
|
||||
|
||||
showQuota(true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.LoadingDialog;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
|
||||
public class ErrorReportActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = ErrorReportActivity.class.getSimpleName();
|
||||
|
||||
private String mLogText;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.error_send);
|
||||
setTitle(getString(R.string.error_log_title));
|
||||
Button cancelErrorLogButton = (Button) findViewById(R.id.cancelErrorLogButton);
|
||||
Button sendErrorLogButton = (Button) findViewById(R.id.sendErrorLogButton);
|
||||
TextView logTV = (TextView) findViewById(R.id.logTV);
|
||||
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getAction();
|
||||
String type = intent.getType();
|
||||
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
mLogText = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||
} else {
|
||||
// Handle other intents, such as being started from the home screen
|
||||
mLogText = "Error, nothing received!";
|
||||
}
|
||||
|
||||
logTV.setText(mLogText);
|
||||
|
||||
cancelErrorLogButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finishAffinity();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
sendErrorLogButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sendMail();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Start activity for sending email with logs attached
|
||||
*/
|
||||
private void sendMail() {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, mLogText);
|
||||
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
sendIntent.setType("text/plain");
|
||||
startActivity(sendIntent);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.files.FileOperationsHelper;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
|
||||
@@ -654,12 +654,16 @@ public class FileDisplayActivity extends HookActivity
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
if (requestCode == REQUEST_CODE__SELECT_CONTENT_FROM_APPS &&
|
||||
(resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
|
||||
(resultCode == RESULT_OK ||
|
||||
resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
|
||||
|
||||
requestUploadOfContentFromApps(data, resultCode);
|
||||
|
||||
} else if (requestCode == REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM &&
|
||||
(resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
|
||||
(resultCode == RESULT_OK ||
|
||||
resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE ||
|
||||
resultCode == UploadFilesActivity.RESULT_OK_AND_DO_NOTHING ||
|
||||
resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
|
||||
|
||||
requestUploadOfFilesFromFileSystem(data, resultCode);
|
||||
|
||||
@@ -704,8 +708,23 @@ public class FileDisplayActivity extends HookActivity
|
||||
remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName();
|
||||
}
|
||||
|
||||
int behaviour = (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) ? FileUploader
|
||||
.LOCAL_BEHAVIOUR_MOVE : FileUploader.LOCAL_BEHAVIOUR_COPY;
|
||||
// default, as fallback
|
||||
int behaviour = FileUploader.LOCAL_BEHAVIOUR_FORGET;
|
||||
|
||||
switch (resultCode) {
|
||||
case UploadFilesActivity.RESULT_OK_AND_MOVE:
|
||||
behaviour = FileUploader.LOCAL_BEHAVIOUR_MOVE;
|
||||
break;
|
||||
|
||||
case UploadFilesActivity.RESULT_OK_AND_DELETE:
|
||||
behaviour = FileUploader.LOCAL_BEHAVIOUR_DELETE;
|
||||
break;
|
||||
|
||||
case UploadFilesActivity.RESULT_OK_AND_DO_NOTHING:
|
||||
behaviour = FileUploader.LOCAL_BEHAVIOUR_FORGET;
|
||||
break;
|
||||
}
|
||||
|
||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||
requester.uploadNewFile(
|
||||
this,
|
||||
@@ -1640,7 +1659,7 @@ public class FileDisplayActivity extends HookActivity
|
||||
// another window floating over
|
||||
}
|
||||
},
|
||||
DELAY_TO_REQUEST_REFRESH_OPERATION_LATER
|
||||
DELAY_TO_REQUEST_OPERATIONS_LATER + 350
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
||||
/**
|
||||
* Created by Bartosz Przybylski on 07.11.2015.
|
||||
*/
|
||||
public class LocalDirectorySelectorActivity extends UploadFilesActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mUploadBtn.setText(R.string.folder_picker_choose_button_text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.upload_files_btn_cancel) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
|
||||
} else if (v.getId() == R.id.upload_files_btn_upload) {
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra(EXTRA_CHOSEN_FILES, getInitialDirectory().getAbsolutePath());
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,13 +45,13 @@ import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.authentication.AuthenticatorActivity;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.files.FileOperationsHelper;
|
||||
import com.owncloud.android.files.services.FileDownloader;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.services.OperationsService;
|
||||
import com.owncloud.android.ui.adapter.AccountListAdapter;
|
||||
import com.owncloud.android.ui.adapter.AccountListItem;
|
||||
import com.owncloud.android.ui.helpers.FileOperationsHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2011 Bartek Przybylski
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
@@ -21,15 +22,17 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
@@ -49,12 +52,24 @@ import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.owncloud.android.BuildConfig;
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.datastorage.DataStorageProvider;
|
||||
import com.owncloud.android.datastorage.StoragePoint;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.PreferenceWithTwoLineLongSummary;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
||||
/**
|
||||
* An Activity that allows the user to change the application's settings.
|
||||
@@ -62,7 +77,8 @@ import com.owncloud.android.utils.DisplayUtils;
|
||||
* It proxies the necessary calls via {@link android.support.v7.app.AppCompatDelegate} to be used
|
||||
* with AppCompat.
|
||||
*/
|
||||
public class Preferences extends PreferenceActivity {
|
||||
public class Preferences extends PreferenceActivity
|
||||
implements StorageMigration.StorageMigrationProgressListener {
|
||||
|
||||
private static final String TAG = Preferences.class.getSimpleName();
|
||||
|
||||
@@ -71,23 +87,56 @@ public class Preferences extends PreferenceActivity {
|
||||
private static final int ACTION_REQUEST_PASSCODE = 5;
|
||||
private static final int ACTION_CONFIRM_PASSCODE = 6;
|
||||
|
||||
public static final String INSTANT_UPLOAD_PATH_ACCOUNT = "instant_upload_path_account";
|
||||
public static final String INSTANT_UPLOAD_PATH = "instant_upload_path";
|
||||
public static final String INSTANT_VIDEO_UPLOAD_PATH = "instant_video_upload_path";
|
||||
public static final String INSTANT_VIDEO_UPLOAD_PATH_ACCOUNT = "instant_video_upload_path_account";
|
||||
public static final String INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS = "instant_video_upload_path_use_subfolders";
|
||||
public static final String INSTANT_VIDEO_UPLOAD_ON_WIFI = "instant_video_upload_on_wifi";
|
||||
public static final String INSTANT_VIDEO_UPLOADING = "instant_video_uploading";
|
||||
public static final String PREFS_INSTANT_BEHAVIOUR = "prefs_instant_behaviour";
|
||||
public static final String ABOUT_APP = "about_app";
|
||||
public static final String INSTANT_UPLOADING_CATEGORY = "instant_uploading_category";
|
||||
public static final String INSTANT_UPLOAD_PATH_USE_SUBFOLDERS = "instant_upload_path_use_subfolders";
|
||||
public static final String INSTANT_UPLOAD_ON_WIFI = "instant_upload_on_wifi";
|
||||
public static final String INSTANT_UPLOADING = "instant_uploading";
|
||||
public static final String LOGGER = "logger";
|
||||
public static final String FEEDBACK = "feedback";
|
||||
public static final String RECOMMEND = "recommend";
|
||||
public static final String MORE = "more";
|
||||
public static final String HELP = "help";
|
||||
|
||||
private static String INSTANT_UPLOAD_ACCOUNT_LABEL;
|
||||
private static String INSTANT_UPLOAD_PATH_LABEL;
|
||||
|
||||
private CheckBoxPreference pCode;
|
||||
private Preference pAboutApp;
|
||||
private AppCompatDelegate mDelegate;
|
||||
|
||||
private PreferenceCategory mAccountsPrefCategory = null;
|
||||
private String mUploadPath;
|
||||
private String mUploadPathAccount;
|
||||
private PreferenceCategory mPrefInstantUploadCategory;
|
||||
private Preference mPrefInstantUpload;
|
||||
private Preference mPrefInstantUploadBehaviour;
|
||||
private Preference mPrefInstantUploadPath;
|
||||
private Preference mPrefInstantUploadUseSubfolders;
|
||||
private Preference mPrefInstantPictureUploadOnlyOnCharging;
|
||||
private Preference mPrefInstantUploadPathWiFi;
|
||||
private Preference mPrefInstantVideoUpload;
|
||||
private Preference mPrefInstantVideoUploadPath;
|
||||
private Preference mPrefInstantVideoUploadUseSubfolders;
|
||||
private Preference mPrefInstantVideoUploadPathWiFi;
|
||||
private Preference mPrefInstantVideoUploadOnlyOnCharging;
|
||||
private String mUploadVideoPath;
|
||||
private String mUploadVideoPathAccount;
|
||||
private ListPreference mPrefStoragePath;
|
||||
private String mStoragePath;
|
||||
|
||||
public static class Keys {
|
||||
public static final String STORAGE_PATH = "storage_path";
|
||||
public static final String INSTANT_UPLOAD_PATH = "instant_upload_path";
|
||||
public static final String INSTANT_VIDEO_UPLOAD_PATH = "instant_video_upload_path";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
@@ -108,7 +157,6 @@ public class Preferences extends PreferenceActivity {
|
||||
getWindow().getDecorView().findViewById(actionBarTitleId).
|
||||
setContentDescription(getString(R.string.actionbar_settings));
|
||||
}
|
||||
|
||||
// Load package info
|
||||
String temp;
|
||||
try {
|
||||
@@ -117,9 +165,9 @@ public class Preferences extends PreferenceActivity {
|
||||
} catch (NameNotFoundException e) {
|
||||
temp = "";
|
||||
Log_OC.e(TAG, "Error while showing about dialog", e);
|
||||
}
|
||||
}
|
||||
final String appVersion = temp;
|
||||
|
||||
|
||||
// Register context menu for list of preferences.
|
||||
registerForContextMenu(getListView());
|
||||
|
||||
@@ -145,10 +193,31 @@ public class Preferences extends PreferenceActivity {
|
||||
});
|
||||
}
|
||||
|
||||
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more");
|
||||
|
||||
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(MORE);
|
||||
|
||||
final Preference pCacheSize = findPreference("pref_cache_size");
|
||||
if (pCacheSize != null){
|
||||
final SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
Long cacheSize = ThumbnailsCacheManager.getMaxSize();
|
||||
pCacheSize.setSummary(cacheSize + " Mb");
|
||||
pCacheSize.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
int size = Integer.decode((String) newValue);
|
||||
if (ThumbnailsCacheManager.setMaxSize(size)){
|
||||
appPrefs.edit().putInt("pref_cache_size", size);
|
||||
pCacheSize.setSummary(size + " MB");
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled);
|
||||
Preference pHelp = findPreference("help");
|
||||
Preference pHelp = findPreference(HELP);
|
||||
if (pHelp != null ){
|
||||
if (helpEnabled) {
|
||||
pHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@@ -167,20 +236,20 @@ public class Preferences extends PreferenceActivity {
|
||||
preferenceCategory.removePreference(pHelp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
|
||||
Preference pRecommend = findPreference("recommend");
|
||||
Preference pRecommend = findPreference(RECOMMEND);
|
||||
if (pRecommend != null){
|
||||
if (recommendEnabled) {
|
||||
pRecommend.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||
intent.setType("text/plain");
|
||||
intent.setData(Uri.parse(getString(R.string.mail_recommend)));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
intent.setData(Uri.parse(getString(R.string.mail_recommend)));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
String appName = getString(R.string.app_name);
|
||||
String downloadUrl = getString(R.string.url_app_download);
|
||||
|
||||
@@ -189,12 +258,12 @@ public class Preferences extends PreferenceActivity {
|
||||
appName);
|
||||
String recommendText = String.format(getString(R.string.recommend_text),
|
||||
appName, downloadUrl);
|
||||
|
||||
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
|
||||
intent.putExtra(Intent.EXTRA_TEXT, recommendText);
|
||||
startActivity(intent);
|
||||
|
||||
return(true);
|
||||
return true;
|
||||
|
||||
}
|
||||
});
|
||||
@@ -202,9 +271,9 @@ public class Preferences extends PreferenceActivity {
|
||||
preferenceCategory.removePreference(pRecommend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean feedbackEnabled = getResources().getBoolean(R.bool.feedback_enabled);
|
||||
Preference pFeedback = findPreference("feedback");
|
||||
Preference pFeedback = findPreference(FEEDBACK);
|
||||
if (pFeedback != null){
|
||||
if (feedbackEnabled) {
|
||||
pFeedback.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@@ -216,11 +285,11 @@ public class Preferences extends PreferenceActivity {
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
|
||||
|
||||
intent.setData(Uri.parse(feedbackMail));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
intent.setData(Uri.parse(feedbackMail));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -230,7 +299,7 @@ public class Preferences extends PreferenceActivity {
|
||||
}
|
||||
|
||||
boolean loggerEnabled = getResources().getBoolean(R.bool.logger_enabled) || BuildConfig.DEBUG;
|
||||
Preference pLogger = findPreference("logger");
|
||||
Preference pLogger = findPreference(LOGGER);
|
||||
if (pLogger != null){
|
||||
if (loggerEnabled) {
|
||||
pLogger.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@@ -269,7 +338,38 @@ public class Preferences extends PreferenceActivity {
|
||||
}
|
||||
}
|
||||
|
||||
mPrefInstantUploadPath = findPreference("instant_upload_path");
|
||||
mPrefStoragePath = (ListPreference) findPreference(Keys.STORAGE_PATH);
|
||||
if (mPrefStoragePath != null) {
|
||||
StoragePoint[] storageOptions = DataStorageProvider.getInstance().getAvailableStoragePoints();
|
||||
String[] entries = new String[storageOptions.length];
|
||||
String[] values = new String[storageOptions.length];
|
||||
for (int i = 0; i < storageOptions.length; ++i) {
|
||||
entries[i] = storageOptions[i].getDescription();
|
||||
values[i] = storageOptions[i].getPath();
|
||||
}
|
||||
mPrefStoragePath.setEntries(entries);
|
||||
mPrefStoragePath.setEntryValues(values);
|
||||
|
||||
mPrefStoragePath.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String newPath = (String)newValue;
|
||||
if (mStoragePath.equals(newPath))
|
||||
return true;
|
||||
|
||||
StorageMigration storageMigration = new StorageMigration(Preferences.this, mStoragePath, newPath);
|
||||
|
||||
storageMigration.setStorageMigrationProgressListener(Preferences.this);
|
||||
|
||||
storageMigration.migrate();
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
mPrefInstantUploadPath = (PreferenceWithTwoLineLongSummary)findPreference(Keys.INSTANT_UPLOAD_PATH);
|
||||
if (mPrefInstantUploadPath != null){
|
||||
|
||||
mPrefInstantUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@@ -285,18 +385,19 @@ public class Preferences extends PreferenceActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mPrefInstantUploadCategory =
|
||||
(PreferenceCategory) findPreference("instant_uploading_category");
|
||||
|
||||
mPrefInstantUploadUseSubfolders = findPreference("instant_upload_path_use_subfolders");
|
||||
mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi");
|
||||
mPrefInstantUpload = findPreference("instant_uploading");
|
||||
mPrefInstantUploadCategory =
|
||||
(PreferenceCategory) findPreference(INSTANT_UPLOADING_CATEGORY);
|
||||
|
||||
mPrefInstantUploadUseSubfolders = findPreference(INSTANT_UPLOAD_PATH_USE_SUBFOLDERS);
|
||||
mPrefInstantUploadPathWiFi = findPreference(INSTANT_UPLOAD_ON_WIFI);
|
||||
mPrefInstantUpload = findPreference(INSTANT_UPLOADING);
|
||||
mPrefInstantPictureUploadOnlyOnCharging = findPreference("instant_upload_on_charging");
|
||||
|
||||
toggleInstantPictureOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked());
|
||||
|
||||
|
||||
mPrefInstantUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
toggleInstantPictureOptions((Boolean) newValue);
|
||||
@@ -306,8 +407,8 @@ public class Preferences extends PreferenceActivity {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
mPrefInstantVideoUploadPath = findPreference("instant_video_upload_path");
|
||||
|
||||
mPrefInstantVideoUploadPath = findPreference(Keys.INSTANT_VIDEO_UPLOAD_PATH);
|
||||
if (mPrefInstantVideoUploadPath != null){
|
||||
|
||||
mPrefInstantVideoUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@@ -325,11 +426,12 @@ public class Preferences extends PreferenceActivity {
|
||||
});
|
||||
}
|
||||
|
||||
mPrefInstantVideoUploadUseSubfolders = findPreference("instant_video_upload_path_use_subfolders");
|
||||
mPrefInstantVideoUploadPathWiFi = findPreference("instant_video_upload_on_wifi");
|
||||
mPrefInstantVideoUpload = findPreference("instant_video_uploading");
|
||||
mPrefInstantVideoUploadUseSubfolders = findPreference(INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS);
|
||||
mPrefInstantVideoUploadPathWiFi = findPreference(INSTANT_VIDEO_UPLOAD_ON_WIFI);
|
||||
mPrefInstantVideoUpload = findPreference(INSTANT_VIDEO_UPLOADING);
|
||||
mPrefInstantVideoUploadOnlyOnCharging = findPreference("instant_video_upload_on_charging");
|
||||
toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked());
|
||||
|
||||
|
||||
mPrefInstantVideoUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
|
||||
@Override
|
||||
@@ -342,44 +444,120 @@ public class Preferences extends PreferenceActivity {
|
||||
}
|
||||
});
|
||||
|
||||
mPrefInstantUploadBehaviour = findPreference("prefs_instant_behaviour");
|
||||
mPrefInstantUploadBehaviour = findPreference(PREFS_INSTANT_BEHAVIOUR);
|
||||
toggleInstantUploadBehaviour(
|
||||
((CheckBoxPreference)mPrefInstantVideoUpload).isChecked(),
|
||||
((CheckBoxPreference)mPrefInstantUpload).isChecked());
|
||||
|
||||
/* About App */
|
||||
pAboutApp = (Preference) findPreference("about_app");
|
||||
pAboutApp = (Preference) findPreference(ABOUT_APP);
|
||||
if (pAboutApp != null) {
|
||||
pAboutApp.setTitle(String.format(getString(R.string.about_android),
|
||||
getString(R.string.app_name)));
|
||||
pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));
|
||||
try {
|
||||
Integer currentVersion = getPackageManager().getPackageInfo
|
||||
(getPackageName(), 0).versionCode;
|
||||
pAboutApp.setSummary(String.format(getString(R.string.about_version),
|
||||
currentVersion));
|
||||
} catch (NameNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANT_UPLOAD_ACCOUNT_LABEL = getResources().getString(R.string.prefs_instant_upload_account);
|
||||
INSTANT_UPLOAD_PATH_LABEL = getResources().getString(R.string.prefs_instant_upload_path);
|
||||
|
||||
INSTANT_UPLOAD_ACCOUNT_LABEL = getResources().getString(R.string.prefs_instant_upload_account);
|
||||
INSTANT_UPLOAD_PATH_LABEL = getResources().getString(R.string.prefs_instant_upload_path);
|
||||
|
||||
loadInstantUploadPath();
|
||||
loadStoragePath();
|
||||
loadInstantUploadVideoPath();
|
||||
/* Link to Beta apks */
|
||||
Preference pBetaLink = findPreference("beta_link");
|
||||
if (pBetaLink != null ){
|
||||
pBetaLink.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Integer latestVersion = -1;
|
||||
Integer currentVersion = -1;
|
||||
try {
|
||||
currentVersion = getPackageManager().getPackageInfo
|
||||
(getPackageName(), 0).versionCode;
|
||||
LoadingVersionNumberTask loadTask = new LoadingVersionNumberTask();
|
||||
loadTask.execute();
|
||||
latestVersion = loadTask.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (latestVersion == -1 || currentVersion == -1) {
|
||||
Toast.makeText(getApplicationContext(), "No information available!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if (latestVersion > currentVersion) {
|
||||
String betaLinkWeb = (String) getText(R.string.beta_link) +
|
||||
latestVersion + ".apk";
|
||||
if (betaLinkWeb != null && betaLinkWeb.length() > 0) {
|
||||
Uri uriUrl = Uri.parse(betaLinkWeb);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "No new version available!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Link to beta changelog */
|
||||
Preference pChangelogLink = findPreference("changelog_link");
|
||||
if (pChangelogLink != null) {
|
||||
pChangelogLink.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String betaLinkWeb = getString(R.string.changelog);
|
||||
if (betaLinkWeb != null && betaLinkWeb.length() > 0) {
|
||||
Uri uriUrl = Uri.parse(betaLinkWeb);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void toggleInstantPictureOptions(Boolean value){
|
||||
if (value){
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi);
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath);
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantUploadUseSubfolders);
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantPictureUploadOnlyOnCharging);
|
||||
} else {
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi);
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath);
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantUploadUseSubfolders);
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantPictureUploadOnlyOnCharging);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void toggleInstantVideoOptions(Boolean value){
|
||||
if (value){
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi);
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath);
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadUseSubfolders);
|
||||
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadOnlyOnCharging);
|
||||
} else {
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi);
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath);
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadUseSubfolders);
|
||||
mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadOnlyOnCharging);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,29 +608,31 @@ public class Preferences extends PreferenceActivity {
|
||||
|
||||
if (requestCode == ACTION_SELECT_UPLOAD_PATH && resultCode == RESULT_OK){
|
||||
|
||||
OCFile folderToUpload =
|
||||
(OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
|
||||
OCFile folderToUpload = data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
|
||||
|
||||
mUploadPath = folderToUpload.getRemotePath();
|
||||
|
||||
mUploadPath = DisplayUtils.getPathWithoutLastSlash(mUploadPath);
|
||||
|
||||
mUploadPathAccount = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext()).name;
|
||||
|
||||
// Show the path on summary preference
|
||||
mPrefInstantUploadPath.setSummary(mUploadPath);
|
||||
mPrefInstantUploadPath.setSummary(getUploadAccountPath(mUploadPathAccount, mUploadPath));
|
||||
|
||||
saveInstantUploadPathOnPreferences();
|
||||
|
||||
} else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && resultCode == RESULT_OK){
|
||||
} else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && resultCode == RESULT_OK) {
|
||||
|
||||
OCFile folderToUploadVideo =
|
||||
(OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
|
||||
OCFile folderToUploadVideo = data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
|
||||
|
||||
mUploadVideoPath = folderToUploadVideo.getRemotePath();
|
||||
|
||||
mUploadVideoPath = DisplayUtils.getPathWithoutLastSlash(mUploadVideoPath);
|
||||
|
||||
mUploadVideoPathAccount = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext()).name;
|
||||
|
||||
// Show the video path on summary preference
|
||||
mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath);
|
||||
mPrefInstantVideoUploadPath.setSummary(getUploadAccountPath(mUploadVideoPathAccount, mUploadVideoPath));
|
||||
|
||||
saveInstantUploadVideoPathOnPreferences();
|
||||
} else if (requestCode == ACTION_REQUEST_PASSCODE && resultCode == RESULT_OK) {
|
||||
@@ -559,24 +739,64 @@ public class Preferences extends PreferenceActivity {
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a combined string of accountName and uploadPath to be displayed to user.
|
||||
*/
|
||||
private String getUploadAccountPath(String accountName, String uploadPath) {
|
||||
return INSTANT_UPLOAD_ACCOUNT_LABEL + ": " + accountName + "\n"
|
||||
+ INSTANT_UPLOAD_PATH_LABEL + ": " + uploadPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load upload path set on preferences
|
||||
*/
|
||||
private void loadInstantUploadPath() {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
mUploadPath = appPrefs.getString("instant_upload_path", getString(R.string.instant_upload_path));
|
||||
mPrefInstantUploadPath.setSummary(mUploadPath);
|
||||
mUploadPath = appPrefs.getString(INSTANT_UPLOAD_PATH, getString(R.string.instant_upload_path));
|
||||
mUploadPathAccount = appPrefs.getString(INSTANT_UPLOAD_PATH_ACCOUNT,
|
||||
AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext()).name);
|
||||
mPrefInstantUploadPath.setSummary(getUploadAccountPath(mUploadPathAccount, mUploadPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the "Instant Upload Path" on preferences
|
||||
* Save storage path
|
||||
*/
|
||||
private void saveStoragePath(String newStoragePath) {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
mStoragePath = newStoragePath;
|
||||
MainApp.setStoragePath(mStoragePath);
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putString(Keys.STORAGE_PATH, mStoragePath);
|
||||
editor.commit();
|
||||
String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(mStoragePath);
|
||||
mPrefStoragePath.setSummary(storageDescription);
|
||||
mPrefStoragePath.setValue(newStoragePath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load storage path set on preferences
|
||||
*/
|
||||
private void loadStoragePath() {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
mStoragePath = appPrefs.getString(Keys.STORAGE_PATH, Environment.getExternalStorageDirectory()
|
||||
.getAbsolutePath());
|
||||
String storageDescription = DataStorageProvider.getInstance().getStorageDescriptionByPath(mStoragePath);
|
||||
mPrefStoragePath.setSummary(storageDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the "Instant Upload Path" and corresponding account on preferences
|
||||
*/
|
||||
private void saveInstantUploadPathOnPreferences() {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putString("instant_upload_path", mUploadPath);
|
||||
editor.putString(INSTANT_UPLOAD_PATH, mUploadPath)
|
||||
.putString(INSTANT_UPLOAD_PATH_ACCOUNT, mUploadPathAccount);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
@@ -586,18 +806,58 @@ public class Preferences extends PreferenceActivity {
|
||||
private void loadInstantUploadVideoPath() {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
mUploadVideoPath = appPrefs.getString("instant_video_upload_path", getString(R.string.instant_upload_path));
|
||||
mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath);
|
||||
mUploadVideoPath = appPrefs.getString(INSTANT_VIDEO_UPLOAD_PATH, getString(R.string.instant_upload_path));
|
||||
mUploadVideoPathAccount = appPrefs.getString(INSTANT_VIDEO_UPLOAD_PATH_ACCOUNT,
|
||||
AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext()).name);
|
||||
mPrefInstantVideoUploadPath.setSummary(getUploadAccountPath(mUploadVideoPathAccount, mUploadVideoPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the "Instant Video Upload Path" on preferences
|
||||
* Save the "Instant Video Upload Path" and corresponding account on preferences
|
||||
*/
|
||||
private void saveInstantUploadVideoPathOnPreferences() {
|
||||
SharedPreferences appPrefs =
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
SharedPreferences.Editor editor = appPrefs.edit();
|
||||
editor.putString("instant_video_upload_path", mUploadVideoPath);
|
||||
editor.putString(INSTANT_VIDEO_UPLOAD_PATH, mUploadVideoPath)
|
||||
.putString(INSTANT_VIDEO_UPLOAD_PATH_ACCOUNT, mUploadVideoPathAccount);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStorageMigrationFinished(String storagePath, boolean succeed) {
|
||||
if (succeed)
|
||||
saveStoragePath(storagePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelMigration() {
|
||||
// Migration was canceled so we don't do anything
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Class for loading the version number
|
||||
*
|
||||
*/
|
||||
private class LoadingVersionNumberTask extends AsyncTask<Void, Void, Integer> {
|
||||
protected Integer doInBackground(Void... args) {
|
||||
try {
|
||||
URL url = new URL(getString(R.string.beta_latest));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
|
||||
Integer latestVersion = Integer.parseInt(in.readLine());
|
||||
in.close();
|
||||
|
||||
return latestVersion;
|
||||
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,9 +42,8 @@ import com.owncloud.android.operations.CreateShareViaLinkOperation;
|
||||
import com.owncloud.android.operations.GetSharesForFileOperation;
|
||||
import com.owncloud.android.operations.UnshareOperation;
|
||||
import com.owncloud.android.operations.UpdateSharePermissionsOperation;
|
||||
import com.owncloud.android.providers.UsersAndGroupsSearchProvider;
|
||||
import org.nextcloud.providers.UsersAndGroupsSearchProvider;
|
||||
import com.owncloud.android.ui.dialog.ShareLinkToDialog;
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
|
||||
import com.owncloud.android.ui.fragment.EditShareFragment;
|
||||
import com.owncloud.android.ui.fragment.SearchShareesFragment;
|
||||
import com.owncloud.android.ui.fragment.ShareFileFragment;
|
||||
@@ -289,7 +288,18 @@ public class ShareActivity extends FileActivity
|
||||
|
||||
// Create dialog to allow the user choose an app to send the link
|
||||
Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
|
||||
String link = ((OCShare) (result.getData().get(0))).getShareLink();
|
||||
|
||||
// if share to user and share via link multiple ocshares are returned,
|
||||
// therefore filtering for public_link
|
||||
String link = "";
|
||||
for (Object object : result.getData()) {
|
||||
OCShare shareLink = (OCShare) object;
|
||||
if (shareLink.getShareType().name().equalsIgnoreCase("PUBLIC_LINK")) {
|
||||
link = shareLink.getShareLink();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
|
||||
intentToShareLink.setType("text/plain");
|
||||
String username = AccountUtils.getUsernameForAccount(getAccount());
|
||||
|
||||
@@ -0,0 +1,424 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Bartosz Przybylski
|
||||
* Copyright (C) 2016 Bartosz Przybylski
|
||||
* Copyright (C) 2016 Nextcloud
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Bartosz Przybylski
|
||||
*/
|
||||
public class StorageMigration {
|
||||
private static final String TAG = StorageMigration.class.getName();
|
||||
|
||||
public interface StorageMigrationProgressListener {
|
||||
void onStorageMigrationFinished(String storagePath, boolean succeed);
|
||||
void onCancelMigration();
|
||||
}
|
||||
|
||||
private ProgressDialog mProgressDialog;
|
||||
private Context mContext;
|
||||
private String mSourceStoragePath;
|
||||
private String mTargetStoragePath;
|
||||
|
||||
private StorageMigrationProgressListener mListener;
|
||||
|
||||
public StorageMigration(Context context, String sourcePath, String targetPath) {
|
||||
mContext = context;
|
||||
mSourceStoragePath = sourcePath;
|
||||
mTargetStoragePath = targetPath;
|
||||
}
|
||||
|
||||
public void setStorageMigrationProgressListener(StorageMigrationProgressListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public void migrate() {
|
||||
if (storageFolderAlreadyExists())
|
||||
askToOverride();
|
||||
else {
|
||||
ProgressDialog progressDialog = createMigrationProgressDialog();
|
||||
progressDialog.show();
|
||||
new FileMigrationTask(
|
||||
mContext,
|
||||
mSourceStoragePath,
|
||||
mTargetStoragePath,
|
||||
progressDialog,
|
||||
mListener).execute();
|
||||
|
||||
progressDialog.getButton(progressDialog.BUTTON_POSITIVE).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean storageFolderAlreadyExists() {
|
||||
File f = new File(mTargetStoragePath, MainApp.getDataFolder());
|
||||
return f.exists() && f.isDirectory();
|
||||
}
|
||||
|
||||
private void askToOverride() {
|
||||
|
||||
new AlertDialog.Builder(mContext)
|
||||
.setMessage(R.string.file_migration_directory_already_exists)
|
||||
.setCancelable(true)
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialogInterface) {
|
||||
if (mListener != null)
|
||||
mListener.onCancelMigration();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.common_cancel, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (mListener != null)
|
||||
mListener.onCancelMigration();
|
||||
}
|
||||
})
|
||||
.setNeutralButton(R.string.file_migration_use_data_folder, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ProgressDialog progressDialog = createMigrationProgressDialog();
|
||||
progressDialog.show();
|
||||
new StoragePathSwitchTask(
|
||||
mContext,
|
||||
mSourceStoragePath,
|
||||
mTargetStoragePath,
|
||||
progressDialog,
|
||||
mListener).execute();
|
||||
|
||||
progressDialog.getButton(ProgressDialog.BUTTON_POSITIVE).setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.file_migration_override_data_folder, new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
ProgressDialog progressDialog = createMigrationProgressDialog();
|
||||
progressDialog.show();
|
||||
new FileMigrationTask(
|
||||
mContext,
|
||||
mSourceStoragePath,
|
||||
mTargetStoragePath,
|
||||
progressDialog,
|
||||
mListener).execute();
|
||||
|
||||
progressDialog.getButton(ProgressDialog.BUTTON_POSITIVE).setVisibility(View.GONE);
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private ProgressDialog createMigrationProgressDialog() {
|
||||
ProgressDialog progressDialog = new ProgressDialog(mContext);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setTitle(R.string.file_migration_dialog_title);
|
||||
progressDialog.setMessage(mContext.getString(R.string.file_migration_preparing));
|
||||
progressDialog.setButton(
|
||||
ProgressDialog.BUTTON_POSITIVE,
|
||||
mContext.getString(R.string.drawer_close),
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
return progressDialog;
|
||||
}
|
||||
|
||||
abstract static private class FileMigrationTaskBase extends AsyncTask<Void, Integer, Integer> {
|
||||
protected String mStorageSource;
|
||||
protected String mStorageTarget;
|
||||
protected Context mContext;
|
||||
protected ProgressDialog mProgressDialog;
|
||||
protected StorageMigrationProgressListener mListener;
|
||||
|
||||
protected String mAuthority;
|
||||
protected Account[] mOcAccounts;
|
||||
|
||||
public FileMigrationTaskBase(Context context,
|
||||
String source,
|
||||
String target,
|
||||
ProgressDialog progressDialog,
|
||||
StorageMigrationProgressListener listener) {
|
||||
mContext = context;
|
||||
mStorageSource = source;
|
||||
mStorageTarget = target;
|
||||
mProgressDialog = progressDialog;
|
||||
mListener = listener;
|
||||
|
||||
mAuthority = mContext.getString(R.string.authority);
|
||||
mOcAccounts = AccountManager.get(mContext).getAccountsByType(MainApp.getAccountType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Integer... progress) {
|
||||
if (progress.length > 1 && progress[0] != 0) {
|
||||
mProgressDialog.setMessage(mContext.getString(progress[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Integer code) {
|
||||
if (code != 0) {
|
||||
mProgressDialog.setMessage(mContext.getString(code));
|
||||
} else {
|
||||
mProgressDialog.setMessage(mContext.getString(R.string.file_migration_ok_finished));
|
||||
}
|
||||
|
||||
boolean succeed = code == 0;
|
||||
if (succeed) {
|
||||
mProgressDialog.hide();
|
||||
} else {
|
||||
mProgressDialog.getButton(ProgressDialog.BUTTON_POSITIVE).setVisibility(View.VISIBLE);
|
||||
mProgressDialog.setIndeterminateDrawable(mContext.getResources().getDrawable(R.drawable.image_fail));
|
||||
}
|
||||
|
||||
if (mListener != null) {
|
||||
mListener.onStorageMigrationFinished(succeed ? mStorageTarget : mStorageSource, succeed);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean[] saveAccountsSyncStatus() {
|
||||
boolean[] syncs = new boolean[mOcAccounts.length];
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
syncs[i] = ContentResolver.getSyncAutomatically(mOcAccounts[i], mAuthority);
|
||||
}
|
||||
return syncs;
|
||||
}
|
||||
|
||||
protected void stopAccountsSyncing() {
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
ContentResolver.setSyncAutomatically(mOcAccounts[i], mAuthority, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void waitForUnfinishedSynchronizations() {
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
while (ContentResolver.isSyncActive(mOcAccounts[i], mAuthority)) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
Log_OC.w(TAG, "Thread interrupted while waiting for account to end syncing");
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void restoreAccountsSyncStatus(boolean oldSync[]) {
|
||||
for (int i = 0; i < mOcAccounts.length; ++i) {
|
||||
ContentResolver.setSyncAutomatically(mOcAccounts[i], mAuthority, oldSync[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static private class StoragePathSwitchTask extends FileMigrationTaskBase {
|
||||
|
||||
public StoragePathSwitchTask(Context context,
|
||||
String source,
|
||||
String target,
|
||||
ProgressDialog progressDialog,
|
||||
StorageMigrationProgressListener listener) {
|
||||
super(context, source, target, progressDialog, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(Void... voids) {
|
||||
publishProgress(R.string.file_migration_preparing);
|
||||
|
||||
Log_OC.stopLogging();
|
||||
boolean[] syncStates = new boolean[0];
|
||||
try {
|
||||
publishProgress(R.string.file_migration_saving_accounts_configuration);
|
||||
syncStates = saveAccountsSyncStatus();
|
||||
|
||||
publishProgress(R.string.file_migration_waiting_for_unfinished_sync);
|
||||
stopAccountsSyncing();
|
||||
waitForUnfinishedSynchronizations();
|
||||
} finally {
|
||||
publishProgress(R.string.file_migration_restoring_accounts_configuration);
|
||||
restoreAccountsSyncStatus(syncStates);
|
||||
}
|
||||
Log_OC.startLogging(mStorageTarget);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static private class FileMigrationTask extends FileMigrationTaskBase {
|
||||
private class MigrationException extends Exception {
|
||||
private int mResId;
|
||||
|
||||
MigrationException(int resId) {
|
||||
super();
|
||||
this.mResId = resId;
|
||||
}
|
||||
|
||||
int getResId() { return mResId; }
|
||||
}
|
||||
|
||||
public FileMigrationTask(Context context,
|
||||
String source,
|
||||
String target,
|
||||
ProgressDialog progressDialog,
|
||||
StorageMigrationProgressListener listener) {
|
||||
super(context, source, target, progressDialog, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(Void... args) {
|
||||
publishProgress(R.string.file_migration_preparing);
|
||||
Log_OC.stopLogging();
|
||||
|
||||
boolean[] syncState = new boolean[0];
|
||||
|
||||
try {
|
||||
File dstFile = new File(mStorageTarget + File.separator + MainApp.getDataFolder());
|
||||
deleteRecursive(dstFile);
|
||||
dstFile.delete();
|
||||
|
||||
File srcFile = new File(mStorageSource + File.separator + MainApp.getDataFolder());
|
||||
srcFile.mkdirs();
|
||||
|
||||
publishProgress(R.string.file_migration_checking_destination);
|
||||
|
||||
checkDestinationAvailability();
|
||||
|
||||
publishProgress(R.string.file_migration_saving_accounts_configuration);
|
||||
syncState = saveAccountsSyncStatus();
|
||||
|
||||
publishProgress(R.string.file_migration_waiting_for_unfinished_sync);
|
||||
stopAccountsSyncing();
|
||||
waitForUnfinishedSynchronizations();
|
||||
|
||||
publishProgress(R.string.file_migration_migrating);
|
||||
copyFiles();
|
||||
|
||||
publishProgress(R.string.file_migration_updating_index);
|
||||
updateIndex(mContext);
|
||||
|
||||
publishProgress(R.string.file_migration_cleaning);
|
||||
cleanup();
|
||||
|
||||
} catch (MigrationException e) {
|
||||
rollback();
|
||||
Log_OC.startLogging(mStorageSource);
|
||||
return e.getResId();
|
||||
} finally {
|
||||
publishProgress(R.string.file_migration_restoring_accounts_configuration);
|
||||
restoreAccountsSyncStatus(syncState);
|
||||
}
|
||||
|
||||
Log_OC.startLogging(mStorageTarget);
|
||||
publishProgress(R.string.file_migration_ok_finished);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void checkDestinationAvailability() throws MigrationException {
|
||||
File srcFile = new File(mStorageSource);
|
||||
File dstFile = new File(mStorageTarget);
|
||||
|
||||
if (!dstFile.canRead() || !srcFile.canRead())
|
||||
throw new MigrationException(R.string.file_migration_failed_not_readable);
|
||||
|
||||
if (!dstFile.canWrite() || !srcFile.canWrite())
|
||||
throw new MigrationException(R.string.file_migration_failed_not_writable);
|
||||
|
||||
if (new File(dstFile, MainApp.getDataFolder()).exists())
|
||||
throw new MigrationException(R.string.file_migration_failed_dir_already_exists);
|
||||
|
||||
if (dstFile.getFreeSpace() < FileStorageUtils.getFolderSize(new File(srcFile, MainApp.getDataFolder())))
|
||||
throw new MigrationException(R.string.file_migration_failed_not_enough_space);
|
||||
}
|
||||
|
||||
void copyFiles() throws MigrationException {
|
||||
File srcFile = new File(mStorageSource + File.separator + MainApp.getDataFolder());
|
||||
File dstFile = new File(mStorageTarget + File.separator + MainApp.getDataFolder());
|
||||
|
||||
copyDirs(srcFile, dstFile);
|
||||
}
|
||||
|
||||
void copyDirs(File src, File dst) throws MigrationException {
|
||||
if (!dst.mkdirs())
|
||||
throw new MigrationException(R.string.file_migration_failed_while_coping);
|
||||
|
||||
for (File f : src.listFiles()) {
|
||||
if (f.isDirectory())
|
||||
copyDirs(f, new File(dst, f.getName()));
|
||||
else if (!FileStorageUtils.copyFile(f, new File(dst, f.getName())))
|
||||
throw new MigrationException(R.string.file_migration_failed_while_coping);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void updateIndex(Context context) throws MigrationException {
|
||||
FileDataStorageManager manager = new FileDataStorageManager(null, context.getContentResolver());
|
||||
|
||||
try {
|
||||
manager.migrateStoredFiles(mStorageSource, mStorageTarget);
|
||||
} catch (Exception e) {
|
||||
Log_OC.e(TAG,e.getMessage(),e);
|
||||
throw new MigrationException(R.string.file_migration_failed_while_updating_index);
|
||||
}
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
File srcFile = new File(mStorageSource + File.separator + MainApp.getDataFolder());
|
||||
if (!deleteRecursive(srcFile))
|
||||
Log_OC.w(TAG, "Migration cleanup step failed");
|
||||
srcFile.delete();
|
||||
}
|
||||
|
||||
boolean deleteRecursive(File f) {
|
||||
boolean res = true;
|
||||
if (f.isDirectory())
|
||||
for (File c : f.listFiles())
|
||||
res = deleteRecursive(c) && res;
|
||||
return f.delete() && res;
|
||||
}
|
||||
|
||||
void rollback() {
|
||||
File dstFile = new File(mStorageTarget + File.separator + MainApp.getDataFolder());
|
||||
if (dstFile.exists())
|
||||
if (!dstFile.delete())
|
||||
Log_OC.w(TAG, "Rollback step failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,12 +37,11 @@ import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.db.PreferenceManager;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
|
||||
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment.ConfirmationDialogFragmentListener;
|
||||
@@ -66,7 +65,8 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
private boolean mSelectAll = false;
|
||||
private LocalFileListFragment mFileListFragment;
|
||||
private Button mCancelBtn;
|
||||
private Button mUploadBtn;
|
||||
protected Button mUploadBtn;
|
||||
private Spinner mBehaviourSpinner;
|
||||
private Account mAccountOnCreation;
|
||||
private DialogFragment mCurrentDialog;
|
||||
private Menu mOptionsMenu;
|
||||
@@ -74,8 +74,10 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
public static final String EXTRA_CHOSEN_FILES =
|
||||
UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CHOSEN_FILES";
|
||||
|
||||
public static final int RESULT_OK_AND_MOVE = RESULT_FIRST_USER;
|
||||
|
||||
public static final int RESULT_OK_AND_MOVE = RESULT_FIRST_USER;
|
||||
public static final int RESULT_OK_AND_DO_NOTHING = 2;
|
||||
public static final int RESULT_OK_AND_DELETE = 3;
|
||||
|
||||
private static final String KEY_DIRECTORY_PATH =
|
||||
UploadFilesActivity.class.getCanonicalName() + ".KEY_DIRECTORY_PATH";
|
||||
private static final String KEY_ALL_SELECTED =
|
||||
@@ -84,9 +86,6 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
private static final String TAG = "UploadFilesActivity";
|
||||
private static final String WAIT_DIALOG_TAG = "WAIT";
|
||||
private static final String QUERY_TO_MOVE_DIALOG_TAG = "QUERY_TO_MOVE";
|
||||
private RadioButton mRadioBtnCopyFiles;
|
||||
private RadioButton mRadioBtnMoveFiles;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -130,15 +129,13 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
|
||||
int localBehaviour = PreferenceManager.getUploaderBehaviour(this);
|
||||
|
||||
mRadioBtnMoveFiles = (RadioButton) findViewById(R.id.upload_radio_move);
|
||||
if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_MOVE){
|
||||
mRadioBtnMoveFiles.setChecked(true);
|
||||
}
|
||||
|
||||
mRadioBtnCopyFiles = (RadioButton) findViewById(R.id.upload_radio_copy);
|
||||
if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY){
|
||||
mRadioBtnCopyFiles.setChecked(true);
|
||||
}
|
||||
// file upload spinner
|
||||
mBehaviourSpinner = (Spinner) findViewById(R.id.upload_files_spinner_behaviour);
|
||||
ArrayAdapter<CharSequence> behaviourAdapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.upload_files_behaviour, android.R.layout.simple_spinner_item);
|
||||
behaviourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
mBehaviourSpinner.setAdapter(behaviourAdapter);
|
||||
mBehaviourSpinner.setSelection(localBehaviour);
|
||||
|
||||
// setup the toolbar
|
||||
setupToolbar();
|
||||
@@ -380,8 +377,9 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
if (v.getId() == R.id.upload_files_btn_cancel) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
|
||||
} else if (v.getId() == R.id.upload_files_btn_upload) {
|
||||
|
||||
} else if (v.getId() == R.id.upload_files_btn_upload &&
|
||||
mBehaviourSpinner.getSelectedItemPosition() == 0) {
|
||||
new CheckAvailableSpaceTask().execute();
|
||||
}
|
||||
}
|
||||
@@ -441,13 +439,25 @@ public class UploadFilesActivity extends FileActivity implements
|
||||
Intent data = new Intent();
|
||||
data.putExtra(EXTRA_CHOSEN_FILES, mFileListFragment.getCheckedFilePaths());
|
||||
|
||||
if (mRadioBtnMoveFiles.isChecked()){
|
||||
setResult(RESULT_OK_AND_MOVE, data);
|
||||
PreferenceManager.setUploaderBehaviour(getApplicationContext(), FileUploader.LOCAL_BEHAVIOUR_MOVE);
|
||||
} else {
|
||||
setResult(RESULT_OK, data);
|
||||
PreferenceManager.setUploaderBehaviour(getApplicationContext(), FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
// set result code
|
||||
switch (mBehaviourSpinner.getSelectedItemPosition()) {
|
||||
case 0: // move to nextcloud folder
|
||||
setResult(RESULT_OK_AND_MOVE, data);
|
||||
break;
|
||||
|
||||
case 1: // only upload
|
||||
setResult(RESULT_OK_AND_DO_NOTHING, data);
|
||||
break;
|
||||
|
||||
case 2: // upload and delete from source
|
||||
setResult(RESULT_OK_AND_DELETE, data);
|
||||
break;
|
||||
}
|
||||
|
||||
// store behaviour
|
||||
PreferenceManager.setUploaderBehaviour(getApplicationContext(),
|
||||
mBehaviourSpinner.getSelectedItemPosition());
|
||||
|
||||
finish();
|
||||
} else {
|
||||
// show a dialog to query the user if wants to move the selected files
|
||||
|
||||
@@ -203,7 +203,7 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
||||
|
||||
case R.id.action_clear_failed_uploads:
|
||||
storageManager = new UploadsStorageManager(getContentResolver());
|
||||
storageManager.clearFailedButNotDelayedForWifiUploads();
|
||||
storageManager.clearFailedButNotDelayedUploads();
|
||||
uploadListFragment.updateUploads();
|
||||
break;
|
||||
|
||||
@@ -215,7 +215,7 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
||||
|
||||
case R.id.action_clear_finished_uploads:
|
||||
storageManager = new UploadsStorageManager(getContentResolver());
|
||||
storageManager.clearAllFinishedButNotDelayedForWifiUploads();
|
||||
storageManager.clearAllFinishedButNotDelayedUploads();
|
||||
uploadListFragment.updateUploads();
|
||||
break;
|
||||
|
||||
|
||||
@@ -120,10 +120,10 @@ public class DiskLruImageCache {
|
||||
}
|
||||
final InputStream in = snapshot.getInputStream( 0 );
|
||||
if ( in != null ) {
|
||||
final BufferedInputStream buffIn =
|
||||
final BufferedInputStream buffIn =
|
||||
new BufferedInputStream( in, IO_BUFFER_SIZE );
|
||||
bitmap = BitmapFactory.decodeStream( buffIn );
|
||||
}
|
||||
bitmap = BitmapFactory.decodeStream( buffIn );
|
||||
}
|
||||
} catch ( IOException e ) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@@ -193,4 +193,12 @@ public class DiskLruImageCache {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxSize(long maxSize){
|
||||
mDiskCache.setMaxSize(maxSize);
|
||||
}
|
||||
|
||||
public long getMaxSize(){
|
||||
return mDiskCache.getMaxSize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* Copyright (C) 2016 Tobias Kaminsky
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.adapter;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.OpenableColumns;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class DiskLruImageCacheFileProvider extends ContentProvider {
|
||||
private static String TAG = FileDataStorageManager.class.getSimpleName();
|
||||
private FileDataStorageManager mFileDataStorageManager;
|
||||
|
||||
public static final String AUTHORITY = "org.nextcloud.beta.imageCache.provider";
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private OCFile getFile(Uri uri){
|
||||
Account account = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
|
||||
mFileDataStorageManager = new FileDataStorageManager(account,
|
||||
MainApp.getAppContext().getContentResolver());
|
||||
|
||||
OCFile ocFile = mFileDataStorageManager.getFileByPath(uri.getPath());
|
||||
return ocFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
|
||||
OCFile ocFile = getFile(uri);
|
||||
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
String.valueOf("r" + ocFile.getRemoteId()));
|
||||
|
||||
// create a file to write bitmap data
|
||||
File f = new File(MainApp.getAppContext().getCacheDir(), ocFile.getFileName());
|
||||
try {
|
||||
f.createNewFile();
|
||||
|
||||
//Convert bitmap to byte array
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bos);
|
||||
byte[] bitmapdata = bos.toByteArray();
|
||||
|
||||
//write the bytes in file
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(f);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
fos.write(bitmapdata);
|
||||
fos.flush();
|
||||
fos.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
OCFile ocFile = getFile(uri);
|
||||
return ocFile.getMimetype();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] arg1, String arg2, String[] arg3, String arg4) {
|
||||
MatrixCursor cursor = null;
|
||||
|
||||
OCFile ocFile = getFile(uri);
|
||||
File file = new File(MainApp.getAppContext().getCacheDir(), ocFile.getFileName());
|
||||
if (file.exists()) {
|
||||
cursor = new MatrixCursor(new String[] {
|
||||
OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE });
|
||||
cursor.addRow(new Object[] { uri.getLastPathSegment(),
|
||||
file.length() });
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
||||
mUploadGroups[1] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_failed_uploads)) {
|
||||
@Override
|
||||
public void refresh() {
|
||||
items = mUploadsStorageManager.getFailedButNotDelayedForWifiUploads();
|
||||
items = mUploadsStorageManager.getFailedButNotDelayedUploads();
|
||||
Arrays.sort(items, comparator);
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
||||
task
|
||||
);
|
||||
fileIcon.setImageDrawable(asyncDrawable);
|
||||
task.execute(fakeFileToCheatThumbnailsCacheManagerInterface);
|
||||
task.execute(fakeFileToCheatThumbnailsCacheManagerInterface, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
||||
task
|
||||
);
|
||||
fileIcon.setImageDrawable(asyncDrawable);
|
||||
task.execute(file);
|
||||
task.execute(file, true);
|
||||
Log_OC.v(TAG, "Executing task to generate a new thumbnail");
|
||||
}
|
||||
}
|
||||
@@ -552,6 +552,10 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
|
||||
R.string.uploads_view_upload_status_waiting_for_wifi
|
||||
);
|
||||
break;
|
||||
case DELAYED_FOR_CHARGING:
|
||||
status = mParentActivity.getString(
|
||||
R.string.uploads_view_upload_status_waiting_for_charging);
|
||||
break;
|
||||
case CONFLICT_ERROR:
|
||||
status = mParentActivity.getString(
|
||||
R.string.uploads_view_upload_status_conflict
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
||||
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
import com.owncloud.android.utils.MimetypeIconUtil;
|
||||
@@ -62,6 +63,7 @@ import java.util.Vector;
|
||||
*/
|
||||
public class FileListListAdapter extends BaseAdapter implements FilterableListAdapter {
|
||||
|
||||
public static final int showFilenameColumnThreshold = 4;
|
||||
private Context mContext;
|
||||
private Vector<OCFile> mFilesAll = new Vector<OCFile>();
|
||||
private Vector<OCFile> mFiles = null;
|
||||
@@ -70,18 +72,21 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
|
||||
private FileDataStorageManager mStorageManager;
|
||||
private Account mAccount;
|
||||
private ComponentsGetter mTransferServiceGetter;
|
||||
private OCFileListFragment mListFragment;
|
||||
|
||||
private enum ViewType {LIST_ITEM, GRID_IMAGE, GRID_ITEM}
|
||||
|
||||
public FileListListAdapter(
|
||||
boolean justFolders,
|
||||
Context context,
|
||||
ComponentsGetter transferServiceGetter
|
||||
ComponentsGetter transferServiceGetter,
|
||||
OCFileListFragment listFragment
|
||||
) {
|
||||
|
||||
mJustFolders = justFolders;
|
||||
mContext = context;
|
||||
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||
mListFragment = listFragment;
|
||||
|
||||
mTransferServiceGetter = transferServiceGetter;
|
||||
|
||||
@@ -198,9 +203,14 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
|
||||
case GRID_ITEM:
|
||||
// filename
|
||||
fileName = (TextView) view.findViewById(R.id.Filename);
|
||||
|
||||
name = file.getFileName();
|
||||
fileName.setText(name);
|
||||
|
||||
if (mListFragment.getColumnSize() > showFilenameColumnThreshold && viewType == ViewType.GRID_ITEM){
|
||||
fileName.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
case GRID_IMAGE:
|
||||
// sharedIcon
|
||||
ImageView sharedIconV = (ImageView) view.findViewById(R.id.sharedIcon);
|
||||
@@ -297,10 +307,9 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
|
||||
if ((file.isImage() || file.isVideo()) && file.getRemoteId() != null) {
|
||||
// Thumbnail in Cache?
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
String.valueOf(file.getRemoteId())
|
||||
"t" + String.valueOf(file.getRemoteId())
|
||||
);
|
||||
if (thumbnail != null && !file.needsUpdateThumbnail()) {
|
||||
|
||||
if (file.isVideo()) {
|
||||
Bitmap withOverlay = ThumbnailsCacheManager.addVideoOverlay(thumbnail);
|
||||
fileIcon.setImageBitmap(withOverlay);
|
||||
@@ -328,7 +337,7 @@ public class FileListListAdapter extends BaseAdapter implements FilterableListAd
|
||||
task
|
||||
);
|
||||
fileIcon.setImageDrawable(asyncDrawable);
|
||||
task.execute(file);
|
||||
task.execute(file, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
|
||||
if (BitmapUtils.isImage(file)){
|
||||
// Thumbnail in Cache?
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
String.valueOf(file.hashCode())
|
||||
"t" + String.valueOf(file.hashCode())
|
||||
);
|
||||
if (thumbnail != null){
|
||||
fileIcon.setImageBitmap(thumbnail);
|
||||
@@ -181,7 +181,7 @@ public class LocalFileListAdapter extends BaseAdapter implements FilterableListA
|
||||
task
|
||||
);
|
||||
fileIcon.setImageDrawable(asyncDrawable);
|
||||
task.execute(file);
|
||||
task.execute(file, true);
|
||||
Log_OC.v(TAG, "Executing task to generate a new thumbnail");
|
||||
|
||||
} // else, already being generated, don't restart it
|
||||
|
||||
@@ -117,7 +117,7 @@ public class UploaderAdapter extends SimpleAdapter {
|
||||
task
|
||||
);
|
||||
fileIcon.setImageDrawable(asyncDrawable);
|
||||
task.execute(file);
|
||||
task.execute(file, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -20,12 +20,17 @@
|
||||
|
||||
package com.owncloud.android.ui.fragment;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.view.GestureDetector;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ScaleGestureDetector;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -38,6 +43,7 @@ import android.widget.GridView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||
import com.owncloud.android.R;
|
||||
@@ -55,7 +61,7 @@ public class ExtendedListFragment extends Fragment
|
||||
|
||||
protected static final String TAG = ExtendedListFragment.class.getSimpleName();
|
||||
|
||||
protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION";
|
||||
protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION";
|
||||
|
||||
private static final String KEY_INDEXES = "INDEXES";
|
||||
private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS";
|
||||
@@ -63,7 +69,11 @@ public class ExtendedListFragment extends Fragment
|
||||
private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
|
||||
private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
|
||||
private static final String KEY_IS_GRID_VISIBLE = "IS_GRID_VISIBLE";
|
||||
private static final String GRID_COLUMNS = "gridColumns";
|
||||
public static final float minColumnSize = 2.0f;
|
||||
public static final float maxColumnSize = 10.0f;
|
||||
|
||||
private ScaleGestureDetector mScaleGestureDetector = null;
|
||||
protected SwipeRefreshLayout mRefreshListLayout;
|
||||
private SwipeRefreshLayout mRefreshGridLayout;
|
||||
protected SwipeRefreshLayout mRefreshEmptyLayout;
|
||||
@@ -90,6 +100,8 @@ public class ExtendedListFragment extends Fragment
|
||||
|
||||
private FilterableListAdapter mAdapter;
|
||||
|
||||
private float mScale = -1f;
|
||||
|
||||
protected void setListAdapter(FilterableListAdapter listAdapter) {
|
||||
mAdapter = listAdapter;
|
||||
mCurrentListView.setAdapter(listAdapter);
|
||||
@@ -176,6 +188,16 @@ public class ExtendedListFragment extends Fragment
|
||||
|
||||
mGridFooterView = inflater.inflate(R.layout.list_footer, null, false);
|
||||
|
||||
mScaleGestureDetector = new ScaleGestureDetector(MainApp.getAppContext(),new ScaleListener());
|
||||
|
||||
mGridView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
mScaleGestureDetector.onTouchEvent(motionEvent);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Pull-down to refresh layout
|
||||
mRefreshListLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_containing_list);
|
||||
mRefreshGridLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_containing_grid);
|
||||
@@ -212,6 +234,30 @@ public class ExtendedListFragment extends Fragment
|
||||
return v;
|
||||
}
|
||||
|
||||
private class SingleTapConfirm extends GestureDetector.SimpleOnGestureListener {
|
||||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
|
||||
@Override
|
||||
public boolean onScale(ScaleGestureDetector detector) {
|
||||
if (mScale == -1f) {
|
||||
mGridView.setNumColumns(GridView.AUTO_FIT);
|
||||
mScale = mGridView.getNumColumns();
|
||||
}
|
||||
mScale *= 1.f - (detector.getScaleFactor() - 1.f);
|
||||
mScale = Math.max(minColumnSize, Math.min(mScale, maxColumnSize));
|
||||
Integer scaleInt = Math.round(mScale);
|
||||
mGridView.setNumColumns(scaleInt);
|
||||
mGridView.invalidateViews();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -232,7 +278,11 @@ public class ExtendedListFragment extends Fragment
|
||||
mTops = new ArrayList<Integer>();
|
||||
mHeightCell = 0;
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences appPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(getContext());
|
||||
mScale = appPreferences.getFloat(GRID_COLUMNS, -1.0f);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -246,6 +296,10 @@ public class ExtendedListFragment extends Fragment
|
||||
savedInstanceState.putIntegerArrayList(KEY_TOPS, mTops);
|
||||
savedInstanceState.putInt(KEY_HEIGHT_CELL, mHeightCell);
|
||||
savedInstanceState.putString(KEY_EMPTY_LIST_MESSAGE, getEmptyViewText());
|
||||
|
||||
SharedPreferences.Editor editor = PreferenceManager
|
||||
.getDefaultSharedPreferences(getContext()).edit();
|
||||
editor.putFloat(GRID_COLUMNS, mScale).apply();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,6 +322,10 @@ public class ExtendedListFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
public int getColumnSize() {
|
||||
return Math.round(mScale);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Restore index and position
|
||||
|
||||
@@ -449,7 +449,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
|
||||
task
|
||||
);
|
||||
iv.setImageDrawable(asyncDrawable);
|
||||
task.execute(file);
|
||||
task.execute(file, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -188,7 +188,8 @@ public class OCFileListFragment extends ExtendedListFragment {
|
||||
mAdapter = new FileListListAdapter(
|
||||
mJustFolders,
|
||||
getActivity(),
|
||||
mContainerActivity
|
||||
mContainerActivity,
|
||||
this
|
||||
);
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
|
||||
@@ -142,6 +142,11 @@ public class ShareFileFragment extends Fragment
|
||||
*/
|
||||
private OnEditPermissionInteractionListener mOnEditPermissionInteractionListener = null;
|
||||
|
||||
/**
|
||||
* Listener for user actions to set or unset hide file listing permission on public link
|
||||
*/
|
||||
private OnHideFileListingPermissionInteractionListener mOnHideFileListingPermissionInteractionListener = null;
|
||||
|
||||
|
||||
/**
|
||||
* Public factory method to create new ShareFileFragment instances.
|
||||
@@ -242,6 +247,9 @@ public class ShareFileFragment extends Fragment
|
||||
// Set listener for user actions on edit permission
|
||||
initEditPermissionListener(view);
|
||||
|
||||
// Set listener for hide file listing
|
||||
initHideFileListingListener(view);
|
||||
|
||||
// Hide share features sections that are not enabled
|
||||
hideNotEnabledShareSections(view);
|
||||
|
||||
@@ -474,11 +482,25 @@ public class ShareFileFragment extends Fragment
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds listener for user actions that start any update the hide file listing permissions
|
||||
* for the public link to the views receiving the user events.
|
||||
*
|
||||
* @param shareView Root view in the fragment.
|
||||
*/
|
||||
private void initHideFileListingListener(View shareView) {
|
||||
mOnHideFileListingPermissionInteractionListener =
|
||||
new OnHideFileListingPermissionInteractionListener();
|
||||
|
||||
((SwitchCompat) shareView.findViewById(R.id.shareViaLinkHideListPermissionSwitch)).
|
||||
setOnCheckedChangeListener(mOnHideFileListingPermissionInteractionListener);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for user actions that start any update on the edit permissions for the public link.
|
||||
*/
|
||||
private class OnEditPermissionInteractionListener
|
||||
implements CompoundButton.OnCheckedChangeListener {
|
||||
private class OnEditPermissionInteractionListener implements CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
/**
|
||||
* Called by R.id.shareViaLinkEditPermissionSwitch to set or clear the edit permission.
|
||||
@@ -509,6 +531,39 @@ public class ShareFileFragment extends Fragment
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for user actions that start any update on the hide file listing permissions for the public link.
|
||||
*/
|
||||
private class OnHideFileListingPermissionInteractionListener implements CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
/**
|
||||
* Called by R.id.shareViaLinkHideListPermissionSwitch to set or clear the edit permission.
|
||||
*
|
||||
* @param switchView {@link SwitchCompat} toggled by the user, R.id.shareViaLinkHideListPermissionSwitch
|
||||
* @param isChecked New switch state.
|
||||
*/
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton switchView, boolean isChecked) {
|
||||
if (!isResumed()) {
|
||||
// very important, setChecked(...) is called automatically during
|
||||
// Fragment recreation on device rotations
|
||||
return;
|
||||
}
|
||||
|
||||
((FileActivity) getActivity()).getFileOperationsHelper().
|
||||
setHideFileListingPermissionsToShare(
|
||||
mPublicShare,
|
||||
isChecked
|
||||
);
|
||||
;
|
||||
|
||||
// undo the toggle to grant the view will be correct if the dialog is cancelled
|
||||
switchView.setOnCheckedChangeListener(null);
|
||||
switchView.toggle();
|
||||
switchView.setOnCheckedChangeListener(mOnHideFileListingPermissionInteractionListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
@@ -542,7 +597,6 @@ public class ShareFileFragment extends Fragment
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get known server capabilities from DB
|
||||
* <p/>
|
||||
@@ -556,7 +610,6 @@ public class ShareFileFragment extends Fragment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get users and groups from the DB to fill in the "share with" list.
|
||||
* <p/>
|
||||
@@ -674,6 +727,7 @@ public class ShareFileFragment extends Fragment
|
||||
getPasswordSection().setVisibility(View.VISIBLE);
|
||||
if (mFile.isFolder() && !mCapabilities.getFilesSharingPublicUpload().isFalse()) {
|
||||
getEditPermissionSection().setVisibility(View.VISIBLE);
|
||||
getHideFileListingPermissionSection().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
getEditPermissionSection().setVisibility(View.GONE);
|
||||
}
|
||||
@@ -744,16 +798,32 @@ public class ShareFileFragment extends Fragment
|
||||
if (!editPermissionSwitch.isChecked()) {
|
||||
editPermissionSwitch.toggle();
|
||||
}
|
||||
getHideFileListingPermissionSection().setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (editPermissionSwitch.isChecked()) {
|
||||
editPermissionSwitch.toggle();
|
||||
}
|
||||
getHideFileListingPermissionSection().setVisibility(View.GONE);
|
||||
}
|
||||
// recover listener
|
||||
editPermissionSwitch.setOnCheckedChangeListener(
|
||||
mOnEditPermissionInteractionListener
|
||||
);
|
||||
|
||||
/// update state of the hide file listing permission switch
|
||||
SwitchCompat hideFileListingPermissionSwitch = getHideFileListingPermissionSwitch();
|
||||
|
||||
// set null listener before setChecked() to prevent infinite loop of calls
|
||||
hideFileListingPermissionSwitch.setOnCheckedChangeListener(null);
|
||||
|
||||
boolean readOnly = (mPublicShare.getPermissions() & OCShare.READ_PERMISSION_FLAG) != 0;
|
||||
hideFileListingPermissionSwitch.setChecked(!readOnly);
|
||||
|
||||
// recover listener
|
||||
hideFileListingPermissionSwitch.setOnCheckedChangeListener(
|
||||
mOnHideFileListingPermissionInteractionListener
|
||||
);
|
||||
|
||||
} else {
|
||||
/// no public share -> collapse section
|
||||
SwitchCompat shareViaLinkSwitch = getShareViaLinkSwitch();
|
||||
@@ -767,6 +837,7 @@ public class ShareFileFragment extends Fragment
|
||||
getExpirationDateSection().setVisibility(View.GONE);
|
||||
getPasswordSection().setVisibility(View.GONE);
|
||||
getEditPermissionSection().setVisibility(View.GONE);
|
||||
getHideFileListingPermissionSection().setVisibility(View.GONE);
|
||||
getGetLinkButton().setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
@@ -810,6 +881,14 @@ public class ShareFileFragment extends Fragment
|
||||
return (SwitchCompat) getView().findViewById(R.id.shareViaLinkEditPermissionSwitch);
|
||||
}
|
||||
|
||||
private SwitchCompat getHideFileListingPermissionSwitch() {
|
||||
return (SwitchCompat) getView().findViewById(R.id.shareViaLinkHideListPermissionSwitch);
|
||||
}
|
||||
|
||||
private View getHideFileListingPermissionSection() {
|
||||
return getView().findViewById(R.id.shareViaLinkHideListPermissionSection);
|
||||
}
|
||||
|
||||
private AppCompatButton getGetLinkButton() {
|
||||
return (AppCompatButton) getView().findViewById(R.id.shareViaLinkGetLinkButton);
|
||||
}
|
||||
@@ -823,6 +902,7 @@ public class ShareFileFragment extends Fragment
|
||||
getPasswordSection().setVisibility(View.GONE);
|
||||
getEditPermissionSection().setVisibility(View.GONE);
|
||||
getGetLinkButton().setVisibility(View.GONE);
|
||||
getHideFileListingPermissionSection().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public static void setListViewHeightBasedOnChildren(ListView listView) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.files;
|
||||
package com.owncloud.android.ui.helpers;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.ActivityNotFoundException;
|
||||
@@ -37,9 +37,7 @@ import android.widget.Toast;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -50,21 +48,19 @@ import com.owncloud.android.services.OperationsService;
|
||||
import com.owncloud.android.services.observer.FileObserverService;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
import com.owncloud.android.ui.activity.ShareActivity;
|
||||
import com.owncloud.android.ui.adapter.DiskLruImageCacheFileProvider;
|
||||
import com.owncloud.android.ui.dialog.ShareLinkToDialog;
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class FileOperationsHelper {
|
||||
|
||||
private static final String TAG = FileOperationsHelper.class.getSimpleName();
|
||||
|
||||
|
||||
private static final String FTAG_CHOOSER_DIALOG = "CHOOSER_DIALOG";
|
||||
|
||||
protected FileActivity mFileActivity = null;
|
||||
@@ -76,15 +72,16 @@ public class FileOperationsHelper {
|
||||
mFileActivity = fileActivity;
|
||||
}
|
||||
|
||||
|
||||
public void openFile(OCFile file) {
|
||||
if (file != null) {
|
||||
String storagePath = file.getStoragePath();
|
||||
String encodedStoragePath = WebdavUtils.encodePath(storagePath);
|
||||
|
||||
Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW);
|
||||
intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath),
|
||||
file.getMimetype());
|
||||
intentForSavedMimeType.setDataAndType(
|
||||
file.getExposedFileUri(mFileActivity),
|
||||
file.getMimetype()
|
||||
);
|
||||
|
||||
intentForSavedMimeType.setFlags(
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
);
|
||||
@@ -96,8 +93,10 @@ public class FileOperationsHelper {
|
||||
);
|
||||
if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) {
|
||||
intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW);
|
||||
intentForGuessedMimeType.setDataAndType(Uri.parse("file://" +
|
||||
encodedStoragePath), guessedMimeType);
|
||||
intentForGuessedMimeType.setDataAndType(
|
||||
file.getExposedFileUri(mFileActivity),
|
||||
guessedMimeType
|
||||
);
|
||||
intentForGuessedMimeType.setFlags(
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION |
|
||||
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
@@ -397,6 +396,35 @@ public class FileOperationsHelper {
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a public share on a folder to set its hide file listing permission.
|
||||
* Starts a request to do it in {@link OperationsService}
|
||||
*
|
||||
* @param share {@link OCShare} instance which permissions will be updated.
|
||||
* @param hideFileListing New state of the permission for editing the folder shared via link.
|
||||
*/
|
||||
public void setHideFileListingPermissionsToShare(OCShare share, boolean hideFileListing) {
|
||||
Intent updateShareIntent = new Intent(mFileActivity, OperationsService.class);
|
||||
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
|
||||
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
|
||||
|
||||
int permission = share.getPermissions();
|
||||
share.setPermissions(permission);
|
||||
|
||||
if(!hideFileListing) {
|
||||
permission |= OCShare.READ_PERMISSION_FLAG;
|
||||
} else {
|
||||
permission &= ~OCShare.READ_PERMISSION_FLAG;
|
||||
}
|
||||
|
||||
updateShareIntent.putExtra(
|
||||
OperationsService.EXTRA_SHARE_PERMISSIONS,
|
||||
permission
|
||||
);
|
||||
queueShareIntent(updateShareIntent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return 'True' if the server supports the Search Users API
|
||||
@@ -412,11 +440,13 @@ public class FileOperationsHelper {
|
||||
public void sendDownloadedFile(OCFile file) {
|
||||
if (file != null) {
|
||||
String storagePath = file.getStoragePath();
|
||||
String encodedStoragePath = WebdavUtils.encodePath(storagePath);
|
||||
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
// set MimeType
|
||||
sendIntent.setType(file.getMimetype());
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath));
|
||||
sendIntent.putExtra(
|
||||
Intent.EXTRA_STREAM,
|
||||
file.getExposedFileUri(mFileActivity)
|
||||
);
|
||||
sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
|
||||
|
||||
// Show dialog, without the own app
|
||||
@@ -435,6 +465,25 @@ public class FileOperationsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendCachedImage(OCFile file) {
|
||||
if (file != null) {
|
||||
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
|
||||
// set MimeType
|
||||
sendIntent.setType(file.getMimetype());
|
||||
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath()));
|
||||
sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
|
||||
|
||||
// Show dialog, without the own app
|
||||
String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
|
||||
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude);
|
||||
chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
|
||||
} else {
|
||||
Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Request the synchronization of a file or folder with the OC server, including its contents.
|
||||
*
|
||||
@@ -390,11 +390,6 @@ public class PreviewImageActivity extends FileActivity implements
|
||||
OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
|
||||
getSupportActionBar().setTitle(currentFile.getFileName());
|
||||
setDrawerIndicatorEnabled(false);
|
||||
if (!currentFile.isDown()) {
|
||||
if (!mPreviewImagePagerAdapter.pendingErrorAt(position)) {
|
||||
requestForDownload(currentFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Call to reset image zoom to initial state
|
||||
((PreviewImagePagerAdapter) mViewPager.getAdapter()).resetZoom();
|
||||
|
||||
@@ -41,8 +41,10 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
|
||||
import com.owncloud.android.files.FileMenuFilter;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
|
||||
@@ -69,11 +71,14 @@ public class PreviewImageFragment extends FileFragment {
|
||||
|
||||
private static final String ARG_FILE = "FILE";
|
||||
private static final String ARG_IGNORE_FIRST = "IGNORE_FIRST";
|
||||
private static final String ARG_SHOW_RESIZED_IMAGE = "SHOW_RESIZED_IMAGE";
|
||||
|
||||
private TouchImageViewCustom mImageView;
|
||||
private TextView mMessageView;
|
||||
private ProgressBar mProgressWheel;
|
||||
|
||||
private Boolean mShowResizedImage = false;
|
||||
|
||||
public Bitmap mBitmap = null;
|
||||
|
||||
private static final String TAG = PreviewImageFragment.class.getSimpleName();
|
||||
@@ -97,11 +102,14 @@ public class PreviewImageFragment extends FileFragment {
|
||||
* {@link FragmentStatePagerAdapter}
|
||||
* ; TODO better solution
|
||||
*/
|
||||
public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState){
|
||||
public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState,
|
||||
boolean showResizedImage){
|
||||
PreviewImageFragment frag = new PreviewImageFragment();
|
||||
frag.mShowResizedImage = showResizedImage;
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(ARG_FILE, imageFile);
|
||||
args.putBoolean(ARG_IGNORE_FIRST, ignoreFirstSavedState);
|
||||
args.putBoolean(ARG_SHOW_RESIZED_IMAGE, showResizedImage);
|
||||
frag.setArguments(args);
|
||||
return frag;
|
||||
}
|
||||
@@ -134,6 +142,7 @@ public class PreviewImageFragment extends FileFragment {
|
||||
// not right now
|
||||
|
||||
mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST);
|
||||
mShowResizedImage = args.getBoolean(ARG_SHOW_RESIZED_IMAGE);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@@ -179,9 +188,6 @@ public class PreviewImageFragment extends FileFragment {
|
||||
if (getFile() == null) {
|
||||
throw new IllegalStateException("Instanced with a NULL OCFile");
|
||||
}
|
||||
if (!getFile().isDown()) {
|
||||
throw new IllegalStateException("There is no local file to preview");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -199,10 +205,56 @@ public class PreviewImageFragment extends FileFragment {
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getFile() != null) {
|
||||
mLoadBitmapTask = new LoadBitmapTask(mImageView, mMessageView, mProgressWheel);
|
||||
//mLoadBitmapTask.execute(new String[]{getFile().getStoragePath()});
|
||||
// mLoadBitmapTask.execute(getFile().getStoragePath());
|
||||
mLoadBitmapTask.execute(getFile());
|
||||
mImageView.setTag(getFile().getFileId());
|
||||
|
||||
if (mShowResizedImage){
|
||||
Bitmap resizedImage = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
String.valueOf("r" + getFile().getRemoteId()));
|
||||
|
||||
if (resizedImage != null && !getFile().needsUpdateThumbnail()){
|
||||
mProgressWheel.setVisibility(View.GONE);
|
||||
mImageView.setImageBitmap(resizedImage);
|
||||
mImageView.setVisibility(View.VISIBLE);
|
||||
mBitmap = resizedImage;
|
||||
} else {
|
||||
// show thumbnail while loading resized image
|
||||
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
|
||||
String.valueOf("t" + getFile().getRemoteId()));
|
||||
|
||||
if (thumbnail != null){
|
||||
mImageView.setImageBitmap(thumbnail);
|
||||
mProgressWheel.setVisibility(View.VISIBLE);
|
||||
mImageView.setVisibility(View.VISIBLE);
|
||||
mBitmap = thumbnail;
|
||||
} else {
|
||||
thumbnail = ThumbnailsCacheManager.mDefaultImg;
|
||||
}
|
||||
|
||||
// generate new resized image
|
||||
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(getFile(), mImageView) &&
|
||||
mContainerActivity.getStorageManager() != null) {
|
||||
final ThumbnailsCacheManager.ThumbnailGenerationTask task =
|
||||
new ThumbnailsCacheManager.ThumbnailGenerationTask(
|
||||
mImageView, mContainerActivity.getStorageManager(),
|
||||
mContainerActivity.getStorageManager().getAccount(),
|
||||
mProgressWheel);
|
||||
if (resizedImage == null) {
|
||||
resizedImage = thumbnail;
|
||||
}
|
||||
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable =
|
||||
new ThumbnailsCacheManager.AsyncThumbnailDrawable(
|
||||
MainApp.getAppContext().getResources(),
|
||||
resizedImage,
|
||||
task
|
||||
);
|
||||
mImageView.setImageDrawable(asyncDrawable);
|
||||
task.execute(getFile(), false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mLoadBitmapTask = new LoadBitmapTask(mImageView, mMessageView, mProgressWheel);
|
||||
mLoadBitmapTask.execute(getFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,9 +355,15 @@ public class PreviewImageFragment extends FileFragment {
|
||||
return true;
|
||||
}
|
||||
case R.id.action_send_file: {
|
||||
mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
|
||||
return true;
|
||||
if (getFile().isImage() && !getFile().isDown()){
|
||||
mContainerActivity.getFileOperationsHelper().sendCachedImage(getFile());
|
||||
return true;
|
||||
} else {
|
||||
mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
case R.id.action_download_file:
|
||||
case R.id.action_sync_file: {
|
||||
mContainerActivity.getFileOperationsHelper().syncFile(getFile());
|
||||
return true;
|
||||
|
||||
@@ -103,17 +103,17 @@ public class PreviewImagePagerAdapter extends FragmentStatePagerAdapter {
|
||||
Fragment fragment = null;
|
||||
if (file.isDown()) {
|
||||
fragment = PreviewImageFragment.newInstance(file,
|
||||
mObsoletePositions.contains(Integer.valueOf(i)));
|
||||
|
||||
} else if (mDownloadErrors.contains(Integer.valueOf(i))) {
|
||||
fragment = FileDownloadFragment.newInstance(file, mAccount, true);
|
||||
((FileDownloadFragment)fragment).setError(true);
|
||||
mDownloadErrors.remove(Integer.valueOf(i));
|
||||
mObsoletePositions.contains(Integer.valueOf(i)), false);
|
||||
|
||||
} else {
|
||||
fragment = FileDownloadFragment.newInstance(
|
||||
file, mAccount, mObsoletePositions.contains(Integer.valueOf(i))
|
||||
);
|
||||
if (mDownloadErrors.contains(Integer.valueOf(i))) {
|
||||
fragment = FileDownloadFragment.newInstance(file, mAccount, true);
|
||||
((FileDownloadFragment)fragment).setError(true);
|
||||
mDownloadErrors.remove(Integer.valueOf(i));
|
||||
} else {
|
||||
fragment = PreviewImageFragment.newInstance(file,
|
||||
mObsoletePositions.contains(Integer.valueOf(i)), true);
|
||||
}
|
||||
}
|
||||
mObsoletePositions.remove(Integer.valueOf(i));
|
||||
return fragment;
|
||||
|
||||
@@ -20,8 +20,11 @@
|
||||
package com.owncloud.android.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.BatteryManager;
|
||||
import android.support.v4.net.ConnectivityManagerCompat;
|
||||
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@@ -46,4 +49,16 @@ public class ConnectivityUtils {
|
||||
return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected();
|
||||
}
|
||||
|
||||
public static boolean isCharging(Context context){
|
||||
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
Intent batteryStatus = context.registerReceiver(null, ifilter);
|
||||
|
||||
int status = 0;
|
||||
if (batteryStatus != null) {
|
||||
status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
}
|
||||
return status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == BatteryManager.BATTERY_STATUS_FULL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -68,6 +68,7 @@ public class DisplayUtils {
|
||||
|
||||
private static final String[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
||||
private static final int[] sizeScales = { 0, 0, 1, 1, 1, 2, 2, 2, 2 };
|
||||
private static final int[] quotaSizeScales = { 0, 0, 0, 1, 1, 2, 2, 2, 2 };
|
||||
public static final int RELATIVE_THRESHOLD_WARNING = 90;
|
||||
public static final int RELATIVE_THRESHOLD_CRITICAL = 95;
|
||||
public static final String MIME_TYPE_UNKNOWN = "Unknown type";
|
||||
@@ -101,19 +102,45 @@ public class DisplayUtils {
|
||||
* byte values
|
||||
*/
|
||||
public static String bytesToHumanReadable(long bytes) {
|
||||
if (bytes < 0) {
|
||||
return MainApp.getAppContext().getString(R.string.common_pending);
|
||||
} else {
|
||||
double result = bytes;
|
||||
int suffixIndex = 0;
|
||||
while (result > 1024 && suffixIndex < sizeSuffixes.length) {
|
||||
result /= 1024.;
|
||||
suffixIndex++;
|
||||
}
|
||||
return bytesToHumanReadable(bytes, sizeScales, sizeSuffixes);
|
||||
}
|
||||
|
||||
return new BigDecimal(result).setScale(
|
||||
sizeScales[suffixIndex], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[suffixIndex];
|
||||
/**
|
||||
* Converts the file size in bytes to human readable output.
|
||||
* <ul>
|
||||
* <li>appends a size suffix, e.g. B, KB, MB etc.</li>
|
||||
* <li>rounds the size based on the suffix to 0,1 or 2 decimals</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param bytes Input file size
|
||||
* @return something readable like "12 MB"
|
||||
*/
|
||||
public static String quotaBytesToHumanReadable(long bytes) {
|
||||
return bytesToHumanReadable(bytes, quotaSizeScales, sizeSuffixes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the file size in bytes to human readable output.
|
||||
* <ul>
|
||||
* <li>appends a size suffix, e.g. B, KB, MB etc.</li>
|
||||
* <li>rounds the size based on the suffix to 0,1 or 2 decimals</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param bytes Input file size
|
||||
* @param sizeScales scales for the different size units
|
||||
* @param sizeSuffixes suffixes for the different size units
|
||||
* @return something readable like "12 MB"
|
||||
*/
|
||||
private static String bytesToHumanReadable(long bytes, int[] sizeScales, String[] sizeSuffixes) {
|
||||
double result = bytes;
|
||||
int suffixIndex = 0;
|
||||
while (result > 1024 && suffixIndex < sizeSuffixes.length) {
|
||||
result /= 1024.;
|
||||
suffixIndex++;
|
||||
}
|
||||
|
||||
return new BigDecimal(result).setScale(
|
||||
sizeScales[suffixIndex], BigDecimal.ROUND_HALF_UP) + " " + sizeSuffixes[suffixIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +304,7 @@ public class DisplayUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the screen size in pixels.
|
||||
* Gets the screen size in pixels in a backwards compatible way.
|
||||
*
|
||||
* @param caller Activity calling; needed to get access to the {@link android.view.WindowManager}
|
||||
* @return Size in pixels of the screen, or default {@link Point} if caller is null
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.owncloud.android.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.ui.activity.ErrorReportActivity;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
// from https://stackoverflow.com/questions/23486627/catching-error-and-user-information#answer-23486834
|
||||
public class ExceptionHandler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
Context context;
|
||||
private final String LINE_SEPARATOR = "\n";
|
||||
|
||||
public ExceptionHandler() {
|
||||
// TODO Auto-generated constructor stub
|
||||
context = MainApp.getAppContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread arg0, Throwable arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
StringWriter stackTrace = new StringWriter();
|
||||
arg1.printStackTrace(new PrintWriter(stackTrace));
|
||||
final StringBuilder errorReport = new StringBuilder();
|
||||
errorReport.append("************ CAUSE OF ERROR ************\n\n");
|
||||
errorReport.append(stackTrace.toString());
|
||||
|
||||
errorReport.append("\n************ DEVICE INFORMATION ***********\n");
|
||||
errorReport.append("Brand: ");
|
||||
errorReport.append(Build.BRAND);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
errorReport.append("Device: ");
|
||||
errorReport.append(Build.DEVICE);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
errorReport.append("Model: ");
|
||||
errorReport.append(Build.MODEL);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
errorReport.append("Id: ");
|
||||
errorReport.append(Build.ID);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
errorReport.append("Product: ");
|
||||
errorReport.append(Build.PRODUCT);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
errorReport.append("\n************ FIRMWARE ************\n");
|
||||
errorReport.append("SDK: ");
|
||||
errorReport.append(Build.VERSION.SDK);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
errorReport.append("Release: ");
|
||||
errorReport.append(Build.VERSION.RELEASE);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
errorReport.append("Incremental: ");
|
||||
errorReport.append(Build.VERSION.INCREMENTAL);
|
||||
errorReport.append(LINE_SEPARATOR);
|
||||
|
||||
|
||||
//after this you can do whatever you want , like i start an activity and show error log there
|
||||
|
||||
if (isUIThread()) {
|
||||
invokeLogActivity(errorReport);
|
||||
} else { //handle non UI thread throw uncaught exception
|
||||
|
||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
invokeLogActivity(errorReport);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void invokeLogActivity(StringBuilder errorReport){
|
||||
// Intent sendIntent = new Intent();
|
||||
// sendIntent.setAction(Intent.ACTION_SEND);
|
||||
// sendIntent.putExtra(Intent.EXTRA_TEXT, errorReport.toString());
|
||||
// sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// sendIntent.setType("text/plain");
|
||||
// context.startActivity(sendIntent);
|
||||
|
||||
Intent sendIntent = new Intent(context, ErrorReportActivity.class);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, errorReport.toString());
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
sendIntent.setType("text/plain");
|
||||
context.startActivity(sendIntent);
|
||||
|
||||
|
||||
System.exit(1);
|
||||
// android.os.Process.killProcess(android.os.Process.myPid());
|
||||
|
||||
}
|
||||
|
||||
private boolean isUIThread(){
|
||||
return Looper.getMainLooper().getThread() == Thread.currentThread();
|
||||
}
|
||||
}
|
||||
@@ -20,23 +20,51 @@
|
||||
|
||||
package com.owncloud.android.utils;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Vector;
|
||||
|
||||
import third_parties.daveKoeller.AlphanumComparator;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
import com.owncloud.android.ui.activity.Preferences;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.net.Uri;
|
||||
import android.os.StatFs;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.webkit.MimeTypeMap;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -62,25 +90,15 @@ public class FileStorageUtils {
|
||||
public static Integer mSortOrder = SORT_NAME;
|
||||
public static Boolean mSortAscending = true;
|
||||
|
||||
/**
|
||||
* Takes a full path to owncloud file and removes beginning which is path to ownload data folder.
|
||||
* If fullPath does not start with that folder, fullPath is returned as is.
|
||||
*/
|
||||
public static final String removeDataFolderPath(String fullPath) {
|
||||
File sdCard = Environment.getExternalStorageDirectory();
|
||||
String dataFolderPath = sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/";
|
||||
if(fullPath.indexOf(dataFolderPath) == 0) {
|
||||
return fullPath.substring(dataFolderPath.length());
|
||||
}
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local owncloud storage path for accountName.
|
||||
*/
|
||||
public static final String getSavePath(String accountName) {
|
||||
File sdCard = Environment.getExternalStorageDirectory();
|
||||
return sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/" + Uri.encode(accountName, "@");
|
||||
public static String getSavePath(String accountName) {
|
||||
return MainApp.getStoragePath()
|
||||
+ File.separator
|
||||
+ MainApp.getDataFolder()
|
||||
+ File.separator
|
||||
+ Uri.encode(accountName, "@");
|
||||
// URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names,
|
||||
// that can be in the accountName since 0.1.190B
|
||||
}
|
||||
@@ -90,40 +108,38 @@ public class FileStorageUtils {
|
||||
* corresponding local path (in local owncloud storage) to remote uploaded
|
||||
* file.
|
||||
*/
|
||||
public static final String getDefaultSavePathFor(String accountName, OCFile file) {
|
||||
public static String getDefaultSavePathFor(String accountName, OCFile file) {
|
||||
return getSavePath(accountName) + file.getRemotePath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get absolute path to tmp folder inside datafolder in sd-card for given accountName.
|
||||
*/
|
||||
public static final String getTemporalPath(String accountName) {
|
||||
File sdCard = Environment.getExternalStorageDirectory();
|
||||
return sdCard.getAbsolutePath() + "/" + MainApp.getDataFolder() + "/tmp/" + Uri.encode(accountName, "@");
|
||||
// URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names,
|
||||
// that can be in the accountName since 0.1.190B
|
||||
public static String getTemporalPath(String accountName) {
|
||||
return MainApp.getStoragePath()
|
||||
+ File.separator
|
||||
+ MainApp.getDataFolder()
|
||||
+ File.separator
|
||||
+ "tmp"
|
||||
+ File.separator
|
||||
+ Uri.encode(accountName, "@");
|
||||
// URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names,
|
||||
// that can be in the accountName since 0.1.190B
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimistic number of bytes available on sd-card. accountName is ignored.
|
||||
*
|
||||
* @param accountName not used. can thus be null.
|
||||
* @return Optimistic number of available bytes (can be less)
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public static final long getUsableSpace(String accountName) {
|
||||
File savePath = Environment.getExternalStorageDirectory();
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
|
||||
return savePath.getUsableSpace();
|
||||
|
||||
} else {
|
||||
StatFs stats = new StatFs(savePath.getAbsolutePath());
|
||||
return stats.getAvailableBlocks() * stats.getBlockSize();
|
||||
}
|
||||
|
||||
public static long getUsableSpace(String accountName) {
|
||||
File savePath = new File(MainApp.getStoragePath());
|
||||
return savePath.getUsableSpace();
|
||||
}
|
||||
|
||||
public static final String getLogPath() {
|
||||
return Environment.getExternalStorageDirectory() + File.separator + MainApp.getDataFolder() + File.separator + "log";
|
||||
public static String getLogPath() {
|
||||
return MainApp.getStoragePath() + File.separator + MainApp.getDataFolder() + File.separator + "log";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,25 +285,17 @@ public class FileStorageUtils {
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sorts list by Date
|
||||
* @param files
|
||||
*/
|
||||
public static Vector<OCFile> sortOCFilesByDate(Vector<OCFile> files){
|
||||
final int multiplier = mSortAscending ? 1 : -1;
|
||||
|
||||
|
||||
Collections.sort(files, new Comparator<OCFile>() {
|
||||
public int compare(OCFile o1, OCFile o2) {
|
||||
if (o1.isFolder() && o2.isFolder()) {
|
||||
Long obj1 = o1.getModificationTimestamp();
|
||||
return multiplier * obj1.compareTo(o2.getModificationTimestamp());
|
||||
}
|
||||
else if (o1.isFolder()) {
|
||||
return -1;
|
||||
} else if (o2.isFolder()) {
|
||||
return 1;
|
||||
} else if (o1.getModificationTimestamp() == 0 || o2.getModificationTimestamp() == 0){
|
||||
if (o1.getModificationTimestamp() == 0 || o2.getModificationTimestamp() == 0){
|
||||
return 0;
|
||||
} else {
|
||||
Long obj1 = o1.getModificationTimestamp();
|
||||
@@ -295,7 +303,7 @@ public class FileStorageUtils {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
@@ -327,7 +335,7 @@ public class FileStorageUtils {
|
||||
}
|
||||
});
|
||||
|
||||
File[] returnArray = new File[1];
|
||||
File[] returnArray = new File[files.size()];
|
||||
return files.toArray(returnArray);
|
||||
}
|
||||
|
||||
@@ -386,7 +394,7 @@ public class FileStorageUtils {
|
||||
}
|
||||
});
|
||||
|
||||
File[] returnArray = new File[1];
|
||||
File[] returnArray = new File[files.size()];
|
||||
return files.toArray(returnArray);
|
||||
}
|
||||
|
||||
@@ -436,10 +444,10 @@ public class FileStorageUtils {
|
||||
}
|
||||
});
|
||||
|
||||
File[] returnArray = new File[1];
|
||||
File[] returnArray = new File[files.size()];
|
||||
return files.toArray(returnArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Local Folder size
|
||||
* @param dir File
|
||||
@@ -448,13 +456,11 @@ public class FileStorageUtils {
|
||||
public static long getFolderSize(File dir) {
|
||||
if (dir.exists()) {
|
||||
long result = 0;
|
||||
File[] fileList = dir.listFiles();
|
||||
for(int i = 0; i < fileList.length; i++) {
|
||||
if(fileList[i].isDirectory()) {
|
||||
result += getFolderSize(fileList[i]);
|
||||
} else {
|
||||
result += fileList[i].length();
|
||||
}
|
||||
for (File f : dir.listFiles()) {
|
||||
if (f.isDirectory())
|
||||
result += getFolderSize(f);
|
||||
else
|
||||
result += f.length();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -504,4 +510,36 @@ public class FileStorageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean copyFile(File src, File target) {
|
||||
boolean ret = true;
|
||||
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
|
||||
try {
|
||||
in = new FileInputStream(src);
|
||||
out = new FileOutputStream(target);
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ret = false;
|
||||
} finally {
|
||||
if (in != null) try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error closing input stream during copy", e);
|
||||
}
|
||||
if (out != null) try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
Log_OC.e(TAG, "Error closing output stream during copy", e);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
|
||||
package com.owncloud.android.providers;
|
||||
package org.nextcloud.providers;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.SearchManager;
|
||||
@@ -72,7 +72,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
|
||||
private static final int RESULTS_PER_PAGE = 50;
|
||||
private static final int REQUESTED_PAGE = 1;
|
||||
|
||||
public static final String AUTHORITY = "com.nextcloud.android.providers.UsersAndGroupsSearchProvider";
|
||||
public static final String AUTHORITY = "org.nextcloud.beta.android.providers.UsersAndGroupsSearchProvider";
|
||||
public static final String ACTION_SHARE_WITH = AUTHORITY + ".action.SHARE_WITH";
|
||||
|
||||
public static final String CONTENT = "content";
|
||||
@@ -11,4 +11,4 @@
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-23
|
||||
target=android-24
|
||||
@@ -1,19 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Originally written by Ralf Kistner <[email protected]>, but placed in the public domain
|
||||
|
||||
set +e
|
||||
|
||||
bootanim=""
|
||||
failcounter=0
|
||||
checkcounter=0
|
||||
timeout_in_sec=360
|
||||
|
||||
until [[ "$bootanim" =~ "stopped" ]]; do
|
||||
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1`
|
||||
echo "($checkcounter) $bootanim"
|
||||
if [[ "$bootanim" =~ "not found" ]]; then
|
||||
let "failcounter += 1"
|
||||
if [[ $failcounter -gt 30 ]]; then
|
||||
echo "Failed to start emulator"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
let "checkcounter += 1"
|
||||
sleep 10
|
||||
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &`
|
||||
if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline" ]]; then
|
||||
let "failcounter += 1"
|
||||
echo "($failcounter) Waiting for emulator to start - $bootanim"
|
||||
if [[ $failcounter -gt timeout_in_sec ]]; then
|
||||
echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
|
||||
exit 1
|
||||
fi
|
||||
elif [[ "$bootanim" =~ "running" ]]; then
|
||||
echo "Emulator is ready"
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "Done"
|
||||
echo "Done"
|
||||