Эх сурвалжийг харах

Merge remote-tracking branch 'upstream/develop' into triggerMediaScan

tobiasKaminsky 10 жил өмнө
parent
commit
e9ba0ebbfa

+ 0 - 11
res/menu/file_select_all.xml

@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-    <item
-        android:id="@+id/actionbar_select_all"
-        android:icon="@android:drawable/checkbox_off_background"
-        android:orderInCategory="1"
-        android:showAsAction="always"
-        android:title="actionbar_select_all"/>
-    
-
-</menu>

+ 31 - 31
res/values-pt-rPT/strings.xml

@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <resources>
-  <string name="about_android">%1$s Aplicação(ões) Android</string>
+  <string name="about_android">%1$s App(s) Android</string>
   <string name="about_version">versão %1$s</string>
   <string name="actionbar_sync">Atualizar conta</string>
   <string name="actionbar_upload">Enviar</string>
@@ -51,15 +51,15 @@
   <string name="setup_btn_connect">Ligar</string>
   <string name="uploader_btn_upload_text">Enviar</string>
   <string name="uploader_top_message">Escolha a pasta de envio:</string>
-  <string name="uploader_wrn_no_account_title">Nenhuma conta encontrada</string>
-  <string name="uploader_wrn_no_account_text">Não tem nenhuma conta  %1$s no seu dispositivo. Configure uma conta.</string>
+  <string name="uploader_wrn_no_account_title">A conta não foi encontrada</string>
+  <string name="uploader_wrn_no_account_text">Não tem nenhuma conta  %1$s no seu dispositivo. Por favor, configure primeiro uma conta.</string>
   <string name="uploader_wrn_no_account_setup_btn_text">Configurar</string>
   <string name="uploader_wrn_no_account_quit_btn_text">Sair</string>
-  <string name="uploader_wrn_no_content_title">Sem conteúdo para carregar</string>
+  <string name="uploader_wrn_no_content_title">Sem conteúdo para enviar</string>
   <string name="uploader_wrn_no_content_text">Não foi recebido nenhum conteúdo. Nada para enviar.</string>
   <string name="uploader_error_forbidden_content">O  %1$s não está autorizado a aceder aos ficheiro partilhados.</string>
   <string name="uploader_info_uploading">A enviar</string>
-  <string name="file_list_seconds_ago">Minutos atrás</string>
+  <string name="file_list_seconds_ago">segundos atrás</string>
   <string name="file_list_empty">Vazio. Envie alguma coisa!</string>
   <string name="file_list_loading">A carregar ...</string>
   <string name="local_file_list_empty">Não existem ficheiros nesta pasta.</string>
@@ -215,12 +215,12 @@
   <string name="ssl_validator_question">Quer confiar neste certificado de qualquer maneira?</string>
   <string name="ssl_validator_not_saved">O certificado não pôde ser guardado</string>
   <string name="ssl_validator_btn_details_see">Detalhes</string>
-  <string name="ssl_validator_btn_details_hide">Esconder</string>
+  <string name="ssl_validator_btn_details_hide">Ocultar</string>
   <string name="ssl_validator_label_subject">Emitido para:</string>
   <string name="ssl_validator_label_issuer">Emitido por:</string>
   <string name="ssl_validator_label_CN">Nome comum.</string>
   <string name="ssl_validator_label_O">Organização:</string>
-  <string name="ssl_validator_label_OU">Unidade organizaconal.</string>
+  <string name="ssl_validator_label_OU">Unidade organizacional.</string>
   <string name="ssl_validator_label_C">País:</string>
   <string name="ssl_validator_label_ST">Estado:</string>
   <string name="ssl_validator_label_L">Localização:</string>
@@ -229,33 +229,33 @@
   <string name="ssl_validator_label_validity_to">Para:</string>
   <string name="ssl_validator_label_signature">Assinatura:</string>
   <string name="ssl_validator_label_signature_algorithm">Algoritmo</string>
-  <string name="ssl_validator_null_cert">O certificado não pôde ser mostrado.</string>
-  <string name="ssl_validator_no_info_about_error">- Nenhuma informação acerca do erro</string>
+  <string name="ssl_validator_null_cert">Não foi possível mostrar o certificado.</string>
+  <string name="ssl_validator_no_info_about_error">- Nenhuma informação sobre o erro</string>
   <string name="placeholder_sentence">Isto é uma variável.</string>
   <string name="placeholder_filename">placeholder.txt</string>
   <string name="placeholder_filetype">Imagem PNG</string>
   <string name="placeholder_filesize">389 KB</string>
