Browse Source

Merge branch 'develop' into cancel_transfer_for_deleted_users

masensio 10 years ago
parent
commit
2d697473a1
35 changed files with 367 additions and 267 deletions
  1. 20 0
      CHANGELOG.md
  2. 1 1
      owncloud-android-library
  3. 0 3
      res/values-bg-rBG/strings.xml
  4. 1 0
      res/values-cs-rCZ/strings.xml
  5. 1 0
      res/values-da/strings.xml
  6. 1 0
      res/values-de-rDE/strings.xml
  7. 1 0
      res/values-de/strings.xml
  8. 1 0
      res/values-el/strings.xml
  9. 1 0
      res/values-en-rGB/strings.xml
  10. 47 0
      res/values-es-rAR/strings.xml
  11. 2 4
      res/values-es/strings.xml
  12. 0 3
      res/values-eu/strings.xml
  13. 1 0
      res/values-fi-rFI/strings.xml
  14. 1 3
      res/values-fr/strings.xml
  15. 1 3
      res/values-gl/strings.xml
  16. 1 0
      res/values-it/strings.xml
  17. 1 0
      res/values-ja-rJP/strings.xml
  18. 0 3
      res/values-nb-rNO/strings.xml
  19. 0 3
      res/values-pl/strings.xml
  20. 1 0
      res/values-pt-rBR/strings.xml
  21. 1 3
      res/values-pt-rPT/strings.xml
  22. 1 0
      res/values-ru/strings.xml
  23. 1 4
      res/values-sl/strings.xml
  24. 3 1
      res/values-sr/strings.xml
  25. 3 3
      res/values-tr/strings.xml
  26. 0 3
      res/values-uk/strings.xml
  27. 0 3
      res/values-zh-rTW/strings.xml
  28. 1 0
      res/values/strings.xml
  29. 1 1
      src/com/owncloud/android/MainApp.java
  30. 124 127
      src/com/owncloud/android/authentication/AuthenticatorActivity.java
  31. 100 0
      src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java
  32. 8 44
      src/com/owncloud/android/services/OperationsService.java
  33. 1 1
      src/com/owncloud/android/services/SyncFolderHandler.java
  34. 21 27
      src/com/owncloud/android/ui/activity/FileDisplayActivity.java
  35. 20 27
      src/com/owncloud/android/ui/activity/FolderPickerActivity.java

+ 20 - 0
CHANGELOG.md

@@ -0,0 +1,20 @@
+## 1.7.0 (19 February 2015)
+
+- Download full folders
+- Grid view for images
+- Remote thumbnails (OC Server 8.0+)
+- Added number of files and folders at the end of the list
+- "Open with" in contextual menu
+- Downloads added to Media Provider
+- Uploads:
+  + Local thumbnails in section "Files"
+  + Multiple selection in "Content from other apps" (Android 4.3+)
+- Gallery: 
+  + proper handling of EXIF
+  + obey sorting in the list of files
+- Settings view updated
+- Improved subjects in e-mails
+- Bugs fixed
+...
+
+

+ 1 - 1
owncloud-android-library

@@ -1 +1 @@
-Subproject commit 2f178c9c34e3dab507c46e718705913ed44db3c5
+Subproject commit c2b5ddd2364f53201e7df6210ce04bc6bf4a2bbd

+ 0 - 3
res/values-bg-rBG/strings.xml

@@ -299,7 +299,4 @@
   <string name="prefs_category_security">Сигурност</string>
   <string name="prefs_instant_video_upload_path_title">Качване на видео път</string>
   <string name="download_folder_failed_content">Свалянето на директорията %1$s не може да бъде завършено</string>
-  <string name="shared_subject_header">споделен</string>
-  <string name="with_you_subject_header">с Вас</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
 </resources>

+ 1 - 0
res/values-cs-rCZ/strings.xml

@@ -298,4 +298,5 @@ správce systému.</string>
   <string name="prefs_category_security">Zabezpečení</string>
   <string name="prefs_instant_video_upload_path_title">Cesta pro nahrávání videí</string>
   <string name="download_folder_failed_content">Stažení adresáře %1$s nemohlo být dokončeno</string>
+  <string name="subject_token">%1$s sdílí \"%2$s\"</string>
 </resources>

+ 1 - 0
res/values-da/strings.xml

@@ -297,4 +297,5 @@
   <string name="prefs_category_security">Sikkerhed</string>
   <string name="prefs_instant_video_upload_path_title">Sti til videoupload</string>
   <string name="download_folder_failed_content">Download af %1$s mappe kunne ikke fuldføres</string>
+  <string name="subject_token">%1$s delt \"%2$s\" med dig</string>
 </resources>

+ 1 - 0
res/values-de-rDE/strings.xml

@@ -299,4 +299,5 @@
   <string name="prefs_category_security">Sicherheit</string>
   <string name="prefs_instant_video_upload_path_title">Verzeichnis zum Hochladen der Videos</string>
   <string name="download_folder_failed_content">Herunterladen des %1$s - Ordners konnte nicht abgeschlossen werden</string>
+  <string name="subject_token">%1$s hat „%2$s“ mit Ihnen geteilt</string>
 </resources>

+ 1 - 0
res/values-de/strings.xml

@@ -299,4 +299,5 @@
   <string name="prefs_category_security">Sicherheit</string>
   <string name="prefs_instant_video_upload_path_title">Verzeichnis zum Hochladen der Videos</string>
   <string name="download_folder_failed_content">Herunterladen des %1$s - Ordners konnte nicht abgeschlossen werden</string>
+  <string name="subject_token">%1$s hat „%2$s“ mit Dir geteilt</string>
 </resources>

+ 1 - 0
res/values-el/strings.xml

@@ -299,4 +299,5 @@
   <string name="prefs_category_security">Ασφάλεια</string>
   <string name="prefs_instant_video_upload_path_title">Διαδρομή Μεταφόρτωσης Βίντεο</string>
   <string name="download_folder_failed_content">Η λήψη του φακέλου %1$s δεν ολοκληρώθηκε με επιτυχία.</string>
+  <string name="subject_token">%1$s μοιράστηκε \"%2$s\" μαζί σας</string>
 </resources>

+ 1 - 0
res/values-en-rGB/strings.xml

@@ -299,4 +299,5 @@
   <string name="prefs_category_security">Security</string>
   <string name="prefs_instant_video_upload_path_title">Upload Video Path</string>
   <string name="download_folder_failed_content">Download of %1$s folder could not be completed</string>
+  <string name="subject_token">%1$s shared \"%2$s\" with you</string>
 </resources>

+ 47 - 0
res/values-es-rAR/strings.xml

@@ -11,6 +11,12 @@
   <string name="actionbar_settings">Configuración</string>
   <string name="actionbar_see_details">Detalles</string>
   <string name="actionbar_send_file">Mandar</string>
+  <string name="actionbar_sort">Orden</string>
+  <string name="actionbar_sort_title">Ordenar por</string>
+  <string-array name="actionbar_sortby">
+    <item>A-Z</item>
+    <item>Nuevos - Viejos</item>
+  </string-array>
   <!--TODO re-enable when server-side folder size calculation is available   
     	<item>Biggest - Smallest</item>-->
   <string name="prefs_category_general">General</string>
