From: David A. Velasco Date: Thu, 25 Jun 2015 12:43:04 +0000 (+0200) Subject: Merge branch 'develop' into release-1.7.2 X-Git-Tag: oc-android-1.7.2~1^2~5 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/9babe1b38cd2b9e5a19a0bc81eb00d4336a2a6ec?hp=378b28f346f84a946a99dd959aaf98284b6518eb Merge branch 'develop' into release-1.7.2 --- diff --git a/owncloud-android-library b/owncloud-android-library index 5d1f0690..f5fbca24 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 5d1f0690036c556ec299881c339959de891fdf46 +Subproject commit f5fbca24becbb01660abe2a7013c1b536ea8a301 diff --git a/res/values-cs-rCZ/strings.xml b/res/values-cs-rCZ/strings.xml index e67179be..5de9318e 100644 --- a/res/values-cs-rCZ/strings.xml +++ b/res/values-cs-rCZ/strings.xml @@ -21,8 +21,12 @@ Biggest - Smallest--> + Všechny soubory + Nastavení + Logy + Zavřít Obecné Více Účty diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 13149f79..a659491e 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -313,7 +313,6 @@ Download af %1$s mappe kunne ikke fuldføres delt med dig - %1$s %2$s >>%3$s<< %4$s Genopfrisk forbindelsen Serveradresse Ikke tilstrækkelig hukommelse diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index cbce970f..b230acee 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -23,6 +23,7 @@ + Einstellungen Allgemein Mehr Konten diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 9c47da0a..1da5dd6f 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -315,7 +315,7 @@ Η λήψη του φακέλου %1$s δεν ολοκληρώθηκε με επιτυχία. διαμοιρασμένα με εσάς - %1$s %2$s >>%3$s<< %4$s + Ο %1$s διαμοιράστηκε το \"%2$s\" με εσάς Ανανέωση σύνδεσης Διεύθυνση διακομιστή Δεν υπάρχει αρκετή μνήμη diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 62474144..e73ed695 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -315,7 +315,7 @@ La descarga de la carpeta %1$s no ha podido ser completada compartido con usted - %1$s %2$s >>%3$s<< %4$s + %1$s compartió \"%2$s\" conmigo Refrescar la conexión Dirección del servidor No hay suficiente memoria diff --git a/res/values-fi-rFI/strings.xml b/res/values-fi-rFI/strings.xml index ef9f7aca..cae7a432 100644 --- a/res/values-fi-rFI/strings.xml +++ b/res/values-fi-rFI/strings.xml @@ -296,6 +296,7 @@ Tietoturva jaettu kanssasi + %1$s jakoi kohteen \"%2$s\" kanssasi Päivitä yhteys Palvelimen osoite Muistia ei ole riittävästi diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 35da9dc6..3079a1f6 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -84,7 +84,7 @@ Téléchargez-le ici : %2$s Télécharger Actualiser le fichier Le fichier a été renommé en %s pendant le téléversement - Disposition en liste + Affichage en liste Partager le lien Ne plus partager ce lien Oui @@ -319,7 +319,7 @@ Ci-dessous la liste des fichiers locaux, et les fichiers distants dans %5$s auxq Le téléchargement de %1$s dossier(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 Actualiser la connexion Adresse du serveur Mémoire insuffisante diff --git a/res/values-gl/strings.xml b/res/values-gl/strings.xml index 808aa2fd..9b65a536 100644 --- a/res/values-gl/strings.xml +++ b/res/values-gl/strings.xml @@ -316,7 +316,7 @@ Descárgueo de aquí: %2$s 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 Actualizar a conexión Enderezo do servidor Non hai memoria abondo diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 13586c1e..3b3e56fb 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -315,7 +315,6 @@ Lo scaricamento della cartella %1$s non può essere completato condiviso con te - %1$s %2$s >>%3$s<< %4$s Aggiorna la connessione Indirizzo del server Memoria insufficiente diff --git a/res/values-nb-rNO/strings.xml b/res/values-nb-rNO/strings.xml index 0c6c5120..7e24d18d 100644 --- a/res/values-nb-rNO/strings.xml +++ b/res/values-nb-rNO/strings.xml @@ -315,7 +315,6 @@ Nedlasting av %1$s mappen kunne ikke fullføres delte med deg - %1$s %2$s >>%3$s<< %4$s Oppfrisk forbindelse Server-adresse Ikke nok minne diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index 62f49c59..ce646f81 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -318,7 +318,7 @@ Hieronder staan de lokale bestanden en de externe bestanden in %5$s waar ze naar Download van %1$s map kon niet worden voltooid gedeeld met u - %1$s %2$s >>%3$s<< %4$s + %1$s deelde \"%2$s\" met u Verversen verbinding Serveradres Niet voldoende geheugen diff --git a/res/values-pt-rBR/strings.xml b/res/values-pt-rBR/strings.xml index 4e73641e..bcb79cb5 100644 --- a/res/values-pt-rBR/strings.xml +++ b/res/values-pt-rBR/strings.xml @@ -315,7 +315,6 @@ Baixar %1$s da pasta não pode ser completado compartilhado com você - %1$s %2$s >>%3$s<< %4$s Reinicializar conexão Endereço do servidor Não há memoria suficiente diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index ee239506..85a259ed 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -316,7 +316,7 @@ Загрузка папки %1$s не может быть завершена поделился с вами - %1$s %2$s >>%3$s<< %4$s + %1$s предоставил вам доступ к \"%2$s\" Обновить соединение Адрес сервера Недостаточно памяти diff --git a/res/values-sk-rSK/strings.xml b/res/values-sk-rSK/strings.xml index 36625d7a..27fc1c2f 100644 --- a/res/values-sk-rSK/strings.xml +++ b/res/values-sk-rSK/strings.xml @@ -21,8 +21,12 @@ Biggest - Smallest--> + Všetky súbory + Nastavenia + Logy + Zavrieť Všeobecné Viac Účty @@ -130,6 +134,10 @@ Lokálne: %1$s Vzdialené: %1$s Nie je dostatok miesta na skopírovanie vybraných súborov do priečinka %1$s. Želáte si ich namiesto toho presunúť? + Prosím, vložte svoje heslo: + Vložte svoje heslo + Prosím, vložte znovu svoje heslo: + Zmazať svoje heslo Prehrávač hudby %1$s %1$s (prehráva) %1$s (načítava) @@ -255,6 +263,8 @@ Pri pokuse o zdieľanie tohto súboru alebo priečinka došlo k chybe Nemožno ukončiť zdieľanie. Skontrolujte, či súbor existuje Pri pokuse zrušiť zdieľanie tohto súboru alebo priečinka došlo k chybe + Vložte heslo + Musíte vložiť heslo Odoslať Kopíruj odkaz Skopírované do schránky @@ -294,5 +304,11 @@ Zabezpečenie Cesta pre nahrávanie videí Sťahovanie %1$s priečinka nebolo dokončené + zdieľané + s vami + %1$s vám zdieľal \"%2$s\" + Obnoviť pripojenie Adresa servera + Nedostatok pamäte + Používateľské meno diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 85c2182c..a560ff9d 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -315,7 +315,6 @@ Imenika %1$s ni mogoče prejeti v celoti v souporabi z vami - %1$s %2$s >>%3$s<< %4$s Osveži povezavo Naslov strežnika Ni dovolj pomnilnika diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index b4bf682e..f6bbd623 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -21,8 +21,12 @@ Biggest - Smallest--> + Сви фајлови + Поставке + Записници + Затвори Опште Остало Налози @@ -211,6 +215,7 @@ Садржај је већ синхронизован Фасцикла се не може направити Забрањени знакови: / \\ < > : \" | ? * + Назив садржи бар један недозвољен карактер Назив фајла не може бити празан Сачекајте тренутак Неочекивани проблем. Изаберите фајл другом апликацијом @@ -308,7 +313,11 @@ Безбедност Путања отпремања видеа Преузимање фасцикле %1$s не може бити довршено + дељено + са вама + %1$s подели „%2$s“ са вама Освежи везу Адреса сервера Нема довољно меморије + Корисничко име diff --git a/res/values-th-rTH/strings.xml b/res/values-th-rTH/strings.xml index 2d63cde2..498cc97a 100644 --- a/res/values-th-rTH/strings.xml +++ b/res/values-th-rTH/strings.xml @@ -313,7 +313,6 @@ การดาวน์โหลดโฟลเดอร์ %1$s อาจไม่สำเร็จ ถูกแชร์ กับคุณ - %1$s %2$s >>%3$s<< %4$s ฟื้นฟูการเชื่อมต่อ ที่อยู่เซิร์ฟเวอร์ หน่วยความจำไม่พอ diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 175b9f21..92cae34a 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -315,7 +315,6 @@ %1$s klasörün indirilmesi tamamlanamadı sizinle paylaştı - %1$s %2$s >>%3$s<< %4$s Bağlantıyı yenile Sunucu adresi Yeterli hafıza yok diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 09e63345..6afb25d5 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -313,7 +313,6 @@ %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 d035650a..369ae9ec 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -302,7 +302,7 @@ %1$s 目錄的下載未完成 以分享的 與你 - %1$s %2$s >>%3$s<< %4$s + %1$s 分享了 \"%2$s\" 給您 重新連線 伺服器位址 使用者名稱 diff --git a/src/com/owncloud/android/authentication/AccountUtils.java b/src/com/owncloud/android/authentication/AccountUtils.java index 9afa819c..87766b54 100644 --- a/src/com/owncloud/android/authentication/AccountUtils.java +++ b/src/com/owncloud/android/authentication/AccountUtils.java @@ -114,7 +114,7 @@ public class AccountUtils { if (accountName != null) { Account[] ocAccounts = AccountManager.get(context).getAccountsByType( MainApp.getAccountType()); - boolean found = false; + boolean found; for (Account account : ocAccounts) { found = (account.name.equals(accountName)); if (found) { @@ -220,19 +220,20 @@ public class AccountUtils { if (isOAuth) { accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_OAUTH2, "TRUE"); } - /* TODO - study if it's possible to run this method in a background thread to copy the authToken - if (isOAuth || isSaml) { - accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken); - } - */ + /* TODO - study if it's possible to run this method in a background thread to copy the authToken + if (isOAuth || isSaml) { + accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken); + } + */ // don't forget the account saved in preferences as the current one - if (currentAccount != null && currentAccount.name.equals(account.name)) { + if (currentAccount.name.equals(account.name)) { AccountUtils.setCurrentOwnCloudAccount(context, newAccountName); } // remove the old account - accountMgr.removeAccount(account, null, null); // will assume it succeeds, not a big deal otherwise + accountMgr.removeAccount(account, null, null); + // will assume it succeeds, not a big deal otherwise } else { // servers which base URL is in the root of their domain need no change @@ -242,7 +243,9 @@ public class AccountUtils { // at least, upgrade account version Log_OC.d(TAG, "Setting version " + ACCOUNT_VERSION + " to " + newAccountName); - accountMgr.setUserData(newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION)); + accountMgr.setUserData( + newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION) + ); } } @@ -267,4 +270,23 @@ public class AccountUtils { return url; } + /** + * Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER + * + * @param account ownCloud account + * @return Version of the OC server corresponding to account, according to the data saved + * in the system AccountManager + */ + public static OwnCloudVersion getServerVersion(Account account) { + OwnCloudVersion serverVersion = null; + if (account != null) { + AccountManager accountMgr = AccountManager.get(MainApp.getAppContext()); + String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION); + if (serverVersionStr != null) { + serverVersion = new OwnCloudVersion(serverVersionStr); + } + } + return serverVersion; + } + } diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index e7b33979..e8f42d99 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -54,7 +54,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.View.OnTouchListener; -import android.view.Window; import android.view.inputmethod.EditorInfo; import android.webkit.HttpAuthHandler; import android.webkit.SslErrorHandler; @@ -348,11 +347,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity if (mAccount != null) { mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL); // TODO do next in a setter for mBaseUrl - mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); - String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); - if (ocVersion != null) { - mServerInfo.mVersion = new OwnCloudVersion(ocVersion); - } + mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); + mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount); } else { mServerInfo.mBaseUrl = getString(R.string.server_url).trim(); mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); @@ -570,7 +566,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity * intended to defer the processing of the redirection caught in * {@link #onNewIntent(Intent)} until {@link #onResume()} * - * See {@link #onSaveInstanceState(Bundle)} + * See {@link super#onSaveInstanceState(Bundle)} */ @Override protected void onSaveInstanceState(Bundle outState) { @@ -1136,7 +1132,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity if(url.toLowerCase().endsWith(AccountUtils.WEBDAV_PATH_4_0_AND_LATER)){ url = url.substring(0, url.length() - AccountUtils.WEBDAV_PATH_4_0_AND_LATER.length()); } - return (url != null ? url : ""); + return url; } @@ -1717,7 +1713,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } - private void getRemoteUserNameOperation(String sessionCookie, boolean followRedirects) { + private void getRemoteUserNameOperation(String sessionCookie) { Intent getUserNameIntent = new Intent(); getUserNameIntent.setAction(OperationsService.ACTION_GET_USER_NAME); @@ -1735,7 +1731,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity if (sessionCookie != null && sessionCookie.length() > 0) { Log_OC.d(TAG, "Successful SSO - time to save the account"); mAuthToken = sessionCookie; - getRemoteUserNameOperation(sessionCookie, true); + getRemoteUserNameOperation(sessionCookie); Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG); if (fd != null && fd instanceof DialogFragment) { Dialog d = ((DialogFragment)fd).getDialog(); @@ -1769,7 +1765,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity X509Certificate x509Certificate, SslError error, SslErrorHandler handler ) { // Show a dialog with the certificate info - SslUntrustedCertDialog dialog = null; + SslUntrustedCertDialog dialog; if (x509Certificate == null) { dialog = SslUntrustedCertDialog.newInstanceForEmptySslError(error, handler); } else { @@ -1861,8 +1857,6 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity doOnResumeAndBound(); - } else { - return; } } @@ -1881,8 +1875,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /** * Create and show dialog for request authentication to the user - * @param webView - * @param handler + * @param webView Web view to emebd into the authentication dialog. + * @param handler Object responsible for catching and recovering HTTP authentication fails. */ public void createAuthenticationDialog(WebView webView, HttpAuthHandler handler) { diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 7825b959..0e59a834 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -29,7 +29,6 @@ import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; import android.accounts.Account; -import android.accounts.AccountManager; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; @@ -43,10 +42,10 @@ import android.widget.ImageView; import com.owncloud.android.MainApp; import com.owncloud.android.R; +import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; -import com.owncloud.android.lib.common.accounts.AccountUtils.Constants; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.ui.adapter.DiskLruImageCache; @@ -61,8 +60,7 @@ public class ThumbnailsCacheManager { private static final String TAG = ThumbnailsCacheManager.class.getSimpleName(); private static final String CACHE_FOLDER = "thumbnailCache"; - private static final String MINOR_SERVER_VERSION_FOR_THUMBS = "7.8.0"; - + private static final Object mThumbnailsDiskCacheLock = new Object(); private static DiskLruImageCache mThumbnailCache = null; private static boolean mThumbnailCacheStarting = true; @@ -71,7 +69,6 @@ public class ThumbnailsCacheManager { private static final CompressFormat mCompressFormat = CompressFormat.JPEG; private static final int mCompressQuality = 70; private static OwnCloudClient mClient = null; - private static String mServerVersion = null; public static Bitmap mDefaultImg = BitmapFactory.decodeResource( @@ -130,10 +127,12 @@ public class ThumbnailsCacheManager { while (mThumbnailCacheStarting) { try { mThumbnailsDiskCacheLock.wait(); - } catch (InterruptedException e) {} + } catch (InterruptedException e) { + Log_OC.e(TAG, "Wait in mThumbnailsDiskCacheLock was interrupted", e); + } } if (mThumbnailCache != null) { - return (Bitmap) mThumbnailCache.getBitmap(key); + return mThumbnailCache.getBitmap(key); } } return null; @@ -167,9 +166,6 @@ public class ThumbnailsCacheManager { try { if (mAccount != null) { - AccountManager accountMgr = AccountManager.get(MainApp.getAppContext()); - - mServerVersion = accountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION); OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, MainApp.getAppContext()); mClient = OwnCloudClientManagerFactory.getDefaultSingleton(). @@ -182,8 +178,7 @@ public class ThumbnailsCacheManager { thumbnail = doOCFileInBackground(); } else if (mFile instanceof File) { thumbnail = doFileInBackground(); - } else { - // do nothing + //} else { do nothing } }catch(Throwable t){ @@ -202,15 +197,15 @@ public class ThumbnailsCacheManager { bitmap = null; } - if (mImageViewReference != null && bitmap != null) { + if (bitmap != null) { final ImageView imageView = mImageViewReference.get(); final ThumbnailGenerationTask bitmapWorkerTask = getBitmapWorkerTask(imageView); - if (this == bitmapWorkerTask && imageView != null) { + if (this == bitmapWorkerTask) { String tagId = ""; if (mFile instanceof OCFile){ tagId = String.valueOf(((OCFile)mFile).getFileId()); } else if (mFile instanceof File){ - tagId = String.valueOf(((File)mFile).hashCode()); + tagId = String.valueOf(mFile.hashCode()); } if (String.valueOf(imageView.getTag()).equals(tagId)) { imageView.setImageBitmap(bitmap); @@ -247,17 +242,16 @@ public class ThumbnailsCacheManager { private int getThumbnailDimension(){ // Converts dp to pixel Resources r = MainApp.getAppContext().getResources(); - return (int) Math.round(r.getDimension(R.dimen.file_icon_size_grid)); + return Math.round(r.getDimension(R.dimen.file_icon_size_grid)); } private Bitmap doOCFileInBackground() { - Bitmap thumbnail = null; OCFile file = (OCFile)mFile; final String imageKey = String.valueOf(file.getRemoteId()); // Check disk cache in background thread - thumbnail = getBitmapFromDiskCache(imageKey); + Bitmap thumbnail = getBitmapFromDiskCache(imageKey); // Not found in disk cache if (thumbnail == null || file.needsUpdateThumbnail()) { @@ -277,19 +271,16 @@ public class ThumbnailsCacheManager { } else { // Download thumbnail from server - if (mClient != null && mServerVersion != null) { - OwnCloudVersion serverOCVersion = new OwnCloudVersion(mServerVersion); - if (serverOCVersion.compareTo( - new OwnCloudVersion(MINOR_SERVER_VERSION_FOR_THUMBS)) >= 0) { + OwnCloudVersion serverOCVersion = AccountUtils.getServerVersion(mAccount); + if (mClient != null && serverOCVersion != null) { + if (serverOCVersion.supportsRemoteThumbnails()) { try { - int status = -1; - String uri = mClient.getBaseUri() + "" + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px + Uri.encode(file.getRemotePath(), "/"); Log_OC.d("Thumbnail", "URI: " + uri); GetMethod get = new GetMethod(uri); - status = mClient.executeMethod(get); + int status = mClient.executeMethod(get); if (status == HttpStatus.SC_OK) { // byte[] bytes = get.getResponseBody(); // Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, @@ -318,13 +309,12 @@ public class ThumbnailsCacheManager { } private Bitmap doFileInBackground() { - Bitmap thumbnail = null; File file = (File)mFile; final String imageKey = String.valueOf(file.hashCode()); // Check disk cache in background thread - thumbnail = getBitmapFromDiskCache(imageKey); + Bitmap thumbnail = getBitmapFromDiskCache(imageKey); // Not found in disk cache if (thumbnail == null) { diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index 5e6741bb..75fae370 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -24,7 +24,6 @@ package com.owncloud.android.files; import org.apache.http.protocol.HTTP; import android.accounts.Account; -import android.accounts.AccountManager; import android.content.Intent; import android.net.Uri; import android.support.v4.app.DialogFragment; @@ -32,11 +31,11 @@ import android.webkit.MimeTypeMap; import android.widget.Toast; import com.owncloud.android.R; +import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; -import com.owncloud.android.lib.common.accounts.AccountUtils.Constants; import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.OwnCloudVersion; @@ -70,19 +69,25 @@ public class FileOperationsHelper { Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW); intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), file.getMimetype()); - intentForSavedMimeType.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intentForSavedMimeType.setFlags( + Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION + ); Intent intentForGuessedMimeType = null; if (storagePath.lastIndexOf('.') >= 0) { - String guessedMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1)); + String guessedMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension( + storagePath.substring(storagePath.lastIndexOf('.') + 1) + ); if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) { intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW); intentForGuessedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), guessedMimeType); - intentForGuessedMimeType.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); + intentForGuessedMimeType.setFlags( + Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION + ); } } - Intent chooserIntent = null; + Intent chooserIntent; if (intentForGuessedMimeType != null) { chooserIntent = Intent.createChooser(intentForGuessedMimeType, mFileActivity.getString(R.string.actionbar_open_with)); } else { @@ -113,7 +118,9 @@ public class FileOperationsHelper { } else { // Show a Message - Toast t = Toast.makeText(mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG); + Toast t = Toast.makeText( + mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG + ); t.show(); } } @@ -151,10 +158,8 @@ public class FileOperationsHelper { */ public boolean isSharedSupported() { if (mFileActivity.getAccount() != null) { - AccountManager accountManager = AccountManager.get(mFileActivity); - - String version = accountManager.getUserData(mFileActivity.getAccount(), Constants.KEY_OC_VERSION); - return (new OwnCloudVersion(version)).isSharedSupported(); + OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount()); + return (serverVersion != null && serverVersion.isSharedSupported()); } return false; } @@ -321,11 +326,8 @@ public class FileOperationsHelper { */ public boolean isVersionWithForbiddenCharacters() { if (mFileActivity.getAccount() != null) { - AccountManager accountManager = AccountManager.get(mFileActivity); - - String version = accountManager.getUserData(mFileActivity.getAccount(), - Constants.KEY_OC_VERSION); - return (new OwnCloudVersion(version)).isVersionWithForbiddenCharacters(); + OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount()); + return (serverVersion != null && serverVersion.isVersionWithForbiddenCharacters()); } return false; } diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 8beff92d..98ad87e2 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -48,7 +48,6 @@ import android.os.Process; import android.support.v4.app.NotificationCompat; import android.webkit.MimeTypeMap; -import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; @@ -58,7 +57,6 @@ import com.owncloud.android.db.DbHandler; import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; -import com.owncloud.android.lib.common.accounts.AccountUtils.Constants; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -118,7 +116,8 @@ public class FileUploader extends Service private Account mLastAccount = null; private FileDataStorageManager mStorageManager; - private ConcurrentMap mPendingUploads = new ConcurrentHashMap(); + private ConcurrentMap mPendingUploads = + new ConcurrentHashMap(); private UploadFileOperation mCurrentUpload = null; private NotificationManager mNotificationManager; @@ -130,7 +129,7 @@ public class FileUploader extends Service public static String getUploadFinishMessage() { - return FileUploader.class.getName().toString() + UPLOAD_FINISH_MESSAGE; + return FileUploader.class.getName() + UPLOAD_FINISH_MESSAGE; } /** @@ -230,7 +229,7 @@ public class FileUploader extends Service if (uploadType == UPLOAD_SINGLE_FILE) { if (intent.hasExtra(KEY_FILE)) { - files = new OCFile[] { (OCFile) intent.getParcelableExtra(KEY_FILE) }; + files = new OCFile[] { intent.getParcelableExtra(KEY_FILE) }; } else { localPaths = new String[] { intent.getStringExtra(KEY_LOCAL_FILE) }; @@ -283,7 +282,7 @@ public class FileUploader extends Service files = new OCFile[localPaths.length]; for (int i = 0; i < localPaths.length; i++) { files[i] = obtainNewOCFileToUpload(remotePaths[i], localPaths[i], - ((mimeTypes != null) ? mimeTypes[i] : (String) null), storageManager); + ((mimeTypes != null) ? mimeTypes[i] : null), storageManager); if (files[i] == null) { // TODO @andomaex add failure Notification return Service.START_NOT_STICKY; @@ -291,9 +290,7 @@ public class FileUploader extends Service } } - AccountManager aMgr = AccountManager.get(this); - String version = aMgr.getUserData(account, Constants.KEY_OC_VERSION); - OwnCloudVersion ocv = new OwnCloudVersion(version); + OwnCloudVersion ocv = AccountUtils.getServerVersion(account); boolean chunked = FileUploader.chunkedUploadIsSupported(ocv); AbstractList requestedUploads = new Vector(); @@ -383,7 +380,8 @@ public class FileUploader extends Service * Map of listeners that will be reported about progress of uploads from a * {@link FileUploaderBinder} instance */ - private Map mBoundListeners = new HashMap(); + private Map mBoundListeners = + new HashMap(); /** * Cancels a pending or current upload of a remote file. @@ -392,7 +390,7 @@ public class FileUploader extends Service * @param file A file in the queue of pending uploads */ public void cancel(Account account, OCFile file) { - UploadFileOperation upload = null; + UploadFileOperation upload; synchronized (mPendingUploads) { upload = mPendingUploads.remove(buildRemoteName(account, file)); } @@ -563,7 +561,7 @@ public class FileUploader extends Service notifyUploadStart(mCurrentUpload); - RemoteOperationResult uploadResult = null, grantResult = null; + RemoteOperationResult uploadResult = null, grantResult; try { /// prepare client object to send requests to the ownCloud server @@ -610,7 +608,7 @@ public class FileUploader extends Service mPendingUploads.remove(uploadKey); Log_OC.i(TAG, "Remove CurrentUploadItem from pending upload Item Map."); } - if (uploadResult.isException()) { + if (uploadResult != null && uploadResult.isException()) { // enforce the creation of a new client object for next uploads; // this grant that a new socket will be created in the future if // the current exception is due to an abrupt lose of network connection @@ -845,7 +843,7 @@ public class FileUploader extends Service int tickerId = (uploadResult.isSuccess()) ? R.string.uploader_upload_succeeded_ticker : R.string.uploader_upload_failed_ticker; - String content = null; + String content; // check credentials error boolean needsToUpdateCredentials = ( @@ -964,8 +962,8 @@ public class FileUploader extends Service /** * Checks if content provider, using the content:// scheme, returns a file with mime-type * 'application/pdf' but file has not extension - * @param localPath - * @param mimeType + * @param localPath Full path to a file in the local file system. + * @param mimeType MIME type of the file. * @return true if is needed to add the pdf file extension to the file */ private boolean isPdfFileFromContentProviderWithoutExtension(String localPath, @@ -977,7 +975,7 @@ public class FileUploader extends Service /** * Remove uploads of an account - * @param accountName + * @param accountName Name of an OC account */ private void cancelUploadForAccount(String accountName){ // this can be slow if there are many uploads :( diff --git a/src/com/owncloud/android/services/OperationsService.java b/src/com/owncloud/android/services/OperationsService.java index 82114140..7667e90a 100644 --- a/src/com/owncloud/android/services/OperationsService.java +++ b/src/com/owncloud/android/services/OperationsService.java @@ -34,13 +34,13 @@ import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; import com.owncloud.android.lib.common.OwnCloudCredentials; import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; -import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; 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.shares.ShareType; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation; import com.owncloud.android.operations.common.SyncOperation; import com.owncloud.android.operations.CreateFolderOperation; @@ -354,12 +354,7 @@ public class OperationsService extends Service { return true; //Log_OC.wtf(TAG, "Sending callback later"); } else { - if (!mServiceHandler.mPendingOperations.isEmpty()) { - return true; - } else { - return false; - } - //Log_OC.wtf(TAG, "Not finished yet"); + return (!mServiceHandler.mPendingOperations.isEmpty()); } } @@ -445,9 +440,9 @@ public class OperationsService extends Service { mOwnCloudClient = OwnCloudClientManagerFactory.getDefaultSingleton(). getClientFor(ocAccount, mService); - AccountManager am = AccountManager.get(mService.getApplicationContext()); - String version = am.getUserData(mLastTarget.mAccount, - AccountUtils.Constants.KEY_OC_VERSION); + OwnCloudVersion version = com.owncloud.android.authentication.AccountUtils.getServerVersion( + mLastTarget.mAccount + ); mOwnCloudClient.setOwnCloudVersion(version); mStorageManager = new FileDataStorageManager( diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index b1c0ffbe..7c3f6f50 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -49,7 +49,6 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.GravityCompat; -import android.support.v7.app.ActionBar; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -322,7 +321,7 @@ public class FileDisplayActivity extends HookActivity startPlaybackPosition, autoplay); } else { - secondFragment = new FileDetailFragment(file, getAccount()); + secondFragment = FileDetailFragment.newInstance(file, getAccount()); } } return secondFragment; @@ -621,10 +620,7 @@ public class FileDisplayActivity extends HookActivity String[] filePaths = data.getStringArrayExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES); if (filePaths != null) { String[] remotePaths = new String[filePaths.length]; - String remotePathBase = ""; - - if (!remotePathBase.endsWith(OCFile.PATH_SEPARATOR)) - remotePathBase += OCFile.PATH_SEPARATOR; + String remotePathBase = getCurrentDir().getRemotePath(); for (int j = 0; j< remotePaths.length; j++) { remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName(); } @@ -1149,7 +1145,7 @@ public class FileDisplayActivity extends HookActivity */ @Override public void showDetails(OCFile file) { - Fragment detailFragment = new FileDetailFragment(file, getAccount()); + Fragment detailFragment = FileDetailFragment.newInstance(file, getAccount()); setSecondFragment(detailFragment); updateFragmentsVisibility(true); updateActionBarTitleAndHomeButton(file); @@ -1641,7 +1637,7 @@ public class FileDisplayActivity extends HookActivity * @param file {@link OCFile} to download and preview. */ public void startDownloadForPreview(OCFile file) { - Fragment detailFragment = new FileDetailFragment(file, getAccount()); + Fragment detailFragment = FileDetailFragment.newInstance(file, getAccount()); setSecondFragment(detailFragment); mWaitingToPreview = file; requestForDownload(); diff --git a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 2432380f..941654b2 100644 --- a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -397,8 +397,8 @@ public class ExtendedListFragment extends Fragment mListFooterView.invalidate(); } else { -// mGridView.removeFooterView(mGridFooterView); -// mListView.removeFooterView(mListFooterView); + mGridView.removeFooterView(mGridFooterView); + mListView.removeFooterView(mListFooterView); } } diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index bff9cea4..4f099e49 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -68,12 +68,34 @@ public class FileDetailFragment extends FileFragment implements OnClickListener private static final String TAG = FileDetailFragment.class.getSimpleName(); public static final String FTAG_CONFIRMATION = "REMOVE_CONFIRMATION_FRAGMENT"; public static final String FTAG_RENAME_FILE = "RENAME_FILE_FRAGMENT"; - + + private static final String ARG_FILE = "FILE"; + private static final String ARG_ACCOUNT = "ACCOUNT"; + + + /** + * Public factory method to create new FileDetailFragment instances. + * + * When 'fileToDetail' or 'ocAccount' are null, creates a dummy layout (to use when a file wasn't tapped before). + * + * @param fileToDetail An {@link OCFile} to show in the fragment + * @param account An ownCloud account; needed to start downloads + * @return New fragment with arguments set + */ + public static FileDetailFragment newInstance(OCFile fileToDetail, Account account) { + FileDetailFragment frag = new FileDetailFragment(); + Bundle args = new Bundle(); + args.putParcelable(ARG_FILE, fileToDetail); + args.putParcelable(ARG_ACCOUNT, account); + frag.setArguments(args); + return frag; + } /** * Creates an empty details fragment. * - * It's necessary to keep a public constructor without parameters; the system uses it when tries to reinstantiate a fragment automatically. + * It's necessary to keep a public constructor without parameters; the system uses it when tries + * to reinstantiate a fragment automatically. */ public FileDetailFragment() { super(); @@ -82,22 +104,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener mProgressListener = null; } - /** - * Creates a details fragment. - * - * When 'fileToDetail' or 'ocAccount' are null, creates a dummy layout (to use when a file wasn't tapped before). - * - * @param fileToDetail An {@link OCFile} to show in the fragment - * @param ocAccount An ownCloud account; needed to start downloads - */ - public FileDetailFragment(OCFile fileToDetail, Account ocAccount) { - super(fileToDetail); - mAccount = ocAccount; - mLayout = R.layout.file_details_empty; - mProgressListener = null; - } - - + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -108,7 +115,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - + + setFile((OCFile) getArguments().getParcelable(ARG_FILE)); + mAccount = getArguments().getParcelable(ARG_ACCOUNT); + if (savedInstanceState != null) { setFile((OCFile)savedInstanceState.getParcelable(FileActivity.EXTRA_FILE)); mAccount = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT); @@ -118,9 +128,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener mLayout = R.layout.file_details_fragment; } - View view = null; - view = inflater.inflate(mLayout, null); - mView = view; + mView = inflater.inflate(mLayout, null); if (mLayout == R.layout.file_details_fragment) { mView.findViewById(R.id.fdKeepInSync).setOnClickListener(this); @@ -128,9 +136,9 @@ public class FileDetailFragment extends FileFragment implements OnClickListener mProgressListener = new ProgressListener(progressBar); mView.findViewById(R.id.fdCancelBtn).setOnClickListener(this); } - + updateFileDetails(false, false); - return view; + return mView; } @Override @@ -337,10 +345,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener setFilename(file.getFileName()); setFiletype(file.getMimetype(), file.getFileName()); setFilesize(file.getFileLength()); - if(ocVersionSupportsTimeCreated()){ - setTimeCreated(file.getCreationTimestamp()); - } - + setTimeModified(file.getModificationTimestamp()); CheckBox cb = (CheckBox)getView().findViewById(R.id.fdKeepInSync); @@ -390,13 +395,13 @@ public class FileDetailFragment extends FileFragment implements OnClickListener /** * Updates the MIME type in view - * @param mimetype to set - * @param filename + * @param mimetype MIME type to set + * @param filename Name of the file, to deduce the icon to use in case the MIME type is not precise enough */ private void setFiletype(String mimetype, String filename) { TextView tv = (TextView) getView().findViewById(R.id.fdType); if (tv != null) { - String printableMimetype = DisplayUtils.convertMIMEtoPrettyPrint(mimetype);; + String printableMimetype = DisplayUtils.convertMIMEtoPrettyPrint(mimetype); tv.setText(printableMimetype); } ImageView iv = (ImageView) getView().findViewById(R.id.fdIcon); @@ -416,20 +421,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } /** - * Updates the time that the file was created in view - * @param milliseconds Unix time to set - */ - private void setTimeCreated(long milliseconds){ - TextView tv = (TextView) getView().findViewById(R.id.fdCreated); - TextView tvLabel = (TextView) getView().findViewById(R.id.fdCreatedLabel); - if(tv != null){ - tv.setText(DisplayUtils.unixTimeToHumanReadable(milliseconds)); - tv.setVisibility(View.VISIBLE); - tvLabel.setVisibility(View.VISIBLE); - } - } - - /** * Updates the time that the file was last modified * @param milliseconds Unix time to set */ @@ -492,27 +483,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } - /** - * In ownCloud 3.X.X and 4.X.X there is a bug that SabreDAV does not return - * the time that the file was created. There is a chance that this will - * be fixed in future versions. Use this method to check if this version of - * ownCloud has this fix. - * @return True, if ownCloud the ownCloud version is supporting creation time - */ - private boolean ocVersionSupportsTimeCreated(){ - /*if(mAccount != null){ - AccountManager accManager = (AccountManager) getActivity() - .getSystemService(Context.ACCOUNT_SERVICE); - OwnCloudVersion ocVersion = new OwnCloudVersion(accManager - .getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION)); - if(ocVersion.compareTo(new OwnCloudVersion(0x030000)) < 0) { - return true; - } - }*/ - return false; - } - - public void listenForTransferProgress() { if (mProgressListener != null) { if (mContainerActivity.getFileDownloaderBinder() != null) { @@ -568,6 +538,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener mLastPercent = percent; } - }; + } } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 06213234..424b0d59 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -36,10 +36,13 @@ import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; import com.owncloud.android.R; +import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.FileMenuFilter; import com.owncloud.android.lib.common.utils.Log_OC; +import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.activity.FolderPickerActivity; import com.owncloud.android.ui.activity.OnEnforceableRefreshListener; @@ -54,7 +57,7 @@ import com.owncloud.android.utils.FileStorageUtils; /** * A Fragment that lists all files and folders in a given path. * - * TODO refactorize to get rid of direct dependency on FileDisplayActivity + * TODO refactor to get rid of direct dependency on FileDisplayActivity */ public class OCFileListFragment extends ExtendedListFragment { @@ -68,8 +71,6 @@ public class OCFileListFragment extends ExtendedListFragment { private static final String KEY_FILE = MY_PACKAGE + ".extra.FILE"; - private final static Double THUMBNAIL_THRESHOLD = 0.5; - private FileFragment.ContainerActivity mContainerActivity; private OCFile mFile = null; @@ -429,7 +430,10 @@ public class OCFileListFragment extends ExtendedListFragment { setFooterText(generateFooterText(filesCount, foldersCount)); // decide grid vs list view - if (((double)imagesCount / (double)filesCount) >= THUMBNAIL_THRESHOLD) { + OwnCloudVersion version = AccountUtils.getServerVersion( + ((FileActivity)mContainerActivity).getAccount()); + if (version != null && version.supportsRemoteThumbnails() && + imagesCount > 0 && imagesCount == filesCount) { switchToGridView(); } else { switchToListView();