-  <string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
+  <string name="placeholder_timestamp">2012/05/18 12:23</string>
   <string name="placeholder_media_time">12:23:45</string>
-  <string name="instant_upload_on_wifi">Enviar fotografias apenas via WiFi</string>
-  <string name="instant_video_upload_on_wifi">Enviar videos apenas por WiFi</string>
-  <string name="instant_upload_path">/Upload-Instantâneo </string>
-  <string name="conflict_title">Conflito na actualização</string>
+  <string name="instant_upload_on_wifi">Só enviar as fotografias via wi-fi</string>
+  <string name="instant_video_upload_on_wifi">Só enviar os vídeos por wi-fi</string>
+  <string name="instant_upload_path">/Envio Instantâneo </string>
+  <string name="conflict_title">Conflito na atualização</string>
   <string name="conflict_message">O ficheiro remoto %s não está sincronizado com o ficheiro local. Se continuar ira substituir o ficheiro no servidor.</string>
-  <string name="conflict_keep_both">Manter os dois</string>
-  <string name="conflict_overwrite">Sobrepor</string>
+  <string name="conflict_keep_both">Manter ambos</string>
+  <string name="conflict_overwrite">Substituir</string>
   <string name="conflict_dont_upload">Não enviar.</string>
-  <string name="preview_image_description">Pré-Visualização da imagem</string>
+  <string name="preview_image_description">Pré-Visualizar imagem</string>
   <string name="preview_image_error_unknown_format">Esta imagem não pode ser mostrada</string>
   <string name="error__upload__local_file_not_copied">Não foi possível copiar %1$s para a pasta local %2$s</string>
-  <string name="prefs_instant_upload_path_title">Caminho de Upload</string>
+  <string name="prefs_instant_upload_path_title">Caminho de \'A Enviar\'</string>
   <string name="share_link_no_support_share_api">Lamentamos mas não é possível partilhar através do seu servidor. Por favor contacte o seu administrador.</string>
   <string name="share_link_file_no_exist">Não é possivel partilhar. Por favor verifique se o ficheiro existe</string>
   <string name="share_link_file_error">Ocorreu um erro enquanto tentava partilhar este ficheiro ou pasta</string>
   <string name="unshare_link_file_no_exist">Não é possível retirar a partilha. Verifique se o ficheiro existe</string>
   <string name="unshare_link_file_error">Ocorreu um erro enquanto retirava a partilha deste ficheiro ou pasta</string>
   <string name="activity_chooser_send_file_title">Enviar</string>
-  <string name="copy_link">Copiar ligação</string>
+  <string name="copy_link">Copiar hiperligação</string>
   <string name="clipboard_text_copied">Copiado para a área de transferência</string>
   <string name="error_cant_bind_to_operations_service">Erro crítico: não é possível executar as operações</string>
   <string name="network_error_socket_exception">Ocorreu um erro durante a ligação ao servidos.</string>
@@ -263,31 +263,31 @@
   <string name="network_error_connect_timeout_exception">Ocorreu um erro durante a ligação ao servidor, não foi possível realizar a operação.</string>
   <string name="network_host_not_available">A operação não foi concluída, o servidor está inacessível.</string>
   <string name="empty"></string>
-  <string name="forbidden_permissions">Você não tem permissão %s</string>
+  <string name="forbidden_permissions">Não tem permissão %s</string>
   <string name="forbidden_permissions_rename">para renomear este ficheiro</string>
-  <string name="forbidden_permissions_delete">para eliminar este ficheiro</string>
+  <string name="forbidden_permissions_delete">para apagar este ficheiro</string>
   <string name="share_link_forbidden_permissions">para partilhar este ficheiro</string>
-  <string name="unshare_link_forbidden_permissions">para eliminar a partilha deste ficheiro</string>
+  <string name="unshare_link_forbidden_permissions">para cancelar a partilha deste ficheiro</string>
   <string name="forbidden_permissions_create">para criar o ficheiro</string>
-  <string name="uploader_upload_forbidden_permissions">para carregar dentro desta pasta</string>
+  <string name="uploader_upload_forbidden_permissions">para enviar nesta pasta</string>
   <string name="downloader_download_file_not_found">O ficheiro não está mais disponível no servidor</string>
   <string name="prefs_category_accounts">Contas</string>
   <string name="prefs_add_account">Adicionar conta</string>
   <string name="auth_redirect_non_secure_connection_title">Ligação segura é redireccionada para um caminho inseguro.</string>