@@ -32,7 +38,10 @@
   <string name="prefs_recommend">Recomendar a un amigo</string>
   <string name="prefs_feedback">Sugerencias</string>
   <string name="prefs_imprint">Imprint</string>
+  <string name="prefs_remember_last_share_location">Recordar compartir ubicación </string>
+  <string name="prefs_remember_last_upload_location_summary">Recordar la ultima ubicación compartida de subida</string>
   <string name="recommend_subject">¡Intento %1$s en tu teléfono inteligente!</string>
+  <string name="recommend_text">Quiero invitarte a usar %1$s en tu teléfono inteligente!\nDescárgalo aquí: %2$s</string>
   <string name="auth_check_server">Verificar Servidor</string>
   <string name="auth_host_url">Dirección del servidor https://...</string>
   <string name="auth_username">Nombre de usuario</string>
@@ -241,12 +250,50 @@
   <string name="conflict_dont_upload">No subir</string>
   <string name="preview_image_description">Previsualización de imagen</string>
   <string name="preview_image_error_unknown_format">Esta imagen no puede ser mostrada</string>
+  <string name="error__upload__local_file_not_copied">%1$s no pudo ser copiado a la carpeta local %2$s </string>
+  <string name="prefs_instant_upload_path_title">Dirección de subida</string>
+  <string name="share_link_no_support_share_api">Lo sentimos, compartir no esta activado en su servidor. Por favor contacte a su
+⇥⇥administrator.</string>
+  <string name="share_link_file_no_exist">Imposible compartir. Por favor revise si el archivo existe</string>
+  <string name="share_link_file_error">Un error ocurrió cuando se intentaba compartir el archivo o carpeta</string>
+  <string name="unshare_link_file_no_exist">Imposible dejar de compartir. Por favor revise si los archivos existen</string>
+  <string name="unshare_link_file_error">Un error ocurrió cuando se intentaba dejar de compartir el archivo o carpeta</string>
   <string name="activity_chooser_send_file_title">Mandar</string>
+  <string name="copy_link">Copiar dirección url</string>
   <string name="clipboard_text_copied">Copiado al portapapeles</string>
+  <string name="error_cant_bind_to_operations_service">Error critico: no se puede realizar operaciones</string>
+  <string name="network_error_socket_exception">Un error ocurrió mientras se conectaba con el Servidor.</string>
+  <string name="network_error_socket_timeout_exception">Un error ocurrió mientras se conectaba con el Servidor. La operación no se realizó </string>
+  <string name="network_error_connect_timeout_exception">Un error ocurrió esperando al Servidor, la operación no se realizó</string>
+  <string name="network_host_not_available">Operación no completada, Servidor no disponible.</string>
   <string name="empty"></string>
+  <string name="forbidden_permissions">Tu no tienes permiso %s</string>
+  <string name="forbidden_permissions_rename">para renombrar este archivo</string>
+  <string name="forbidden_permissions_delete">para borrar este archivo</string>
+  <string name="share_link_forbidden_permissions">para compartir este archivo</string>
+  <string name="unshare_link_forbidden_permissions">para dejar de compartir este archivo</string>
+  <string name="forbidden_permissions_create">para crear el archivo</string>
+  <string name="uploader_upload_forbidden_permissions">para subir en esta carpeta</string>
+  <string name="downloader_download_file_not_found">El archivo no esta mas disponible en este Servidor</string>
   <string name="prefs_category_accounts">Cuentas</string>
+  <string name="prefs_add_account">Añadir cuenta</string>
+  <string name="auth_redirect_non_secure_connection_title">Conexión segura redireccionada a una ruta insegura.</string>
+  <string name="actionbar_logger">Registro</string>
+  <string name="log_send_history_button">Enviar Historial</string>
+  <string name="log_send_no_mail_app">Aplicación para enviar registros no encontrada. Instale una aplicación de correo!</string>
+  <string name="log_send_mail_subject">%1$s Registros de la aplicación Android</string>
+  <string name="log_progress_dialog_text">Cargando datos...</string>
   <string name="saml_authentication_required_text">Autentificación requerida</string>
   <string name="saml_authentication_wrong_pass">Clave incorrecta</string>
+  <string name="actionbar_move">Mover</string>
+  <string name="file_list_empty_moving">Nada aquí. Puedes agregar una carpeta!</string>
   <string name="folder_picker_choose_button_text">Elegir</string>
+  <string name="move_file_not_found">Imposible mover. Por favor revisa si el archivo existe</string>
+  <string name="move_file_invalid_overwrite">El archivo ya existe en la carpeta destino</string>
+  <string name="move_file_error">Un error ocurrió intentando mover el archivo o carpeta</string>
+  <string name="forbidden_permissions_move">para mover este archivo</string>
+  <string name="prefs_category_instant_uploading">Subida Instantánea </string>
   <string name="prefs_category_security">Seguridad</string>
+  <string name="prefs_instant_video_upload_path_title">Dirección de subida del video</string>
+  <string name="download_folder_failed_content">La descarga de la carpeta %1$s no pudo ser completada</string>
 </resources>

+ 2 - 4
res/values-es/strings.xml

@@ -289,7 +289,7 @@
   <string name="saml_authentication_wrong_pass">Contraseña incorrecta</string>
   <string name="actionbar_move">Mover</string>
   <string name="file_list_empty_moving">Aquí no hay nada. ¡Puede agregar una carpeta!</string>
-  <string name="folder_picker_choose_button_text">Seleccionar</string>
+  <string name="folder_picker_choose_button_text">Elegir</string>
   <string name="move_file_not_found">No se puede mover. Revise si el archivo existe</string>
   <string name="move_file_invalid_into_descendent">No se puede mover una carpeta dentro de una de SUS subcarpetas.</string>
   <string name="move_file_invalid_overwrite">El archivo ya existe en la carpeta de destino</string>
@@ -299,7 +299,5 @@
   <string name="prefs_category_security">Seguridad</string>
   <string name="prefs_instant_video_upload_path_title">Guardar videos subidos en la carpeta:</string>
   <string name="download_folder_failed_content">La descarga de la carpeta %1$s no ha podido ser completada</string>
-  <string name="shared_subject_header">compartido</string>
-  <string name="with_you_subject_header">contigo</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
+  <string name="subject_token">%1$s compartió \"%2$s\" contigo</string>
 </resources>

+ 0 - 3
res/values-eu/strings.xml

@@ -295,7 +295,4 @@ Mesedez, baimendu berriz</string>
   <string name="prefs_category_security">Segurtasuna</string>
   <string name="prefs_instant_video_upload_path_title">Bideo Igoera Bidea</string>
   <string name="download_folder_failed_content">%1$s karpetaren deskarga ezin izan da burutu</string>
-  <string name="shared_subject_header">konpartitua</string>
-  <string name="with_you_subject_header">zurekin</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
 </resources>

+ 1 - 0
res/values-fi-rFI/strings.xml

@@ -276,4 +276,5 @@
   <string name="move_file_error">Tämän tiedoston tai kansion siirtoa yrittäessä tapahtui virhe</string>
   <string name="prefs_category_instant_uploading">Välittömät lähetykset</string>
   <string name="prefs_category_security">Tietoturva</string>
