-Subproject commit 5d1f0690036c556ec299881c339959de891fdf46
+Subproject commit f5fbca24becbb01660abe2a7013c1b536ea8a301
<item>Biggest - Smallest</item>-->
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<string name="drawer_item_accounts">Accounts</string>-->
+ <string name="drawer_item_all_files">Všechny soubory</string>
<!--TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
+ <string name="drawer_item_settings">Nastavení</string>
+ <string name="drawer_item_logs">Logy</string>
+ <string name="drawer_close">Zavřít</string>
<string name="prefs_category_general">Obecné</string>
<string name="prefs_category_more">Více</string>
<string name="prefs_accounts">Účty</string>
<string name="download_folder_failed_content">Download af %1$s mappe kunne ikke fuldføres</string>
<string name="shared_subject_header">delt</string>
<string name="with_you_subject_header">med dig</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">Genopfrisk forbindelsen</string>
<string name="auth_host_address">Serveradresse</string>
<string name="common_error_out_memory">Ikke tilstrækkelig hukommelse</string>
<!--<string name="drawer_item_accounts">Accounts</string>-->
<!--TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
+ <string name="drawer_item_settings">Einstellungen</string>
<string name="prefs_category_general">Allgemein</string>
<string name="prefs_category_more">Mehr</string>
<string name="prefs_accounts">Konten</string>
<string name="download_folder_failed_content">Η λήψη του φακέλου %1$s δεν ολοκληρώθηκε με επιτυχία.</string>
<string name="shared_subject_header">διαμοιρασμένα</string>
<string name="with_you_subject_header">με εσάς</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
+ <string name="subject_token">Ο %1$s διαμοιράστηκε το \"%2$s\" με εσάς</string>
<string name="auth_refresh_button">Ανανέωση σύνδεσης</string>
<string name="auth_host_address">Διεύθυνση διακομιστή</string>
<string name="common_error_out_memory">Δεν υπάρχει αρκετή μνήμη</string>
<string name="download_folder_failed_content">La descarga de la carpeta %1$s no ha podido ser completada</string>
<string name="shared_subject_header">compartido</string>
<string name="with_you_subject_header">con usted</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
+ <string name="subject_token">%1$s compartió \"%2$s\" conmigo</string>
<string name="auth_refresh_button">Refrescar la conexión</string>
<string name="auth_host_address">Dirección del servidor</string>
<string name="common_error_out_memory">No hay suficiente memoria</string>
<string name="prefs_category_security">Tietoturva</string>
<string name="shared_subject_header">jaettu</string>
<string name="with_you_subject_header">kanssasi</string>
+ <string name="subject_token">%1$s jakoi kohteen \"%2$s\" kanssasi</string>
<string name="auth_refresh_button">Päivitä yhteys</string>
<string name="auth_host_address">Palvelimen osoite</string>
<string name="common_error_out_memory">Muistia ei ole riittävästi</string>
<string name="filedetails_download">Télécharger</string>
<string name="filedetails_sync_file">Actualiser le fichier</string>
<string name="filedetails_renamed_in_upload_msg">Le fichier a été renommé en %s pendant le téléversement</string>
- <string name="list_layout">Disposition en liste</string>
+ <string name="list_layout">Affichage en liste</string>
<string name="action_share_file">Partager le lien</string>
<string name="action_unshare_file">Ne plus partager ce lien</string>
<string name="common_yes">Oui</string>
<string name="download_folder_failed_content">Le téléchargement de %1$s dossier(s) n\'a pas pu être achevé</string>
<string name="shared_subject_header">partagé</string>
<string name="with_you_subject_header">avec vous</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
+ <string name="subject_token">%1$s a partagé \"%2$s\" avec vous</string>
<string name="auth_refresh_button">Actualiser la connexion</string>
<string name="auth_host_address">Adresse du serveur</string>
<string name="common_error_out_memory">Mémoire insuffisante</string>
<string name="download_folder_failed_content">Non foi posíbel completar a descarga do cartafol %1$s</string>
<string name="shared_subject_header">compartido</string>
<string name="with_you_subject_header">con vostede</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
+ <string name="subject_token">%1$s compartiu «%2$s» con vostede</string>
<string name="auth_refresh_button">Actualizar a conexión</string>
<string name="auth_host_address">Enderezo do servidor</string>
<string name="common_error_out_memory">Non hai memoria abondo</string>
<string name="download_folder_failed_content">Lo scaricamento della cartella %1$s non può essere completato</string>
<string name="shared_subject_header">condiviso</string>
<string name="with_you_subject_header">con te</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">Aggiorna la connessione</string>
<string name="auth_host_address">Indirizzo del server</string>
<string name="common_error_out_memory">Memoria insufficiente</string>
<string name="download_folder_failed_content">Nedlasting av %1$s mappen kunne ikke fullføres</string>
<string name="shared_subject_header">delte</string>
<string name="with_you_subject_header">med deg</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">Oppfrisk forbindelse</string>
<string name="auth_host_address">Server-adresse</string>
<string name="common_error_out_memory">Ikke nok minne</string>
<string name="download_folder_failed_content">Download van %1$s map kon niet worden voltooid</string>
<string name="shared_subject_header">gedeeld</string>
<string name="with_you_subject_header">met u</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
+ <string name="subject_token">%1$s deelde \"%2$s\" met u</string>
<string name="auth_refresh_button">Verversen verbinding</string>
<string name="auth_host_address">Serveradres</string>
<string name="common_error_out_memory">Niet voldoende geheugen</string>
<string name="download_folder_failed_content">Baixar %1$s da pasta não pode ser completado</string>
<string name="shared_subject_header">compartilhado</string>
<string name="with_you_subject_header">com você</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">Reinicializar conexão</string>
<string name="auth_host_address">Endereço do servidor</string>
<string name="common_error_out_memory">Não há memoria suficiente</string>
<string name="download_folder_failed_content">Загрузка папки %1$s не может быть завершена</string>
<string name="shared_subject_header">поделился</string>
<string name="with_you_subject_header">с вами</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
+ <string name="subject_token">%1$s предоставил вам доступ к \"%2$s\"</string>
<string name="auth_refresh_button">Обновить соединение</string>
<string name="auth_host_address">Адрес сервера</string>
<string name="common_error_out_memory">Недостаточно памяти</string>
<item>Biggest - Smallest</item>-->
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<string name="drawer_item_accounts">Accounts</string>-->
+ <string name="drawer_item_all_files">Všetky súbory</string>
<!--TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
+ <string name="drawer_item_settings">Nastavenia</string>
+ <string name="drawer_item_logs">Logy</string>
+ <string name="drawer_close">Zavrieť</string>
<string name="prefs_category_general">Všeobecné</string>
<string name="prefs_category_more">Viac</string>
<string name="prefs_accounts">Účty</string>
<string name="foreign_files_local_text">Lokálne: %1$s</string>
<string name="foreign_files_remote_text">Vzdialené: %1$s</string>
<string name="upload_query_move_foreign_files">Nie je dostatok miesta na skopírovanie vybraných súborov do priečinka %1$s. Želáte si ich namiesto toho presunúť?</string>
+ <string name="pass_code_enter_pass_code">Prosím, vložte svoje heslo:</string>
+ <string name="pass_code_configure_your_pass_code">Vložte svoje heslo</string>
+ <string name="pass_code_reenter_your_pass_code">Prosím, vložte znovu svoje heslo:</string>
+ <string name="pass_code_remove_your_pass_code">Zmazať svoje heslo</string>
<string name="media_notif_ticker">Prehrávač hudby %1$s</string>
<string name="media_state_playing">%1$s (prehráva)</string>
<string name="media_state_loading">%1$s (načítava)</string>
<string name="share_link_file_error">Pri pokuse o zdieľanie tohto súboru alebo priečinka došlo k chybe</string>
<string name="unshare_link_file_no_exist">Nemožno ukončiť zdieľanie. Skontrolujte, či súbor existuje</string>
<string name="unshare_link_file_error">Pri pokuse zrušiť zdieľanie tohto súboru alebo priečinka došlo k chybe</string>
+ <string name="share_link_password_title">Vložte heslo</string>
+ <string name="share_link_empty_password">Musíte vložiť heslo</string>
<string name="activity_chooser_send_file_title">Odoslať</string>
<string name="copy_link">Kopíruj odkaz</string>
<string name="clipboard_text_copied">Skopírované do schránky</string>
<string name="prefs_category_security">Zabezpečenie</string>
<string name="prefs_instant_video_upload_path_title">Cesta pre nahrávanie videí</string>
<string name="download_folder_failed_content">Sťahovanie %1$s priečinka nebolo dokončené</string>
+ <string name="shared_subject_header">zdieľané</string>
+ <string name="with_you_subject_header">s vami</string>
+ <string name="subject_token">%1$s vám zdieľal \"%2$s\"</string>
+ <string name="auth_refresh_button">Obnoviť pripojenie</string>
<string name="auth_host_address">Adresa servera</string>
+ <string name="common_error_out_memory">Nedostatok pamäte</string>
+ <string name="username">Používateľské meno</string>
</resources>
<string name="download_folder_failed_content">Imenika %1$s ni mogoče prejeti v celoti</string>
<string name="shared_subject_header">v souporabi</string>
<string name="with_you_subject_header">z vami</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">Osveži povezavo</string>
<string name="auth_host_address">Naslov strežnika</string>
<string name="common_error_out_memory">Ni dovolj pomnilnika</string>
<item>Biggest - Smallest</item>-->
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
<!--<string name="drawer_item_accounts">Accounts</string>-->
+ <string name="drawer_item_all_files">Сви фајлови</string>
<!--TODO re-enable when "On Device" is available
<string name="drawer_item_on_device">On device</string>-->
+ <string name="drawer_item_settings">Поставке</string>
+ <string name="drawer_item_logs">Записници</string>
+ <string name="drawer_close">Затвори</string>
<string name="prefs_category_general">Опште</string>
<string name="prefs_category_more">Остало</string>
<string name="prefs_accounts">Налози</string>
<string name="sync_file_nothing_to_do_msg">Садржај је већ синхронизован</string>
<string name="create_dir_fail_msg">Фасцикла се не може направити</string>
<string name="filename_forbidden_characters">Забрањени знакови: / \\ < > : \" | ? *</string>
+ <string name="filename_forbidden_charaters_from_server">Назив садржи бар један недозвољен карактер</string>
<string name="filename_empty">Назив фајла не може бити празан</string>
<string name="wait_a_moment">Сачекајте тренутак</string>
<string name="filedisplay_unexpected_bad_get_content">Неочекивани проблем. Изаберите фајл другом апликацијом</string>
<string name="prefs_category_security">Безбедност</string>
<string name="prefs_instant_video_upload_path_title">Путања отпремања видеа</string>
<string name="download_folder_failed_content">Преузимање фасцикле %1$s не може бити довршено</string>
+ <string name="shared_subject_header">дељено</string>
+ <string name="with_you_subject_header">са вама</string>
+ <string name="subject_token">%1$s подели „%2$s“ са вама</string>
<string name="auth_refresh_button">Освежи везу</string>
<string name="auth_host_address">Адреса сервера</string>
<string name="common_error_out_memory">Нема довољно меморије</string>
+ <string name="username">Корисничко име</string>
</resources>
<string name="download_folder_failed_content">การดาวน์โหลดโฟลเดอร์ %1$s อาจไม่สำเร็จ</string>
<string name="shared_subject_header">ถูกแชร์</string>
<string name="with_you_subject_header">กับคุณ</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">ฟื้นฟูการเชื่อมต่อ</string>
<string name="auth_host_address">ที่อยู่เซิร์ฟเวอร์</string>
<string name="common_error_out_memory">หน่วยความจำไม่พอ</string>
<string name="download_folder_failed_content">%1$s klasörün indirilmesi tamamlanamadı</string>
<string name="shared_subject_header">sizinle</string>
<string name="with_you_subject_header">paylaştı</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">Bağlantıyı yenile</string>
<string name="auth_host_address">Sunucu adresi</string>
<string name="common_error_out_memory">Yeterli hafıza yok</string>
<string name="download_folder_failed_content">%1$s 文件夹的下载无法完成</string>
<string name="shared_subject_header">已共享</string>
<string name="with_you_subject_header">与你</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
<string name="auth_refresh_button">刷新连接</string>
<string name="auth_host_address">服务器地址</string>
<string name="common_error_out_memory">内存不足</string>
<string name="download_folder_failed_content">%1$s 目錄的下載未完成</string>
<string name="shared_subject_header">以分享的</string>
<string name="with_you_subject_header">與你</string>
- <string name="subject_token">%1$s %2$s >>%3$s<< %4$s</string>
+ <string name="subject_token">%1$s 分享了 \"%2$s\" 給您</string>
<string name="auth_refresh_button">重新連線</string>
<string name="auth_host_address">伺服器位址</string>
<string name="username">使用者名稱</string>
if (accountName != null) {\r
Account[] ocAccounts = AccountManager.get(context).getAccountsByType(\r
MainApp.getAccountType());\r
- boolean found = false;\r
+ boolean found;\r
for (Account account : ocAccounts) {\r
found = (account.name.equals(accountName));\r
if (found) {\r
if (isOAuth) {\r
accountMgr.setUserData(newAccount, Constants.KEY_SUPPORTS_OAUTH2, "TRUE");\r
}\r
- /* TODO - study if it's possible to run this method in a background thread to copy the authToken\r
- if (isOAuth || isSaml) {\r
- accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken);\r
- }\r
- */\r
+ /* TODO - study if it's possible to run this method in a background thread to copy the authToken\r
+ if (isOAuth || isSaml) {\r
+ accountMgr.setAuthToken(newAccount, mAuthTokenType, mAuthToken);\r
+ }\r
+ */\r
\r
// don't forget the account saved in preferences as the current one\r
- if (currentAccount != null && currentAccount.name.equals(account.name)) {\r
+ if (currentAccount.name.equals(account.name)) {\r
AccountUtils.setCurrentOwnCloudAccount(context, newAccountName);\r
}\r
\r
// remove the old account\r
- accountMgr.removeAccount(account, null, null); // will assume it succeeds, not a big deal otherwise\r
+ accountMgr.removeAccount(account, null, null);\r
+ // will assume it succeeds, not a big deal otherwise\r
\r
} else {\r
// servers which base URL is in the root of their domain need no change\r
\r
// at least, upgrade account version\r
Log_OC.d(TAG, "Setting version " + ACCOUNT_VERSION + " to " + newAccountName);\r
- accountMgr.setUserData(newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION));\r
+ accountMgr.setUserData(\r
+ newAccount, Constants.KEY_OC_ACCOUNT_VERSION, Integer.toString(ACCOUNT_VERSION)\r
+ );\r
\r
}\r
}\r
return url;\r
}\r
\r
+ /**\r
+ * Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER\r
+ *\r
+ * @param account ownCloud account\r
+ * @return Version of the OC server corresponding to account, according to the data saved\r
+ * in the system AccountManager\r
+ */\r
+ public static OwnCloudVersion getServerVersion(Account account) {\r
+ OwnCloudVersion serverVersion = null;\r
+ if (account != null) {\r
+ AccountManager accountMgr = AccountManager.get(MainApp.getAppContext());\r
+ String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);\r
+ if (serverVersionStr != null) {\r
+ serverVersion = new OwnCloudVersion(serverVersionStr);\r
+ }\r
+ }\r
+ return serverVersion;\r
+ }\r
+\r
}\r
import android.view.View;\r
import android.view.View.OnFocusChangeListener;\r
import android.view.View.OnTouchListener;\r
-import android.view.Window;\r
import android.view.inputmethod.EditorInfo;\r
import android.webkit.HttpAuthHandler;\r
import android.webkit.SslErrorHandler;\r
if (mAccount != null) {\r
mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL);\r
// TODO do next in a setter for mBaseUrl\r
- mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://"); \r
- String ocVersion = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_VERSION);\r
- if (ocVersion != null) {\r
- mServerInfo.mVersion = new OwnCloudVersion(ocVersion);\r
- }\r
+ mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");\r
+ mServerInfo.mVersion = AccountUtils.getServerVersion(mAccount);\r
} else {\r
mServerInfo.mBaseUrl = getString(R.string.server_url).trim();\r
mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");\r
* intended to defer the processing of the redirection caught in \r
* {@link #onNewIntent(Intent)} until {@link #onResume()} \r
* \r
- * See {@link #onSaveInstanceState(Bundle)}\r
+ * See {@link super#onSaveInstanceState(Bundle)}\r
*/\r
@Override\r
protected void onSaveInstanceState(Bundle outState) {\r
if(url.toLowerCase().endsWith(AccountUtils.WEBDAV_PATH_4_0_AND_LATER)){\r
url = url.substring(0, url.length() - AccountUtils.WEBDAV_PATH_4_0_AND_LATER.length());\r
}\r
- return (url != null ? url : "");\r
+ return url;\r
}\r
\r
\r
}\r
\r
\r
- private void getRemoteUserNameOperation(String sessionCookie, boolean followRedirects) {\r
+ private void getRemoteUserNameOperation(String sessionCookie) {\r
\r
Intent getUserNameIntent = new Intent();\r
getUserNameIntent.setAction(OperationsService.ACTION_GET_USER_NAME);\r
if (sessionCookie != null && sessionCookie.length() > 0) {\r
Log_OC.d(TAG, "Successful SSO - time to save the account");\r
mAuthToken = sessionCookie;\r
- getRemoteUserNameOperation(sessionCookie, true);\r
+ getRemoteUserNameOperation(sessionCookie);\r
Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);\r
if (fd != null && fd instanceof DialogFragment) {\r
Dialog d = ((DialogFragment)fd).getDialog();\r
X509Certificate x509Certificate, SslError error, SslErrorHandler handler\r
) {\r
// Show a dialog with the certificate info\r
- SslUntrustedCertDialog dialog = null;\r
+ SslUntrustedCertDialog dialog;\r
if (x509Certificate == null) {\r
dialog = SslUntrustedCertDialog.newInstanceForEmptySslError(error, handler);\r
} else {\r
\r
doOnResumeAndBound();\r
\r
- } else {\r
- return;\r
}\r
\r
}\r
\r
/**\r
* Create and show dialog for request authentication to the user\r
- * @param webView\r
- * @param handler\r
+ * @param webView Web view to emebd into the authentication dialog.\r
+ * @param handler Object responsible for catching and recovering HTTP authentication fails.\r
*/\r
public void createAuthenticationDialog(WebView webView, HttpAuthHandler handler) {\r
\r
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;
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;
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;
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(
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;
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().
thumbnail = doOCFileInBackground();
} else if (mFile instanceof File) {
thumbnail = doFileInBackground();
- } else {
- // do nothing
+ //} else { do nothing
}
}catch(Throwable t){
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);
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()) {
} 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,
}
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) {
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;
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;
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 {
} 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();
}
}
*/
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;
}
*/
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;
}
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;
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;
private Account mLastAccount = null;
private FileDataStorageManager mStorageManager;
- private ConcurrentMap<String, UploadFileOperation> mPendingUploads = new ConcurrentHashMap<String, UploadFileOperation>();
+ private ConcurrentMap<String, UploadFileOperation> mPendingUploads =
+ new ConcurrentHashMap<String, UploadFileOperation>();
private UploadFileOperation mCurrentUpload = null;
private NotificationManager mNotificationManager;
public static String getUploadFinishMessage() {
- return FileUploader.class.getName().toString() + UPLOAD_FINISH_MESSAGE;
+ return FileUploader.class.getName() + UPLOAD_FINISH_MESSAGE;
}
/**
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) };
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;
}
}
- 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<String> requestedUploads = new Vector<String>();
* Map of listeners that will be reported about progress of uploads from a
* {@link FileUploaderBinder} instance
*/
- private Map<String, OnDatatransferProgressListener> mBoundListeners = new HashMap<String, OnDatatransferProgressListener>();
+ private Map<String, OnDatatransferProgressListener> mBoundListeners =
+ new HashMap<String, OnDatatransferProgressListener>();
/**
* Cancels a pending or current upload of a remote file.
* @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));
}
notifyUploadStart(mCurrentUpload);
- RemoteOperationResult uploadResult = null, grantResult = null;
+ RemoteOperationResult uploadResult = null, grantResult;
try {
/// prepare client object to send requests to the ownCloud server
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
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 = (
/**
* 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,
/**
* 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 :(
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;
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());
}
}
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(
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;
startPlaybackPosition, autoplay);
} else {
- secondFragment = new FileDetailFragment(file, getAccount());
+ secondFragment = FileDetailFragment.newInstance(file, getAccount());
}
}
return secondFragment;
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();
}
*/
@Override
public void showDetails(OCFile file) {
- Fragment detailFragment = new FileDetailFragment(file, getAccount());
+ Fragment detailFragment = FileDetailFragment.newInstance(file, getAccount());
setSecondFragment(detailFragment);
updateFragmentsVisibility(true);
updateActionBarTitleAndHomeButton(file);
* @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();
mListFooterView.invalidate();
} else {
-// mGridView.removeFooterView(mGridFooterView);
-// mListView.removeFooterView(mListFooterView);
+ mGridView.removeFooterView(mGridFooterView);
+ mListView.removeFooterView(mListFooterView);
}
}
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();
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);
@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);
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);
mProgressListener = new ProgressListener(progressBar);
mView.findViewById(R.id.fdCancelBtn).setOnClickListener(this);
}
-
+
updateFileDetails(false, false);
- return view;
+ return mView;
}
@Override
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);
/**
* 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);
}
/**
- * 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
*/
}
- /**
- * 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) {
mLastPercent = percent;
}
- };
+ }
}
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;
/**
* 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 {
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;
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();