-  <string name="actionbar_logger">Logs</string>
+  <string name="actionbar_logger">Registos de Alterações</string>
   <string name="log_send_history_button">Enviar Histórico</string>
-  <string name="log_mail_subject">Logs da app ownCloud Android</string>
-  <string name="log_progress_dialog_text">A carregar os dados...</string>
+  <string name="log_mail_subject">Registos das alterações da app ownCloud Android</string>
+  <string name="log_progress_dialog_text">A carregar os dados ...</string>
   <string name="saml_authentication_required_text">Autenticação necessária</string>
-  <string name="saml_authentication_wrong_pass">Password errada</string>
+  <string name="saml_authentication_wrong_pass">Palavra-passe errada</string>
   <string name="actionbar_move">Mover</string>
   <string name="file_list_empty_moving">Não está aqui nada. Pode adicionar uma pasta!</string>
-  <string name="move_choose_button_text">Escolha</string>
-  <string name="move_file_not_found">Não é possível mover. Verifique se o ficheiro existe</string>
+  <string name="move_choose_button_text">Escolher</string>
+  <string name="move_file_not_found">Não é possível mover. Por favor, verifique se o ficheiro existe</string>
   <string name="move_file_invalid_into_descendent">Não é possível mover esta pasta deste modo</string>
   <string name="move_file_invalid_overwrite">O ficheiro já existe na pasta de destino</string>
-  <string name="move_file_error">Um erro ocorreu ao tentar mover este ficheiro ou pasta</string>
+  <string name="move_file_error">Ocorreu um ocorreu quando tentava mover este ficheiro ou pasta</string>
   <string name="forbidden_permissions_move">para mover este ficheiro</string>
-  <string name="prefs_category_instant_uploading">Uploads Instantâneos</string>
+  <string name="prefs_category_instant_uploading">Envios Instantâneos</string>
   <string name="prefs_category_security">Segurança</string>
 </resources>

+ 36 - 12
src/com/owncloud/android/files/services/FileUploader.java

@@ -73,6 +73,7 @@ import com.owncloud.android.operations.common.SyncOperation;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.utils.ErrorMessageAdapter;
+import com.owncloud.android.utils.UriUtils;
 
 
 
@@ -120,6 +121,9 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
     private NotificationCompat.Builder mNotificationBuilder;
     private int mLastPercent;
 
+    private static final String MIME_TYPE_PDF = "application/pdf";
+    private static final String FILE_EXTENSION_PDF = ".pdf";
+
     
     public static String getUploadFinishMessage() {
         return FileUploader.class.getName().toString() + UPLOAD_FINISH_MESSAGE;
@@ -646,18 +650,6 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
 
     private OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType,
             FileDataStorageManager storageManager) {
-        OCFile newFile = new OCFile(remotePath);
-        newFile.setStoragePath(localPath);
-        newFile.setLastSyncDateForProperties(0);
-        newFile.setLastSyncDateForData(0);
-
-        // size
-        if (localPath != null && localPath.length() > 0) {
-            File localFile = new File(localPath);
-            newFile.setFileLength(localFile.length());
-            newFile.setLastSyncDateForData(localFile.lastModified());
-        } // don't worry about not assigning size, the problems with localPath
-          // are checked when the UploadFileOperation instance is created
 
         // MIME type
         if (mimeType == null || mimeType.length() <= 0) {
@@ -671,6 +663,25 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         if (mimeType == null) {
             mimeType = "application/octet-stream";
         }
+
+        if (isPdfFileFromContentProviderWithoutExtension(localPath, mimeType)){
+            remotePath += FILE_EXTENSION_PDF;
+        }
+
+        OCFile newFile = new OCFile(remotePath);
+        newFile.setStoragePath(localPath);
+        newFile.setLastSyncDateForProperties(0);
+        newFile.setLastSyncDateForData(0);
+
+        // size
+        if (localPath != null && localPath.length() > 0) {
+            File localFile = new File(localPath);
+            newFile.setFileLength(localFile.length());
+            newFile.setLastSyncDateForData(localFile.lastModified());
+        } // don't worry about not assigning size, the problems with localPath
+          // are checked when the UploadFileOperation instance is created
+
+
         newFile.setMimetype(mimeType);
 
         return newFile;
@@ -856,4 +867,17 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         sendStickyBroadcast(end);
     }
 
+    /**
+     * Checks if content provider, using the content:// scheme, returns a file with mime-type 
+     * 'application/pdf' but file has not extension
+     * @param localPath
+     * @param mimeType
+     * @return true if is needed to add the pdf file extension to the file
+     */
+    private boolean isPdfFileFromContentProviderWithoutExtension(String localPath, String mimeType) {
+        return localPath.startsWith(UriUtils.URI_CONTENT_SCHEME) && 
+                mimeType.equals(MIME_TYPE_PDF) && 
+                !localPath.endsWith(FILE_EXTENSION_PDF);
+    }
+
 }