+  <string name="subject_token">%1$s jakoi kohteen \"%2$s\" kanssasi</string>
 </resources>

+ 1 - 3
res/values-fr/strings.xml

@@ -303,7 +303,5 @@ Ci-dessous la liste des fichiers locaux, et les fichiers distants dans %5$s auxq
   <string name="prefs_category_security">Sécurité</string>
   <string name="prefs_instant_video_upload_path_title">Répertoire de téléversement des vidéos</string>
   <string name="download_folder_failed_content">Le téléchargement du dossier %1$s n\'a pas pu être achevé</string>
-  <string name="shared_subject_header">partagé</string>
-  <string name="with_you_subject_header">avec vous</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
+  <string name="subject_token">%1$s a partagé \"%2$s\" avec vous</string>
 </resources>

+ 1 - 3
res/values-gl/strings.xml

@@ -300,7 +300,5 @@ Descárgueo de aquí: %2$s</string>
   <string name="prefs_category_security">Seguranza</string>
   <string name="prefs_instant_video_upload_path_title">Enviar a ruta do vídeo</string>
   <string name="download_folder_failed_content">Non foi posíbel completar a descarga do cartafol %1$s</string>
-  <string name="shared_subject_header">compartido</string>
-  <string name="with_you_subject_header">con vostede</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
+  <string name="subject_token">%1$s compartiu «%2$s» con vostede</string>
 </resources>

+ 1 - 0
res/values-it/strings.xml

@@ -299,4 +299,5 @@
   <string name="prefs_category_security">Protezione</string>
   <string name="prefs_instant_video_upload_path_title">Percorso di caricamento video</string>
   <string name="download_folder_failed_content">Lo scaricamento della cartella %1$s non può essere completato</string>
+  <string name="subject_token">%1$s ha condiviso \"%2$s\" con te</string>
 </resources>

+ 1 - 0
res/values-ja-rJP/strings.xml

@@ -300,4 +300,5 @@
   <string name="prefs_category_security">セキュリティ</string>
   <string name="prefs_instant_video_upload_path_title">動画のアップロードパス</string>
   <string name="download_folder_failed_content">%1$s のフォルダのダウンロードが完了しませんでした。</string>
+  <string name="subject_token">%1$sがあなたと\"%2$s\"を共有しました</string>
 </resources>

+ 0 - 3
res/values-nb-rNO/strings.xml

@@ -299,7 +299,4 @@
   <string name="prefs_category_security">Sikkerhet</string>
   <string name="prefs_instant_video_upload_path_title">Sti til video-opplasting</string>
   <string name="download_folder_failed_content">Nedlasting av %1$s mappen kunne ikke fullføres</string>
-  <string name="shared_subject_header">delt</string>
-  <string name="with_you_subject_header">med deg</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
 </resources>

+ 0 - 3
res/values-pl/strings.xml

@@ -299,7 +299,4 @@
   <string name="prefs_category_security">Bezpieczeństwo</string>
   <string name="prefs_instant_video_upload_path_title">Katalog wysyłania dla wideo</string>
   <string name="download_folder_failed_content">Pobieranie %1$s katalogu nie może zostać ukończone</string>
-  <string name="shared_subject_header">współdzielone</string>
-  <string name="with_you_subject_header">z Tobą</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
 </resources>

+ 1 - 0
res/values-pt-rBR/strings.xml

@@ -299,4 +299,5 @@
   <string name="prefs_category_security">Segurança</string>
   <string name="prefs_instant_video_upload_path_title">Enviar o Caminho do Vídeo</string>
   <string name="download_folder_failed_content">Baixar %1$s da pasta não pode ser completado</string>
+  <string name="subject_token">%1$s compartilhou \"%2$s\" com você</string>
 </resources>

+ 1 - 3
res/values-pt-rPT/strings.xml

@@ -297,7 +297,5 @@
   <string name="prefs_category_security">Segurança</string>
   <string name="prefs_instant_video_upload_path_title">Envio do Caminho do Vídeo</string>
   <string name="download_folder_failed_content">Não foi possível completar o download da pasta %1$s</string>
-  <string name="shared_subject_header">partilhado</string>
-  <string name="with_you_subject_header">consigo</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
+  <string name="subject_token">%1$s partilhou \"%2$s\" consigo</string>
 </resources>

+ 1 - 0
res/values-ru/strings.xml

@@ -300,4 +300,5 @@
   <string name="prefs_category_security">Безопасность</string>
   <string name="prefs_instant_video_upload_path_title">Путь для загрузки Видео</string>
   <string name="download_folder_failed_content">Загрузка папки %1$s не может быть завершена</string>
+  <string name="subject_token">%1$s предоставил вам доступ к \"%2$s\"</string>
 </resources>

+ 1 - 4
res/values-sl/strings.xml

@@ -298,8 +298,5 @@
   <string name="prefs_category_instant_uploading">Takojšnje pošiljanje v oblak</string>
   <string name="prefs_category_security">Varnost</string>
   <string name="prefs_instant_video_upload_path_title">Pot videa za pošiljanje</string>
-  <string name="download_folder_failed_content">Prenos imenika %1$s  ni mogoče dokončati</string>
-  <string name="shared_subject_header">v souporabi</string>
-  <string name="with_you_subject_header">z vami</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
+  <string name="download_folder_failed_content">Imenika %1$s  ni mogoče prejeti v celoti</string>
 </resources>

+ 3 - 1
res/values-sr/strings.xml

@@ -48,11 +48,14 @@
   <string name="common_cancel">Откажи</string>
   <string name="common_save_exit">Сачувај и изађи</string>
   <string name="common_error">Грешка</string>
+  <string name="common_loading">Учитавам...</string>
+  <string name="common_error_unknown">Непозната грешка</string>
   <string name="about_title">О програму</string>
   <string name="change_password">Измени лозинку</string>
   <string name="delete_account">Обриши налог</string>
   <string name="create_account">Отвори налог</string>
   <string name="upload_chooser_title">Отпреми из…</string>
+  <string name="uploader_info_dirname">Назив фасцикле</string>
   <string name="uploader_upload_in_progress_ticker">Отпремам…</string>
   <string name="uploader_upload_in_progress_content">%1$d%% Отпремам %2$s</string>
   <string name="uploader_upload_succeeded_ticker">Отпремање је успело</string>
@@ -139,5 +142,4 @@
   <string name="saml_authentication_wrong_pass">Лозинка пограшна</string>
   <string name="folder_picker_choose_button_text">Одабери</string>
   <string name="prefs_category_security">Безбедност</string>
-  <string name="shared_subject_header">Дељено</string>
 </resources>

+ 3 - 3
res/values-tr/strings.xml

@@ -64,9 +64,9 @@
   <string name="file_list_loading">Yükleniyor...</string>
   <string name="local_file_list_empty">Bu klasörde dosya yok.</string>
   <string name="file_list_folder">klasör</string>
-  <string name="file_list_folders">klasörler</string>
+  <string name="file_list_folders">klasör</string>
   <string name="file_list_file">dosya</string>
