# built application files
-*.apk
*.ap_
# files for the dex VM
build
# Actionbarsherlock is now ignored since scripts takes care of init the sub-modules.
-actionbarsherlock
\ No newline at end of file
+actionbarsherlock
<provider
android:name=".providers.FileContentProvider"
- android:authorities="@string/authority"
+ android:authorities="com.owncloud.beta"
android:enabled="true"
- android:exported="false"
+ android:exported="true"
android:label="@string/sync_string_files"
android:syncable="true"></provider>
+ <provider
+ android:name=".ui.adapter.DiskLruImageCacheFileProvider"
+ android:authorities="com.owncloud.beta.imageCache.provider">
+ </provider>
+
<activity
android:name=".authentication.AuthenticatorActivity"
android:exported="true"
<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">
<intent-filter>
-## 1.8.0 (September 2015)
-- New MATERIAL DESIGN theme
-- Updated FILE TYPE ICONS
-- Preview TXT files within the app
-- COPY files & folders
-- Preview the full file/folder name from the long press menu
-- Set a file as FAVORITE (kept-in-sync) from the CONTEXT MENU
-- Updated CONFLICT RESOLUTION dialog (wording)
-- Updated background for images with TRANSPARENCY in GALLERY
-- Hidden files will not enforce list view instead of GRID VIEW (folders from Picasa & others)
-- Security:
- + Updated network stack with security fixes (Jackrabbit 2.10.1)
-- Bugs fixed:
- + Fixed crash when ETag is lost
- + Passcode creation not restarted on device rotation
- + Recovered share icon shown on folders 'shared with me'
- + User name added to subject when sending a share link through e-mail (fixed on SAMLed apps)
-
-## 1.7.2 (July 2015)
-- New navigation drawer
-- Improved Passcode
-- Automatic grid view just for folders full of images
-- More characters allowed in file names
-- Support for servers in same domain, different path
-- Bugs fixed:
- + Frequent crashes in folder with several images
- + Sync error in servers with huge quota and external storage enable
- + Share by link error
- + Some other crashes and minor bugs
-
-## 1.7.1 (April 2015)
-
-- Share link even with password enforced by server
-- Get the app ready for oc 8.1 servers
-- Added option to create new folder in uploads from external apps
-- Improved management of deleted users
-- Bugs fixed
- + Fixed crash on Android 2.x devices
- + Improvements on uploads
-
-## 1.7.0 (February 2015)
-
-- Download full folders
-- Grid view for images
-- Remote thumbnails (OC Server 8.0+)
-- Added number of files and folders at the end of the list
-- "Open with" in contextual menu
-- Downloads added to Media Provider
-- Uploads:
- + Local thumbnails in section "Files"
- + Multiple selection in "Content from other apps" (Android 4.3+)
-- Gallery:
- + proper handling of EXIF
- + obey sorting in the list of files
-- Settings view updated
-- Improved subjects in e-mails
-- Bugs fixed
-
+# 2015-10-29
+- PR [#1099](https://github.com/owncloud/android/pull/1099) "Switch list vs grid" merged
+# 2015-10-26
+- start of branch
+- PR [#745](https://github.com/owncloud/android/pull/745) merged
+- PR [#1044](https://github.com/owncloud/android/pull/1044) merged: < 8.1: GalleryPlus app needed, >= 8.2 Gallery app needed
+- PR [#1111](https://github.com/owncloud/android/pull/1111) merged
\ No newline at end of file
-#This is the Android client for [ownCloud][0]
+#This is the BETA Android client for [ownCloud][0]
+
+The BETA app is only intended to be used by experienced users that want to use and test the latest features.
+All pull requests labeled "3 - to review" or higher will be included into the branch.
+If you find a bug please comment in the corresponding pull request or create a new issue with the label "Beta".
+
+The compiled APKs can be found [here][2]
+
+The changelog is found [here][3]
The app performs file synchronization with an ownCloud server. Other ownCloud features may be added in the future, but they are not a priority right now.
## Build Status on
-Git master: 
-
-Git stable: 
+Git beta: 
## Development
[0]: https://github.com/owncloud/core
[1]: https://github.com/owncloud/android/blob/master/SETUP.md
+[2]: https://github.com/owncloud/android/tree/beta/apks/
+[3]: https://github.com/owncloud/android/blob/beta/CHANGELOG.md
### Contributing
Please see [Contribution Guidelines](https://owncloud.org/contribute/). Fork this repository and contribute back using
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
+
+ defaultConfig {
+ applicationId "com.owncloud.android.beta"
+ }
+
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
-Subproject commit ecc3415e3e3c13fa8f73fdd51a88c1ab7087b199
+Subproject commit 652cd28bb15672eaedfe8c1d9a46cf293c909b89
-<?xml version="1.0" encoding="utf-8"?><!--
+<?xml version="1.0" encoding="utf-8"?>
+<!--
ownCloud Android client application
Copyright (C) 2012 Bartek Przybylski
android:title="@string/actionbar_mkdir"
android:contentDescription="@string/actionbar_mkdir"/>
<item
+ android:id="@+id/action_switch_view"
+ android:icon="@drawable/ic_view_module"
+ android:orderInCategory="2"
+ app:showAsAction="never"
+ android:title="@string/action_switch_grid_view" />
+ <item
android:id="@+id/action_sync_account"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="1"
<item>Biggest - Smallest</item>-->
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<string name="drawer_item_accounts">Accounts</string>-->
+ <string name="drawer_item_all_files">Visas datnes</string>
<!--TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
+ <string name="drawer_item_settings">Iestatījumi</string>
+ <string name="drawer_close">Aizvērt</string>
<string name="drawer_open">Atvērt</string>
<string name="prefs_category_general">Vispārīgi</string>
<string name="prefs_category_more">Vairāk</string>
<string name="prefs_help">Palīdzība</string>
<string name="prefs_recommend">Ieteikt draugam</string>
<string name="prefs_feedback">Atsauksmes</string>
+ <string name="recommend_subject">Izmēģini %1$s uz savu viedtālruni!</string>
+ <string name="auth_check_server">Pārbaudīt serveri</string>
<string name="auth_username">Lietotājvārds</string>
<string name="auth_password">Parole</string>
<string name="sync_string_files">Datnes</string>
<string name="uploader_info_uploading">Augšupielādē</string>
<string name="file_list_seconds_ago">sekundes atpakaļ</string>
<string name="file_list_empty">Te vēl nekas nav. Rīkojies, sāc augšupielādēt!</string>
+ <string name="file_list_loading">Ielādē…</string>
<string name="local_file_list_empty">Šajā mapē nav failu</string>
<string name="filedetails_select_file">Uzsitiet uz datnes, lai redzētu papildinformāciju.</string>
<string name="filedetails_size">Izmērs:</string>
<string name="filedetails_download">Lejupielādēt</string>
<string name="filedetails_sync_file">Atsvaidzināt failu</string>
<string name="filedetails_renamed_in_upload_msg">Datne tika pārsaukta uz %1$s augšupielādes laikā</string>
+ <string name="action_share_file">Dalīt saiti</string>
+ <string name="action_unshare_file">Pārtraukt dalīt saiti</string>
<string name="common_yes">Jā</string>
<string name="common_no">Nē</string>
<string name="common_ok">Labi</string>
<string name="common_remove">Izņemt</string>
<string name="confirmation_remove_local">Tikai lokālos</string>
<string name="confirmation_remove_folder_local">Tikai lokālos</string>
+ <string name="confirmation_remove_remote">No servera</string>
<string name="remove_success_msg">Veiksmīgi izņemts</string>
<string name="remove_fail_msg">Neizdevās izņemt</string>
<string name="rename_dialog_title">Ievadīt jaunu nosaukumu</string>
<string name="rename_server_fail_msg">Nevarēja pabeigt pārsaukšanu</string>
<string name="sync_file_fail_msg">Nevarēja atzīmēt attālinātas datnes</string>
<string name="sync_file_nothing_to_do_msg">Datnes saturs jau ir sinhronizēts</string>
+ <string name="create_dir_fail_msg">Mapi nevarēja izveidot</string>
<string name="wait_a_moment">Uzgaidīt brīdi</string>
<string name="filedisplay_unexpected_bad_get_content">Negaidīta problēma; lūdzu, izvēlieties datni no citas lietotnes</string>
<string name="filedisplay_no_file_selected">Netika izvēlēta neviena datne</string>
<string name="ssl_validator_label_validity_to">Kam:</string>
<string name="ssl_validator_label_signature">Paraksts:</string>
<string name="ssl_validator_label_signature_algorithm">Algoritms:</string>
+ <string name="placeholder_filetype">PNG attēls</string>
<string name="instant_upload_on_wifi">Attēlus augšupielādēt tikai caur WiFi</string>
<string name="instant_upload_path">/TūlītējaAugšupielāde</string>
<string name="conflict_keep_both">Paturēt abas</string>
+ <string name="preview_image_error_unknown_format">Šo attēlu nevar attēlot</string>
+ <string name="share_link_password_title">Ievadiet paroli</string>
+ <string name="share_link_empty_password">Jums ir jāievada paroli</string>
<string name="activity_chooser_send_file_title">Sūtīt</string>
+ <string name="copy_link">Kopēt saiti</string>
<string name="empty"></string>
+ <string name="forbidden_permissions_rename">lai pārsauktu šo datni</string>
+ <string name="forbidden_permissions_delete">lai dzēstu šo datni</string>
+ <string name="share_link_forbidden_permissions">lai dalītu šo datni</string>
+ <string name="unshare_link_forbidden_permissions">lai pārtrauktu šis datnes dalīšanu</string>
+ <string name="forbidden_permissions_create">lai izveidotu datni</string>
<string name="prefs_category_accounts">Konti</string>
+ <string name="prefs_add_account">Pievienot kontu</string>
+ <string name="log_progress_dialog_text">Ielādē datus…</string>
<string name="saml_authentication_wrong_pass">Nepareiza parole</string>
+ <string name="actionbar_move">Pārvietot</string>
+ <string name="file_list_empty_moving">Šeit nekā nav. Jūs varat pievienot mapi!</string>
<string name="folder_picker_choose_button_text">Izvēlieties</string>
+ <string name="forbidden_permissions_move">lai pārvietotu šo datni</string>
+ <string name="forbidden_permissions_copy">lai kopētu šo datni</string>
<string name="prefs_category_security">Drošība</string>
+ <string name="shared_subject_header">koplietots</string>
+ <string name="with_you_subject_header">ar jums</string>
<string name="auth_host_address">Servera adrese</string>
+ <string name="username">Lietotājvārds</string>
+ <string name="file_list__footer__folder">1 mape</string>
+ <string name="file_list__footer__file">1 datne</string>
</resources>
+++ /dev/null
-<?xml version='1.0' encoding='UTF-8'?>
-<resources>
- <!--TODO re-enable when server-side folder size calculation is available
- <item>Biggest - Smallest</item>-->
- <!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
- <!--<string name="drawer_item_accounts">Accounts</string>-->
- <!--TODO re-enable when "On Device" is available
- <string name="drawer_item_on_device">On device</string>-->
- <string name="empty"></string>
-</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- App name and other strings-->
- <string name="app_name">ownCloud</string>
+ <string name="app_name">Owncloud Beta</string>
<string name="account_type">owncloud</string> <!-- better if was a domain name; but changing it now would require migrate accounts when the app is updated -->
<string name="authority">org.owncloud</string> <!-- better if was the app package with ".provider" appended ; it identifies the provider -->
- <string name ="db_file">owncloud.db</string>
+ <string name ="db_file">owncloud-beta.db</string>
<string name ="db_name">ownCloud</string>
- <string name ="data_folder">owncloud</string>
+ <string name ="data_folder">owncloud-beta</string>
<string name ="log_name">Owncloud_</string>
<string name ="default_display_name_for_root_folder">ownCloud</string>
<string name ="user_agent">Mozilla/5.0 (Android) ownCloud-android/%1$s</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="shared_subject_header">shared</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>
</resources>
ownCloud Android client application
Copyright (C) 2012 Bartek Przybylski
- Copyright (C) 2015 ownCloud Inc.
+ Copyright (C) 2012-2013 ownCloud Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2,
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
- <PreferenceCategory android:title="@string/prefs_category_accounts" android:key="accounts_category">
+ <PreferenceCategory
+ android:title="@string/prefs_category_accounts"
+ android:key="accounts_category">
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefs_category_security">
- <android.preference.CheckBoxPreference android:title="@string/prefs_passcode" android:key="set_pincode" />
+ <!-- ListPreference
+ android:key="select_oc_account"
+ android:title="@string/prefs_select_oc_account"
+ android:summary="@string/prefs_summary_select_oc_account"
+ / -->
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:title="@string/prefs_pincode" android:key="set_pincode"
+ android:summary="@string/prefs_pincode_summary"/>
</PreferenceCategory>
- <PreferenceCategory android:title="@string/prefs_category_instant_uploading" android:key="instant_uploading_category">
- <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_uploading"
- android:title="@string/prefs_instant_upload"
- android:summary="@string/prefs_instant_upload_summary"/>
- <com.owncloud.android.ui.PreferenceWithLongSummary
- android:title="@string/prefs_instant_upload_path_title"
- android:key="instant_upload_path" />
+ <PreferenceCategory android:title="@string/prefs_category_instant_uploading"
+ android:key="instant_uploading_category">
+
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+ android:key="instant_uploading"
+ android:title="@string/prefs_instant_upload"
+ android:summary="@string/prefs_instant_upload_summary"/>
+ <com.owncloud.android.ui.PreferenceWithLongSummary
+ android:dependency="instant_uploading"
+ android:disableDependentsState="true"
+ android:title="@string/prefs_instant_upload_path_title"
+ android:key="instant_upload_path" />
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
- android:title="@string/instant_upload_on_wifi"
- android:key="instant_upload_on_wifi"/>
- <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle android:key="instant_video_uploading"
- android:title="@string/prefs_instant_video_upload"
- android:summary="@string/prefs_instant_video_upload_summary" />
+ android:dependency="instant_uploading"
+ android:disableDependentsState="true"
+ android:title="@string/instant_upload_on_wifi"
+ android:key="instant_upload_on_wifi"/>
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+ android:dependency="instant_uploading"
+ android:disableDependentsState="true"
+ android:title="@string/instant_upload_on_charging"
+ android:key="instant_upload_on_charging"/>
+
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+ android:key="instant_video_uploading"
+ android:title="@string/prefs_instant_video_upload"
+ android:summary="@string/prefs_instant_video_upload_summary" />
<com.owncloud.android.ui.PreferenceWithLongSummary
- android:title="@string/prefs_instant_video_upload_path_title"
- android:key="instant_video_upload_path" />
+ android:dependency="instant_video_uploading"
+ android:disableDependentsState="true"
+ android:title="@string/prefs_instant_video_upload_path_title"
+ android:key="instant_video_upload_path" />
<com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
- android:title="@string/instant_video_upload_on_wifi"
- android:key="instant_video_upload_on_wifi"/>
- <!-- DISABLED FOR RELEASE UNTIL FIXED
+ android:dependency="instant_video_uploading"
+ android:disableDependentsState="true"
+ android:title="@string/instant_video_upload_on_wifi"
+ android:key="instant_video_upload_on_wifi"/>
+ <com.owncloud.android.ui.CheckBoxPreferenceWithLongTitle
+ android:dependency="instant_video_uploading"
+ android:disableDependentsState="true"
+ android:title="@string/instant_video_upload_on_charging"
+ android:key="instant_video_upload_on_charging"/>
+ </PreferenceCategory>
+
+ <PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
+ <!-- DISABLED FOR RELEASE UNTIL FIXED
CheckBoxPreference android:key="log_to_file"
android:title="@string/prefs_log_title"
android:summary="@string/prefs_log_summary"/>
<Preference android:key="log_history"
android:title="@string/prefs_log_title_history"
android:summary="@string/prefs_log_summary_history"/ -->
-
- </PreferenceCategory>
-
- <PreferenceCategory android:title="@string/prefs_category_more" android:key="more">
- <Preference android:title="@string/prefs_help" android:key="help" />
- <Preference android:title="@string/prefs_recommend" android:key="recommend" />
- <Preference android:title="@string/prefs_feedback" android:key="feedback" />
- <Preference android:title="@string/prefs_imprint" android:key="imprint" />
-
- <Preference android:id="@+id/about_app"
- android:title="@string/about_title"
- android:key="about_app" />
+ <Preference android:title="@string/prefs_help" android:key="help" />
+ <Preference android:title="@string/prefs_recommend" android:key="recommend" />
+ <Preference android:title="@string/prefs_feedback" android:key="feedback" />
+ <Preference android:title="@string/prefs_imprint" android:key="imprint" />
+
+ <Preference android:id="@+id/about_app"
+ android:title="@string/about_title"
+ android:key="about_app" />
</PreferenceCategory>
-
+
</PreferenceScreen>
import com.owncloud.android.lib.common.utils.Log_OC;
import java.io.File;
+import java.util.Enumeration;
import third_parties.daveKoeller.AlphanumComparator;
public class OCFile implements Parcelable, Comparable<OCFile> {
private boolean mIsDownloading;
+ private boolean mShowGridView;
+
/**
* Create new {@link OCFile} with given path.
import org.apache.commons.httpclient.methods.GetMethod;
import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
+import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.media.ThumbnailUtils;
import android.net.Uri;
import android.os.AsyncTask;
+import android.view.Display;
+import android.view.View;
+import android.view.WindowManager;
import android.widget.ImageView;
+import android.widget.ProgressBar;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
public static class ThumbnailGenerationTask extends AsyncTask<Object, Void, Bitmap> {
private final WeakReference<ImageView> mImageViewReference;
+ private WeakReference<ProgressBar> mProgressWheelRef;
private static Account mAccount;
private Object mFile;
+ private Boolean mIsThumbnail;
private FileDataStorageManager mStorageManager;
-
public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
Account account) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mAccount = account;
}
+ public ThumbnailGenerationTask(ImageView imageView, FileDataStorageManager storageManager,
+ Account account, ProgressBar progressWheel) {
+ this(imageView, storageManager, account);
+ mProgressWheelRef = new WeakReference<ProgressBar>(progressWheel);
+ }
+
public ThumbnailGenerationTask(ImageView imageView) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<ImageView>(imageView);
}
mFile = params[0];
+ mIsThumbnail = (Boolean) params[1];
+
if (mFile instanceof OCFile) {
- thumbnail = doOCFileInBackground();
+ thumbnail = doOCFileInBackground(mIsThumbnail);
} else if (mFile instanceof File) {
- thumbnail = doFileInBackground();
- //} else { do nothing
+ thumbnail = doFileInBackground(mIsThumbnail);
+ } else {
+ // do nothing
}
}catch(Throwable t){
tagId = String.valueOf(mFile.hashCode());
}
if (String.valueOf(imageView.getTag()).equals(tagId)) {
+ if (mProgressWheelRef != null) {
+ final ProgressBar progressWheel = mProgressWheelRef.get();
+ if (progressWheel != null) {
+ progressWheel.setVisibility(View.GONE);
+ }
+ }
imageView.setImageBitmap(bitmap);
+ imageView.setVisibility(View.VISIBLE);
}
}
}
* @param imageKey: thumb key
* @param bitmap: image for extracting thumbnail
* @param path: image path
- * @param px: thumbnail dp
+ * @param pxW: thumbnail width
+ * @param pxH: thumbnail height
* @return Bitmap
*/
- private Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path, int px){
+ private Bitmap addThumbnailToCache(String imageKey, Bitmap bitmap, String path, int pxW, int pxH){
- Bitmap thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
+ Bitmap thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
// Rotate image, obeying exif tag
thumbnail = BitmapUtils.rotateImage(thumbnail,path);
return Math.round(r.getDimension(R.dimen.file_icon_size_grid));
}
- private Bitmap doOCFileInBackground() {
+ private Point getScreenDimension(){
+ WindowManager wm = (WindowManager) MainApp.getAppContext().getSystemService(Context.WINDOW_SERVICE);
+ Display display = wm.getDefaultDisplay();
+ Point test = new Point();
+ display.getSize(test);
+ return test;
+ }
+
+ private Bitmap doOCFileInBackground(Boolean isThumbnail) {
+ Bitmap thumbnail = null;
OCFile file = (OCFile)mFile;
- final String imageKey = String.valueOf(file.getRemoteId());
+ // distinguish between thumbnail and resized image
+ String temp = String.valueOf(file.getRemoteId());
+ if (isThumbnail){
+ temp = "t" + temp;
+ } else {
+ temp = "r" + temp;
+ }
+
+ final String imageKey = temp;
// Check disk cache in background thread
- Bitmap thumbnail = getBitmapFromDiskCache(imageKey);
+ thumbnail = getBitmapFromDiskCache(imageKey);
// Not found in disk cache
if (thumbnail == null || file.needsUpdateThumbnail()) {
-
- int px = getThumbnailDimension();
+ int pxW = 0;
+ int pxH = 0;
+ if (mIsThumbnail) {
+ pxW = pxH = getThumbnailDimension();
+ } else {
+ Point p = getScreenDimension();
+ pxW = p.x;
+ pxH = p.y;
+ }
if (file.isDown()) {
- Bitmap temp = BitmapUtils.decodeSampledBitmapFromFile(
- file.getStoragePath(), px, px);
- Bitmap bitmap = ThumbnailUtils.extractThumbnail(temp, px, px);
+ Bitmap tempBitmap = BitmapUtils.decodeSampledBitmapFromFile(
+ file.getStoragePath(), pxW, pxH);
+ Bitmap bitmap = ThumbnailUtils.extractThumbnail(tempBitmap, pxW, pxH);
if (bitmap != null) {
// Handle PNG
if (file.getMimetype().equalsIgnoreCase("image/png")) {
- bitmap = handlePNG(bitmap, px);
+ bitmap = handlePNG(bitmap, pxW);
}
- thumbnail = addThumbnailToCache(imageKey, bitmap, file.getStoragePath(), px);
+ thumbnail = addThumbnailToCache(imageKey, bitmap,
+ file.getStoragePath(), pxW, pxH);
file.setNeedsUpdateThumbnail(false);
mStorageManager.saveFile(file);
if (mClient != null && serverOCVersion != null) {
if (serverOCVersion.supportsRemoteThumbnails()) {
try {
- String uri = mClient.getBaseUri() + "" +
- "/index.php/apps/files/api/v1/thumbnail/" +
- px + "/" + px + Uri.encode(file.getRemotePath(), "/");
- Log_OC.d("Thumbnail", "URI: " + uri);
- GetMethod get = new GetMethod(uri);
- int status = mClient.executeMethod(get);
- if (status == HttpStatus.SC_OK) {
- InputStream inputStream = get.getResponseBodyAsStream();
- Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
- thumbnail = ThumbnailUtils.extractThumbnail(bitmap, px, px);
-
- // Handle PNG
- if (file.getMimetype().equalsIgnoreCase("image/png")) {
- thumbnail = handlePNG(thumbnail, px);
+ if (mIsThumbnail) {
+ String uri = mClient.getBaseUri() + "" +
+ "/index.php/apps/files/api/v1/thumbnail/" +
+ pxW + "/" + pxH + Uri.encode(file.getRemotePath(), "/");
+ Log_OC.d("Thumbnail", "Download URI: " + uri);
+ GetMethod get = new GetMethod(uri);
+ int status = mClient.executeMethod(get);
+ if (status == HttpStatus.SC_OK) {
+ InputStream inputStream = get.getResponseBodyAsStream();
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
+ thumbnail = ThumbnailUtils.extractThumbnail(bitmap, pxW, pxH);
+ } else {
+ Log_OC.d(TAG, "Status: " + status);
+ }
+ } else {
+ String gallery = "";
+ if (serverOCVersion.supportsNativeGallery()){
+ gallery = "gallery";
+ } else {
+ gallery = "galleryplus";
}
- // Add thumbnail to cache
- if (thumbnail != null) {
- addBitmapToCache(imageKey, thumbnail);
+ String uri = mClient.getBaseUri() +
+ "/index.php/apps/" + gallery + "/api/preview/" + Integer.parseInt(file.getRemoteId().substring(0,8)) +
+ "/" + pxW + "/" + pxH;
+ Log_OC.d("Thumbnail", "FileName: " + file.getFileName() + " Download URI: " + uri);
+ GetMethod get = new GetMethod(uri);
+ int status = mClient.executeMethod(get);
+ if (status == HttpStatus.SC_OK) {
+ InputStream inputStream = get.getResponseBodyAsStream();
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
+ // Download via gallery app
+ thumbnail = bitmap;
}
}
+
+ // Handle PNG
+ if (thumbnail != null && file.getMimetype().equalsIgnoreCase("image/png")) {
+ thumbnail = handlePNG(thumbnail, pxW);
+ }
+
+ // Add thumbnail to cache
+ if (thumbnail != null) {
+ addBitmapToCache(imageKey, thumbnail);
+ }
} catch (Exception e) {
e.printStackTrace();
}
return resultBitmap;
}
- private Bitmap doFileInBackground() {
+ private Bitmap doFileInBackground(Boolean mIsThumbnail) {
+ Bitmap thumbnail = null;
File file = (File)mFile;
final String imageKey = String.valueOf(file.hashCode());
// Check disk cache in background thread
- Bitmap thumbnail = getBitmapFromDiskCache(imageKey);
+ thumbnail = getBitmapFromDiskCache(imageKey);
// Not found in disk cache
if (thumbnail == null) {
-
- int px = getThumbnailDimension();
+ int pxW = 0;
+ int pxH = 0;
+ if (mIsThumbnail) {
+ pxW = pxH = getThumbnailDimension();
+ } else {
+ Point p = getScreenDimension();
+ pxW = p.x;
+ pxH = p.y;
+ }
Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(
- file.getAbsolutePath(), px, px);
+ file.getAbsolutePath(), pxW, pxH);
if (bitmap != null) {
- thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), px);
+ thumbnail = addThumbnailToCache(imageKey, bitmap, file.getPath(), pxW, pxH);
}
}
return thumbnail;
} else {
toShow.add(R.id.action_unfavorite_file);
}
-
}
}
import android.content.Intent;
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 android.widget.Toast;
+import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.lib.common.network.WebdavUtils;
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.dialog.ShareLinkToDialog;
import org.apache.http.protocol.HTTP;
import java.util.List;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
/**
*
*/
}
}
+ public void sendCachedImage(OCFile file) {
+ if (file != null) {
+ Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
+ // set MimeType
+ sendIntent.setType(file.getMimetype());
+// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.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 syncFile(OCFile file) {
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.utils.FileStorageUtils;
-
import android.accounts.Account;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;
+import android.os.BatteryManager;
import android.preference.PreferenceManager;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Video;
@Override
public void onReceive(Context context, Intent intent) {
Log_OC.d(TAG, "Received: " + intent.getAction());
- if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
+ if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION) || intent.getAction().equals(Intent.ACTION_POWER_CONNECTED)) {
handleConnectivityAction(context, intent);
}else if (intent.getAction().equals(NEW_PHOTO_ACTION_UNOFFICIAL)) {
handleNewPictureAction(context, intent);
file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE));
c.close();
-
Log_OC.d(TAG, file_path + "");
// save always temporally the picture to upload
db.putFileForLater(file_path, account.name, null);
db.close();
- if (!isOnline(context) || (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
+ if (!isOnline(context)
+ || (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))
+ || (instantUploadWhenChargingOnly(context) && !isCharging(context))
+ ) {
return;
}
mime_type = c.getString(c.getColumnIndex(Video.Media.MIME_TYPE));
c.close();
Log_OC.d(TAG, file_path + "");
+
+ // save always temporally the picture to upload
+ DbHandler db = new DbHandler(context);
+ db.putFileForLater(file_path, account.name, null);
+ db.close();
- if (!isOnline(context) || (instantVideoUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
+ if (!isOnline(context)
+ || (instantVideoUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))
+ || (instantVideoUploadWhenChargingOnly(context) && !isCharging(context))
+ ) {
return;
}
}
private void handleConnectivityAction(Context context, Intent intent) {
- if (!instantPictureUploadEnabled(context)) {
+ if (!instantPictureUploadEnabled(context) && !instantVideoUploadEnabled(context)) {
Log_OC.d(TAG, "Instant upload disabled, don't upload anything");
return;
}
if (!intent.hasExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY)
&& isOnline(context)
- && (!instantPictureUploadViaWiFiOnly(context) || (instantPictureUploadViaWiFiOnly(context) == isConnectedViaWiFi(context) == true))) {
+ && (!instantUploadWhenChargingOnly(context) || (instantUploadWhenChargingOnly(context) && isCharging(context)))
+ && (!instantVideoUploadWhenChargingOnly(context) || (instantVideoUploadWhenChargingOnly(context) && isCharging(context)))
+ && (!instantPictureUploadViaWiFiOnly(context) || (instantPictureUploadViaWiFiOnly(context) && isConnectedViaWiFi(context)))
+ && (!instantVideoUploadViaWiFiOnly(context) || (instantVideoUploadViaWiFiOnly(context) && isConnectedViaWiFi(context)))
+ ) {
DbHandler db = new DbHandler(context);
Cursor c = db.getAwaitingFiles();
if (c.moveToFirst()) {
c.close();
db.close();
}
-
}
public static boolean isOnline(Context context) {
&& cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI
&& cm.getActiveNetworkInfo().getState() == State.CONNECTED;
}
+
+ public static boolean isCharging(Context context){
+ IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
+ Intent batteryStatus = context.registerReceiver(null, ifilter);
+
+ int status = 0;
+ if (batteryStatus != null) {
+ status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
+ }
+ return status == BatteryManager.BATTERY_STATUS_CHARGING ||
+ status == BatteryManager.BATTERY_STATUS_FULL;
+ }
public static boolean instantPictureUploadEnabled(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_uploading", false);
public static boolean instantVideoUploadViaWiFiOnly(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_upload_on_wifi", false);
}
+ public static boolean instantUploadWhenChargingOnly(Context context) {
+ return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_upload_on_charging", false);
+ }
+ public static boolean instantVideoUploadWhenChargingOnly(Context context) {
+ return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_video_upload_on_charging", false);
+ }
}
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");
startTextPreview(file);
}
+ if (DisplayUtils.isGridView(getFile(), getStorageManager())){
+ switchToGridView();
+ } else {
+ switchToListView();
+ }
+
} else {
Log_OC.wtf(TAG, "initFragments() called with invalid NULLs!");
if (getAccount() == null) {
boolean drawerOpen = mDrawerLayout.isDrawerOpen(GravityCompat.START);
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);
}
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;
}
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);
}
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 {
+ menuItem.setTitle(getApplicationContext().getString(R.string.action_switch_grid_view));
+ menuItem.setIcon(ContextCompat.getDrawable(getApplicationContext(),
+ R.drawable.ic_view_module));
}
}
cleanSecondFragment();
// Sync Folder
startSyncFolderOperation(directory, false);
+
+ MenuItem menuItem = mOptionsMenu.findItem(R.id.action_switch_view);
+
+ changeGridIcon();
+ if (DisplayUtils.isGridView(directory, getStorageManager())){
+ switchToGridView();
+ } else {
+ switchToListView();
+ }
}
/**
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();
mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi);
mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath);
} else {
- mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi);
- mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath);
+// mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi);
+// mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath);
}
}
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi);
mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath);
} else {
- mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi);
- mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath);
+// mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi);
+// mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath);
}
}
SharedPreferences appPrefs =
PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
mUploadVideoPath = appPrefs.getString("instant_video_upload_path", getString(R.string.instant_upload_path));
- mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath);
+// mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath);
}
/**
}
final InputStream in = snapshot.getInputStream( 0 );
if ( in != null ) {
- final BufferedInputStream buffIn =
+ final BufferedInputStream buffIn =
new BufferedInputStream( in, IO_BUFFER_SIZE );
- bitmap = BitmapFactory.decodeStream( buffIn );
- }
+ bitmap = BitmapFactory.decodeStream( buffIn );
+ }
} catch ( IOException e ) {
e.printStackTrace();
} finally {
--- /dev/null
+/**
+ * ownCloud Android client application
+ *
+ * Copyright (C) 2015 Tobias Kaminsky
+ * Copyright (C) 2015 ownCloud Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * adapted from: http://stephendnicholas.com/archives/974
+ *
+ */
+
+package com.owncloud.android.ui.adapter;
+
+import android.accounts.Account;
+import android.content.ContentProvider;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.ParcelFileDescriptor;
+
+import com.owncloud.android.MainApp;
+import com.owncloud.android.authentication.AccountUtils;
+import com.owncloud.android.datamodel.FileDataStorageManager;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.datamodel.ThumbnailsCacheManager;
+import com.owncloud.android.lib.common.utils.Log_OC;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class DiskLruImageCacheFileProvider extends ContentProvider {
+ private static String TAG = FileDataStorageManager.class.getSimpleName();
+
+ public static final String AUTHORITY = "com.owncloud.imageCache.provider";
+
+ @Override
+ public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+ Account account = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
+ FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(account,
+ MainApp.getAppContext().getContentResolver());
+
+ OCFile ocFile = fileDataStorageManager.getFileByPath(uri.getPath());
+
+ Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
+ String.valueOf("r" + ocFile.getRemoteId()));
+
+ // create a file to write bitmap data
+ File f = new File(MainApp.getAppContext().getCacheDir(), ocFile.getFileName());
+ try {
+ f.createNewFile();
+
+ //Convert bitmap to byte array
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bos);
+ byte[] bitmapdata = bos.toByteArray();
+
+ //write the bytes in file
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(f);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ fos.write(bitmapdata);
+ fos.flush();
+ fos.close();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return ParcelFileDescriptor.open(f, ParcelFileDescriptor.MODE_READ_ONLY);
+ }
+
+
+ @Override
+ public boolean onCreate() {
+ return true;
+ }
+
+ @Override
+ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ return null;
+ }
+
+ @Override
+ public String getType(Uri uri) {
+ return null;
+ }
+
+ @Override
+ public Uri insert(Uri uri, ContentValues values) {
+ return null;
+ }
+
+ @Override
+ public int delete(Uri uri, String selection, String[] selectionArgs) {
+ return 0;
+ }
+
+ @Override
+ public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ return 0;
+ }
+}
task\r
);\r
fileIcon.setImageDrawable(asyncDrawable);\r
- task.execute(file);\r
+ task.execute(file, true);\r
}\r
}\r
\r
public void setGridMode(boolean gridMode) {\r
mGridMode = gridMode;\r
}\r
+\r
+ public boolean isGridMode() {\r
+ return mGridMode;\r
+ }\r
}\r
return fabMain;
}
- protected void switchToGridView() {
+ public void switchToGridView() {
if ((mCurrentListView == mListView)) {
mListView.setAdapter(null);
mCurrentListView = mGridView;
}
}
-
- protected void switchToListView() {
+
+ public void switchToListView() {
if (mCurrentListView == mGridView) {
mGridView.setAdapter(null);
mRefreshGridLayout.setVisibility(View.GONE);
mCurrentListView = mListView;
}
}
+
+ public boolean isGridView(){
+ if (mAdapter instanceof FileListListAdapter) {
+ return ((FileListListAdapter) mAdapter).isGridMode();
+ }
+ return false;
+ }
@Override
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.FileStorageUtils;
import com.owncloud.android.ui.preview.PreviewTextFragment;
} else {
mContainerActivity.getFileOperationsHelper().openFile(file);
}
-
- } else {
- // automatic download, preview on finish
- ((FileDisplayActivity) mContainerActivity).startDownloadForPreview(file);
+
}
-
}
} else {
item.setEnabled(false);
}
}
+
+// String.format(mContext.getString(R.string.subject_token),
+// getClient().getCredentials().getUsername(), file.getFileName()));
}
}
OwnCloudVersion version = AccountUtils.getServerVersion(
((FileActivity)mContainerActivity).getAccount());
if (version != null && version.supportsRemoteThumbnails() &&
- imagesCount > 0 && imagesCount == filesCount) {
+ DisplayUtils.isGridView(mFile, mContainerActivity.getStorageManager())) {
switchToGridView();
registerLongClickListener();
} else {
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Movie;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
-import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.datamodel.OCFile;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
public class ImageViewCustom extends ImageView {
private int mBitmapHeight;
private int mBitmapWidth;
-
+ private Movie mGifMovie;
+ private int mMovieWidth, mMovieHeight;
+ private long mMovieDuration;
+ private long mMovieRunDuration;
+ private long mLastTick;
+
public ImageViewCustom(Context context) {
super(context);
}
@SuppressLint("NewApi")
@Override
protected void onDraw(Canvas canvas) {
-
if(IS_ICS_OR_HIGHER && checkIfMaximumBitmapExceed(canvas) || IS_VERSION_BUGGY_ON_RECYCLES ) {
// Software type is set with two targets:
// 1. prevent that bitmaps larger than maximum textures allowed are shown as black views in devices
// with LAYER_TYPE_HARDWARE enabled by default;
- // 2. grant that bitmaps are correctly dellocated from memory in versions suffering the bug fixed in
+ // 2. grant that bitmaps are correctly de-allocated from memory in versions suffering the bug fixed in
// https://android.googlesource.com/platform/frameworks/base/+/034de6b1ec561797a2422314e6ef03e3cd3e08e0;
//
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
- super.onDraw(canvas);
+ if(mGifMovie == null){
+ super.onDraw(canvas);
+ } else {
+ long nowTick = android.os.SystemClock.uptimeMillis();
+ if (mLastTick == 0) {
+ mMovieRunDuration = 0;
+ } else {
+ mMovieRunDuration += nowTick - mLastTick;
+ if(mMovieRunDuration > mMovieDuration){
+ mMovieRunDuration = 0;
+ }
+ }
+
+ mGifMovie.setTime((int) mMovieRunDuration);
+
+ float scale;
+ if(mGifMovie.height() > getHeight() || mGifMovie.width() > getWidth()) {
+ scale = (1f / Math.min(canvas.getHeight() / mGifMovie.height(),
+ canvas.getWidth() / mGifMovie.width())) + 0.25f;
+ } else {
+ scale = Math.min(canvas.getHeight() / mGifMovie.height(),
+ canvas.getWidth() / mGifMovie.width());
+ }
+
+ canvas.scale(scale, scale);
+ canvas.translate(((float) getWidth() / scale - (float) mGifMovie.width()) / 2f,
+ ((float) getHeight() / scale - (float) mGifMovie.height()) /2f);
+
+ mGifMovie.draw(canvas, 0, 0);
+
+ mLastTick = nowTick;
+ invalidate();
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ if (mGifMovie == null){
+ setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
+ } else {
+ setMeasuredDimension(mMovieWidth, mMovieHeight);
+ }
}
/**
*/
@SuppressLint("NewApi")
private boolean checkIfMaximumBitmapExceed(Canvas canvas) {
- Log_OC.v(TAG, "Canvas maximum: " + canvas.getMaximumBitmapWidth() + " - " + canvas.getMaximumBitmapHeight());
- if (mBitmapWidth > canvas.getMaximumBitmapWidth()
- || mBitmapHeight > canvas.getMaximumBitmapHeight()) {
- return true;
- }
-
- return false;
+ return mBitmapWidth > canvas.getMaximumBitmapWidth()
+ || mBitmapHeight > canvas.getMaximumBitmapHeight();
+
}
@Override
* Keeps the size of the bitmap cached in member variables for faster access in {@link #onDraw(Canvas)} ,
* but without keeping another reference to the {@link Bitmap}
*/
- public void setImageBitmap (Bitmap bm) {
+ public void setImageBitmap(Bitmap bm) {
mBitmapWidth = bm.getWidth();
mBitmapHeight = bm.getHeight();
super.setImageBitmap(bm);
}
+ public void setGifImage(OCFile file){
+ try {
+ InputStream gifInputStream = new FileInputStream(file.getStoragePath());
+ setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ setFocusable(true);
+
+ mGifMovie = Movie.decodeStream(gifInputStream);
+ mMovieWidth = mGifMovie.width();
+ mMovieHeight = mGifMovie.height();
+ mMovieDuration = mGifMovie.duration();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
}
OCFile currentFile = mPreviewImagePagerAdapter.getFileAt(position);
getSupportActionBar().setTitle(currentFile.getFileName());
mDrawerToggle.setDrawerIndicatorEnabled(false);
- if (!currentFile.isDown()) {
- if (!mPreviewImagePagerAdapter.pendingErrorAt(position)) {
- requestForDownload(currentFile);
- }
- }
-
+
// Call to reset image zoom to initial state
((PreviewImagePagerAdapter) mViewPager.getAdapter()).resetZoom();
}
import android.widget.ProgressBar;
import android.widget.TextView;
+import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
private TextView mMessageView;
private ProgressBar mProgressWheel;
+ private Boolean mShowResizedImage = false;
+
public Bitmap mBitmap = null;
private static final String TAG = PreviewImageFragment.class.getSimpleName();
* {@link FragmentStatePagerAdapter}
* ; TODO better solution
*/
- public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState){
+ public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState,
+ boolean showResizedImage){
PreviewImageFragment frag = new PreviewImageFragment();
+ frag.mShowResizedImage = showResizedImage;
Bundle args = new Bundle();
args.putParcelable(ARG_FILE, imageFile);
args.putBoolean(ARG_IGNORE_FIRST, ignoreFirstSavedState);
if (getFile() == null) {
throw new IllegalStateException("Instanced with a NULL OCFile");
}
- if (!getFile().isDown()) {
- throw new IllegalStateException("There is no local file to preview");
- }
}
public void onStart() {
super.onStart();
if (getFile() != null) {
- mLoadBitmapTask = new LoadBitmapTask(mImageView, mMessageView, mProgressWheel);
- //mLoadBitmapTask.execute(new String[]{getFile().getStoragePath()});
-// mLoadBitmapTask.execute(getFile().getStoragePath());
- mLoadBitmapTask.execute(getFile());
+ mImageView.setTag(getFile().getFileId());
+
+ if (mShowResizedImage){
+ Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(
+ String.valueOf("r" + getFile().getRemoteId())
+ );
+
+ if (thumbnail != null && !getFile().needsUpdateThumbnail()){
+ mProgressWheel.setVisibility(View.GONE);
+ mImageView.setImageBitmap(thumbnail);
+ mImageView.setVisibility(View.VISIBLE);
+ mBitmap = thumbnail;
+ } else {
+ // generate new Thumbnail
+ if (ThumbnailsCacheManager.cancelPotentialWork(getFile(), mImageView)) {
+ final ThumbnailsCacheManager.ThumbnailGenerationTask task =
+ new ThumbnailsCacheManager.ThumbnailGenerationTask(
+ mImageView, mContainerActivity.getStorageManager(),
+ mContainerActivity.getStorageManager().getAccount(),
+ mProgressWheel);
+ if (thumbnail == null) {
+ thumbnail = ThumbnailsCacheManager.mDefaultImg;
+ }
+ final ThumbnailsCacheManager.AsyncDrawable asyncDrawable =
+ new ThumbnailsCacheManager.AsyncDrawable(
+ MainApp.getAppContext().getResources(),
+ thumbnail,
+ task
+ );
+ mImageView.setImageDrawable(asyncDrawable);
+ task.execute(getFile(), false);
+ }
+ }
+ } else {
+ mLoadBitmapTask = new LoadBitmapTask(mImageView, mMessageView, mProgressWheel);
+ mLoadBitmapTask.execute(getFile());
+ }
}
}
return true;
}
case R.id.action_send_file: {
- mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
- return true;
+ if (getFile().isImage() && !getFile().isDown()){
+ mContainerActivity.getFileOperationsHelper().sendCachedImage(getFile());
+ return true;
+ } else {
+ mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
+ return true;
+ }
}
case R.id.action_sync_file: {
mContainerActivity.getFileOperationsHelper().syncFile(getFile());
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
}
import java.util.Vector;
import android.accounts.Account;
+import android.graphics.Bitmap;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.datamodel.ThumbnailsCacheManager;
+import com.owncloud.android.ui.adapter.FileListListAdapter;
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.utils.FileStorageUtils;
Fragment fragment = null;
if (file.isDown()) {
fragment = PreviewImageFragment.newInstance(file,
- mObsoletePositions.contains(Integer.valueOf(i)));
+ mObsoletePositions.contains(Integer.valueOf(i)), false);
} else if (mDownloadErrors.contains(Integer.valueOf(i))) {
fragment = FileDownloadFragment.newInstance(file, mAccount, true);
((FileDownloadFragment)fragment).setError(true);
mDownloadErrors.remove(Integer.valueOf(i));
-
} else {
- fragment = FileDownloadFragment.newInstance(
- file, mAccount, mObsoletePositions.contains(Integer.valueOf(i))
- );
+ fragment = PreviewImageFragment.newInstance(file,
+ mObsoletePositions.contains(Integer.valueOf(i)), true);
}
mObsoletePositions.remove(Integer.valueOf(i));
return fragment;
\r
package com.owncloud.android.utils;\r
\r
+import java.io.File;\r
+import java.net.IDN;\r
+import java.text.DateFormat;\r
+import java.util.Arrays;\r
+import java.util.Calendar;\r
+import java.util.Date;\r
+import java.util.HashMap;\r
+import java.util.HashSet;\r
+import java.util.Set;\r
+import java.util.Vector;\r
+\r
import android.annotation.TargetApi;\r
import android.app.Activity;\r
import android.content.Context;\r
+import android.content.SharedPreferences;\r
import android.graphics.Point;\r
import android.graphics.PorterDuff;\r
import android.os.Build;\r
\r
import com.owncloud.android.MainApp;\r
import com.owncloud.android.R;\r
+import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.datamodel.OCFile;\r
\r
import java.math.BigDecimal;\r
}\r
\r
/**\r
+ * Determines if user set folder to grid or list view. If folder is not set itself,\r
+ * it finds a parent that is set (at least root is set).\r
+ * @param file\r
+ * @param storageManager\r
+ * @return\r
+ */\r
+ public static boolean isGridView(OCFile file, FileDataStorageManager storageManager){\r
+ if (file != null) {\r
+ OCFile fileToTest = file;\r
+ OCFile parentDir = null;\r
+ String parentPath = null;\r
+\r
+ SharedPreferences setting = MainApp.getAppContext().getSharedPreferences(\r
+ "viewMode", Context.MODE_PRIVATE);\r
+\r
+ if (setting.contains(fileToTest.getRemoteId())) {\r
+ return setting.getBoolean(fileToTest.getRemoteId(), false);\r
+ } else {\r
+ do {\r
+ if (fileToTest.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {\r
+ parentPath = new File(fileToTest.getRemotePath()).getParent();\r
+ parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath :\r
+ parentPath + OCFile.PATH_SEPARATOR;\r
+ parentDir = storageManager.getFileByPath(parentPath);\r
+ } else {\r
+ parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH);\r
+ }\r
+\r
+ while (parentDir == null) {\r
+ parentPath = new File(parentPath).getParent();\r
+ parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath :\r
+ parentPath + OCFile.PATH_SEPARATOR;\r
+ parentDir = storageManager.getFileByPath(parentPath);\r
+ }\r
+ fileToTest = parentDir;\r
+ } while (endWhile(parentDir, setting));\r
+ return setting.getBoolean(fileToTest.getRemoteId(), false);\r
+ }\r
+ } else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ private static boolean endWhile(OCFile parentDir, SharedPreferences setting) {\r
+ if (parentDir.getRemotePath().compareToIgnoreCase(OCFile.ROOT_PATH) == 0) {\r
+ return false;\r
+ } else {\r
+ return !setting.contains(parentDir.getRemoteId());\r
+ }\r
+ }\r
+\r
+ public static void setViewMode(OCFile file, boolean setGrid){\r
+ SharedPreferences setting = MainApp.getAppContext().getSharedPreferences(\r
+ "viewMode", Context.MODE_PRIVATE);\r
+\r
+ SharedPreferences.Editor editor = setting.edit();\r
+ editor.putBoolean(file.getRemoteId(), setGrid);\r
+ editor.commit();\r
+ }\r
+\r
+ /**\r
* sets the coloring of the given progress bar to color_accent.\r
*\r
* @param progressBar the progress bar to be colored\r