+ 73 - 47
src/com/owncloud/android/operations/UploadFileOperation.java

@@ -31,11 +31,16 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 
+import android.accounts.Account;
+import android.content.Context;
+import android.net.Uri;
+
+import com.owncloud.android.MainApp;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileUploader;
-import com.owncloud.android.lib.common.network.ProgressiveDataTransferer;
-import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
+import com.owncloud.android.lib.common.network.ProgressiveDataTransferer;
 import com.owncloud.android.lib.common.operations.OperationCancelledException;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@@ -45,9 +50,7 @@ import com.owncloud.android.lib.resources.files.ChunkedUploadRemoteFileOperation
 import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
 import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
 import com.owncloud.android.utils.FileStorageUtils;
-
-import android.accounts.Account;
-import android.content.Context;
+import com.owncloud.android.utils.UriUtils;
 
 
 /**
@@ -92,10 +95,9 @@ public class UploadFileOperation extends RemoteOperation {
             throw new IllegalArgumentException("Illegal NULL account in UploadFileOperation creation");
         if (file == null)
             throw new IllegalArgumentException("Illegal NULL file in UploadFileOperation creation");
-        if (file.getStoragePath() == null || file.getStoragePath().length() <= 0
-                || !(new File(file.getStoragePath()).exists())) {
+        if (file.getStoragePath() == null || file.getStoragePath().length() <= 0) {
             throw new IllegalArgumentException(
-                    "Illegal file in UploadFileOperation; storage path invalid or file not found: "
+                    "Illegal file in UploadFileOperation; storage path invalid: "
                             + file.getStoragePath());
         }
 
@@ -218,52 +220,77 @@ public class UploadFileOperation extends RemoteOperation {
                                    // copied
 
                 } else {
+
                     String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
                     mFile.setStoragePath(temporalPath);
                     temporalFile = new File(temporalPath);
-                    if (!mOriginalStoragePath.equals(temporalPath)) { // preventing
-                                                                      // weird
-                                                                      // but
-                                                                      // possible
-                                                                      // situation
-                        InputStream in = null;
-                        OutputStream out = null;
-                        try {
-                            File temporalParent = temporalFile.getParentFile();
-                            temporalParent.mkdirs();
-                            if (!temporalParent.isDirectory()) {
-                                throw new IOException("Unexpected error: parent directory could not be created");
-                            }
-                            temporalFile.createNewFile();
-                            if (!temporalFile.isFile()) {
-                                throw new IOException("Unexpected error: target file could not be created");
-                            }
-                            in = new FileInputStream(originalFile);
+
+                    File temporalParent = temporalFile.getParentFile();
+                    temporalParent.mkdirs();
+                    if (!temporalParent.isDirectory()) {
+                        throw new IOException("Unexpected error: parent directory could not be created");
+                    }
+                    temporalFile.createNewFile();
+                    if (!temporalFile.isFile()) {
+                        throw new IOException("Unexpected error: target file could not be created");
+                    }
+
+                    InputStream in = null;
+                    OutputStream out = null;
+
+                    try {
+
+                        // In case document provider schema as 'content://'
+                        if (mOriginalStoragePath.startsWith(UriUtils.URI_CONTENT_SCHEME)) {
+
+                            Uri uri = Uri.parse(mOriginalStoragePath);
+
+                            in = MainApp.getAppContext().getContentResolver().openInputStream(uri);
                             out = new FileOutputStream(temporalFile);
-                            byte[] buf = new byte[1024];
-                            int len;
-                            while ((len = in.read(buf)) > 0) {
-                                out.write(buf, 0, len);
-                            }
 
-                        } catch (Exception e) {
-                            result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_COPIED);
-                            return result;
-
-                        } finally {
-                            try {
-                                if (in != null)
-                                    in.close();
-                            } catch (Exception e) {
-                                Log_OC.d(TAG, "Weird exception while closing input stream for " + mOriginalStoragePath + " (ignoring)", e);
+                            int nRead;
+                            byte[] data = new byte[16384];
+
+                            while ((nRead = in.read(data, 0, data.length)) != -1) {
+                                out.write(data, 0, nRead);
                             }
-                            try {
-                                if (out != null)
-                                    out.close();
-                            } catch (Exception e) {
-                                Log_OC.d(TAG, "Weird exception while closing output stream for " + expectedPath + " (ignoring)", e);
+
+                            out.flush();
+
+                        } else {
+                            if (!mOriginalStoragePath.equals(temporalPath)) { // preventing
+                                                                          // weird
+                                                                          // but
+                                                                          // possible
+                                                                          // situation
+
+                                in = new FileInputStream(originalFile);
+                                out = new FileOutputStream(temporalFile);
+                                byte[] buf = new byte[1024];
+                                int len;
+                                while ((len = in.read(buf)) > 0) {
+                                    out.write(buf, 0, len);
+                                }
                             }
                         }
+
+                    } catch (Exception e) {
+                        result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_COPIED);
+                        return result;
+
+                    } finally {
+                        try {
+                            if (in != null)
+                                in.close();
+                        } catch (Exception e) {
+                            Log_OC.d(TAG, "Weird exception while closing input stream for " + mOriginalStoragePath + " (ignoring)", e);
+                        }
+                        try {
+                            if (out != null)
+                                out.close();
+                        } catch (Exception e) {
+                            Log_OC.d(TAG, "Weird exception while closing output stream for " + expectedPath + " (ignoring)", e);
+                        }
                     }
                 }
             }
@@ -417,5 +444,4 @@ public class UploadFileOperation extends RemoteOperation {
     public void cancel() {
         mUploadOperation.cancel();
     }
-
 }

+ 107 - 15
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -31,6 +31,7 @@ import android.app.ProgressDialog;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.ContentResolver;
+import android.content.ContentUris;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
@@ -41,13 +42,18 @@ import android.content.SyncRequest;
 import android.content.res.Resources.NotFoundException;
 import android.database.Cursor;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
+import android.os.Environment;
 import android.os.IBinder;
 import android.preference.PreferenceManager;
+import android.provider.DocumentsContract;
 import android.provider.MediaStore;
+import android.provider.OpenableColumns;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
@@ -101,6 +107,7 @@ import com.owncloud.android.ui.preview.PreviewMediaFragment;
 import com.owncloud.android.ui.preview.PreviewVideoActivity;
 import com.owncloud.android.utils.DisplayUtils;
 import com.owncloud.android.utils.ErrorMessageAdapter;
+import com.owncloud.android.utils.UriUtils;
 
 
 /**
@@ -151,7 +158,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
     private String DIALOG_UNTRUSTED_CERT;
     
     private OCFile mWaitingToSend;
-    
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         Log_OC.d(TAG, "onCreate() start");
@@ -563,6 +570,11 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
             builder.setExpedited(true);
             builder.setManual(true);
             builder.syncOnce();
+
+            // Fix bug in Android Lollipop when you click on refresh the whole account
+            Bundle extras = new Bundle();
+            builder.setExtras(extras);
+
             SyncRequest request = builder.build();
             ContentResolver.requestSync(request);
         }
@@ -654,8 +666,12 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
 
     private void requestSimpleUpload(Intent data, int resultCode) {
         String filepath = null;
+        String mimeType = null;
+
+        Uri selectedImageUri = data.getData();
+
         try {
-            Uri selectedImageUri = data.getData();
+            mimeType = getContentResolver().getType(selectedImageUri);
 
             String filemanagerstring = selectedImageUri.getPath();
             String selectedImagePath = getPath(selectedImageUri);
@@ -687,10 +703,34 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
         }
         if (!remotepath.endsWith(OCFile.PATH_SEPARATOR))
             remotepath += OCFile.PATH_SEPARATOR;
-        remotepath += new File(filepath).getName();
+
+        if (filepath.startsWith(UriUtils.URI_CONTENT_SCHEME)) {
+
+            Cursor cursor = MainApp.getAppContext().getContentResolver()
+                    .query(Uri.parse(filepath), null, null, null, null, null);
+
+            try {
+                if (cursor != null && cursor.moveToFirst()) {
+                    String displayName = cursor.getString(
+                            cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
+                    Log.i(TAG, "Display Name: " + displayName + "; mimeType: " + mimeType);
+
+                    displayName.replace(File.separatorChar, '_');
+                    displayName.replace(File.pathSeparatorChar, '_');
+                    remotepath += displayName + DisplayUtils.getComposedFileExtension(filepath);
+
+                }
+            } finally {
+                cursor.close();
+            }
+
+        } else {
+            remotepath += new File(filepath).getName();
+        }
 
         i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);
         i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);
+        i.putExtra(FileUploader.KEY_MIME_TYPE, mimeType);
         i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
         if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)
             i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
@@ -866,22 +906,74 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
         return dialog;
     }
 
-
     /**
-     * Translates a content URI of an image to a physical path
-     * on the disk
+     * Translates a content URI of an content to a physical path on the disk
+     * 
      * @param uri The URI to resolve
-     * @return The path to the image or null if it could not be found
+     * @return The path to the content or null if it could not be found
      */
     public String getPath(Uri uri) {
-        String[] projection = { MediaStore.Images.Media.DATA };
-        Cursor cursor = managedQuery(uri, projection, null, null, null);
-        if (cursor != null) {
-            int column_index = cursor
-                    .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
-            cursor.moveToFirst();
-            return cursor.getString(column_index);
-        } 
+        final boolean isKitKatOrLater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
+
+        // DocumentProvider
+        if (isKitKatOrLater && DocumentsContract.isDocumentUri(getApplicationContext(), uri)) {
+            // ExternalStorageProvider
+            if (UriUtils.isExternalStorageDocument(uri)) {
+                final String docId = DocumentsContract.getDocumentId(uri);
+                final String[] split = docId.split(":");
+                final String type = split[0];
+
+                if ("primary".equalsIgnoreCase(type)) {
+                    return Environment.getExternalStorageDirectory() + "/" + split[1];
+                }
+            }
+            // DownloadsProvider
+            else if (UriUtils.isDownloadsDocument(uri)) {
+
+                final String id = DocumentsContract.getDocumentId(uri);
+                final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
+                        Long.valueOf(id));
+
+                return UriUtils.getDataColumn(getApplicationContext(), contentUri, null, null);
+            }
+            // MediaProvider
+            else if (UriUtils.isMediaDocument(uri)) {
+                final String docId = DocumentsContract.getDocumentId(uri);
+                final String[] split = docId.split(":");
+                final String type = split[0];
+
+                Uri contentUri = null;
+                if ("image".equals(type)) {
+                    contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+                } else if ("video".equals(type)) {
+                    contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
+                } else if ("audio".equals(type)) {
+                    contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
+                }
+
+                final String selection = "_id=?";
+                final String[] selectionArgs = new String[] { split[1] };
+
+                return UriUtils.getDataColumn(getApplicationContext(), contentUri, selection, selectionArgs);
+            }
+            // Documents providers returned as content://...
+            else if (UriUtils.isContentDocument(uri)) {
+                return uri.toString();
+            }
+        }
+        // MediaStore (and general)
+        else if ("content".equalsIgnoreCase(uri.getScheme())) {
+
+            // Return the remote address
+            if (UriUtils.isGooglePhotosUri(uri))
+                return uri.getLastPathSegment();
+
+            return UriUtils.getDataColumn(getApplicationContext(), uri, null, null);
+        }
+        // File
+        else if ("file".equalsIgnoreCase(uri.getScheme())) {
+            return uri.getPath();
+        }
         return null;
     }
 