-  <string name="file_list_files">dosyalar</string>
+  <string name="file_list_files">dosya</string>
   <string name="filedetails_select_file">Ek bilgileri görmek için dosyaya dokunun.</string>
   <string name="filedetails_size">Boyut:</string>
   <string name="filedetails_type">Tür:</string>
@@ -299,5 +299,5 @@
   <string name="prefs_category_security">Güvenlik</string>
   <string name="prefs_instant_video_upload_path_title">Video Yükleme Yolu</string>
   <string name="download_folder_failed_content">%1$s klasörün indirilmesi tamamlanamadı</string>
-  <string name="subject_token">%1$s sizinle \"%2$s\" paylaştı</string>
+  <string name="subject_token">%1$s sizinle \"%2$s\" paylaşımını yaptı</string>
 </resources>

+ 0 - 3
res/values-uk/strings.xml

@@ -298,7 +298,4 @@
   <string name="prefs_category_security">Безпека</string>
   <string name="prefs_instant_video_upload_path_title">Шлях завантаження відео</string>
   <string name="download_folder_failed_content">Скачування теки %1$s не може бути завершено</string>
-  <string name="shared_subject_header">спільне</string>
-  <string name="with_you_subject_header">з тобою</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
 </resources>

+ 0 - 3
res/values-zh-rTW/strings.xml

@@ -299,7 +299,4 @@
   <string name="prefs_category_security">安全性</string>
   <string name="prefs_instant_video_upload_path_title">影片上傳路徑</string>
   <string name="download_folder_failed_content">%1$s 目錄的下載未完成</string>
-  <string name="shared_subject_header">以分享的</string>
-  <string name="with_you_subject_header">與你</string>
-  <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
 </resources>

+ 1 - 0
res/values/strings.xml

@@ -193,6 +193,7 @@
 	<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="auth_account_does_not_exist">Account does not exist in the device yet</string>
     
     <string name="fd_keep_in_sync">Keep file up to date</string>
     <string name="common_rename">Rename</string>

+ 1 - 1
src/com/owncloud/android/MainApp.java

@@ -1,5 +1,5 @@
 /* ownCloud Android client application
- *   Copyright (C) 2012-2013 ownCloud Inc.
+ *   Copyright (C) 2012-2015 ownCloud Inc.
  *
  *   This program is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License version 2,

+ 124 - 127
src/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -1,6 +1,6 @@
 /* ownCloud Android client application
  *   Copyright (C) 2012  Bartek Przybylski
- *   Copyright (C) 2012-2014 ownCloud Inc.
+ *   Copyright (C) 2012-2015 ownCloud Inc.
  *
  *   This program is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License version 2,
@@ -64,7 +64,10 @@ import com.actionbarsherlock.app.SherlockDialogFragment;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;
+import com.owncloud.android.lib.common.OwnCloudCredentials;
+import com.owncloud.android.lib.common.OwnCloudCredentialsFactory;
 import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
+import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
 import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
 import com.owncloud.android.lib.common.network.CertificateCombinedException;
 import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
@@ -72,7 +75,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;
 import com.owncloud.android.operations.DetectAuthenticationMethodOperation.AuthenticationMethod;
@@ -95,8 +97,9 @@ import com.owncloud.android.utils.DisplayUtils;
  * @author masensio
  */
 public class AuthenticatorActivity extends AccountAuthenticatorActivity
-implements  OnRemoteOperationListener, OnFocusChangeListener, OnEditorActionListener, 
-SsoWebViewClientListener, OnSslUntrustedCertListener {
+        implements  OnRemoteOperationListener, OnFocusChangeListener, OnEditorActionListener,
+        SsoWebViewClientListener, OnSslUntrustedCertListener,
+        AuthenticatorAsyncTask.OnAuthenticatorTaskListener {
 
     private static final String TAG = AuthenticatorActivity.class.getSimpleName();
 
@@ -132,6 +135,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private static final String CREDENTIALS_DIALOG_TAG = "CREDENTIALS_DIALOG";
     private static final String KEY_AUTH_IS_FIRST_ATTEMPT_TAG = "KEY_AUTH_IS_FIRST_ATTEMPT";
 
+    private static final String KEY_USERNAME = "USERNAME";
+    private static final String KEY_PASSWORD = "PASSWORD";
+    private static final String KEY_ASYNC_TASK_IN_PROGRESS = "AUTH_IN_PROGRESS";
     
     /// parameters from EXTRAs in starter Intent
     private byte mAction;
@@ -175,14 +181,19 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private int mAuthStatusText = 0, mAuthStatusIcon = 0;
     
     private String mAuthToken = "";
+    private AuthenticatorAsyncTask mAsyncTask;
 
     private boolean mIsFirstAuthAttempt;
-
     
     /// Identifier of operation in progress which result shouldn't be lost 
     private long mWaitingForOpId = Long.MAX_VALUE;
 
-    
+    private final String BASIC_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());
+    private final String OAUTH_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());
+    private final String SAML_TOKEN_TYPE =
+            AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType());
+
+
     /**
      * {@inheritDoc}
      * 
@@ -227,7 +238,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         setContentView(R.layout.account_setup);
         
         /// initialize general UI elements
-        initOverallUi(savedInstanceState);
+        initOverallUi();
         
         mOkButton = findViewById(R.id.buttonOK);
 
@@ -265,21 +276,19 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 
     private String chooseAuthTokenType(boolean oauth, boolean saml) {
         if (saml) {
-            return AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType());
+            return SAML_TOKEN_TYPE;
         } else if (oauth) {
-             return AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());
+             return OAUTH_TOKEN_TYPE;
         } else {
-            return AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());
+            return BASIC_TOKEN_TYPE;
         }
     }
 
     
     /**
      * Configures elements in the user interface under direct control of the Activity.
-     * 
-     * @param savedInstanceState        Saved activity state, as in {{@link #onCreate(Bundle)}
      */
-    private void initOverallUi(Bundle savedInstanceState) {
+    private void initOverallUi() {
         
         /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)
         boolean isWelcomeLinkVisible = getResources().getBoolean(R.bool.show_welcome_link);
@@ -415,9 +424,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                     if (
                             AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(
                                     MainApp.getAccountType()
-                                    ).equals(mAuthTokenType) &&
-                            mHostUrlInput.hasFocus()
-                    ) {
+                            ).equals(mAuthTokenType) &&
+                                    mHostUrlInput.hasFocus()
+                            ) {
                         checkOcServer();
                     }
                 }
