You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="match_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
+ android:layout_weight="1" >
- <com.owncloud.android.ui.ExtendedListView
- android:id="@+id/list_root"
+ <android.support.v4.widget.SwipeRefreshLayout
+ android:id="@+id/swipe_refresh_files"
android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_height="match_parent" >
-
++ android:layout_height="match_parent"
+ android:layout_weight="1"
- android:footerDividersEnabled="false"
- />
-
- <TextView
- android:id="@+id/empty_list_view"
++ android:footerDividersEnabled="false" >
++
+ <com.owncloud.android.ui.ExtendedListView
+ android:id="@+id/list_root"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
-
++
+ </android.support.v4.widget.SwipeRefreshLayout>
-
- <android.support.v4.widget.SwipeRefreshLayout
++
++ <android.support.v4.widget.SwipeRefreshLayout
+ android:id="@+id/swipe_refresh_files_emptyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:gravity="center_vertical|center_horizontal"
- android:text="@string/file_list_empty"
- android:visibility="gone"
- />
+ android:visibility="gone" >
- </LinearLayout>
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <TextView
+ android:id="@+id/empty_list_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_vertical|center_horizontal"
+ android:text="@string/empty"
+ android:layout_gravity="center"
+ android:visibility="visible" />
+
+ </ScrollView>
+ </android.support.v4.widget.SwipeRefreshLayout>
+ </FrameLayout>
<string name="actionbar_upload_from_apps">Content from other apps</string>
<string name="actionbar_upload_files">Files</string>
<string name="actionbar_open_with">Open with</string>
- <string name="actionbar_mkdir">Create directory</string>
+ <string name="actionbar_mkdir">New folder</string>
<string name="actionbar_settings">Settings</string>
<string name="actionbar_see_details">Details</string>
-
+ <string name="actionbar_send_file">Send</string>
+ <string name="actionbar_sort">Sort</string>
+ <string name="actionbar_sort_title">Sort by</string>
+ <string-array name="actionbar_sortby">
+ <item>A-Z</item>
+ <item>Newest - Oldest</item>
+ <!-- TODO re-enable when server-side folder size calculation is available
+ <item>Biggest - Smallest</item> -->
+ </string-array>
<string name="prefs_category_general">General</string>
<string name="prefs_category_more">More</string>
<string name="prefs_accounts">Accounts</string>
<string name="prefs_manage_accounts">Manage Accounts</string>
<string name="prefs_pincode">App PIN</string>
<string name="prefs_pincode_summary">Protect your client</string>
- <string name="prefs_instant_upload">Enable instant uploads</string>
- <string name="prefs_instant_upload_summary">Instantly upload photos taken by camera</string>
+ <string name="prefs_instant_upload">Instant picture uploads</string>
+ <string name="prefs_instant_upload_summary">Instantly upload pictures taken by camera</string>
+ <string name="prefs_instant_video_upload">Instant video uploads</string>
+ <string name="prefs_instant_video_upload_summary">Instantly upload videos recorded by camera</string>
<string name="prefs_log_title">Enable Logging</string>
<string name="prefs_log_summary">This is used to log problems</string>
<string name="prefs_log_title_history">Logging History</string>
<string name="prefs_imprint">Imprint</string>
<string name="recommend_subject">"Try %1$s on your smartphone!"</string>
- <string name="recommend_text">"I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s"</string>
+ <string name="recommend_text">"I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s"</string>
<string name="auth_check_server">Check Server</string>
- <string name="auth_host_url">Server address</string>
+ <string name="auth_host_url">Server address https://…</string>
<string name="auth_username">Username</string>
<string name="auth_password">Password</string>
<string name="auth_register">New to %1$s?</string>
<string name="sync_string_files">Files</string>
<string name="setup_btn_connect">Connect</string>
<string name="uploader_btn_upload_text">Upload</string>
- <string name="uploader_top_message">Choose upload directory:</string>
+ <string name="uploader_top_message">Choose upload folder:</string>
<string name="uploader_wrn_no_account_title">No account found</string>
<string name="uploader_wrn_no_account_text">There are no %1$s accounts on your device. Please setup an account first.</string>
<string name="uploader_wrn_no_account_setup_btn_text">Setup</string>
<string name="uploader_wrn_no_content_text">No content was received. Nothing to upload.</string>
<string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</string>
<string name="uploader_info_uploading">Uploading</string>
- <string name="file_list_empty">There are no files in this folder.\nNew files can be added with the \"Upload\" menu option.</string>
+ <string name="file_list_empty">Nothing in here. Upload something!</string>
+ <string name="file_list_loading">Loading...</string>
+ <string name="local_file_list_empty">There are no files in this folder.</string>
+ <string name="file_list_folder">folder</string>
+ <string name="file_list_folders">folders</string>
+ <string name="file_list_file">file</string>
+ <string name="file_list_files">files</string>
<string name="filedetails_select_file">Tap on a file to display additional information.</string>
<string name="filedetails_size">Size:</string>
<string name="filedetails_type">Type:</string>
<string name="filedetails_download">Download</string>
<string name="filedetails_sync_file">Refresh file</string>
<string name="filedetails_renamed_in_upload_msg">File was renamed to %1$s during upload</string>
+ <string name="action_share_file">Share link</string>
+ <string name="action_unshare_file">Unshare link</string>
<string name="common_yes">Yes</string>
<string name="common_no">No</string>
<string name="common_ok">OK</string>
<string name="delete_account">Delete account</string>
<string name="create_account">Create account</string>
<string name="upload_chooser_title">Upload from …</string>
- <string name="uploader_info_dirname">Directory name</string>
+ <string name="uploader_info_dirname">Folder name</string>
<string name="uploader_upload_in_progress_ticker">Uploading …</string>
<string name="uploader_upload_in_progress_content">%1$d%% Uploading %2$s</string>
<string name="uploader_upload_succeeded_ticker">Upload succeeded</string>
<string name="uploader_upload_succeeded_content_single">%1$s was successfully uploaded</string>
<string name="uploader_upload_failed_ticker">Upload failed</string>
<string name="uploader_upload_failed_content_single">Upload of %1$s could not be completed</string>
+ <string name="uploader_upload_failed_credentials_error">Upload failed, you need to relogin</string>
<string name="downloader_download_in_progress_ticker">Downloading …</string>
<string name="downloader_download_in_progress_content">%1$d%% Downloading %2$s</string>
<string name="downloader_download_succeeded_ticker">Download succeeded</string>
<string name="downloader_download_failed_ticker">Download failed</string>
<string name="downloader_download_failed_content">Download of %1$s could not be completed</string>
<string name="downloader_not_downloaded_yet">Not downloaded yet</string>
+ <string name="downloader_download_failed_credentials_error">Download failed, you need to relogin</string>
<string name="common_choose_account">Choose account</string>
<string name="sync_fail_ticker">Synchronization failed</string>
+ <string name="sync_fail_ticker_unauthorized">Synchronization failed, you need to relogin</string>
<string name="sync_fail_content">Synchronization of %1$s could not be completed</string>
<string name="sync_fail_content_unauthorized">Invalid password for %1$s</string>
<string name="sync_conflicts_in_favourites_ticker">Conflicts found</string>
<string name="sync_fail_in_favourites_ticker">Kept-in-sync files failed</string>
<string name="sync_fail_in_favourites_content">Contents of %1$d files could not be sync\'ed (%2$d conflicts)</string>
<string name="sync_foreign_files_forgotten_ticker">Some local files were forgotten</string>
- <string name="sync_foreign_files_forgotten_content">%1$d files out of the %2$s directory could not be copied into</string>
- <string name="sync_foreign_files_forgotten_explanation">As of version 1.3.16, files uploaded from this device are copied into the local %1$s folder to prevent data loss when a single file is synced with multiple accounts.\n\nDue to this change, all files uploaded in previous versions of this app were copied into the %2$s folder. However, an error prevented the completion of this operation during account synchronization. You may either leave the file(s) as is and remove the link to %3$s, or move the file(s) into the %1$s directory and retain the link to %4$s.\n\nListed below are the local file(s), and the the remote file(s) in %5$s they were linked to.</string>
+ <string name="sync_foreign_files_forgotten_content">%1$d files out of the %2$s folder could not be copied into</string>
+ <string name="sync_foreign_files_forgotten_explanation">As of version 1.3.16, files uploaded from this device are copied into the local %1$s folder to prevent data loss when a single file is synced with multiple accounts.\n\nDue to this change, all files uploaded in previous versions of this app were copied into the %2$s folder. However, an error prevented the completion of this operation during account synchronization. You may either leave the file(s) as is and remove the link to %3$s, or move the file(s) into the %1$s folder and retain the link to %4$s.\n\nListed below are the local file(s), and the remote file(s) in %5$s they were linked to.</string>
<string name="sync_current_folder_was_removed">Folder %1$s does not exist anymore</string>
<string name="foreign_files_move">"Move all"</string>
<string name="foreign_files_success">"All files were moved"</string>
<string name="foreign_files_fail">"Some files could not be moved"</string>
<string name="foreign_files_local_text">"Local: %1$s"</string>
<string name="foreign_files_remote_text">"Remote: %1$s"</string>
- <string name="upload_query_move_foreign_files">There is not space enough to copy the selected files into the %1$s folder. Would like to move them into instead? </string>
+ <string name="upload_query_move_foreign_files">There is not space enough to copy the selected files into the %1$s folder. Would you like to move them instead? </string>
<string name="pincode_enter_pin_code">Please, insert your App PIN</string>
+
<string name="pincode_configure_your_pin">Enter your App PIN</string>
<string name="pincode_configure_your_pin_explanation">The PIN will be requested every time the app is started</string>
<string name="pincode_reenter_your_pincode">Please, reenter your App PIN</string>
<string name="media_event_done">"%1$s playback finished"</string>
<string name="media_err_nothing_to_play">No media file found</string>
<string name="media_err_no_account">No account provided</string>
- <string name="media_err_not_in_owncloud">File not in a valid account</string>
- <string name="media_err_unsupported">Unsupported media codec</string>
- <string name="media_err_io">Media file could not be read</string>
- <string name="media_err_malformed">Media file not correctly encoded</string>
- <string name="media_err_timeout">Timed out while trying to play</string>
- <string name="media_err_invalid_progressive_playback">Media file cannot be streamed</string>
- <string name="media_err_unknown">Media file cannot be played with the stock media player</string>
- <string name="media_err_security_ex">Security error trying to play %1$s</string>
+ <string name="media_err_not_in_owncloud">File not in a valid account</string>
+ <string name="media_err_unsupported">Unsupported media codec</string>
+ <string name="media_err_io">Media file could not be read</string>
+ <string name="media_err_malformed">Media file not correctly encoded</string>
+ <string name="media_err_timeout">Timed out while trying to play</string>
+ <string name="media_err_invalid_progressive_playback">Media file cannot be streamed</string>
+ <string name="media_err_unknown">Media file cannot be played with the stock media player</string>
+ <string name="media_err_security_ex">Security error trying to play %1$s</string>
<string name="media_err_io_ex">Input error trying to play %1$s</string>
<string name="media_err_unexpected">Unexpected error trying to play %1$s</string>
<string name="media_rewind_description">Rewind button</string>
<string name="media_play_pause_description">Play or pause button</string>
<string name="media_forward_description">Fast forward button</string>
- <string name="auth_trying_to_login">Trying to login…</string>
- <string name="auth_no_net_conn_title">No network connection</string>
- <string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
- <string name="auth_connection_established">Connection established</string>
- <string name="auth_testing_connection">Testing connection…</string>
- <string name="auth_not_configured_title">Malformed server configuration</string>
- <string name="auth_account_not_new">An account for the same user and server already exists in the device</string>
- <string name="auth_account_not_the_same">The entered user does not match the user of this account</string>
- <string name="auth_unknown_error_title">Unknown error occurred!</string>
- <string name="auth_unknown_host_title">Couldn\'t find host</string>
- <string name="auth_incorrect_path_title">Server instance not found</string>
- <string name="auth_timeout_title">The server took too long to respond</string>
- <string name="auth_incorrect_address_title">Malformed URL</string>
- <string name="auth_ssl_general_error_title">SSL initialization failed</string>
- <string name="auth_ssl_unverified_server_title">Couldn\'t verify SSL server\'s identity</string>
- <string name="auth_bad_oc_version_title">Unrecognized server version</string>
- <string name="auth_wrong_connection_title">Couldn\'t establish connection</string>
- <string name="auth_secure_connection">Secure connection established</string>
- <string name="auth_unauthorized">Wrong username or password</string>
+ <string name="auth_getting_authorization">Getting authorization…</string>
+ <string name="auth_trying_to_login">Trying to login…</string>
+ <string name="auth_no_net_conn_title">No network connection</string>
+ <string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
+ <string name="auth_connection_established">Connection established</string>
+ <string name="auth_testing_connection">Testing connection…</string>
+ <string name="auth_not_configured_title">Malformed server configuration</string>
+ <string name="auth_account_not_new">An account for the same user and server already exists in the device</string>
+ <string name="auth_account_not_the_same">The entered user does not match the user of this account</string>
+ <string name="auth_unknown_error_title">Unknown error occurred!</string>
+ <string name="auth_unknown_host_title">Couldn\'t find host</string>
+ <string name="auth_incorrect_path_title">Server instance not found</string>
+ <string name="auth_timeout_title">The server took too long to respond</string>
+ <string name="auth_incorrect_address_title">Malformed URL</string>
+ <string name="auth_ssl_general_error_title">SSL initialization failed</string>
+ <string name="auth_ssl_unverified_server_title">Couldn\'t verify SSL server\'s identity</string>
+ <string name="auth_bad_oc_version_title">Unrecognized server version</string>
+ <string name="auth_wrong_connection_title">Couldn\'t establish connection</string>
+ <string name="auth_secure_connection">Secure connection established</string>
+ <string name="auth_unauthorized">Wrong username or password</string>
<string name="auth_oauth_error">Unsuccessful authorization</string>
<string name="auth_oauth_error_access_denied">Access denied by authorization server</string>
- <string name="auth_wtf_reenter_URL">Unexpected state; please, enter the server URL again</string>
- <string name="auth_expired_oauth_token_toast">Your authorization expired. Please, authorize again</string>
- <string name="auth_expired_basic_auth_toast">Please, enter the current password</string>
- <string name="auth_expired_saml_sso_token_toast">Your session expired. Please connect again</string>
+ <string name="auth_wtf_reenter_URL">Unexpected state; please, enter the server URL again</string>
+ <string name="auth_expired_oauth_token_toast">Your authorization expired. Please, authorize again</string>
+ <string name="auth_expired_basic_auth_toast">Please, enter the current password</string>
+ <string name="auth_expired_saml_sso_token_toast">Your session expired. Please connect again</string>
<string name="auth_connecting_auth_server">Connecting to authentication server…</string>
- <string name="auth_unsupported_auth_method">The server does not support this authentication method</string>
+ <string name="auth_unsupported_auth_method">The server does not support this authentication method</string>
<string name="auth_unsupported_multiaccount">%1$s does not support multiple accounts</string>
+ <string name="auth_fail_get_user_name">Your server is not returning a correct user id, please contact an administrator
+ </string>
+ <string name="auth_can_not_auth_against_server">Cannot authenticate against this server</string>
<string name="fd_keep_in_sync">Keep file up to date</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_folder_alert">"Do you really want to remove %1$s and its contents ?"</string>
+ <string name="confirmation_remove_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 contents only</string>
<string name="confirmation_remove_remote">Remove from server</string>
<string name="rename_server_fail_msg">"Rename could not be completed"</string>
<string name="sync_file_fail_msg">Remote file could not be checked</string>
<string name="sync_file_nothing_to_do_msg">File contents already synchronized</string>
- <string name="create_dir_fail_msg">Directory could not be created</string>
+ <string name="create_dir_fail_msg">Folder could not be created</string>
+ <string name="filename_forbidden_characters">Forbidden characters: / \\ < > : " | ? *</string>
+ <string name="filename_empty">File name cannot be empty</string>
<string name="wait_a_moment">Wait a moment</string>
<string name="filedisplay_unexpected_bad_get_content">"Unexpected problem ; please select the file from a different app"</string>
<string name="filedisplay_no_file_selected">No file was selected</string>
+ <string name="activity_chooser_title">Send link to …</string>
<string name="oauth_check_onoff">Login with oAuth2</string>
<string name="oauth_login_connection">Connecting to oAuth2 server…</string>
<string name="ssl_validator_label_validity_to">To:</string>
<string name="ssl_validator_label_signature">Signature:</string>
<string name="ssl_validator_label_signature_algorithm">Algorithm:</string>
+ <string name="ssl_validator_null_cert">The certificate could not be shown.</string>
+ <string name="ssl_validator_no_info_about_error">- No information about the error</string>
<string name="placeholder_sentence">This is a placeholder</string>
<string name="placeholder_filename">placeholder.txt</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_path">/InstantUpload</string>
<string name="conflict_title">Update conflict</string>
<string name="conflict_message">Remote file %s is not synchronized with local file. Continuing will replace content of file on server.</string>
<string name="conflict_dont_upload">Don\'t upload</string>
<string name="preview_image_description">Image preview</string>
- <string name="preview_image_error_unknown_format">This image can not be shown</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 directory</string>
- <string name="actionbar_failed_instant_upload">Failed InstantUpload"</string>
- <string name="failed_upload_headline_text">Failed instant uploads</string>
- <string name="failed_upload_headline_hint">Summary of all failed instant uploads</string>
- <string name="failed_upload_all_cb">select all</string>
- <string name="failed_upload_headline_retryall_btn">retry all selected</string>
- <string name="failed_upload_headline_delete_all_btn">delete all selected from uploadqueue</string>
- <string name="failed_upload_retry_text">retry to upload the image: </string>
- <string name="failed_upload_load_more_images">Load more Picrures</string>
- <string name="failed_upload_retry_do_nothing_text">do nothing you are not online for instant upload</string>
- <string name="failed_upload_failure_text">Failure Message: </string>
- <string name="failed_upload_quota_exceeded_text">Please check your server configuration,maybe your quota is exceeded.</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="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your
+ administrator.</string>
+ <string name="share_link_file_no_exist">Unable to share. Please check whether the file exists</string>
+ <string name="share_link_file_error">An error occurred while trying to share this file or folder</string>
+ <string name="unshare_link_file_no_exist">Unable to unshare. Please check whether the file exists</string>
+ <string name="unshare_link_file_error">An error occurred while trying to unshare this file or folder</string>
+
+ <string name="activity_chooser_send_file_title">Send</string>
+
+ <string name="copy_link">Copy link</string>
+ <string name="clipboard_text_copied">Copied to clipboard</string>
+
+ <string name="error_cant_bind_to_operations_service">Critical error: cannot perform operations</string>
+
+ <string name="network_error_socket_exception">An error occurred while connecting with the server.</string>
+ <string name="network_error_socket_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
+ <string name="network_error_connect_timeout_exception">An error occurred while waiting for the server, the operation couldn\'t have been done</string>
+ <string name="network_host_not_available">The operation couldn\'t be completed, server is unavailable</string>
+ <string name="empty"></string>
+
+ <string name="forbidden_permissions">You do not have permission %s</string>
+ <string name="forbidden_permissions_rename">to rename this file</string>
+ <string name="forbidden_permissions_delete">to delete this file</string>
+ <string name="share_link_forbidden_permissions">to share this file</string>
+ <string name="unshare_link_forbidden_permissions">to unshare this file</string>
+ <string name="forbidden_permissions_create">to create the file</string>
+ <string name="uploader_upload_forbidden_permissions">to upload in this folder</string>
+ <string name="downloader_download_file_not_found">The file is no longer available on the server</string>
+
+ <string name="prefs_category_accounts">Accounts</string>
+ <string name="prefs_add_account">Add account</string>
+ <string name="auth_redirect_non_secure_connection_title">Secure connection is redirected to an unsecured route.</string>
+
+ <string name="actionbar_logger">Logs</string>
+ <string name="log_send_history_button">Send History</string>
+ <string name="log_mail_subject">ownCloud Android app logs</string>
+ <string name="log_progress_dialog_text">Loading data...</string>
+
+ <string name="saml_authentication_required_text">Authentication required</string>
+ <string name="saml_authentication_wrong_pass">Wrong password</string>
+ <string name="actionbar_move">Move</string>
+ <string name="file_list_empty_moving">Nothing in here. You can add a folder!</string>
+ <string name="move_choose_button_text">Choose</string>
+
+ <string name="move_file_not_found">Unable to move. Please check whether the file exists</string>
+ <string name="move_file_invalid_into_descendent">It is not possible to move a folder into a descendant</string>
+ <string name="move_file_invalid_overwrite">The file exists already in the destination folder</string>
+ <string name="move_file_error">An error occurred while trying to move this file or folder</string>
+ <string name="forbidden_permissions_move">to move this file</string>
+
+ <string name="prefs_category_instant_uploading">Instant Uploads</string>
+ <string name="prefs_category_security">Security</string>
+
</resources>
package com.owncloud.android.ui.fragment;
-import java.util.ArrayList;
-
import android.os.Bundle;
+ import android.support.v4.widget.SwipeRefreshLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
+ import android.widget.TextView;
import com.actionbarsherlock.app.SherlockFragment;
+import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
-import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.ui.ExtendedListView;
-import com.owncloud.android.ui.activity.OnEnforceableRefreshListener;
/**
- * TODO extending SherlockListFragment instead of SherlockFragment
+ * TODO extending SherlockListFragment instead of SherlockFragment
*/
- public class ExtendedListFragment extends SherlockFragment implements OnItemClickListener {
+ public class ExtendedListFragment extends SherlockFragment
+ implements OnItemClickListener, OnEnforceableRefreshListener {
-
+
private static final String TAG = ExtendedListFragment.class.getSimpleName();
- private static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION";
+ private static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION";
+ private static final String KEY_INDEXES = "INDEXES";
+ private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS";
+ private static final String KEY_TOPS = "TOPS";
+ private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
+ private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
protected ExtendedListView mList;
-
+
+ private SwipeRefreshLayout mRefreshLayout;
+ private SwipeRefreshLayout mRefreshEmptyLayout;
+ private TextView mEmptyListMessage;
+
+ // Save the state of the scroll in browsing
+ private ArrayList<Integer> mIndexes;
+ private ArrayList<Integer> mFirstPositions;
+ private ArrayList<Integer> mTops;
+ private int mHeightCell = 0;
+
+ private OnEnforceableRefreshListener mOnRefreshListener = null;
+
+
public void setListAdapter(ListAdapter listAdapter) {
mList.setAdapter(listAdapter);
mList.invalidate();
}
+ public void setFooterView(View footer) {
+ mList.addFooterView(footer);
+ mList.invalidate();
+ }
+
public ListView getListView() {
return mList;
}
-
-
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log_OC.e(TAG, "onCreateView");
- // mList = new ExtendedListView(getActivity());
-
++
View v = inflater.inflate(R.layout.list_fragment, null);
- mList = (ExtendedListView)(v.findViewById(R.id.list_root));
+ mEmptyListMessage = (TextView) v.findViewById(R.id.empty_list_view);
+ mList = (ExtendedListView) (v.findViewById(R.id.list_root));
mList.setOnItemClickListener(this);
- // mList.setEmptyView(v.findViewById(R.id.empty_list_view)); // looks
- // like it's not a cool idea
+
mList.setDivider(getResources().getDrawable(R.drawable.uploader_list_separator));
mList.setDividerHeight(1);
int referencePosition = savedInstanceState.getInt(KEY_SAVED_LIST_POSITION);
setReferencePosition(referencePosition);
}
-
+
+ // Pull down refresh
+ mRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files);
+ mRefreshEmptyLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_files_emptyView);
+
+ onCreateSwipeToRefresh(mRefreshLayout);
+ onCreateSwipeToRefresh(mRefreshEmptyLayout);
+
+ mList.setEmptyView(mRefreshEmptyLayout);
+
return v;
}
-
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ if (savedInstanceState != null) {
+ mIndexes = savedInstanceState.getIntegerArrayList(KEY_INDEXES);
+ mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS);
+ mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
+ mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
+ setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE));
+
+ } else {
+ mIndexes = new ArrayList<Integer>();
+ mFirstPositions = new ArrayList<Integer>();
+ mTops = new ArrayList<Integer>();
+ mHeightCell = 0;
+ }
+ }
+
+
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
Log_OC.e(TAG, "onSaveInstanceState()");
savedInstanceState.putInt(KEY_SAVED_LIST_POSITION, getReferencePosition());
+ savedInstanceState.putIntegerArrayList(KEY_INDEXES, mIndexes);
+ savedInstanceState.putIntegerArrayList(KEY_FIRST_POSITIONS, mFirstPositions);
+ savedInstanceState.putIntegerArrayList(KEY_TOPS, mTops);
+ savedInstanceState.putInt(KEY_HEIGHT_CELL, mHeightCell);
+ savedInstanceState.putString(KEY_EMPTY_LIST_MESSAGE, getEmptyViewText());
}
-
/**
- * Calculates the position of the item that will be used as a reference to reposition the visible items in the list when
- * the device is turned to other position.
+ * Calculates the position of the item that will be used as a reference to
+ * reposition the visible items in the list when the device is turned to
+ * other position.
*
- * THe current policy is take as a reference the visible item in the center of the screen.
+ * THe current policy is take as a reference the visible item in the center
+ * of the screen.
*
- * @return The position in the list of the visible item in the center of the screen.
+ * @return The position in the list of the visible item in the center of the
+ * screen.
*/
protected int getReferencePosition() {
if (mList != null) {
}
}
-
/**
* Sets the visible part of the list from the reference position.
*
- * @param position Reference position previously returned by {@link LocalFileListFragment#getReferencePosition()}
+ * @param position Reference position previously returned by
+ * {@link LocalFileListFragment#getReferencePosition()}
*/
protected void setReferencePosition(int position) {
if (mList != null) {
}
}
+
+ /*
+ * Restore index and position
+ */
+ protected void restoreIndexAndTopPosition() {
+ if (mIndexes.size() > 0) {
+ // needs to be checked; not every browse-up had a browse-down before
+
+ int index = mIndexes.remove(mIndexes.size() - 1);
+
+ int firstPosition = mFirstPositions.remove(mFirstPositions.size() -1);
+
+ int top = mTops.remove(mTops.size() - 1);
+
+ mList.setSelectionFromTop(firstPosition, top);
+
+ // Move the scroll if the selection is not visible
+ int indexPosition = mHeightCell*index;
+ int height = mList.getHeight();
+
+ if (indexPosition > height) {
+ if (android.os.Build.VERSION.SDK_INT >= 11)
+ {
+ mList.smoothScrollToPosition(index);
+ }
+ else if (android.os.Build.VERSION.SDK_INT >= 8)
+ {
+ mList.setSelectionFromTop(index, 0);
+ }
+
+ }
+ }
+ }
+
+ /*
+ * Save index and top position
+ */
+ protected void saveIndexAndTopPosition(int index) {
+
+ mIndexes.add(index);
+
+ int firstPosition = mList.getFirstVisiblePosition();
+ mFirstPositions.add(firstPosition);
+
+ View view = mList.getChildAt(0);
+ int top = (view == null) ? 0 : view.getTop() ;
+
+ mTops.add(top);
+
+ // Save the height of a cell
+ mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight();
+ }
+
+
@Override
- public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
- // to be @overriden
+ // to be @overriden
}
-
+ @Override
+ public void onRefresh() {
+ // to be @overriden
+ mRefreshLayout.setRefreshing(false);
+ mRefreshEmptyLayout.setRefreshing(false);
+
+ if (mOnRefreshListener != null) {
+ mOnRefreshListener.onRefresh();
+ }
+ }
+ public void setOnRefreshListener(OnEnforceableRefreshListener listener) {
+ mOnRefreshListener = listener;
+ }
+
+
+ /**
+ * Enables swipe gesture
+ */
+ public void enableSwipe() {
+ mRefreshLayout.setEnabled(true);
+ }
+
+ /**
+ * Disables swipe gesture. It prevents manual gestures but keeps the option you show
+ * refreshing programmatically.
+ */
+ public void disableSwipe() {
+ mRefreshLayout.setEnabled(false);
+ }
+
+ /**
+ * It shows the SwipeRefreshLayout progress
+ */
+ public void showSwipeProgress() {
+ mRefreshLayout.setRefreshing(true);
+ }
+
+ /**
+ * It shows the SwipeRefreshLayout progress
+ */
+ public void hideSwipeProgress() {
+ mRefreshLayout.setRefreshing(false);
+ }
+
+ /**
+ * Set message for empty list view
+ */
+ public void setMessageForEmptyList(String message) {
+ if (mEmptyListMessage != null) {
+ mEmptyListMessage.setText(message);
+ }
+ }
+
+ /**
+ * Get the text of EmptyListMessage TextView
+ *
+ * @return String
+ */
+ public String getEmptyViewText() {
+ return (mEmptyListMessage != null) ? mEmptyListMessage.getText().toString() : "";
+ }
+
+ private void onCreateSwipeToRefresh(SwipeRefreshLayout refreshLayout) {
+ // Colors in animations: background
+ refreshLayout.setColorScheme(R.color.background_color, R.color.background_color, R.color.background_color,
+ R.color.background_color);
+
+ refreshLayout.setOnRefreshListener(this);
+ }
+
+ @Override
+ public void onRefresh(boolean ignoreETag) {
+ mRefreshLayout.setRefreshing(false);
+ mRefreshEmptyLayout.setRefreshing(false);
+
+ if (mOnRefreshListener != null) {
+ mOnRefreshListener.onRefresh(ignoreETag);
+ }
+ }
}
+++ /dev/null
--/* ownCloud Android client application
-- * Copyright (C) 2011 Bartek Przybylski
- * Copyright (C) 2012-2013 ownCloud Inc.
- * Copyright (C) 2012-2014 ownCloud Inc.
-- *
-- * This program is free software: you can redistribute it and/or modify
-- * it under the terms of the GNU General Public License version 2,
-- * as published by the Free Software Foundation.
-- *
-- * This program is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- * GNU General Public License for more details.
-- *
-- * You should have received a copy of the GNU General Public License
-- * along with this program. If not, see <http://www.gnu.org/licenses/>.
-- *
-- */
--package com.owncloud.android.ui.fragment;
--
--import java.io.File;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Vector;
--
- import android.accounts.Account;
--import android.app.Activity;
- import android.content.Context;
-import android.content.Intent;
--import android.os.Bundle;
- import android.os.Handler;
-import android.support.v4.widget.SwipeRefreshLayout;
--import android.view.ContextMenu;
- import android.view.LayoutInflater;
--import android.view.MenuInflater;
--import android.view.MenuItem;
--import android.view.View;
--import android.widget.AdapterView;
--import android.widget.AdapterView.AdapterContextMenuInfo;
- import android.widget.TextView;
--
- import com.owncloud.android.Log_OC;
--import com.owncloud.android.R;
- import com.owncloud.android.authentication.AccountUtils;
--import com.owncloud.android.datamodel.FileDataStorageManager;
--import com.owncloud.android.datamodel.OCFile;
- import com.owncloud.android.files.FileHandler;
- import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
- import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
- import com.owncloud.android.operations.OnRemoteOperationListener;
- import com.owncloud.android.operations.RemoteOperation;
- import com.owncloud.android.operations.RemoveFileOperation;
- import com.owncloud.android.operations.RenameFileOperation;
- import com.owncloud.android.operations.SynchronizeFileOperation;
-import com.owncloud.android.files.FileMenuFilter;
-import com.owncloud.android.lib.common.utils.Log_OC;
--import com.owncloud.android.ui.activity.FileDisplayActivity;
- import com.owncloud.android.ui.activity.TransferServiceGetter;
-import com.owncloud.android.ui.activity.MoveActivity;
-import com.owncloud.android.ui.activity.OnEnforceableRefreshListener;
--import com.owncloud.android.ui.adapter.FileListListAdapter;
- import com.owncloud.android.ui.dialog.EditNameDialog;
- import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener;
- import com.owncloud.android.ui.fragment.ConfirmationDialogFragment.ConfirmationDialogFragmentListener;
-import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
-import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
-import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
--import com.owncloud.android.ui.preview.PreviewImageFragment;
--import com.owncloud.android.ui.preview.PreviewMediaFragment;
--
--/**
-- * A Fragment that lists all files and folders in a given path.
-- *
- * @author Bartek Przybylski
- * TODO refactorize to get rid of direct dependency on FileDisplayActivity
-- *
- * @author Bartek Przybylski
- * @author masensio
- * @author David A. Velasco
-- */
- public class OCFileListFragment extends ExtendedListFragment implements EditNameDialogListener,
- ConfirmationDialogFragmentListener {
-
-public class OCFileListFragment extends ExtendedListFragment {
-
-- private static final String TAG = OCFileListFragment.class.getSimpleName();
-
- private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ? OCFileListFragment.class
- .getPackage().getName() : "com.owncloud.android.ui.fragment";
- private static final String EXTRA_FILE = MY_PACKAGE + ".extra.FILE";
--
- private OCFileListFragment.ContainerActivity mContainerActivity;
- private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ?
- OCFileListFragment.class.getPackage().getName() : "com.owncloud.android.ui.fragment";
-
- public final static String ARG_JUST_FOLDERS = MY_PACKAGE + ".JUST_FOLDERS";
- public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS = MY_PACKAGE + ".ALLOW_CONTEXTUAL";
-
- private static final String KEY_FILE = MY_PACKAGE + ".extra.FILE";
--
- private FileFragment.ContainerActivity mContainerActivity;
-
-- private OCFile mFile = null;
-- private FileListListAdapter mAdapter;
- private View mFooterView;
-
- private Handler mHandler;
-
-- private OCFile mTargetFile;
--
-
-- /**
-- * {@inheritDoc}
-- */
-- @Override
-- public void onAttach(Activity activity) {
-- super.onAttach(activity);
-- Log_OC.e(TAG, "onAttach");
-- try {
- mContainerActivity = (ContainerActivity) activity;
- mContainerActivity = (FileFragment.ContainerActivity) activity;
-
-- } catch (ClassCastException e) {
- throw new ClassCastException(activity.toString() + " must implement "
- + OCFileListFragment.ContainerActivity.class.getSimpleName());
- throw new ClassCastException(activity.toString() + " must implement " +
- FileFragment.ContainerActivity.class.getSimpleName());
- }
- try {
- setOnRefreshListener((OnEnforceableRefreshListener) activity);
-
- } catch (ClassCastException e) {
- throw new ClassCastException(activity.toString() + " must implement " +
- SwipeRefreshLayout.OnRefreshListener.class.getSimpleName());
-- }
- }
-
-
- @Override
- public void onDetach() {
- setOnRefreshListener(null);
- mContainerActivity = null;
- super.onDetach();
-- }
--
-- /**
-- * {@inheritDoc}
-- */
-- @Override
-- public void onActivityCreated(Bundle savedInstanceState) {
-- super.onActivityCreated(savedInstanceState);
-- Log_OC.e(TAG, "onActivityCreated() start");
-
- mFooterView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
- R.layout.list_footer, null, false);
- setFooterView(mFooterView);
-
- mAdapter = new FileListListAdapter(getActivity(), mContainerActivity);
-
-- if (savedInstanceState != null) {
- mFile = savedInstanceState.getParcelable(EXTRA_FILE);
- mFile = savedInstanceState.getParcelable(KEY_FILE);
-- }
-
- Bundle args = getArguments();
- boolean justFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false);
- mAdapter = new FileListListAdapter(
- justFolders,
- getSherlockActivity(),
- mContainerActivity
- );
-- setListAdapter(mAdapter);
-
-
-- registerForContextMenu(getListView());
-- getListView().setOnCreateContextMenuListener(this);
-
- mHandler = new Handler();
-
- }
-
- }
-
-- /**
-- * Saves the current listed folder.
-- */
-- @Override
- public void onSaveInstanceState(Bundle outState) {
- public void onSaveInstanceState (Bundle outState) {
-- super.onSaveInstanceState(outState);
- outState.putParcelable(EXTRA_FILE, mFile);
- outState.putParcelable(KEY_FILE, mFile);
-- }
-
-
-- /**
-- * 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.
- * 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.
-- *
- * return Count of folder levels browsed up.
- * return Count of folder levels browsed up.
-- */
-- public int onBrowseUp() {
-- OCFile parentDir = null;
-- int moveCount = 0;
-
- if (mFile != null) {
-
- if(mFile != null){
-- FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
-
-
-- String parentPath = null;
-- if (mFile.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {
-- parentPath = new File(mFile.getRemotePath()).getParent();
- parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath
- + OCFile.PATH_SEPARATOR;
- parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath :
- parentPath + OCFile.PATH_SEPARATOR;
-- parentDir = storageManager.getFileByPath(parentPath);
-- moveCount++;
-- } else {
- parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH); // never
- // returns
- // null;
- // keep
- // the
- // path
- // in
- // root
- // folder
- parentDir = storageManager.getFileByPath(OCFile.ROOT_PATH);
-- }
-- while (parentDir == null) {
-- parentPath = new File(parentPath).getParent();
- parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath
- + OCFile.PATH_SEPARATOR;
- parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath :
- parentPath + OCFile.PATH_SEPARATOR;
-- parentDir = storageManager.getFileByPath(parentPath);
-- moveCount++;
- } // exit is granted because storageManager.getFileByPath("/") never
- // returns null
- } // exit is granted because storageManager.getFileByPath("/") never returns null
-- mFile = parentDir;
- }
-
- if (mFile != null) {
-
-- listDirectory(mFile);
-
- mContainerActivity.startSyncFolderOperation(mFile);
- } // else - should never happen now
--
- onRefresh(false);
-
- // restore index and top position
- restoreIndexAndTopPosition();
-
- } // else - should never happen now
-
-- return moveCount;
-- }
-
-
-- @Override
-- public void onItemClick(AdapterView<?> l, View v, int position, long id) {
-- OCFile file = (OCFile) mAdapter.getItem(position);
-- if (file != null) {
- if (file.isFolder()) {
- if (file.isFolder()) {
-- // update state and view of this fragment
-- listDirectory(file);
- // then, notify parent activity to let it update its state and
- // view, and other fragments
- // then, notify parent activity to let it update its state and view
-- mContainerActivity.onBrowsedDownTo(file);
-
- } else { // / Click on a file
- // save index and top position
- saveIndexAndTopPosition(position);
-
- } else { /// Click on a file
-- if (PreviewImageFragment.canBePreviewed(file)) {
-- // preview image - it handles the download, if needed
- mContainerActivity.startImagePreview(file);
-
- ((FileDisplayActivity)mContainerActivity).startImagePreview(file);
-
-- } else if (file.isDown()) {
-- if (PreviewMediaFragment.canBePreviewed(file)) {
-- // media preview
- mContainerActivity.startMediaPreview(file, 0, true);
- ((FileDisplayActivity)mContainerActivity).startMediaPreview(file, 0, true);
-- } else {
- // open with
- mContainerActivity.openFile(file);
- mContainerActivity.getFileOperationsHelper().openFile(file);
-- }
-
-
-- } else {
-- // automatic download, preview on finish
- mContainerActivity.startDownloadForPreview(file);
- ((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) {
- public void onCreateContextMenu (
- ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
-- super.onCreateContextMenu(menu, v, menuInfo);
- MenuInflater inflater = getActivity().getMenuInflater();
- inflater.inflate(R.menu.file_actions_menu, menu);
- AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
- OCFile targetFile = (OCFile) mAdapter.getItem(info.position);
- List<Integer> toHide = new ArrayList<Integer>();
- List<Integer> toDisable = new ArrayList<Integer>();
-
- MenuItem item = null;
- if (targetFile.isFolder()) {
- // contextual menu for folders
- toHide.add(R.id.action_open_file_with);
- toHide.add(R.id.action_download_file);
- toHide.add(R.id.action_cancel_download);
- toHide.add(R.id.action_cancel_upload);
- toHide.add(R.id.action_sync_file);
- toHide.add(R.id.action_see_details);
- if (mContainerActivity.getFileDownloaderBinder().isDownloading(
- AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)
- || mContainerActivity.getFileUploaderBinder().isUploading(
- AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)) {
- toDisable.add(R.id.action_rename_file);
- toDisable.add(R.id.action_remove_file);
-
- }
-
- } else {
- // contextual menu for regular files
-
- // new design: 'download' and 'open with' won't be available anymore
- // in context menu
- toHide.add(R.id.action_download_file);
- toHide.add(R.id.action_open_file_with);
-
- if (targetFile.isDown()) {
- toHide.add(R.id.action_cancel_download);
- toHide.add(R.id.action_cancel_upload);
-
- } else {
- toHide.add(R.id.action_sync_file);
- }
- if (mContainerActivity.getFileDownloaderBinder().isDownloading(
- AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)) {
- toHide.add(R.id.action_cancel_upload);
- toDisable.add(R.id.action_rename_file);
- toDisable.add(R.id.action_remove_file);
-
- } else if (mContainerActivity.getFileUploaderBinder().isUploading(
- AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)) {
- toHide.add(R.id.action_cancel_download);
- toDisable.add(R.id.action_rename_file);
- toDisable.add(R.id.action_remove_file);
-
- } else {
- toHide.add(R.id.action_cancel_download);
- toHide.add(R.id.action_cancel_upload);
- Bundle args = getArguments();
- boolean allowContextualActions =
- (args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true);
- if (allowContextualActions) {
- MenuInflater inflater = getSherlockActivity().getMenuInflater();
- inflater.inflate(R.menu.file_actions_menu, menu);
- AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
- OCFile targetFile = (OCFile) mAdapter.getItem(info.position);
-
- if (mContainerActivity.getStorageManager() != null) {
- FileMenuFilter mf = new FileMenuFilter(
- targetFile,
- mContainerActivity.getStorageManager().getAccount(),
- mContainerActivity,
- getSherlockActivity()
- );
- mf.filter(menu);
-- }
- }
-
- for (int i : toHide) {
- item = menu.findItem(i);
-
- /// additional restrictions for this fragment
- // TODO allow in the future 'open with' for previewable files
- MenuItem item = menu.findItem(R.id.action_open_file_with);
-- if (item != null) {
-- item.setVisible(false);
-- item.setEnabled(false);
-- }
- }
-
- for (int i : toDisable) {
- item = menu.findItem(i);
- if (item != null) {
- item.setEnabled(false);
- /// TODO break this direct dependency on FileDisplayActivity... if possible
- FileFragment frag = ((FileDisplayActivity)getSherlockActivity()).getSecondFragment();
- if (frag != null && frag instanceof FileDetailFragment &&
- frag.getFile().getFileId() == targetFile.getFileId()) {
- item = menu.findItem(R.id.action_see_details);
- if (item != null) {
- item.setVisible(false);
- item.setEnabled(false);
- }
-- }
-- }
-- }
-
-
-
-- /**
-- * {@inhericDoc}
-- */
-- @Override
- public boolean onContextItemSelected(MenuItem item) {
- AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
- public boolean onContextItemSelected (MenuItem item) {
- AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
-- mTargetFile = (OCFile) mAdapter.getItem(info.position);
- switch (item.getItemId()) {
- case R.id.action_rename_file: {
- String fileName = mTargetFile.getFileName();
- int extensionStart = mTargetFile.isFolder() ? -1 : fileName.lastIndexOf(".");
- int selectionEnd = (extensionStart >= 0) ? extensionStart : fileName.length();
- EditNameDialog dialog = EditNameDialog.newInstance(getString(R.string.rename_dialog_title), fileName, 0,
- selectionEnd, this);
- dialog.show(getFragmentManager(), EditNameDialog.TAG);
- return true;
- }
- case R.id.action_remove_file: {
- int messageStringId = R.string.confirmation_remove_alert;
- int posBtnStringId = R.string.confirmation_remove_remote;
- int neuBtnStringId = -1;
- if (mTargetFile.isFolder()) {
- messageStringId = R.string.confirmation_remove_folder_alert;
- posBtnStringId = R.string.confirmation_remove_remote_and_local;
- neuBtnStringId = R.string.confirmation_remove_folder_local;
- } else if (mTargetFile.isDown()) {
- posBtnStringId = R.string.confirmation_remove_remote_and_local;
- neuBtnStringId = R.string.confirmation_remove_local;
- switch (item.getItemId()) {
- case R.id.action_share_file: {
- mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile);
- return true;
-- }
- ConfirmationDialogFragment confDialog = ConfirmationDialogFragment.newInstance(messageStringId,
- new String[] { mTargetFile.getFileName() }, posBtnStringId, neuBtnStringId, R.string.common_cancel);
- confDialog.setOnConfirmationListener(this);
- confDialog.show(getFragmentManager(), FileDetailFragment.FTAG_CONFIRMATION);
- return true;
- }
- case R.id.action_sync_file: {
- Account account = AccountUtils.getCurrentOwnCloudAccount(getSherlockActivity());
- RemoteOperation operation = new SynchronizeFileOperation(mTargetFile, null,
- mContainerActivity.getStorageManager(), account, true, getSherlockActivity());
- operation.execute(account, getSherlockActivity(), mContainerActivity, mHandler, getSherlockActivity());
- ((FileDisplayActivity) getSherlockActivity()).showLoadingDialog();
- return true;
- }
- case R.id.action_cancel_download: {
- FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
- Account account = AccountUtils.getCurrentOwnCloudAccount(getActivity());
- if (downloaderBinder != null && downloaderBinder.isDownloading(account, mTargetFile)) {
- downloaderBinder.cancel(account, mTargetFile);
- listDirectory();
- mContainerActivity.onTransferStateChanged(mTargetFile, false, false);
- case R.id.action_unshare_file: {
- mContainerActivity.getFileOperationsHelper().unshareFileWithLink(mTargetFile);
- return true;
-- }
- return true;
- }
- case R.id.action_cancel_upload: {
- FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
- Account account = AccountUtils.getCurrentOwnCloudAccount(getActivity());
- if (uploaderBinder != null && uploaderBinder.isUploading(account, mTargetFile)) {
- uploaderBinder.cancel(account, mTargetFile);
- listDirectory();
- mContainerActivity.onTransferStateChanged(mTargetFile, false, false);
- case R.id.action_rename_file: {
- RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(mTargetFile);
- dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
- return true;
-- }
- return true;
- }
- case R.id.action_see_details: {
- ((FileFragment.ContainerActivity) getActivity()).showDetails(mTargetFile);
- return true;
- }
- default:
- return super.onContextItemSelected(item);
- 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_download:
- case R.id.action_cancel_upload: {
- ((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);
-
- } else {
- mContainerActivity.getFileOperationsHelper().sendDownloadedFile(mTargetFile);
- }
- return true;
- }
- case R.id.action_move: {
- Intent action = new Intent(getActivity(), MoveActivity.class);
-
- // Pass mTargetFile that contains info of selected file/folder
- action.putExtra(MoveActivity.EXTRA_TARGET_FILE, mTargetFile);
- getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
- return true;
- }
- default:
- return super.onContextItemSelected(item);
-- }
-- }
-
--
-- /**
- * Use this to query the {@link OCFile} that is currently being displayed by
- * this fragment
- *
- * Use this to query the {@link OCFile} that is currently
- * being displayed by this fragment
-- * @return The currently viewed OCFile
-- */
- public OCFile getCurrentFile() {
- public OCFile getCurrentFile(){
-- return mFile;
-- }
-
-
-- /**
- * Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null
- * parameter
- * Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter
-- */
- public void listDirectory() {
- public void listDirectory(){
-- listDirectory(null);
-- }
-
-
-- /**
-- * Lists the given directory on the view. When the input parameter is null,
- * it will either refresh the last known directory. list the root if there
- * never was a directory.
- * it will either refresh the last known directory. list the root
- * if there never was a directory.
-- *
-- * @param directory File to be listed
-- */
-- public void listDirectory(OCFile directory) {
-- FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
-- if (storageManager != null) {
--
-- // Check input parameters for null
- if (directory == null) {
- if (mFile != null) {
- if(directory == null){
- if(mFile != null){
-- directory = mFile;
-- } else {
-- directory = storageManager.getFileByPath("/");
- if (directory == null)
- return; // no files, wait for sync
- if (directory == null) return; // no files, wait for sync
-- }
-- }
-
-
-
-- // If that's not a directory -> List its parent
- if (!directory.isFolder()) {
- if(!directory.isFolder()){
-- Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString());
-- directory = storageManager.getFileById(directory.getParentId());
-- }
--
-- mAdapter.swapDirectory(directory, storageManager);
-- if (mFile == null || !mFile.equals(directory)) {
-- mList.setSelectionFromTop(0, 0);
-- }
-- mFile = directory;
-
- // Update Footer
- TextView footerText = (TextView) mFooterView.findViewById(R.id.footerText);
- Log_OC.d("footer", String.valueOf(System.currentTimeMillis()));
- footerText.setText(generateFooterText(directory));
- Log_OC.d("footer", String.valueOf(System.currentTimeMillis()));
- }
- }
-
- private String generateFooterText(OCFile directory) {
- Integer files = 0;
- Integer folders = 0;
-
- FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
- Vector<OCFile> mFiles = storageManager.getFolderContent(mFile);
-
- for (OCFile ocFile : mFiles) {
- if (ocFile.isFolder()) {
- folders++;
- } else {
- files++;
- }
- }
-
- String output = "";
-
- if (folders == 1) {
- output = folders.toString() + " " + getResources().getString(R.string.file_list_folder) + ", ";
- } else if (folders > 1) {
- output = folders.toString() + " " + getResources().getString(R.string.file_list_folders) + ", ";
- }
- if (files == 1) {
- output = output + files.toString() + " " + getResources().getString(R.string.file_list_file);
- } else {
- output = output + files.toString() + " " + getResources().getString(R.string.file_list_files);
- }
- return output;
- }
-
- /**
- * Interface to implement by any Activity that includes some instance of
- * FileListFragment
- *
- * @author David A. Velasco
- */
- public interface ContainerActivity extends TransferServiceGetter, OnRemoteOperationListener, FileHandler {
-
- /**
- * Callback method invoked when a the user browsed into a different
- * folder through the list of files
- *
- * @param file
- */
- public void onBrowsedDownTo(OCFile folder);
-
- public void startDownloadForPreview(OCFile file);
-
- public void startMediaPreview(OCFile file, int i, boolean b);
-
- public void startImagePreview(OCFile file);
-
- public void startSyncFolderOperation(OCFile folder);
-
- /**
- * Getter for the current DataStorageManager in the container activity
- */
- public FileDataStorageManager getStorageManager();
-
- /**
- * Callback method invoked when a the 'transfer state' of a file
- * changes.
- *
- * This happens when a download or upload is started or ended for a
- * file.
- *
- * This method is necessary by now to update the user interface of the
- * double-pane layout in tablets because methods
- * {@link FileDownloaderBinder#isDownloading(Account, OCFile)} and
- * {@link FileUploaderBinder#isUploading(Account, OCFile)} won't provide
- * the needed response before the method where this is called finishes.
- *
- * TODO Remove this when the transfer state of a file is kept in the
- * database (other thing TODO)
- *
- * @param file OCFile which state changed.
- * @param downloading Flag signaling if the file is now downloading.
- * @param uploading Flag signaling if the file is now uploading.
- */
- public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading);
-
- }
-
- @Override
- public void onDismiss(EditNameDialog dialog) {
- if (dialog.getResult()) {
- String newFilename = dialog.getNewFilename();
- Log_OC.d(TAG, "name edit dialog dismissed with new name " + newFilename);
- RemoteOperation operation = new RenameFileOperation(mTargetFile,
- AccountUtils.getCurrentOwnCloudAccount(getActivity()), newFilename,
- mContainerActivity.getStorageManager());
- operation.execute(AccountUtils.getCurrentOwnCloudAccount(getSherlockActivity()), getSherlockActivity(),
- mContainerActivity, mHandler, getSherlockActivity());
- ((FileDisplayActivity) getActivity()).showLoadingDialog();
-- }
-- }
-
- @Override
- public void onConfirmation(String callerTag) {
- if (callerTag.equals(FileDetailFragment.FTAG_CONFIRMATION)) {
- if (mContainerActivity.getStorageManager().getFileById(mTargetFile.getFileId()) != null) {
- RemoteOperation operation = new RemoveFileOperation(mTargetFile, true,
- mContainerActivity.getStorageManager());
- operation.execute(AccountUtils.getCurrentOwnCloudAccount(getSherlockActivity()), getSherlockActivity(),
- mContainerActivity, mHandler, getSherlockActivity());
-
- ((FileDisplayActivity) getActivity()).showLoadingDialog();
- }
- }
-
- public void sortByName(boolean descending) {
- mAdapter.setSortOrder(FileListListAdapter.SORT_NAME, descending);
-- }
--
- @Override
- public void onNeutral(String callerTag) {
- mContainerActivity.getStorageManager().removeFile(mTargetFile, false, true); // TODO
- // perform
- // in
- // background
- // task
- // /
- // new
- // thread
- listDirectory();
- mContainerActivity.onTransferStateChanged(mTargetFile, false, false);
- public void sortByDate(boolean descending) {
- mAdapter.setSortOrder(FileListListAdapter.SORT_DATE, descending);
-- }
--
- @Override
- public void onCancel(String callerTag) {
- Log_OC.d(TAG, "REMOVAL CANCELED");
- }
- public void sortBySize(boolean descending) {
- mAdapter.setSortOrder(FileListListAdapter.SORT_SIZE, descending);
- }
--
--}