+ 4 - 40
src/com/owncloud/android/ui/activity/UploadFilesActivity.java

@@ -34,9 +34,6 @@ import android.widget.TextView;
 
 import com.actionbarsherlock.app.ActionBar;
 import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.actionbarsherlock.internal.view.menu.ActionMenuItemView;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
 import com.actionbarsherlock.view.MenuItem;
 import com.owncloud.android.R;
 import com.owncloud.android.lib.common.utils.Log_OC;
@@ -76,8 +73,6 @@ public class UploadFilesActivity extends FileActivity implements
     private static final String WAIT_DIALOG_TAG = "WAIT";
     private static final String QUERY_TO_MOVE_DIALOG_TAG = "QUERY_TO_MOVE";
     
-    private boolean selectAllToggled = false;
-    private Menu menu;
     
     @Override
     public void onCreate(Bundle savedInstanceState) {
@@ -124,7 +119,6 @@ public class UploadFilesActivity extends FileActivity implements
         actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
         actionBar.setListNavigationCallbacks(mDirectories, this);
         
-        
         // wait dialog
         if (mCurrentDialog != null) {
             mCurrentDialog.dismiss();
@@ -133,15 +127,8 @@ public class UploadFilesActivity extends FileActivity implements
             
         Log_OC.d(TAG, "onCreate() end");
     }
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        // Inflate the menu items for use in the action bar
-        MenuInflater inflater = getSherlock().getMenuInflater();
-        inflater.inflate(R.menu.file_select_all, menu);     
-        this.menu = menu;
-        return true;
-    }
- 
+
+
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         boolean retval = true;
@@ -152,33 +139,12 @@ public class UploadFilesActivity extends FileActivity implements
                 }
                 break;
             }