@@ -549,7 +558,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * intended to defer the processing of the redirection caught in 
      * {@link #onNewIntent(Intent)} until {@link #onResume()} 
      * 
-     * See {@link #loadSavedInstanceState(Bundle)}
+     * See {@link #onSaveInstanceState(Bundle)}
      */
     @Override
     protected void onSaveInstanceState(Bundle outState) {
@@ -581,9 +590,42 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         /// authentication
         outState.putBoolean(KEY_AUTH_IS_FIRST_ATTEMPT_TAG, mIsFirstAuthAttempt);
 
+        /// AsyncTask (User and password)
+        outState.putString(KEY_USERNAME, mUsernameInput.getText().toString());
+        outState.putString(KEY_PASSWORD, mPasswordInput.getText().toString());
+
+        if (mAsyncTask != null) {
+            mAsyncTask.cancel(true);
+            outState.putBoolean(KEY_ASYNC_TASK_IN_PROGRESS, true);
+        } else {
+            outState.putBoolean(KEY_ASYNC_TASK_IN_PROGRESS, false);
+        }
+        mAsyncTask = null;
+
         //Log_OC.wtf(TAG, "onSaveInstanceState end" );
     }
 
+    @Override
+    public void onRestoreInstanceState(Bundle savedInstanceState) {
+        super.onRestoreInstanceState(savedInstanceState);
+
+        // AsyncTask
+        boolean inProgress = savedInstanceState.getBoolean(KEY_ASYNC_TASK_IN_PROGRESS);
+        if (inProgress){
+            String username = savedInstanceState.getString(KEY_USERNAME);
+            String password = savedInstanceState.getString(KEY_PASSWORD);
+
+            OwnCloudCredentials credentials = null;
+            if (BASIC_TOKEN_TYPE.equals(mAuthTokenType)) {
+                credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password);
+
+            } else if (OAUTH_TOKEN_TYPE.equals(mAuthTokenType)) {
+                credentials = OwnCloudCredentialsFactory.newBearerCredentials(mAuthToken);
+
+            }
+            accessRootFolder(credentials);
+        }
+    }
 
     /**
      * The redirection triggered by the OAuth authentication server as response to the 
@@ -608,7 +650,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      */
     @Override
     protected void onResume() {
-        //Log_OC.wtf(TAG, "onResume init" );
         super.onResume();
         
         // bound here to avoid spurious changes triggered by Android on device rotations
@@ -623,15 +664,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             doOnResumeAndBound();
         }
         
-        //Log_OC.wtf(TAG, "onResume end" );
     }
 
     
     @Override
     protected void onPause() {
-        //Log_OC.wtf(TAG, "onPause init" );
         if (mOperationsServiceBinder != null) {
-            //Log_OC.wtf(TAG, "unregistering to listen for operation callbacks" );
             mOperationsServiceBinder.removeOperationListener(this);
         }
         
@@ -639,7 +677,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         mHostUrlInput.setOnFocusChangeListener(null);
         
         super.onPause();
-        //Log_OC.wtf(TAG, "onPause end" );
     }
     
     @Override
@@ -695,14 +732,14 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     public void onFocusChange(View view, boolean hasFocus) {
         if (view.getId() == R.id.hostUrlInput) {   
             if (!hasFocus) {
-                onUrlInputFocusLost((TextView) view);
+                onUrlInputFocusLost();
             }
             else {
                 showRefreshButton(false);
             }
 
         } else if (view.getId() == R.id.account_password) {
-            onPasswordFocusChanged((TextView) view, hasFocus);
+            onPasswordFocusChanged(hasFocus);
         }
     }
 
@@ -715,10 +752,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * started. 
      * 
      * When hasFocus:    user 'comes back' to write again the server URL.
-     * 
-     * @param hostInput     TextView with the URL input field receiving the change of focus.
      */
-    private void onUrlInputFocusLost(TextView hostInput) {
+    private void onUrlInputFocusLost() {
         if (!mServerInfo.mBaseUrl.equals(
                 normalizeUrl(mHostUrlInput.getText().toString(), mServerInfo.mIsSslConn))) {
             // check server again only if the user changed something in the field
@@ -772,10 +807,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * 
      * When (!hasFocus), the button is made invisible and the password is hidden.
      * 
-     * @param passwordInput    TextView with the password input field receiving the change of focus.
      * @param hasFocus          'True' if focus is received, 'false' if is lost
      */
-    private void onPasswordFocusChanged(TextView passwordInput, boolean hasFocus) {
+    private void onPasswordFocusChanged(boolean hasFocus) {
         if (hasFocus) {
             showViewPasswordButton();
         } else {
@@ -840,7 +874,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             mServerStatusText = R.string.auth_wtf_reenter_URL;
             showServerStatus();
             mOkButton.setEnabled(false);
-            //Log_OC.wtf(TAG,  "The user was allowed to click 'connect' to an unchecked server!!");
             return;
         }
 
@@ -873,25 +906,17 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);
 
         /// validate credentials accessing the root folder
-        accessRootFolderRemoteOperation(username, password);
-        
+        OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password);
+        accessRootFolder(credentials);
     }
 
-    private void accessRootFolderRemoteOperation(String username, String password) {
-        Intent existenceCheckIntent = new Intent();
-        existenceCheckIntent.setAction(OperationsService.ACTION_EXISTENCE_CHECK);
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mServerInfo.mBaseUrl);
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, "/");
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_USERNAME, username);
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_PASSWORD, password);
-        existenceCheckIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN, mAuthToken);
-        
-        if (mOperationsServiceBinder != null) {
-            //Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." );
-            mWaitingForOpId = mOperationsServiceBinder.queueNewOperation(existenceCheckIntent);
-        }
+    private void accessRootFolder(OwnCloudCredentials credentials) {
+        mAsyncTask = new AuthenticatorAsyncTask(this);
+        Object[] params = { mServerInfo.mBaseUrl, credentials };
+        mAsyncTask.execute(params);
     }
 
+
     /**
      * Starts the OAuth 'grant type' flow to get an access token, with 
      * a GET AUTHORIZATION request to the BUILT-IN authorization server. 
@@ -929,17 +954,16 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * in the server.
      */
     private void startSamlBasedFederatedSingleSignOnAuthorization() {
-        // be gentle with the user
+        /// be gentle with the user
         mAuthStatusIcon = R.drawable.progress_small;
         mAuthStatusText = R.string.auth_connecting_auth_server;
         showAuthStatus();
-        IndeterminateProgressDialog dialog = 
-                IndeterminateProgressDialog.newInstance(R.string.auth_trying_to_login, true);
-        dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);
-
-        /// validate credentials accessing the root folder
-        accessRootFolderRemoteOperation("", "");
 
+        /// Show SAML-based SSO web dialog
+        String targetUrl = mServerInfo.mBaseUrl
+                + AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);
+        SamlWebViewDialog dialog = SamlWebViewDialog.newInstance(targetUrl, targetUrl);
+        dialog.show(getSupportFragmentManager(), SAML_DIALOG_TAG);
     }
 
     /**
@@ -959,15 +983,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         } else if (operation instanceof OAuth2GetAccessToken) {
             onGetOAuthAccessTokenFinish(result);
 
-        } else if (operation instanceof ExistenceCheckRemoteOperation)  {
-            //Log_OC.wtf(TAG, "received detection response through callback" );
-            if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).
-                    equals(mAuthTokenType)) {
-                onSamlBasedFederatedSingleSignOnAuthorizationStart(result);
-
-            } else {
-                onAuthorizationCheckFinish(result);
-            }
         } else if (operation instanceof GetRemoteUserNameOperation) {
             onGetUserNameFinish(result);
         }
@@ -988,20 +1003,20 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 if (!mUsernameInput.getText().toString().equals(username)) {
                     // fail - not a new account, but an existing one; disallow
                     result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_THE_SAME);
-                    /*
-                    OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(
-                            new OwnCloudAccount(
-                                    Uri.parse(mServerInfo.mBaseUrl),
-                                    OwnCloudCredentialsFactory.newSamlSsoCredentials(mAuthToken))
-                            );
-                            */
                     mAuthToken = "";
                     updateAuthStatusIconAndText(result);
                     showAuthStatus();
                     Log_OC.d(TAG, result.getLogMessage());
                 } else {
-                    updateToken();
-                    success = true;
+                    try {
+                        updateAccountAuthentication();
+                        success = true;
+
+                    } catch (AccountNotFoundException e) {
+                        Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);
+                        Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();
+                        finish();
+                    }
                 }
             }
 
