From: masensio Date: Tue, 24 Feb 2015 13:19:41 +0000 (+0100) Subject: Merge branch 'develop' into cancel_transfer_for_deleted_users X-Git-Tag: oc-android-1.7.1_signed^2~40^2~3 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/2d697473a1be0d57dcc9c4412749fd1e290d0e07?hp=e3a61d283fdd1a89cac30faacbba1863dd2907a7 Merge branch 'develop' into cancel_transfer_for_deleted_users --- diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..51d52429 --- /dev/null +++ b/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 +... + + diff --git a/owncloud-android-library b/owncloud-android-library index 2f178c9c..c2b5ddd2 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 2f178c9c34e3dab507c46e718705913ed44db3c5 +Subproject commit c2b5ddd2364f53201e7df6210ce04bc6bf4a2bbd diff --git a/res/values-bg-rBG/strings.xml b/res/values-bg-rBG/strings.xml index a39f77d0..2cd1c818 100644 --- a/res/values-bg-rBG/strings.xml +++ b/res/values-bg-rBG/strings.xml @@ -299,7 +299,4 @@ Сигурност Качване на видео път Свалянето на директорията %1$s не може да бъде завършено - споделен - с Вас - %1$s %2$s >>%3$s<< %4$s diff --git a/res/values-cs-rCZ/strings.xml b/res/values-cs-rCZ/strings.xml index 3cc5171a..a6d98fcd 100644 --- a/res/values-cs-rCZ/strings.xml +++ b/res/values-cs-rCZ/strings.xml @@ -298,4 +298,5 @@ správce systému. Zabezpečení Cesta pro nahrávání videí Stažení adresáře %1$s nemohlo být dokončeno + %1$s sdílí \"%2$s\" diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 4852e565..9700ad6a 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -297,4 +297,5 @@ Sikkerhed Sti til videoupload Download af %1$s mappe kunne ikke fuldføres + %1$s delt \"%2$s\" med dig diff --git a/res/values-de-rDE/strings.xml b/res/values-de-rDE/strings.xml index 59f63695..a8463836 100644 --- a/res/values-de-rDE/strings.xml +++ b/res/values-de-rDE/strings.xml @@ -299,4 +299,5 @@ Sicherheit Verzeichnis zum Hochladen der Videos Herunterladen des %1$s - Ordners konnte nicht abgeschlossen werden + %1$s hat „%2$s“ mit Ihnen geteilt diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index fdc369c8..2d0b0774 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -299,4 +299,5 @@ Sicherheit Verzeichnis zum Hochladen der Videos Herunterladen des %1$s - Ordners konnte nicht abgeschlossen werden + %1$s hat „%2$s“ mit Dir geteilt diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 8fbc0e0f..b51af5df 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -299,4 +299,5 @@ Ασφάλεια Διαδρομή Μεταφόρτωσης Βίντεο Η λήψη του φακέλου %1$s δεν ολοκληρώθηκε με επιτυχία. + %1$s μοιράστηκε \"%2$s\" μαζί σας diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index 9b303212..8675183b 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -299,4 +299,5 @@ Security Upload Video Path Download of %1$s folder could not be completed + %1$s shared \"%2$s\" with you diff --git a/res/values-es-rAR/strings.xml b/res/values-es-rAR/strings.xml index 3baeea20..dca9e4ac 100644 --- a/res/values-es-rAR/strings.xml +++ b/res/values-es-rAR/strings.xml @@ -11,6 +11,12 @@ Configuración Detalles Mandar + Orden + Ordenar por + + A-Z + Nuevos - Viejos + General @@ -32,7 +38,10 @@ Recomendar a un amigo Sugerencias Imprint + Recordar compartir ubicación + Recordar la ultima ubicación compartida de subida ¡Intento %1$s en tu teléfono inteligente! + Quiero invitarte a usar %1$s en tu teléfono inteligente!\nDescárgalo aquí: %2$s Verificar Servidor Dirección del servidor https://... Nombre de usuario @@ -241,12 +250,50 @@ No subir Previsualización de imagen Esta imagen no puede ser mostrada + %1$s no pudo ser copiado a la carpeta local %2$s + Dirección de subida + Lo sentimos, compartir no esta activado en su servidor. Por favor contacte a su +⇥⇥administrator. + Imposible compartir. Por favor revise si el archivo existe + Un error ocurrió cuando se intentaba compartir el archivo o carpeta + Imposible dejar de compartir. Por favor revise si los archivos existen + Un error ocurrió cuando se intentaba dejar de compartir el archivo o carpeta Mandar + Copiar dirección url Copiado al portapapeles + Error critico: no se puede realizar operaciones + Un error ocurrió mientras se conectaba con el Servidor. + Un error ocurrió mientras se conectaba con el Servidor. La operación no se realizó + Un error ocurrió esperando al Servidor, la operación no se realizó + Operación no completada, Servidor no disponible. + Tu no tienes permiso %s + para renombrar este archivo + para borrar este archivo + para compartir este archivo + para dejar de compartir este archivo + para crear el archivo + para subir en esta carpeta + El archivo no esta mas disponible en este Servidor Cuentas + Añadir cuenta + Conexión segura redireccionada a una ruta insegura. + Registro + Enviar Historial + Aplicación para enviar registros no encontrada. Instale una aplicación de correo! + %1$s Registros de la aplicación Android + Cargando datos... Autentificación requerida Clave incorrecta + Mover + Nada aquí. Puedes agregar una carpeta! Elegir + Imposible mover. Por favor revisa si el archivo existe + El archivo ya existe en la carpeta destino + Un error ocurrió intentando mover el archivo o carpeta + para mover este archivo + Subida Instantánea Seguridad + Dirección de subida del video + La descarga de la carpeta %1$s no pudo ser completada diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index a8fd6791..17207949 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -289,7 +289,7 @@ Contraseña incorrecta Mover Aquí no hay nada. ¡Puede agregar una carpeta! - Seleccionar + Elegir No se puede mover. Revise si el archivo existe No se puede mover una carpeta dentro de una de SUS subcarpetas. El archivo ya existe en la carpeta de destino @@ -299,7 +299,5 @@ Seguridad Guardar videos subidos en la carpeta: La descarga de la carpeta %1$s no ha podido ser completada - compartido - contigo - %1$s %2$s >>%3$s<< %4$s + %1$s compartió \"%2$s\" contigo diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml index 2c1a78b6..0bca4628 100644 --- a/res/values-eu/strings.xml +++ b/res/values-eu/strings.xml @@ -295,7 +295,4 @@ Mesedez, baimendu berriz Segurtasuna Bideo Igoera Bidea %1$s karpetaren deskarga ezin izan da burutu - konpartitua - zurekin - %1$s %2$s >>%3$s<< %4$s diff --git a/res/values-fi-rFI/strings.xml b/res/values-fi-rFI/strings.xml index ae5c4850..4f9db067 100644 --- a/res/values-fi-rFI/strings.xml +++ b/res/values-fi-rFI/strings.xml @@ -276,4 +276,5 @@ Tämän tiedoston tai kansion siirtoa yrittäessä tapahtui virhe Välittömät lähetykset Tietoturva + %1$s jakoi kohteen \"%2$s\" kanssasi diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index de72d129..3f7a1064 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -303,7 +303,5 @@ Ci-dessous la liste des fichiers locaux, et les fichiers distants dans %5$s auxq Sécurité Répertoire de téléversement des vidéos Le téléchargement du dossier %1$s n\'a pas pu être achevé - partagé - avec vous - %1$s %2$s >>%3$s<< %4$s + %1$s a partagé \"%2$s\" avec vous diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml index 43b83bcb..6861b674 100644 --- a/res/values-gl/strings.xml +++ b/res/values-gl/strings.xml @@ -300,7 +300,5 @@ Descárgueo de aquí: %2$s Seguranza Enviar a ruta do vídeo Non foi posíbel completar a descarga do cartafol %1$s - compartido - con vostede - %1$s %2$s >>%3$s<< %4$s + %1$s compartiu «%2$s» con vostede diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index a4d161a2..64033373 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -299,4 +299,5 @@ Protezione Percorso di caricamento video Lo scaricamento della cartella %1$s non può essere completato + %1$s ha condiviso \"%2$s\" con te diff --git a/res/values-ja-rJP/strings.xml b/res/values-ja-rJP/strings.xml index 5d4db25f..20eca25b 100644 --- a/res/values-ja-rJP/strings.xml +++ b/res/values-ja-rJP/strings.xml @@ -300,4 +300,5 @@ セキュリティ 動画のアップロードパス %1$s のフォルダのダウンロードが完了しませんでした。 + %1$sがあなたと\"%2$s\"を共有しました diff --git a/res/values-nb-rNO/strings.xml b/res/values-nb-rNO/strings.xml index 2d8fdfe9..3336ec12 100644 --- a/res/values-nb-rNO/strings.xml +++ b/res/values-nb-rNO/strings.xml @@ -299,7 +299,4 @@ Sikkerhet Sti til video-opplasting Nedlasting av %1$s mappen kunne ikke fullføres - delt - med deg - %1$s %2$s >>%3$s<< %4$s diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index fc0f3633..3623617f 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -299,7 +299,4 @@ Bezpieczeństwo Katalog wysyłania dla wideo Pobieranie %1$s katalogu nie może zostać ukończone - współdzielone - z Tobą - %1$s %2$s >>%3$s<< %4$s diff --git a/res/values-pt-rBR/strings.xml b/res/values-pt-rBR/strings.xml index 5135951f..c68a4a3e 100644 --- a/res/values-pt-rBR/strings.xml +++ b/res/values-pt-rBR/strings.xml @@ -299,4 +299,5 @@ Segurança Enviar o Caminho do Vídeo Baixar %1$s da pasta não pode ser completado + %1$s compartilhou \"%2$s\" com você diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml index 231a9e66..13c8d744 100644 --- a/res/values-pt-rPT/strings.xml +++ b/res/values-pt-rPT/strings.xml @@ -297,7 +297,5 @@ Segurança Envio do Caminho do Vídeo Não foi possível completar o download da pasta %1$s - partilhado - consigo - %1$s %2$s >>%3$s<< %4$s + %1$s partilhou \"%2$s\" consigo diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index a9bb306b..09283a0a 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -300,4 +300,5 @@ Безопасность Путь для загрузки Видео Загрузка папки %1$s не может быть завершена + %1$s предоставил вам доступ к \"%2$s\" diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 7c6e3006..aac1ac6f 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -298,8 +298,5 @@ Takojšnje pošiljanje v oblak Varnost Pot videa za pošiljanje - Prenos imenika %1$s ni mogoče dokončati - v souporabi - z vami - %1$s %2$s >>%3$s<< %4$s + Imenika %1$s ni mogoče prejeti v celoti diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index 2a9f45bf..3e0b1bd7 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -48,11 +48,14 @@ Откажи Сачувај и изађи Грешка + Учитавам... + Непозната грешка О програму Измени лозинку Обриши налог Отвори налог Отпреми из… + Назив фасцикле Отпремам… %1$d%% Отпремам %2$s Отпремање је успело @@ -139,5 +142,4 @@ Лозинка пограшна Одабери Безбедност - Дељено diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 3b1ac5e0..6ac42871 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -64,9 +64,9 @@ Yükleniyor... Bu klasörde dosya yok. klasör - klasörler + klasör dosya - dosyalar + dosya Ek bilgileri görmek için dosyaya dokunun. Boyut: Tür: @@ -299,5 +299,5 @@ Güvenlik Video Yükleme Yolu %1$s klasörün indirilmesi tamamlanamadı - %1$s sizinle \"%2$s\" paylaştı + %1$s sizinle \"%2$s\" paylaşımını yaptı diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 87fe6714..64c57d30 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -298,7 +298,4 @@ Безпека Шлях завантаження відео Скачування теки %1$s не може бути завершено - спільне - з тобою - %1$s %2$s >>%3$s<< %4$s diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index de6dd10e..4659d43a 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -299,7 +299,4 @@ 安全性 影片上傳路徑 %1$s 目錄的下載未完成 - 以分享的 - 與你 - %1$s %2$s >>%3$s<< %4$s diff --git a/res/values/strings.xml b/res/values/strings.xml index 296a8e0e..1ad9d8d3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -193,6 +193,7 @@ Your server is not returning a correct user id, please contact an administrator Cannot authenticate against this server + Account does not exist in the device yet Keep file up to date Rename diff --git a/src/com/owncloud/android/MainApp.java b/src/com/owncloud/android/MainApp.java index c2a4c68b..65e704be 100644 --- a/src/com/owncloud/android/MainApp.java +++ b/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, diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 8d7182d7..d88d778b 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/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 tokens = (Map)(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; } + + } diff --git a/src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java b/src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java new file mode 100644 index 00000000..e995c006 --- /dev/null +++ b/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 . + * + */ +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 { + + private static String REMOTE_PATH = "/"; + private static boolean SUCCESS_IF_ABSENT = false; + + private Context mContext; + private final WeakReference mListener; + protected Activity mActivity; + + public AuthenticatorAsyncTask(Activity activity) { + mContext = activity.getApplicationContext(); + mListener = new WeakReference((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); + } +} diff --git a/src/com/owncloud/android/services/OperationsService.java b/src/com/owncloud/android/services/OperationsService.java index 581a686d..baf163a2 100644 --- a/src/com/owncloud/android/services/OperationsService.java +++ b/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 listeners = mOperationsBinder.mBoundListeners.keySet().iterator(); while (listeners.hasNext()) { diff --git a/src/com/owncloud/android/services/SyncFolderHandler.java b/src/com/owncloud/android/services/SyncFolderHandler.java index 02f8f7a4..2dbddbe4 100644 --- a/src/com/owncloud/android/services/SyncFolderHandler.java +++ b/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()); } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 3bc1aed9..7b8af0f8 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/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); diff --git a/src/com/owncloud/android/ui/activity/FolderPickerActivity.java b/src/com/owncloud/android/ui/activity/FolderPickerActivity.java index e4b1886c..1c295377 100644 --- a/src/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/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);