-            case R.id.actionbar_select_all:{
-                if(selectAllToggled){
-                    toggleOffSelectAll();
-                }else{
-                    toggleOnSelectAll(item);
-                }
-                break;
-            }
             default:
                 retval = super.onOptionsItemSelected(item);
         }
         return retval;
     }
-    public void toggleOffSelectAll(MenuItem item){
-        selectAllToggled = false;
-        item.setIcon(android.R.drawable.checkbox_off_background);
-        mFileListFragment.deselectAll();
-    }
-    public void toggleOffSelectAll(){
-        MenuItem item = menu.findItem(R.id.actionbar_select_all);
-        toggleOffSelectAll(item);
-    }
-    public void toggleOnSelectAll(MenuItem item){
-        selectAllToggled = true;
-        item.setIcon(android.R.drawable.checkbox_on_background);        
-        mFileListFragment.selectAll();
-    }
+
     
     @Override
     public boolean onNavigationItemSelected(int itemPosition, long itemId) {
@@ -209,7 +175,6 @@ public class UploadFilesActivity extends FileActivity implements
             ActionBar actionBar = getSupportActionBar(); 
             actionBar.setDisplayHomeAsUpEnabled(false);
         } 
-        toggleOffSelectAll();
     }
 
     
@@ -277,11 +242,10 @@ public class UploadFilesActivity extends FileActivity implements
      * {@inheritDoc}
      */
     @Override