@@ -1015,35 +1030,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 
     }
 
-    private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) {
-        mWaitingForOpId = Long.MAX_VALUE;
-        dismissDialog(WAIT_DIALOG_TAG);
-
-        if (result.isIdPRedirection()) {
-            String targetUrl = mServerInfo.mBaseUrl 
-                    + AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);
-
-            // Show dialog
-            SamlWebViewDialog dialog = SamlWebViewDialog.newInstance(targetUrl, targetUrl);            
-            dialog.show(getSupportFragmentManager(), SAML_DIALOG_TAG);
-
-            mAuthStatusIcon = 0;
-            mAuthStatusText = 0;
-
-        } else {
-            mAuthStatusIcon = R.drawable.common_error;
-            mAuthStatusText = R.string.auth_unsupported_auth_method;
-
-        }
-        showAuthStatus();
-    }
-
-
     /**
      * Processes the result of the server check performed when the user finishes the enter of the
      * server URL.
-     * 
-     * @param operation     Server check performed.
+     *
      * @param result        Result of the check.
      */
     private void onGetServerInfoFinish(RemoteOperationResult result) {
@@ -1088,16 +1078,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 
 
     private boolean authSupported(AuthenticationMethod authMethod) {
-        String basic = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());
-        String oAuth = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());
-        String saml =  AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType());
-        
-        return (( mAuthTokenType.equals(basic) && 
-                    authMethod.equals(AuthenticationMethod.BASIC_HTTP_AUTH) ) ||
-                ( mAuthTokenType.equals(oAuth) && 
-                    authMethod.equals(AuthenticationMethod.BEARER_TOKEN)) ||
-                ( mAuthTokenType.equals(saml)  && 
-                    authMethod.equals(AuthenticationMethod.SAML_WEB_SSO))
+        return (( BASIC_TOKEN_TYPE.equals(mAuthTokenType) &&
+                    AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod) ) ||
+                ( OAUTH_TOKEN_TYPE.equals(mAuthTokenType) &&
+                    AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
+                ( SAML_TOKEN_TYPE.equals(mAuthTokenType)  &&
+                    AuthenticationMethod.SAML_WEB_SSO.equals(authMethod))
         );
     }
 
@@ -1338,8 +1324,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             Map<String, String> tokens = (Map<String, String>)(result.getData().get(0));
             mAuthToken = tokens.get(OAuth2Constants.KEY_ACCESS_TOKEN);
             Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);
-            
-            accessRootFolderRemoteOperation("", "");
+
+            /// validate token accessing to root folder / getting session
+            OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBearerCredentials(mAuthToken);
+            accessRootFolder(credentials);
 
         } else {
             updateAuthStatusIconAndText(result);
@@ -1353,11 +1341,11 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * Processes the result of the access check performed to try the user credentials.
      * 
      * Creates a new account through the AccountManager.
-     * 
-     * @param operation     Access check performed.
+     *
      * @param result        Result of the operation.
      */
-    private void onAuthorizationCheckFinish(RemoteOperationResult result) {
+    @Override
+    public void onAuthenticatorTaskCallback(RemoteOperationResult result) {
         mWaitingForOpId = Long.MAX_VALUE;
         dismissDialog(WAIT_DIALOG_TAG);
 
@@ -1369,15 +1357,22 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 success = createAccount();
 
             } else {
-                updateToken();
-                success = true;
+                try {
+                    updateAccountAuthentication();
+                    success = true;
+
+                } catch (AccountNotFoundException e) {
+                    Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);
+                    Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();
+                    finish();
+                }
             }
 
             if (success) {
                 finish();
             }
             
-        } else if (result.isServerFail() || result.isException()) {
+        } else if (result.isServerFail() || result.isException()) {
             /// server errors or exceptions in authorization take to requiring a new check of 
             /// the server
             mServerIsChecked = true;
@@ -1411,10 +1406,16 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 
 
     /**
-     * Sets the proper response to get that the Account Authenticator that started this activity 
+     * Updates the authentication token.
+     *
+     * Sets the proper response so that the AccountAuthenticator that started this activity
      * saves a new authorization token for mAccount.
+     *
+     * Kills the session kept by OwnCloudClientManager so that a new one will created with
+     * the new credentials when needed.
      */
-    private void updateToken() {
+    private void updateAccountAuthentication() throws AccountNotFoundException {
+        
         Bundle response = new Bundle();
         response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);
         response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);
@@ -1500,21 +1501,19 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             final Intent intent = new Intent();       
             intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE,    MainApp.getAccountType());
             intent.putExtra(AccountManager.KEY_ACCOUNT_NAME,    mAccount.name);
-            /*if (!isOAuth)
-                intent.putExtra(AccountManager.KEY_AUTHTOKEN,   MainApp.getAccountType()); */
             intent.putExtra(AccountManager.KEY_USERDATA,        username);
             if (isOAuth || isSaml) {
                 mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
             }
             /// add user data to the new account; TODO probably can be done in the last parameter 
-            //      addAccountExplicitly, or in KEY_USERDATA
+            //      addAccountExplicitly, or in KEY_USERDATA
             mAccountMgr.setUserData(
                     mAccount, Constants.KEY_OC_VERSION,    mServerInfo.mVersion.getVersion()
             );
             mAccountMgr.setUserData(
                     mAccount, Constants.KEY_OC_BASE_URL,   mServerInfo.mBaseUrl
             );
-
+
             if (isSaml) {
                 mAccountMgr.setUserData(mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); 
             } else if (isOAuth) {
@@ -1546,9 +1545,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     /**
      * Updates the content and visibility state of the icon and text associated
      * to the last check on the ownCloud server.
-     * 
-     * @param serverStatusText      Resource identifier of the text to show.
-     * @param serverStatusIcon      Resource identifier of the icon to show.
+     *
      */
     private void showServerStatus() {
         if (mServerStatusIcon == 0 && mServerStatusText == 0) {
@@ -1626,9 +1623,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     public void onCheckClick(View view) {
         CheckBox oAuth2Check = (CheckBox)view;
         if (oAuth2Check.isChecked()) {
-            mAuthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());
+            mAuthTokenType = OAUTH_TOKEN_TYPE;
         } else {
-            mAuthTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());
+            mAuthTokenType = BASIC_TOKEN_TYPE;
         }
         updateAuthenticationPreFragmentVisibility();
     }
@@ -1702,7 +1699,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         getUserNameIntent.putExtra(OperationsService.EXTRA_COOKIE, sessionCookie);
         
         if (mOperationsServiceBinder != null) {
-            //Log_OC.wtf(TAG, "starting getRemoteUserNameOperation..." );
             mWaitingForOpId = mOperationsServiceBinder.queueNewOperation(getUserNameIntent);
         }
     }
