- <?xml version="1.0" encoding="utf-8"?><!--
+ <?xml version="1.0" encoding="utf-8"?>
+ <!--
ownCloud Android client application
Copyright (C) 2012 Bartek Przybylski
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.owncloud.android"
- android:versionCode="10800000"
- android:versionName="1.8.0" >
+ -->
+<manifest package="com.owncloud.android"
+ android:versionName="ownCloud beta" xmlns:android="http://schemas.android.com/apk/res/android">
+ <uses-sdk
+ android:minSdkVersion="14"
+ android:targetSdkVersion="22" />
+
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
-
- <uses-sdk
- android:minSdkVersion="14"
- android:targetSdkVersion="22" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
+ <android:uses-permission android:name="android.permission.READ_PHONE_STATE" />
+ <android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".MainApp"
android:icon="@drawable/icon"
android:label="@string/app_name"
- android:theme="@style/Theme.ownCloud">
+ android:theme="@style/Theme.ownCloud" >
<activity
android:name=".ui.activity.FileDisplayActivity"
- android:label="@string/app_name">
+ android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name=".ui.activity.UploadFilesActivity"></activity>
- <activity android:name=".ui.activity.Uploader">
+ <activity android:name=".ui.activity.UploadFilesActivity" />
+ <activity android:name=".ui.activity.Uploader" >
<intent-filter>
- <action android:name="android.intent.action.SEND"></action>
+ <action android:name="android.intent.action.SEND" />
- <category android:name="android.intent.category.DEFAULT"></category>
+ <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="*/*"></data>
+ <data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
- <action android:name="android.intent.action.SEND_MULTIPLE"></action>
-
- <category android:name="android.intent.category.DEFAULT"></category>
+ <action android:name="android.intent.action.SEND_MULTIPLE" />
- <data android:mimeType="*/*"></data>
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:mimeType="*/*" />
</intent-filter>
</activity>
<activity
android:name=".ui.activity.Preferences"
android:theme="@style/Theme.ownCloud" >
</activity>
- <activity
+ <activity
android:name=".ui.preview.PreviewImageActivity"
- android:theme="@style/Theme.ownCloud.Overlay"
- />
-
- <activity
+ android:theme="@style/Theme.ownCloud.Overlay" />
+ <activity
android:name=".ui.preview.PreviewVideoActivity"
android:label="@string/app_name"
- android:theme="@style/Theme.ownCloud.Fullscreen"></activity>
+ android:theme="@style/Theme.ownCloud.Fullscreen" />
<service
android:name=".authentication.AccountAuthenticatorService"
- android:exported="true">
- <intent-filter android:priority="100">
+ android:exported="true" >
+ <intent-filter android:priority="100" >
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
</service>
<service
android:name=".syncadapter.FileSyncService"
- android:exported="true">
+ android:exported="true" >
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
android:enabled="true"
android:exported="true"
android:label="@string/sync_string_files"
- android:syncable="true"></provider>
+ android:syncable="true" />
+
+ <provider
+ android:name=".providers.UsersAndGroupsSearchProvider"
+ android:authorities="com.owncloud.android.providers.UsersAndGroupsSearchProvider"
+ android:enabled="true"
+ android:exported="false"
+ android:label="@string/search_users_and_groups_hint" />
<provider
android:name=".ui.adapter.DiskLruImageCacheFileProvider"
- android:authorities="com.owncloud.imageCache.provider"
+ android:authorities="@string/authorityCache"
android:exported="true">
</provider>
<activity
android:name=".authentication.AuthenticatorActivity"
android:exported="true"
- android:theme="@style/Theme.ownCloud.noActionBar"
- android:launchMode="singleTask">
+ android:launchMode="singleTask"
+ android:theme="@style/Theme.ownCloud.noActionBar" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
<intent-filter>
<action android:name="com.owncloud.android.workaround.accounts.CREATE" />
+
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<service android:name=".media.MediaService" />
<activity android:name=".ui.activity.PassCodeActivity" />
- <activity android:name=".ui.activity.ConflictsResolveActivity" />
- <activity android:name=".ui.activity.GenericExplanationActivity" />
- <activity android:name=".ui.activity.ErrorsWhileCopyingHandlerActivity" />
- <activity android:name=".ui.activity.LogHistoryActivity" />
-
- <receiver android:name=".files.InstantUploadBroadcastReceiver" >
+ <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"/>
+
+ <receiver android:name=".files.InstantUploadBroadcastReceiver">
<intent-filter>
+
<!-- unofficially supported by many Android phones but not by HTC devices: -->
<action android:name="com.android.camera.NEW_PICTURE" />
<!-- officially supported since Android 4.0 (SDK 14, works even for HTC devices): -->
<action android:name="android.hardware.action.NEW_PICTURE" />
+
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.hardware.action.NEW_VIDEO" />
+
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
+ <intent-filter>
+ <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.BootupBroadcastReceiver">
+ <receiver android:name=".files.BootupBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
- <service android:name=".services.observer.FileObserverService"/>
-
- <activity
- android:name=".ui.activity.CopyToClipboardActivity"
- android:label="@string/copy_link"
- android:icon="@drawable/copy_link"/>
- <activity
- android:name=".ui.activity.FolderPickerActivity"
- android:label="@string/app_name"/>
+ <service android:name=".services.observer.FileObserverService" />
<activity
- android:name=".ui.activity.UploadPathActivity"
- android:label="@string/app_name"/>
-
+ android:name=".ui.activity.CopyToClipboardActivity"
+ android:icon="@drawable/copy_link"
+ android:label="@string/copy_link" />
+ <activity
+ android:name=".ui.activity.FolderPickerActivity"
+ android:label="@string/app_name" />
+ <activity
+ android:name=".ui.activity.UploadPathActivity"
+ android:label="@string/app_name" />
+ <activity
+ android:name=".ui.activity.ShareActivity"
+ android:label="@string/share_dialog_title"
+ android:theme="@style/Theme.ownCloud.Dialog"
+ android:launchMode="singleTop"
+ android:windowSoftInputMode="adjustResize" >
+ <intent-filter>
+ <action android:name="android.intent.action.SEARCH" />
+ </intent-filter>
+ <meta-data android:name="android.app.searchable"
+ android:resource="@xml/users_and_groups_searchable"/>
+ </activity>
</application>
</manifest>
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.2.3'
+ classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'com.android.application'
-
repositories {
mavenCentral()
dependencies {
compile name: 'touch-image-view'
- compile 'com.android.support:support-v4:22.2.1'
compile project(':owncloud-android-library')
+ compile 'com.android.support:support-v4:22.2.1'
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'com.android.support:appcompat-v7:22.2.1'
+ compile 'com.getbase:floatingactionbutton:1.10.1'
}
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
+
+ defaultConfig {
+ applicationId "com.owncloud.android.beta"
+ versionCode computeVersionCode()
+ }
+
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
abortOnError false
}
}
-
+
productFlavors {
}
}
}
-
+
+
+
+
+def computeVersionCode() {
+ def date = new Date()
+ def formattedDate = date.format('yyyyMMdd').toInteger()
+ return formattedDate
+}
- Subproject commit 59fb61601de4dd8bfcab1afb619e016e1a7b904d
-Subproject commit 32ab89fc308af2a51b9b7ded7fb40fc786dfd8a6
++Subproject commit fff67c91f73532229cd678cbbee19b52b0852db5
android:scaleType="centerCrop"\r
android:src="@drawable/ic_menu_archive"/>\r
\r
- <LinearLayout\r
+ <ImageView\r
+ android:id="@+id/sharedIcon"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_gravity="top|right"\r
- android:orientation="vertical"\r
- android:layout_margin="4dp">\r
- \r
- <ImageView\r
- android:id="@+id/sharedIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="center"\r
- android:layout_marginBottom="4dp"\r
- android:src="@drawable/sharedlink" />\r
- \r
- <ImageView\r
- android:id="@+id/sharedWithMeIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="center"\r
- android:layout_marginTop="4dp"\r
- android:src="@drawable/shared_with_me"\r
- android:visibility="invisible" />\r
- </LinearLayout>\r
+ android:layout_margin="4dp"\r
+ android:src="@drawable/shared_via_link" />\r
\r
<ImageView\r
android:id="@+id/localFileIndicator"\r
android:layout_marginBottom="4dp"\r
android:layout_marginRight="4dp"\r
android:src="@drawable/ic_favorite" />\r
+\r
+ <ImageView\r
+ android:id="@+id/custom_checkbox"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="center_vertical|bottom"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:gravity=""\r
+ android:src="@android:drawable/checkbox_off_background" />\r
</FrameLayout>\r
\r
</LinearLayout>
android:layout_marginRight="10dp"\r
android:src="@drawable/ic_menu_archive" />\r
\r
- <LinearLayout\r
+ <ImageView\r
+ android:id="@+id/sharedIcon"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
+ android:layout_margin="4dp"\r
android:layout_gravity="top|right"\r
- android:orientation="vertical"\r
- android:layout_margin="2dp">\r
- \r
- <ImageView\r
- android:id="@+id/sharedIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="center"\r
- android:layout_marginBottom="2dp"\r
- android:src="@drawable/sharedlink" />\r
- \r
- <ImageView\r
- android:id="@+id/sharedWithMeIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="center"\r
- android:layout_marginTop="2dp"\r
- android:src="@drawable/shared_with_me"\r
- android:visibility="invisible" />\r
- </LinearLayout>\r
+ android:src="@drawable/shared_via_link" />\r
\r
<ImageView\r
android:id="@+id/localFileIndicator"\r
android:layout_marginRight="2dp"\r
android:src="@drawable/ic_favorite" />\r
\r
-\r
+ <ImageView\r
+ android:id="@+id/custom_checkbox"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="center_vertical|bottom"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:gravity=""\r
+ android:src="@android:drawable/checkbox_off_background"\r
+ android:elevation="30dp" />\r
\r
</FrameLayout>\r
\r
android:layout_width="match_parent"\r
android:background="@drawable/list_selector"\r
android:orientation="vertical"\r
- android:layout_height="56dp">\r
+ android:layout_height="72dp">\r
\r
<LinearLayout\r
android:layout_width="match_parent"\r
android:orientation="horizontal">\r
\r
<FrameLayout\r
- android:layout_width="56dp"\r
- android:layout_height="56dp"\r
+ android:layout_width="60dp"\r
+ android:layout_height="72dp"\r
+ android:paddingLeft="12dp"\r
+ android:paddingBottom="@dimen/standard_padding"\r
+ android:paddingTop="@dimen/standard_padding"\r
+ android:paddingRight="4dp"\r
android:focusable="false"\r
android:focusableInTouchMode="false">\r
\r
android:id="@+id/localFileIndicator"\r
android:layout_width="@dimen/file_icon_size"\r
android:layout_height="@dimen/file_icon_size"\r
- android:layout_gravity="center_vertical"\r
- android:layout_marginLeft="22dp"\r
+ android:layout_gravity="top|right"\r
+ android:layout_marginRight="4dp"\r
android:src="@drawable/local_file_indicator" />\r
\r
<ImageView\r
android:id="@+id/thumbnail"\r
android:layout_width="@dimen/file_icon_size"\r
android:layout_height="@dimen/file_icon_size"\r
- android:layout_gravity="center_vertical"\r
- android:layout_marginLeft="12dp"\r
+ android:layout_gravity="left|center_vertical"\r
android:src="@drawable/ic_menu_archive" />\r
\r
<ImageView\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_gravity="bottom|right"\r
- android:layout_marginBottom="10dp"\r
- android:layout_marginRight="2dp"\r
+ android:layout_marginRight="4dp"\r
android:src="@drawable/ic_favorite" />\r
</FrameLayout>\r
\r
android:layout_width="0dp"\r
android:layout_height="match_parent"\r
android:layout_weight="1"\r
- android:gravity="center_vertical"\r
+ android:gravity="top"\r
+ android:paddingTop="@dimen/standard_padding"\r
android:orientation="vertical" >\r
\r
<TextView\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:layout_gravity="center_vertical"\r
- android:layout_marginLeft="4dp"\r
+ android:layout_marginLeft="0dp"\r
android:layout_marginRight="4dp"\r
android:ellipsize="middle"\r
android:singleLine="true"\r
android:text="TextView"\r
android:textColor="@color/textColor"\r
- android:textSize="16dip" />\r
+ android:textSize="@dimen/two_line_primary_text_size" />\r
\r
<LinearLayout\r
android:layout_width="match_parent"\r
android:layout_height="wrap_content"\r
- android:layout_marginLeft="4dp"\r
+ android:layout_marginLeft="0dp"\r
android:layout_marginRight="4dp"\r
- android:weightSum="1">\r
+ android:orientation="horizontal">\r
\r
<TextView\r
- android:id="@+id/last_mod"\r
+ android:id="@+id/file_size"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
- android:text="TextView"\r
- android:layout_weight=".5"\r
+ android:text="Size MB"\r
android:textColor="@color/list_item_lastmod_and_filesize_text"\r
- android:textSize="12dip"/>\r
+ android:textSize="@dimen/two_line_secondary_text_size"/>\r
\r
<TextView\r
- android:id="@+id/file_size"\r
+ android:id="@+id/file_separator"\r
android:layout_width="wrap_content"\r
android:layout_height="wrap_content"\r
android:gravity="right"\r
- android:text="TextView"\r
+ android:text=", "\r
android:textColor="@color/list_item_lastmod_and_filesize_text"\r
- android:layout_weight=".5"\r
- android:textSize="12dip"/>\r
+ android:textSize="@dimen/two_line_secondary_text_size"/>\r
+\r
+ <TextView\r
+ android:id="@+id/last_mod"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:gravity="right"\r
+ android:text="Mod Date"\r
+ android:textColor="@color/list_item_lastmod_and_filesize_text"\r
+ android:textSize="@dimen/two_line_secondary_text_size"/>\r
\r
</LinearLayout>\r
\r
</LinearLayout>\r
\r
- <LinearLayout\r
- android:layout_width="25dp"\r
- android:layout_height="match_parent"\r
- android:gravity="center_vertical"\r
- android:orientation="vertical">\r
- \r
- <ImageView\r
- android:id="@+id/sharedIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="center"\r
- android:layout_marginLeft="4dp"\r
- android:layout_marginBottom="4dp"\r
- android:layout_marginRight="4dp"\r
- android:src="@drawable/sharedlink" />\r
- \r
- <ImageView\r
- android:id="@+id/sharedWithMeIcon"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_gravity="center"\r
- android:layout_marginLeft="4dp"\r
- android:layout_marginRight="4dp"\r
- android:layout_marginTop="4dp"\r
- android:src="@drawable/shared_with_me"\r
- android:visibility="invisible" />\r
- \r
- </LinearLayout>\r
+ <ImageView\r
+ android:id="@+id/sharedIcon"\r
+ android:layout_width="wrap_content"\r
+ android:layout_height="wrap_content"\r
+ android:layout_gravity="center"\r
+ android:layout_marginTop="4dp"\r
+ android:layout_marginLeft="4dp"\r
+ android:layout_marginBottom="4dp"\r
+ android:layout_marginRight="4dp"\r
+ android:src="@drawable/shared_via_link" />\r
\r
<ImageView\r
android:id="@+id/custom_checkbox"\r
android:layout_height="wrap_content"\r
android:layout_gravity="center_vertical"\r
android:layout_marginLeft="4dp"\r
- android:layout_marginRight="4dp"\r
+ android:layout_marginRight="@dimen/standard_margin"\r
android:gravity=""\r
- android:src="@android:drawable/checkbox_off_background" />\r
+ android:src="@drawable/ic_checkbox_blank_outline" />\r
</LinearLayout>\r
\r
<View\r
-<?xml version="1.0" encoding="utf-8"?><!--
+<?xml version="1.0" encoding="utf-8"?>
+<!--
ownCloud Android client application
Copyright (C) 2012 Bartek Przybylski
android:icon="@android:drawable/ic_menu_share"
android:orderInCategory="1" />
<item
+ android:id="@+id/action_stream_file"
+ android:title="@string/action_stream_file"
+ android:icon="@android:drawable/ic_menu_view"
+ android:orderInCategory="1" />
+ <item
android:id="@+id/action_unshare_file"
android:title="@string/action_unshare_file"
android:icon="@android:drawable/ic_menu_share"
android:orderInCategory="1" />
<item
+ android:id="@+id/action_share_with_users"
+ android:title="@string/action_share_with_users"
+ android:orderInCategory="1" />
+
+ <item
android:id="@+id/action_open_file_with"
android:title="@string/actionbar_open_with"
android:icon="@android:drawable/ic_menu_set_as"
android:icon="@android:drawable/ic_menu_set_as"
android:orderInCategory="1" />
<item
+ android:id="@+id/action_set_as_wallpaper"
+ android:title="@string/set_picture_as"
+ android:icon="@android:drawable/ic_menu_set_as"
+ android:orderInCategory="1" />
+ <item
android:id="@+id/action_see_details"
android:title="@string/actionbar_see_details"
android:icon="@android:drawable/ic_menu_info_details"
<string name="filedetails_created">Δημιουργήθηκε:</string>
<string name="filedetails_modified">Τροποποιήθηκε:</string>
<string name="filedetails_download">Λήψη</string>
+ <string name="filedetails_sync_file">Συγχρονισμός</string>
<string name="filedetails_renamed_in_upload_msg">Το αρχείο μετονομάστηκε σε %1$s κατά τη μεταφόρτωση</string>
<string name="list_layout">Διάταξη Λίστας</string>
<string name="action_share_file">Διαμοιρασμός συνδέσμου</string>
<string name="common_yes">Ναι</string>
<string name="common_no">Όχι</string>
<string name="common_ok">ΟΚ</string>
+ <string name="common_cancel_sync">Ακύρωση συγχρονισμού</string>
<string name="common_cancel">Άκυρο</string>
<string name="common_save_exit">Αποθήκευση & Έξοδος</string>
<string name="common_error">Σφάλμα</string>
<string name="unfavorite">Κατάργηση από τα αγαπημένα</string>
<string name="common_rename">Μετονομασία</string>
<string name="common_remove">Αφαίρεση</string>
- <string name="confirmation_remove_alert">Θέλετε στ\' αλήθεια να αφαιρέσετε το %1$s;</string>
+ <string name="confirmation_remove_file_alert">Θέλετε στ\' αλήθεια να αφαιρέσετε το %1$s;</string>
<string name="confirmation_remove_folder_alert">Θέλετε στ\' αλήθεια να διαγράψετε το %1$s και τα περιεχόμενά του;</string>
<string name="confirmation_remove_local">Μόνο τοπικά</string>
<string name="confirmation_remove_folder_local">Μόνο τοπικά</string>
- <string name="confirmation_remove_remote">Από το διακομιστή</string>
+ <string name="confirmation_remove_file_remote">Από το διακομιστή</string>
<string name="confirmation_remove_remote_and_local">Απομακρυσμένα & τοπικά</string>
<string name="remove_success_msg">Αφαίρεση επιτυχής</string>
<string name="remove_fail_msg">Η αφαίρεση απέτυχε</string>
<string name="prefs_category_instant_uploading">Στιγμιαίες Μεταφορτώσεις</string>
<string name="prefs_category_security">Ασφάλεια</string>
<string name="prefs_instant_video_upload_path_title">Διαδρομή Μεταφόρτωσης Βίντεο</string>
+ <string name="sync_folder_failed_content">Ο συγχρονισμός του φακέλου %1$s δεν μπόρεσε να ολοκληρωθεί</string>
<string name="shared_subject_header">διαμοιρασμένα</string>
<string name="with_you_subject_header">με εσάς</string>
<string name="subject_token">Ο %1$s διαμοιράστηκε το \"%2$s\" με εσάς</string>
<string name="filedetails_created">Creado:</string>
<string name="filedetails_modified">Modificado:</string>
<string name="filedetails_download">Descargar</string>
+ <string name="filedetails_sync_file">Sincronizar</string>
<string name="filedetails_renamed_in_upload_msg">El fichero fue renombrado como %1$s durante la subida</string>
<string name="list_layout">Diseño de lista</string>
<string name="action_share_file">Compartir con enlace</string>
<string name="common_yes">Sí</string>
<string name="common_no">No</string>
<string name="common_ok">Aceptar</string>
+ <string name="common_cancel_sync">Cancelar sincronización</string>
<string name="common_cancel">Cancelar</string>
<string name="common_save_exit">Guardar & Salir</string>
<string name="common_error">Error</string>
<string name="unfavorite">No-favorito</string>
<string name="common_rename">Renombrar</string>
<string name="common_remove">Borrar</string>
- <string name="confirmation_remove_alert">¿Realmente desea eliminar %1$s?</string>
+ <string name="confirmation_remove_file_alert">¿Realmente desea eliminar %1$s?</string>
<string name="confirmation_remove_folder_alert">¿Realmente desea eliminar %1$s y todo su contenido?</string>
<string name="confirmation_remove_local">Sólo local</string>
<string name="confirmation_remove_folder_local">Sólo local</string>
- <string name="confirmation_remove_remote">Desde el servidor</string>
+ <string name="confirmation_remove_file_remote">Desde el servidor</string>
<string name="confirmation_remove_remote_and_local">Remoto & local</string>
<string name="remove_success_msg">Borrado correctamente</string>
<string name="remove_fail_msg">El borrado no pudo ser completado</string>
<string name="prefs_category_instant_uploading">Subidas instantáneas</string>
<string name="prefs_category_security">Seguridad</string>
<string name="prefs_instant_video_upload_path_title">Guardar videos subidos en la carpeta:</string>
+ <string name="sync_folder_failed_content">La sincronización de la carpeta %1$s no se pudo completar</string>
<string name="shared_subject_header">compartido</string>
<string name="with_you_subject_header">con usted</string>
<string name="subject_token">%1$s compartió \"%2$s\" conmigo</string>
<string name="file_list_loading">Chargement...</string>
<string name="file_list_no_app_for_file_type">Aucune app trouvée pour ce type de fichier !</string>
<string name="local_file_list_empty">Aucun fichier n\'est présent dans ce dossier.</string>
- <string name="filedetails_select_file">Appuyez sur un fichier pour afficher des informations supplémentaires</string>
+ <string name="filedetails_select_file">Sélectionnez un fichier pour afficher des informations supplémentaires</string>
<string name="filedetails_size">Taille :</string>
<string name="filedetails_type">Type :</string>
<string name="filedetails_created">Créé le :</string>
<string name="unfavorite">Retirer des favoris</string>
<string name="common_rename">Renommer</string>
<string name="common_remove">Supprimer</string>
- <string name="confirmation_remove_alert">Voulez-vous vraiment supprimer %1$s ?</string>
+ <string name="confirmation_remove_file_alert">Voulez-vous vraiment supprimer %1$s ?</string>
<string name="confirmation_remove_folder_alert">Voulez-vous vraiment supprimer %1$s et son contenu ?</string>
<string name="confirmation_remove_local">Local seulement</string>
<string name="confirmation_remove_folder_local">Local seulement</string>
- <string name="confirmation_remove_remote">Depuis le serveur</string>
+ <string name="confirmation_remove_file_remote">Depuis le serveur</string>
<string name="confirmation_remove_remote_and_local">Distant & local</string>
<string name="remove_success_msg">Suppression effectuée avec succès</string>
<string name="remove_fail_msg">Suppression impossible</string>
<string name="prefs_recommend">Ajánlja egy barátjának</string>
<string name="prefs_feedback">Visszajelzés</string>
<string name="prefs_imprint">Impresszum</string>
+ <string name="prefs_remember_last_share_location">Emlékezzen a megosztás helyére</string>
<string name="recommend_subject">Próbálja ki %1$s-t az okostelefonján!</string>
<string name="auth_check_server">Szerver állapot ellenörzés</string>
<string name="auth_host_url">Kiszolgáló címe https://...</string>
<string name="filedetails_created">Készült:</string>
<string name="filedetails_modified">Módosítva:</string>
<string name="filedetails_download">Letöltés</string>
+ <string name="filedetails_sync_file">Szinkronizálás</string>
<string name="filedetails_renamed_in_upload_msg">A feltöltés során az állmányt erre neveztük át: %1$s</string>
+ <string name="list_layout">Lista Elrendezés</string>
<string name="action_share_file">Megosztás hivatkozással</string>
<string name="action_unshare_file">Megosztás visszavonása</string>
<string name="common_yes">Igen</string>
<string name="common_no">Nem</string>
<string name="common_ok">OK</string>
+ <string name="common_cancel_sync">Szinkronizálás megállítása</string>
<string name="common_cancel">Mégsem</string>
<string name="common_save_exit">Mentés & Kilépés</string>
<string name="common_error">Hiba</string>
<string name="auth_no_net_conn_title">Nincs hálózati kapcsolat</string>
<string name="auth_nossl_plain_ok_title">Nem érhető el biztonságos kapcsolat.</string>
<string name="auth_connection_established">A kapcsolat létrejött</string>
+ <string name="auth_testing_connection">Kapcsolat ellenőrzése</string>
<string name="auth_not_configured_title">Hibás a kiszolgáló beállítása</string>
<string name="auth_account_not_new">Egy bejelentkezési beállítás már létezik ugyanehhez a kiszolgálóhoz és felhasználóhoz</string>
<string name="auth_account_not_the_same">A megadott felhasználó nem azonos ezzel a belépési jogosultsággal</string>
<string name="unfavorite">Nem kedvenc</string>
<string name="common_rename">Átnevezés</string>
<string name="common_remove">Eltávolítás</string>
- <string name="confirmation_remove_alert">Tényleg el akarod távolítani %1$s?</string>
+ <string name="confirmation_remove_file_alert">Tényleg el akarod távolítani %1$s?</string>
<string name="confirmation_remove_folder_alert">Tényleg el akarod távolítani a %1$s és tartalmát?</string>
<string name="confirmation_remove_local">Csak a helyi példány</string>
<string name="confirmation_remove_folder_local">Csak a helyi példány</string>
<string name="preview_image_description">Előnézeti kép</string>
<string name="preview_image_error_unknown_format">Ez a kép nem jeleníthető meg</string>
<string name="error__upload__local_file_not_copied">%1$s nem lehet másolni a %2$s helyi könyvtárba</string>
+ <string name="prefs_instant_upload_path_title">Feltöltési Elérési Út</string>
<string name="share_link_file_error">Hiba lépett fel a mappa megosztásakor</string>
<string name="unshare_link_file_error">Hiba lépett fel a mappa megosztásának visszavonásakor</string>
<string name="share_link_password_title">Jelszó beírása</string>
<string name="filedetails_created">Sukurta:</string>
<string name="filedetails_modified">Modifikuota:</string>
<string name="filedetails_download">Atsisiųsti</string>
+ <string name="filedetails_sync_file">Sinchronizuojama</string>
<string name="filedetails_renamed_in_upload_msg">Įkėlimo metu failas buvo pervadintas į %1$s</string>
<string name="list_layout">Sąrašo išdėstymas</string>
<string name="action_share_file">Dalintis nuoroda</string>
<string name="common_yes">Taip</string>
<string name="common_no">Ne</string>
<string name="common_ok">Gerai</string>
+ <string name="common_cancel_sync">Atšaukti sinchronizavimą</string>
<string name="common_cancel">Atšaukti</string>
<string name="common_save_exit">Išsaugoti ir Išeiti</string>
<string name="common_error">Klaida</string>
<string name="sync_fail_in_favourites_content">Nepavyko sinchronizuoti %1$d failų turinio (%2$d konfliktų)</string>
<string name="sync_foreign_files_forgotten_ticker">Keli vietiniai failai buvo užmiršti</string>
<string name="sync_foreign_files_forgotten_content">%1$d failai iš %2$s aplanko negali būti nukopijuoti</string>
+ <string name="sync_foreign_files_forgotten_explanation">Iki 1.3.16 versijos, iš šio įrenginio įkelti failai nukopijuoti į vietinį %1$s aplanką, siekiant išvengti duomenų praradimo kai vienas failas sinchronizuojamas su keletu įrenginių.\n\nTodėl visi failai įkelti su ankstesne versija nukopijuoti į %2$s aplanką. Dėja kopijavimas nepavuko dėl klaidos sinchronizuojant paskyrą. Galita palikti failus ir pašalinti ryšį su %3$s, arba perkelti failą(us) į %1$s aplanką ir palikti ryšį su %4$s.\n\nŽemiau pateikti vietiniai failai ir aplankas(ai), bei nutolę failai susieti per %5$s.</string>
<string name="sync_current_folder_was_removed">Aplankas %1$s nebeegzistuoja</string>
<string name="foreign_files_move">Perkelti visus</string>
<string name="foreign_files_success">Visi failai buvo perkelti</string>
<string name="unfavorite">Nebemėgti</string>
<string name="common_rename">Pervadinti</string>
<string name="common_remove">Pašalinti</string>
- <string name="confirmation_remove_alert">Ar tikrai norite pašalinti %1$s?</string>
+ <string name="confirmation_remove_file_alert">Ar tikrai norite pašalinti %1$s?</string>
<string name="confirmation_remove_folder_alert">Ar tikrai norite pašalinti %1$s ir ten esantį turinį?</string>
<string name="confirmation_remove_local">Tik vietiniai</string>
<string name="confirmation_remove_folder_local">Tik vietiniai</string>
<string name="prefs_category_instant_uploading">Momentinis įkėlimas</string>
<string name="prefs_category_security">Saugumas</string>
<string name="prefs_instant_video_upload_path_title">Vaizdo įrašų įkėlimo kelias</string>
+ <string name="sync_folder_failed_content">%1$s sinchronizavimas negali būti užbaigtas.</string>
<string name="shared_subject_header">Dalinamasi</string>
<string name="with_you_subject_header">su jumis</string>
<string name="subject_token">%1$s dalinamasi \"%2$s\" su jumis</string>
<string name="unfavorite">Niet meer favoriet</string>
<string name="common_rename">Hernoemen</string>
<string name="common_remove">Verwijderen</string>
- <string name="confirmation_remove_alert">Wilt u %1$s werkelijk verwijderen?</string>
+ <string name="confirmation_remove_file_alert">Wilt u %1$s werkelijk verwijderen?</string>
<string name="confirmation_remove_folder_alert">Wilt u %1$s en de inhoud ervan werkelijk verwijderen?</string>
<string name="confirmation_remove_local">Alleen lokaal</string>
<string name="confirmation_remove_folder_local">Alleen lokaal</string>
- <string name="confirmation_remove_remote">Van server</string>
+ <string name="confirmation_remove_file_remote">Van server</string>
<string name="confirmation_remove_remote_and_local">Extern & lokaal</string>
<string name="remove_success_msg">Succesvol verwijderd</string>
<string name="remove_fail_msg">Verwijdering kon niet voltooid worden</string>
<string name="log_progress_dialog_text">Laden data...</string>
<string name="saml_authentication_required_text">Authenticatie vereist</string>
<string name="saml_authentication_wrong_pass">Onjuist wachtwoord</string>
- <string name="actionbar_move">verplaatsen</string>
+ <string name="actionbar_move">Verplaatsen</string>
<string name="file_list_empty_moving">Niets hier. U kunt een map toevoegen!</string>
<string name="folder_picker_choose_button_text">Kies</string>
<string name="move_file_not_found">Kan niet verplaatsen. Ga na of het bestand wel bestaat</string>
<string name="filedetails_created">สร้างเมื่อ:</string>
<string name="filedetails_modified">แก้ไขเมื่อ:</string>
<string name="filedetails_download">ดาวน์โหลด</string>
+ <string name="filedetails_sync_file">ประสานข้อมูล</string>
<string name="filedetails_renamed_in_upload_msg">ไฟล์ได้ถูกเปลี่ยนชื่อเป็น %1$s ในระหว่างการอัพโหลด</string>
<string name="list_layout">เค้าโครงรายการ</string>
<string name="action_share_file">แชร์ลิงค์</string>
<string name="common_yes">ตกลง</string>
<string name="common_no">ไม่ตกลง</string>
<string name="common_ok">ตกลง</string>
+ <string name="common_cancel_sync">ยกเลิกการประสานข้อมูล</string>
<string name="common_cancel">ยกเลิก</string>
<string name="common_save_exit">บันทึก & ออก</string>
<string name="common_error">ข้อผิดพลาด</string>
<string name="unfavorite">ออกจากรายการโปรด</string>
<string name="common_rename">เปลี่ยนชื่อ</string>
<string name="common_remove">ลบออก</string>
- <string name="confirmation_remove_alert">คุณต้องการที่จะลบ %1$s?</string>
+ <string name="confirmation_remove_file_alert">คุณต้องการที่จะลบ %1$s?</string>
<string name="confirmation_remove_folder_alert">คุณต้องการที่จะลบ %1$s และเนื้อหาของมัน?</string>
<string name="confirmation_remove_local">เฉพาะต้นทางเท่านั้น</string>
<string name="confirmation_remove_folder_local">เฉพาะต้นทางเท่านั้น</string>
- <string name="confirmation_remove_remote">จากเซิฟเวอร์</string>
+ <string name="confirmation_remove_file_remote">จากเซิฟเวอร์</string>
<string name="confirmation_remove_remote_and_local">รีโมท & ต้นทาง</string>
<string name="remove_success_msg">ลบเรียบร้อยแล้ว</string>
<string name="remove_fail_msg">ไม่สามารถลบได้</string>
<string name="prefs_category_instant_uploading">อัพโหลดทันที</string>
<string name="prefs_category_security">ความปลอดภัย</string>
<string name="prefs_instant_video_upload_path_title">อัพโหลดเส้นทางวิดีโอ</string>
+ <string name="sync_folder_failed_content">ประสานข้อมูลโฟลเดอร์ %1$s ไม่สำเร็จ</string>
<string name="shared_subject_header">ถูกแชร์</string>
<string name="with_you_subject_header">กับคุณ</string>
<string name="subject_token">%1$s ได้แชร์ \"%2$s\" กับคุณ</string>
<!-- TODO re-enable when "Accounts" is available in Navigation Drawer -->
<!--<string name="drawer_item_accounts">Accounts</string>-->
<string name="drawer_item_all_files">All files</string>
- <!-- TODO re-enable when "On Device" is available
- <string name="drawer_item_on_device">On device</string>-->
+ <string name="drawer_item_on_device">On device</string>
<string name="drawer_item_settings">Settings</string>
<string name="drawer_item_logs">Logs</string>
<string name="drawer_close">Close</string>
<string name="list_layout">List Layout</string>
<string name="action_share_file">Share link</string>
<string name="action_unshare_file">Unshare link</string>
+ <string name="action_share_with_users">Share with users</string>
<string name="common_yes">Yes</string>
<string name="common_no">No</string>
<string name="common_ok">OK</string>
<string name="unfavorite">Unfavorite</string>
<string name="common_rename">Rename</string>
<string name="common_remove">Remove</string>
- <string name="confirmation_remove_alert">"Do you really want to remove %1$s?"</string>
+ <string name="confirmation_remove_file_alert">"Do you really want to remove %1$s?"</string>
<string name="confirmation_remove_folder_alert">"Do you really want to remove %1$s and its contents?"</string>
<string name="confirmation_remove_local">Local only</string>
<string name="confirmation_remove_folder_local">Local only</string>
- <string name="confirmation_remove_remote">From server</string>
+ <string name="confirmation_remove_file_remote">From server</string>
<string name="confirmation_remove_remote_and_local">Remote & local</string>
<string name="remove_success_msg">"Removal succeeded"</string>
<string name="remove_fail_msg">"Removal failed"</string>
<string name="placeholder_filesize">389 KB</string>
<string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
<string name="placeholder_media_time">12:23:45</string>
-
- <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_upload_on_wifi">Upload pictures via wifi only</string>
+ <string name="instant_upload_on_charging">Upload when charging 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_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>
<string name="preview_image_error_unknown_format">This image cannot be shown</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">Upload Path</string>
+ <string name="prefs_instant_upload_path_title">Upload path</string>
<string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your
administrator.</string>
<string name="prefs_category_instant_uploading">Instant Uploads</string>
<string name="prefs_category_security">Security</string>
- <string name="prefs_instant_video_upload_path_title">Upload Video Path</string>
+ <string name="prefs_instant_video_upload_path_title">Upload video path</string>
+ <string name="download_folder_failed_content">Download of %1$s folder could not be completed</string>
<string name="sync_folder_failed_content">Synchronization of %1$s folder could not be completed</string>
<string name="shared_subject_header">shared</string>
<string name="with_you_subject_header">with you</string>
- <string name="subject_token">%1$s shared \"%2$s\" with you</string>
- <string name="saml_subject_token">\"%1$s\" has been shared with you</string>
+ <string name="subject_user_shared_with_you">%1$s shared \"%2$s\" with you</string>
+ <string name="subject_shared_with_you">\"%1$s\" has been shared with you</string>
<string name="auth_refresh_button">Refresh connection</string>
<string name="auth_host_address">Server address</string>
<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="action_switch_grid_view">Switch to grid view</string>
+ <string name="action_switch_list_view">Switch to list view</string>
+ <string name="common_category">Common</string>
+ <string name="pref_cache_size">Cache size</string>
+ <string name="prefs_instant_behaviour_dialogTitle">Upload file to server and ...</string>
+ <string name="prefs_instant_behaviour_title">Behaviour</string>
+ <string name="upload_copy_files">Copy file</string>
+ <string name="upload_move_files">Move file</string>
+
+ <string name="pref_behaviour_entries_do_nothing">do nothing</string>
+ <string name="pref_behaviour_entries_copy">copy file to OC folder</string>
+ <string name="pref_behaviour_entries_move">move file to OC folder</string>
+ <string name="pref_behaviour_entries_delete">delete origin file</string>
+ <string name="confirmation_remove_files_alert">Do you really want to remove selected items?</string>
+ <string name="confirmation_remove_folders_alert">Do you really want to remove a folder and its content?</string>
+ <string name="confirmation_remove_files">selected items</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="action_stream_file">Stream file with external player</string>
+ <string name="stream_expose_password">Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password!</string>
+ <string name="set_picture_as">Set picture as</string>
+ <string name="share_dialog_title">Sharing</string>
+ <string name="share_with_user_section_title">Share with Users and Groups</string>
+ <string name="share_no_users">No data shared with users yet</string>
+ <string name="share_add_user_or_group">Add User or Group</string>
+ <string name="share_search">Search</string>
+
+ <string name="search_users_and_groups_hint">Search users and groups</string>
+ <string name="share_group_clarification">%1$s (group)</string>
+
+ <string name="share_sharee_unavailable">Sorry, your server version does not allow share with users within clients.
+ \nPlease contact your administrator</string>
+
</resources>
<style name="Theme.ownCloud" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
<item name="actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
- <item name="android:buttonStyle">@style/Theme.ownCloud.ButtonStyle</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
<item name="android:alertDialogTheme">@style/Theme.ownCloud.Dialog</item>
<item name="alertDialogTheme">@style/ownCloud.AlertDialog</item>
- <item name="colorButtonNormal">@color/background_color</item>
- <item name="colorControlActivated">@color/primary_dark</item>
- <item name="colorControlHighlight">@color/color_accent</item>
</style>
<!-- seperate action bar style for activities without an action bar -->
<style name="Theme.ownCloud.noActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
- <item name="android:buttonStyle">@style/Theme.ownCloud.ButtonStyle</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorAccent">@color/color_accent</item>
<item name="android:alertDialogTheme">@style/Theme.ownCloud.Dialog</item>
<item name="alertDialogTheme">@style/ownCloud.AlertDialog</item>
- <item name="colorButtonNormal">@color/background_color</item>
- <item name="colorControlActivated">@color/primary_dark</item>
- <item name="colorControlHighlight">@color/color_accent</item>
</style>
<style name="Theme.ownCloud.noActionBar.Login" parent="Theme.ownCloud.noActionBar">
<item name="android:textColorPrimary">@color/primary</item>
</style>
- <style name="ownCloud.Dialog" parent="Theme.AppCompat.Light.Dialog" />
+ <style name="ownCloud.Dialog" parent="Theme.AppCompat.Light.Dialog">
+ <item name="colorAccent">@color/color_accent</item>
+ </style>
<style name="ProgressDialogTheme" parent="ownCloud.Dialog">
<item name="colorAccent">@color/color_accent</item>
<style name="Theme.ownCloud.Fullscreen" parent="style/Theme.AppCompat">
<item name="android:windowFullscreen">true</item>
+ <item name="colorAccent">@color/color_accent</item>
</style>
<item name="buttonBarStyle">@style/Theme.ownCloud.Dialog.ButtonBar</item>
</style>
+ <style name="menu_labels_style">
+ <item name="android:background">@drawable/fab_label_background</item>
+ <item name="android:textColor">@color/fab_white</item>
+ </style>
+
<!-- Button Bar hack due to Lollipop bug:
https://code.google.com/p/android/issues/detail?id=78302
fix see:
<color name="setup_text_hint">#777777</color>
<color name="setup_text_typed">#000000</color>
+ <style name="Theme.ownCloud.NoActionBar">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ </style>
+ <style name="Theme.ownCloud.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
+ <style name="Theme.ownCloud.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
}
- public Vector<OCFile> getFolderContent(OCFile f/*, boolean onlyOnDevice*/) {
+ public Vector<OCFile> getFolderContent(OCFile f, boolean onlyOnDevice) {
if (f != null && f.isFolder() && f.getFileId() != -1) {
- // TODO Enable when "On Device" is recovered ?
- return getFolderContent(f.getFileId()/*, onlyOnDevice*/);
+ return getFolderContent(f.getFileId(), onlyOnDevice);
} else {
return new Vector<OCFile>();
}
- public Vector<OCFile> getFolderImages(OCFile folder/*, boolean onlyOnDevice*/) {
- Vector<OCFile> ret = new Vector<OCFile>();
+ public Vector<OCFile> getFolderImages(OCFile folder, boolean onlyOnDevice) {
+ Vector<OCFile> ret = new Vector<OCFile>();
if (folder != null) {
// TODO better implementation, filtering in the access to database instead of here
- // TODO Enable when "On Device" is recovered ?
- Vector<OCFile> tmp = getFolderContent(folder/*, onlyOnDevice*/);
- OCFile current = null;
+ Vector<OCFile> tmp = getFolderContent(folder, onlyOnDevice);
+ OCFile current = null;
for (int i=0; i<tmp.size(); i++) {
current = tmp.get(i);
if (current.isImage()) {
boolean overriden = false;
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
- cv.put(
- ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
- file.getModificationTimestampAtLastSyncForData()
+ cv.put(
+ ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
+ file.getModificationTimestampAtLastSyncForData()
);
cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
- cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, file.getEtagInConflict());
boolean sameRemotePath = fileExists(file.getRemotePath());
- if (sameRemotePath || fileExists(file.getFileId())) { // for renamed files; no more delete and create
+ if (sameRemotePath ||
+ fileExists(file.getFileId())) { // for renamed files; no more delete and create
OCFile oldFile;
if (sameRemotePath) {
*/
public void saveFolder(
OCFile folder, Collection<OCFile> updatedFiles, Collection<OCFile> filesToRemove
- ) {
-
- Log_OC.d(TAG, "Saving folder " + folder.getRemotePath() + " with " + updatedFiles.size()
+ ) {
+
+ Log_OC.d(TAG, "Saving folder " + folder.getRemotePath() + " with " + updatedFiles.size()
+ " children and " + filesToRemove.size() + " files to remove");
- ArrayList<ContentProviderOperation> operations =
+ ArrayList<ContentProviderOperation> operations =
new ArrayList<ContentProviderOperation>(updatedFiles.size());
// prepare operations to insert or update files to save in the given folder
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
cv.put(
- ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
- file.getModificationTimestampAtLastSyncForData()
+ ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
+ file.getModificationTimestampAtLastSyncForData()
);
cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
- cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
ProviderTableMeta.CONTENT_URI_DIR, file.getFileId()
)
).withSelection(where, whereArgs).build());
-
- File localFolder =
+
+ File localFolder =
new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
if (localFolder.exists()) {
removeLocalFolder(localFolder);
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, folder.getModificationTimestamp());
cv.put(
- ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
- folder.getModificationTimestampAtLastSyncForData()
+ ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
+ folder.getModificationTimestampAtLastSyncForData()
);
cv.put(ProviderTableMeta.FILE_CREATION, folder.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, 0);
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, folder.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag());
- cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, folder.isShareByLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, folder.isSharedViaLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, folder.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, folder.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId());
} else {
if (removeDBData) {
- //Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId());
- Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, file.getFileId());
- String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " + ProviderTableMeta.FILE_PATH + "=?";
+ //Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE,
+ // ""+file.getFileId());
+ Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE,
+ file.getFileId());
+ String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " +
+ ProviderTableMeta.FILE_PATH + "=?";
String[] whereArgs = new String[]{mAccount.name, file.getRemotePath()};
int deleted = 0;
if (getContentProviderClient() != null) {
private boolean removeFolderInDb(OCFile folder) {
Uri folder_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, "" +
folder.getFileId()); // URI for recursive deletion
- String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " +
+ String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " +
ProviderTableMeta.FILE_PATH + "=?";
String [] whereArgs = new String[]{mAccount.name, folder.getRemotePath()};
int deleted = 0;
File localFolder = new File(localFolderPath);
if (localFolder.exists()) {
// stage 1: remove the local files already registered in the files database
- // TODO Enable when "On Device" is recovered ?
- Vector<OCFile> files = getFolderContent(folder.getFileId()/*, false*/);
+ Vector<OCFile> files = getFolderContent(folder.getFileId(), false);
if (files != null) {
for (OCFile file : files) {
if (file.isFolder()) {
return success;
}
-
+
/**
* Updates database and file system for a file or folder that was moved to a different location.
*
OCFile targetParent = getFileByPath(targetParentPath);
if (targetParent == null) {
- throw new IllegalStateException("Parent folder of the target path does not exist!!");
+ throw new IllegalStateException(
+ "Parent folder of the target path does not exist!!");
}
/// 1. get all the descendants of the moved element in a single QUERY
// update link to downloaded content - but local move is not done here!
String targetLocalPath = defaultSavePath + targetPath +
child.getStoragePath().substring(lengthOfOldStoragePath);
-
+
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, targetLocalPath);
-
+
originalPathsToTriggerMediaScan.add(child.getStoragePath());
newPathsToTriggerMediaScan.add(targetLocalPath);
-
+
}
if (child.getRemotePath().equals(file.getRemotePath())) {
cv.put(
}
} catch (Exception e) {
- Log_OC.e(TAG, "Fail to update " + file.getFileId() + " and descendants in database", e);
+ Log_OC.e(TAG, "Fail to update " + file.getFileId() + " and descendants in database",
+ e);
}
/// 4. move in local file system
return ret;
}
-
- private Vector<OCFile> getFolderContent(long parentId/*, boolean onlyOnDevice*/) {
+
+ private Vector<OCFile> getFolderContent(long parentId, boolean onlyOnDevice) {
Vector<OCFile> ret = new Vector<OCFile>();
if (c.moveToFirst()) {
do {
OCFile child = createFileInstance(c);
- // TODO Enable when "On Device" is recovered ?
- // if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
- ret.add(child);
- // }
+ if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
+ ret.add(child);
+ }
} while (c.moveToNext());
}
file.setFavorite(c.getInt(
c.getColumnIndex(ProviderTableMeta.FILE_KEEP_IN_SYNC)) == 1 ? true : false);
file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG)));
- file.setShareByLink(c.getInt(
- c.getColumnIndex(ProviderTableMeta.FILE_SHARE_BY_LINK)) == 1 ? true : false);
+ file.setShareViaLink(c.getInt(
+ c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_LINK)) == 1 ? true : false);
+ file.setShareWithSharee(c.getInt(
+ c.getColumnIndex(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1 ? true : false);
file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK)));
file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS)));
file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID)));
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
cv.put(
- ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
- share.getSharedWithDisplayName()
+ ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
+ share.getSharedWithDisplayName()
);
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getIdRemoteShared());
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
- if (shareExists(share.getIdRemoteShared())) { // for renamed files; no more delete and create
+ if (shareExists(share.getIdRemoteShared())) {// for renamed files; no more delete and create
overriden = true;
if (getContentResolver() != null) {
getContentResolver().update(ProviderTableMeta.CONTENT_URI_SHARE, cv,
}
- public OCShare getFirstShareByPathAndType(String path, ShareType type) {
+ public OCShare getFirstShareByPathAndType(String path, ShareType type, String shareWith) {
Cursor c = null;
+
+ String selection = ProviderTableMeta.OCSHARES_PATH + "=? AND "
+ + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND "
+ + ProviderTableMeta.OCSHARES_SHARE_WITH + "=? AND "
+ + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?" ;
+
+ String [] selectionArgs = new String[]{path, Integer.toString(type.getValue()),
+ shareWith, mAccount.name};
+
if (getContentResolver() != null) {
c = getContentResolver().query(
ProviderTableMeta.CONTENT_URI_SHARE,
null,
- ProviderTableMeta.OCSHARES_PATH + "=? AND "
- + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND "
- + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
- new String[]{path, Integer.toString(type.getValue()), mAccount.name},
+ selection, selectionArgs,
null);
} else {
try {
c = getContentProviderClient().query(
ProviderTableMeta.CONTENT_URI_SHARE,
null,
- ProviderTableMeta.OCSHARES_PATH + "=? AND "
- + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND "
- + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
- new String[]{path, Integer.toString(type.getValue()), mAccount.name},
+ selection, selectionArgs,
null);
} catch (RemoteException e) {
.getColumnIndex(ProviderTableMeta.OCSHARES_ITEM_SOURCE)));
share.setShareType(ShareType.fromValue(c.getInt(c
.getColumnIndex(ProviderTableMeta.OCSHARES_SHARE_TYPE))));
+ share.setShareWith(c.getString(c
+ .getColumnIndex(ProviderTableMeta.OCSHARES_SHARE_WITH)));
share.setPermissions(c.getInt(c
.getColumnIndex(ProviderTableMeta.OCSHARES_PERMISSIONS)));
share.setSharedDate(c.getLong(c
share.setIsFolder(c.getInt(
c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_DIRECTORY)) == 1);
share.setUserId(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_USER_ID)));
- share.setIdRemoteShared(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)));
+ share.setIdRemoteShared(c.getLong(
+ c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)));
}
return share;
}
return shareExists(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, String.valueOf(remoteId));
}
- private void cleanSharedFiles() {
+ private void resetShareFlagsInAllFiles() {
ContentValues cv = new ContentValues();
- cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
String[] whereArgs = new String[]{mAccount.name};
} else {
try {
- getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
+ getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where,
+ whereArgs);
} catch (RemoteException e) {
- Log_OC.e(TAG, "Exception in cleanSharedFiles" + e.getMessage());
+ Log_OC.e(TAG, "Exception in resetShareFlagsInAllFiles" + e.getMessage());
}
}
}
- private void cleanSharedFilesInFolder(OCFile folder) {
+ private void resetShareFlagsInFolder(OCFile folder) {
ContentValues cv = new ContentValues();
- cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
ProviderTableMeta.FILE_PARENT + "=?";
String [] whereArgs = new String[] { mAccount.name , String.valueOf(folder.getFileId()) };
-
+
+ if (getContentResolver() != null) {
+ getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
+
+ } else {
+ try {
+ getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where,
+ whereArgs);
+ } catch (RemoteException e) {
+ Log_OC.e(TAG, "Exception in resetShareFlagsInFolder " + e.getMessage());
+ }
+ }
+ }
+
+ private void resetShareFlagInAFile(String filePath){
+ ContentValues cv = new ContentValues();
+ cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
+ cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
+ String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
+ ProviderTableMeta.FILE_PATH+ "=?";
+ String [] whereArgs = new String[] { mAccount.name , filePath };
+
if (getContentResolver() != null) {
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
} else {
try {
- getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
+ getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where,
+ whereArgs);
} catch (RemoteException e) {
- Log_OC.e(TAG, "Exception in cleanSharedFilesInFolder " + e.getMessage());
+ Log_OC.e(TAG, "Exception in resetShareFlagsInFolder " + e.getMessage());
}
}
}
} else {
try {
- getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs);
+ getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_SHARE, where,
+ whereArgs);
} catch (RemoteException e) {
Log_OC.e(TAG, "Exception in cleanShares" + e.getMessage());
}
public void saveShares(Collection<OCShare> shares) {
cleanShares();
if (shares != null) {
- ArrayList<ContentProviderOperation> operations =
+ ArrayList<ContentProviderOperation> operations =
new ArrayList<ContentProviderOperation>(shares.size());
// prepare operations to insert or update files to save in the given folder
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
cv.put(
- ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
- share.getSharedWithDisplayName()
+ ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
+ share.getSharedWithDisplayName()
);
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
// updating an existing file
operations.add(
ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI_SHARE).
- withValues(cv).
- withSelection(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?",
- new String[]{String.valueOf(share.getIdRemoteShared())})
- .build());
+ withValues(cv).
+ withSelection(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?",
+ new String[]{String.valueOf(share.getIdRemoteShared())})
+ .build());
} else {
// adding a new file
operations.add(
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE).
- withValues(cv).
- build()
+ withValues(cv).
+ build()
);
}
}
if (operations.size() > 0) {
@SuppressWarnings("unused")
ContentProviderResult[] results = null;
- Log_OC.d(TAG, "Sending " + operations.size() +
+ Log_OC.d(TAG, "Sending " + operations.size() +
" operations to FileContentProvider");
try {
if (getContentResolver() != null) {
- results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
+ results = getContentResolver().applyBatch(MainApp.getAuthority(),
+ operations);
} else {
results = getContentProviderClient().applyBatch(operations);
}
}
public void updateSharedFiles(Collection<OCFile> sharedFiles) {
- cleanSharedFiles();
+ resetShareFlagsInAllFiles();
if (sharedFiles != null) {
- ArrayList<ContentProviderOperation> operations =
+ ArrayList<ContentProviderOperation> operations =
new ArrayList<ContentProviderOperation>(sharedFiles.size());
// prepare operations to insert or update files to save in the given folder
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp());
cv.put(
- ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
- file.getModificationTimestampAtLastSyncForData()
+ ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA,
+ file.getModificationTimestampAtLastSyncForData()
);
cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp());
cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength());
cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name);
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
cv.put(
- ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
- file.getLastSyncDateForData()
+ ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
+ file.getLastSyncDateForData()
);
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
- cv.put(ProviderTableMeta.FILE_SHARE_BY_LINK, file.isShareByLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(
- ProviderTableMeta.FILE_UPDATE_THUMBNAIL,
- file.needsUpdateThumbnail() ? 1 : 0
+ ProviderTableMeta.FILE_UPDATE_THUMBNAIL,
+ file.needsUpdateThumbnail() ? 1 : 0
);
cv.put(
ProviderTableMeta.FILE_IS_DOWNLOADING,
// updating an existing file
operations.add(
ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI).
- withValues(cv).
- withSelection(ProviderTableMeta._ID + "=?",
- new String[]{String.valueOf(file.getFileId())})
- .build());
+ withValues(cv).
+ withSelection(ProviderTableMeta._ID + "=?",
+ new String[]{String.valueOf(file.getFileId())})
+ .build());
} else {
// adding a new file
operations.add(
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI).
- withValues(cv).
- build()
+ withValues(cv).
+ build()
);
}
}
if (operations.size() > 0) {
@SuppressWarnings("unused")
ContentProviderResult[] results = null;
- Log_OC.d(TAG, "Sending " + operations.size() +
+ Log_OC.d(TAG, "Sending " + operations.size() +
" operations to FileContentProvider");
try {
if (getContentResolver() != null) {
public void removeShare(OCShare share) {
Uri share_uri = ProviderTableMeta.CONTENT_URI_SHARE;
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?" + " AND " +
- ProviderTableMeta.FILE_PATH + "=?";
- String [] whereArgs = new String[]{mAccount.name, share.getPath()};
+ ProviderTableMeta._ID + "=?";
+ String [] whereArgs = new String[]{mAccount.name, Long.toString(share.getId())};
if (getContentProviderClient() != null) {
try {
getContentProviderClient().delete(share_uri, where, whereArgs);
}
public void saveSharesDB(ArrayList<OCShare> shares) {
- saveShares(shares);
-
- ArrayList<OCFile> sharedFiles = new ArrayList<OCFile>();
+ ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
- for (OCShare share : shares) {
- // Get the path
- String path = share.getPath();
- if (share.isFolder()) {
- path = path + FileUtils.PATH_SEPARATOR;
+ // Reset flags & Remove shares for this files
+ String filePath = "";
+ for (OCShare share: shares) {
+ if (filePath != share.getPath()){
+ filePath = share.getPath();
+ resetShareFlagInAFile(filePath);
+ operations = prepareRemoveSharesInFile(filePath, operations);
}
+ }
+
+ // Add operations to insert shares
+ operations = prepareInsertShares(shares, operations);
- // Update OCFile with data from share: ShareByLink and publicLink
- OCFile file = getFileByPath(path);
- if (file != null) {
- if (share.getShareType().equals(ShareType.PUBLIC_LINK)) {
- file.setShareByLink(true);
- sharedFiles.add(file);
+ // apply operations in batch
+ if (operations.size() > 0) {
+ Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
+ try {
+ if (getContentResolver() != null) {
+ getContentResolver().applyBatch(MainApp.getAuthority(), operations);
+
+ } else {
+ getContentProviderClient().applyBatch(operations);
}
+
+ } catch (OperationApplicationException e) {
+ Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
+
+ } catch (RemoteException e) {
+ Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
}
}
- updateSharedFiles(sharedFiles);
+ // // TODO: review if it is needed
+ // // Update shared files
+ // ArrayList<OCFile> sharedFiles = new ArrayList<OCFile>();
+ //
+ // for (OCShare share : shares) {
+ // // Get the path
+ // String path = share.getPath();
+ // if (share.isFolder()) {
+ // path = path + FileUtils.PATH_SEPARATOR;
+ // }
+ //
+ // // Update OCFile with data from share: ShareByLink, publicLink and
+ // OCFile file = getFileByPath(path);
+ // if (file != null) {
+ // if (share.getShareType().equals(ShareType.PUBLIC_LINK)) {
+ // file.setShareViaLink(true);
+ // sharedFiles.add(file);
+ // }
+ // }
+ // }
+ //
+ // // TODO: Review
+ // updateSharedFiles(sharedFiles);
}
public void saveSharesInFolder(ArrayList<OCShare> shares, OCFile folder) {
- cleanSharedFilesInFolder(folder);
+ resetShareFlagsInFolder(folder);
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
operations = prepareRemoveSharesInFolder(folder, operations);
if (shares != null) {
// prepare operations to insert or update files to save in the given folder
+ operations = prepareInsertShares(shares, operations);
+ }
+
+ // apply operations in batch
+ if (operations.size() > 0) {
+ Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
+ try {
+ if (getContentResolver() != null) {
+ getContentResolver().applyBatch(MainApp.getAuthority(), operations);
+
+ } else {
+ getContentProviderClient().applyBatch(operations);
+ }
+
+ } catch (OperationApplicationException e) {
+ Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
+
+ } catch (RemoteException e) {
+
+ }
+ }
+
+ }
+
+ /**
+ * Prepare operations to insert or update files to save in the given folder
+ * @param shares List of shares to insert
+ * @param operations List of operations
+ * @return
+ */
+ private ArrayList<ContentProviderOperation> prepareInsertShares(
+ ArrayList<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
+
+ if (shares != null) {
+ // prepare operations to insert or update files to save in the given folder
for (OCShare share : shares) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource());
cv.put(ProviderTableMeta.OCSHARES_EXPIRATION_DATE, share.getExpirationDate());
cv.put(ProviderTableMeta.OCSHARES_TOKEN, share.getToken());
cv.put(
- ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
- share.getSharedWithDisplayName()
+ ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME,
+ share.getSharedWithDisplayName()
);
cv.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
cv.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getIdRemoteShared());
cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name);
- /*
- if (shareExists(share.getIdRemoteShared())) {
- // updating an existing share resource
- operations.add(
- ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI_SHARE).
- withValues(cv).
- withSelection( ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?",
- new String[] { String.valueOf(share.getIdRemoteShared()) })
- .build());
-
- } else {
- */
// adding a new share resource
operations.add(
ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE).
- withValues(cv).
- build()
+ withValues(cv).
+ build()
);
- //}
- }
- }
-
- // apply operations in batch
- if (operations.size() > 0) {
- @SuppressWarnings("unused")
- ContentProviderResult[] results = null;
- Log_OC.d(TAG, "Sending " + operations.size() + " operations to FileContentProvider");
- try {
- if (getContentResolver() != null) {
- results = getContentResolver().applyBatch(MainApp.getAuthority(), operations);
-
- } else {
- results = getContentProviderClient().applyBatch(operations);
- }
-
- } catch (OperationApplicationException e) {
- Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
-
- } catch (RemoteException e) {
- Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage());
}
}
- //}
-
+ return operations;
}
private ArrayList<ContentProviderOperation> prepareRemoveSharesInFolder(
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
String [] whereArgs = new String[]{ "", mAccount.name };
- // TODO Enable when "On Device" is recovered ?
- Vector<OCFile> files = getFolderContent(folder /*, false*/);
-
+ Vector<OCFile> files = getFolderContent(folder, false);
+
for (OCFile file : files) {
whereArgs[0] = file.getRemotePath();
preparedOperations.add(
ContentProviderOperation.newDelete(ProviderTableMeta.CONTENT_URI_SHARE).
- withSelection(where, whereArgs).
- build()
+ withSelection(where, whereArgs).
+ build()
);
}
}
return preparedOperations;
+
+ }
+
+ private ArrayList<ContentProviderOperation> prepareRemoveSharesInFile(
+ String filePath, ArrayList<ContentProviderOperation> preparedOperations) {
+
+ String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND "
+ + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
+ String[] whereArgs = new String[]{filePath, mAccount.name};
+
+ preparedOperations.add(
+ ContentProviderOperation.newDelete(ProviderTableMeta.CONTENT_URI_SHARE).
+ withSelection(where, whereArgs).
+ build()
+ );
+
+ return preparedOperations;
+
+ }
+
+ public ArrayList<OCShare> getSharesWithForAFile(String filePath, String accountName){
+ // Condition
+ String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND "
+ + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?"+ "AND"
+ + " (" + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR "
+ + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? ) ";
+ String [] whereArgs = new String[]{ filePath, accountName ,
+ Integer.toString(ShareType.USER.getValue()),
+ Integer.toString(ShareType.GROUP.getValue()) };
+
+ Cursor c = null;
+ if (getContentResolver() != null) {
+ c = getContentResolver().query(
+ ProviderTableMeta.CONTENT_URI_SHARE,
+ null, where, whereArgs, null);
+ } else {
+ try {
+ c = getContentProviderClient().query(
+ ProviderTableMeta.CONTENT_URI_SHARE,
+ null, where, whereArgs, null);
+
+ } catch (RemoteException e) {
+ Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage());
+ c = null;
+ }
+ }
+ ArrayList<OCShare> shares = new ArrayList<OCShare>();
+ OCShare share = null;
+ if (c.moveToFirst()) {
+ do {
+ share = createShareInstance(c);
+ shares.add(share);
+ // }
+ } while (c.moveToNext());
+ }
+ c.close();
+
+ return shares;
}
- public void triggerMediaScan(String path) {
+ public static void triggerMediaScan(String path) {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(new File(path)));
MainApp.getAppContext().sendBroadcast(intent);
import third_parties.daveKoeller.AlphanumComparator;
public class OCFile implements Parcelable, Comparable<OCFile> {
- public static final Parcelable.Creator<OCFile> CREATOR = new Parcelable.Creator<OCFile>() {
- @Override
+ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public OCFile createFromParcel(Parcel source) {
return new OCFile(source);
}
- @Override
public OCFile[] newArray(int size) {
return new OCFile[size];
}
};
+ private final static String PERMISSION_SHARED_WITH_ME = "S"; // TODO move to better location
+
public static final String PATH_SEPARATOR = "/";
public static final String ROOT_PATH = PATH_SEPARATOR;
private boolean mIsDownloading;
+ private boolean mShowGridView;
+
private String mEtagInConflict; // Save file etag in the server, when there is a conflict. No conflict = null
+ private boolean mShareWithSharee;
+
/**
* Create new {@link OCFile} with given path.
mNeedsUpdateThumbnail = source.readInt() == 1;
mIsDownloading = source.readInt() == 1;
mEtagInConflict = source.readString();
+ mShareWithSharee = source.readInt() == 1;
}
dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0);
dest.writeInt(mIsDownloading ? 1 : 0);
dest.writeString(mEtagInConflict);
+ dest.writeInt(mShareWithSharee ? 1 : 0);
}
/**
mNeedsUpdateThumbnail = false;
mIsDownloading = false;
mEtagInConflict = null;
+ mShareWithSharee = false;
}
/**
this.mEtag = (etag != null ? etag : "");
}
- public boolean isShareByLink() {
+
+ public boolean isSharedViaLink() {
return mShareByLink;
}
- public void setShareByLink(boolean shareByLink) {
+ public void setShareViaLink(boolean shareByLink) {
this.mShareByLink = shareByLink;
}
public void setEtagInConflict(String etagInConflict) {
mEtagInConflict = etagInConflict;
}
+
+ public boolean isSharedWithSharee() {
+ return mShareWithSharee;
+ }
+
+ public void setShareWithSharee(boolean shareWithSharee) {
+ this.mShareWithSharee = shareWithSharee;
+ }
+
+ public boolean isSharedWithMe() {
+ String permissions = getPermissions();
+ return (permissions != null && permissions.contains(PERMISSION_SHARED_WITH_ME));
+ }
}
import android.view.MenuItem;
import com.owncloud.android.R;
+ import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileDownloader;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
* {@link FileUploader} and {@link FileDownloader} services
* @param context Android {@link Context}, needed to access build setup resources.
*/
- public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg, Context context) {
+ public FileMenuFilter(OCFile targetFile, Account account, ComponentsGetter cg,
+ Context context) {
mFile = targetFile;
mAccount = account;
mComponentsGetter = cg;
toShow.add(R.id.action_sync_file);
}
- // SHARE FILE
+ // SHARE FILE
// TODO add check on SHARE available on server side?
boolean shareAllowed = (mContext != null &&
mContext.getString(R.string.share_feature).equalsIgnoreCase("on"));
toShow.add(R.id.action_share_file);
}
- // UNSHARE FILE
+ // UNSHARE FILE
// TODO add check on SHARE available on server side?
- if ( !shareAllowed || (mFile == null || !mFile.isShareByLink())) {
+ if ( !shareAllowed || (mFile == null || !mFile.isSharedViaLink())) {
toHide.add(R.id.action_unshare_file);
} else {
toShow.add(R.id.action_unshare_file);
}
+ // SHARE FILE, with Users
+ if (!shareAllowed || mFile == null) {
+ toHide.add(R.id.action_share_with_users);
+ } else {
+ toShow.add(R.id.action_share_with_users);
+ }
+
+
// SEE DETAILS
if (mFile == null || mFile.isFolder()) {
toHide.add(R.id.action_see_details);
toShow.add(R.id.action_unfavorite_file);
}
+ // STREAM
+ if (mFile != null && !mFile.isDown() && (mFile.isAudio() || mFile.isVideo())){
+ toShow.add(R.id.action_stream_file);
+ } else {
+ toHide.add(R.id.action_stream_file);
+ }
+
}
}
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
+ import android.graphics.Bitmap;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
import android.net.Uri;
import android.support.v4.app.DialogFragment;
import android.webkit.MimeTypeMap;
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;
+ import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
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.adapter.DiskLruImageCacheFileProvider;
+ import com.owncloud.android.ui.activity.ShareActivity;
import com.owncloud.android.ui.dialog.ShareLinkToDialog;
+import org.apache.http.protocol.HTTP;
+
+import java.io.File;
+import java.util.List;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+ import org.apache.http.protocol.HTTP;
+
+import java.util.ArrayList;
+ import java.util.List;
/**
*
String encodedStoragePath = WebdavUtils.encodePath(storagePath);
Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW);
- intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), file.getMimetype());
+ intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath),
+ file.getMimetype());
intentForSavedMimeType.setFlags(
Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
);
);
if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) {
intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW);
- intentForGuessedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), guessedMimeType);
+ intentForGuessedMimeType.
+ setDataAndType(Uri.parse("file://"+ encodedStoragePath),
+ guessedMimeType);
intentForGuessedMimeType.setFlags(
- Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
+ Intent.FLAG_GRANT_READ_URI_PERMISSION |
+ Intent.FLAG_GRANT_WRITE_URI_PERMISSION
);
}
}
String link = "https://fake.url";
Intent intent = createShareWithLinkIntent(link);
String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
- DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent, packagesToExclude, file);
+ DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent,
+ packagesToExclude, file);
chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
} else {
} else {
// Show a Message
Toast t = Toast.makeText(
- mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG
+ mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api),
+ Toast.LENGTH_LONG
);
t.show();
}
public void shareFileWithLinkToApp(OCFile file, String password, Intent sendIntent) {
if (file != null) {
- mFileActivity.showLoadingDialog();
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
Intent service = new Intent(mFileActivity, OperationsService.class);
- service.setAction(OperationsService.ACTION_CREATE_SHARE);
+ service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
service.putExtra(OperationsService.EXTRA_PASSWORD_SHARE, password);
/**
+ * Helper method to share a file with a know sharee. Starts a request to do it in {@link OperationsService}
+ *
+ * @param file The file to share.
+ * @param shareeName Name (user name or group name) of the target sharee.
+ * @param shareType The share type determines the sharee type.
+ */
+ public void shareFileWithSharee(OCFile file, String shareeName, ShareType shareType) {
+ if (file != null) {
+ // TODO check capability?
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
+
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_CREATE_SHARE_WITH_SHAREE);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ service.putExtra(OperationsService.EXTRA_SHARE_WITH, shareeName);
+ service.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
+
+ } else {
+ Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
+ }
+ }
+
+
+ /**
* @return 'True' if the server supports the Share API
*/
public boolean isSharedSupported() {
public void unshareFileWithLink(OCFile file) {
+ // Unshare the file: Create the intent
+ Intent unshareService = new Intent(mFileActivity, OperationsService.class);
+ unshareService.setAction(OperationsService.ACTION_UNSHARE);
+ unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, ShareType.PUBLIC_LINK);
+ unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, "");
+
+ unshareFile(unshareService);
+ }
+
+ public void unshareFileWithUserOrGroup(OCFile file, ShareType shareType, String userOrGroup){
+
+ // Unshare the file: Create the intent
+ Intent unshareService = new Intent(mFileActivity, OperationsService.class);
+ unshareService.setAction(OperationsService.ACTION_UNSHARE);
+ unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
+ unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, userOrGroup);
+
+ unshareFile(unshareService);
+ }
+
+
+ private void unshareFile(Intent unshareService){
if (isSharedSupported()) {
// Unshare the file
- Intent service = new Intent(mFileActivity, OperationsService.class);
- service.setAction(OperationsService.ACTION_UNSHARE);
- service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
- service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
- mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
-
- mFileActivity.showLoadingDialog();
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().
+ queueNewOperation(unshareService);
+
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
} else {
// Show a Message
- Toast t = Toast.makeText(mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
+ Toast t = Toast.makeText(mFileActivity,
+ mFileActivity.getString(R.string.share_link_no_support_share_api),
+ Toast.LENGTH_LONG);
t.show();
}
}
+ /**
+ * Show an instance of {@link ShareType} for sharing or unsharing the {@OCFile} received as parameter.
+ *
+ * @param file File to share or unshare.
+ */
+ public void showShareFile(OCFile file){
+ Intent intent = new Intent(mFileActivity, ShareActivity.class);
+ intent.putExtra(mFileActivity.EXTRA_FILE, file);
+ intent.putExtra(mFileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ mFileActivity.startActivity(intent);
+
+ }
+
+
+ /**
+ * @return 'True' if the server supports the Search Users API
+ */
+ public boolean isSearchUsersSupportedSupported() {
+ if (mFileActivity.getAccount() != null) {
+ OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
+ return (serverVersion != null && serverVersion.isSearchUsersSupported());
+ }
+ return false;
+ }
+
public void sendDownloadedFile(OCFile file) {
if (file != null) {
String storagePath = file.getStoragePath();
// Show dialog, without the own app
String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
- DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
+ DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent,
+ packagesToExclude, file);
chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
} else {
}
}
+ public void setPictureAs(OCFile file) {
+ if (file != null){
+ if (file.isDown()) {
+ File externalFile = new File(file.getStoragePath());
+ Uri sendUri = Uri.fromFile(externalFile);
+ Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
+ intent.setDataAndType(sendUri, file.getMimetype());
+ intent.putExtra("mimeType", file.getMimetype());
+ mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
+ } else {
+ // TODO re-enable after resized images is available
+ Uri sendUri = Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath());
+ Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
+ intent.setDataAndType(sendUri, file.getMimetype());
+ intent.putExtra("mimeType", file.getMimetype());
+ mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
+
+// 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.getRemoteId() + "#" + file.getFileName()));
+// 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, file);
+// chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
+ }
+ } else {
+ Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
+ }
+ }
+
public void sendCachedImage(OCFile file) {
if (file != null) {
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
}
}
-
-
+
+ public void syncFiles(ArrayList<OCFile> files) {
+ for (OCFile file: files) {
+ syncFile(file);
+ }
+ }
/**
* Request the synchronization of a file or folder with the OC server, including its contents.
intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
- mFileActivity.showLoadingDialog();
-
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
+
} else {
Intent intent = new Intent(mFileActivity, OperationsService.class);
intent.setAction(OperationsService.ACTION_SYNC_FOLDER);
}
}
+ public void toggleFavorites(ArrayList<OCFile> files, boolean isFavorite){
+ for (OCFile file: files) {
+ toggleFavorite(file, isFavorite);
+ }
+ }
+
public void toggleFavorite(OCFile file, boolean isFavorite) {
file.setFavorite(isFavorite);
mFileActivity.getStorageManager().saveFile(file);
service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
- mFileActivity.showLoadingDialog();
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
}
service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy);
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
- mFileActivity.showLoadingDialog();
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
}
service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
- mFileActivity.showLoadingDialog();
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
}
/**
public void cancelTransference(OCFile file) {
Account account = mFileActivity.getAccount();
if (file.isFolder()) {
- OperationsService.OperationsServiceBinder opsBinder = mFileActivity.getOperationsServiceBinder();
+ OperationsService.OperationsServiceBinder opsBinder =
+ mFileActivity.getOperationsServiceBinder();
if (opsBinder != null) {
opsBinder.cancel(account, file);
}
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
- mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
- getString(R.string.wait_a_moment));
+ // TODO Tobi loading dialog?
- // mFileActivity.showLoadingDialog();
++// mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
++// getString(R.string.wait_a_moment));
}
/**
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
- mFileActivity.showLoadingDialog();
+ mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
+ getString(R.string.wait_a_moment));
}
public long getOpIdWaitingFor() {
*/
public boolean isVersionWithForbiddenCharacters() {
if (mFileActivity.getAccount() != null) {
- OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
+ OwnCloudVersion serverVersion =
+ AccountUtils.getServerVersion(mFileActivity.getAccount());
return (serverVersion != null && serverVersion.isVersionWithForbiddenCharacters());
}
return false;
result = fetchAndSyncRemoteFolder(client);
} else {
fetchFavoritesToSyncFromLocalData();
- mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
+ mChildren = mStorageManager.getFolderContent(mLocalFolder, false);
}
if (result.isSuccess()) {
mFilesToSyncContents.clear();
// get current data about local contents of the folder to synchronize
- // TODO Enable when "On Device" is recovered ?
- List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
+ List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder, false);
Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
for (OCFile file : localFiles) {
localFilesMap.put(file.getRemotePath(), file);
Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
}
updatedFile.setPublicLink(localFile.getPublicLink());
- updatedFile.setShareByLink(localFile.isShareByLink());
+ updatedFile.setShareViaLink(localFile.isSharedViaLink());
+ updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
updatedFile.setEtagInConflict(localFile.getEtagInConflict());
} else {
// remote eTag will not be updated unless file CONTENTS are synchronized
}
+ /**
+ * Syncs the Share resources for the files contained in the folder refreshed (children, not deeper descendants).
+ *
+ * @param client Handler of a session with an OC server.
+ * @return The result of the remote operation retrieving the Share resources in the folder refreshed by
+ * the operation.
+ */
private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
RemoteOperationResult result = null;
// remote request
GetRemoteSharesForFileOperation operation =
- new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), false, true);
+ new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), true, true);
result = operation.execute(client);
if (result.isSuccess()) {
private void fetchFavoritesToSyncFromLocalData() {
- List<OCFile> children = mStorageManager.getFolderContent(mLocalFolder);
+ List<OCFile> children = mStorageManager.getFolderContent(mLocalFolder, false);
for (OCFile child : children) {
if (!child.isFolder() && child.isFavorite()) {
SynchronizeFileOperation operation = new SynchronizeFileOperation(
}
// get current data about local contents of the folder to synchronize
- // TODO Enable when "On Device" is recovered ?
- List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder/*, false*/);
+ List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder, false);
Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
for (OCFile file : localFiles) {
localFilesMap.put(file.getRemotePath(), file);
Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
}
updatedFile.setPublicLink(localFile.getPublicLink());
- updatedFile.setShareByLink(localFile.isShareByLink());
+ updatedFile.setShareViaLink(localFile.isSharedViaLink());
+ updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
updatedFile.setEtagInConflict(localFile.getEtagInConflict());
} else {
// remote eTag will not be updated unless file CONTENTS are synchronized
private void prepareOpsFromLocalKnowledge() throws OperationCancelledException {
- // TODO Enable when "On Device" is recovered ?
- List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder/*, false*/);
+ List<OCFile> children = getStorageManager().getFolderContent(mLocalFolder, false);
for (OCFile child : children) {
/// classify file to sync/download contents later
if (child.isFolder()) {
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
- import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
- import com.owncloud.android.operations.CreateShareOperation;
+ import com.owncloud.android.operations.CreateShareViaLinkOperation;
+ import com.owncloud.android.operations.CreateShareWithShareeOperation;
+ import com.owncloud.android.operations.GetSharesForFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.SynchronizeFolderOperation;
- import com.owncloud.android.operations.UnshareLinkOperation;
+ import com.owncloud.android.operations.UnshareOperation;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
import com.owncloud.android.ui.NavigationDrawerItem;
public static final String TAG = FileActivity.class.getSimpleName();
private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
+
private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";
private static final String DIALOG_SHARE_PASSWORD = "DIALOG_SHARE_PASSWORD";
private static final String KEY_TRY_SHARE_AGAIN = "TRY_SHARE_AGAIN";
private static final String KEY_ACTION_BAR_TITLE = "ACTION_BAR_TITLE";
- protected static final long DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS = 200;
+ protected static final long DELAY_TO_REQUEST_OPERATIONS_LATER = 200;
/** OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located.*/
savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)
);
mTryShareAgain = savedInstanceState.getBoolean(KEY_TRY_SHARE_AGAIN);
- getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
+ if (getSupportActionBar() != null) {
+ getSupportActionBar().setTitle(savedInstanceState.getString(KEY_ACTION_BAR_TITLE));
+ }
} else {
account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
// }
// Display username in drawer
- Account account = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
- if (account != null) {
- TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
- int lastAtPos = account.name.lastIndexOf("@");
- username.setText(account.name.substring(0, lastAtPos));
- }
+ setUsernameInDrawer(navigationDrawerLayout, AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()));
// load slide menu items
mDrawerTitles = getResources().getStringArray(R.array.drawer_items);
mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[0], mDrawerContentDescriptions[0],
R.drawable.ic_folder_open));
- // TODO Enable when "On Device" is recovered
// On Device
- //mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
- // mDrawerContentDescriptions[2]));
+ mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1],
+ R.drawable.ic_action_download_grey));
// Settings
- mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[1], mDrawerContentDescriptions[1],
- R.drawable.ic_settings));
+ mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2], mDrawerContentDescriptions[2],
+ R.drawable.ic_action_settings));
// Logs
if (BuildConfig.DEBUG) {
- mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[2],
- mDrawerContentDescriptions[2],R.drawable.ic_log));
+ mDrawerItems.add(new NavigationDrawerItem(mDrawerTitles[3],
+ mDrawerContentDescriptions[3],R.drawable.ic_log));
}
// setting the nav drawer list adapter
}
/**
+ * sets the given account name in the drawer in case the drawer is available. The account name
+ * is shortened beginning from the @-sign in the username.
+ *
+ * @param navigationDrawerLayout the drawer layout to be used
+ * @param account the account to be set in the drawer
+ */
+ protected void setUsernameInDrawer(RelativeLayout navigationDrawerLayout, Account account) {
+ if (navigationDrawerLayout != null && getAccount() != null) {
+ TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
+ int lastAtPos = account.name.lastIndexOf("@");
+ username.setText(account.name.substring(0, lastAtPos));
+ }
+ }
+
+ /**
* Updates title bar and home buttons (state and icon).
*
* Assumes that navigation drawer is NOT visible.
outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification);
outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor());
outState.putBoolean(KEY_TRY_SHARE_AGAIN, mTryShareAgain);
- if(getSupportActionBar().getTitle() != null) {
+ if(getSupportActionBar() != null && getSupportActionBar().getTitle() != null) {
// Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST
// since it doesn't have a title then
outState.putString(KEY_ACTION_BAR_TITLE, getSupportActionBar().getTitle().toString());
mFileOperationsHelper.setOpIdWaitingFor(Long.MAX_VALUE);
+ dismissLoadingDialog();
+
if (!result.isSuccess() && (
result.getCode() == ResultCode.UNAUTHORIZED ||
result.isIdPRedirection() ||
}
mTryShareAgain = false;
- } else if (operation instanceof CreateShareOperation) {
- onCreateShareOperationFinish((CreateShareOperation) operation, result);
+ } else if (operation == null ||
+ operation instanceof CreateShareWithShareeOperation ||
+ operation instanceof UnshareOperation ||
+ operation instanceof SynchronizeFolderOperation
+ ) {
+ if (result.isSuccess()) {
+ updateFileFromDB();
+
+ } else if (result.getCode() != ResultCode.CANCELLED) {
+ Toast t = Toast.makeText(this,
+ ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
+ Toast.LENGTH_LONG);
+ t.show();
+ }
- } else if (operation instanceof UnshareLinkOperation) {
- onUnshareLinkOperationFinish((UnshareLinkOperation)operation, result);
+ } else if (operation instanceof CreateShareViaLinkOperation) {
+ onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result);
- } else if (operation instanceof SynchronizeFolderOperation) {
- onSynchronizeFolderOperationFinish((SynchronizeFolderOperation)operation, result);
+ } else if (operation instanceof SynchronizeFileOperation) {
+ onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result);
- }else if (operation instanceof SynchronizeFileOperation) {
- onSynchronizeFileOperationFinish((SynchronizeFileOperation)operation, result);
+ } else if (operation instanceof GetSharesForFileOperation) {
+ if (result.isSuccess()) {
+ updateFileFromDB();
+ } else if (result.getCode() != ResultCode.SHARE_NOT_FOUND) {
+ Toast t = Toast.makeText(this,
+ ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
+ Toast.LENGTH_LONG);
+ t.show();
+ }
}
}
- private void onCreateShareOperationFinish(CreateShareOperation operation,
- RemoteOperationResult result) {
- dismissLoadingDialog();
+ private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
+ RemoteOperationResult result) {
if (result.isSuccess()) {
mTryShareAgain = false;
updateFileFromDB();
- Intent sendIntent = operation.getSendIntent();
+ Intent sendIntent = operation.getSendIntentWithSubject(this);
startActivity(sendIntent);
} else {
// Detect Failure (403) --> needs Password
}
}
-
- private void onUnshareLinkOperationFinish(UnshareLinkOperation operation,
- RemoteOperationResult result) {
- dismissLoadingDialog();
-
- if (result.isSuccess()){
- updateFileFromDB();
-
- } else {
- Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result,
- operation, getResources()), Toast.LENGTH_LONG);
- t.show();
- }
- }
-
- private void onSynchronizeFolderOperationFinish(
- SynchronizeFolderOperation operation, RemoteOperationResult result
- ) {
- if (!result.isSuccess() && result.getCode() != ResultCode.CANCELLED){
- Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result,
- operation, getResources()), Toast.LENGTH_LONG);
- t.show();
- }
- }
-
private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation,
RemoteOperationResult result) {
- dismissLoadingDialog();
OCFile syncedFile = operation.getLocalFile();
if (!result.isSuccess()) {
if (result.getCode() == ResultCode.SYNC_CONFLICT) {
/**
* Show loading dialog
*/
- public void showLoadingDialog() {
+ public void showLoadingDialog(String message) {
// Construct dialog
- Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
- if (frag == null) {
- Log_OC.d(TAG, "show loading dialog");
- LoadingDialog loading = new LoadingDialog(getResources().getString(R.string.wait_a_moment));
- FragmentManager fm = getSupportFragmentManager();
- FragmentTransaction ft = fm.beginTransaction();
- loading.show(ft, DIALOG_WAIT_TAG);
- fm.executePendingTransactions();
- }
+ LoadingDialog loading = new LoadingDialog(message);
+ FragmentManager fm = getSupportFragmentManager();
+ FragmentTransaction ft = fm.beginTransaction();
+ loading.show(ft, DIALOG_WAIT_TAG);
+
}
public void dismissLoadingDialog() {
Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
if (frag != null) {
+ Log_OC.d(TAG, "dismiss loading dialog");
LoadingDialog loading = (LoadingDialog) frag;
loading.dismiss();
}
startActivity(i);
}
+ public void refresh(){
+ Intent i = new Intent(this, FileDisplayActivity.class);
+ i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(i);
+ }
+
// TODO re-enable when "Accounts" is available in Navigation Drawer
// public void closeDrawer() {
// mDrawerLayout.closeDrawers();
restart();
}
+ public void refreshDirectory(){
+ // overridden by FileDisplayActivity
+ }
+
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// break;
case 0: // All Files
- allFilesOption();
+ MainApp.showOnlyFilesOnDevice(false);
+ refreshDirectory();
mDrawerLayout.closeDrawers();
break;
- // TODO Enable when "On Device" is recovered ?
-// case 2:
-// MainApp.showOnlyFilesOnDevice(true);
-// mDrawerLayout.closeDrawers();
-// break;
+ case 1: // On Device
+ MainApp.showOnlyFilesOnDevice(true);
+ refreshDirectory();
+ mDrawerLayout.closeDrawers();
+ break;
- case 1: // Settings
+ case 2: // Settings
Intent settingsIntent = new Intent(getApplicationContext(),
Preferences.class);
startActivity(settingsIntent);
mDrawerLayout.closeDrawers();
break;
- case 2: // Logs
+ case 3: // Logs
Intent loggerIntent = new Intent(getApplicationContext(),
LogHistoryActivity.class);
startActivity(loggerIntent);
import android.accounts.AccountManager;
import android.accounts.AuthenticatorException;
import android.annotation.TargetApi;
+import android.os.Parcelable;
import android.support.v7.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.CopyFileOperation;
import com.owncloud.android.operations.CreateFolderOperation;
- import com.owncloud.android.operations.CreateShareOperation;
+ import com.owncloud.android.operations.CreateShareViaLinkOperation;
+ import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.MoveFileOperation;
import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
- import com.owncloud.android.operations.UnshareLinkOperation;
+ import com.owncloud.android.operations.UnshareOperation;
import com.owncloud.android.services.observer.FileObserverService;
import com.owncloud.android.syncadapter.FileSyncAdapter;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
import com.owncloud.android.utils.UriUtils;
import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
/**
* Displays, what files the user has available in his ownCloud.
implements FileFragment.ContainerActivity,
OnSslUntrustedCertListener, OnEnforceableRefreshListener {
-
-
private SyncBroadcastReceiver mSyncBroadcastReceiver;
private UploadFinishReceiver mUploadFinishReceiver;
private DownloadFinishReceiver mDownloadFinishReceiver;
private boolean mSyncInProgress = false;
private static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT";
- private static String DIALOG_CREATE_FOLDER = "DIALOG_CREATE_FOLDER";
+ public static String DIALOG_CREATE_FOLDER = "DIALOG_CREATE_FOLDER";
private static String DIALOG_UPLOAD_SOURCE = "DIALOG_UPLOAD_SOURCE";
private static String DIALOG_CERT_NOT_SAVED = "DIALOG_CERT_NOT_SAVED";
private OCFile mWaitingToSend;
+ private Menu mOptionsMenu;
+
-
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.v(TAG, "onCreate() start");
}
@Override
+ protected void onStop() {
+ Log_OC.v(TAG, "onStop() start");
+ super.onStop();
+ Log_OC.v(TAG, "onStop() end");
+ }
+
+ @Override
protected void onDestroy() {
Log_OC.v(TAG, "onDestroy() start");
super.onDestroy();
setFile(file);
if (mAccountWasSet) {
- RelativeLayout navigationDrawerLayout = (RelativeLayout) findViewById(R.id.left_drawer);
- if (navigationDrawerLayout != null && getAccount() != null) {
- TextView username = (TextView) navigationDrawerLayout.findViewById(R.id.drawer_username);
- int lastAtPos = getAccount().name.lastIndexOf("@");
- username.setText(getAccount().name.substring(0, lastAtPos));
- }
+ setUsernameInDrawer((RelativeLayout) findViewById(R.id.left_drawer), getAccount());
}
if (!stateWasRecovered) {
/// First fragment
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) {
- listOfFiles.listDirectory(getCurrentDir());
- // TODO Enable when "On Device" is recovered
- // listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
-
+ listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
} else {
Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
}
startTextPreview(file);
}
+ if (DisplayUtils.isGridView(getFile(), getStorageManager())){
+ switchToGridView();
+ } else {
+ switchToListView();
+ }
+
} else {
Log_OC.wtf(TAG, "initFragments() called with invalid NULLs!");
if (getAccount() == null) {
protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
- fileListFragment.listDirectory();
- // TODO Enable when "On Device" is recovered ?
- // fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
+ fileListFragment.listDirectory(MainApp.getOnlyOnDevice());
}
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
boolean drawerOpen = mDrawerLayout.isDrawerOpen(GravityCompat.START);
- menu.findItem(R.id.action_upload).setVisible(!drawerOpen);
- menu.findItem(R.id.action_create_dir).setVisible(!drawerOpen);
menu.findItem(R.id.action_sort).setVisible(!drawerOpen);
menu.findItem(R.id.action_sync_account).setVisible(!drawerOpen);
+ menu.findItem(R.id.action_switch_view).setVisible(!drawerOpen);
return super.onPrepareOptionsMenu(menu);
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
+ menu.findItem(R.id.action_create_dir).setVisible(false);
+ mOptionsMenu = menu;
+
+ MenuItem menuItem = mOptionsMenu.findItem(R.id.action_switch_view);
+
+ changeGridIcon();
+
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
boolean retval = true;
switch (item.getItemId()) {
- case R.id.action_create_dir: {
- CreateFolderDialogFragment dialog =
- CreateFolderDialogFragment.newInstance(getCurrentDir());
- dialog.show(getSupportFragmentManager(), DIALOG_CREATE_FOLDER);
- break;
- }
-
case R.id.action_sync_account: {
startSynchronization();
break;
}
- case R.id.action_upload: {
- UploadSourceDialogFragment dialog =
- UploadSourceDialogFragment.newInstance(getAccount());
- dialog.show(getSupportFragmentManager(), DIALOG_UPLOAD_SOURCE);
- break;
- }
case android.R.id.home: {
FileFragment second = getSecondFragment();
OCFile currentDir = getCurrentDir();
builder.create().show();
break;
}
+ case R.id.action_switch_view:{
+ if (isGridView()){
+ item.setTitle(getApplicationContext().getString(R.string.action_switch_grid_view));
+ item.setIcon(ContextCompat.getDrawable(getApplicationContext(),
+ R.drawable.ic_view_module));
+ DisplayUtils.setViewMode(getFile(), false);
+ switchToListView();
+ } else {
+ item.setTitle(getApplicationContext().getString(R.string.action_switch_list_view));
+ item.setIcon(ContextCompat.getDrawable(getApplicationContext(),
+ R.drawable.ic_view_list));
+ DisplayUtils.setViewMode(getFile(), true);
+ switchToGridView();
+ }
+
+ return true;
+ }
default:
retval = super.onOptionsItemSelected(item);
}
return retval;
}
+ public void createFolder() {
+ CreateFolderDialogFragment dialog =
+ CreateFolderDialogFragment.newInstance(getCurrentDir());
+ dialog.show(getSupportFragmentManager(), DIALOG_CREATE_FOLDER);
+ }
+
+ public void uploadLocalFilesSelected() {
+ Intent action = new Intent(this, UploadFilesActivity.class);
+ action.putExtra(
+ UploadFilesActivity.EXTRA_ACCOUNT,
+ getAccount()
+ );
+ startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
+ }
+
+ public void uploadFromOtherAppsSelected() {
+ Intent action = new Intent(Intent.ACTION_GET_CONTENT);
+ action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
+ //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+ }
+ startActivityForResult(
+ Intent.createChooser(action, getString(R.string.upload_chooser_title)),
+ ACTION_SELECT_CONTENT_FROM_APPS
+ );
+ }
+
private void startSynchronization() {
Log_OC.d(TAG, "Got to start sync");
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
requestMoveOperation(fData, fResultCode);
}
},
- DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS
+ DELAY_TO_REQUEST_OPERATIONS_LATER
);
} else if (requestCode == ACTION_COPY_FILES && resultCode == RESULT_OK) {
requestCopyOperation(fData, fResultCode);
}
},
- DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS
+ DELAY_TO_REQUEST_OPERATIONS_LATER
);
} else {
*/
private void requestMoveOperation(Intent data, int resultCode) {
OCFile folderToMoveAt = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
- OCFile targetFile = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);
- getFileOperationsHelper().moveFile(folderToMoveAt, targetFile);
+
+ ArrayList<OCFile> files = data.getParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES);
+
+ for (Parcelable file : files) {
+ getFileOperationsHelper().moveFile(folderToMoveAt, (OCFile) file);
+ }
}
/**
*/
private void requestCopyOperation(Intent data, int resultCode) {
OCFile folderToMoveAt = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
- OCFile targetFile = data.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);
- getFileOperationsHelper().copyFile(folderToMoveAt, targetFile);
+
+ ArrayList<OCFile> files = data.getParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES);
+
+ for (Parcelable file : files) {
+ getFileOperationsHelper().copyFile(folderToMoveAt, (OCFile) file);
+ }
}
@Override
public void onBackPressed() {
- if (!isDrawerOpen()){
+ boolean isFabOpen = isFabOpen();
+ boolean isDrawerOpen = isDrawerOpen();
+
+ /*
+ * BackPressed priority/hierarchy:
+ * 1. close drawer if opened
+ * 2. close FAB if open (only if drawer isn't open)
+ * 3. navigate up (only if drawer and FAB aren't open)
+ */
+ if(isDrawerOpen && isFabOpen) {
+ // close drawer first
+ super.onBackPressed();
+ } else if(isDrawerOpen && !isFabOpen) {
+ // close drawer
+ super.onBackPressed();
+ } else if (!isDrawerOpen && isFabOpen) {
+ // close fab
+ getListOfFilesFragment().getFabMain().collapse();
+ } else {
+ // all closed
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (mDualPane || getSecondFragment() == null) {
OCFile currentDir = getCurrentDir();
setFile(listOfFiles.getCurrentFile());
}
cleanSecondFragment();
+ changeGridIcon();
+ }
+ }
+
+ private void changeGridIcon(){
+ MenuItem menuItem = mOptionsMenu.findItem(R.id.action_switch_view);
+ if (DisplayUtils.isGridView(getFile(), getStorageManager())){
+ menuItem.setTitle(getApplicationContext().getString(R.string.action_switch_list_view));
+ menuItem.setIcon(ContextCompat.getDrawable(getApplicationContext(),
+ R.drawable.ic_view_list));
} else {
- super.onBackPressed();
+ menuItem.setTitle(getApplicationContext().getString(R.string.action_switch_grid_view));
+ menuItem.setIcon(ContextCompat.getDrawable(getApplicationContext(),
+ R.drawable.ic_view_module));
}
}
Log_OC.v(TAG, "onPause() end");
}
+ public boolean isFabOpen() {
+ if(getListOfFilesFragment() != null && getListOfFilesFragment().getFabMain() != null && getListOfFilesFragment().getFabMain().isExpanded()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
private class SyncBroadcastReceiver extends BroadcastReceiver {
currentDir.getRemotePath().equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
- fileListFragment.listDirectory();
- // TODO Enable when "On Device" is recovered ?
- // fileListFragment.listDirectory(currentDir,
- // MainApp.getOnlyOnDevice());
+ fileListFragment.listDirectory(currentDir,
+ MainApp.getOnlyOnDevice());
}
}
setFile(currentFile);
}
}
+
}
removeStickyBroadcast(intent);
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { // should never be null, indeed
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
- listOfFiles.listDirectory(root);
- // TODO Enable when "On Device" is recovered ?
- // listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
+ listOfFiles.listDirectory(root, MainApp.getOnlyOnDevice());
setFile(listOfFiles.getCurrentFile());
startSyncFolderOperation(root, false);
}
cleanSecondFragment();
// Sync Folder
startSyncFolderOperation(directory, false);
+
+ MenuItem menuItem = mOptionsMenu.findItem(R.id.action_switch_view);
+
+ changeGridIcon();
+ if (DisplayUtils.isGridView(directory, getStorageManager())){
+ switchToGridView();
+ } else {
+ switchToListView();
+ }
}
/**
// getFileDownloadBinder() - THIS IS A MESS
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) {
- listOfFiles.listDirectory();
- // TODO Enable when "On Device" is recovered ?
- // listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
+ listOfFiles.listDirectory(MainApp.getOnlyOnDevice());
}
FileFragment secondFragment = getSecondFragment();
if (secondFragment != null && secondFragment instanceof FileDetailFragment) {
} else if (operation instanceof CreateFolderOperation) {
onCreateFolderOperationFinish((CreateFolderOperation) operation, result);
- } else if (operation instanceof CreateShareOperation) {
- onCreateShareOperationFinish((CreateShareOperation) operation, result);
+ } else if (operation instanceof CreateShareViaLinkOperation ||
+ operation instanceof CreateShareWithShareeOperation ) {
- } else if (operation instanceof UnshareLinkOperation) {
- onUnshareLinkOperationFinish((UnshareLinkOperation) operation, result);
+ refreshShowDetails();
+ refreshListOfFilesFragment();
+
+ } else if (operation instanceof UnshareOperation) {
+ onUnshareLinkOperationFinish((UnshareOperation) operation, result);
} else if (operation instanceof MoveFileOperation) {
onMoveFileOperationFinish((MoveFileOperation) operation, result);
}
}
- private void onCreateShareOperationFinish(CreateShareOperation operation,
- RemoteOperationResult result) {
- if (result.isSuccess()) {
- refreshShowDetails();
- refreshListOfFilesFragment();
- }
- }
- private void onUnshareLinkOperationFinish(UnshareLinkOperation operation,
+ private void onUnshareLinkOperationFinish(UnshareOperation operation,
RemoteOperationResult result) {
if (result.isSuccess()) {
refreshShowDetails();
*/
private void onRemoveFileOperationFinish(RemoveFileOperation operation,
RemoteOperationResult result) {
- dismissLoadingDialog();
-
Toast msg = Toast.makeText(this,
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
Toast.LENGTH_LONG);
private void onMoveFileOperationFinish(MoveFileOperation operation,
RemoteOperationResult result) {
if (result.isSuccess()) {
- dismissLoadingDialog();
refreshListOfFilesFragment();
} else {
- dismissLoadingDialog();
try {
Toast msg = Toast.makeText(FileDisplayActivity.this,
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
*/
private void onCopyFileOperationFinish(CopyFileOperation operation, RemoteOperationResult result) {
if (result.isSuccess()) {
- dismissLoadingDialog();
refreshListOfFilesFragment();
} else {
- dismissLoadingDialog();
try {
Toast msg = Toast.makeText(FileDisplayActivity.this,
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
*/
private void onRenameFileOperationFinish(RenameFileOperation operation,
RemoteOperationResult result) {
- dismissLoadingDialog();
OCFile renamedFile = operation.getFile();
if (result.isSuccess()) {
FileFragment details = getSecondFragment();
private void onCreateFolderOperationFinish(CreateFolderOperation operation,
RemoteOperationResult result) {
if (result.isSuccess()) {
- dismissLoadingDialog();
refreshListOfFilesFragment();
} else {
- dismissLoadingDialog();
try {
Toast msg = Toast.makeText(FileDisplayActivity.this,
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
return null;
}
- public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
- long currentSyncTime = System.currentTimeMillis();
-
- mSyncInProgress = true;
-
- // perform folder synchronization
- RemoteOperation synchFolderOp = new RefreshFolderOperation( folder,
- currentSyncTime,
- false,
- getFileOperationsHelper().isSharedSupported(),
- ignoreETag,
- getStorageManager(),
- getAccount(),
- getApplicationContext()
+ /**
+ * Starts an operation to refresh the requested folder.
+ *
+ * The operation is run in a new background thread created on the fly.
+ *
+ * The refresh updates is a "light sync": properties of regular files in folder are updated (including
+ * associated shares), but not their contents. Only the contents of files marked to be kept-in-sync are
+ * synchronized too.
+ *
+ * @param folder Folder to refresh.
+ * @param ignoreETag If 'true', the data from the server will be fetched and sync'ed even if the eTag
+ * didn't change.
+ */
+ public void startSyncFolderOperation(final OCFile folder, final boolean ignoreETag) {
+
+ // the execution is slightly delayed to allow the activity get the window focus if it's being started
+ // or if the method is called from a dialog that is being dismissed
+ getHandler().postDelayed(
+ new Runnable() {
+ @Override
+ public void run() {
+ if (hasWindowFocus()) {
+ long currentSyncTime = System.currentTimeMillis();
+ mSyncInProgress = true;
+
+ // perform folder synchronization
+ RemoteOperation synchFolderOp = new RefreshFolderOperation(folder,
+ currentSyncTime,
+ false,
+ getFileOperationsHelper().isSharedSupported(),
+ ignoreETag,
+ getStorageManager(),
+ getAccount(),
+ getApplicationContext()
+ );
+ synchFolderOp.execute(
+ getAccount(),
+ MainApp.getAppContext(),
+ FileDisplayActivity.this,
+ null,
+ null
+ );
+
+ mProgressBar.setIndeterminate(true);
+
+ setBackgroundText();
+
+ } // else: NOTHING ; lets' not refresh when the user rotates the device but there is
+ // another window floating over
+ }
+ },
+ DELAY_TO_REQUEST_OPERATIONS_LATER
);
- synchFolderOp.execute(getAccount(), MainApp.getAppContext(), this, null, null);
-
- mProgressBar.setIndeterminate(true);
- setBackgroundText();
}
/**
private void sortByName(boolean ascending) {
getListOfFilesFragment().sortByName(ascending);
}
+ private boolean isGridView(){ return getListOfFilesFragment().isGridView(); }
+ private void switchToGridView() {
+ getListOfFilesFragment().switchToGridView();
+ }
+ private void switchToListView() {
+ getListOfFilesFragment().switchToListView();
+ }
public void allFilesOption() {
browseToRoot();
}
+
+ public void refreshDirectory(){
+ getListOfFilesFragment().refreshDirectory();
+ }
}
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
- import android.view.Window;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.utils.ErrorMessageAdapter;
+import java.util.ArrayList;
+
public class FolderPickerActivity extends FileActivity implements FileFragment.ContainerActivity,
OnClickListener, OnEnforceableRefreshListener {
+ ".EXTRA_FOLDER";
public static final String EXTRA_FILE = UploadFilesActivity.class.getCanonicalName()
+ ".EXTRA_FILE";
+ public static final String EXTRA_FILES = UploadFilesActivity.class.getCanonicalName()
+ + ".EXTRA_FILES";
//TODO: Think something better
private SyncBroadcastReceiver mSyncBroadcastReceiver;
if (!stateWasRecovered) {
OCFileListFragment listOfFolders = getListOfFilesFragment();
- listOfFolders.listDirectory(folder/*, false*/);
+ listOfFolders.listDirectory(folder, false);
startSyncFolderOperation(folder, false);
}
Bundle args = new Bundle();
args.putBoolean(OCFileListFragment.ARG_JUST_FOLDERS, true);
args.putBoolean(OCFileListFragment.ARG_ALLOW_CONTEXTUAL_ACTIONS, false);
+ args.putBoolean(OCFileListFragment.ARG_HIDE_FAB, true);
listOfFiles.setArguments(args);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.fragment_container, listOfFiles, TAG_LIST_OF_FOLDERS);
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
- menu.findItem(R.id.action_upload).setVisible(false);
menu.findItem(R.id.action_sort).setVisible(false);
return true;
}
protected void refreshListOfFilesFragment() {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
- fileListFragment.listDirectory();
- // TODO Enable when "On Device" is recovered ?
- // fileListFragment.listDirectory(false);
+ fileListFragment.listDirectory(false);
}
}
OCFileListFragment listOfFiles = getListOfFilesFragment();
if (listOfFiles != null) { // should never be null, indeed
OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
- listOfFiles.listDirectory(root);
- // TODO Enable when "On Device" is recovered ?
- // listOfFiles.listDirectory(root, false);
+ listOfFiles.listDirectory(root, false);
setFile(listOfFiles.getCurrentFile());
updateNavigationElementsInActionBar();
startSyncFolderOperation(root, false);
actionBar.setDisplayHomeAsUpEnabled(!atRoot);
actionBar.setHomeButtonEnabled(!atRoot);
actionBar.setTitle(
- atRoot
- ? getString(R.string.default_display_name_for_root_folder)
- : currentDir.getFileName()
+ atRoot
+ ? getString(R.string.default_display_name_for_root_folder)
+ : currentDir.getFileName()
);
}
} else if (v == mChooseBtn) {
Intent i = getIntent();
Parcelable targetFile = i.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);
+ ArrayList<Parcelable> targetFiles = i.getParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES);
Intent data = new Intent();
data.putExtra(EXTRA_FOLDER, getCurrentFolder());
if (targetFile != null) {
data.putExtra(EXTRA_FILE, targetFile);
}
+ if (targetFiles != null){
+ data.putParcelableArrayListExtra(EXTRA_FILES, targetFiles);
+ }
setResult(RESULT_OK, data);
finish();
}
super.onRemoteOperationFinish(operation, result);
if (operation instanceof CreateFolderOperation) {
- onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+ onCreateFolderOperationFinish((CreateFolderOperation) operation, result);
}
}
) {
if (result.isSuccess()) {
- dismissLoadingDialog();
refreshListOfFilesFragment();
} else {
- dismissLoadingDialog();
try {
Toast msg = Toast.makeText(FolderPickerActivity.this,
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
equals(synchFolderRemotePath)) {
OCFileListFragment fileListFragment = getListOfFilesFragment();
if (fileListFragment != null) {
- fileListFragment.listDirectory(currentDir);
- // TODO Enable when "On Device" is recovered ?
- // fileListFragment.listDirectory(currentDir, false);
+ fileListFragment.listDirectory(currentDir, false);
}
}
setFile(currentFile);
/**
- * Shows the information of the {@link OCFile} received as a
+ * Shows the information of the {@link OCFile} received as a
* parameter in the second fragment.
- *
+ *
* @param file {@link OCFile} whose details will be shown
*/
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// click on folder in the list
Log_OC.d(TAG, "on item click");
- // TODO Enable when "On Device" is recovered ?
- Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile /*, false*/);
+ Vector<OCFile> tmpfiles = getStorageManager().getFolderContent(mFile, false);
if (tmpfiles.size() <= 0) return;
// filter on dirtype
Vector<OCFile> files = new Vector<OCFile>();
mFile = getStorageManager().getFileByPath(full_path);
if (mFile != null) {
- // TODO Enable when "On Device" is recovered ?
- Vector<OCFile> files = getStorageManager().getFolderContent(mFile/*, false*/);
+ Vector<OCFile> files = getStorageManager().getFolderContent(mFile, false);
List<HashMap<String, Object>> data = new LinkedList<HashMap<String,Object>>();
for (OCFile f : files) {
HashMap<String, Object> h = new HashMap<String, Object>();
private void onCreateFolderOperationFinish(CreateFolderOperation operation,
RemoteOperationResult result) {
if (result.isSuccess()) {
- dismissLoadingDialog();
populateDirectoryList();
} else {
- dismissLoadingDialog();
try {
Toast msg = Toast.makeText(this,
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
- menu.findItem(R.id.action_upload).setVisible(false);
menu.findItem(R.id.action_sort).setVisible(false);
menu.findItem(R.id.action_sync_account).setVisible(false);
return true;
\r
\r
import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
import java.util.Vector;\r
\r
import android.accounts.Account;\r
import android.content.Context;\r
import android.content.SharedPreferences;\r
import android.graphics.Bitmap;\r
+import android.graphics.Color;\r
+import android.graphics.BitmapFactory;\r
+import android.graphics.Canvas;\r
+import android.graphics.Paint;\r
import android.os.Build;\r
import android.preference.PreferenceManager;\r
import android.text.format.DateUtils;\r
* instance.\r
*/\r
public class FileListListAdapter extends BaseAdapter implements ListAdapter {\r
- private final static String PERMISSION_SHARED_WITH_ME = "S";\r
\r
private Context mContext;\r
private OCFile mFile = null;\r
private enum ViewType {LIST_ITEM, GRID_IMAGE, GRID_ITEM };\r
\r
private SharedPreferences mAppPreferences;\r
+\r
+ private HashMap<Integer, Boolean> mSelection = new HashMap<Integer, Boolean>();\r
\r
public FileListListAdapter(\r
boolean justFolders, \r
ViewType viewType;\r
if (!mGridMode){\r
viewType = ViewType.LIST_ITEM;\r
- } else if (file.isImage()){\r
+ } else if (file.isImage() || file.isVideo()){\r
viewType = ViewType.GRID_IMAGE;\r
} else {\r
viewType = ViewType.GRID_ITEM;\r
switch (viewType){\r
case LIST_ITEM:\r
TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);\r
+ TextView fileSizeSeparatorV = (TextView) view.findViewById(R.id.file_separator);\r
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);\r
- ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
+\r
\r
lastModV.setVisibility(View.VISIBLE);\r
lastModV.setText(showRelativeTimestamp(file));\r
\r
- checkBoxV.setVisibility(View.GONE);\r
\r
+ fileSizeSeparatorV.setVisibility(View.VISIBLE);\r
fileSizeV.setVisibility(View.VISIBLE);\r
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));\r
\r
- if (!file.isFolder()) {\r
- AbsListView parentList = (AbsListView)parent;\r
- if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {\r
- if (parentList.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {\r
- checkBoxV.setVisibility(View.GONE);\r
- } else {\r
- if (parentList.isItemChecked(position)) {\r
- checkBoxV.setImageResource(\r
- android.R.drawable.checkbox_on_background);\r
- } else {\r
- checkBoxV.setImageResource(\r
- android.R.drawable.checkbox_off_background);\r
- }\r
- checkBoxV.setVisibility(View.VISIBLE);\r
- }\r
- }\r
-\r
- } else { //Folder\r
- fileSizeV.setVisibility(View.INVISIBLE);\r
+// if (!file.isFolder()) {\r
+// AbsListView parentList = (AbsListView)parent;\r
+// if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {\r
+// if (parentList.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {\r
+// checkBoxV.setVisibility(View.GONE);\r
+// } else {\r
+// if (parentList.isItemChecked(position)) {\r
+// checkBoxV.setImageResource(\r
+// R.drawable.ic_checkbox_marked);\r
+// } else {\r
+// checkBoxV.setImageResource(\r
+// R.drawable.ic_checkbox_blank_outline);\r
+// }\r
+// checkBoxV.setVisibility(View.VISIBLE);\r
+// }\r
+// }\r
+\r
+ if (file.isFolder()) {\r
+ fileSizeSeparatorV.setVisibility(View.GONE);\r
+ fileSizeV.setVisibility(View.GONE);\r
}\r
\r
case GRID_ITEM:\r
case GRID_IMAGE:\r
// sharedIcon\r
ImageView sharedIconV = (ImageView) view.findViewById(R.id.sharedIcon);\r
- if (file.isShareByLink()) {\r
+ if (file.isSharedViaLink()) {\r
+ sharedIconV.setImageResource(R.drawable.shared_via_link);\r
+ sharedIconV.setVisibility(View.VISIBLE);\r
+ sharedIconV.bringToFront();\r
+ } else if (file.isSharedWithSharee() || file.isSharedWithMe() ) {\r
+ sharedIconV.setImageResource(R.drawable.shared_via_users);\r
sharedIconV.setVisibility(View.VISIBLE);\r
sharedIconV.bringToFront();\r
} else {\r
sharedIconV.setVisibility(View.GONE);\r
}\r
\r
+ /*ImageView sharedWithMeIcon = (ImageView) view.findViewById(R.id.sharedWithMeIcon);\r
+ sharedWithMeIcon.bringToFront();*/\r
+ \r
// local state\r
ImageView localStateView = (ImageView) view.findViewById(R.id.localFileIndicator);\r
localStateView.bringToFront();\r
localStateView.setVisibility(View.VISIBLE);\r
}\r
\r
- // share with me icon\r
- ImageView sharedWithMeIconV = (ImageView)\r
- view.findViewById(R.id.sharedWithMeIcon);\r
- sharedWithMeIconV.bringToFront();\r
- if (checkIfFileIsSharedWithMe(file) &&\r
- (!file.isFolder() || !mGridMode)) {\r
- sharedWithMeIconV.setVisibility(View.VISIBLE);\r
- } else {\r
- sharedWithMeIconV.setVisibility(View.GONE);\r
- }\r
- \r
break;\r
}\r
+\r
+ ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
+ checkBoxV.setVisibility(View.GONE);\r
+\r
+ AbsListView parentList = (AbsListView)parent;\r
+ if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {\r
+ if (parentList.getChoiceMode() == AbsListView.CHOICE_MODE_NONE) {\r
+ checkBoxV.setVisibility(View.GONE);\r
+ } else if (parentList.getCheckedItemCount() > 0){\r
+ if (parentList.isItemChecked(position)) {\r
+ checkBoxV.setImageResource(\r
+ android.R.drawable.checkbox_on_background);\r
+ } else {\r
+ checkBoxV.setImageResource(\r
+ android.R.drawable.checkbox_off_background);\r
+ }\r
+ checkBoxV.setVisibility(View.VISIBLE);\r
+ }\r
+ }\r
\r
// For all Views\r
\r
\r
// No Folder\r
if (!file.isFolder()) {\r
- if (file.isImage() && file.getRemoteId() != null){\r
+ if ((file.isImage() || file.isVideo()) && file.getRemoteId() != null){\r
// Thumbnail in Cache?\r
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(\r
"t" + String.valueOf(file.getRemoteId()));\r
if (thumbnail != null && !file.needsUpdateThumbnail()){\r
- fileIcon.setImageBitmap(thumbnail);\r
+\r
+ if (file.isVideo()) {\r
+ Bitmap withOverlay = ThumbnailsCacheManager.addVideoOverlay(thumbnail);\r
+ fileIcon.setImageBitmap(withOverlay);\r
+ } else {\r
+ fileIcon.setImageBitmap(thumbnail);\r
+ }\r
} else {\r
// generate new Thumbnail\r
if (ThumbnailsCacheManager.cancelPotentialWork(file, fileIcon)) {\r
// Folder\r
fileIcon.setImageResource(\r
MimetypeIconUtil.getFolderTypeIconId(\r
- checkIfFileIsSharedWithMe(file), file.isShareByLink()));\r
+ file.isSharedWithMe() || file.isSharedWithSharee(),\r
+ file.isSharedViaLink()\r
+ )\r
+ );\r
}\r
}\r
\r
+ if (mSelection.get(position) != null) {\r
+ view.setBackgroundColor(Color.rgb(248, 248, 248));\r
+ } else {\r
+ view.setBackgroundColor(Color.WHITE);\r
+ }\r
+\r
return view;\r
}\r
\r
* mStorageManager if is different (and not NULL)\r
*/\r
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager\r
- /*, boolean onlyOnDevice*/) {\r
+ , boolean onlyOnDevice) {\r
mFile = directory;\r
if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {\r
mStorageManager = updatedStorageManager;\r
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
}\r
if (mStorageManager != null) {\r
- // TODO Enable when "On Device" is recovered ?\r
- mFiles = mStorageManager.getFolderContent(mFile/*, onlyOnDevice*/);\r
+ mFiles = mStorageManager.getFolderContent(mFile, onlyOnDevice);\r
mFilesOrig.clear();\r
mFilesOrig.addAll(mFiles);\r
\r
mFiles = null;\r
}\r
\r
- mFiles = FileStorageUtils.sortFolder(mFiles);\r
+ mFiles = FileStorageUtils.sortOcFolder(mFiles);\r
notifyDataSetChanged();\r
}\r
\r
}\r
\r
\r
- /**\r
- * Check if parent folder does not include 'S' permission and if file/folder\r
- * is shared with me\r
- * \r
- * @param file: OCFile\r
- * @return boolean: True if it is shared with me and false if it is not\r
- */\r
- private boolean checkIfFileIsSharedWithMe(OCFile file) {\r
- return (mFile.getPermissions() != null \r
- && !mFile.getPermissions().contains(PERMISSION_SHARED_WITH_ME)\r
- && file.getPermissions() != null \r
- && file.getPermissions().contains(PERMISSION_SHARED_WITH_ME));\r
- }\r
- \r
public void setSortOrder(Integer order, boolean ascending) {\r
SharedPreferences.Editor editor = mAppPreferences.edit();\r
editor.putInt("sortOrder", order);\r
FileStorageUtils.mSortAscending = ascending;\r
\r
\r
- mFiles = FileStorageUtils.sortFolder(mFiles);\r
+ mFiles = FileStorageUtils.sortOcFolder(mFiles);\r
notifyDataSetChanged();\r
\r
}\r
public void setGridMode(boolean gridMode) {\r
mGridMode = gridMode;\r
}\r
+\r
+ public boolean isGridMode() {\r
+ return mGridMode;\r
+ }\r
+\r
+ public void setNewSelection(int position, boolean checked) {\r
+ mSelection.put(position, checked);\r
+ notifyDataSetChanged();\r
+ }\r
+\r
+ public void removeSelection(int position) {\r
+ mSelection.remove(position);\r
+ notifyDataSetChanged();\r
+ }\r
+\r
+ public void removeSelection(){\r
+ mSelection.clear();\r
+ notifyDataSetChanged();\r
+ }\r
+\r
+ public ArrayList<Integer> getCheckedItemPositions() {\r
+ ArrayList<Integer> ids = new ArrayList<Integer>();\r
+\r
+ for (Map.Entry<Integer, Boolean> entry : mSelection.entrySet()){\r
+ if (entry.getValue()){\r
+ ids.add(entry.getKey());\r
+ }\r
+ }\r
+ return ids;\r
+ }\r
+\r
+ public ArrayList<OCFile> getCheckedItems() {\r
+ ArrayList<OCFile> files = new ArrayList<OCFile>();\r
+\r
+ for (Map.Entry<Integer, Boolean> entry : mSelection.entrySet()){\r
+ if (entry.getValue()){\r
+ files.add((OCFile) getItem(entry.getKey()));\r
+ }\r
+ }\r
+ return files;\r
+ }\r
}\r
import java.util.Comparator;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
+import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.owncloud.android.utils.BitmapUtils;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimetypeIconUtil;
+import com.owncloud.android.utils.FileStorageUtils;
/**
* This Adapter populates a ListView with all files and directories contained
private Context mContext;
private File mDirectory;
private File[] mFiles = null;
+ private SharedPreferences mAppPreferences;
public LocalFileListAdapter(File directory, Context context) {
mContext = context;
+
+ mAppPreferences = PreferenceManager
+ .getDefaultSharedPreferences(mContext);
+
+ // Read sorting order, default to sort by name ascending
+ FileStorageUtils.mSortOrder = mAppPreferences.getInt("sortOrder", 0);
+ FileStorageUtils.mSortAscending = mAppPreferences.getBoolean("sortAscending", true);
+
swapDirectory(directory);
}
fileIcon.setTag(file.hashCode());
TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
+ TextView fileSizeSeparatorV = (TextView) view.findViewById(R.id.file_separator);
TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
if (!file.isDirectory()) {
+ fileSizeSeparatorV.setVisibility(View.VISIBLE);
fileSizeV.setVisibility(View.VISIBLE);
fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.length()));
checkBoxV.setVisibility(View.GONE);
} else {
if (parentList.isItemChecked(position)) {
- checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
+ checkBoxV.setImageResource(R.drawable.ic_checkbox_marked);
} else {
- checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
+ checkBoxV.setImageResource(R.drawable.ic_checkbox_blank_outline);
}
checkBoxV.setVisibility(View.VISIBLE);
}
}
} else {
+ fileSizeSeparatorV.setVisibility(View.GONE);
fileSizeV.setVisibility(View.GONE);
lastModV.setVisibility(View.GONE);
checkBoxV.setVisibility(View.GONE);
view.findViewById(R.id.favoriteIcon).setVisibility(View.GONE);
view.findViewById(R.id.sharedIcon).setVisibility(View.GONE);
- view.findViewById(R.id.sharedWithMeIcon).setVisibility(View.GONE);
}
return view;
}
});
+
+ mFiles = FileStorageUtils.sortLocalFolder(mFiles);
}
notifyDataSetChanged();
}
+
+ public void setSortOrder(Integer order, boolean ascending) {
+ SharedPreferences.Editor editor = mAppPreferences.edit();
+ editor.putInt("sortOrder", order);
+ editor.putBoolean("sortAscending", ascending);
+ editor.commit();
+
+ FileStorageUtils.mSortOrder = order;
+ FileStorageUtils.mSortAscending = ascending;
+
+ mFiles = FileStorageUtils.sortLocalFolder(mFiles);
+ notifyDataSetChanged();
+
+ }
}
*/
package com.owncloud.android.ui.fragment;
+import android.accounts.Account;
import android.app.Activity;
+import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Build;
+import android.net.Uri;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.support.v4.widget.SwipeRefreshLayout;
+import android.view.ActionMode;
+import android.support.v7.app.AlertDialog;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.PopupMenu;
+import android.widget.TextView;
+import android.widget.Toast;
+import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
+import com.owncloud.android.media.MediaService;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.FolderPickerActivity;
import com.owncloud.android.ui.activity.OnEnforceableRefreshListener;
+import com.owncloud.android.ui.activity.UploadFilesActivity;
import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
+import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.FileActionsDialogFragment;
import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
+import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
+import com.owncloud.android.ui.dialog.UploadSourceDialogFragment;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
+import com.owncloud.android.utils.DisplayUtils;
+import com.owncloud.android.utils.ExceptionHandler;
+import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.ui.preview.PreviewTextFragment;
import com.owncloud.android.utils.FileStorageUtils;
import java.io.File;
+import java.util.ArrayList;
/**
* A Fragment that lists all files and folders in a given path.
*
* TODO refactor to get rid of direct dependency on FileDisplayActivity
*/
-public class OCFileListFragment extends ExtendedListFragment
- implements FileActionsDialogFragment.FileActionsDialogFragmentListener {
+public class OCFileListFragment extends ExtendedListFragment {
private static final String TAG = OCFileListFragment.class.getSimpleName();
public final static String ARG_JUST_FOLDERS = MY_PACKAGE + ".JUST_FOLDERS";
public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS = MY_PACKAGE + ".ALLOW_CONTEXTUAL";
+ public final static String ARG_HIDE_FAB = MY_PACKAGE + ".HIDE_FAB";
private static final String KEY_FILE = MY_PACKAGE + ".extra.FILE";
+ private static final String KEY_FAB_EVER_CLICKED = "FAB_EVER_CLICKED";
+
+ private static String DIALOG_CREATE_FOLDER = "DIALOG_CREATE_FOLDER";
private FileFragment.ContainerActivity mContainerActivity;
private boolean mJustFolders;
private OCFile mTargetFile;
-
-
+
+ private boolean miniFabClicked = false;
/**
* {@inheritDoc}
setListAdapter(mAdapter);
registerLongClickListener();
+
+ boolean hideFab = (args != null) && args.getBoolean(ARG_HIDE_FAB, false);
+ if (hideFab) {
+ setFabEnabled(false);
+ } else {
+ setFabEnabled(true);
+ registerFabListeners();
+
+ // detect if a mini FAB has ever been clicked
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ if(prefs.getLong(KEY_FAB_EVER_CLICKED, 0) > 0) {
+ miniFabClicked = true;
+ }
+
+ // add labels to the min FABs when none of them has ever been clicked on
+ if(!miniFabClicked) {
+ setFabLabels();
+ } else {
+ removeFabLabels();
+ }
+ }
}
+ /**
+ * adds labels to all mini FABs.
+ */
+ private void setFabLabels() {
+ getFabUpload().setTitle(getResources().getString(R.string.actionbar_upload));
+ getFabMkdir().setTitle(getResources().getString(R.string.actionbar_mkdir));
+ getFabUploadFromApp().setTitle(getResources().getString(R.string.actionbar_upload_from_apps));
+ }
+
+ /**
+ * registers all listeners on all mini FABs.
+ */
+ private void registerFabListeners() {
+ registerFabUploadListeners();
+ registerFabMkDirListeners();
+ registerFabUploadFromAppListeners();
+ }
+
+ /**
+ * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
+ * on the Upload mini FAB for the linked action and {@link Toast} showing the underlying action.
+ */
+ private void registerFabUploadListeners() {
+ getFabUpload().setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent action = new Intent(getActivity(), UploadFilesActivity.class);
+ action.putExtra(
+ UploadFilesActivity.EXTRA_ACCOUNT,
+ ((FileActivity) getActivity()).getAccount()
+ );
+ getActivity().startActivityForResult(action, UploadSourceDialogFragment.ACTION_SELECT_MULTIPLE_FILES);
+ getFabMain().collapse();
+ recordMiniFabClick();
+ }
+ });
+
+ getFabUpload().setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ Toast.makeText(getActivity(), R.string.actionbar_upload, Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ });
+ }
+
+ /**
+ * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
+ * on the 'Create Dir' mini FAB for the linked action and {@link Toast} showing the underlying action.
+ */
+ private void registerFabMkDirListeners() {
+ getFabMkdir().setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ CreateFolderDialogFragment dialog =
+ CreateFolderDialogFragment.newInstance(mFile);
+ dialog.show(getActivity().getSupportFragmentManager(), FileDisplayActivity.DIALOG_CREATE_FOLDER);
+ getFabMain().collapse();
+ recordMiniFabClick();
+ }
+ });
+
+ getFabMkdir().setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ Toast.makeText(getActivity(), R.string.actionbar_mkdir, Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ });
+ }
+
+ /**
+ * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
+ * on the Upload from App mini FAB for the linked action and {@link Toast} showing the underlying action.
+ */
+ private void registerFabUploadFromAppListeners() {
+ getFabUploadFromApp().setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent action = new Intent(Intent.ACTION_GET_CONTENT);
+ action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
+
+ //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+ }
+
+ getActivity().startActivityForResult(
+ Intent.createChooser(action, getString(R.string.upload_chooser_title)),
+ UploadSourceDialogFragment.ACTION_SELECT_CONTENT_FROM_APPS
+ );
+ getFabMain().collapse();
+ recordMiniFabClick();
+ }
+ });
+
+ getFabUploadFromApp().setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ Toast.makeText(getActivity(),
+ R.string.actionbar_upload_from_apps,
+ Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ });
+ }
+
+ /**
+ * records a click on a mini FAB and thus:
+ * <ol>
+ * <li>persists the click fact</li>
+ * <li>removes the mini FAB labels</li>
+ * </ol>
+ */
+ private void recordMiniFabClick() {
+ // only record if it hasn't been done already at some other time
+ if(!miniFabClicked) {
+ final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ sp.edit().putLong(KEY_FAB_EVER_CLICKED, 1).commit();
+ miniFabClicked = true;
+ }
+ }
+
+ /**
+ * removes the labels on all known min FABs.
+ */
+ private void removeFabLabels() {
+ getFabUpload().setTitle(null);
+ getFabMkdir().setTitle(null);
+ getFabUploadFromApp().setTitle(null);
+ ((TextView) getFabUpload().getTag(com.getbase.floatingactionbutton.R.id.fab_label)).setVisibility(View.GONE);
+ ((TextView) getFabMkdir().getTag(com.getbase.floatingactionbutton.R.id.fab_label)).setVisibility(View.GONE);
+ ((TextView) getFabUploadFromApp().getTag(com.getbase.floatingactionbutton.R.id.fab_label)).setVisibility(View.GONE);
+ }
+
private void registerLongClickListener() {
- getListView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- public boolean onItemLongClick(AdapterView<?> arg0, View v,
- int index, long arg3) {
- showFileAction(index);
+ getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
+ private Menu menu;
+
+ @Override
+ public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
+ final int checkedCount = getListView().getCheckedItemCount();
+ // TODO Tobi extract to values
+ mode.setTitle(checkedCount + " selected");
+
+ if (checked) {
+ mAdapter.setNewSelection(position, checked);
+ } else {
+ mAdapter.removeSelection(position);
+ }
+
+ // TODO maybe change: only recreate menu if count changes
+ menu.clear();
+ if (checkedCount == 1) {
+ createContextMenu(menu);
+ } else {
+ // download, move, copy, delete
+ getActivity().getMenuInflater().inflate(R.menu.multiple_file_actions_menu, menu);
+ }
+
+ }
+
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ this.menu = menu;
return true;
}
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ return onFileActionChosen(item.getItemId());
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+ mAdapter.removeSelection();
+ }
});
}
}
}
- FileActionsDialogFragment dialog = FileActionsDialogFragment.newInstance(menu, fileIndex, targetFile.getFileName());
+ FileActionsDialogFragment dialog = FileActionsDialogFragment.newInstance(menu,
+ fileIndex, targetFile.getFileName());
dialog.setTargetFragment(this, 0);
dialog.show(getFragmentManager(), FileActionsDialogFragment.FTAG_FILE_ACTIONS);
}
/**
* Call this, when the user presses the up button.
- *
- * Tries to move up the current folder one level. If the parent folder was removed from the
- * database, it continues browsing up until finding an existing folders.
- * <p/>
- * return Count of folder levels browsed up.
+ * <p>
+ * Tries to move up the current folder one level. If the parent folder was removed from the
+ * database, it continues browsing up until finding an existing folders.
+ * </p>
+ * @return Count of folder levels browsed up.
*/
public int onBrowseUp() {
OCFile parentDir = null;
} // exit is granted because storageManager.getFileByPath("/") never returns null
mFile = parentDir;
- // TODO Enable when "On Device" is recovered ?
- listDirectory(mFile /*, MainApp.getOnlyOnDevice()*/);
+ listDirectory(mFile, MainApp.getOnlyOnDevice());
onRefresh(false);
if (file != null) {
if (file.isFolder()) {
// update state and view of this fragment
- // TODO Enable when "On Device" is recovered ?
- listDirectory(file/*, MainApp.getOnlyOnDevice()*/);
+ listDirectory(file, MainApp.getOnlyOnDevice());
// then, notify parent activity to let it update its state and view
mContainerActivity.onBrowsedDownTo(file);
// save index and top position
((FileDisplayActivity)mContainerActivity).startImagePreview(file);
} else if (PreviewTextFragment.canBePreviewed(file)){
((FileDisplayActivity)mContainerActivity).startTextPreview(file);
- } else if (file.isDown()) {
- if (PreviewMediaFragment.canBePreviewed(file)) {
+ } else if (PreviewMediaFragment.canBePreviewed(file)) {
// media preview
((FileDisplayActivity) mContainerActivity).startMediaPreview(file, 0, true);
- } else {
+ } else if (file.isDown()) {
mContainerActivity.getFileOperationsHelper().openFile(file);
- } else {
- }
-
+ } else {
// automatic download, preview on finish
((FileDisplayActivity) mContainerActivity).startDownloadForPreview(file);
}
-
}
-
} else {
Log_OC.d(TAG, "Null object in ListAdapter!!");
}
-
}
/**
* {@inheritDoc}
*/
- @Override
- public void onCreateContextMenu(
- ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
+ // TODO Tobi needed?
+ public void createContextMenu(Menu menu) {
Bundle args = getArguments();
boolean allowContextualActions =
(args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true);
if (allowContextualActions) {
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.file_actions_menu, menu);
- AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
- OCFile targetFile = (OCFile) mAdapter.getItem(info.position);
+ OCFile targetFile = null;
+ if (mAdapter.getCheckedItems().size() == 1){
+ targetFile = mAdapter.getCheckedItems().get(0);
+ }
if (mContainerActivity.getStorageManager() != null) {
FileMenuFilter mf = new FileMenuFilter(
item.setEnabled(false);
}
}
+
+// String.format(mContext.getString(R.string.subject_token),
+// getClient().getCredentials().getUsername(), file.getFileName()));
}
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean onFileActionChosen(int menuId, int filePosition) {
- mTargetFile = (OCFile) mAdapter.getItem(filePosition);
- switch (menuId) {
- case R.id.action_share_file: {
- mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile);
- return true;
- }
- case R.id.action_share_with_users: {
- mContainerActivity.getFileOperationsHelper().showShareFile(mTargetFile);
- return true;
- }
- case R.id.action_open_file_with: {
- mContainerActivity.getFileOperationsHelper().openFile(mTargetFile);
- return true;
- }
- case R.id.action_unshare_file: {
- mContainerActivity.getFileOperationsHelper().unshareFileWithLink(mTargetFile);
- return true;
- }
- case R.id.action_rename_file: {
- RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(mTargetFile);
- dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
- return true;
- }
- case R.id.action_remove_file: {
- RemoveFileDialogFragment dialog = RemoveFileDialogFragment.newInstance(mTargetFile);
- dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
- return true;
- }
- case R.id.action_download_file:
- case R.id.action_sync_file: {
- mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile);
- return true;
- }
- case R.id.action_cancel_sync: {
- ((FileDisplayActivity)mContainerActivity).cancelTransference(mTargetFile);
- return true;
- }
- case R.id.action_see_details: {
- mContainerActivity.showDetails(mTargetFile);
- return true;
- }
- case R.id.action_send_file: {
- // Obtain the file
- if (!mTargetFile.isDown()) { // Download the file
- Log_OC.d(TAG, mTargetFile.getRemotePath() + " : File must be downloaded");
- ((FileDisplayActivity) mContainerActivity).startDownloadForSending(mTargetFile);
+ public boolean onFileActionChosen(int menuId) {
+ if (mAdapter.getCheckedItems().size() == 1){
+ OCFile mTargetFile = mAdapter.getCheckedItems().get(0);
- } else {
- mContainerActivity.getFileOperationsHelper().sendDownloadedFile(mTargetFile);
+ switch (menuId) {
+ case R.id.action_share_file: {
+ mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile);
+ return true;
}
- return true;
+ case R.id.action_open_file_with: {
+ mContainerActivity.getFileOperationsHelper().openFile(mTargetFile);
+ return true;
+ }
+ case R.id.action_unshare_file: {
+ mContainerActivity.getFileOperationsHelper().unshareFileWithLink(mTargetFile);
+ return true;
+ }
+ case R.id.action_rename_file: {
+ RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(mTargetFile);
+ dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
+ return true;
+ }
+ case R.id.action_remove_file: {
+ RemoveFileDialogFragment dialog = RemoveFileDialogFragment.newInstance(mTargetFile);
+ dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
+ return true;
+ }
+ case R.id.action_download_file:
+ case R.id.action_sync_file: {
+ mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile);
+ return true;
+ }
+ case R.id.action_cancel_sync: {
+ ((FileDisplayActivity) mContainerActivity).cancelTransference(mTargetFile);
+ return true;
+ }
+ case R.id.action_see_details: {
+ mContainerActivity.showDetails(mTargetFile);
+ return true;
+ }
+ case R.id.action_send_file: {
+ // Obtain the file
+ if (!mTargetFile.isDown()) { // Download the file
+ Log_OC.d(TAG, mTargetFile.getRemotePath() + " : File must be downloaded");
+ ((FileDisplayActivity) mContainerActivity).startDownloadForSending(mTargetFile);
+ return true;
+ } else {
+ mContainerActivity.getFileOperationsHelper().sendDownloadedFile(mTargetFile);
+ }
+ }
+ case R.id.action_stream_file: {
+ Account account = ((FileActivity)mContainerActivity).getAccount();
+ Context context = MainApp.getAppContext();
+ String uri = PreviewMediaFragment.generateUrlWithCredentials(account, context, mTargetFile);
+ MediaService.streamWithExternalApp(uri, getActivity()).show();
+ return true;
+ }
+ case R.id.action_move: {
+ Intent action = new Intent(getActivity(), FolderPickerActivity.class);
+ ArrayList files = new ArrayList();
+ files.add(mTargetFile);
+ action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, files);
+ getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
+ return true;
+ }
+ case R.id.action_favorite_file: {
+ mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true);
+ return true;
+ }
+ case R.id.action_unfavorite_file: {
+ mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false);
+ return true;
+ }
+ case R.id.action_copy:
+ Intent action = new Intent(getActivity(), FolderPickerActivity.class);
+
+ // Pass mTargetFile that contains info of selected file/folder
+ action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
+ getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
+ return true;
+ default:
+ return false;
}
- case R.id.action_move: {
- Intent action = new Intent(getActivity(), FolderPickerActivity.class);
+ } else {
+ ArrayList<OCFile> mTargetFiles = mAdapter.getCheckedItems();
- // Pass mTargetFile that contains info of selected file/folder
- action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
- getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
- return true;
- }
- case R.id.action_favorite_file: {
- mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true);
- return true;
- }
- case R.id.action_unfavorite_file: {
- mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false);
- return true;
+ switch (menuId) {
+ case R.id.action_remove_file: {
+ RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(mTargetFiles);
+ dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
+ return true;
+ }
+ case R.id.action_download_file:
+ case R.id.action_sync_file: {
+ mContainerActivity.getFileOperationsHelper().syncFiles(mTargetFiles);
+ return true;
+ }
+ case R.id.action_move: {
+ Intent action = new Intent(getActivity(), FolderPickerActivity.class);
+ action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, mTargetFiles);
+ getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
+ return true;
+ }
+ case R.id.action_favorite_file: {
+ mContainerActivity.getFileOperationsHelper().toggleFavorites(mTargetFiles, true);
+ return true;
+ }
+ case R.id.action_unfavorite_file: {
+ mContainerActivity.getFileOperationsHelper().toggleFavorites(mTargetFiles, false);
+ return true;
+ }
+ case R.id.action_copy:
+ Intent action = new Intent(getActivity(), FolderPickerActivity.class);
+ action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, mTargetFiles);
+ getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
+ return true;
+ default:
+ return false;
}
- case R.id.action_copy:
- Intent action = new Intent(getActivity(), FolderPickerActivity.class);
-
- // Pass mTargetFile that contains info of selected file/folder
- action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
- getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
- return true;
- default:
- return false;
}
-
}
/**
@Override
public boolean onContextItemSelected (MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
- boolean matched = onFileActionChosen(item.getItemId());
- boolean matched = onFileActionChosen(item.getItemId(),
- ((AdapterContextMenuInfo) item.getMenuInfo()).position);
++ boolean matched = onFileActionChosen(item.getItemId()) ;
if(!matched) {
return super.onContextItemSelected(item);
} else {
}
/**
- * Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter
+ * Calls {@link OCFileListFragment#listDirectory(OCFile, boolean)} with a null parameter
*/
- public void listDirectory(/*boolean onlyOnDevice*/){
- listDirectory(null);
- // TODO Enable when "On Device" is recovered ?
- // listDirectory(null, onlyOnDevice);
+ public void listDirectory(boolean onlyOnDevice){
+ listDirectory(null, onlyOnDevice);
}
public void refreshDirectory(){
- // TODO Enable when "On Device" is recovered ?
- listDirectory(getCurrentFile()/*, MainApp.getOnlyOnDevice()*/);
+ listDirectory(getCurrentFile(), MainApp.getOnlyOnDevice());
}
/**
*
* @param directory File to be listed
*/
- public void listDirectory(OCFile directory/*, boolean onlyOnDevice*/) {
+ public void listDirectory(OCFile directory, boolean onlyOnDevice) {
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
if (storageManager != null) {
directory = storageManager.getFileById(directory.getParentId());
}
- // TODO Enable when "On Device" is recovered ?
- mAdapter.swapDirectory(directory, storageManager/*, onlyOnDevice*/);
+ mAdapter.swapDirectory(directory, storageManager, onlyOnDevice);
if (mFile == null || !mFile.equals(directory)) {
mCurrentListView.setSelection(0);
}
if (!file.isHidden()) {
filesCount++;
- if (file.isImage()) {
+ if (file.isImage() || file.isVideo()) {
imagesCount++;
}
}
OwnCloudVersion version = AccountUtils.getServerVersion(
((FileActivity)mContainerActivity).getAccount());
if (version != null && version.supportsRemoteThumbnails() &&
- imagesCount > 0 && imagesCount == filesCount) {
+ DisplayUtils.isGridView(mFile, mContainerActivity.getStorageManager())) {
switchToGridView();
registerLongClickListener();
} else {
switchToListView();
+// switchToGridView();
}
}
}
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
- import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import com.ortiz.touch.ExtendedViewPager;
+import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
- import com.owncloud.android.operations.CreateShareOperation;
+ import com.owncloud.android.operations.CreateShareViaLinkOperation;
+ import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
- import com.owncloud.android.operations.UnshareLinkOperation;
+ import com.owncloud.android.operations.UnshareOperation;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
+ import com.owncloud.android.ui.activity.ShareActivity;
import com.owncloud.android.ui.fragment.FileFragment;
- import com.owncloud.android.utils.DisplayUtils;
/**
parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
}
- // TODO Enable when "On Device" is recovered ?
mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(),
- parentFolder, getAccount(), getStorageManager()/*, MainApp.getOnlyOnDevice()*/);
+ parentFolder, getAccount(), getStorageManager(), MainApp.getOnlyOnDevice());
mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager);
int position = mHasSavedPosition ? mSavedPosition :
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
super.onRemoteOperationFinish(operation, result);
- if (operation instanceof CreateShareOperation) {
- onCreateShareOperationFinish((CreateShareOperation) operation, result);
-
- } else if (operation instanceof UnshareLinkOperation) {
- onUnshareLinkOperationFinish((UnshareLinkOperation) operation, result);
+ if (operation instanceof CreateShareViaLinkOperation ||
+ operation instanceof CreateShareWithShareeOperation) {
+ onCreateShareOperationFinish(result);
+
+ } else if (operation instanceof UnshareOperation) {
+ onUnshareLinkOperationFinish((UnshareOperation) operation, result);
} else if (operation instanceof RemoveFileOperation) {
finish();
}
- private void onUnshareLinkOperationFinish(UnshareLinkOperation operation,
+ private void onUnshareLinkOperationFinish(UnshareOperation operation,
RemoteOperationResult result) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
}
- private void onCreateShareOperationFinish(CreateShareOperation operation,
- RemoteOperationResult result) {
+ private void onCreateShareOperationFinish(RemoteOperationResult result) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
if (file != null) {
}
-
private void requestForDownload(OCFile file) {
if (mDownloaderBinder == null) {
Log_OC.d(TAG, "requestForDownload called without binder to download service");
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.file_actions_menu, menu);
+
+// MenuItem item = menu.findItem(R.id.action_set_as_wallpaper);
+// item.setVisible(getFile().isDown());
}
/**
mContainerActivity.getFileOperationsHelper().shareFileWithLink(getFile());
return true;
}
+ case R.id.action_share_with_users: {
+ mContainerActivity.getFileOperationsHelper().showShareFile(getFile());
+ return true;
+ }
case R.id.action_unshare_file: {
mContainerActivity.getFileOperationsHelper().unshareFileWithLink(getFile());
return true;
return true;
}
}
+ case R.id.action_download_file:
case R.id.action_sync_file: {
mContainerActivity.getFileOperationsHelper().syncFile(getFile());
return true;
mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false);
return true;
}
+ case R.id.action_set_as_wallpaper:{
+ mContainerActivity.getFileOperationsHelper().setPictureAs(getFile());
+ return true;
+ }
default:
return false;
}
mContainerActivity.showDetails(getFile());
}
-
@Override
public void onResume() {
super.onResume();
imageView.setBackground(backrepeat);
}
- imageView.setImageBitmap(bitmap);
+ if (result.ocFile.getMimetype().equalsIgnoreCase("image/gif")){
+ imageView.setGifImage(result.ocFile);
+ } else {
+ imageView.setImageBitmap(bitmap);
+ }
+
imageView.setVisibility(View.VISIBLE);
mBitmap = bitmap; // needs to be kept for recycling when not useful
}
package com.owncloud.android.ui.preview;
import android.accounts.Account;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
import android.app.Activity;
+import android.content.ActivityNotFoundException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
+import android.os.AsyncTask;
import android.support.v7.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.widget.Toast;
import android.widget.VideoView;
+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.OwnCloudAccount;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
+import com.owncloud.android.lib.common.OwnCloudCredentials;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.media.MediaControlView;
import com.owncloud.android.media.MediaService;
import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
import com.owncloud.android.ui.fragment.FileFragment;
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
/**
* This fragment shows a preview of a downloaded media file (audio or video).
private ImageView mImagePreview;
private VideoView mVideoPreview;
private int mSavedPlaybackPosition;
+ private String mUri;
private MediaServiceBinder mMediaServiceBinder = null;
private MediaControlView mMediaController = null;
if (mAccount == null) {
throw new IllegalStateException("Instanced with a NULL ownCloud Account");
}
- if (!file.isDown()) {
- throw new IllegalStateException("There is no local file to preview");
- }
-
}
else {
file = (OCFile) savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
mAutoplay = savedInstanceState.getBoolean(PreviewMediaFragment.EXTRA_PLAYING);
}
- if (file != null && file.isDown()) {
+ if (file != null) {
if (file.isVideo()) {
mVideoPreview.setVisibility(View.VISIBLE);
mImagePreview.setVisibility(View.GONE);
Log_OC.e(TAG, "onStart");
OCFile file = getFile();
- if (file != null && file.isDown()) {
+ if (file != null) {
if (file.isAudio()) {
bindMediaService();
mContainerActivity.getFileOperationsHelper().shareFileWithLink(getFile());
return true;
}
+ case R.id.action_share_with_users: {
+ seeShareFile();
+ return true;
+ }
case R.id.action_unshare_file: {
stopPreview(false);
mContainerActivity.getFileOperationsHelper().unshareFileWithLink(getFile());
mContainerActivity.showDetails(getFile());
}
+ private void seeShareFile() {
+ stopPreview(false);
+ mContainerActivity.getFileOperationsHelper().showShareFile(getFile());
+ }
private void prepareVideo() {
// create helper to get more control on the playback
// load the video file in the video player ;
// when done, VideoHelper#onPrepared() will be called
- Uri uri = Uri.parse(getFile().getStoragePath());
- mVideoPreview.setVideoPath(uri.encode(getFile().getStoragePath()));
+ if (getFile().isDown()) {
+ mUri = getFile().getStoragePath();
+ } else {
+ Context context = MainApp.getAppContext();
+ Account account = mContainerActivity.getStorageManager().getAccount();
+
+ mUri = generateUrlWithCredentials(account, context, getFile());
+ }
+
+ mVideoPreview.setVideoPath(mUri);
+ }
+
+ public static String generateUrlWithCredentials(Account account, Context context, OCFile file){
+ OwnCloudAccount ocAccount = null;
+ try {
+ ocAccount = new OwnCloudAccount(account, context);
+
+ final ClientGenerationTask task = new ClientGenerationTask();
+ task.execute(ocAccount);
+
+ OwnCloudClient mClient = task.get();
+ String url = AccountUtils.constructFullURLForAccount(context, account) + Uri.encode(file.getRemotePath(), "/");
+ OwnCloudCredentials credentials = mClient.getCredentials();
+
+ return url.replace("//", "//" + credentials.getUsername() + ":" + credentials.getAuthToken() + "@");
+
+ } catch (AccountUtils.AccountNotFoundException e) {
+ e.printStackTrace();
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ public static class ClientGenerationTask extends AsyncTask<Object, Void, OwnCloudClient> {
+ @Override
+ protected OwnCloudClient doInBackground(Object... params) {
+ Object account = params[0];
+ if (account instanceof OwnCloudAccount){
+ try {
+ OwnCloudAccount ocAccount = (OwnCloudAccount) account;
+ return OwnCloudClientManagerFactory.getDefaultSingleton().
+ getClientFor(ocAccount, MainApp.getAppContext());
+ } catch (AccountUtils.AccountNotFoundException e) {
+ e.printStackTrace();
+ } catch (OperationCanceledException e) {
+ e.printStackTrace();
+ } catch (AuthenticatorException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return null;
+ }
}
*/
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
- if (mVideoPreview.getWindowToken() != null) {
- String message = MediaService.getMessageForMediaError(
- getActivity(), what, extra);
- new AlertDialog.Builder(getActivity())
- .setMessage(message)
- .setPositiveButton(android.R.string.VideoView_error_button,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- dialog.dismiss();
- VideoHelper.this.onCompletion(null);
- }
- })
- .setCancelable(false)
- .show();
- }
+ MediaService.streamWithExternalApp(mUri, getActivity()).show();
return true;
}
-
}
-
@Override
public void onPause() {
Log_OC.e(TAG, "onPause");