-    public void onDirectoryClick(File directory) { 
+    public void onDirectoryClick(File directory) {
         pushDirname(directory);
         ActionBar actionBar = getSupportActionBar();
         actionBar.setDisplayHomeAsUpEnabled(true);
-        toggleOffSelectAll();
     }
     
     

+ 1 - 1
src/com/owncloud/android/ui/activity/Uploader.java

@@ -170,7 +170,7 @@ public class Uploader extends SherlockListActivity implements OnItemClickListene
         case DIALOG_MULTIPLE_ACCOUNT:
             CharSequence ac[] = new CharSequence[mAccountManager.getAccountsByType(MainApp.getAccountType()).length];
             for (int i = 0; i < ac.length; ++i) {
-                ac[i] = mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name;
+                ac[i] = DisplayUtils.convertIdn(mAccountManager.getAccountsByType(MainApp.getAccountType())[i].name, false);
             }
             builder.setTitle(R.string.common_choose_account);
             builder.setItems(ac, new OnClickListener() {

+ 1 - 21
src/com/owncloud/android/ui/fragment/LocalFileListFragment.java

@@ -98,33 +98,13 @@ public class LocalFileListFragment extends ExtendedListFragment {
         Log_OC.i(TAG, "onActivityCreated() stop");
     }
     
-    public void selectAll(){
-        int numberOfFiles = mAdapter.getCount();
-        for(int i = 0; i < numberOfFiles; i++){
-            File file = (File) mAdapter.getItem(i);
-            if (file != null) {                
-                if (!file.isDirectory()) {  
-                    /// Click on a file
-                    getListView().setItemChecked(i, true);                       
-                    // notify the change to the container Activity
-                    mContainerActivity.onFileClick(file);
-                }
-            }
-        }
-    }
-    
-    public void deselectAll(){        
-        mAdapter = new LocalFileListAdapter(mContainerActivity.getInitialDirectory(), getActivity());
-        setListAdapter(mAdapter);
-    }
     
     /**
      * Checks the file clicked over. Browses inside if it is a directory. Notifies the container activity in any case.
      */
     @Override
     public void onItemClick(AdapterView<?> l, View v, int position, long id) {
-        File file = (File) mAdapter.getItem(position);
-        
+        File file = (File) mAdapter.getItem(position); 
         if (file != null) {
             /// Click on a directory
             if (file.isDirectory()) {

+ 19 - 2
src/com/owncloud/android/utils/DisplayUtils.java

@@ -277,7 +277,24 @@ public class DisplayUtils {
             return url;
         }
     }
-    
+
+    /**
+     * Get the file extension if it is on path as type "content://.../DocInfo.doc"
+     * @param filepath: Content Uri converted to string format
+     * @return String: fileExtension (type '.pdf'). Empty if no extension
+     */
+    public static String getComposedFileExtension(String filepath) {
+        String fileExtension = "";
+        String fileNameInContentUri = filepath.substring(filepath.lastIndexOf("/"));
+
+        // Check if extension is included in uri
+        int pos = fileNameInContentUri.lastIndexOf('.');
+        if (pos >= 0) {
+            fileExtension = fileNameInContentUri.substring(pos);
+        }
+        return fileExtension;
+    }
+
     public static CharSequence getRelativeDateTimeString(Context c, long time, long minResolution, long transitionResolution, int flags){
         CharSequence dateString = "";
         
@@ -301,6 +318,6 @@ public class DisplayUtils {
             }
         }
         
-        return dateString.toString().split(",")[0];
+        return dateString.toString().split(",")[0];
     }
 }

+ 103 - 0
src/com/owncloud/android/utils/UriUtils.java

@@ -0,0 +1,103 @@
+/* ownCloud Android client application
+ *   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.utils;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+
+
+/**
+ * A helper class for some Uri operations.
+ */
+public class UriUtils {
+    
+    public static final String URI_CONTENT_SCHEME = "content://";
+    
+    
+    /**
+     * Get the value of the data column for this Uri. This is useful for
+     * MediaStore Uris, and other file-based ContentProviders.
+     * 
+     * @param context The context.
+     * @param uri The Uri to query.
+     * @param selection (Optional) Filter used in the query.
+     * @param selectionArgs (Optional) Selection arguments used in the query.
+     * @return The value of the _data column, which is typically a file path.
+     */
+    public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
+
+        Cursor cursor = null;
+        final String column = "_data";
+        final String[] projection = { column };
+
+        try {
+            cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
+            if (cursor != null && cursor.moveToFirst()) {
+
+                final int column_index = cursor.getColumnIndexOrThrow(column);
+                return cursor.getString(column_index);
+            }
+        } finally {
+            if (cursor != null)
+                cursor.close();
+        }
+        return null;
+    }
+
+    /**
+     * @param uri The Uri to check.
+     * @return Whether the Uri authority is ExternalStorageProvider.
+     */
+    public static boolean isExternalStorageDocument(Uri uri) {
+        return "com.android.externalstorage.documents".equals(uri.getAuthority());
+    }
+
+    /**
+     * @param uri The Uri to check.
+     * @return Whether the Uri authority is DownloadsProvider.
+     */
+    public static boolean isDownloadsDocument(Uri uri) {
+        return "com.android.providers.downloads.documents".equals(uri.getAuthority());
+    }
+
+    /**
+     * @param uri The Uri to check.
+     * @return Whether the Uri authority is MediaProvider.
+     */
+    public static boolean isMediaDocument(Uri uri) {
+        return "com.android.providers.media.documents".equals(uri.getAuthority());
+    }
+
+    /**
+     * @param uri The Uri to check.
+     * @return Whether the Uri authority is Google Photos.
+     */
+    public static boolean isGooglePhotosUri(Uri uri) {
+        return "com.google.android.apps.photos.content".equals(uri.getAuthority());
+    }
+
+    /**
+     * 
+     * @param uri The Uri to check.
+     * @return Whether the Uri is from a content provider as kind "content://..."
+     */
+    public static boolean isContentDocument(Uri uri) {
+        return uri.toString().startsWith(URI_CONTENT_SCHEME);
+    }
+}

+ 2 - 2
tests/.classpath

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/owncloud-android"/>
 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
 	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
-	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="src" path="gen"/>
 	<classpathentry kind="output" path="bin/classes"/>
 </classpath>