@@ -1835,7 +1831,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             if (component.equals(
                     new ComponentName(AuthenticatorActivity.this, OperationsService.class)
                 )) {
-                //Log_OC.wtf(TAG, "Operations service connected");
                 mOperationsServiceBinder = (OperationsServiceBinder) service;
                 
                 doOnResumeAndBound();
@@ -1891,4 +1886,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     public void doNegativeAuthenticatioDialogClick(){
         mIsFirstAuthAttempt = true;
     }
+
+
 }

+ 100 - 0
src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java

@@ -0,0 +1,100 @@
+/* ownCloud Android client application
+ *   Copyright (C) 2012-2015 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package com.owncloud.android.authentication;
+
+import android.app.Activity;
+import android.content.Context;
+import android.net.Uri;
+import android.os.AsyncTask;
+
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientFactory;
+import com.owncloud.android.lib.common.OwnCloudCredentials;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
+
+import java.lang.ref.WeakReference;
+
+
+/**
+ * Async Task to verify the credentials of a user
+ *
+ * @author masensio on 09/02/2015.
+ */
+public class AuthenticatorAsyncTask  extends AsyncTask<Object, Void, RemoteOperationResult> {
+
+    private static String REMOTE_PATH = "/";
+    private static boolean SUCCESS_IF_ABSENT = false;
+
+    private Context mContext;
+    private final WeakReference<OnAuthenticatorTaskListener> mListener;
+    protected Activity mActivity;
+
+    public AuthenticatorAsyncTask(Activity activity) {
+        mContext = activity.getApplicationContext();
+        mListener = new WeakReference<OnAuthenticatorTaskListener>((OnAuthenticatorTaskListener)activity);
+    }
+
+    @Override
+    protected RemoteOperationResult doInBackground(Object... params) {
+
+        RemoteOperationResult result;
+        if (params!= null && params.length==2) {
+            String url = (String)params[0];
+            OwnCloudCredentials credentials = (OwnCloudCredentials)params[1];
+
+            // Client
+            Uri uri = Uri.parse(url);
+            OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(uri, mContext, true);
+
+            client.setCredentials(credentials);
+
+            // Operation
+            ExistenceCheckRemoteOperation operation = new ExistenceCheckRemoteOperation(
+                    REMOTE_PATH,
+                    mContext,
+                    SUCCESS_IF_ABSENT
+            );
+            result = operation.execute(client);
+
+        } else {
+            result = new RemoteOperationResult(RemoteOperationResult.ResultCode.UNKNOWN_ERROR);
+        }
+
+        return result;
+    }
+
+    @Override
+    protected void onPostExecute(RemoteOperationResult result) {
+
+        if (result!= null)
+        {
+            OnAuthenticatorTaskListener listener = mListener.get();
+            if (listener!= null)
+            {
+                listener.onAuthenticatorTaskCallback(result);
+            }
+        }
+    }
+    /*
+     * Interface to retrieve data from recognition task
+     */
+    public interface OnAuthenticatorTaskListener{
+
+        void onAuthenticatorTaskCallback(RemoteOperationResult result);
+    }
+}

+ 8 - 44
src/com/owncloud/android/services/OperationsService.java

@@ -37,7 +37,6 @@ import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
 import com.owncloud.android.lib.resources.shares.ShareType;
 import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;
 import com.owncloud.android.operations.common.SyncOperation;
@@ -85,25 +84,18 @@ public class OperationsService extends Service {
     public static final String EXTRA_NEW_PARENT_PATH = "NEW_PARENT_PATH";
     public static final String EXTRA_FILE = "FILE";
 
-    // TODO review if ALL OF THEM are necessary
-    public static final String EXTRA_SUCCESS_IF_ABSENT = "SUCCESS_IF_ABSENT";
-    public static final String EXTRA_USERNAME = "USERNAME";
-    public static final String EXTRA_PASSWORD = "PASSWORD";
-    public static final String EXTRA_AUTH_TOKEN = "AUTH_TOKEN";
     public static final String EXTRA_COOKIE = "COOKIE";
     
     public static final String ACTION_CREATE_SHARE = "CREATE_SHARE";
     public static final String ACTION_UNSHARE = "UNSHARE";
     public static final String ACTION_GET_SERVER_INFO = "GET_SERVER_INFO";
     public static final String ACTION_OAUTH2_GET_ACCESS_TOKEN = "OAUTH2_GET_ACCESS_TOKEN";
-    public static final String ACTION_EXISTENCE_CHECK = "EXISTENCE_CHECK";
     public static final String ACTION_GET_USER_NAME = "GET_USER_NAME";
     public static final String ACTION_RENAME = "RENAME";
     public static final String ACTION_REMOVE = "REMOVE";
     public static final String ACTION_CREATE_FOLDER = "CREATE_FOLDER";
     public static final String ACTION_SYNC_FILE = "SYNC_FILE";
     public static final String ACTION_SYNC_FOLDER = "SYNC_FOLDER";  // for the moment, just to download
-    //public static final String ACTION_CANCEL_SYNC_FOLDER = "CANCEL_SYNC_FOLDER";  // for the moment, just to download
     public static final String ACTION_MOVE_FILE = "MOVE_FILE";
     
     public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() + ".OPERATION_ADDED";
@@ -117,18 +109,11 @@ public class OperationsService extends Service {
     private static class Target {
         public Uri mServerUrl = null;
         public Account mAccount = null;
-        public String mUsername = null;
-        public String mPassword = null;
-        public String mAuthToken = null;
         public String mCookie = null;
         
-        public Target(Account account, Uri serverUrl, String username, String password, String authToken,
-                String cookie) {
+        public Target(Account account, Uri serverUrl, String cookie) {
             mAccount = account;
             mServerUrl = serverUrl;
-            mUsername = username;
-            mPassword = password;
-            mAuthToken = authToken;
             mCookie = cookie;
         }
     }
@@ -248,7 +233,7 @@ public class OperationsService extends Service {
      */
     @Override
     public boolean onUnbind(Intent intent) {
-        ((OperationsServiceBinder)mOperationsBinder).clearListeners();
+        mOperationsBinder.clearListeners();
         return false;   // not accepting rebinding (default behaviour)
     }
 
@@ -448,19 +433,10 @@ public class OperationsService extends Service {
                             );
                         } else {
                             OwnCloudCredentials credentials = null;
-                            if (mLastTarget.mUsername != null && 
-                                    mLastTarget.mUsername.length() > 0) {
-                                credentials = OwnCloudCredentialsFactory.newBasicCredentials(
-                                        mLastTarget.mUsername, 
-                                        mLastTarget.mPassword);  // basic
-                                
-                            } else if (mLastTarget.mAuthToken != null && 
-                                    mLastTarget.mAuthToken.length() > 0) {
-                                credentials = OwnCloudCredentialsFactory.newBearerCredentials(
-                                        mLastTarget.mAuthToken);  // bearer token
-                                
-                            } else if (mLastTarget.mCookie != null &&
+                            if (mLastTarget.mCookie != null &&
                                     mLastTarget.mCookie.length() > 0) {
+                                // just used for GetUserName
+                                // TODO refactor to run GetUserName as AsyncTask in the context of AuthenticatorActivity
                                 credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(
                                         mLastTarget.mCookie); // SAML SSO
                             }
@@ -509,7 +485,7 @@ public class OperationsService extends Service {
                 }
                 
                 //sendBroadcastOperationFinished(mLastTarget, mCurrentOperation, result);
-                mService.dispatchResultToOperationListeners(mLastTarget, mCurrentOperation, result);
+                mService.dispatchResultToOperationListeners(mCurrentOperation, result);
             }
         }
 
@@ -537,16 +513,10 @@ public class OperationsService extends Service {
             } else {
                 Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT);
                 String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL);
-                String username = operationIntent.getStringExtra(EXTRA_USERNAME);
-                String password = operationIntent.getStringExtra(EXTRA_PASSWORD);
-                String authToken = operationIntent.getStringExtra(EXTRA_AUTH_TOKEN);
                 String cookie = operationIntent.getStringExtra(EXTRA_COOKIE);
                 target = new Target(
                         account, 
                         (serverUrl == null) ? null : Uri.parse(serverUrl),
-                        username,
-                        password,
-                        authToken,
                         cookie
                 );
                 
@@ -581,12 +551,6 @@ public class OperationsService extends Service {
                             getString(R.string.oauth2_grant_type),
                             oauth2QueryParameters);
                     
-                } else if (action.equals(ACTION_EXISTENCE_CHECK)) {
-                    // Existence Check 
-                    String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
-                    boolean successIfAbsent = operationIntent.getBooleanExtra(EXTRA_SUCCESS_IF_ABSENT, false);
-                    operation = new ExistenceCheckRemoteOperation(remotePath, OperationsService.this, successIfAbsent);
-                    
                 } else if (action.equals(ACTION_GET_USER_NAME)) {
                     // Get User Name
                     operation = new GetRemoteUserNameOperation();
@@ -698,12 +662,12 @@ public class OperationsService extends Service {
     /**
      * Notifies the currently subscribed listeners about the end of an operation.
      *
-     * @param target            Account or URL pointing to an OC server.
      * @param operation         Finished operation.
      * @param result            Result of the operation.
      */
     protected void dispatchResultToOperationListeners(
-            Target target, final RemoteOperation operation, final RemoteOperationResult result) {
+            final RemoteOperation operation, final RemoteOperationResult result
+    ) {
         int count = 0;
         Iterator<OnRemoteOperationListener> listeners = mOperationsBinder.mBoundListeners.keySet().iterator();
         while (listeners.hasNext()) {

+ 1 - 1
src/com/owncloud/android/services/SyncFolderHandler.java

@@ -126,7 +126,7 @@ class SyncFolderHandler extends Handler {
             } finally {
                 mPendingOperations.removePayload(account, remotePath);
 
-                mService.dispatchResultToOperationListeners(null, mCurrentSyncOperation, result);
+                mService.dispatchResultToOperationListeners(mCurrentSyncOperation, result);
 
                 sendBroadcastFinishedSyncFolder(account, remotePath, result.isSuccess());
             }

+ 21 - 27
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1110,40 +1110,34 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
                                     (synchResult.isException() && synchResult.getException() 
                                             instanceof AuthenticatorException))) {
 
-                            OwnCloudClient client = null;
+
                             try {
-                                OwnCloudAccount ocAccount = 
+                                OwnCloudClient client;
+                                OwnCloudAccount ocAccount =
                                         new OwnCloudAccount(getAccount(), context);
                                 client = (OwnCloudClientManagerFactory.getDefaultSingleton().
                                         removeClientFor(ocAccount));
-                                // TODO get rid of these exceptions
-                            } catch (AccountNotFoundException e) {
-                                e.printStackTrace();
-                            } catch (AuthenticatorException e) {
-                                e.printStackTrace();
-                            } catch (OperationCanceledException e) {
-                                e.printStackTrace();
-                            } catch (IOException e) {
-                                e.printStackTrace();
-                            }
-                            
-                            if (client != null) {
-                                OwnCloudCredentials cred = client.getCredentials();
-                                if (cred != null) {
-                                    AccountManager am = AccountManager.get(context);
-                                    if (cred.authTokenExpires()) {
-                                        am.invalidateAuthToken(
-                                                getAccount().type, 
-                                                cred.getAuthToken()
-                                        );
-                                    } else {
-                                        am.clearPassword(getAccount());
+
+                                if (client != null) {
+                                    OwnCloudCredentials cred = client.getCredentials();
+                                    if (cred != null) {
+                                        AccountManager am = AccountManager.get(context);
+                                        if (cred.authTokenExpires()) {
+                                            am.invalidateAuthToken(
+                                                    getAccount().type,
+                                                    cred.getAuthToken()
+                                            );
+                                        } else {
+                                            am.clearPassword(getAccount());
+                                        }
                                     }
                                 }
+                                requestCredentialsUpdate();
+
+                            } catch (AccountNotFoundException e) {
+                                Log_OC.e(TAG, "Account " + getAccount() + " was removed!", e);
                             }
-                            
-                            requestCredentialsUpdate();
-                            
+
                         }
                     }
                     removeStickyBroadcast(intent);

+ 20 - 27
src/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -489,40 +489,33 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
                                     (synchResult.isException() && synchResult.getException() 
                                             instanceof AuthenticatorException))) {
 
-                            OwnCloudClient client = null;
                             try {
-                                OwnCloudAccount ocAccount = 
+                                OwnCloudClient client;
+                                OwnCloudAccount ocAccount =
                                         new OwnCloudAccount(getAccount(), context);
                                 client = (OwnCloudClientManagerFactory.getDefaultSingleton().
                                         removeClientFor(ocAccount));
-                                // TODO get rid of these exceptions
-                            } catch (AccountNotFoundException e) {
-                                e.printStackTrace();
-                            } catch (AuthenticatorException e) {
-                                e.printStackTrace();
-                            } catch (OperationCanceledException e) {
-                                e.printStackTrace();
-                            } catch (IOException e) {
-                                e.printStackTrace();
-                            }
-                            
-                            if (client != null) {
-                                OwnCloudCredentials cred = client.getCredentials();
-                                if (cred != null) {
-                                    AccountManager am = AccountManager.get(context);
-                                    if (cred.authTokenExpires()) {
-                                        am.invalidateAuthToken(
-                                                getAccount().type, 
-                                                cred.getAuthToken()
-                                        );
-                                    } else {
-                                        am.clearPassword(getAccount());
+
+                                if (client != null) {
+                                    OwnCloudCredentials cred = client.getCredentials();
+                                    if (cred != null) {
+                                        AccountManager am = AccountManager.get(context);
+                                        if (cred.authTokenExpires()) {
+                                            am.invalidateAuthToken(
+                                                    getAccount().type,
+                                                    cred.getAuthToken()
+                                            );
+                                        } else {
+                                            am.clearPassword(getAccount());
+                                        }
                                     }
                                 }
+                                requestCredentialsUpdate();
+
+                            } catch (AccountNotFoundException e) {
+                                Log_OC.e(TAG, "Account " + getAccount() + " was removed!", e);
                             }
-                            
-                            requestCredentialsUpdate();
-                            
+
                         }
                     }
                     removeStickyBroadcast(intent);